@webority/mobile-ui 0.174.1 → 0.175.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/dist/canvas-kit/kit.js +10 -10
  2. package/dist/canvas-kit/manifest.json +1 -1
  3. package/dist/canvas-kit/release.json +5 -5
  4. package/lib/commonjs/components/Accordion/Accordion.js +1 -1
  5. package/lib/commonjs/components/AmountSlider/AmountSlider.js +1 -1
  6. package/lib/commonjs/components/AppBar/AppBar.js +1 -1
  7. package/lib/commonjs/components/AuthedImage/authedImageCache.js +1 -1
  8. package/lib/commonjs/components/Avatar/Avatar.js +1 -1
  9. package/lib/commonjs/components/Badge/Badge.js +1 -1
  10. package/lib/commonjs/components/Banner/Banner.js +1 -1
  11. package/lib/commonjs/components/BarChart/BarChart.js +1 -1
  12. package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
  13. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  14. package/lib/commonjs/components/Box/Box.js +1 -1
  15. package/lib/commonjs/components/Button/Button.js +1 -1
  16. package/lib/commonjs/components/Calendar/Calendar.js +1 -1
  17. package/lib/commonjs/components/Card/Card.js +1 -1
  18. package/lib/commonjs/components/Carousel/Carousel.js +1 -1
  19. package/lib/commonjs/components/Checkbox/Checkbox.js +1 -1
  20. package/lib/commonjs/components/Chip/Chip.js +1 -1
  21. package/lib/commonjs/components/Composer/Composer.js +1 -1
  22. package/lib/commonjs/components/Confetti/Confetti.js +1 -1
  23. package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +1 -1
  24. package/lib/commonjs/components/DecimalInput/DecimalInput.js +1 -1
  25. package/lib/commonjs/components/Descriptions/Descriptions.js +1 -1
  26. package/lib/commonjs/components/Divider/Divider.js +1 -1
  27. package/lib/commonjs/components/Drawer/Drawer.js +1 -1
  28. package/lib/commonjs/components/EmptyState/EmptyState.js +1 -1
  29. package/lib/commonjs/components/FieldBase/ChoiceText.js +1 -1
  30. package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
  31. package/lib/commonjs/components/FieldBase/useFloatingLabel.js +1 -1
  32. package/lib/commonjs/components/FilePicker/FilePicker.js +1 -1
  33. package/lib/commonjs/components/FilterChipRow/FilterChipRow.js +1 -1
  34. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  35. package/lib/commonjs/components/FormField/FormField.js +1 -1
  36. package/lib/commonjs/components/IconBadge/IconBadge.js +1 -1
  37. package/lib/commonjs/components/IconButton/IconButton.js +1 -1
  38. package/lib/commonjs/components/Input/Input.js +1 -1
  39. package/lib/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +1 -1
  40. package/lib/commonjs/components/ListItem/ListItem.js +1 -1
  41. package/lib/commonjs/components/Modal/Modal.js +1 -1
  42. package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
  43. package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
  44. package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
  45. package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  46. package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +1 -1
  47. package/lib/commonjs/components/ProfileCompletion/ProfileCompletion.js +1 -1
  48. package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
  49. package/lib/commonjs/components/ProgressRing/ProgressRing.js +1 -1
  50. package/lib/commonjs/components/Radio/Radio.js +1 -1
  51. package/lib/commonjs/components/Radio/RadioGroup.js +1 -1
  52. package/lib/commonjs/components/Rating/Rating.js +1 -1
  53. package/lib/commonjs/components/RichTextEditor/RichTextEditor.js +1 -1
  54. package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -1
  55. package/lib/commonjs/components/Screen/Screen.js +1 -1
  56. package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
  57. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
  58. package/lib/commonjs/components/Select/Select.js +1 -1
  59. package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
  60. package/lib/commonjs/components/Skeleton/SkeletonClock.js +1 -1
  61. package/lib/commonjs/components/Skeleton/SkeletonProvider.js +1 -1
  62. package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +1 -1
  63. package/lib/commonjs/components/Slider/Slider.js +1 -1
  64. package/lib/commonjs/components/SliderField/SliderField.js +1 -1
  65. package/lib/commonjs/components/Sparkline/Sparkline.js +1 -1
  66. package/lib/commonjs/components/Spinner/Spinner.js +1 -1
  67. package/lib/commonjs/components/SquircleView/SquircleView.js +1 -1
  68. package/lib/commonjs/components/StatTile/StatTile.js +1 -1
  69. package/lib/commonjs/components/StatusBadge/StatusBadge.js +1 -1
  70. package/lib/commonjs/components/Stepper/Stepper.js +1 -1
  71. package/lib/commonjs/components/Switch/Switch.js +1 -1
  72. package/lib/commonjs/components/Tabs/Tabs.js +1 -1
  73. package/lib/commonjs/components/TagInput/TagInput.js +1 -1
  74. package/lib/commonjs/components/Text/Text.js +1 -1
  75. package/lib/commonjs/components/Toast/ToastProvider.js +1 -1
  76. package/lib/commonjs/navigation/DiscardGuard.js +1 -1
  77. package/lib/commonjs/theme/ThemeContext.js +1 -1
  78. package/lib/commonjs/utils/shadows.js +1 -1
  79. package/lib/module/components/Accordion/Accordion.js +1 -1
  80. package/lib/module/components/AmountSlider/AmountSlider.js +1 -1
  81. package/lib/module/components/AppBar/AppBar.js +1 -1
  82. package/lib/module/components/AuthedImage/authedImageCache.js +1 -1
  83. package/lib/module/components/Avatar/Avatar.js +1 -1
  84. package/lib/module/components/Badge/Badge.js +1 -1
  85. package/lib/module/components/Banner/Banner.js +1 -1
  86. package/lib/module/components/BarChart/BarChart.js +1 -1
  87. package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
  88. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  89. package/lib/module/components/Box/Box.js +1 -1
  90. package/lib/module/components/Button/Button.js +1 -1
  91. package/lib/module/components/Calendar/Calendar.js +1 -1
  92. package/lib/module/components/Card/Card.js +1 -1
  93. package/lib/module/components/Carousel/Carousel.js +1 -1
  94. package/lib/module/components/Checkbox/Checkbox.js +1 -1
  95. package/lib/module/components/Chip/Chip.js +1 -1
  96. package/lib/module/components/Composer/Composer.js +1 -1
  97. package/lib/module/components/Confetti/Confetti.js +1 -1
  98. package/lib/module/components/DateRangePicker/DateRangePicker.js +1 -1
  99. package/lib/module/components/DecimalInput/DecimalInput.js +1 -1
  100. package/lib/module/components/Descriptions/Descriptions.js +1 -1
  101. package/lib/module/components/Divider/Divider.js +1 -1
  102. package/lib/module/components/Drawer/Drawer.js +1 -1
  103. package/lib/module/components/EmptyState/EmptyState.js +1 -1
  104. package/lib/module/components/FieldBase/ChoiceText.js +1 -1
  105. package/lib/module/components/FieldBase/FieldBase.js +1 -1
  106. package/lib/module/components/FieldBase/useFloatingLabel.js +1 -1
  107. package/lib/module/components/FilePicker/FilePicker.js +1 -1
  108. package/lib/module/components/FilterChipRow/FilterChipRow.js +1 -1
  109. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
  110. package/lib/module/components/FormField/FormField.js +1 -1
  111. package/lib/module/components/IconBadge/IconBadge.js +1 -1
  112. package/lib/module/components/IconButton/IconButton.js +1 -1
  113. package/lib/module/components/Input/Input.js +1 -1
  114. package/lib/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +1 -1
  115. package/lib/module/components/ListItem/ListItem.js +1 -1
  116. package/lib/module/components/Modal/Modal.js +1 -1
  117. package/lib/module/components/NumberInput/NumberInput.js +1 -1
  118. package/lib/module/components/OTPInput/OTPInput.js +1 -1
  119. package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
  120. package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  121. package/lib/module/components/PickerTrigger/PickerTrigger.js +1 -1
  122. package/lib/module/components/ProfileCompletion/ProfileCompletion.js +1 -1
  123. package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
  124. package/lib/module/components/ProgressRing/ProgressRing.js +1 -1
  125. package/lib/module/components/Radio/Radio.js +1 -1
  126. package/lib/module/components/Radio/RadioGroup.js +1 -1
  127. package/lib/module/components/Rating/Rating.js +1 -1
  128. package/lib/module/components/RichTextEditor/RichTextEditor.js +1 -1
  129. package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -1
  130. package/lib/module/components/Screen/Screen.js +1 -1
  131. package/lib/module/components/SearchBar/SearchBar.js +1 -1
  132. package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
  133. package/lib/module/components/Select/Select.js +1 -1
  134. package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
  135. package/lib/module/components/Skeleton/SkeletonClock.js +1 -1
  136. package/lib/module/components/Skeleton/SkeletonProvider.js +1 -1
  137. package/lib/module/components/SlideToConfirm/SlideToConfirm.js +1 -1
  138. package/lib/module/components/Slider/Slider.js +1 -1
  139. package/lib/module/components/SliderField/SliderField.js +1 -1
  140. package/lib/module/components/Sparkline/Sparkline.js +1 -1
  141. package/lib/module/components/Spinner/Spinner.js +1 -1
  142. package/lib/module/components/SquircleView/SquircleView.js +1 -1
  143. package/lib/module/components/StatTile/StatTile.js +1 -1
  144. package/lib/module/components/StatusBadge/StatusBadge.js +1 -1
  145. package/lib/module/components/Stepper/Stepper.js +1 -1
  146. package/lib/module/components/Switch/Switch.js +1 -1
  147. package/lib/module/components/Tabs/Tabs.js +1 -1
  148. package/lib/module/components/TagInput/TagInput.js +1 -1
  149. package/lib/module/components/Text/Text.js +1 -1
  150. package/lib/module/components/Toast/ToastProvider.js +1 -1
  151. package/lib/module/navigation/DiscardGuard.js +1 -1
  152. package/lib/module/theme/ThemeContext.js +1 -1
  153. package/lib/module/utils/shadows.js +1 -1
  154. package/lib/typescript/commonjs/components/AmountSlider/AmountSlider.d.ts +3 -2
  155. package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +4 -1
  156. package/lib/typescript/commonjs/components/AuthedImage/authedImageCache.d.ts +3 -1
  157. package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +6 -1
  158. package/lib/typescript/commonjs/components/Badge/Badge.d.ts +5 -1
  159. package/lib/typescript/commonjs/components/Banner/Banner.d.ts +3 -1
  160. package/lib/typescript/commonjs/components/BarChart/BarChart.d.ts +4 -1
  161. package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +3 -1
  162. package/lib/typescript/commonjs/components/Box/Box.d.ts +6 -3
  163. package/lib/typescript/commonjs/components/Button/Button.d.ts +4 -2
  164. package/lib/typescript/commonjs/components/Calendar/Calendar.d.ts +4 -2
  165. package/lib/typescript/commonjs/components/Card/Card.d.ts +2 -1
  166. package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +4 -1
  167. package/lib/typescript/commonjs/components/Chip/Chip.d.ts +3 -1
  168. package/lib/typescript/commonjs/components/Composer/Composer.d.ts +3 -1
  169. package/lib/typescript/commonjs/components/Confetti/Confetti.d.ts +3 -1
  170. package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +4 -2
  171. package/lib/typescript/commonjs/components/DecimalInput/DecimalInput.d.ts +4 -2
  172. package/lib/typescript/commonjs/components/Divider/Divider.d.ts +3 -2
  173. package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +3 -1
  174. package/lib/typescript/commonjs/components/EmptyState/EmptyState.d.ts +2 -1
  175. package/lib/typescript/commonjs/components/FilePicker/FilePicker.d.ts +4 -1
  176. package/lib/typescript/commonjs/components/FilterChipRow/FilterChipRow.d.ts +4 -2
  177. package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +2 -1
  178. package/lib/typescript/commonjs/components/FormField/FormField.d.ts +3 -2
  179. package/lib/typescript/commonjs/components/IconBadge/IconBadge.d.ts +4 -2
  180. package/lib/typescript/commonjs/components/IconButton/IconButton.d.ts +4 -2
  181. package/lib/typescript/commonjs/components/Input/Input.d.ts +4 -1
  182. package/lib/typescript/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +4 -1
  183. package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +2 -0
  184. package/lib/typescript/commonjs/components/Modal/Modal.d.ts +3 -1
  185. package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +4 -2
  186. package/lib/typescript/commonjs/components/OTPInput/OTPInput.d.ts +3 -2
  187. package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +4 -2
  188. package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +4 -4
  189. package/lib/typescript/commonjs/components/ProfileCompletion/ProfileCompletion.d.ts +4 -1
  190. package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +3 -2
  191. package/lib/typescript/commonjs/components/ProgressRing/ProgressRing.d.ts +2 -1
  192. package/lib/typescript/commonjs/components/Radio/Radio.d.ts +4 -2
  193. package/lib/typescript/commonjs/components/Rating/Rating.d.ts +5 -1
  194. package/lib/typescript/commonjs/components/RichTextEditor/RichTextEditor.d.ts +2 -1
  195. package/lib/typescript/commonjs/components/ScannerOverlay/ScannerOverlay.d.ts +2 -1
  196. package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +4 -2
  197. package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -2
  198. package/lib/typescript/commonjs/components/SignaturePad/SignaturePad.d.ts +4 -1
  199. package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +3 -1
  200. package/lib/typescript/commonjs/components/Slider/Slider.d.ts +3 -1
  201. package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +3 -1
  202. package/lib/typescript/commonjs/components/Sparkline/Sparkline.d.ts +4 -2
  203. package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +2 -1
  204. package/lib/typescript/commonjs/components/SquircleView/SquircleView.d.ts +8 -3
  205. package/lib/typescript/commonjs/components/StatTile/StatTile.d.ts +3 -2
  206. package/lib/typescript/commonjs/components/StatusBadge/StatusBadge.d.ts +4 -1
  207. package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +3 -1
  208. package/lib/typescript/commonjs/components/Switch/Switch.d.ts +3 -2
  209. package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +3 -2
  210. package/lib/typescript/commonjs/components/TagInput/TagInput.d.ts +4 -2
  211. package/lib/typescript/commonjs/components/Text/Text.d.ts +4 -1
  212. package/lib/typescript/commonjs/navigation/DiscardGuard.d.ts +3 -1
  213. package/lib/typescript/module/components/AmountSlider/AmountSlider.d.ts +3 -2
  214. package/lib/typescript/module/components/AppBar/AppBar.d.ts +4 -1
  215. package/lib/typescript/module/components/AuthedImage/authedImageCache.d.ts +3 -1
  216. package/lib/typescript/module/components/Avatar/Avatar.d.ts +6 -1
  217. package/lib/typescript/module/components/Badge/Badge.d.ts +5 -1
  218. package/lib/typescript/module/components/Banner/Banner.d.ts +3 -1
  219. package/lib/typescript/module/components/BarChart/BarChart.d.ts +4 -1
  220. package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +3 -1
  221. package/lib/typescript/module/components/Box/Box.d.ts +6 -3
  222. package/lib/typescript/module/components/Button/Button.d.ts +4 -2
  223. package/lib/typescript/module/components/Calendar/Calendar.d.ts +4 -2
  224. package/lib/typescript/module/components/Card/Card.d.ts +2 -1
  225. package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +4 -1
  226. package/lib/typescript/module/components/Chip/Chip.d.ts +3 -1
  227. package/lib/typescript/module/components/Composer/Composer.d.ts +3 -1
  228. package/lib/typescript/module/components/Confetti/Confetti.d.ts +3 -1
  229. package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +4 -2
  230. package/lib/typescript/module/components/DecimalInput/DecimalInput.d.ts +4 -2
  231. package/lib/typescript/module/components/Divider/Divider.d.ts +3 -2
  232. package/lib/typescript/module/components/Drawer/Drawer.d.ts +3 -1
  233. package/lib/typescript/module/components/EmptyState/EmptyState.d.ts +2 -1
  234. package/lib/typescript/module/components/FilePicker/FilePicker.d.ts +4 -1
  235. package/lib/typescript/module/components/FilterChipRow/FilterChipRow.d.ts +4 -2
  236. package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +2 -1
  237. package/lib/typescript/module/components/FormField/FormField.d.ts +3 -2
  238. package/lib/typescript/module/components/IconBadge/IconBadge.d.ts +4 -2
  239. package/lib/typescript/module/components/IconButton/IconButton.d.ts +4 -2
  240. package/lib/typescript/module/components/Input/Input.d.ts +4 -1
  241. package/lib/typescript/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +4 -1
  242. package/lib/typescript/module/components/ListItem/ListItem.d.ts +2 -0
  243. package/lib/typescript/module/components/Modal/Modal.d.ts +3 -1
  244. package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +4 -2
  245. package/lib/typescript/module/components/OTPInput/OTPInput.d.ts +3 -2
  246. package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +4 -2
  247. package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +4 -4
  248. package/lib/typescript/module/components/ProfileCompletion/ProfileCompletion.d.ts +4 -1
  249. package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +3 -2
  250. package/lib/typescript/module/components/ProgressRing/ProgressRing.d.ts +2 -1
  251. package/lib/typescript/module/components/Radio/Radio.d.ts +4 -2
  252. package/lib/typescript/module/components/Rating/Rating.d.ts +5 -1
  253. package/lib/typescript/module/components/RichTextEditor/RichTextEditor.d.ts +2 -1
  254. package/lib/typescript/module/components/ScannerOverlay/ScannerOverlay.d.ts +2 -1
  255. package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +4 -2
  256. package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -2
  257. package/lib/typescript/module/components/SignaturePad/SignaturePad.d.ts +4 -1
  258. package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +3 -1
  259. package/lib/typescript/module/components/Slider/Slider.d.ts +3 -1
  260. package/lib/typescript/module/components/SliderField/SliderField.d.ts +3 -1
  261. package/lib/typescript/module/components/Sparkline/Sparkline.d.ts +4 -2
  262. package/lib/typescript/module/components/Spinner/Spinner.d.ts +2 -1
  263. package/lib/typescript/module/components/SquircleView/SquircleView.d.ts +8 -3
  264. package/lib/typescript/module/components/StatTile/StatTile.d.ts +3 -2
  265. package/lib/typescript/module/components/StatusBadge/StatusBadge.d.ts +4 -1
  266. package/lib/typescript/module/components/Stepper/Stepper.d.ts +3 -1
  267. package/lib/typescript/module/components/Switch/Switch.d.ts +3 -2
  268. package/lib/typescript/module/components/Tabs/Tabs.d.ts +3 -2
  269. package/lib/typescript/module/components/TagInput/TagInput.d.ts +4 -2
  270. package/lib/typescript/module/components/Text/Text.d.ts +4 -1
  271. package/lib/typescript/module/navigation/DiscardGuard.d.ts +3 -1
  272. package/package.json +7 -7
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.KeyboardAwareScrollView=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_index=require("../../theme/index.js"),_jsxRuntime=require("react/jsx-runtime");const tapAreaStyle={flexGrow:1},CHILD_LAYOUT_KEYS=["gap","rowGap","columnGap","flexDirection","flexWrap","alignItems","alignContent","justifyContent"],childLayout=e=>{const r=_reactNative.StyleSheet.flatten(e),t={};for(const e of CHILD_LAYOUT_KEYS)void 0!==r?.[e]&&Object.assign(t,{[e]:r[e]});return t},KeyboardAwareScrollView=exports.KeyboardAwareScrollView=(0,_react.forwardRef)((e,r)=>{const{children:t,bottomOffset:o=24,extraKeyboardSpace:a=0,safeAreaEdges:i=["bottom"],refreshing:l=!1,onRefresh:s,dismissOnTapOutside:n=!0,contentContainerStyle:d,refreshControl:c,...u}=e,f=(0,_index.useTheme)(),y=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),b=i.includes("bottom"),p={paddingBottom:b?y.bottom:0,...i.includes("top")?{paddingTop:y.top}:null,...i.includes("left")?{paddingLeft:y.left}:null,...i.includes("right")?{paddingRight:y.right}:null},x=c??(s?(0,_jsxRuntime.jsx)(_reactNative.RefreshControl,{refreshing:l,onRefresh:s,tintColor:f.colors.primary,colors:[f.colors.primary],progressBackgroundColor:f.colors.surface,titleColor:f.colors["text-muted"]}):void 0);return(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardAwareScrollView,{ref:r,bottomOffset:o,extraKeyboardSpace:a-(b?y.bottom:0),disableScrollOnKeyboardHide:!0,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"none",contentContainerStyle:[d,p],refreshControl:x,...u,children:n?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessible:!1,onPress:_reactNative.Keyboard.dismiss,style:[tapAreaStyle,childLayout(d)],children:t}):t})});KeyboardAwareScrollView.displayName="KeyboardAwareScrollView";var _default=exports.default=KeyboardAwareScrollView;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KeyboardAwareScrollView=KeyboardAwareScrollView,exports.default=void 0;var _reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_index=require("../../theme/index.js"),_jsxRuntime=require("react/jsx-runtime");const tapAreaStyle={flexGrow:1},CHILD_LAYOUT_KEYS=["gap","rowGap","columnGap","flexDirection","flexWrap","alignItems","alignContent","justifyContent"],childLayout=e=>{const r=_reactNative.StyleSheet.flatten(e),t={};for(const e of CHILD_LAYOUT_KEYS)void 0!==r?.[e]&&Object.assign(t,{[e]:r[e]});return t};function KeyboardAwareScrollView({ref:e,...r}){const{children:t,bottomOffset:o=24,extraKeyboardSpace:a=0,safeAreaEdges:i=["bottom"],refreshing:n=!1,onRefresh:s,dismissOnTapOutside:l=!0,contentContainerStyle:d,refreshControl:c,...u}=r,f=(0,_index.useTheme)(),y=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),b=i.includes("bottom"),p={paddingBottom:b?y.bottom:0,...i.includes("top")?{paddingTop:y.top}:null,...i.includes("left")?{paddingLeft:y.left}:null,...i.includes("right")?{paddingRight:y.right}:null},x=c??(s?(0,_jsxRuntime.jsx)(_reactNative.RefreshControl,{refreshing:n,onRefresh:s,tintColor:f.colors.primary,colors:[f.colors.primary],progressBackgroundColor:f.colors.surface,titleColor:f.colors["text-muted"]}):void 0);return(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardAwareScrollView,{ref:e,bottomOffset:o,extraKeyboardSpace:a-(b?y.bottom:0),disableScrollOnKeyboardHide:!0,keyboardShouldPersistTaps:"handled",keyboardDismissMode:"none",contentContainerStyle:[d,p],refreshControl:x,...u,children:l?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessible:!1,onPress:_reactNative.Keyboard.dismiss,style:[tapAreaStyle,childLayout(d)],children:t}):t})}var _default=exports.default=KeyboardAwareScrollView;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ListItem=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_useFlickGuard=require("../../hooks/useFlickGuard.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_themeStyles=require("../../utils/themeStyles.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index2=require("../Button/index.js"),_index3=require("../IconBadge/index.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_webOnly=require("../Menu/webOnly.js"),_index4=require("../Skeleton/index.js"),_index5=require("../Swipeable/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,s,n=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=n&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?n(r,s,i):r[s]=e[s]);return r}const Chevron=({color:e})=>{const t=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:(t.settings.icons.chevronRight??_defaultIcons.defaultIcons.chevronRight)({size:20,color:e})})},BADGE_SIZE={sm:"sm",md:"md",lg:"lg"},RIGHT_BELOW_FONT_SCALE=1.2,MENU_ROW_MIN_HEIGHT=48,WEB_CHECKABLE_ROLE=(0,_webOnly.webOnly)({role:"menuitemcheckbox"}),SelectionBox=({checked:e,disabled:t})=>{const i=(0,_index.useTheme)(),s=(0,_index.resolveCheckboxSize)(i,"md")["box-size"],n=Math.round(.72*s);return(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{width:s,height:s,alignItems:"center",justifyContent:"center",borderWidth:i.size.border,borderRadius:i.radius.sm,..._corners.smoothCorners,borderColor:e?i.colors.primary:i.colors.border,backgroundColor:e?i.colors.primary:t?i.colors["surface-disabled"]:"transparent"},children:e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:n,height:n,viewBox:"0 0 24 24",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:i.colors["on-primary"],strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})}):null})},isActionList=e=>Array.isArray(e)&&e.length>0&&e.every(e=>null!=e&&"object"==typeof e&&!_react.default.isValidElement(e)&&"label"in e),renderActions=e=>isActionList(e)?e.map(e=>(0,_jsxRuntime.jsx)(_index2.Button,{size:"sm",variant:e.variant??"outline",tone:e.tone,leftIcon:e.icon,disabled:e.disabled,testID:e.testID,label:e.label,onPress:e.onPress},e.label)):e,ListItemRoot=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{title:i,loading:s=!1,subtitle:n,description:r,children:l,titleLines:a,subtitleLines:o=1,leading:c,icon:d,iconTone:u="primary",trailing:m,rightPlacement:x="auto",selectable:_=!1,checked:h=!1,onCheckedChange:p,actions:j,onPress:b,onFocus:g,haptic:y,selected:f=!1,expanded:v,disabled:R=!1,size:S="md",variant:w="list",divider:I=!1,chevron:L=!1,leftActions:k,rightActions:V,contextMenu:N,accessibilityLabel:C,accessibilityHint:A,style:q,rowStyle:B,titleStyle:O,subtitleStyle:P,descriptionStyle:z,leftSlotStyle:E,rightSlotStyle:M,testID:T}=e;(0,_assertValidValue.assertValidValue)("ListItem","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("ListItem","iconTone",e.iconTone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("ListItem","rightPlacement",e.rightPlacement,["auto","side","below"]),(0,_assertValidValue.assertValidValue)("ListItem","variant",e.variant,["list","menu"]);const D="menu"===w,W=a??(D?2:1),F=D?e.checked:void 0,H=(0,_index.useTheme)(),G=(0,_react.useMemo)(()=>(0,_index.resolveListItemSize)(H,S),[H,S]),U=stylesFor(H),{fontScale:K}=(0,_reactNative.useWindowDimensions)(),Z=!!m&&("below"===x||"auto"===x&&K>1.2),J=(0,_useContextMenu.useContextMenu)(R?void 0:N,{haptic:y||!1,testID:T}),Q=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,J.hostRef),[t,J.hostRef]),X=_||!!b,Y=X||J.enabled,$=Y&&!R,{style:ee,pressIn:te,pressOut:ie}=(0,_usePressAnimation.usePressAnimation)({enabled:$&&!D}),se=(0,_useFlickGuard.useFlickGuard)(),ne=C??("string"==typeof i?i:void 0),isText=e=>"string"==typeof e||"number"==typeof e,re=c??(void 0===d?null:(0,_jsxRuntime.jsx)(_index3.IconBadge,{icon:d,tone:u,size:BADGE_SIZE[S]})),le=_?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:U.selectionLead,children:[(0,_jsxRuntime.jsx)(SelectionBox,{checked:h,disabled:R}),re?(0,_jsxRuntime.jsx)(_reactNative.View,{style:U.selectionLeadContent,children:re}):null]}):re,ae=null!=j&&!1!==j&&!(Array.isArray(j)&&0===j.length),oe=I&&!ae,ce=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[U.row,{paddingVertical:D?H.space.sm:G["padding-y"],minHeight:D?48:G["min-height"],backgroundColor:f?H.colors["surface-selected"]:"transparent"},oe?U.divider:null,R&&!D?U.disabled:null,B],children:[le?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[U.leftSlot,E],children:le}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:U.middle,children:[null==i||isText(i)?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[U.title,{fontSize:D?H.text.base.size:G["title-text"],...(0,_index.fontFor)(H,D?"normal":"medium"),color:R?H.colors["text-disabled"]:H.colors["text-body"]},O],numberOfLines:W,children:i??" "}):i,null==n||""===n?null:isText(n)?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[U.subtitle,{fontSize:D?H.text.xs.size:G["subtitle-text"],color:R?H.colors["text-disabled"]:H.colors["text-muted"]},D?U.menuSubtitle:null,P],numberOfLines:o,children:n}):n,null==r||""===r?null:isText(r)?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[U.description,{fontSize:G["subtitle-text"],color:R?H.colors["text-disabled"]:H.colors["text-subtle"]},z],numberOfLines:2,children:r}):r,null!=l&&!1!==l?(0,_jsxRuntime.jsx)(_reactNative.View,{style:U.body,children:l}):null,Z?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[U.rightBelow,M],children:m}):null]}),m&&!Z||L?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[U.rightSlot,Z?null:M],children:[Z?null:m,L?(0,_jsxRuntime.jsx)(_reactNative.View,{style:m&&!Z?U.chevronWithRight:null,children:(0,_jsxRuntime.jsx)(Chevron,{color:R?H.colors["text-disabled"]:H.colors["text-subtle"]})}):null]}):null]}),de=Y?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:Q,onPress:e=>{$&&X&&!se.isFlick(e)&&(y&&(0,_hapticUtils.triggerHaptic)(y),_?p?.(!h):b?.(e))},onPressIn:e=>{se.onPressIn(e),te()},onPressOut:ie,disabled:!$,onFocus:g,accessibilityRole:_?"checkbox":D?"menuitem":b?"button":void 0,accessibilityLabel:ne,accessibilityHint:A,accessibilityState:_?{checked:h,disabled:!$,expanded:v}:{selected:f,disabled:!$,expanded:v,...void 0!==F?{checked:F}:null},"aria-disabled":!$,"aria-expanded":v,..._?{"aria-checked":h}:void 0!==F?{"aria-checked":F}:{"aria-selected":f},...void 0!==F?WEB_CHECKABLE_ROLE:null,testID:T,android_ripple:{color:H.colors["surface-pressed"],borderless:!1},style:({pressed:e})=>[q,e?U.pressed:null],...J.hostProps,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:ee,children:ce})}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityRole:"none",accessibilityLabel:ne,accessibilityHint:A,accessibilityState:{selected:f,disabled:R},"aria-selected":f,"aria-disabled":R,testID:T,style:q,children:ce}),ue=k&&k.length>0||V&&V.length>0,me=ae?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[f?{backgroundColor:H.colors["surface-selected"]}:null,I?U.divider:null],children:[de,(0,_jsxRuntime.jsx)(_reactNative.View,{style:U.actions,children:renderActions(j)})]}):de,xe=ue?(0,_jsxRuntime.jsx)(_index5.Swipeable,{leftActions:k,rightActions:V,accessibilityLabel:ne,children:me}):me;return s?(0,_jsxRuntime.jsx)(ListItemSkeleton,{...e}):J.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[xe,J.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:U.preview,children:ce}))]}):xe})),ListItemSkeleton=({subtitle:e,description:t,leading:i,icon:s,trailing:n,chevron:r,size:l="md",variant:a="list",style:o})=>{const c=(0,_index.useTheme)(),d=(0,_index.resolveListItemSize)(c,l),u=Math.round(1.15*d["title-text"]),m=Math.round(1.15*d["subtitle-text"]),x="menu"===a;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"center",paddingHorizontal:c.space.md,paddingVertical:x?c.space.sm:d["padding-y"],minHeight:x?48:d["min-height"]},o],children:[void 0!==i||void 0!==s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:c.space.sm},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"circle",width:40,height:40})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},children:[(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"70%",height:u,style:{marginBottom:c.space.xs}}),void 0!==e?(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"50%",height:m,style:void 0!==t?{marginBottom:c.space.xs}:void 0}):null,void 0!==t?(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"85%",height:m}):null]}),void 0!==n||r?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginLeft:c.space.sm},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:20,height:20,radius:"sm"})}):null]})};ListItemSkeleton.displayName="ListItemSkeleton";const ListItem=exports.ListItem=Object.assign(ListItemRoot,{Skeleton:ListItemSkeleton});ListItem.displayName="ListItem";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.md},divider:{borderBottomWidth:_reactNative.StyleSheet.hairlineWidth,borderBottomColor:e.colors.border},pressed:{backgroundColor:e.colors["surface-pressed"]},disabled:{opacity:.55},leftSlot:{marginRight:e.space.md,alignItems:"center",justifyContent:"center"},middle:{flex:1,flexDirection:"column",justifyContent:"center"},selectionLead:{flexDirection:"row",alignItems:"center"},selectionLeadContent:{marginLeft:e.space.sm},body:{marginTop:e.space.xs},rightBelow:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",marginTop:e.space.xs},rightSlot:{marginLeft:e.space.md,alignItems:"center",justifyContent:"center",flexDirection:"row"},actions:{flexDirection:"row",flexWrap:"wrap",gap:e.space.sm,paddingHorizontal:e.space.md,paddingBottom:e.space.md},chevronWithRight:{marginLeft:e.space.xs},preview:{flex:1,backgroundColor:e.colors.surface,borderRadius:e.radius.md,..._corners.smoothCorners,overflow:"hidden"},title:{letterSpacing:e["letter-spacing"].normal},subtitle:{marginTop:e.space.xxs,...(0,_index.fontFor)(e,"normal")},menuSubtitle:{marginTop:0},description:{marginTop:e.space.xxs,...(0,_index.fontFor)(e,"normal")}}),stylesFor=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=ListItem;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ListItem=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_useFlickGuard=require("../../hooks/useFlickGuard.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_themeStyles=require("../../utils/themeStyles.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index2=require("../Button/index.js"),_index3=require("../IconBadge/index.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_webOnly=require("../Menu/webOnly.js"),_index4=require("../Skeleton/index.js"),_index5=require("../Swipeable/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,s,n=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=n&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?n(r,s,i):r[s]=e[s]);return r}const Chevron=({color:e})=>{const t=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:(t.settings.icons.chevronRight??_defaultIcons.defaultIcons.chevronRight)({size:20,color:e})})},BADGE_SIZE={sm:"sm",md:"md",lg:"lg"},RIGHT_BELOW_FONT_SCALE=1.2,MENU_ROW_MIN_HEIGHT=48,WEB_CHECKABLE_ROLE=(0,_webOnly.webOnly)({role:"menuitemcheckbox"}),SelectionBox=({checked:e,disabled:t})=>{const i=(0,_index.useTheme)(),s=(0,_index.resolveCheckboxSize)(i,"md")["box-size"],n=Math.round(.72*s);return(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",pointerEvents:"none",style:{width:s,height:s,alignItems:"center",justifyContent:"center",borderWidth:i.size.border,borderRadius:i.radius.sm,..._corners.smoothCorners,borderColor:e?i.colors.primary:i.colors.border,backgroundColor:e?i.colors.primary:t?i.colors["surface-disabled"]:"transparent"},children:e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:n,height:n,viewBox:"0 0 24 24",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:i.colors["on-primary"],strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})}):null})},isActionList=e=>Array.isArray(e)&&e.length>0&&e.every(e=>null!=e&&"object"==typeof e&&!_react.default.isValidElement(e)&&"label"in e),renderActions=e=>isActionList(e)?e.map(e=>(0,_jsxRuntime.jsx)(_index2.Button,{size:"sm",variant:e.variant??"outline",tone:e.tone,leftIcon:e.icon,disabled:e.disabled,testID:e.testID,label:e.label,onPress:e.onPress},e.label)):e,ListItemRoot=_react.default.memo(function ListItemRoot({ref:e,...t}){const{title:i,loading:s=!1,subtitle:n,description:r,children:l,titleLines:a,subtitleLines:o=1,leading:c,icon:d,iconTone:u="primary",trailing:m,rightPlacement:x="auto",selectable:_=!1,checked:h=!1,onCheckedChange:p,actions:j,onPress:b,onFocus:g,haptic:y,selected:f=!1,expanded:v,disabled:R=!1,size:S="md",variant:w="list",divider:I=!1,chevron:L=!1,leftActions:k,rightActions:V,contextMenu:N,accessibilityLabel:C,accessibilityHint:A,style:q,rowStyle:B,titleStyle:O,subtitleStyle:P,descriptionStyle:z,leftSlotStyle:E,rightSlotStyle:M,testID:T}=t;(0,_assertValidValue.assertValidValue)("ListItem","size",t.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("ListItem","iconTone",t.iconTone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("ListItem","rightPlacement",t.rightPlacement,["auto","side","below"]),(0,_assertValidValue.assertValidValue)("ListItem","variant",t.variant,["list","menu"]);const D="menu"===w,W=a??(D?2:1),F=D?t.checked:void 0,H=(0,_index.useTheme)(),G=(0,_react.useMemo)(()=>(0,_index.resolveListItemSize)(H,S),[H,S]),U=stylesFor(H),{fontScale:K}=(0,_reactNative.useWindowDimensions)(),Z=!!m&&("below"===x||"auto"===x&&K>1.2),J=(0,_useContextMenu.useContextMenu)(R?void 0:N,{haptic:y||!1,testID:T}),Q=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(e,J.hostRef),[e,J.hostRef]),X=_||!!b,Y=X||J.enabled,$=Y&&!R,{style:ee,pressIn:te,pressOut:ie}=(0,_usePressAnimation.usePressAnimation)({enabled:$&&!D}),se=(0,_useFlickGuard.useFlickGuard)(),ne=C??("string"==typeof i?i:void 0),isText=e=>"string"==typeof e||"number"==typeof e,re=c??(void 0===d?null:(0,_jsxRuntime.jsx)(_index3.IconBadge,{icon:d,tone:u,size:BADGE_SIZE[S]})),le=_?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:U.selectionLead,children:[(0,_jsxRuntime.jsx)(SelectionBox,{checked:h,disabled:R}),re?(0,_jsxRuntime.jsx)(_reactNative.View,{style:U.selectionLeadContent,children:re}):null]}):re,ae=null!=j&&!1!==j&&!(Array.isArray(j)&&0===j.length),oe=I&&!ae,ce=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[U.row,{paddingVertical:D?H.space.sm:G["padding-y"],minHeight:D?48:G["min-height"],backgroundColor:f?H.colors["surface-selected"]:"transparent"},oe?U.divider:null,R&&!D?U.disabled:null,B],children:[le?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[U.leftSlot,E],children:le}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:U.middle,children:[null==i||isText(i)?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[U.title,{fontSize:D?H.text.base.size:G["title-text"],...(0,_index.fontFor)(H,D?"normal":"medium"),color:R?H.colors["text-disabled"]:H.colors["text-body"]},O],numberOfLines:W,children:i??" "}):i,null==n||""===n?null:isText(n)?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[U.subtitle,{fontSize:D?H.text.xs.size:G["subtitle-text"],color:R?H.colors["text-disabled"]:H.colors["text-muted"]},D?U.menuSubtitle:null,P],numberOfLines:o,children:n}):n,null==r||""===r?null:isText(r)?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[U.description,{fontSize:G["subtitle-text"],color:R?H.colors["text-disabled"]:H.colors["text-subtle"]},z],numberOfLines:2,children:r}):r,null!=l&&!1!==l?(0,_jsxRuntime.jsx)(_reactNative.View,{style:U.body,children:l}):null,Z?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[U.rightBelow,M],children:m}):null]}),m&&!Z||L?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[U.rightSlot,Z?null:M],children:[Z?null:m,L?(0,_jsxRuntime.jsx)(_reactNative.View,{style:m&&!Z?U.chevronWithRight:null,children:(0,_jsxRuntime.jsx)(Chevron,{color:R?H.colors["text-disabled"]:H.colors["text-subtle"]})}):null]}):null]}),de=Y?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:Q,onPress:e=>{$&&X&&!se.isFlick(e)&&(y&&(0,_hapticUtils.triggerHaptic)(y),_?p?.(!h):b?.(e))},onPressIn:e=>{se.onPressIn(e),te()},onPressOut:ie,disabled:!$,onFocus:g,accessibilityRole:_?"checkbox":D?"menuitem":b?"button":void 0,accessibilityLabel:ne,accessibilityHint:A,accessibilityState:_?{checked:h,disabled:!$,expanded:v}:{selected:f,disabled:!$,expanded:v,...void 0!==F?{checked:F}:null},"aria-disabled":!$,"aria-expanded":v,..._?{"aria-checked":h}:void 0!==F?{"aria-checked":F}:{"aria-selected":f},...void 0!==F?WEB_CHECKABLE_ROLE:null,testID:T,android_ripple:{color:H.colors["surface-pressed"],borderless:!1},style:({pressed:e})=>[q,e?U.pressed:null],...J.hostProps,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:ee,children:ce})}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e,accessibilityRole:"none",accessibilityLabel:ne,accessibilityHint:A,accessibilityState:{selected:f,disabled:R},"aria-selected":f,"aria-disabled":R,testID:T,style:q,children:ce}),ue=k&&k.length>0||V&&V.length>0,me=ae?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[f?{backgroundColor:H.colors["surface-selected"]}:null,I?U.divider:null],children:[de,(0,_jsxRuntime.jsx)(_reactNative.View,{style:U.actions,children:renderActions(j)})]}):de,xe=ue?(0,_jsxRuntime.jsx)(_index5.Swipeable,{leftActions:k,rightActions:V,accessibilityLabel:ne,children:me}):me;return s?(0,_jsxRuntime.jsx)(ListItemSkeleton,{...t}):J.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[xe,J.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:U.preview,children:ce}))]}):xe}),ListItemSkeleton=({subtitle:e,description:t,leading:i,icon:s,trailing:n,chevron:r,size:l="md",variant:a="list",style:o})=>{const c=(0,_index.useTheme)(),d=(0,_index.resolveListItemSize)(c,l),u=Math.round(1.15*d["title-text"]),m=Math.round(1.15*d["subtitle-text"]),x="menu"===a;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"center",paddingHorizontal:c.space.md,paddingVertical:x?c.space.sm:d["padding-y"],minHeight:x?48:d["min-height"]},o],children:[void 0!==i||void 0!==s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:c.space.sm},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"circle",width:40,height:40})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},children:[(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"70%",height:u,style:{marginBottom:c.space.xs}}),void 0!==e?(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"50%",height:m,style:void 0!==t?{marginBottom:c.space.xs}:void 0}):null,void 0!==t?(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"85%",height:m}):null]}),void 0!==n||r?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginLeft:c.space.sm},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:20,height:20,radius:"sm"})}):null]})};ListItemSkeleton.displayName="ListItemSkeleton";const ListItem=exports.ListItem=Object.assign(ListItemRoot,{Skeleton:ListItemSkeleton});ListItem.displayName="ListItem";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.md},divider:{borderBottomWidth:_reactNative.StyleSheet.hairlineWidth,borderBottomColor:e.colors.border},pressed:{backgroundColor:e.colors["surface-pressed"]},disabled:{opacity:.55},leftSlot:{marginRight:e.space.md,alignItems:"center",justifyContent:"center"},middle:{flex:1,flexDirection:"column",justifyContent:"center"},selectionLead:{flexDirection:"row",alignItems:"center"},selectionLeadContent:{marginLeft:e.space.sm},body:{marginTop:e.space.xs},rightBelow:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",marginTop:e.space.xs},rightSlot:{marginLeft:e.space.md,alignItems:"center",justifyContent:"center",flexDirection:"row"},actions:{flexDirection:"row",flexWrap:"wrap",gap:e.space.sm,paddingHorizontal:e.space.md,paddingBottom:e.space.md},chevronWithRight:{marginLeft:e.space.xs},preview:{flex:1,backgroundColor:e.colors.surface,borderRadius:e.radius.md,..._corners.smoothCorners,overflow:"hidden"},title:{letterSpacing:e["letter-spacing"].normal},subtitle:{marginTop:e.space.xxs,...(0,_index.fontFor)(e,"normal")},menuSubtitle:{marginTop:0},description:{marginTop:e.space.xxs,...(0,_index.fontFor)(e,"normal")}}),stylesFor=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=ListItem;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Modal=exports.MODAL_DISMISS_GRACE_MS=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../text/index.js"),_modalG=require("../../text/phone/modal.g.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_placement=require("../../utils/placement.js"),_squircle=require("../../utils/squircle.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");const MODAL_PRESENTATIONS=["centered","bottom","fullScreen","anchored"],MODAL_DISMISS_GRACE_MS=exports.MODAL_DISMISS_GRACE_MS=300,SCALE_START_VALUE=.9,Modal=exports.Modal=(0,_react.forwardRef)((e,t)=>{(0,_assertValidValue.assertValidValue)("Modal","presentation",e.presentation,MODAL_PRESENTATIONS);const{open:r,onClose:a,presentation:i="centered",backdropOpacity:n,backdropPressClose:o=!0,animationDuration:s,animateMount:c=!0,accessibilityLabel:l,hardwareBackPress:u=!0,children:d,contentStyle:m,backdropStyle:_,restoreFocusRef:p,onDismissed:f,haptic:v,labels:h,anchor:g,placement:b="auto",align:S="center",testID:x,bare:M=!1,onInsetsChange:A}=e,D=(0,_index2.useTheme)(),y=(0,_index.useMobileUiText)("modal",_modalG.MODAL_TEXT),N=(0,_react.useMemo)(()=>({...y,...h}),[y,h]),R=(0,_usePresenceMotion.usePresenceMotion)(),[C,j]=(0,_ModalSafeArea.useModalInsets)();(0,_react.useEffect)(()=>{A?.(C)},[C,A]);const{width:w,height:V}=(0,_reactNative.useWindowDimensions)(),[q,T]=(0,_react.useState)({width:0,height:0}),E=s??R.duration("default"),I=_reactNative.Dimensions.get("window").height,L=(0,_react.useRef)(!c&&r),P=L.current,O=(0,_react.useRef)((0,_index2.createAnimatedValue)(P?1:.9)).current,k=(0,_react.useRef)((0,_index2.createAnimatedValue)(P?1:0)).current,z=(0,_react.useRef)((0,_index2.createAnimatedValue)(P?0:I)).current,F=(0,_react.useRef)((0,_index2.createAnimatedValue)(P?1:0)).current,H=(0,_react.useRef)(null),W=(0,_react.useRef)(!1),[G,U]=(0,_react.useState)(r),B=(0,_react.useMemo)(()=>buildStyles(D),[D]),K=(0,_react.useMemo)(()=>{if("anchored"!==i||void 0===g)return null;const e={width:w,height:V,insets:{top:C.top,bottom:C.bottom,left:0,right:0}},t=(0,_placement.computePlacement)(g,q,e,b,{align:S});return{...t,maxHeight:(0,_placement.placementMaxHeight)(t.placement,(0,_placement.placementRoom)(g,e))}},[i,g,q,b,S,w,V,C.top,C.bottom]),X=(0,_react.useMemo)(()=>{const e=D.colors.scrim;return"number"!=typeof n?"anchored"===i?(0,_color.transparentOf)(e):e:(0,_color.withAlpha)(e,n)??e},[D.colors.scrim,n,i]),Y=(0,_react.useMemo)(()=>F.interpolate({inputRange:[0,1],outputRange:[(0,_color.transparentOf)(X),X]}),[F,X]);(0,_react.useEffect)(()=>{r&&(_reactNative.Keyboard.dismiss(),U(!0))},[r]),(0,_react.useEffect)(()=>{const e=[];if(r&&G&&L.current)L.current=!1;else if(r&&G){const t=_reactNative.Animated.timing(F,{toValue:1,duration:R.duration("default"),useNativeDriver:!1});if(t.start(),e.push(t),R.reduced||"anchored"===i){k.setValue(0),z.setValue(0),O.setValue(1);const t=_reactNative.Animated.timing(k,{toValue:1,duration:E,useNativeDriver:_nativeDriver.nativeDriver});t.start(),e.push(t)}else if("bottom"===i){k.setValue(1);const t=_reactNative.Animated.spring(z,{toValue:0,damping:D.motion.spring.gentle.damping,stiffness:D.motion.spring.gentle.stiffness,mass:D.motion.spring.gentle.mass,useNativeDriver:_nativeDriver.nativeDriver});t.start(),e.push(t)}else{const t=_reactNative.Animated.parallel([_reactNative.Animated.spring(O,{toValue:1,damping:D.motion.spring.gentle.damping,stiffness:D.motion.spring.gentle.stiffness,mass:D.motion.spring.gentle.mass,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(k,{toValue:1,duration:E,useNativeDriver:_nativeDriver.nativeDriver})]);t.start(),e.push(t)}}else if(G){const t=R.duration("fast"),r=_reactNative.Easing.bezier(...D.motion.ease.accelerate),a=_reactNative.Animated.timing(k,{toValue:0,duration:t,easing:r,useNativeDriver:_nativeDriver.nativeDriver}),n=R.reduced||"anchored"===i?a:"bottom"===i?_reactNative.Animated.timing(z,{toValue:I,duration:t,easing:r,useNativeDriver:_nativeDriver.nativeDriver}):_reactNative.Animated.parallel([_reactNative.Animated.timing(O,{toValue:.9,duration:t,easing:r,useNativeDriver:_nativeDriver.nativeDriver}),a]),o=_reactNative.Animated.parallel([n,_reactNative.Animated.timing(F,{toValue:0,duration:R.duration("default"),useNativeDriver:!1})]);o.start(({finished:e})=>{e&&(z.setValue(I),U(!1))}),e.push(o)}return()=>e.forEach(e=>{e.stop()})},[r,G,i,E,O,k,F,z,I,D.motion.spring.gentle.damping,D.motion.spring.gentle.stiffness,D.motion.spring.gentle.mass,R,D.motion.ease.accelerate]),(0,_react.useEffect)(()=>{if("web"===_reactNative.Platform.OS)return;let e,t;return r?(e=setTimeout(()=>{H.current&&_reactNative.AccessibilityInfo.sendAccessibilityEvent(H.current,"focus")},150),W.current=!0):W.current&&(W.current=!1,p?.current&&(t=setTimeout(()=>{const e=p.current;e&&_reactNative.AccessibilityInfo.sendAccessibilityEvent(e,"focus")},E))),()=>{e&&clearTimeout(e),t&&clearTimeout(t)}},[r,E,p]);const $=(0,_react.useRef)(f);$.current=f;const J=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(r)return void(J.current=!0);if(!J.current)return;J.current=!1;const e=setTimeout(()=>$.current?.(),MODAL_DISMISS_GRACE_MS);return()=>clearTimeout(e)},[r]);const Q=(0,_react.useCallback)(()=>{if(!o)return;const e=(0,_hapticUtils.resolveHaptic)(v,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),a()},[o,a,v]),Z=(0,_react.useCallback)(()=>{u&&a()},[u,a]),ee=(0,_SquircleFill.useSquircle)(!M&&"bottom"!==i&&"fullScreen"!==i&&"anchored"!==i,D.radius.xl),te=(0,_react.useCallback)(e=>{ee.onLayout(e);const{width:t,height:r}=e.nativeEvent.layout;T(e=>e.width===t&&e.height===r?e:{width:t,height:r})},[ee.onLayout]),re=(0,_react.useMemo)(()=>M?"bottom"===i?B.bottomContent:"fullScreen"===i?B.fullScreenContent:B.bareCentredContent:"anchored"===i?[B.anchoredContent,{left:K?.x,top:K?.y,maxHeight:K?.maxHeight,backgroundColor:D.colors.surface,borderRadius:D.radius.lg,..._corners.smoothCorners},D.shadow.modal]:"fullScreen"===i?[B.fullScreenContent,{backgroundColor:D.colors.surface}]:"bottom"===i?[B.bottomContent,{backgroundColor:D.colors.surface,borderTopLeftRadius:D.radius.xl,borderTopRightRadius:D.radius.xl,..._corners.smoothCorners,paddingTop:D.space.lg,paddingHorizontal:D.space.lg,paddingBottom:D.space.lg+C.bottom},D.shadow.modal]:[B.centeredContent,{backgroundColor:D.colors.surface,borderRadius:ee.active&&ee.size?(0,_squircle.squircleHostRadius)(ee.size.width,ee.size.height,D.radius.xl):D.radius.xl,..._corners.smoothCorners,padding:D.space.xl},D.shadow.modal],[i,D,B,C.bottom,ee.active,ee.size,K,M]),ae=(0,_react.useMemo)(()=>"anchored"===i?B.anchoredWrapper:"bottom"===i?B.bottomWrapper:"fullScreen"===i?B.fullScreenWrapper:B.centeredWrapper,[i,B]),ie=(0,_react.useMemo)(()=>"bottom"===i?{opacity:k,transform:[{translateY:z}]}:"fullScreen"===i||"anchored"===i?{opacity:k}:{opacity:k,transform:[{scale:O}]},[i,O,k,z]);if("anchored"===i&&void 0===g)throw new Error('[@webority/mobile-ui] Modal: presentation "anchored" needs an anchor.');if(M&&"anchored"===i)throw new Error('[@webority/mobile-ui] Modal: presentation "anchored" bare does not combine with presentation anchored.');return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:G,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:Z,testID:x,children:(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{H.current=e,"function"==typeof t?t(e):t&&(t.current=e)},style:B.root,accessible:!1,accessibilityViewIsModal:!0,accessibilityRole:"alert",accessibilityLabel:l,children:(0,_jsxRuntime.jsxs)(_ModalSafeArea.ModalSafeArea,{onInsets:j,children:[(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{collapsable:!1,style:[_reactNative.StyleSheet.absoluteFill,ae,{backgroundColor:Y},_],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:Q,accessibilityRole:o?"button":void 0,accessibilityLabel:o?N.close:void 0,accessible:!!o&&void 0,importantForAccessibility:o?void 0:"no",disabled:!o,testID:x?`${x}-backdrop`:void 0}),(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[re,ie,q.height>0||"anchored"!==i?null:B.unmeasured,m],onLayout:te,pointerEvents:M&&"fullScreen"===i?"box-none":"auto",needsOffscreenAlphaCompositing:!0,children:[ee.active&&ee.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ee.size.width,height:ee.size.height,radius:D.radius.xl,fill:D.colors.surface}):null,d]})]}),(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})})})});Modal.displayName="Modal";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1},centeredWrapper:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},centeredContent:{maxWidth:"90%",width:"90%"},bottomWrapper:{flex:1,justifyContent:"flex-end"},bottomContent:{width:"100%"},fullScreenWrapper:{flex:1},fullScreenContent:{flex:1},anchoredWrapper:{flex:1},anchoredContent:{position:"absolute"},unmeasured:{opacity:0},bareCentredContent:{alignSelf:"center"}});var _default=exports.default=Modal;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MODAL_DISMISS_GRACE_MS=void 0,exports.Modal=Modal,exports.default=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../text/index.js"),_modalG=require("../../text/phone/modal.g.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_placement=require("../../utils/placement.js"),_squircle=require("../../utils/squircle.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");const MODAL_PRESENTATIONS=["centered","bottom","fullScreen","anchored"],MODAL_DISMISS_GRACE_MS=exports.MODAL_DISMISS_GRACE_MS=300,SCALE_START_VALUE=.9;function Modal({ref:e,...t}){(0,_assertValidValue.assertValidValue)("Modal","presentation",t.presentation,MODAL_PRESENTATIONS);const{open:r,onClose:a,presentation:i="centered",backdropOpacity:n,backdropPressClose:o=!0,animationDuration:s,animateMount:c=!0,accessibilityLabel:l,hardwareBackPress:u=!0,children:d,contentStyle:m,backdropStyle:_,restoreFocusRef:p,onDismissed:f,haptic:v,labels:h,anchor:g,placement:b="auto",align:S="center",testID:x,bare:A=!1,onInsetsChange:M}=t,D=(0,_index2.useTheme)(),y=(0,_index.useMobileUiText)("modal",_modalG.MODAL_TEXT),N=(0,_react.useMemo)(()=>({...y,...h}),[y,h]),R=(0,_usePresenceMotion.usePresenceMotion)(),[C,j]=(0,_ModalSafeArea.useModalInsets)();(0,_react.useEffect)(()=>{M?.(C)},[C,M]);const{width:V,height:T}=(0,_reactNative.useWindowDimensions)(),[q,w]=(0,_react.useState)({width:0,height:0}),E=s??R.duration("default"),I=T,L=(0,_react.useRef)(!c&&r),P=L.current,O=(0,_react.useRef)((0,_index2.createAnimatedValue)(P?1:SCALE_START_VALUE)).current,k=(0,_react.useRef)((0,_index2.createAnimatedValue)(P?1:0)).current,z=(0,_react.useRef)((0,_index2.createAnimatedValue)(P?0:I)).current,F=(0,_react.useRef)((0,_index2.createAnimatedValue)(P?1:0)).current,H=(0,_react.useRef)(null),W=(0,_react.useRef)(!1),[U,G]=(0,_react.useState)(r),B=(0,_react.useMemo)(()=>buildStyles(D),[D]),K=(0,_react.useMemo)(()=>{if("anchored"!==i||void 0===g)return null;const e={width:V,height:T,insets:{top:C.top,bottom:C.bottom,left:0,right:0}},t=(0,_placement.computePlacement)(g,q,e,b,{align:S});return{...t,maxHeight:(0,_placement.placementMaxHeight)(t.placement,(0,_placement.placementRoom)(g,e))}},[i,g,q,b,S,V,T,C.top,C.bottom]),X=(0,_react.useMemo)(()=>{const e=D.colors.scrim;return"number"!=typeof n?"anchored"===i?(0,_color.transparentOf)(e):e:(0,_color.withAlpha)(e,n)??e},[D.colors.scrim,n,i]),Y=(0,_react.useMemo)(()=>F.interpolate({inputRange:[0,1],outputRange:[(0,_color.transparentOf)(X),X]}),[F,X]);(0,_react.useEffect)(()=>{r&&(_reactNative.Keyboard.dismiss(),G(!0))},[r]),(0,_react.useEffect)(()=>{const e=[];if(r&&U&&L.current)L.current=!1;else if(r&&U){const t=_reactNative.Animated.timing(F,{toValue:1,duration:R.duration("default"),useNativeDriver:!1});if(t.start(),e.push(t),R.reduced||"anchored"===i){k.setValue(0),z.setValue(0),O.setValue(1);const t=_reactNative.Animated.timing(k,{toValue:1,duration:E,useNativeDriver:_nativeDriver.nativeDriver});t.start(),e.push(t)}else if("bottom"===i){k.setValue(1);const t=_reactNative.Animated.spring(z,{toValue:0,damping:D.motion.spring.gentle.damping,stiffness:D.motion.spring.gentle.stiffness,mass:D.motion.spring.gentle.mass,useNativeDriver:_nativeDriver.nativeDriver});t.start(),e.push(t)}else{const t=_reactNative.Animated.parallel([_reactNative.Animated.spring(O,{toValue:1,damping:D.motion.spring.gentle.damping,stiffness:D.motion.spring.gentle.stiffness,mass:D.motion.spring.gentle.mass,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(k,{toValue:1,duration:E,useNativeDriver:_nativeDriver.nativeDriver})]);t.start(),e.push(t)}}else if(U){const t=R.duration("fast"),r=_reactNative.Easing.bezier(...D.motion.ease.accelerate),a=_reactNative.Animated.timing(k,{toValue:0,duration:t,easing:r,useNativeDriver:_nativeDriver.nativeDriver}),n=R.reduced||"anchored"===i?a:"bottom"===i?_reactNative.Animated.timing(z,{toValue:I,duration:t,easing:r,useNativeDriver:_nativeDriver.nativeDriver}):_reactNative.Animated.parallel([_reactNative.Animated.timing(O,{toValue:SCALE_START_VALUE,duration:t,easing:r,useNativeDriver:_nativeDriver.nativeDriver}),a]),o=_reactNative.Animated.parallel([n,_reactNative.Animated.timing(F,{toValue:0,duration:R.duration("default"),useNativeDriver:!1})]);o.start(({finished:e})=>{e&&(z.setValue(I),G(!1))}),e.push(o)}return()=>e.forEach(e=>{e.stop()})},[r,U,i,E,O,k,F,z,I,D.motion.spring.gentle.damping,D.motion.spring.gentle.stiffness,D.motion.spring.gentle.mass,R,D.motion.ease.accelerate]),(0,_react.useEffect)(()=>{if("web"===_reactNative.Platform.OS)return;let e,t;return r?(e=setTimeout(()=>{H.current&&_reactNative.AccessibilityInfo.sendAccessibilityEvent(H.current,"focus")},150),W.current=!0):W.current&&(W.current=!1,p?.current&&(t=setTimeout(()=>{const e=p.current;e&&_reactNative.AccessibilityInfo.sendAccessibilityEvent(e,"focus")},E))),()=>{e&&clearTimeout(e),t&&clearTimeout(t)}},[r,E,p]);const $=(0,_react.useRef)(f);$.current=f;const J=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(r)return void(J.current=!0);if(!J.current)return;J.current=!1;const e=setTimeout(()=>$.current?.(),MODAL_DISMISS_GRACE_MS);return()=>clearTimeout(e)},[r]);const Q=(0,_react.useCallback)(()=>{if(!o)return;const e=(0,_hapticUtils.resolveHaptic)(v,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),a()},[o,a,v]),Z=(0,_react.useCallback)(()=>{u&&a()},[u,a]),ee=(0,_SquircleFill.useSquircle)(!A&&"bottom"!==i&&"fullScreen"!==i&&"anchored"!==i,D.radius.xl),te=(0,_react.useCallback)(e=>{ee.onLayout(e);const{width:t,height:r}=e.nativeEvent.layout;w(e=>e.width===t&&e.height===r?e:{width:t,height:r})},[ee.onLayout]),re=(0,_react.useMemo)(()=>A?"bottom"===i?B.bottomContent:"fullScreen"===i?B.fullScreenContent:B.bareCentredContent:"anchored"===i?[B.anchoredContent,{left:K?.x,top:K?.y,maxHeight:K?.maxHeight,backgroundColor:D.colors.surface,borderRadius:D.radius.lg,..._corners.smoothCorners},D.shadow.modal]:"fullScreen"===i?[B.fullScreenContent,{backgroundColor:D.colors.surface}]:"bottom"===i?[B.bottomContent,{backgroundColor:D.colors.surface,borderTopLeftRadius:D.radius.xl,borderTopRightRadius:D.radius.xl,..._corners.smoothCorners,paddingTop:D.space.lg,paddingHorizontal:D.space.lg,paddingBottom:D.space.lg+C.bottom},D.shadow.modal]:[B.centeredContent,{backgroundColor:D.colors.surface,borderRadius:ee.active&&ee.size?(0,_squircle.squircleHostRadius)(ee.size.width,ee.size.height,D.radius.xl):D.radius.xl,..._corners.smoothCorners,padding:D.space.xl},D.shadow.modal],[i,D,B,C.bottom,ee.active,ee.size,K,A]),ae=(0,_react.useMemo)(()=>"anchored"===i?B.anchoredWrapper:"bottom"===i?B.bottomWrapper:"fullScreen"===i?B.fullScreenWrapper:B.centeredWrapper,[i,B]),ie=(0,_react.useMemo)(()=>"bottom"===i?{opacity:k,transform:[{translateY:z}]}:"fullScreen"===i||"anchored"===i?{opacity:k}:{opacity:k,transform:[{scale:O}]},[i,O,k,z]);if("anchored"===i&&void 0===g)throw new Error('[@webority/mobile-ui] Modal: presentation "anchored" needs an anchor.');if(A&&"anchored"===i)throw new Error('[@webority/mobile-ui] Modal: presentation "anchored" bare does not combine with presentation anchored.');return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:U,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:Z,testID:x,children:(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t=>{H.current=t,"function"==typeof e?e(t):e&&(e.current=t)},style:B.root,accessible:!1,accessibilityViewIsModal:!0,accessibilityRole:"alert",accessibilityLabel:l,children:(0,_jsxRuntime.jsxs)(_ModalSafeArea.ModalSafeArea,{onInsets:j,children:[(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{collapsable:!1,style:[_reactNative.StyleSheet.absoluteFill,ae,{backgroundColor:Y},_],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:Q,accessibilityRole:o?"button":void 0,accessibilityLabel:o?N.close:void 0,accessible:!!o&&void 0,importantForAccessibility:o?void 0:"no",disabled:!o,testID:x?`${x}-backdrop`:void 0}),(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[re,ie,q.height>0||"anchored"!==i?null:B.unmeasured,m],onLayout:te,pointerEvents:A&&"fullScreen"===i?"box-none":"auto",needsOffscreenAlphaCompositing:!0,children:[ee.active&&ee.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ee.size.width,height:ee.size.height,radius:D.radius.xl,fill:D.colors.surface}):null,d]})]}),(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})})})}const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1},centeredWrapper:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},centeredContent:{maxWidth:"90%",width:"90%"},bottomWrapper:{flex:1,justifyContent:"flex-end"},bottomContent:{width:"100%"},fullScreenWrapper:{flex:1},fullScreenContent:{flex:1},anchoredWrapper:{flex:1},anchoredContent:{position:"absolute"},unmeasured:{opacity:0},bareCentredContent:{alignSelf:"center"}});var _default=exports.default=Modal;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.NumberInput=void 0;var cache,_mobileCore=require("@webority/mobile-core"),_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../text/index.js"),_numberInputG=require("../../text/phone/numberInput.g.js"),_index3=require("../../theme/index.js"),_index4=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,r,a=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((i=a&&Object.getOwnPropertyDescriptor(e,r))&&(i.get||i.set)?a(n,r,i):n[r]=e[r]);return n}const NUMBER_INPUT_SIZES=["sm","md","lg"],NUMBER_INPUT_VARIANTS=["inline","horizontal"],DEFAULT_LONG_PRESS_DELAY=500,DEFAULT_LONG_PRESS_INTERVAL=80,roundToPrecision=(e,t)=>{if(!Number.isFinite(e))return 0;if(t<=0)return Math.round(e);const i=10**t;return Math.round(e*i)/i},clamp=(e,t,i)=>e<t?t:e>i?i:e,formatValue=(e,t,i)=>Number.isFinite(e)?t&&i>0?e.toFixed(i):String(Math.trunc(e)):"",sanitizeTyped=(e,t)=>{if(!e)return"";let i=e.replace(/[^0-9.-]/g,"");if(i=i.replace(/(?!^)-/g,""),t){const e=i.indexOf(".");-1!==e&&(i=i.slice(0,e+1)+i.slice(e+1).replace(/\./g,""))}else i=i.replace(/\./g,"");return i},NumberInput=exports.NumberInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:r,onChange:a,min:n=Number.NEGATIVE_INFINITY,max:s=Number.POSITIVE_INFINITY,step:l=1,allowDecimal:c=!1,precision:u=0,label:o,help:d,helperText:_,error:b,disabled:m=!1,size:x="md",variant:p="inline",unit:f,haptic:h,labels:y,accessibilityLabel:N,style:I,inputStyle:j,buttonStyle:g,unitStyle:T,labelStyle:v,textInputProps:S,testID:R}=e;(0,_assertValidValue.assertValidValue)("NumberInput","size",e.size,NUMBER_INPUT_SIZES),(0,_assertValidValue.assertValidValue)("NumberInput","variant",e.variant,NUMBER_INPUT_VARIANTS);const F=(0,_index2.useMobileUiText)("numberInput",_numberInputG.NUMBER_INPUT_TEXT),V=(0,_react.useMemo)(()=>({...F,...y}),[F,y]),[P,C]=(0,_index.useControllableState)({value:i,defaultValue:r??e.min??0,onChange:a}),w=(0,_index3.useTheme)(),E=(0,_index3.resolveFieldSize)(w,x),z=(0,_FieldBase.resolveFieldTextStyle)(w,{disabled:m}),B=(0,_react.useMemo)(()=>buildStyles(w),[w]),M=(0,_react.useRef)(null),[k,q]=(0,_react.useState)(formatValue(P,c,u)),[A,L]=(0,_react.useState)(!1),[U,D]=(0,_react.useState)(!1),O=(0,_react.useCallback)(()=>{m||M.current?.focus()},[m]),W=(0,_react.useRef)(null),H=(0,_react.useRef)(null),G=(0,_react.useCallback)(()=>{null!==W.current&&(clearTimeout(W.current),W.current=null),null!==H.current&&(clearInterval(H.current),H.current=null)},[]);(0,_react.useEffect)(()=>G,[G]),(0,_react.useEffect)(()=>{A||q(formatValue(P,c,u))},[P,c,u,A]);const Y=P<=n,$=P>=s,Z=!m,X=(0,_react.useCallback)(e=>{const t=roundToPrecision(e,c?u:0),i=clamp(t,n,s);i!==P&&C(i)},[c,s,n,C,u,P]),J=(0,_react.useCallback)(()=>{if(!Z||Y)return;const e=(0,_index4.resolveHaptic)(h,"selection");e&&(0,_index4.triggerHaptic)(e),X(P-l)},[Y,Z,h,X,l,P]),K=(0,_react.useCallback)(()=>{if(!Z||$)return;const e=(0,_index4.resolveHaptic)(h,"selection");e&&(0,_index4.triggerHaptic)(e),X(P+l)},[$,Z,h,X,l,P]);_react.default.useImperativeHandle(t,()=>({focus:()=>M.current?.focus(),blur:()=>M.current?.blur(),clear:()=>{q(""),Number.isFinite(n)&&n>0?C(n):C(0<n?n:Math.min(s,0))}}),[s,n,C]);const Q=(0,_react.useCallback)(e=>{Z&&(G(),W.current=setTimeout(()=>{H.current=setInterval(()=>{"inc"===e?K():J()},80)},500))},[G,J,K,Z]),ee=(0,_react.useCallback)(e=>{(0,_mobileCore.reportIdleActivity)();const t=sanitizeTyped(e,c);q(t);const i=Number(t);""!==t&&"-"!==t&&"."!==t&&Number.isFinite(i)&&i>=n&&i<=s&&i!==P&&C(roundToPrecision(i,c?u:0))},[c,s,n,C,u,P]),te=(0,_react.useCallback)(()=>{L(!1),D(!1);const e=Number(k);if(""===k||!Number.isFinite(e))return void q(formatValue(P,c,u));const t=roundToPrecision(e,c?u:0),i=clamp(t,n,s);i!==P&&C(i),q(formatValue(i,c,u))},[c,k,s,n,C,u,P]),ie=(0,_react.useCallback)(()=>{L(!0),D(!0)},[]),re=Y||m?w.colors["text-disabled"]:w.colors["text-body"],ae=$||m?w.colors["text-disabled"]:w.colors["text-body"],ne=E.icon+8,renderStepper=(e,t,i,r,a,n)=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:t,onLongPress:()=>Q(e),onPressOut:G,delayLongPress:500,disabled:i,accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{disabled:i},"aria-disabled":i,style:({pressed:e})=>[{width:ne,height:ne,alignItems:"center",justifyContent:"center",borderRadius:w.radius.pill,..._corners.smoothCorners},e&&!i?{backgroundColor:w.colors["surface-pressed"]}:null,g],testID:`${R??"numberinput"}-${"inc"===e?"plus":"minus"}`,children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",weight:"semibold",style:{fontSize:E.icon,color:a,fontWeight:w.weight.semibold,lineHeight:E.icon+2},children:n})}),se=N??(0,_FieldBase.fieldTextAsString)(o)??V.input,le=!0===b||(0,_FieldBase.hasFieldText)(b),ce=(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{testID:R?`${R}-field`:void 0,size:x,disabled:m,error:le,filled:!0,focused:U,onPress:O,pressFeedback:!1,leading:renderStepper("dec",J,Y||m,V.decrease,re,"−"),trailing:renderStepper("inc",K,$||m,V.increase,ae,"+"),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:B.inputRow,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:M,value:k,onChangeText:ee,onFocus:ie,onBlur:te,editable:!m,keyboardType:c?"decimal-pad":"number-pad",selectTextOnFocus:!0,accessibilityRole:"adjustable",accessibilityLabel:se,accessibilityValue:{now:Number.isFinite(P)?P:0},accessibilityState:{disabled:m},"aria-disabled":m,accessibilityActions:[{name:"increment",label:V.increase},{name:"decrement",label:V.decrease}],onAccessibilityAction:e=>{"increment"===e.nativeEvent.actionName&&K(),"decrement"===e.nativeEvent.actionName&&J()},style:[B.input,{fontSize:E.text,color:z.color,...z.weightStyle},j],...S}),f?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"bodySmall",style:[B.unit,{fontSize:E.text,color:z.placeholderColor},T],children:f}):null]})}),ue=(0,_FieldBase.hasFieldText)(o)?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:x,help:d,style:v,children:o}):null,oe=(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:x,error:le,text:le?b:_});return"horizontal"===p?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[B.horizontalContainer,I],testID:R,accessibilityState:{disabled:m},"aria-disabled":m,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.horizontalLabelWrap,children:ue}),(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[ce,oe]})]}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[I],testID:R,accessibilityState:{disabled:m},"aria-disabled":m,children:[ue,ce,oe]})});NumberInput.displayName="NumberInput";const buildStyles=e=>_reactNative.StyleSheet.create({inputRow:{flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center"},input:{flex:1,textAlign:"center",padding:e.space.none,margin:e.space.none,includeFontPadding:!1},unit:{marginLeft:e.space.xs},label:{marginBottom:e.space.xs},helper:{marginTop:e.space.xs},horizontalContainer:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},horizontalLabelWrap:{flexShrink:1,paddingRight:e.space.md}});var _default=exports.default=NumberInput;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.NumberInput=NumberInput,exports.default=void 0;var cache,_mobileCore=require("@webority/mobile-core"),_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../text/index.js"),_numberInputG=require("../../text/phone/numberInput.g.js"),_index3=require("../../theme/index.js"),_index4=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,r,a=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((i=a&&Object.getOwnPropertyDescriptor(e,r))&&(i.get||i.set)?a(n,r,i):n[r]=e[r]);return n}const NUMBER_INPUT_SIZES=["sm","md","lg"],NUMBER_INPUT_VARIANTS=["inline","horizontal"],DEFAULT_LONG_PRESS_DELAY=500,DEFAULT_LONG_PRESS_INTERVAL=80,roundToPrecision=(e,t)=>{if(!Number.isFinite(e))return 0;if(t<=0)return Math.round(e);const i=10**t;return Math.round(e*i)/i},clamp=(e,t,i)=>e<t?t:e>i?i:e,formatValue=(e,t,i)=>Number.isFinite(e)?t&&i>0?e.toFixed(i):String(Math.trunc(e)):"",sanitizeTyped=(e,t)=>{if(!e)return"";let i=e.replace(/[^0-9.-]/g,"");if(i=i.replace(/(?!^)-/g,""),t){const e=i.indexOf(".");-1!==e&&(i=i.slice(0,e+1)+i.slice(e+1).replace(/\./g,""))}else i=i.replace(/\./g,"");return i};function NumberInput({ref:e,...t}){const{value:i,defaultValue:r,onChange:a,min:n=Number.NEGATIVE_INFINITY,max:s=Number.POSITIVE_INFINITY,step:l=1,allowDecimal:c=!1,precision:u=0,label:o,help:d,helperText:_,error:b,disabled:m=!1,size:x="md",variant:p="inline",unit:f,haptic:h,labels:N,accessibilityLabel:y,style:I,inputStyle:j,buttonStyle:S,unitStyle:T,labelStyle:g,textInputProps:R,testID:v}=t;(0,_assertValidValue.assertValidValue)("NumberInput","size",t.size,NUMBER_INPUT_SIZES),(0,_assertValidValue.assertValidValue)("NumberInput","variant",t.variant,NUMBER_INPUT_VARIANTS);const F=(0,_index2.useMobileUiText)("numberInput",_numberInputG.NUMBER_INPUT_TEXT),V=(0,_react.useMemo)(()=>({...F,...N}),[F,N]),[E,P]=(0,_index.useControllableState)({value:i,defaultValue:r??t.min??0,onChange:a}),L=(0,_index3.useTheme)(),C=(0,_index3.resolveFieldSize)(L,x),A=(0,_FieldBase.resolveFieldTextStyle)(L,{disabled:m}),w=(0,_react.useMemo)(()=>buildStyles(L),[L]),z=(0,_react.useRef)(null),[B,D]=(0,_react.useState)(formatValue(E,c,u)),[M,k]=(0,_react.useState)(!1),[U,q]=(0,_react.useState)(!1),O=(0,_react.useCallback)(()=>{m||z.current?.focus()},[m]),G=(0,_react.useRef)(null),W=(0,_react.useRef)(null),H=(0,_react.useCallback)(()=>{null!==G.current&&(clearTimeout(G.current),G.current=null),null!==W.current&&(clearInterval(W.current),W.current=null)},[]);(0,_react.useEffect)(()=>H,[H]),(0,_react.useEffect)(()=>{M||D(formatValue(E,c,u))},[E,c,u,M]);const Y=E<=n,$=E>=s,Z=!m,X=(0,_react.useCallback)(e=>{const t=roundToPrecision(e,c?u:0),i=clamp(t,n,s);i!==E&&P(i)},[c,s,n,P,u,E]),J=(0,_react.useCallback)(()=>{if(!Z||Y)return;const e=(0,_index4.resolveHaptic)(h,"selection");e&&(0,_index4.triggerHaptic)(e),X(E-l)},[Y,Z,h,X,l,E]),K=(0,_react.useCallback)(()=>{if(!Z||$)return;const e=(0,_index4.resolveHaptic)(h,"selection");e&&(0,_index4.triggerHaptic)(e),X(E+l)},[$,Z,h,X,l,E]);_react.default.useImperativeHandle(e,()=>({focus:()=>z.current?.focus(),blur:()=>z.current?.blur(),clear:()=>{D(""),Number.isFinite(n)&&n>0?P(n):P(0<n?n:Math.min(s,0))}}),[s,n,P]);const Q=(0,_react.useCallback)(e=>{Z&&(H(),G.current=setTimeout(()=>{W.current=setInterval(()=>{"inc"===e?K():J()},DEFAULT_LONG_PRESS_INTERVAL)},DEFAULT_LONG_PRESS_DELAY))},[H,J,K,Z]),ee=(0,_react.useCallback)(e=>{(0,_mobileCore.reportIdleActivity)();const t=sanitizeTyped(e,c);D(t);const i=Number(t);""!==t&&"-"!==t&&"."!==t&&Number.isFinite(i)&&i>=n&&i<=s&&i!==E&&P(roundToPrecision(i,c?u:0))},[c,s,n,P,u,E]),te=(0,_react.useCallback)(()=>{k(!1),q(!1);const e=Number(B);if(""===B||!Number.isFinite(e))return void D(formatValue(E,c,u));const t=roundToPrecision(e,c?u:0),i=clamp(t,n,s);i!==E&&P(i),D(formatValue(i,c,u))},[c,B,s,n,P,u,E]),ie=(0,_react.useCallback)(()=>{k(!0),q(!0)},[]),re=Y||m?L.colors["text-disabled"]:L.colors["text-body"],ae=$||m?L.colors["text-disabled"]:L.colors["text-body"],ne=C.icon+8,renderStepper=(e,t,i,r,a,n)=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:t,onLongPress:()=>Q(e),onPressOut:H,delayLongPress:DEFAULT_LONG_PRESS_DELAY,disabled:i,accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{disabled:i},"aria-disabled":i,style:({pressed:e})=>[{width:ne,height:ne,alignItems:"center",justifyContent:"center",borderRadius:L.radius.pill,..._corners.smoothCorners},e&&!i?{backgroundColor:L.colors["surface-pressed"]}:null,S],testID:`${v??"numberinput"}-${"inc"===e?"plus":"minus"}`,children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",weight:"semibold",style:{fontSize:C.icon,color:a,fontWeight:L.weight.semibold,lineHeight:C.icon+2},children:n})}),se=y??(0,_FieldBase.fieldTextAsString)(o)??V.input,le=!0===b||(0,_FieldBase.hasFieldText)(b),ce=(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{testID:v?`${v}-field`:void 0,size:x,disabled:m,error:le,filled:!0,focused:U,onPress:O,pressFeedback:!1,leading:renderStepper("dec",J,Y||m,V.decrease,re,"−"),trailing:renderStepper("inc",K,$||m,V.increase,ae,"+"),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:w.inputRow,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:z,value:B,onChangeText:ee,onFocus:ie,onBlur:te,editable:!m,keyboardType:c?"decimal-pad":"number-pad",selectTextOnFocus:!0,accessibilityRole:"adjustable",accessibilityLabel:se,accessibilityValue:{now:Number.isFinite(E)?E:0},accessibilityState:{disabled:m},"aria-disabled":m,accessibilityActions:[{name:"increment",label:V.increase},{name:"decrement",label:V.decrease}],onAccessibilityAction:e=>{"increment"===e.nativeEvent.actionName&&K(),"decrement"===e.nativeEvent.actionName&&J()},style:[w.input,{fontSize:C.text,color:A.color,...A.weightStyle},j],...R}),f?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"bodySmall",style:[w.unit,{fontSize:C.text,color:A.placeholderColor},T],children:f}):null]})}),ue=(0,_FieldBase.hasFieldText)(o)?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:x,help:d,style:g,children:o}):null,oe=(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:x,error:le,text:le?b:_});return"horizontal"===p?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[w.horizontalContainer,I],testID:v,accessibilityState:{disabled:m},"aria-disabled":m,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:w.horizontalLabelWrap,children:ue}),(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[ce,oe]})]}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[I],testID:v,accessibilityState:{disabled:m},"aria-disabled":m,children:[ue,ce,oe]})}const buildStyles=e=>_reactNative.StyleSheet.create({inputRow:{flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center"},input:{flex:1,textAlign:"center",padding:e.space.none,margin:e.space.none,includeFontPadding:!1},unit:{marginLeft:e.space.xs},label:{marginBottom:e.space.xs},helper:{marginTop:e.space.xs},horizontalContainer:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},horizontalLabelWrap:{flexShrink:1,paddingRight:e.space.md}});var _default=exports.default=NumberInput;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OTPInput=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../text/index.js"),_otpInputG=require("../../text/phone/otpInput.g.js"),_index3=require("../../theme/index.js"),_index4=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const cellAt=(e,t)=>{const i=e[t];if(void 0===i)throw new Error(`OTP cell ${t} is outside the ${e.length} cells.`);return i},sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=exports.OTPInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:r,onChange:a,onComplete:n,length:s=6,keyboardType:l="number-pad",autoFocus:o=!1,autoFocusDelay:c=0,disabled:u=!1,error:d,size:_="md",secure:p=!1,haptic:m,labels:v,onFocus:x,accessibilityLabel:g,style:h,cellStyle:f,textStyle:b,testID:y}=e;(0,_assertValidValue.assertValidValue)("OTPInput","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("OTPInput","keyboardType",e.keyboardType,["number-pad","default"]);const j=(0,_index2.useMobileUiText)("otpInput",_otpInputG.OTP_INPUT_TEXT),T=(0,_react.useMemo)(()=>({...j,...v}),[j,v]),[N,V]=(0,_index.useControllableState)({value:i,defaultValue:r??"",onChange:a}),C=(0,_index3.useTheme)(),k=(0,_react.useMemo)(()=>buildStyles(C),[C]),D=(0,_index3.resolveOtpInputSize)(C,_),I=C.components["otp-input"][_].radius,R=(0,_react.useRef)([]),[A,w]=(0,_react.useState)(-1),[E,F]=(0,_react.useState)(0),O=(0,_react.useRef)(null),M=(0,_react.useRef)((0,_index3.createAnimatedValue)(0)).current,q=(0,_react.useRef)(new Map),P=(0,_react.useMemo)(()=>{const e=q.current,t=[];for(let i=0;i<s;i+=1){let r=e.get(i);r||(r=new _reactNative.Animated.Value(0),e.set(i,r)),t.push(r)}for(const t of Array.from(e.keys()))t>=s&&e.delete(t);return t},[s]),S=(0,_react.useRef)(-1),z=C.settings.components["otp-input"]?.shakeOnError??!1,B=(0,_index.useReducedMotion)(),H=!0===d||(0,_FieldBase.hasFieldText)(d);(0,_react.useEffect)(()=>{let e;return null===O.current||!H||O.current||(m&&(0,_index4.triggerHaptic)("notificationError"),z&&!B&&((0,_index3.setNativeValue)(M,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(M,{toValue:1,duration:C.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(M,{toValue:-1,duration:C.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(M,{toValue:1,duration:C.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(M,{toValue:0,duration:C.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:_nativeDriver.nativeDriver})]),e.start())),O.current=H,()=>e?.stop()},[H,M,z,m,B,C.motion.duration.instant]),(0,_react.useEffect)(()=>{const e=S.current;if(S.current=A,e===A)return;if(-1===e&&-1===A)return;const t=[];return P.forEach((i,r)=>{const a=r===A?1:0;if(r!==A&&r!==e)return;const n=_reactNative.Animated.timing(i,{toValue:a,duration:C.motion.duration.fast,easing:_reactNative.Easing.bezier(...C.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});n.start(),t.push(n)}),()=>t.forEach(e=>{e.stop()})},[A,P,C]);const L=(0,_react.useCallback)(e=>{const t=R.current[e];t&&t.focus()},[]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>L(0),blur:()=>{const e=R.current[Math.max(A,0)];e?.blur()},clear:()=>{V(""),L(0)}}),[L,A,V]),(0,_react.useEffect)(()=>{if(o&&!u){const e=setTimeout(()=>L(0),c);return()=>clearTimeout(e)}},[o,c,u,L]);const W=(0,_react.useMemo)(()=>{const e=new Array(s).fill("");for(let t=0;t<Math.min(N.length,s);t+=1)e[t]=N.charAt(t);return e},[N,s]),G=(0,_react.useMemo)(()=>W.map((e,t)=>({key:`otp-cell-${t}`,index:t,char:e})),[W]),$=(0,_react.useCallback)(e=>{const t=e.slice(0,s);t!==N&&(V(t),t.length===s&&n&&n(t))},[s,V,n,N]),U=(0,_react.useCallback)((e,t)=>{const i=t.replace(/\u200B/g,""),r=sanitizeChar(i,l);if(!r){const t=W.slice(),i=cellAt(W,e).length>0;if(t[e]="",$(t.join("").slice(0,s)),!i&&e>0){const t=W.slice();t[e-1]="",$(t.join("")),L(e-1)}return}const a=cellAt(W,e),n=a&&r.length>s&&r.startsWith(a)?r.slice(a.length):r;if(n.length>=s){const t=n.slice(0,s),i=N.length;return $(t),t.length!==i&&m&&(0,_index4.triggerHaptic)(m),void R.current[e]?.blur()}const o=W.slice();let c=e;for(let e=0;e<r.length&&c<s;e+=1)o[c]=r.charAt(e),c+=1;const u=o.join("").slice(0,s),d=N.length;$(u),u.length!==d&&m&&(0,_index4.triggerHaptic)(m);const _=Math.min(c,s-1);c>=s?R.current[e]?.blur():L(_)},[W,L,l,s,m,$,N]),X=(0,_react.useCallback)((e,t)=>{if("Backspace"!==t.nativeEvent.key)return;if(0===cellAt(W,e).length){if(e>0){const t=W.slice();t[e-1]="",$(t.join("")),L(e-1)}}else{const t=W.slice();t[e]="",$(t.join(""))}},[W,L,$]),K=(0,_react.useCallback)((e,t)=>{w(e),x?.(t)},[x]),J=(0,_react.useCallback)(()=>{w(-1)},[]),Q=(0,_react.useCallback)(()=>{if(u)return;const e=W.indexOf("");L(-1===e?s-1:e)},[W,u,L,s]),Y=(0,_react.useCallback)(e=>{F(e.nativeEvent.layout.width)},[]),Z=g??(0,_index2.fillText)(T.field,{length:s}),ee=E>0?Math.max(24,Math.min(D.cell,Math.floor((E-D.gap*(s-1))/s))):D.cell,te=M.interpolate({inputRange:[-1,1],outputRange:[-6,6]});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:h,onLayout:Y,accessible:!0,accessibilityRole:"none",accessibilityLabel:Z,accessibilityValue:{text:i},accessibilityState:{disabled:u},"aria-disabled":u,testID:y,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Q,disabled:u,accessible:!1,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[k.row,{columnGap:D.gap,transform:[{translateX:te}]}],children:G.map(({key:e,index:t,char:i})=>{const r=A===t,a=i.length>0,n=H?C.colors["danger-border"]:C.colors["focus-ring"],o=P[t];if(!o)return null;const c=p&&a?"●":i;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:k.cellWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:_,width:ee,height:ee,radius:I,borderWidth:1.5,focused:r,error:H,filled:a,disabled:u,paddingHorizontal:C.space.none,paddingVertical:C.space.none,gap:C.space.none,style:f,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:e=>{R.current[t]=e},value:(p&&a?"":i)||"​",onChangeText:e=>{(0,_mobileCore.reportIdleActivity)(),U(t,e)},onKeyPress:e=>X(t,e),onFocus:e=>K(t,e),onBlur:J,keyboardType:l,editable:!u,selectTextOnFocus:!0,caretHidden:a,maxLength:s+1,textContentType:"oneTimeCode",autoComplete:0===t?"sms-otp":"off",importantForAutofill:0===t?"yes":"no",style:[k.input,{fontSize:D.text,color:C.colors["text-body"],...(0,_index3.fontFor)(C,"semibold")},b]}),p&&a?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:k.maskOverlay,children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",weight:"semibold",style:[{fontSize:D.text},b],children:c})}):null]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[k.underline,{backgroundColor:n,opacity:o}]})]},e)})})}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:_,error:!0,text:d})]})});OTPInput.displayName="OTPInput";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},cellWrapper:{alignItems:"center"},input:{width:"100%",height:"100%",textAlign:"center",padding:e.space.none},maskOverlay:{..._reactNative.StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center"},underline:{marginTop:e.space.xs,height:2,width:"60%",borderRadius:e.radius.pill,..._corners.smoothCorners}});var _default=exports.default=OTPInput;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OTPInput=OTPInput,exports.default=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../text/index.js"),_otpInputG=require("../../text/phone/otpInput.g.js"),_index3=require("../../theme/index.js"),_index4=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const cellAt=(e,t)=>{const i=e[t];if(void 0===i)throw new Error(`OTP cell ${t} is outside the ${e.length} cells.`);return i},sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"";function OTPInput({ref:e,...t}){const{value:i,defaultValue:r,onChange:a,onComplete:n,length:s=6,keyboardType:l="number-pad",autoFocus:o=!1,autoFocusDelay:c=0,disabled:u=!1,error:d,size:_="md",secure:p=!1,haptic:m,labels:v,onFocus:x,accessibilityLabel:g,style:h,cellStyle:f,textStyle:b,testID:y}=t;(0,_assertValidValue.assertValidValue)("OTPInput","size",t.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("OTPInput","keyboardType",t.keyboardType,["number-pad","default"]);const j=(0,_index2.useMobileUiText)("otpInput",_otpInputG.OTP_INPUT_TEXT),N=(0,_react.useMemo)(()=>({...j,...v}),[j,v]),[T,V]=(0,_index.useControllableState)({value:i,defaultValue:r??"",onChange:a}),C=(0,_index3.useTheme)(),k=(0,_react.useMemo)(()=>buildStyles(C),[C]),D=(0,_index3.resolveOtpInputSize)(C,_),A=C.components["otp-input"][_].radius,R=(0,_react.useRef)([]),[I,w]=(0,_react.useState)(-1),[E,F]=(0,_react.useState)(0),M=(0,_react.useRef)(null),q=(0,_react.useRef)((0,_index3.createAnimatedValue)(0)).current,O=(0,_react.useRef)(new Map),S=(0,_react.useMemo)(()=>{const e=O.current,t=[];for(let i=0;i<s;i+=1){let r=e.get(i);r||(r=new _reactNative.Animated.Value(0),e.set(i,r)),t.push(r)}for(const t of Array.from(e.keys()))t>=s&&e.delete(t);return t},[s]),P=(0,_react.useRef)(-1),z=C.settings.components["otp-input"]?.shakeOnError??!1,B=(0,_index.useReducedMotion)(),H=!0===d||(0,_FieldBase.hasFieldText)(d);(0,_react.useEffect)(()=>{let e;return null===M.current||!H||M.current||(m&&(0,_index4.triggerHaptic)("notificationError"),z&&!B&&((0,_index3.setNativeValue)(q,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(q,{toValue:1,duration:C.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(q,{toValue:-1,duration:C.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(q,{toValue:1,duration:C.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(q,{toValue:0,duration:C.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:_nativeDriver.nativeDriver})]),e.start())),M.current=H,()=>e?.stop()},[H,q,z,m,B,C.motion.duration.instant]),(0,_react.useEffect)(()=>{const e=P.current;if(P.current=I,e===I)return;if(-1===e&&-1===I)return;const t=[];return S.forEach((i,r)=>{const a=r===I?1:0;if(r!==I&&r!==e)return;const n=_reactNative.Animated.timing(i,{toValue:a,duration:C.motion.duration.fast,easing:_reactNative.Easing.bezier(...C.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});n.start(),t.push(n)}),()=>t.forEach(e=>{e.stop()})},[I,S,C]);const L=(0,_react.useCallback)(e=>{const t=R.current[e];t&&t.focus()},[]);(0,_react.useImperativeHandle)(e,()=>({focus:()=>L(0),blur:()=>{const e=R.current[Math.max(I,0)];e?.blur()},clear:()=>{V(""),L(0)}}),[L,I,V]),(0,_react.useEffect)(()=>{if(o&&!u){const e=setTimeout(()=>L(0),c);return()=>clearTimeout(e)}},[o,c,u,L]);const W=(0,_react.useMemo)(()=>{const e=new Array(s).fill("");for(let t=0;t<Math.min(T.length,s);t+=1)e[t]=T.charAt(t);return e},[T,s]),G=(0,_react.useMemo)(()=>W.map((e,t)=>({key:`otp-cell-${t}`,index:t,char:e})),[W]),$=(0,_react.useCallback)(e=>{const t=e.slice(0,s);t!==T&&(V(t),t.length===s&&n&&n(t))},[s,V,n,T]),U=(0,_react.useCallback)((e,t)=>{const i=t.replace(/\u200B/g,""),r=sanitizeChar(i,l);if(!r){const t=W.slice(),i=cellAt(W,e).length>0;if(t[e]="",$(t.join("").slice(0,s)),!i&&e>0){const t=W.slice();t[e-1]="",$(t.join("")),L(e-1)}return}const a=cellAt(W,e),n=a&&r.length>s&&r.startsWith(a)?r.slice(a.length):r;if(n.length>=s){const t=n.slice(0,s),i=T.length;return $(t),t.length!==i&&m&&(0,_index4.triggerHaptic)(m),void R.current[e]?.blur()}const o=W.slice();let c=e;for(let e=0;e<r.length&&c<s;e+=1)o[c]=r.charAt(e),c+=1;const u=o.join("").slice(0,s),d=T.length;$(u),u.length!==d&&m&&(0,_index4.triggerHaptic)(m);const _=Math.min(c,s-1);c>=s?R.current[e]?.blur():L(_)},[W,L,l,s,m,$,T]),X=(0,_react.useCallback)((e,t)=>{if("Backspace"!==t.nativeEvent.key)return;if(0===cellAt(W,e).length){if(e>0){const t=W.slice();t[e-1]="",$(t.join("")),L(e-1)}}else{const t=W.slice();t[e]="",$(t.join(""))}},[W,L,$]),K=(0,_react.useCallback)((e,t)=>{w(e),x?.(t)},[x]),J=(0,_react.useCallback)(()=>{w(-1)},[]),Q=(0,_react.useCallback)(()=>{if(u)return;const e=W.indexOf("");L(-1===e?s-1:e)},[W,u,L,s]),Y=(0,_react.useCallback)(e=>{F(e.nativeEvent.layout.width)},[]),Z=g??(0,_index2.fillText)(N.field,{length:s}),ee=E>0?Math.max(24,Math.min(D.cell,Math.floor((E-D.gap*(s-1))/s))):D.cell,te=q.interpolate({inputRange:[-1,1],outputRange:[-6,6]});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:h,onLayout:Y,accessible:!0,accessibilityRole:"none",accessibilityLabel:Z,accessibilityValue:{text:i},accessibilityState:{disabled:u},"aria-disabled":u,testID:y,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Q,disabled:u,accessible:!1,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[k.row,{columnGap:D.gap,transform:[{translateX:te}]}],children:G.map(({key:e,index:t,char:i})=>{const r=I===t,a=i.length>0,n=H?C.colors["danger-border"]:C.colors["focus-ring"],o=S[t];if(!o)return null;const c=p&&a?"●":i;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:k.cellWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:_,width:ee,height:ee,radius:A,borderWidth:1.5,focused:r,error:H,filled:a,disabled:u,paddingHorizontal:C.space.none,paddingVertical:C.space.none,gap:C.space.none,style:f,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:e=>{R.current[t]=e},value:(p&&a?"":i)||"​",onChangeText:e=>{(0,_mobileCore.reportIdleActivity)(),U(t,e)},onKeyPress:e=>X(t,e),onFocus:e=>K(t,e),onBlur:J,keyboardType:l,editable:!u,selectTextOnFocus:!0,caretHidden:a,maxLength:s+1,textContentType:"oneTimeCode",autoComplete:0===t?"sms-otp":"off",importantForAutofill:0===t?"yes":"no",style:[k.input,{fontSize:D.text,color:C.colors["text-body"],...(0,_index3.fontFor)(C,"semibold")},b]}),p&&a?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:k.maskOverlay,children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",weight:"semibold",style:[{fontSize:D.text},b],children:c})}):null]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[k.underline,{backgroundColor:n,opacity:o}]})]},e)})})}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:_,error:!0,text:d})]})}const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},cellWrapper:{alignItems:"center"},input:{width:"100%",height:"100%",textAlign:"center",padding:e.space.none},maskOverlay:{..._reactNative.StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center"},underline:{marginTop:e.space.xs,height:2,width:"60%",borderRadius:e.radius.pill,..._corners.smoothCorners}});var _default=exports.default=OTPInput;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OptionSheet=OptionSheet,exports.default=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_index=require("../../text/index.js"),_optionSheetG=require("../../text/phone/optionSheet.g.js"),_index2=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index3=require("../Modal/index.js"),_index4=require("../Text/index.js"),_optionAccessors=require("./optionAccessors.js"),_jsxRuntime=require("react/jsx-runtime");const SEARCH_ICON_SIZE=18,hostStyle=_reactNative.StyleSheet.create({host:{padding:0,paddingTop:0,paddingHorizontal:0,paddingBottom:0,backgroundColor:"transparent",borderTopLeftRadius:0,borderTopRightRadius:0,shadowOpacity:0,elevation:0}}).host;function OptionSheetPanel(e){const{onClose:t,title:i,options:r,sections:s,renderSectionHeader:o,renderOption:a,alphabetIndex:n=!1,labels:l,getOptionLabel:c,getOptionValue:d,getOptionDescription:u,isOptionDisabled:p,getOptionIcon:h,destructiveOf:x,getOptionAction:m,value:_,onChange:b,multi:g=!1,searchable:y=!1,searchSelectionColor:j,accessibilityLabel:f,optionStyle:R,selectedOptionStyle:v,optionTextStyle:S,selectedOptionTextStyle:T,testID:w}=e,C=c??_optionAccessors.selectOptionLabel,N=d??_optionAccessors.selectOptionValue,I=u??_optionAccessors.selectOptionDescription,k=p??_optionAccessors.selectOptionDisabled,O=h??_optionAccessors.selectOptionIcon,L=m??_optionAccessors.selectOptionAction,V=(0,_index2.useTheme)(),D=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),H=(0,_react.useMemo)(()=>buildStyles(V),[V]),[A,P]=(0,_react.useState)(""),M=(0,_react.useCallback)(e=>{(0,_mobileCore.reportIdleActivity)(),P(e)},[]),B=_reactNative.Dimensions.get("window").height,q=Math.round(.7*B),z=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,{handleGesture:W,opacity:G}=(0,_useDragToDismiss.useDragToDismiss)({drag:z,travel:q,onDismiss:t,testID:w}),F=(0,_reactNativeGestureHandler.useNativeGesture)(),E=(0,_reactNativeKeyboardController.useKeyboardState)(e=>e.height),K=Math.max(0,Math.round(E)),U=Math.max(D.top,_reactNative.StatusBar.currentHeight??0)+V.space.sm,$=K>0,Y=$?Math.max(0,Math.min(q,B-K-U)):q,Z=(0,_react.useMemo)(()=>{const e=y?A.trim().toLowerCase():"",matches=t=>0===e.length||C(t).toLowerCase().includes(e)||(I(t)??"").toLowerCase().includes(e);if(!s)return r.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return s.forEach((e,i)=>{const r=e.options.filter(matches);if(0!==r.length){t.push({kind:"header",title:e.title});for(const e of r)t.push({kind:"option",option:e,section:i})}}),t},[y,A,r,s,C,I]),X=(0,_react.useCallback)(()=>{t()},[t]),J=(0,_react.useRef)(null),Q=(0,_react.useMemo)(()=>{const e=new Map;if(!n)return e;let t=0;if(s)for(const[e,i]of Z.entries())"header"===i.kind&&(t=e+1);for(const[i,r]of Z.entries()){if(i<t||"option"!==r.kind)continue;const s=C(r.option).trim().charAt(0).toUpperCase(),o=/^[A-Z]$/.test(s)?s:"#";e.has(o)||e.set(o,i)}return e},[n,Z,s,C]),ee=n&&Q.size>0&&0===A.trim().length,te=(0,_react.useMemo)(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...Q.has("#")?["#"]:[]],[Q]),ie=(0,_react.useCallback)(e=>{const t=Q.get(e);void 0!==t&&J.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[Q]),re=(0,_react.useRef)(null),se=(0,_react.useCallback)(()=>{null!==re.current&&(clearTimeout(re.current),re.current=null)},[]),oe=(0,_react.useCallback)(e=>{J.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),se(),re.current=setTimeout(()=>{re.current=null,J.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[se]);(0,_react.useEffect)(()=>se,[se]);return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:H.gestureRoot,children:(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{testID:w,accessibilityViewIsModal:!0,accessibilityLabel:f??i??l.fallbackName,style:[H.sheet,{maxHeight:Y,marginBottom:K,paddingBottom:$?V.space.lg:D.bottom+V.space.lg,backgroundColor:V.colors.surface,borderTopLeftRadius:V.radius.xl,borderTopRightRadius:V.radius.xl,..._corners.smoothCorners,opacity:G,transform:[{translateY:z}],...V.shadow.modal}],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:W,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.sheetHandleRow,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.sheetHandle,{backgroundColor:V.colors.border}]})}),i?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",style:[H.sheetTitle,{paddingHorizontal:V.space.lg,marginBottom:V.space.sm}],children:i}):null]})}),y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.searchWrap,{marginHorizontal:V.space.lg,marginBottom:V.space.sm}],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.searchBox,{backgroundColor:V.colors["bg-subtle"],borderColor:V.colors.border,borderRadius:V.radius.md,..._corners.smoothCorners,paddingHorizontal:V.space.md,gap:V.space.sm}],children:[(V.settings.icons.search??_defaultIcons.defaultIcons.search)({size:18,color:V.colors["text-subtle"]}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{value:A,onChangeText:M,placeholder:l.searchPlaceholder,placeholderTextColor:V.colors["text-subtle"],selectionColor:j??V.colors["focus-ring"],accessibilityLabel:l.searchOptions,style:[H.searchInput,{color:V.colors["text-body"],fontSize:V.text.base.size,paddingVertical:V.space.sm}]}),A.length>0?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>P(""),hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:l.clearSearch,children:(V.settings.icons.close??_defaultIcons.defaultIcons.close)({size:18,color:V.colors["text-muted"]})}):null]})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.listWrap,ee?H.listRow:null],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:F,children:(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:J,data:Z,keyExtractor:e=>"header"===e.kind?`h:${e.title}`:`o:${e.section??""}:${String(N(e.option))}`,renderItem:({item:e,index:t})=>{if("header"===e.kind)return(0,_jsxRuntime.jsx)(_reactNative.View,{accessible:!0,accessibilityRole:"header",style:[H.sectionHeader,{paddingHorizontal:V.space.lg,paddingTop:V.space.md}],children:o?o(e.title):(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",color:"tertiary",style:H.sectionTitle,children:e.title.toUpperCase()})});const i=e.option,r=C(i),s=N(i),n=I(i),l=O(i),c=(d=s,Array.isArray(_)?_.some(e=>String(e)===String(d)):null!=_&&String(_)===String(d));var d;const u=k(i),p=x?.(i)??!1,h=L(i),m=Boolean(l);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{if(h)return h(),void X();b(s,i)},disabled:u,android_ripple:{color:V.colors["surface-pressed"],borderless:!1},accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{selected:c,disabled:u},"aria-selected":c,"aria-disabled":u,style:({pressed:e})=>[H.optionRow,{backgroundColor:c?V.colors["surface-selected"]:e?V.colors["surface-pressed"]:"transparent",opacity:u?.5:1,paddingHorizontal:V.space.lg,paddingVertical:V.space.md},R,c?v:null],children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.optionTextWrap,children:a({option:i,selected:c,disabled:u,index:t})}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[m?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.optionIcon,children:l}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.optionTextWrap,children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:c?"semibold":"medium",color:p?"danger":c?"brand":void 0,style:[H.optionLabel,S,c?T:null],children:r}),n?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"tertiary",numberOfLines:2,style:H.optionDescription,children:n}):null]})]}),g?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.checkbox,{borderColor:c?V.colors.primary:V.colors.border,backgroundColor:c?V.colors.primary:"transparent"}],children:c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.checkboxTick}):null}):c?"icon"===V.settings.components["option-sheet"]?.selectedMarker?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.singleSelectedIcon,children:(V.settings.icons.selectedTick??_defaultIcons.defaultIcons.selectedTick)({size:20,color:V.colors.primary})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.singleSelectedDot,{backgroundColor:V.colors.primary}]}):null]})},onScrollToIndexFailed:oe,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!ee,style:ee?H.listBesideRail:null,ListEmptyComponent:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"tertiary",align:"center",style:{paddingVertical:V.space.xl},children:l.empty})})}),ee?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.rail,{paddingRight:V.space.xs}],accessibilityRole:"list",accessibilityLabel:l.jumpToLetter,testID:"option-sheet-alphabet",children:te.map(e=>{const t=Q.has(e);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>ie(e),disabled:!t,hitSlop:{left:8,right:8},...(0,_hitSlop.hitSlopMarker)({left:8,right:8}),accessibilityRole:"button",accessibilityLabel:(0,_index.fillText)(l.jumpTo,{letter:e}),accessibilityState:{disabled:!t},"aria-disabled":!t,style:H.railLetter,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",color:t?"brand":"tertiary",style:[H.railLetterText,{opacity:t?1:.45}],children:e})},e)})}):null]}),g?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.sheetFooter,{borderTopColor:V.colors["border-subtle"],paddingHorizontal:V.space.lg,paddingVertical:V.space.md}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:X,accessibilityRole:"button",accessibilityLabel:l.done,style:({pressed:e})=>[H.doneButton,{backgroundColor:e?V.colors["primary-pressed"]:V.colors.primary,borderRadius:V.radius.md,..._corners.smoothCorners,paddingVertical:V.space.sm,paddingHorizontal:V.space.lg}],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",style:{color:V.colors["on-primary"]},children:l.done})})}):null]})})}function OptionSheet(e){const{open:t,onOpenChange:i,onAfterClose:r,labels:s,onClose:o,haptic:a,...n}=e,l=(0,_index.useMobileUiText)("optionSheet",_optionSheetG.OPTION_SHEET_TEXT),c=(0,_react.useMemo)(()=>({...l,...s}),[l,s]),d=(0,_react.useRef)(i);d.current=i;const u=(0,_react.useRef)(!1);return(0,_react.useEffect)(()=>{u.current!==t&&(u.current=t,d.current?.(t))},[t]),(0,_jsxRuntime.jsx)(_index3.Modal,{open:t,onClose:o,presentation:"bottom",onDismissed:r,haptic:a,contentStyle:hostStyle,labels:{close:c.closePicker},accessibilityLabel:n.accessibilityLabel??n.title??c.fallbackName,children:(0,_jsxRuntime.jsx)(OptionSheetPanel,{...n,onClose:o,labels:c})})}OptionSheet.displayName="OptionSheet";const buildStyles=e=>_reactNative.StyleSheet.create({gestureRoot:{width:"100%"},sheet:{paddingBottom:e.space.lg,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:e.space.sm,paddingBottom:e.space.sm},sheetHandle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:e.space.xs},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:e.space.xs},railLetter:{paddingHorizontal:e.space.xs,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:Math.round(e.text.xs.size*e.leading.heading)},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:e.space.md},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:e.space.xxs},checkbox:{width:22,height:22,borderRadius:e.radius.sm,..._corners.smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:e.space.md},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors["on-primary"],transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:e.radius.pill,..._corners.smoothCorners,marginLeft:e.space.md},singleSelectedIcon:{marginLeft:e.space.md},sheetFooter:{borderTopWidth:_reactNative.StyleSheet.hairlineWidth,alignItems:"flex-end"},doneButton:{alignSelf:"flex-end"}});var _default=exports.default=OptionSheet;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.OptionSheet=OptionSheet,exports.default=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_index=require("../../text/index.js"),_optionSheetG=require("../../text/phone/optionSheet.g.js"),_index2=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index3=require("../Modal/index.js"),_index4=require("../Text/index.js"),_optionAccessors=require("./optionAccessors.js"),_jsxRuntime=require("react/jsx-runtime");const SEARCH_ICON_SIZE=18,hostStyle=_reactNative.StyleSheet.create({host:{padding:0,paddingTop:0,paddingHorizontal:0,paddingBottom:0,backgroundColor:"transparent",borderTopLeftRadius:0,borderTopRightRadius:0,shadowOpacity:0,elevation:0}}).host;function OptionSheetPanel(e){const{onClose:t,title:i,options:r,sections:s,renderSectionHeader:o,renderOption:a,alphabetIndex:n=!1,labels:l,getOptionLabel:c,getOptionValue:d,getOptionDescription:u,isOptionDisabled:p,getOptionIcon:h,destructiveOf:x,getOptionAction:m,value:_,onChange:b,multi:g=!1,searchable:y=!1,searchSelectionColor:j,accessibilityLabel:f,optionStyle:R,selectedOptionStyle:v,optionTextStyle:S,selectedOptionTextStyle:T,testID:C}=e,w=c??_optionAccessors.selectOptionLabel,N=d??_optionAccessors.selectOptionValue,I=u??_optionAccessors.selectOptionDescription,k=p??_optionAccessors.selectOptionDisabled,O=h??_optionAccessors.selectOptionIcon,L=m??_optionAccessors.selectOptionAction,V=(0,_index2.useTheme)(),D=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),H=(0,_react.useMemo)(()=>buildStyles(V),[V]),[A,P]=(0,_react.useState)(""),M=(0,_react.useCallback)(e=>{(0,_mobileCore.reportIdleActivity)(),P(e)},[]),{height:B}=(0,_reactNative.useWindowDimensions)(),q=Math.round(.7*B),z=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,{handleGesture:W,opacity:G}=(0,_useDragToDismiss.useDragToDismiss)({drag:z,travel:q,onDismiss:t,testID:C}),F=(0,_reactNativeGestureHandler.useNativeGesture)(),E=(0,_reactNativeKeyboardController.useKeyboardState)(e=>e.height),K=Math.max(0,Math.round(E)),U=Math.max(D.top,_reactNative.StatusBar.currentHeight??0)+V.space.sm,$=K>0,Y=$?Math.max(0,Math.min(q,B-K-U)):q,Z=(0,_react.useMemo)(()=>{const e=y?A.trim().toLowerCase():"",matches=t=>0===e.length||w(t).toLowerCase().includes(e)||(I(t)??"").toLowerCase().includes(e);if(!s)return r.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return s.forEach((e,i)=>{const r=e.options.filter(matches);if(0!==r.length){t.push({kind:"header",title:e.title});for(const e of r)t.push({kind:"option",option:e,section:i})}}),t},[y,A,r,s,w,I]),X=(0,_react.useCallback)(()=>{t()},[t]),J=(0,_react.useRef)(null),Q=(0,_react.useMemo)(()=>{const e=new Map;if(!n)return e;let t=0;if(s)for(const[e,i]of Z.entries())"header"===i.kind&&(t=e+1);for(const[i,r]of Z.entries()){if(i<t||"option"!==r.kind)continue;const s=w(r.option).trim().charAt(0).toUpperCase(),o=/^[A-Z]$/.test(s)?s:"#";e.has(o)||e.set(o,i)}return e},[n,Z,s,w]),ee=n&&Q.size>0&&0===A.trim().length,te=(0,_react.useMemo)(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...Q.has("#")?["#"]:[]],[Q]),ie=(0,_react.useCallback)(e=>{const t=Q.get(e);void 0!==t&&J.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[Q]),re=(0,_react.useRef)(null),se=(0,_react.useCallback)(()=>{null!==re.current&&(clearTimeout(re.current),re.current=null)},[]),oe=(0,_react.useCallback)(e=>{J.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),se(),re.current=setTimeout(()=>{re.current=null,J.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[se]);(0,_react.useEffect)(()=>se,[se]);return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:H.gestureRoot,children:(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{testID:C,accessibilityViewIsModal:!0,accessibilityLabel:f??i??l.fallbackName,style:[H.sheet,{maxHeight:Y,marginBottom:K,paddingBottom:$?V.space.lg:D.bottom+V.space.lg,backgroundColor:V.colors.surface,borderTopLeftRadius:V.radius.xl,borderTopRightRadius:V.radius.xl,..._corners.smoothCorners,opacity:G,transform:[{translateY:z}],...V.shadow.modal}],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:W,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.sheetHandleRow,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.sheetHandle,{backgroundColor:V.colors.border}]})}),i?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",style:[H.sheetTitle,{paddingHorizontal:V.space.lg,marginBottom:V.space.sm}],children:i}):null]})}),y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.searchWrap,{marginHorizontal:V.space.lg,marginBottom:V.space.sm}],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.searchBox,{backgroundColor:V.colors["bg-subtle"],borderColor:V.colors.border,borderRadius:V.radius.md,..._corners.smoothCorners,paddingHorizontal:V.space.md,gap:V.space.sm}],children:[(V.settings.icons.search??_defaultIcons.defaultIcons.search)({size:18,color:V.colors["text-subtle"]}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{value:A,onChangeText:M,placeholder:l.searchPlaceholder,placeholderTextColor:V.colors["text-subtle"],selectionColor:j??V.colors["focus-ring"],accessibilityLabel:l.searchOptions,style:[H.searchInput,{color:V.colors["text-body"],fontSize:V.text.base.size,paddingVertical:V.space.sm}]}),A.length>0?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>P(""),hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:l.clearSearch,children:(V.settings.icons.close??_defaultIcons.defaultIcons.close)({size:18,color:V.colors["text-muted"]})}):null]})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[H.listWrap,ee?H.listRow:null],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:F,children:(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:J,data:Z,keyExtractor:e=>"header"===e.kind?`h:${e.title}`:`o:${e.section??""}:${String(N(e.option))}`,renderItem:({item:e,index:t})=>{if("header"===e.kind)return(0,_jsxRuntime.jsx)(_reactNative.View,{accessible:!0,accessibilityRole:"header",style:[H.sectionHeader,{paddingHorizontal:V.space.lg,paddingTop:V.space.md}],children:o?o(e.title):(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",color:"tertiary",style:H.sectionTitle,children:e.title.toUpperCase()})});const i=e.option,r=w(i),s=N(i),n=I(i),l=O(i),c=(d=s,Array.isArray(_)?_.some(e=>String(e)===String(d)):null!=_&&String(_)===String(d));var d;const u=k(i),p=x?.(i)??!1,h=L(i),m=Boolean(l);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{if(h)return h(),void X();b(s,i)},disabled:u,android_ripple:{color:V.colors["surface-pressed"],borderless:!1},accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{selected:c,disabled:u},"aria-selected":c,"aria-disabled":u,style:({pressed:e})=>[H.optionRow,{backgroundColor:c?V.colors["surface-selected"]:e?V.colors["surface-pressed"]:"transparent",opacity:u?.5:1,paddingHorizontal:V.space.lg,paddingVertical:V.space.md},R,c?v:null],children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.optionTextWrap,children:a({option:i,selected:c,disabled:u,index:t})}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[m?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.optionIcon,children:l}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.optionTextWrap,children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:c?"semibold":"medium",color:p?"danger":c?"brand":void 0,style:[H.optionLabel,S,c?T:null],children:r}),n?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"tertiary",numberOfLines:2,style:H.optionDescription,children:n}):null]})]}),g?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.checkbox,{borderColor:c?V.colors.primary:V.colors.border,backgroundColor:c?V.colors.primary:"transparent"}],children:c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.checkboxTick}):null}):c?"icon"===V.settings.components["option-sheet"]?.selectedMarker?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H.singleSelectedIcon,children:(V.settings.icons.selectedTick??_defaultIcons.defaultIcons.selectedTick)({size:20,color:V.colors.primary})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.singleSelectedDot,{backgroundColor:V.colors.primary}]}):null]})},onScrollToIndexFailed:oe,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!ee,style:ee?H.listBesideRail:null,ListEmptyComponent:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"tertiary",align:"center",style:{paddingVertical:V.space.xl},children:l.empty})})}),ee?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.rail,{paddingRight:V.space.xs}],accessibilityRole:"list",accessibilityLabel:l.jumpToLetter,testID:"option-sheet-alphabet",children:te.map(e=>{const t=Q.has(e);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>ie(e),disabled:!t,hitSlop:{left:8,right:8},...(0,_hitSlop.hitSlopMarker)({left:8,right:8}),accessibilityRole:"button",accessibilityLabel:(0,_index.fillText)(l.jumpTo,{letter:e}),accessibilityState:{disabled:!t},"aria-disabled":!t,style:H.railLetter,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",color:t?"brand":"tertiary",style:[H.railLetterText,{opacity:t?1:.45}],children:e})},e)})}):null]}),g?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.sheetFooter,{borderTopColor:V.colors["border-subtle"],paddingHorizontal:V.space.lg,paddingVertical:V.space.md}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:X,accessibilityRole:"button",accessibilityLabel:l.done,style:({pressed:e})=>[H.doneButton,{backgroundColor:e?V.colors["primary-pressed"]:V.colors.primary,borderRadius:V.radius.md,..._corners.smoothCorners,paddingVertical:V.space.sm,paddingHorizontal:V.space.lg}],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",style:{color:V.colors["on-primary"]},children:l.done})})}):null]})})}function OptionSheet(e){const{open:t,onOpenChange:i,onAfterClose:r,labels:s,onClose:o,haptic:a,...n}=e,l=(0,_index.useMobileUiText)("optionSheet",_optionSheetG.OPTION_SHEET_TEXT),c=(0,_react.useMemo)(()=>({...l,...s}),[l,s]),d=(0,_react.useRef)(i);d.current=i;const u=(0,_react.useRef)(!1);return(0,_react.useEffect)(()=>{u.current!==t&&(u.current=t,d.current?.(t))},[t]),(0,_jsxRuntime.jsx)(_index3.Modal,{open:t,onClose:o,presentation:"bottom",onDismissed:r,haptic:a,contentStyle:hostStyle,labels:{close:c.closePicker},accessibilityLabel:n.accessibilityLabel??n.title??c.fallbackName,children:(0,_jsxRuntime.jsx)(OptionSheetPanel,{...n,onClose:o,labels:c})})}OptionSheet.displayName="OptionSheet";const buildStyles=e=>_reactNative.StyleSheet.create({gestureRoot:{width:"100%"},sheet:{paddingBottom:e.space.lg,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:e.space.sm,paddingBottom:e.space.sm},sheetHandle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:e.space.xs},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:e.space.xs},railLetter:{paddingHorizontal:e.space.xs,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:Math.round(e.text.xs.size*e.leading.heading)},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:e.space.md},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:e.space.xxs},checkbox:{width:22,height:22,borderRadius:e.radius.sm,..._corners.smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:e.space.md},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors["on-primary"],transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:e.radius.pill,..._corners.smoothCorners,marginLeft:e.space.md},singleSelectedIcon:{marginLeft:e.space.md},sheetFooter:{borderTopWidth:_reactNative.StyleSheet.hairlineWidth,alignItems:"flex-end"},doneButton:{alignSelf:"flex-end"}});var _default=exports.default=OptionSheet;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseE164=exports.formatE164=exports.default=exports.PhoneNumberInput=exports.DEFAULT_CALLING_CODES=exports.ALL_CALLING_CODES=void 0;var _mobileCore=require("@webority/mobile-core"),_countries=require("@webority/mobile-core/phone/countries"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../text/index.js"),_phoneNumberInputG=require("../../text/phone/phoneNumberInput.g.js"),_index3=require("../../theme/index.js"),_index4=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hitSlop=require("../../utils/hitSlop.js"),_index5=require("../FieldBase/index.js"),_Chevron=require("../FieldBase/Chevron.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CALLING_CODES=exports.DEFAULT_CALLING_CODES=[{iso:"AU",code:"61",label:"Australia"},{iso:"CA",code:"1",label:"Canada"},{iso:"IN",code:"91",label:"India"},{iso:"SA",code:"966",label:"Saudi Arabia"},{iso:"SG",code:"65",label:"Singapore"},{iso:"AE",code:"971",label:"United Arab Emirates"},{iso:"GB",code:"44",label:"United Kingdom"},{iso:"US",code:"1",label:"United States"}],ALL_CALLING_CODES=exports.ALL_CALLING_CODES=(0,_mobileCore.getPhoneCountries)().map(e=>({iso:e.iso,code:e.callingCode,label:_countries.PHONE_COUNTRY_NAMES[e.iso]??e.iso})).sort((e,t)=>e.label.localeCompare(t.label)),digitsOnly=e=>e.replace(/[^0-9]/g,""),formatE164=e=>`+${e.callingCode}${e.nationalNumber}`;exports.formatE164=formatE164;const parseE164=(e,t,i)=>{const o=e.replace(/[^0-9]/g,"");if(!o)return null;const n=(0,_mobileCore.splitPhoneNumber)(`+${o}`);let r=n?.callingCode,l=n?.nationalNumber??"";if(!r){const e=Array.from(new Set(t.map(e=>e.code))).sort((e,t)=>t.length-e.length);if(r=e.find(e=>o.startsWith(e)),!r)return null;l=o.slice(r.length)}const a=t.filter(e=>e.code===r),s=a.find(e=>e.iso===i)?.iso??a.find(e=>e.iso===n?.country)?.iso??n?.country??a[0]?.iso??"";return{callingCode:r,nationalNumber:l,iso:s}};exports.parseE164=parseE164;const planOf=e=>(0,_mobileCore.isSupportedCountry)(e)?e:null,assertDefaultCountryVisible=(e,t)=>{if(void 0!==e&&!t.some(t=>t.iso===e))throw new RangeError(`PhoneNumberInput: defaultCountry "${e}" is not among the visible countries. Add it to countries, or remove it from hiddenCountries.`)},PhoneNumberInput=exports.PhoneNumberInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:o,onChange:n,e164:r,onChangeE164:l,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,onComplete:d,onValidityChange:c,countries:b=ALL_CALLING_CODES,popularCountries:p,hiddenCountries:m,showFlag:_=!0,renderFlag:h,renderCountry:f,showAlphabetIndex:g,defaultCountry:x,validation:C="any",maxLength:N,formatAsYouType:v=!0,countryLocked:y=!1,label:S,labelMode:I="top",labelStyle:L,placeholder:j,helperText:E,error:T,invalidMessage:V,required:F,disabled:A=!1,size:O="md",variant:P,radius:R,labels:D,haptic:q,accessibilityLabel:M,countryAccessibilityLabel:w,onFocus:k,onBlur:z,style:U,testID:B}=e;(0,_assertValidValue.assertValidValue)("PhoneNumberInput","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("PhoneNumberInput","variant",e.variant,["outline","filled","underline"]),(0,_assertValidValue.assertValidValue)("PhoneNumberInput","labelMode",e.labelMode,["top","float"]),(0,_assertValidValue.assertValidValue)("PhoneNumberInput","validation",!1===e.validation?void 0:e.validation,["any","mobile"]);const $=(0,_index3.useTheme)(),G=(0,_react.useMemo)(()=>buildStyles($),[$]),W=(0,_react.useRef)(null),H=(0,_index2.useMobileUiText)("phoneNumberInput",_phoneNumberInputG.PHONE_NUMBER_INPUT_TEXT),Y=(0,_react.useMemo)(()=>({...H,...D}),[H,D]),K=j??Y.placeholder,X=(0,_react.useMemo)(()=>/-([A-Za-z]{2})(?:-|$)/.exec((0,_mobileCore.getFormatterConfig)().locale)?.[1]?.toUpperCase(),[]),Z=(0,_react.useMemo)(()=>m?.length?b.filter(e=>!m.includes(e.iso)):b,[b,m]),J=(0,_react.useMemo)(()=>{if(!p?.length)return;const e=p.map(e=>Z.find(t=>t.iso===e)).filter(e=>void 0!==e);return e.length?[{title:Y.popular,options:e},{title:Y.allCountries,options:Z}]:void 0},[p,Y.popular,Y.allCountries,Z]),Q=(0,_react.useCallback)((e,t,i)=>{if(!e)return null;if(h)return h(e);if(!_)return null;const o=(0,_mobileCore.countryFlagEmoji)(e.iso);return o?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"body",style:[G.flag,{fontSize:t}],testID:i,children:o}):null},[h,_,G.flag]),ee=(0,_react.useCallback)(e=>{const t=planOf(e),i=t?(0,_mobileCore.maxNationalNumberLength)(t,!1===C?"any":C):Number.POSITIVE_INFINITY;return N?Math.min(i,N):i},[N,C]),te=(0,_react.useCallback)((e,t)=>e.slice(0,ee(t)),[ee]),ie=(0,_react.useCallback)((e,t)=>{const i=planOf(t)??void 0,o=(0,_mobileCore.splitPhoneNumber)(e,i);if(!o)return null;const n=o.country??t,r=b.find(e=>e.iso===n);return{callingCode:r?.code??o.callingCode,nationalNumber:te(o.nationalNumber,n),iso:r?.iso??n}},[b,te]);(0,_react.useState)(()=>assertDefaultCountryVisible(x,Z));const oe=(0,_react.useMemo)(()=>{const e=Z.find(e=>e.iso===(x??X))??Z[0]??b[0],t={callingCode:e?.code??"",nationalNumber:"",iso:e?.iso??""};return"string"==typeof o?ie(o,t.iso)??t:o??t},[b,Z,x,X,o,ie]),ne=(0,_react.useCallback)(e=>{if(!1===C)return e.nationalNumber.length>0;const t=planOf(e.iso);return t?(0,_mobileCore.isValidNationalNumber)(e.nationalNumber,t,C):e.nationalNumber.length>0},[C]),[re,le]=(0,_react.useState)(oe.iso),ae=(0,_react.useMemo)(()=>{if(void 0===r)return;const e=r?parseE164(r,b,re):null;if(e)return{...e,nationalNumber:te(e.nationalNumber,e.iso)};const t=b.find(e=>e.iso===re);return{callingCode:t?.code??oe.callingCode,nationalNumber:"",iso:re}},[r,b,re,oe.callingCode,te]),se=(0,_react.useCallback)(e=>{le(e.iso),n?.(e),l?.(e.nationalNumber?formatE164(e):"",{country:b.find(t=>t.iso===e.iso),national:e.nationalNumber,valid:ne(e)})},[n,l,b,ne]),[ue,de]=(0,_index.useControllableState)({value:i??ae,defaultValue:oe,onChange:se}),[ce,be]=(0,_react.useState)(!1),pe=(0,_react.useCallback)(()=>{A||W.current?.focus()},[A]),[me,he]=(0,_react.useState)(!1),[fe,ge]=(0,_react.useState)(!1),[xe,Ce]=(0,_react.useState)(!1),Ne=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{xe||(Ne.current=!1)},[xe]);const ve=(0,_index3.resolveFieldSize)($,O),ye=(0,_index5.resolveFieldTextStyle)($,{disabled:A}),Se=P??$.settings.components.field?.defaultVariant??"outline",Ie="underline"===Se,Le=$.space.md,[je,Ee]=(0,_react.useState)(0),Te=je+Le+1+Le,Ve=ue.nationalNumber.length>0,Fe=F&&!S&&!Ve&&K.length>0,Ae=ce||Ve,Oe=Boolean(S)&&"float"===I&&je>0,Pe=(0,_useFloatingLabel.useFloatingLabel)({label:S,enabled:Oe,floated:Ae,required:F,variant:Se,sizeTokens:ve,leadingOffset:Te,paddingLeft:Ie?$.space.none:ve["padding-x"],color:$.colors["field-label"],style:L}),Re=(0,_react.useMemo)(()=>b.find(e=>e.iso===ue.iso),[b,ue.iso]),De=planOf(ue.iso),qe=v&&De?(0,_mobileCore.formatPhoneAsTyped)(ue.nationalNumber,De):ue.nationalNumber,Me=ee(ue.iso),we=0===ue.nationalNumber.length||me||!Number.isFinite(Me)?void 0:qe.length+Math.max(0,Me-ue.nationalNumber.length),ke=ne(ue);(0,_react.useEffect)(()=>{Ve||ge(!1)},[Ve]);const ze=De?(0,_mobileCore.maxNationalNumberLength)(De,!1===C?"any":C):Number.POSITIVE_INFINITY,Ue=ue.nationalNumber.length>=ze,Be=!1!==C&&!1!==V&&Ve&&!ke&&(fe||Ue),$e="mobile"===C?Y.invalidMobile:Y.invalid,Ge=(0,_index5.hasFieldText)(T)?T:Be?V||$e:void 0,We=!0===T||(0,_index5.hasFieldText)(Ge),He=(0,_react.useRef)(ke),Ye=(0,_react.useRef)(ue);Ye.current=ue,(0,_react.useEffect)(()=>{He.current!==ke&&(He.current=ke,c?.(ke),ke&&d?.(formatE164(Ye.current)))},[ke,d,c]);const Ke=(0,_react.useCallback)(e=>{if((0,_mobileCore.reportIdleActivity)(),e.includes("+")){const t=ie(e,ue.iso);if(t&&!y&&Z.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)})},[Z,y,ue,ie,te,de]),Xe=(0,_react.useCallback)(e=>{de({callingCode:e.code,iso:e.iso,nationalNumber:te(ue.nationalNumber,e.iso)}),Ce(!1);const t=(0,_index4.resolveHaptic)(q,"selection");t&&(0,_index4.triggerHaptic)(t)},[ue,q,te,de]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>W.current?.focus(),blur:()=>W.current?.blur(),clear:()=>de({...Ye.current,nationalNumber:""}),isFocused:()=>W.current?.isFocused()??!1,getValue:()=>Ye.current,getE164:()=>formatE164(Ye.current),getFormatted:()=>{const e=Ye.current,t=planOf(e.iso);return t?(0,_mobileCore.formatPhoneAsTyped)(e.nationalNumber,t):e.nationalNumber},isValid:()=>ne(Ye.current),getCountry:()=>b.find(e=>e.iso===Ye.current.iso)}),[b,ne,de]);const Ze=A||y,Je=(0,_jsxRuntime.jsx)(_index5.FieldBase,{testID:B?`${B}-field`:void 0,size:O,variant:Se,radius:R,topNotch:Pe.topNotch,focused:ce,disabled:A,error:We,filled:Ve,onPress:pe,pressFeedback:!1,leadingDivider:!0,paddingLeft:Ie?$.space.none:void 0,leading:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{Ze||(Ne.current=!0,Ce(!0))},disabled:Ze,accessibilityRole:"button",accessibilityLabel:w??(0,_index2.fillText)(Y.countryButton,{callingCode:ue.callingCode}),accessibilityState:{disabled:Ze},"aria-disabled":Ze,hitSlop:6,...(0,_hitSlop.hitSlopMarker)(6),onLayout:e=>{const{width:t}=e.nativeEvent.layout;Ee(e=>e===t?e:t)},style:G.codeTrigger,testID:B?`${B}-code`:void 0,children:[Q(Re,ve.text,B?`${B}-flag`:void 0),(0,_jsxRuntime.jsx)(_index6.Text,{variant:"body",style:[G.codeText,{color:ye.color,fontSize:ve.text}],children:`+${ue.callingCode}`}),y?null:(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:A?$.colors["field-icon-disabled"]:$.colors["field-icon"],size:ve.icon,open:xe})]}),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:G.inputWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:W,value:qe,maxLength:we,onChangeText:Ke,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,onSelectionChange:e=>{const{start:t,end:i}=e.nativeEvent.selection;he(t!==i)},onFocus:()=>{be(!0),k?.()},onBlur:()=>{be(!1),Ve&&!Ne.current&&ge(!0),z?.()},editable:!A,placeholder:Oe&&!Ae||Fe?void 0:K,placeholderTextColor:ye.placeholderColor,accessibilityLabel:M??S??K,selectionColor:$.colors["field-caret"],keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",style:[G.input,{color:ye.color,fontSize:ve.text,...ye.weightStyle,paddingLeft:Ie?$.space.none:void 0}],testID:B?`${B}-input`:void 0}),Fe?(0,_jsxRuntime.jsx)(_index5.RequiredPlaceholder,{text:K,color:ye.placeholderColor,fontSize:ve.text,weightStyle:ye.weightStyle}):null]})});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:U,testID:B,children:[S&&"top"===I?(0,_jsxRuntime.jsx)(_index5.FieldLabel,{size:O,required:F,style:L,children:S}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:G.fieldWrapper,children:[Je,Pe.node]}),(0,_jsxRuntime.jsx)(_index5.FieldMessage,{size:O,error:We,text:We?Ge:E}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:xe,haptic:q,onClose:()=>Ce(!1),title:Y.countrySheetTitle,options:Z,sections:J,getOptionLabel:e=>`${e.label} (+${e.code})`,getOptionValue:e=>e.iso,getOptionIcon:e=>Q(e,$.text.lg.size),renderOption:f?({option:e,selected:t})=>f(e,{selected:t}):void 0,value:Re?.iso,onChange:(e,t)=>Xe(t),searchable:Z.length>8,labels:{searchPlaceholder:Y.countrySearchPlaceholder},alphabetIndex:g??Z.length>20})]})});PhoneNumberInput.displayName="PhoneNumberInput";const buildStyles=e=>_reactNative.StyleSheet.create({fieldWrapper:{position:"relative",overflow:"visible"},codeTrigger:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},flag:{includeFontPadding:!1,marginRight:e.space.xs},codeText:{...(0,_index3.fontFor)(e,"semibold"),fontWeight:"600",includeFontPadding:!1,writingDirection:"ltr"},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1,writingDirection:"ltr"},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"}});var _default=exports.default=PhoneNumberInput;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseE164=exports.formatE164=exports.default=exports.PhoneNumberInput=exports.DEFAULT_CALLING_CODES=exports.ALL_CALLING_CODES=void 0;var _mobileCore=require("@webority/mobile-core"),_countries=require("@webority/mobile-core/phone/countries"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../text/index.js"),_phoneNumberInputG=require("../../text/phone/phoneNumberInput.g.js"),_index3=require("../../theme/index.js"),_index4=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hitSlop=require("../../utils/hitSlop.js"),_index5=require("../FieldBase/index.js"),_Chevron=require("../FieldBase/Chevron.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CALLING_CODES=exports.DEFAULT_CALLING_CODES=[{iso:"AU",code:"61",label:"Australia"},{iso:"CA",code:"1",label:"Canada"},{iso:"IN",code:"91",label:"India"},{iso:"SA",code:"966",label:"Saudi Arabia"},{iso:"SG",code:"65",label:"Singapore"},{iso:"AE",code:"971",label:"United Arab Emirates"},{iso:"GB",code:"44",label:"United Kingdom"},{iso:"US",code:"1",label:"United States"}],ALL_CALLING_CODES=exports.ALL_CALLING_CODES=(0,_mobileCore.getPhoneCountries)().map(e=>({iso:e.iso,code:e.callingCode,label:_countries.PHONE_COUNTRY_NAMES[e.iso]??e.iso})).sort((e,t)=>e.label.localeCompare(t.label)),digitsOnly=e=>e.replace(/[^0-9]/g,""),formatE164=e=>`+${e.callingCode}${e.nationalNumber}`;exports.formatE164=formatE164;const parseE164=(e,t,i)=>{const o=e.replace(/[^0-9]/g,"");if(!o)return null;const n=(0,_mobileCore.splitPhoneNumber)(`+${o}`);let r=n?.callingCode,l=n?.nationalNumber??"";if(!r){const e=Array.from(new Set(t.map(e=>e.code))).sort((e,t)=>t.length-e.length);if(r=e.find(e=>o.startsWith(e)),!r)return null;l=o.slice(r.length)}const a=t.filter(e=>e.code===r),s=a.find(e=>e.iso===i)?.iso??a.find(e=>e.iso===n?.country)?.iso??n?.country??a[0]?.iso??"";return{callingCode:r,nationalNumber:l,iso:s}};exports.parseE164=parseE164;const planOf=e=>(0,_mobileCore.isSupportedCountry)(e)?e:null,assertDefaultCountryVisible=(e,t)=>{if(void 0!==e&&!t.some(t=>t.iso===e))throw new RangeError(`PhoneNumberInput: defaultCountry "${e}" is not among the visible countries. Add it to countries, or remove it from hiddenCountries.`)},PhoneNumberInput=({ref:e,...t})=>{const{value:i,defaultValue:o,onChange:n,e164:r,onChangeE164:l,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,onComplete:d,onValidityChange:c,countries:b=ALL_CALLING_CODES,popularCountries:p,hiddenCountries:m,showFlag:_=!0,renderFlag:h,renderCountry:f,showAlphabetIndex:g,defaultCountry:x,validation:C="any",maxLength:N,formatAsYouType:v=!0,countryLocked:y=!1,label:S,labelMode:I="top",labelStyle:L,placeholder:j,helperText:E,error:T,invalidMessage:V,required:F,disabled:A=!1,size:O="md",variant:P,radius:R,labels:D,haptic:q,accessibilityLabel:M,countryAccessibilityLabel:w,onFocus:k,onBlur:z,style:U,testID:B}=t;(0,_assertValidValue.assertValidValue)("PhoneNumberInput","size",t.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("PhoneNumberInput","variant",t.variant,["outline","filled","underline"]),(0,_assertValidValue.assertValidValue)("PhoneNumberInput","labelMode",t.labelMode,["top","float"]),(0,_assertValidValue.assertValidValue)("PhoneNumberInput","validation",!1===t.validation?void 0:t.validation,["any","mobile"]);const $=(0,_index3.useTheme)(),G=(0,_react.useMemo)(()=>buildStyles($),[$]),W=(0,_react.useRef)(null),H=(0,_index2.useMobileUiText)("phoneNumberInput",_phoneNumberInputG.PHONE_NUMBER_INPUT_TEXT),Y=(0,_react.useMemo)(()=>({...H,...D}),[H,D]),K=j??Y.placeholder,X=(0,_react.useMemo)(()=>/-([A-Za-z]{2})(?:-|$)/.exec((0,_mobileCore.getFormatterConfig)().locale)?.[1]?.toUpperCase(),[]),Z=(0,_react.useMemo)(()=>m?.length?b.filter(e=>!m.includes(e.iso)):b,[b,m]),J=(0,_react.useMemo)(()=>{if(!p?.length)return;const e=p.map(e=>Z.find(t=>t.iso===e)).filter(e=>void 0!==e);return e.length?[{title:Y.popular,options:e},{title:Y.allCountries,options:Z}]:void 0},[p,Y.popular,Y.allCountries,Z]),Q=(0,_react.useCallback)((e,t,i)=>{if(!e)return null;if(h)return h(e);if(!_)return null;const o=(0,_mobileCore.countryFlagEmoji)(e.iso);return o?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"body",style:[G.flag,{fontSize:t}],testID:i,children:o}):null},[h,_,G.flag]),ee=(0,_react.useCallback)(e=>{const t=planOf(e),i=t?(0,_mobileCore.maxNationalNumberLength)(t,!1===C?"any":C):Number.POSITIVE_INFINITY;return N?Math.min(i,N):i},[N,C]),te=(0,_react.useCallback)((e,t)=>e.slice(0,ee(t)),[ee]),ie=(0,_react.useCallback)((e,t)=>{const i=planOf(t)??void 0,o=(0,_mobileCore.splitPhoneNumber)(e,i);if(!o)return null;const n=o.country??t,r=b.find(e=>e.iso===n);return{callingCode:r?.code??o.callingCode,nationalNumber:te(o.nationalNumber,n),iso:r?.iso??n}},[b,te]);(0,_react.useState)(()=>assertDefaultCountryVisible(x,Z));const oe=(0,_react.useMemo)(()=>{const e=Z.find(e=>e.iso===(x??X))??Z[0]??b[0],t={callingCode:e?.code??"",nationalNumber:"",iso:e?.iso??""};return"string"==typeof o?ie(o,t.iso)??t:o??t},[b,Z,x,X,o,ie]),ne=(0,_react.useCallback)(e=>{if(!1===C)return e.nationalNumber.length>0;const t=planOf(e.iso);return t?(0,_mobileCore.isValidNationalNumber)(e.nationalNumber,t,C):e.nationalNumber.length>0},[C]),[re,le]=(0,_react.useState)(oe.iso),ae=(0,_react.useMemo)(()=>{if(void 0===r)return;const e=r?parseE164(r,b,re):null;if(e)return{...e,nationalNumber:te(e.nationalNumber,e.iso)};const t=b.find(e=>e.iso===re);return{callingCode:t?.code??oe.callingCode,nationalNumber:"",iso:re}},[r,b,re,oe.callingCode,te]),se=(0,_react.useCallback)(e=>{le(e.iso),n?.(e),l?.(e.nationalNumber?formatE164(e):"",{country:b.find(t=>t.iso===e.iso),national:e.nationalNumber,valid:ne(e)})},[n,l,b,ne]),[ue,de]=(0,_index.useControllableState)({value:i??ae,defaultValue:oe,onChange:se}),[ce,be]=(0,_react.useState)(!1),pe=(0,_react.useCallback)(()=>{A||W.current?.focus()},[A]),[me,he]=(0,_react.useState)(!1),[fe,ge]=(0,_react.useState)(!1),[xe,Ce]=(0,_react.useState)(!1),Ne=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{xe||(Ne.current=!1)},[xe]);const ve=(0,_index3.resolveFieldSize)($,O),ye=(0,_index5.resolveFieldTextStyle)($,{disabled:A}),Se=P??$.settings.components.field?.defaultVariant??"outline",Ie="underline"===Se,Le=$.space.md,[je,Ee]=(0,_react.useState)(0),Te=je+Le+1+Le,Ve=ue.nationalNumber.length>0,Fe=F&&!S&&!Ve&&K.length>0,Ae=ce||Ve,Oe=Boolean(S)&&"float"===I&&je>0,Pe=(0,_useFloatingLabel.useFloatingLabel)({label:S,enabled:Oe,floated:Ae,required:F,variant:Se,sizeTokens:ve,leadingOffset:Te,paddingLeft:Ie?$.space.none:ve["padding-x"],color:$.colors["field-label"],style:L}),Re=(0,_react.useMemo)(()=>b.find(e=>e.iso===ue.iso),[b,ue.iso]),De=planOf(ue.iso),qe=v&&De?(0,_mobileCore.formatPhoneAsTyped)(ue.nationalNumber,De):ue.nationalNumber,Me=ee(ue.iso),we=0===ue.nationalNumber.length||me||!Number.isFinite(Me)?void 0:qe.length+Math.max(0,Me-ue.nationalNumber.length),ke=ne(ue);(0,_react.useEffect)(()=>{Ve||ge(!1)},[Ve]);const ze=De?(0,_mobileCore.maxNationalNumberLength)(De,!1===C?"any":C):Number.POSITIVE_INFINITY,Ue=ue.nationalNumber.length>=ze,Be=!1!==C&&!1!==V&&Ve&&!ke&&(fe||Ue),$e="mobile"===C?Y.invalidMobile:Y.invalid,Ge=(0,_index5.hasFieldText)(T)?T:Be?V||$e:void 0,We=!0===T||(0,_index5.hasFieldText)(Ge),He=(0,_react.useRef)(ke),Ye=(0,_react.useRef)(ue);Ye.current=ue,(0,_react.useEffect)(()=>{He.current!==ke&&(He.current=ke,c?.(ke),ke&&d?.(formatE164(Ye.current)))},[ke,d,c]);const Ke=(0,_react.useCallback)(e=>{if((0,_mobileCore.reportIdleActivity)(),e.includes("+")){const t=ie(e,ue.iso);if(t&&!y&&Z.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)})},[Z,y,ue,ie,te,de]),Xe=(0,_react.useCallback)(e=>{de({callingCode:e.code,iso:e.iso,nationalNumber:te(ue.nationalNumber,e.iso)}),Ce(!1);const t=(0,_index4.resolveHaptic)(q,"selection");t&&(0,_index4.triggerHaptic)(t)},[ue,q,te,de]);(0,_react.useImperativeHandle)(e,()=>({focus:()=>W.current?.focus(),blur:()=>W.current?.blur(),clear:()=>de({...Ye.current,nationalNumber:""}),isFocused:()=>W.current?.isFocused()??!1,getValue:()=>Ye.current,getE164:()=>formatE164(Ye.current),getFormatted:()=>{const e=Ye.current,t=planOf(e.iso);return t?(0,_mobileCore.formatPhoneAsTyped)(e.nationalNumber,t):e.nationalNumber},isValid:()=>ne(Ye.current),getCountry:()=>b.find(e=>e.iso===Ye.current.iso)}),[b,ne,de]);const Ze=A||y,Je=(0,_jsxRuntime.jsx)(_index5.FieldBase,{testID:B?`${B}-field`:void 0,size:O,variant:Se,radius:R,topNotch:Pe.topNotch,focused:ce,disabled:A,error:We,filled:Ve,onPress:pe,pressFeedback:!1,leadingDivider:!0,paddingLeft:Ie?$.space.none:void 0,leading:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{Ze||(Ne.current=!0,Ce(!0))},disabled:Ze,accessibilityRole:"button",accessibilityLabel:w??(0,_index2.fillText)(Y.countryButton,{callingCode:ue.callingCode}),accessibilityState:{disabled:Ze},"aria-disabled":Ze,hitSlop:6,...(0,_hitSlop.hitSlopMarker)(6),onLayout:e=>{const{width:t}=e.nativeEvent.layout;Ee(e=>e===t?e:t)},style:G.codeTrigger,testID:B?`${B}-code`:void 0,children:[Q(Re,ve.text,B?`${B}-flag`:void 0),(0,_jsxRuntime.jsx)(_index6.Text,{variant:"body",style:[G.codeText,{color:ye.color,fontSize:ve.text}],children:`+${ue.callingCode}`}),y?null:(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:A?$.colors["field-icon-disabled"]:$.colors["field-icon"],size:ve.icon,open:xe})]}),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:G.inputWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:W,value:qe,maxLength:we,onChangeText:Ke,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,onSelectionChange:e=>{const{start:t,end:i}=e.nativeEvent.selection;he(t!==i)},onFocus:()=>{be(!0),k?.()},onBlur:()=>{be(!1),Ve&&!Ne.current&&ge(!0),z?.()},editable:!A,placeholder:Oe&&!Ae||Fe?void 0:K,placeholderTextColor:ye.placeholderColor,accessibilityLabel:M??S??K,selectionColor:$.colors["field-caret"],keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",style:[G.input,{color:ye.color,fontSize:ve.text,...ye.weightStyle,paddingLeft:Ie?$.space.none:void 0}],testID:B?`${B}-input`:void 0}),Fe?(0,_jsxRuntime.jsx)(_index5.RequiredPlaceholder,{text:K,color:ye.placeholderColor,fontSize:ve.text,weightStyle:ye.weightStyle}):null]})});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:U,testID:B,children:[S&&"top"===I?(0,_jsxRuntime.jsx)(_index5.FieldLabel,{size:O,required:F,style:L,children:S}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:G.fieldWrapper,children:[Je,Pe.node]}),(0,_jsxRuntime.jsx)(_index5.FieldMessage,{size:O,error:We,text:We?Ge:E}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:xe,haptic:q,onClose:()=>Ce(!1),title:Y.countrySheetTitle,options:Z,sections:J,getOptionLabel:e=>`${e.label} (+${e.code})`,getOptionValue:e=>e.iso,getOptionIcon:e=>Q(e,$.text.lg.size),renderOption:f?({option:e,selected:t})=>f(e,{selected:t}):void 0,value:Re?.iso,onChange:(e,t)=>Xe(t),searchable:Z.length>8,labels:{searchPlaceholder:Y.countrySearchPlaceholder},alphabetIndex:g??Z.length>20})]})};exports.PhoneNumberInput=PhoneNumberInput;const buildStyles=e=>_reactNative.StyleSheet.create({fieldWrapper:{position:"relative",overflow:"visible"},codeTrigger:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},flag:{includeFontPadding:!1,marginRight:e.space.xs},codeText:{...(0,_index3.fontFor)(e,"semibold"),fontWeight:"600",includeFontPadding:!1,writingDirection:"ltr"},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1,writingDirection:"ltr"},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"}});var _default=exports.default=PhoneNumberInput;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.PickerTrigger=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../text/index.js"),_pickerTriggerG=require("../../text/phone/pickerTrigger.g.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index3=require("../FieldBase/index.js"),_Chevron=require("../FieldBase/Chevron.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const PickerTrigger=exports.PickerTrigger=(0,_react.forwardRef)((e,i)=>{(0,_assertValidValue.assertValidValue)("PickerTrigger","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("PickerTrigger","variant",e.variant,["outline","filled","underline"]);const{value:r,placeholder:t,label:l,help:s,helperText:a,error:n,required:d=!1,onPress:o,clearable:c=!1,onClear:x,leftIcon:u,trailing:_,disabled:g=!1,size:b="md",variant:j,style:y,triggerStyle:v,valueStyle:T,labelStyle:h,messageStyle:m,accessibilityLabel:p,labels:R,testID:f}=e,P=(0,_index.useMobileUiText)("pickerTrigger",_pickerTriggerG.PICKER_TRIGGER_TEXT),S=(0,_react.useMemo)(()=>({...P,...R}),[P,R]),V=(0,_index2.useTheme)(),k=(0,_react.useMemo)(()=>buildStyles(V),[V]),q=(0,_index2.resolveFieldSize)(V,b),F=(0,_index3.resolveFieldTextStyle)(V,{disabled:g}),z="string"==typeof r&&r.length>0,w=!0===n||(0,_index3.hasFieldText)(n),C=(0,_index3.hasFieldText)(l),I=z?r:t??S.placeholder,M=z?F.color:F.placeholderColor,L=z?`${(0,_index3.fieldTextAsString)(l)??S.selection}: ${r}`:t??S.noSelection,N=p??L,G={disabled:g},B=void 0===_,D=c&&z&&!g;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[k.root,y],testID:f,children:[C?(0,_jsxRuntime.jsx)(_index3.FieldLabel,{size:b,required:d,help:s,style:h,children:l}):null,(0,_jsxRuntime.jsx)(_index3.FieldBase,{size:b,variant:j,disabled:g,error:w,filled:z,onPress:o,leading:u,trailing:D||B||null!==_?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:k.trailingRow,children:[D?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",onPress:()=>{g||x?.()},accessibilityRole:"button",accessibilityLabel:S.clear,style:{fontSize:q.icon,color:V.colors["text-muted"],paddingHorizontal:V.space.xs},children:"×"}):null,void 0!==_?_:B?(0,_jsxRuntime.jsx)(_Chevron.Chevron,{size:q.icon,color:g?V.colors["text-disabled"]:V.colors["text-subtle"]}):null]}):null,accessibilityLabel:N,accessibilityState:G,accessibilityRole:"button",style:v,children:(0,_jsxRuntime.jsxs)(_index4.Text,{variant:"body",numberOfLines:1,style:[k.valueText,{color:M,fontSize:q.text,...F.weightStyle},T],children:[I,z||!d||C?null:(0,_jsxRuntime.jsx)(_index3.RequiredMark,{})]})}),(0,_jsxRuntime.jsx)(_index3.FieldMessage,{size:b,error:w,text:w?n:a,style:m})]})});PickerTrigger.displayName="PickerTrigger";const buildStyles=e=>_reactNative.StyleSheet.create({root:{width:"100%"},label:{includeFontPadding:!1},valueText:{flex:1,includeFontPadding:!1},message:{includeFontPadding:!1},trailingRow:{flexDirection:"row",alignItems:"center"}});var _default=exports.default=PickerTrigger;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PickerTrigger=PickerTrigger,exports.default=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../text/index.js"),_pickerTriggerG=require("../../text/phone/pickerTrigger.g.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index3=require("../FieldBase/index.js"),_Chevron=require("../FieldBase/Chevron.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function PickerTrigger(e){(0,_assertValidValue.assertValidValue)("PickerTrigger","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("PickerTrigger","variant",e.variant,["outline","filled","underline"]);const{value:i,placeholder:r,label:t,help:l,helperText:s,error:a,required:n=!1,onPress:d,clearable:o=!1,onClear:c,leftIcon:x,trailing:u,disabled:_=!1,size:g="md",variant:b,style:j,triggerStyle:v,valueStyle:y,labelStyle:h,messageStyle:T,accessibilityLabel:m,labels:p,testID:R}=e,S=(0,_index.useMobileUiText)("pickerTrigger",_pickerTriggerG.PICKER_TRIGGER_TEXT),f=(0,_react.useMemo)(()=>({...S,...p}),[S,p]),P=(0,_index2.useTheme)(),V=(0,_react.useMemo)(()=>buildStyles(P),[P]),q=(0,_index2.resolveFieldSize)(P,g),F=(0,_index3.resolveFieldTextStyle)(P,{disabled:_}),k="string"==typeof i&&i.length>0,z=!0===a||(0,_index3.hasFieldText)(a),w=(0,_index3.hasFieldText)(t),C=k?i:r??f.placeholder,I=k?F.color:F.placeholderColor,M=k?`${(0,_index3.fieldTextAsString)(t)??f.selection}: ${i}`:r??f.noSelection,L=m??M,G={disabled:_},N=void 0===u,B=o&&k&&!_;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[V.root,j],testID:R,children:[w?(0,_jsxRuntime.jsx)(_index3.FieldLabel,{size:g,required:n,help:l,style:h,children:t}):null,(0,_jsxRuntime.jsx)(_index3.FieldBase,{size:g,variant:b,disabled:_,error:z,filled:k,onPress:d,leading:x,trailing:B||N||null!==u?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:V.trailingRow,children:[B?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",onPress:()=>{_||c?.()},accessibilityRole:"button",accessibilityLabel:f.clear,style:{fontSize:q.icon,color:P.colors["text-muted"],paddingHorizontal:P.space.xs},children:"×"}):null,void 0!==u?u:N?(0,_jsxRuntime.jsx)(_Chevron.Chevron,{size:q.icon,color:_?P.colors["text-disabled"]:P.colors["text-subtle"]}):null]}):null,accessibilityLabel:L,accessibilityState:G,accessibilityRole:"button",style:v,children:(0,_jsxRuntime.jsxs)(_index4.Text,{variant:"body",numberOfLines:1,style:[V.valueText,{color:I,fontSize:q.text,...F.weightStyle},y],children:[C,k||!n||w?null:(0,_jsxRuntime.jsx)(_index3.RequiredMark,{})]})}),(0,_jsxRuntime.jsx)(_index3.FieldMessage,{size:g,error:z,text:z?a:s,style:T})]})}const buildStyles=e=>_reactNative.StyleSheet.create({root:{width:"100%"},label:{includeFontPadding:!1},valueText:{flex:1,includeFontPadding:!1},message:{includeFontPadding:!1},trailingRow:{flexDirection:"row",alignItems:"center"}});var _default=exports.default=PickerTrigger;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ProfileCompletion=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../text/index.js"),_profileCompletionG=require("../../text/phone/profileCompletion.g.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index3=require("../AppIcon/index.js"),_index4=require("../Avatar/index.js"),_index5=require("../IconBadge/index.js"),_index6=require("../ProgressRing/index.js"),_index7=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const AVATAR_PX={sm:32,md:48,lg:64,xl:80},toneColor=(e,i)=>{switch(i){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["text-muted"];default:return e.colors.primary}},DEFAULT_RING_WIDTH=3,DEFAULT_RING_GAP=1,ProfileCompletion=exports.ProfileCompletion=(0,_react.forwardRef)((e,i)=>{const{progress:t,title:r,subtitle:s,description:n,source:a,ImageComponent:l,size:o="md",avatarTone:c="neutral",avatarBackgroundColor:u,avatarColor:d,ringWidth:m,ringGap:x=DEFAULT_RING_GAP,ringVariant:_="banded",tone:p,ringColor:g,animated:f=!0,showCompleteBadge:y=!0,trailing:j,labels:b,accessibilityLabel:h,style:V,titleStyle:v,subtitleStyle:C,descriptionStyle:R,testID:T}=e;(0,_assertValidValue.assertValidValue)("ProfileCompletion","size",e.size,["sm","md","lg","xl"]),(0,_assertValidValue.assertValidValue)("ProfileCompletion","ringVariant",e.ringVariant,["banded","single"]),(0,_assertValidValue.assertValidValue)("ProfileCompletion","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const I=(0,_index2.useTheme)(),P=(0,_react.useMemo)(()=>buildStyles(I),[I]),w=(0,_index.useMobileUiText)("profileCompletion",_profileCompletionG.PROFILE_COMPLETION_TEXT),A=(0,_react.useMemo)(()=>({...w,...b}),[w,b]),N=m??3,q=AVATAR_PX[o]+2*(x+N),D=Math.min(100,Math.max(0,Number.isNaN(t)?0:t)),G=Math.round(D),M=h??(0,_index.fillText)(A.summary,{title:r,percent:G}),L=T??"profile-completion",S=y&&D>=100,E=Math.max(16,Math.round(.3*q)),z=q/2*(1+Math.SQRT1_2)-N/2,O=g??("banded"===_&&null==p?I.colors.success:toneColor(I,p??"primary"));return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:i,style:[P.root,V],testID:T,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:P.summary,accessible:!0,accessibilityRole:"summary",accessibilityLabel:M,accessibilityValue:{min:0,max:100,now:G},testID:`${L}-summary`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{width:q,height:q},children:[(0,_jsxRuntime.jsx)(_index6.ProgressRing,{progress:D/100,size:q,strokeWidth:N,tone:p??"primary",ringColor:g,colorByProgress:"banded"===_&&null==p&&null==g,animated:f,testID:`${L}-ring`,children:(0,_jsxRuntime.jsx)(_index4.Avatar,{name:r,source:a,ImageComponent:l,size:o,tone:c,backgroundColor:u,color:d,accessibilityLabel:(0,_index.fillText)(A.avatar,{title:r})})}),S?(0,_jsxRuntime.jsx)(_index5.IconBadge,{dimension:E,fill:"surface",icon:(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"verify",variant:"bold",size:E-2,color:O}),pointerEvents:"none",style:[P.badge,{left:z-E/2,top:z-E/2}],testID:`${L}-complete-badge`}):null]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:P.body,children:[(0,_jsxRuntime.jsx)(_index7.Text,{variant:"h3",numberOfLines:2,style:v,children:r}),s?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"label",color:"tertiary",numberOfLines:1,style:[P.subtitle,C],children:s}):null,n?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"body",color:"secondary",style:R,children:n}):null]})]}),null!=j?(0,_jsxRuntime.jsx)(_reactNative.View,{style:P.trailing,children:j}):null]})});ProfileCompletion.displayName="ProfileCompletion";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flexDirection:"row",alignItems:"center",columnGap:e.space.md},summary:{flex:1,flexDirection:"row",alignItems:"center",columnGap:e.space.md},body:{flex:1,rowGap:e.space.xxs},badge:{position:"absolute"},subtitle:{textTransform:"uppercase",letterSpacing:e["letter-spacing"].wide},trailing:{alignSelf:"flex-start"}});var _default=exports.default=ProfileCompletion;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProfileCompletion=ProfileCompletion,exports.default=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../text/index.js"),_profileCompletionG=require("../../text/phone/profileCompletion.g.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index3=require("../AppIcon/index.js"),_index4=require("../Avatar/index.js"),_index5=require("../IconBadge/index.js"),_index6=require("../ProgressRing/index.js"),_index7=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const AVATAR_PX={sm:32,md:48,lg:64,xl:80},toneColor=(e,i)=>{switch(i){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["text-muted"];default:return e.colors.primary}},DEFAULT_RING_WIDTH=3,DEFAULT_RING_GAP=1;function ProfileCompletion({ref:e,...i}){const{progress:t,title:r,subtitle:n,description:s,source:a,ImageComponent:l,size:o="md",avatarTone:c="neutral",avatarBackgroundColor:u,avatarColor:d,ringWidth:x,ringGap:m=DEFAULT_RING_GAP,ringVariant:_="banded",tone:p,ringColor:g,animated:f=!0,showCompleteBadge:y=!0,trailing:j,labels:b,accessibilityLabel:h,style:V,titleStyle:v,subtitleStyle:R,descriptionStyle:C,testID:T}=i;(0,_assertValidValue.assertValidValue)("ProfileCompletion","size",i.size,["sm","md","lg","xl"]),(0,_assertValidValue.assertValidValue)("ProfileCompletion","ringVariant",i.ringVariant,["banded","single"]),(0,_assertValidValue.assertValidValue)("ProfileCompletion","tone",i.tone,["primary","success","warning","danger","info","neutral"]);const I=(0,_index2.useTheme)(),P=(0,_react.useMemo)(()=>buildStyles(I),[I]),w=(0,_index.useMobileUiText)("profileCompletion",_profileCompletionG.PROFILE_COMPLETION_TEXT),A=(0,_react.useMemo)(()=>({...w,...b}),[w,b]),N=x??DEFAULT_RING_WIDTH,D=AVATAR_PX[o]+2*(m+N),q=Math.min(100,Math.max(0,Number.isNaN(t)?0:t)),G=Math.round(q),L=h??(0,_index.fillText)(A.summary,{title:r,percent:G}),M=T??"profile-completion",S=y&&q>=100,E=Math.max(16,Math.round(.3*D)),z=D/2*(1+Math.SQRT1_2)-N/2,O=g??("banded"===_&&null==p?I.colors.success:toneColor(I,p??"primary"));return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:e,style:[P.root,V],testID:T,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:P.summary,accessible:!0,accessibilityRole:"summary",accessibilityLabel:L,accessibilityValue:{min:0,max:100,now:G},testID:`${M}-summary`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{width:D,height:D},children:[(0,_jsxRuntime.jsx)(_index6.ProgressRing,{progress:q/100,size:D,strokeWidth:N,tone:p??"primary",ringColor:g,colorByProgress:"banded"===_&&null==p&&null==g,animated:f,testID:`${M}-ring`,children:(0,_jsxRuntime.jsx)(_index4.Avatar,{name:r,source:a,ImageComponent:l,size:o,tone:c,backgroundColor:u,color:d,accessibilityLabel:(0,_index.fillText)(A.avatar,{title:r})})}),S?(0,_jsxRuntime.jsx)(_index5.IconBadge,{dimension:E,fill:"surface",icon:(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"verify",variant:"bold",size:E-2,color:O}),pointerEvents:"none",style:[P.badge,{left:z-E/2,top:z-E/2}],testID:`${M}-complete-badge`}):null]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:P.body,children:[(0,_jsxRuntime.jsx)(_index7.Text,{variant:"h3",numberOfLines:2,style:v,children:r}),n?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"label",color:"tertiary",numberOfLines:1,style:[P.subtitle,R],children:n}):null,s?(0,_jsxRuntime.jsx)(_index7.Text,{variant:"body",color:"secondary",style:C,children:s}):null]})]}),null!=j?(0,_jsxRuntime.jsx)(_reactNative.View,{style:P.trailing,children:j}):null]})}const buildStyles=e=>_reactNative.StyleSheet.create({root:{flexDirection:"row",alignItems:"center",columnGap:e.space.md},summary:{flex:1,flexDirection:"row",alignItems:"center",columnGap:e.space.md},body:{flex:1,rowGap:e.space.xxs},badge:{position:"absolute"},subtitle:{textTransform:"uppercase",letterSpacing:e["letter-spacing"].wide},trailing:{alignSelf:"flex-start"}});var _default=exports.default=ProfileCompletion;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ProgressBar=void 0;var _react=require("react"),_reactNative=require("react-native"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../text/index.js"),_progressBarG=require("../../text/phone/progressBar.g.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;case"primary":return e.colors.primary}},DETERMINATE_ANIMATION_DURATION=400,INDETERMINATE_LOOP_DURATION=1500,INDETERMINATE_WIDTH="30%",GLOW_LOCATIONS=[0,.35,.5,.65,1],glowOf=e=>{const t=(0,_color.tintOf)(e,0,"transparent"),r=(0,_color.tintOf)(e,.6,e);return{colors:[t,r,e,r,t],locations:GLOW_LOCATIONS,start:{x:0,y:.5},end:{x:1,y:.5}}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)||e<0?0:e>1?1:e,ProgressBar=exports.ProgressBar=(0,_react.forwardRef)((e,t)=>{const r=(0,_index2.useTheme)(),i=(0,_useReducedMotion.useReducedMotion)(),{progress:a,label:s,showPercent:n=!1,valueLabel:o,indeterminate:l,height:c=6,radius:u,tone:d="primary",trackColor:_,barColor:m,gradient:g,segments:p,animated:x=!0,style:y,barStyle:h,accessibilityLabel:v,labels:b,testID:f}=e;(0,_assertValidValue.assertValidValue)("ProgressBar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const R=(0,_index.useMobileUiText)("progressBar",_progressBarG.PROGRESS_BAR_TEXT),j=(0,_react.useMemo)(()=>({...R,...b}),[R,b]),w=l??"number"!=typeof a,N=clampProgress(a),V=(0,_react.useRef)((0,_index2.createAnimatedValue)(N)).current,A=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,T=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,O=(0,_react.useRef)(0),B=(0,_react.useMemo)(()=>buildStyles(r),[r]),E=u??r.radius.pill,D=_??r.colors["surface-disabled"],M=m??toneColor(r,d),P=(0,_react.useMemo)(()=>{if(null==g)return null;if("string"!=typeof g)return g;const e=r.settings.gradients[g];if(void 0===e){const e=Object.keys(r.settings.gradients);throw new RangeError(`[@webority/mobile-ui] <ProgressBar> received gradient="${g}", which is not a gradient in theme.settings.gradients (${e.length>0?`known: ${e.map(e=>`"${e}"`).join(", ")}`:"the theme defines none"}). Pass a known gradient name or a GradientDefinition, or omit the prop.`)}return e},[g,r.settings.gradients]),I=(0,_react.useMemo)(()=>glowOf(M),[M]),S=Array.isArray(p)&&p.length>0,k=(0,_react.useMemo)(()=>(p??[]).map((e,t)=>({key:`segment-${t}`,segment:e})),[p]);(0,_react.useEffect)(()=>{w||(x?_reactNative.Animated.timing(V,{toValue:N,duration:400,easing:_reactNative.Easing.bezier(...r.motion.ease["in-out"]),useNativeDriver:!1}).start():V.setValue(N))},[x,N,V,w,r]),(0,_react.useEffect)(()=>{if(!w)return;(0,_index2.setNativeValue)(A,0);const e=_reactNative.Animated.loop(_reactNative.Animated.timing(A,{toValue:1,duration:1500,easing:_reactNative.Easing.inOut(_reactNative.Easing.ease),useNativeDriver:_nativeDriver.nativeDriver}));return e.start(),()=>{e.stop()}},[w,A]);const C=V.interpolate({inputRange:[0,1],outputRange:["0%","100%"]}),q=A.interpolate({inputRange:[0,1],outputRange:[-1,1]}),G=A.interpolate({inputRange:[0,.5,1],outputRange:[.4,1,.4]}),L=n&&!w&&!S,$=null!=s||L||null!=o,F=v??("string"==typeof s?s:void 0),U=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityRole:"progressbar",accessibilityLabel:F,accessibilityValue:w?{text:j.loading}:{min:0,max:100,now:Math.round(100*N)},testID:f,onLayout:e=>{const t=e.nativeEvent.layout.width;O.current=t,(0,_index2.setNativeValue)(T,t)},style:[B.track,{height:c,borderRadius:E,..._corners.smoothCorners,backgroundColor:D},y],children:S?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[B.segments,{height:c}],children:k.map(({key:e,segment:t})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:100*clampProgress(t.value)+"%",height:c,backgroundColor:t.color??toneColor(r,t.tone??"primary")}},e))}):w?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[B.indeterminateBar,{height:c,width:i?"100%":"30%",opacity:i?G:1,transform:i?[]:[{translateX:_reactNative.Animated.multiply(q,T)}]},h],children:(0,_jsxRuntime.jsx)(_index2.Gradient,{gradient:I,style:_reactNative.StyleSheet.absoluteFill})}):(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[B.determinateBar,{height:c,borderRadius:E,..._corners.smoothCorners,backgroundColor:P?"transparent":M,width:C,overflow:P?"hidden":void 0},h],children:P?(0,_jsxRuntime.jsx)(_index2.Gradient,{gradient:P,style:_reactNative.StyleSheet.absoluteFill}):null})});return $?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:B.wrapper,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[B.labelRow,{marginBottom:r.space.xs}],children:["string"==typeof s||"number"==typeof s?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",color:"primary",style:B.label,children:s}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.label,children:s}),null!=o?"string"==typeof o||"number"==typeof o?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:o}):o:L?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:`${Math.round(100*N)}%`}):null]}),U]}):U});ProgressBar.displayName="ProgressBar";const buildStyles=e=>_reactNative.StyleSheet.create({wrapper:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},label:{flexShrink:1},track:{width:"100%",overflow:"hidden"},determinateBar:{position:"absolute",left:0,top:0},indeterminateBar:{position:"absolute",left:0,top:0},segments:{flexDirection:"row",width:"100%"}});var _default=exports.default=ProgressBar;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProgressBar=ProgressBar,exports.default=void 0;var _react=require("react"),_reactNative=require("react-native"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../text/index.js"),_progressBarG=require("../../text/phone/progressBar.g.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;case"primary":return e.colors.primary}},DETERMINATE_ANIMATION_DURATION=400,INDETERMINATE_LOOP_DURATION=1500,INDETERMINATE_WIDTH="30%",GLOW_LOCATIONS=[0,.35,.5,.65,1],glowOf=e=>{const t=(0,_color.tintOf)(e,0,"transparent"),r=(0,_color.tintOf)(e,.6,e);return{colors:[t,r,e,r,t],locations:GLOW_LOCATIONS,start:{x:0,y:.5},end:{x:1,y:.5}}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)||e<0?0:e>1?1:e;function ProgressBar({ref:e,...t}){const r=(0,_index2.useTheme)(),i=(0,_useReducedMotion.useReducedMotion)(),{progress:a,label:s,showPercent:n=!1,valueLabel:o,indeterminate:l,height:u=6,radius:c,tone:d="primary",trackColor:_,barColor:m,gradient:g,segments:x,animated:p=!0,style:h,barStyle:y,accessibilityLabel:v,labels:b,testID:R}=t;(0,_assertValidValue.assertValidValue)("ProgressBar","tone",t.tone,["primary","success","warning","danger","info","neutral"]);const f=(0,_index.useMobileUiText)("progressBar",_progressBarG.PROGRESS_BAR_TEXT),N=(0,_react.useMemo)(()=>({...f,...b}),[f,b]),j=l??"number"!=typeof a,w=clampProgress(a),A=(0,_react.useRef)((0,_index2.createAnimatedValue)(w)).current,T=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,E=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,I=(0,_react.useRef)(0),V=(0,_react.useMemo)(()=>buildStyles(r),[r]),O=c??r.radius.pill,D=_??r.colors["surface-disabled"],M=m??toneColor(r,d),B=(0,_react.useMemo)(()=>{if(null==g)return null;if("string"!=typeof g)return g;const e=r.settings.gradients[g];if(void 0===e){const e=Object.keys(r.settings.gradients);throw new RangeError(`[@webority/mobile-ui] <ProgressBar> received gradient="${g}", which is not a gradient in theme.settings.gradients (${e.length>0?`known: ${e.map(e=>`"${e}"`).join(", ")}`:"the theme defines none"}). Pass a known gradient name or a GradientDefinition, or omit the prop.`)}return e},[g,r.settings.gradients]),P=(0,_react.useMemo)(()=>glowOf(M),[M]),S=Array.isArray(x)&&x.length>0,k=(0,_react.useMemo)(()=>(x??[]).map((e,t)=>({key:`segment-${t}`,segment:e})),[x]);(0,_react.useEffect)(()=>{j||(p?_reactNative.Animated.timing(A,{toValue:w,duration:DETERMINATE_ANIMATION_DURATION,easing:_reactNative.Easing.bezier(...r.motion.ease["in-out"]),useNativeDriver:!1}).start():A.setValue(w))},[p,w,A,j,r]),(0,_react.useEffect)(()=>{if(!j)return;(0,_index2.setNativeValue)(T,0);const e=_reactNative.Animated.loop(_reactNative.Animated.timing(T,{toValue:1,duration:INDETERMINATE_LOOP_DURATION,easing:_reactNative.Easing.inOut(_reactNative.Easing.ease),useNativeDriver:_nativeDriver.nativeDriver}));return e.start(),()=>{e.stop()}},[j,T]);const C=A.interpolate({inputRange:[0,1],outputRange:["0%","100%"]}),q=T.interpolate({inputRange:[0,1],outputRange:[-1,1]}),L=T.interpolate({inputRange:[0,.5,1],outputRange:[.4,1,.4]}),G=n&&!j&&!S,$=null!=s||G||null!=o,U=v??("string"==typeof s?s:void 0),F=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e,accessibilityRole:"progressbar",accessibilityLabel:U,accessibilityValue:j?{text:N.loading}:{min:0,max:100,now:Math.round(100*w)},testID:R,onLayout:e=>{const t=e.nativeEvent.layout.width;I.current=t,(0,_index2.setNativeValue)(E,t)},style:[V.track,{height:u,borderRadius:O,..._corners.smoothCorners,backgroundColor:D},h],children:S?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[V.segments,{height:u}],children:k.map(({key:e,segment:t})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:100*clampProgress(t.value)+"%",height:u,backgroundColor:t.color??toneColor(r,t.tone??"primary")}},e))}):j?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[V.indeterminateBar,{height:u,width:i?"100%":INDETERMINATE_WIDTH,opacity:i?L:1,transform:i?[]:[{translateX:_reactNative.Animated.multiply(q,E)}]},y],children:(0,_jsxRuntime.jsx)(_index2.Gradient,{gradient:P,style:_reactNative.StyleSheet.absoluteFill})}):(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[V.determinateBar,{height:u,borderRadius:O,..._corners.smoothCorners,backgroundColor:B?"transparent":M,width:C,overflow:B?"hidden":void 0},y],children:B?(0,_jsxRuntime.jsx)(_index2.Gradient,{gradient:B,style:_reactNative.StyleSheet.absoluteFill}):null})});return $?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:V.wrapper,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[V.labelRow,{marginBottom:r.space.xs}],children:["string"==typeof s||"number"==typeof s?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",color:"primary",style:V.label,children:s}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:V.label,children:s}),null!=o?"string"==typeof o||"number"==typeof o?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:o}):o:G?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:`${Math.round(100*w)}%`}):null]}),F]}):F}const buildStyles=e=>_reactNative.StyleSheet.create({wrapper:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},label:{flexShrink:1},track:{width:"100%",overflow:"hidden"},determinateBar:{position:"absolute",left:0,top:0},indeterminateBar:{position:"absolute",left:0,top:0},segments:{flexDirection:"row",width:"100%"}});var _default=exports.default=ProgressBar;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ProgressRing=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var r,s,a=Object.defineProperty,i={__proto__:null,default:e};if(Object(e)!==e)return i;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,i)}for(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((r=a&&Object.getOwnPropertyDescriptor(e,s))&&(r.get||r.set)?a(i,s,r):i[s]=e[s]);return i}const AnimatedCircle=_reactNative.Animated.createAnimatedComponent(_reactNativeSvg.Circle),toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["text-muted"];default:return e.colors.primary}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)?0:Math.min(1,Math.max(0,e)),DEFAULT_STROKE_WIDTH=4,DEFAULT_DURATION=600,DEFAULT_COLOR_STOPS=[1/3,2/3],STOP_EDGE=1e-4,ProgressRing=exports.ProgressRing=(0,_react.forwardRef)((e,t)=>{const{progress:r,size:s=48,strokeWidth:a,tone:i="primary",trackColor:n,ringColor:o,colorByProgress:c=!1,animated:l=!0,rounded:u=!0,children:d,accessibilityLabel:g,style:_,testID:p}=e;(0,_assertValidValue.assertValidValue)("ProgressRing","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const m=(0,_index2.useTheme)(),f=(0,_index.useReducedMotion)(),h=clampProgress(r),x=a??4,R=n??m.colors["surface-disabled"],[v,y]=DEFAULT_COLOR_STOPS,b=Math.max(0,(s-x)/2),j=2*Math.PI*b,P=(0,_react.useRef)((0,_index2.createAnimatedValue)(h)).current;(0,_react.useEffect)(()=>{if(!l||f)return void P.setValue(h);const e=_reactNative.Animated.timing(P,{toValue:h,duration:600,easing:_reactNative.Easing.bezier(...m.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[l,h,P,f,m.motion.ease["in-out"]]);const w=P.interpolate({inputRange:[0,1],outputRange:[j,0]}),N=P.interpolate({inputRange:[0,.001,1],outputRange:[0,1,1]}),O=(0,_react.useMemo)(()=>P.interpolate({inputRange:[0,v-1e-4,v,y-1e-4,y,1],outputRange:[m.colors.danger,m.colors.danger,m.colors.warning,m.colors.warning,m.colors.success,m.colors.success]}),[P,m.colors.danger,m.colors.warning,m.colors.success]),D=o??(c?O:toneColor(m,i)),S=(0,_react.useMemo)(()=>buildStyles(),[]),V=s/2;return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessible:null==d,accessibilityRole:"progressbar",accessibilityLabel:g,accessibilityValue:{min:0,max:100,now:Math.round(100*h)},testID:p,style:[S.root,{width:s,height:s},_],children:[(0,_jsxRuntime.jsxs)(_reactNativeSvg.default,{width:s,height:s,viewBox:`0 0 ${s} ${s}`,children:[(0,_jsxRuntime.jsx)(_reactNativeSvg.Circle,{cx:V,cy:V,r:b,stroke:R,strokeWidth:x,fill:"none"}),(0,_jsxRuntime.jsx)(AnimatedCircle,{cx:V,cy:V,r:b,stroke:D,strokeWidth:x,strokeLinecap:u?"round":"butt",strokeDasharray:`${j} ${j}`,strokeDashoffset:w,strokeOpacity:N,fill:"none",transform:`rotate(-90 ${V} ${V})`,...p?{testID:`${p}-fill`}:{}})]}),null!=d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:S.content,pointerEvents:"box-none",children:d}):null]})});ProgressRing.displayName="ProgressRing";const buildStyles=()=>_reactNative.StyleSheet.create({root:{alignItems:"center",justifyContent:"center"},content:{position:"absolute",top:0,right:0,bottom:0,left:0,alignItems:"center",justifyContent:"center"}});var _default=exports.default=ProgressRing;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProgressRing=ProgressRing,exports.default=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var r,s,a=Object.defineProperty,i={__proto__:null,default:e};if(Object(e)!==e)return i;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,i)}for(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((r=a&&Object.getOwnPropertyDescriptor(e,s))&&(r.get||r.set)?a(i,s,r):i[s]=e[s]);return i}const AnimatedCircle=_reactNative.Animated.createAnimatedComponent(_reactNativeSvg.Circle),toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["text-muted"];default:return e.colors.primary}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)?0:Math.min(1,Math.max(0,e)),DEFAULT_STROKE_WIDTH=4,DEFAULT_DURATION=600,DEFAULT_COLOR_STOPS=[1/3,2/3],STOP_EDGE=1e-4;function ProgressRing({ref:e,...t}){const{progress:r,size:s=48,strokeWidth:a,tone:i="primary",trackColor:n,ringColor:o,colorByProgress:c=!1,animated:l=!0,rounded:u=!0,children:d,accessibilityLabel:_,style:g,testID:m}=t;(0,_assertValidValue.assertValidValue)("ProgressRing","tone",t.tone,["primary","success","warning","danger","info","neutral"]);const p=(0,_index2.useTheme)(),f=(0,_index.useReducedMotion)(),h=clampProgress(r),x=a??DEFAULT_STROKE_WIDTH,v=DEFAULT_DURATION,R=n??p.colors["surface-disabled"],[y,b]=DEFAULT_COLOR_STOPS,j=Math.max(0,(s-x)/2),D=2*Math.PI*j,O=(0,_react.useRef)((0,_index2.createAnimatedValue)(h)).current;(0,_react.useEffect)(()=>{if(!l||f)return void O.setValue(h);const e=_reactNative.Animated.timing(O,{toValue:h,duration:v,easing:_reactNative.Easing.bezier(...p.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[l,h,O,f,p.motion.ease["in-out"]]);const P=O.interpolate({inputRange:[0,1],outputRange:[D,0]}),T=O.interpolate({inputRange:[0,.001,1],outputRange:[0,1,1]}),E=(0,_react.useMemo)(()=>O.interpolate({inputRange:[0,y-STOP_EDGE,y,b-STOP_EDGE,b,1],outputRange:[p.colors.danger,p.colors.danger,p.colors.warning,p.colors.warning,p.colors.success,p.colors.success]}),[O,p.colors.danger,p.colors.warning,p.colors.success]),N=o??(c?E:toneColor(p,i)),S=(0,_react.useMemo)(()=>buildStyles(),[]),w=s/2;return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:e,accessible:null==d,accessibilityRole:"progressbar",accessibilityLabel:_,accessibilityValue:{min:0,max:100,now:Math.round(100*h)},testID:m,style:[S.root,{width:s,height:s},g],children:[(0,_jsxRuntime.jsxs)(_reactNativeSvg.default,{width:s,height:s,viewBox:`0 0 ${s} ${s}`,children:[(0,_jsxRuntime.jsx)(_reactNativeSvg.Circle,{cx:w,cy:w,r:j,stroke:R,strokeWidth:x,fill:"none"}),(0,_jsxRuntime.jsx)(AnimatedCircle,{cx:w,cy:w,r:j,stroke:N,strokeWidth:x,strokeLinecap:u?"round":"butt",strokeDasharray:`${D} ${D}`,strokeDashoffset:P,strokeOpacity:T,fill:"none",transform:`rotate(-90 ${w} ${w})`,...m?{testID:`${m}-fill`}:{}})]}),null!=d?(0,_jsxRuntime.jsx)(_reactNative.View,{style:S.content,pointerEvents:"box-none",children:d}):null]})}const buildStyles=()=>_reactNative.StyleSheet.create({root:{alignItems:"center",justifyContent:"center"},content:{position:"absolute",top:0,right:0,bottom:0,left:0,alignItems:"center",justifyContent:"center"}});var _default=exports.default=ProgressRing;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useRadioGroup=exports.default=exports.RadioGroupContext=exports.Radio=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_index2=require("../FieldBase/index.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_RadioDot=require("./RadioDot.js"),_jsxRuntime=require("react/jsx-runtime");const RadioGroupContext=exports.RadioGroupContext=(0,_react.createContext)(null),useRadioGroup=()=>(0,_react.useContext)(RadioGroupContext);exports.useRadioGroup=useRadioGroup;const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;default:return e.colors.primary}},Radio=exports.Radio=(0,_react.forwardRef)((e,t)=>{const{value:i,selected:r,onChange:o,disabled:s=!1,label:a,helperText:l,description:d,error:c,size:n="md",tone:u="primary",accessibilityLabel:p,haptic:x,style:_,circleStyle:h,dotStyle:b,labelStyle:R,testID:y,hitSlop:m,...g}=e;(0,_assertValidValue.assertValidValue)("Radio","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Radio","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const f=(0,_index.useTheme)(),S=(0,_react.useMemo)(()=>buildStyles(f),[f]),C=useRadioGroup();__DEV__&&void 0===i&&_mobileCore.Logger.warn("[@webority/mobile-ui] Radio was rendered without a `value`. Selection compares against it, so the group cannot track which option is chosen.");const j=C?C.selectedValue===i:!!r,w=C&&C.disabled||s,T=toneColor(f,u),V=(0,_index.spaceOf)(f,f.components.radio["label-gap"]),v=m??6,q=p??(0,_index2.fieldTextAsString)(a),D="string"==typeof c?c:void 0,G={description:d,helperText:l,error:D},k=!0===C?.error||!0===c||(0,_index2.hasFieldText)(c);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:t,onPress:e=>{if(w)return;const t=(0,_hapticUtils.resolveHaptic)(x,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),C?C.onChange(i):o?.(i)},disabled:w,accessibilityRole:"radio",accessibilityLabel:q,accessibilityHint:g.accessibilityHint??(0,_index2.fieldTextAsString)(l)??(0,_index2.fieldTextAsString)(d),accessibilityState:{checked:j,disabled:w},"aria-checked":j,"aria-disabled":w,testID:y,hitSlop:v,...(0,_hitSlop.hitSlopMarker)(v),...g,style:({pressed:e})=>[S.row,(0,_ChoiceText.hasChoiceDetail)(G)?S.rowTop:null,{opacity:w?.55:e?.85:1},_],children:[(0,_jsxRuntime.jsx)(_RadioDot.RadioDot,{selected:j,color:T,disabled:w&&!j,size:n,style:[!k||j||w?null:{borderColor:f.colors["field-border-error"]},h],dotStyle:b}),(0,_jsxRuntime.jsx)(_ChoiceText.ChoiceText,{label:a,helperText:l,description:d,error:D,disabled:w,style:{marginLeft:V},labelStyle:R})]})});Radio.displayName="Radio";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"}});var _default=exports.default=Radio;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Radio=Radio,exports.useRadioGroup=exports.default=exports.RadioGroupContext=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_index2=require("../FieldBase/index.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_RadioDot=require("./RadioDot.js"),_jsxRuntime=require("react/jsx-runtime");const RadioGroupContext=exports.RadioGroupContext=(0,_react.createContext)(null),useRadioGroup=()=>(0,_react.useContext)(RadioGroupContext);exports.useRadioGroup=useRadioGroup;const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;default:return e.colors.primary}};function Radio(e){const{ref:t,value:i,selected:r,onChange:o,disabled:s=!1,label:a,helperText:l,description:n,error:c,size:d="md",tone:u="primary",accessibilityLabel:p,haptic:x,style:_,circleStyle:h,dotStyle:b,labelStyle:y,testID:R,hitSlop:g,...m}=e;(0,_assertValidValue.assertValidValue)("Radio","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Radio","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const f=(0,_index.useTheme)(),S=(0,_react.useMemo)(()=>buildStyles(f),[f]),C=useRadioGroup();__DEV__&&void 0===i&&_mobileCore.Logger.warn("[@webority/mobile-ui] Radio was rendered without a `value`. Selection compares against it, so the group cannot track which option is chosen.");const j=C?C.selectedValue===i:!!r,w=C&&C.disabled||s,T=toneColor(f,u),V=(0,_index.spaceOf)(f,f.components.radio["label-gap"]),v=g??6,q=p??(0,_index2.fieldTextAsString)(a),D="string"==typeof c?c:void 0,G={description:n,helperText:l,error:D},k=!0===C?.error||!0===c||(0,_index2.hasFieldText)(c);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:t,onPress:e=>{if(w)return;const t=(0,_hapticUtils.resolveHaptic)(x,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),C?C.onChange(i):o?.(i)},disabled:w,accessibilityRole:"radio",accessibilityLabel:q,accessibilityHint:m.accessibilityHint??(0,_index2.fieldTextAsString)(l)??(0,_index2.fieldTextAsString)(n),accessibilityState:{checked:j,disabled:w},"aria-checked":j,"aria-disabled":w,testID:R,hitSlop:v,...(0,_hitSlop.hitSlopMarker)(v),...m,style:({pressed:e})=>[S.row,(0,_ChoiceText.hasChoiceDetail)(G)?S.rowTop:null,{opacity:w?.55:e?.85:1},_],children:[(0,_jsxRuntime.jsx)(_RadioDot.RadioDot,{selected:j,color:T,disabled:w&&!j,size:d,style:[!k||j||w?null:{borderColor:f.colors["field-border-error"]},h],dotStyle:b}),(0,_jsxRuntime.jsx)(_ChoiceText.ChoiceText,{label:a,helperText:l,description:n,error:D,disabled:w,style:{marginLeft:V},labelStyle:y})]})}const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"}});var _default=exports.default=Radio;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.RadioGroup=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../FieldBase/index.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_Radio=require("./Radio.js"),_jsxRuntime=require("react/jsx-runtime");const RadioGroup=e=>{const{value:i,defaultValue:r,onChange:a,children:t,disabled:o=!1,error:s,accessibilityLabel:d,style:l,testID:u}=e,n=(0,_react.useCallback)(e=>{if("string"!=typeof e&&"number"!=typeof e)throw new Error("RadioGroup received a missing value in single mode.");a?.(e)},[a]),[c,x]=(0,_index.useControllableState)({controlled:"value"in e,value:i,defaultValue:r??void 0,onChange:n}),p=!0===s||(0,_index2.hasFieldText)(s),_=(0,_react.useMemo)(()=>({selectedValue:c,onChange:x,disabled:o,error:p}),[c,x,o,p]);return(0,_jsxRuntime.jsxs)(_Radio.RadioGroupContext.Provider,{value:_,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"radiogroup",accessibilityLabel:d,accessibilityState:{disabled:o},"aria-disabled":o,testID:u,style:l,children:t}),(0,_jsxRuntime.jsx)(_ChoiceText.ChoiceText,{error:"string"==typeof s?s:void 0})]})};exports.RadioGroup=RadioGroup,RadioGroup.displayName="RadioGroup";var _default=exports.default=RadioGroup;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.RadioGroup=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../FieldBase/index.js"),_ChoiceText=require("../FieldBase/ChoiceText.js"),_Radio=require("./Radio.js"),_jsxRuntime=require("react/jsx-runtime");const RadioGroup=e=>{const{value:i,defaultValue:r,onChange:a,children:t,disabled:o=!1,error:s,accessibilityLabel:d,style:l,testID:u}=e,n=(0,_react.useCallback)(e=>{if("string"!=typeof e&&"number"!=typeof e)throw new Error("RadioGroup received a missing value in single mode.");a?.(e)},[a]),[c,x]=(0,_index.useControllableState)({controlled:"value"in e,value:i,defaultValue:r??void 0,onChange:n}),p=!0===s||(0,_index2.hasFieldText)(s),_=(0,_react.useMemo)(()=>({selectedValue:c,onChange:x,disabled:o,error:p}),[c,x,o,p]);return(0,_jsxRuntime.jsxs)(_Radio.RadioGroupContext,{value:_,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityRole:"radiogroup",accessibilityLabel:d,accessibilityState:{disabled:o},"aria-disabled":o,testID:u,style:l,children:t}),(0,_jsxRuntime.jsx)(_ChoiceText.ChoiceText,{error:"string"==typeof s?s:void 0})]})};exports.RadioGroup=RadioGroup,RadioGroup.displayName="RadioGroup";var _default=exports.default=RadioGroup;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Rating=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../text/index.js"),_ratingG=require("../../text/phone/rating.g.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const RATING_SIZES=["sm","md","lg"],RATING_TONES=["primary","success","warning","danger","info","neutral"],sizePxMap={sm:16,md:24,lg:32},resolveSize=e=>sizePxMap[e],PULSE_SCALE=1.2,toneColorFor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;case"primary":return e.colors.primary}},clampToStep=(e,t,i)=>{const a=Math.max(0,Math.min(t,e)),s=Math.round(a/i)*i;return Number(s.toFixed(2))},Star=({index:e,filled:t,size:i,filledColor:a,emptyColor:s,scale:r})=>{const n=Math.max(0,Math.min(1,t-e));return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[starStyles.starWrap,{width:i,height:i,transform:[{scale:r}]}],children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",style:[starStyles.glyph,{color:s,fontSize:i,lineHeight:i}],accessible:!1,children:"☆"}),n>0?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[starStyles.fillClip,{width:i*n,height:i}],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",style:[starStyles.glyph,{color:a,fontSize:i,lineHeight:i}],accessible:!1,children:"★"})}):null]})},RatingRoot=(0,_react.forwardRef)((e,t)=>{const{value:i,onChange:a,max:s=5,allowHalf:r=!0,readonly:n=!1,size:l="md",tone:o="warning",label:c,loading:u=!1,haptic:d,labels:m,accessibilityLabel:x,style:_,starContainerStyle:g,testID:p}=e;(0,_assertValidValue.assertValidValue)("Rating","size",e.size,RATING_SIZES),(0,_assertValidValue.assertValidValue)("Rating","tone",e.tone,RATING_TONES);const y=(0,_index.useMobileUiText)("rating",_ratingG.RATING_TEXT),v=(0,_react.useMemo)(()=>({...y,...m}),[y,m]),h=(0,_index2.useTheme)(),f=(0,_react.useMemo)(()=>buildStyles(h),[h]),b=!n&&"function"==typeof a,R=r?.5:1,S=resolveSize(l),j=toneColorFor(h,o),w=h.colors.border,N=(0,_react.useRef)(S),V=(0,_react.useCallback)(e=>{N.current=e.nativeEvent.layout.width},[]),k=(0,_react.useRef)(new Map),T=(0,_react.useMemo)(()=>{const e=k.current,t=[];for(let i=0;i<s;i+=1){let a=e.get(i);a||(a=new _reactNative.Animated.Value(1),e.set(i,a)),t.push(a)}for(const t of Array.from(e.keys()))t>=s&&e.delete(t);return t},[s]),C=h.settings.components.rating?.pulseOnPress??!1,A=(0,_react.useCallback)(e=>{const t=T[e];if(!t)throw new Error(`Rating has no star at index ${e}; the pulse index must be below max.`);_reactNative.Animated.sequence([_reactNative.Animated.timing(t,{toValue:1.2,duration:h.motion.duration.fast,easing:_reactNative.Easing.bezier(...h.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.spring(t,{toValue:1,damping:h.motion.spring.bouncy.damping,stiffness:h.motion.spring.bouncy.stiffness,mass:h.motion.spring.bouncy.mass,useNativeDriver:_nativeDriver.nativeDriver})]).start()},[h.motion,T]),M=(0,_react.useCallback)((e,t)=>{if(!b||!a)return;const i=clampToStep(e,s,R),r=(0,_hapticUtils.resolveHaptic)(d,"selection");r&&(0,_hapticUtils.triggerHaptic)(r),C&&"number"==typeof t&&A(t),a(i)},[b,a,s,R,A,d,C]),z=(0,_react.useCallback)(e=>t=>{if(!b)return;const i=N.current||S,a=t.nativeEvent.locationX??i;let s;s=r&&a<i/2?e+.5:e+1,M(s,e)},[b,S,r,M]),E=(0,_react.useCallback)(e=>{b&&("increment"===e.nativeEvent.actionName?M(i+R):"decrement"===e.nativeEvent.actionName&&M(i-R))},[b,i,R,M]),q=(0,_index.fillText)(v.value,{value:i,max:s}),D=x??c??q,I=[];for(const[e,t]of T.entries()){const a=(0,_jsxRuntime.jsx)(Star,{index:e,filled:i,size:S,filledColor:j,emptyColor:w,scale:t},e);I.push(b?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:z(e),onLayout:0===e?V:void 0,hitSlop:4,...(0,_hitSlop.hitSlopMarker)(4),accessible:!1,style:f.starPress,children:a},e):(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:0===e?V:void 0,style:f.starPress,children:a},e))}const P=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[f.wrapper,_],ref:t,testID:p,children:[c?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:f.label,children:c}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[f.row,g],accessible:!0,accessibilityRole:b?"adjustable":"text",accessibilityLabel:D,accessibilityValue:b?{min:0,max:s,now:i,text:q}:void 0,accessibilityActions:b?[{name:"increment"},{name:"decrement"}]:void 0,onAccessibilityAction:b?E:void 0,children:I})]});return u?(0,_jsxRuntime.jsx)(RatingSkeleton,{...e}):P});RatingRoot.displayName="Rating";const RatingSkeleton=({max:e=5,size:t="md",label:i,starContainerStyle:a,style:s})=>{const r=(0,_index2.useTheme)(),n=resolveSize(t),l=Math.max(1,e),o=(0,_react.useMemo)(()=>Array.from({length:l},(e,t)=>({key:`sk-star-${t}`,index:t})),[l]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{alignItems:"flex-start"},s],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==i?(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:80,height:14,style:{marginBottom:r.space.xs}}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{flexDirection:"row"},a],children:o.map(({key:e,index:t})=>(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:n,height:n,radius:Math.round(.25*n),style:t<l-1?{marginRight:r.space.xs}:void 0},e))})]})};RatingSkeleton.displayName="RatingSkeleton";const Rating=exports.Rating=Object.assign(RatingRoot,{Skeleton:RatingSkeleton}),starStyles=_reactNative.StyleSheet.create({starWrap:{position:"relative",alignItems:"flex-start",justifyContent:"center"},glyph:{textAlign:"left",includeFontPadding:!1},fillClip:{position:"absolute",top:0,left:0,overflow:"hidden"}}),buildStyles=e=>_reactNative.StyleSheet.create({wrapper:{flexDirection:"column"},row:{flexDirection:"row",alignItems:"center"},starPress:{marginRight:e.space.xs},label:{marginBottom:e.space.xs}});var _default=exports.default=Rating;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Rating=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../text/index.js"),_ratingG=require("../../text/phone/rating.g.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const RATING_SIZES=["sm","md","lg"],RATING_TONES=["primary","success","warning","danger","info","neutral"],sizePxMap={sm:16,md:24,lg:32},resolveSize=e=>sizePxMap[e],PULSE_SCALE=1.2,toneColorFor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;case"primary":return e.colors.primary}},clampToStep=(e,t,i)=>{const a=Math.max(0,Math.min(t,e)),s=Math.round(a/i)*i;return Number(s.toFixed(2))},Star=({index:e,filled:t,size:i,filledColor:a,emptyColor:s,scale:r})=>{const n=Math.max(0,Math.min(1,t-e));return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[starStyles.starWrap,{width:i,height:i,transform:[{scale:r}]}],children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",style:[starStyles.glyph,{color:s,fontSize:i,lineHeight:i}],accessible:!1,children:"☆"}),n>0?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[starStyles.fillClip,{width:i*n,height:i}],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",style:[starStyles.glyph,{color:a,fontSize:i,lineHeight:i}],accessible:!1,children:"★"})}):null]})};function RatingRoot({ref:e,...t}){const{value:i,onChange:a,max:s=5,allowHalf:r=!0,readonly:n=!1,size:l="md",tone:o="warning",label:c,loading:u=!1,haptic:d,labels:m,accessibilityLabel:x,style:_,starContainerStyle:g,testID:p}=t;(0,_assertValidValue.assertValidValue)("Rating","size",t.size,RATING_SIZES),(0,_assertValidValue.assertValidValue)("Rating","tone",t.tone,RATING_TONES);const y=(0,_index.useMobileUiText)("rating",_ratingG.RATING_TEXT),v=(0,_react.useMemo)(()=>({...y,...m}),[y,m]),h=(0,_index2.useTheme)(),f=(0,_react.useMemo)(()=>buildStyles(h),[h]),b=!n&&"function"==typeof a,R=r?.5:1,S=resolveSize(l),j=toneColorFor(h,o),w=h.colors.border,N=(0,_react.useRef)(S),V=(0,_react.useCallback)(e=>{N.current=e.nativeEvent.layout.width},[]),k=(0,_react.useRef)(new Map),T=(0,_react.useMemo)(()=>{const e=k.current,t=[];for(let i=0;i<s;i+=1){let a=e.get(i);a||(a=new _reactNative.Animated.Value(1),e.set(i,a)),t.push(a)}for(const t of Array.from(e.keys()))t>=s&&e.delete(t);return t},[s]),C=h.settings.components.rating?.pulseOnPress??!1,A=(0,_react.useCallback)(e=>{const t=T[e];if(!t)throw new Error(`Rating has no star at index ${e}; the pulse index must be below max.`);_reactNative.Animated.sequence([_reactNative.Animated.timing(t,{toValue:1.2,duration:h.motion.duration.fast,easing:_reactNative.Easing.bezier(...h.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.spring(t,{toValue:1,damping:h.motion.spring.bouncy.damping,stiffness:h.motion.spring.bouncy.stiffness,mass:h.motion.spring.bouncy.mass,useNativeDriver:_nativeDriver.nativeDriver})]).start()},[h.motion,T]),M=(0,_react.useCallback)((e,t)=>{if(!b||!a)return;const i=clampToStep(e,s,R),r=(0,_hapticUtils.resolveHaptic)(d,"selection");r&&(0,_hapticUtils.triggerHaptic)(r),C&&"number"==typeof t&&A(t),a(i)},[b,a,s,R,A,d,C]),z=(0,_react.useCallback)(e=>t=>{if(!b)return;const i=N.current||S,a=t.nativeEvent.locationX??i;let s;s=r&&a<i/2?e+.5:e+1,M(s,e)},[b,S,r,M]),E=(0,_react.useCallback)(e=>{b&&("increment"===e.nativeEvent.actionName?M(i+R):"decrement"===e.nativeEvent.actionName&&M(i-R))},[b,i,R,M]),q=(0,_index.fillText)(v.value,{value:i,max:s}),D=x??c??q,I=[];for(const[e,t]of T.entries()){const a=(0,_jsxRuntime.jsx)(Star,{index:e,filled:i,size:S,filledColor:j,emptyColor:w,scale:t},e);I.push(b?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:z(e),onLayout:0===e?V:void 0,hitSlop:4,...(0,_hitSlop.hitSlopMarker)(4),accessible:!1,style:f.starPress,children:a},e):(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:0===e?V:void 0,style:f.starPress,children:a},e))}const P=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[f.wrapper,_],ref:e,testID:p,children:[c?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:f.label,children:c}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[f.row,g],accessible:!0,accessibilityRole:b?"adjustable":"text",accessibilityLabel:D,accessibilityValue:b?{min:0,max:s,now:i,text:q}:void 0,accessibilityActions:b?[{name:"increment"},{name:"decrement"}]:void 0,onAccessibilityAction:b?E:void 0,children:I})]});return u?(0,_jsxRuntime.jsx)(RatingSkeleton,{...t}):P}RatingRoot.displayName="Rating";const RatingSkeleton=({max:e=5,size:t="md",label:i,starContainerStyle:a,style:s})=>{const r=(0,_index2.useTheme)(),n=resolveSize(t),l=Math.max(1,e),o=(0,_react.useMemo)(()=>Array.from({length:l},(e,t)=>({key:`sk-star-${t}`,index:t})),[l]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{alignItems:"flex-start"},s],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==i?(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:80,height:14,style:{marginBottom:r.space.xs}}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{flexDirection:"row"},a],children:o.map(({key:e,index:t})=>(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:n,height:n,radius:Math.round(.25*n),style:t<l-1?{marginRight:r.space.xs}:void 0},e))})]})};RatingSkeleton.displayName="RatingSkeleton";const Rating=exports.Rating=Object.assign(RatingRoot,{Skeleton:RatingSkeleton}),starStyles=_reactNative.StyleSheet.create({starWrap:{position:"relative",alignItems:"flex-start",justifyContent:"center"},glyph:{textAlign:"left",includeFontPadding:!1},fillClip:{position:"absolute",top:0,left:0,overflow:"hidden"}}),buildStyles=e=>_reactNative.StyleSheet.create({wrapper:{flexDirection:"column"},row:{flexDirection:"row",alignItems:"center"},starPress:{marginRight:e.space.xs},label:{marginBottom:e.space.xs}});var _default=exports.default=Rating;