@webority/mobile-ui 0.144.2 → 0.146.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 (174) hide show
  1. package/dist/canvas-kit/kit.js +4429 -3708
  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/AnimatePresence/AnimatePresence.js +1 -1
  7. package/lib/commonjs/components/AppBar/AppBar.js +1 -1
  8. package/lib/commonjs/components/AppIcon/AppIcon.js +1 -1
  9. package/lib/commonjs/components/AsyncBlock/AsyncBlock.js +1 -1
  10. package/lib/commonjs/components/AuthedImage/AuthedImage.js +1 -1
  11. package/lib/commonjs/components/Autocomplete/Autocomplete.js +1 -1
  12. package/lib/commonjs/components/Avatar/Avatar.js +1 -1
  13. package/lib/commonjs/components/Badge/Badge.js +1 -1
  14. package/lib/commonjs/components/Banner/Banner.js +1 -1
  15. package/lib/commonjs/components/BarChart/BarChart.js +1 -1
  16. package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
  17. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  18. package/lib/commonjs/components/Button/Button.js +1 -1
  19. package/lib/commonjs/components/Calendar/Calendar.js +1 -1
  20. package/lib/commonjs/components/Card/Card.js +1 -1
  21. package/lib/commonjs/components/Carousel/Carousel.js +1 -1
  22. package/lib/commonjs/components/Checkbox/Checkbox.js +1 -1
  23. package/lib/commonjs/components/Chip/Chip.js +1 -1
  24. package/lib/commonjs/components/ChoiceGroup/ChoiceGroup.js +1 -1
  25. package/lib/commonjs/components/Confetti/Confetti.js +1 -1
  26. package/lib/commonjs/components/Descriptions/Descriptions.js +1 -1
  27. package/lib/commonjs/components/Dialog/Dialog.js +1 -1
  28. package/lib/commonjs/components/Dialog/OverlayActions.js +1 -1
  29. package/lib/commonjs/components/Divider/Divider.js +1 -1
  30. package/lib/commonjs/components/Drawer/Drawer.js +1 -1
  31. package/lib/commonjs/components/EmptyState/EmptyState.js +1 -1
  32. package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
  33. package/lib/commonjs/components/FilePicker/FilePicker.js +1 -1
  34. package/lib/commonjs/components/FileViewer/FileViewer.js +1 -1
  35. package/lib/commonjs/components/FilterChipRow/FilterChipRow.js +1 -1
  36. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  37. package/lib/commonjs/components/FormField/FormField.js +1 -1
  38. package/lib/commonjs/components/IconBadge/IconBadge.js +1 -1
  39. package/lib/commonjs/components/IconButton/IconButton.js +1 -1
  40. package/lib/commonjs/components/InlineSelect/InlineSelect.js +1 -1
  41. package/lib/commonjs/components/Input/Input.js +1 -1
  42. package/lib/commonjs/components/ListItem/ListItem.js +1 -1
  43. package/lib/commonjs/components/ListSection/ListSection.js +1 -1
  44. package/lib/commonjs/components/Menu/Menu.js +1 -1
  45. package/lib/commonjs/components/Menu/useContextMenu.js +1 -1
  46. package/lib/commonjs/components/MessageBubble/MessageBubble.js +1 -1
  47. package/lib/commonjs/components/Modal/Modal.js +1 -1
  48. package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
  49. package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
  50. package/lib/commonjs/components/PermissionPrompt/PermissionPrompt.js +1 -1
  51. package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  52. package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +1 -1
  53. package/lib/commonjs/components/ProfileCompletion/ProfileCompletion.js +1 -1
  54. package/lib/commonjs/components/ProfilePicker/ProfilePicker.js +1 -1
  55. package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
  56. package/lib/commonjs/components/ProgressRing/ProgressRing.js +1 -1
  57. package/lib/commonjs/components/Radio/Radio.js +1 -1
  58. package/lib/commonjs/components/Rating/Rating.js +1 -1
  59. package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -1
  60. package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
  61. package/lib/commonjs/components/SectionHeader/SectionHeader.js +1 -1
  62. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
  63. package/lib/commonjs/components/Select/Select.js +1 -1
  64. package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
  65. package/lib/commonjs/components/Skeleton/Skeleton.js +1 -1
  66. package/lib/commonjs/components/Skeleton/SkeletonContent.js +1 -1
  67. package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +1 -1
  68. package/lib/commonjs/components/Slider/Slider.js +1 -1
  69. package/lib/commonjs/components/SliderField/SliderField.js +1 -1
  70. package/lib/commonjs/components/Sparkline/Sparkline.js +1 -1
  71. package/lib/commonjs/components/Spinner/Spinner.js +1 -1
  72. package/lib/commonjs/components/StatTile/StatTile.js +1 -1
  73. package/lib/commonjs/components/StatusBadge/StatusBadge.js +1 -1
  74. package/lib/commonjs/components/Stepper/Stepper.js +1 -1
  75. package/lib/commonjs/components/Swipeable/Swipeable.js +1 -1
  76. package/lib/commonjs/components/Switch/Switch.js +1 -1
  77. package/lib/commonjs/components/Tabs/Tabs.js +1 -1
  78. package/lib/commonjs/components/TagInput/TagInput.js +1 -1
  79. package/lib/commonjs/components/Text/Text.js +1 -1
  80. package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
  81. package/lib/commonjs/components/Timeline/Timeline.js +1 -1
  82. package/lib/commonjs/components/Toast/Toast.js +1 -1
  83. package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
  84. package/lib/commonjs/components/WheelPicker/WheelPicker.js +1 -1
  85. package/lib/commonjs/utils/assertValidValue.js +1 -0
  86. package/lib/module/components/Accordion/Accordion.js +1 -1
  87. package/lib/module/components/AmountSlider/AmountSlider.js +1 -1
  88. package/lib/module/components/AnimatePresence/AnimatePresence.js +1 -1
  89. package/lib/module/components/AppBar/AppBar.js +1 -1
  90. package/lib/module/components/AppIcon/AppIcon.js +1 -1
  91. package/lib/module/components/AsyncBlock/AsyncBlock.js +1 -1
  92. package/lib/module/components/AuthedImage/AuthedImage.js +1 -1
  93. package/lib/module/components/Autocomplete/Autocomplete.js +1 -1
  94. package/lib/module/components/Avatar/Avatar.js +1 -1
  95. package/lib/module/components/Badge/Badge.js +1 -1
  96. package/lib/module/components/Banner/Banner.js +1 -1
  97. package/lib/module/components/BarChart/BarChart.js +1 -1
  98. package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
  99. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  100. package/lib/module/components/Button/Button.js +1 -1
  101. package/lib/module/components/Calendar/Calendar.js +1 -1
  102. package/lib/module/components/Card/Card.js +1 -1
  103. package/lib/module/components/Carousel/Carousel.js +1 -1
  104. package/lib/module/components/Checkbox/Checkbox.js +1 -1
  105. package/lib/module/components/Chip/Chip.js +1 -1
  106. package/lib/module/components/ChoiceGroup/ChoiceGroup.js +1 -1
  107. package/lib/module/components/Confetti/Confetti.js +1 -1
  108. package/lib/module/components/Descriptions/Descriptions.js +1 -1
  109. package/lib/module/components/Dialog/Dialog.js +1 -1
  110. package/lib/module/components/Dialog/OverlayActions.js +1 -1
  111. package/lib/module/components/Divider/Divider.js +1 -1
  112. package/lib/module/components/Drawer/Drawer.js +1 -1
  113. package/lib/module/components/EmptyState/EmptyState.js +1 -1
  114. package/lib/module/components/FieldBase/FieldBase.js +1 -1
  115. package/lib/module/components/FilePicker/FilePicker.js +1 -1
  116. package/lib/module/components/FileViewer/FileViewer.js +1 -1
  117. package/lib/module/components/FilterChipRow/FilterChipRow.js +1 -1
  118. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
  119. package/lib/module/components/FormField/FormField.js +1 -1
  120. package/lib/module/components/IconBadge/IconBadge.js +1 -1
  121. package/lib/module/components/IconButton/IconButton.js +1 -1
  122. package/lib/module/components/InlineSelect/InlineSelect.js +1 -1
  123. package/lib/module/components/Input/Input.js +1 -1
  124. package/lib/module/components/ListItem/ListItem.js +1 -1
  125. package/lib/module/components/ListSection/ListSection.js +1 -1
  126. package/lib/module/components/Menu/Menu.js +1 -1
  127. package/lib/module/components/Menu/useContextMenu.js +1 -1
  128. package/lib/module/components/MessageBubble/MessageBubble.js +1 -1
  129. package/lib/module/components/Modal/Modal.js +1 -1
  130. package/lib/module/components/NumberInput/NumberInput.js +1 -1
  131. package/lib/module/components/OTPInput/OTPInput.js +1 -1
  132. package/lib/module/components/PermissionPrompt/PermissionPrompt.js +1 -1
  133. package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  134. package/lib/module/components/PickerTrigger/PickerTrigger.js +1 -1
  135. package/lib/module/components/ProfileCompletion/ProfileCompletion.js +1 -1
  136. package/lib/module/components/ProfilePicker/ProfilePicker.js +1 -1
  137. package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
  138. package/lib/module/components/ProgressRing/ProgressRing.js +1 -1
  139. package/lib/module/components/Radio/Radio.js +1 -1
  140. package/lib/module/components/Rating/Rating.js +1 -1
  141. package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -1
  142. package/lib/module/components/SearchBar/SearchBar.js +1 -1
  143. package/lib/module/components/SectionHeader/SectionHeader.js +1 -1
  144. package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
  145. package/lib/module/components/Select/Select.js +1 -1
  146. package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
  147. package/lib/module/components/Skeleton/Skeleton.js +1 -1
  148. package/lib/module/components/Skeleton/SkeletonContent.js +1 -1
  149. package/lib/module/components/SlideToConfirm/SlideToConfirm.js +1 -1
  150. package/lib/module/components/Slider/Slider.js +1 -1
  151. package/lib/module/components/SliderField/SliderField.js +1 -1
  152. package/lib/module/components/Sparkline/Sparkline.js +1 -1
  153. package/lib/module/components/Spinner/Spinner.js +1 -1
  154. package/lib/module/components/StatTile/StatTile.js +1 -1
  155. package/lib/module/components/StatusBadge/StatusBadge.js +1 -1
  156. package/lib/module/components/Stepper/Stepper.js +1 -1
  157. package/lib/module/components/Swipeable/Swipeable.js +1 -1
  158. package/lib/module/components/Switch/Switch.js +1 -1
  159. package/lib/module/components/Tabs/Tabs.js +1 -1
  160. package/lib/module/components/TagInput/TagInput.js +1 -1
  161. package/lib/module/components/Text/Text.js +1 -1
  162. package/lib/module/components/TimePicker/TimePicker.js +1 -1
  163. package/lib/module/components/Timeline/Timeline.js +1 -1
  164. package/lib/module/components/Toast/Toast.js +1 -1
  165. package/lib/module/components/Tooltip/Tooltip.js +1 -1
  166. package/lib/module/components/WheelPicker/WheelPicker.js +1 -1
  167. package/lib/module/utils/assertValidValue.js +1 -0
  168. package/lib/typescript/commonjs/utils/assertValidValue.d.ts +10 -0
  169. package/lib/typescript/module/utils/assertValidValue.d.ts +10 -0
  170. package/package.json +7 -7
  171. package/lib/commonjs/utils/warnInvalidValue.js +0 -1
  172. package/lib/module/utils/warnInvalidValue.js +0 -1
  173. package/lib/typescript/commonjs/utils/warnInvalidValue.d.ts +0 -10
  174. package/lib/typescript/module/utils/warnInvalidValue.d.ts +0 -10
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.InlineSelect=exports.DEFAULT_INLINE_SELECT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_Chevron=require("../FieldBase/Chevron.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_INLINE_SELECT_LABELS=exports.DEFAULT_INLINE_SELECT_LABELS={select:"Select",options:"Options",noSelection:"No selection",selected:e=>`Selected: ${e}`},InlineSelect=exports.InlineSelect=(0,_react.forwardRef)((e,t)=>{const{options:i,getOptionLabel:l,getOptionValue:s,isOptionDisabled:n,getOptionDescription:a,getOptionIcon:r,value:o,onChange:c,placeholder:d,labels:u,label:p,title:_,searchable:x=!1,haptic:S,disabled:b=!1,size:h="md",color:v,chevronColor:m,chevronSize:L,textStyle:g,style:j,optionStyle:y,selectedOptionStyle:I,optionTextStyle:O,selectedOptionTextStyle:C,accessibilityLabel:E,testID:f}=e,T=(0,_index.useTheme)(),N=Object.keys(T.components.field);(0,_warnInvalidValue.warnInvalidValue)("InlineSelect","size",e.size,N);const F=(0,_react.useMemo)(()=>buildStyles(T),[T]),D=N.includes(h)?h:"md",R=(0,_index.resolveFieldSize)(T,D),k=(0,_react.useMemo)(()=>({...DEFAULT_INLINE_SELECT_LABELS,...u}),[u]),q=(0,_react.useCallback)(e=>l?l(e):e.label??"",[l]),B=(0,_react.useCallback)(e=>s?s(e):e.value,[s]),z=(0,_react.useCallback)(e=>n?n(e):!0===e.disabled,[n]),A=(0,_react.useCallback)(e=>a?a(e):e.description,[a]),w=(0,_react.useCallback)(e=>r?r(e):e.icon,[r]),[V,M]=(0,_react.useState)(!1),H=(0,_react.useMemo)(()=>{if(null!=o)return i.find(e=>B(e)===o)},[i,o,B]),P=(0,_react.useCallback)(()=>{if(b)return;const e=(0,_index2.resolveHaptic)(S,"selection");e&&(0,_index2.triggerHaptic)(e),M(!0)},[b,S]),U=(0,_react.useCallback)(()=>{M(!1)},[]),$=(0,_react.useCallback)(e=>{if(z(e))return;const t=(0,_index2.resolveHaptic)(S,"selection");t&&(0,_index2.triggerHaptic)(t),c(B(e)),U()},[z,B,c,U,S]),G=b?T.colors["text-disabled"]:v??T.colors.primary,J=void 0!==H?q(H):d??k.select,K=void 0!==H?k.selected(q(H)):d??k.noSelection,Q=E??`${p??_??k.select}. ${K}`,W=(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:t,onPress:P,disabled:b,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:Q,accessibilityState:{disabled:b,expanded:V},"aria-disabled":b,"aria-expanded":V,testID:f,style:({pressed:e})=>[F.trigger,{columnGap:T.space.xs,opacity:e&&!b?.6:1},j],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[F.triggerText,{color:G,fontSize:R.text,...(0,_index.fontFor)(T,"medium")},g],numberOfLines:1,children:J}),(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:m??G,size:L??R.icon,open:V})]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[p?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:F.labelled,children:[(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:D,children:p}),W]}):W,(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:V,onClose:U,haptic:S,title:_,accessibilityLabel:p??_??d??k.options,options:i,getOptionLabel:q,getOptionValue:B,isOptionDisabled:z,getOptionDescription:A,getOptionIcon:w,value:o,onChange:(e,t)=>$(t),searchable:x,optionStyle:y,selectedOptionStyle:I,optionTextStyle:O,selectedOptionTextStyle:C})]})});InlineSelect.displayName="InlineSelect";const buildStyles=e=>_reactNative.StyleSheet.create({labelled:{alignItems:"flex-start"},trigger:{flexDirection:"row",alignItems:"center"},triggerText:{includeFontPadding:!1}});var _default=exports.default=InlineSelect;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.InlineSelect=exports.DEFAULT_INLINE_SELECT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hitSlop=require("../../utils/hitSlop.js"),_Chevron=require("../FieldBase/Chevron.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_INLINE_SELECT_LABELS=exports.DEFAULT_INLINE_SELECT_LABELS={select:"Select",options:"Options",noSelection:"No selection",selected:e=>`Selected: ${e}`},InlineSelect=exports.InlineSelect=(0,_react.forwardRef)((e,t)=>{const{options:i,getOptionLabel:l,getOptionValue:s,isOptionDisabled:a,getOptionDescription:n,getOptionIcon:r,value:o,onChange:c,placeholder:d,labels:u,label:p,title:_,searchable:x=!1,haptic:S,disabled:b=!1,size:h="md",color:m,chevronColor:L,chevronSize:g,textStyle:j,style:y,optionStyle:v,selectedOptionStyle:O,optionTextStyle:I,selectedOptionTextStyle:C,accessibilityLabel:E,testID:f}=e,T=(0,_index.useTheme)(),N=Object.keys(T.components.field);(0,_assertValidValue.assertValidValue)("InlineSelect","size",e.size,N);const F=(0,_react.useMemo)(()=>buildStyles(T),[T]),D=N.includes(h)?h:"md",R=(0,_index.resolveFieldSize)(T,D),V=(0,_react.useMemo)(()=>({...DEFAULT_INLINE_SELECT_LABELS,...u}),[u]),k=(0,_react.useCallback)(e=>l?l(e):e.label??"",[l]),q=(0,_react.useCallback)(e=>s?s(e):e.value,[s]),B=(0,_react.useCallback)(e=>a?a(e):!0===e.disabled,[a]),z=(0,_react.useCallback)(e=>n?n(e):e.description,[n]),A=(0,_react.useCallback)(e=>r?r(e):e.icon,[r]),[M,H]=(0,_react.useState)(!1),P=(0,_react.useMemo)(()=>{if(null!=o)return i.find(e=>q(e)===o)},[i,o,q]),U=(0,_react.useCallback)(()=>{if(b)return;const e=(0,_index2.resolveHaptic)(S,"selection");e&&(0,_index2.triggerHaptic)(e),H(!0)},[b,S]),w=(0,_react.useCallback)(()=>{H(!1)},[]),$=(0,_react.useCallback)(e=>{if(B(e))return;const t=(0,_index2.resolveHaptic)(S,"selection");t&&(0,_index2.triggerHaptic)(t),c(q(e)),w()},[B,q,c,w,S]),G=b?T.colors["text-disabled"]:m??T.colors.primary,J=void 0!==P?k(P):d??V.select,K=void 0!==P?V.selected(k(P)):d??V.noSelection,Q=E??`${p??_??V.select}. ${K}`,W=(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:t,onPress:U,disabled:b,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:Q,accessibilityState:{disabled:b,expanded:M},"aria-disabled":b,"aria-expanded":M,testID:f,style:({pressed:e})=>[F.trigger,{columnGap:T.space.xs,opacity:e&&!b?.6:1},y],children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[F.triggerText,{color:G,fontSize:R.text,...(0,_index.fontFor)(T,"medium")},j],numberOfLines:1,children:J}),(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:L??G,size:g??R.icon,open:M})]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[p?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:F.labelled,children:[(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:D,children:p}),W]}):W,(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:M,onClose:w,haptic:S,title:_,accessibilityLabel:p??_??d??V.options,options:i,getOptionLabel:k,getOptionValue:q,isOptionDisabled:B,getOptionDescription:z,getOptionIcon:A,value:o,onChange:(e,t)=>$(t),searchable:x,optionStyle:v,selectedOptionStyle:O,optionTextStyle:I,selectedOptionTextStyle:C})]})});InlineSelect.displayName="InlineSelect";const buildStyles=e=>_reactNative.StyleSheet.create({labelled:{alignItems:"flex-start"},trigger:{flexDirection:"row",alignItems:"center"},triggerText:{includeFontPadding:!1}});var _default=exports.default=InlineSelect;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Input=exports.DEFAULT_INPUT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../Button/index.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_textInk=require("../Text/textInk.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_INPUT_LABELS=exports.DEFAULT_INPUT_LABELS={showPassword:"Show password",hidePassword:"Hide password"},Input=exports.Input=(0,_react.forwardRef)((e,t)=>{const{label:i,help:n,placeholder:a,value:l,onChangeText:s,error:r,helperText:o,type:d="input",secureTextEntry:c=!1,showPasswordToggle:u=!1,disabled:x=!1,multiline:p=!1,leftIcon:_,rightIcon:f,unit:g,unitStyle:m,prefix:v,prefixStyle:h,readOnly:y=!1,action:j,actionStyle:I,size:b="md",variant:w,labelMode:S,required:R=!1,maxLength:N,showCounter:T=!0,textAlign:F,format:V,parse:A,style:L,containerStyle:B,inputStyle:P,labelStyle:k,messageStyle:z,radius:q,onFocus:D,onBlur:C,accessibilityLabel:E,labels:H,testID:M,editable:O,...U}=e;(0,_warnInvalidValue.warnInvalidValue)("Input","variant",w,["outline","filled","underline"]),(0,_warnInvalidValue.warnInvalidValue)("Input","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Input","labelMode",S,["float","top"]),(0,_warnInvalidValue.warnInvalidValue)("Input","type",e.type,["input","password","textarea"]);const G=(0,_react.useMemo)(()=>({...DEFAULT_INPUT_LABELS,...H}),[H]),W=(0,_index2.useTheme)(),$=(0,_react.useMemo)(()=>buildStyles(W),[W]),X=(0,_index2.resolveFieldSize)(W,b),J=W.components.input[b]["multiline-min-height"],K=Math.round(X.text*W.leading.body),Q=w??W.settings.components.input?.defaultVariant??W.settings.components.field?.defaultVariant??"outline",Y=S??W.settings.components.input?.defaultLabelMode??"top",[Z,ee]=(0,_react.useState)(!1),[te,ie]=(0,_react.useState)(!1),ne="password"===d||u||c,ae="password"===d||u,le="textarea"===d||p,se=le?Math.round(.1*X.text):0,re="string"==typeof l&&l.length>0,oe=(0,_FieldBase.hasFieldText)(r),de=!0===r||oe,ce=(0,_FieldBase.hasFieldText)(o),ue=oe||!de&&ce,xe=(0,_FieldBase.hasFieldText)(i),pe=(0,_FieldBase.hasFieldText)(v),fe=!x&&!1!==O,ge=Z||re||pe,me=(0,_react.useRef)(null),ve=(0,_react.useMemo)(()=>(0,_index3.mergeRefs)(me,t),[t]),he=(0,_react.useCallback)(()=>{fe&&me.current?.focus()},[fe]),ye=xe&&"float"===Y,je=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,Ie=(0,_react.useRef)((0,_index2.createAnimatedValue)(ue?1:0)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(Ie,{toValue:ue?1:0,duration:W.motion.duration.fast,easing:_reactNative.Easing.bezier(...W.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[ue,Ie,W.motion.duration.fast,W.motion.ease["in-out"]]);const be=(0,_index.useReducedMotion)(),we=W.settings.components.input?.shakeOnError??!1,Se=(0,_react.useRef)(de);(0,_react.useEffect)(()=>{if(!we)return void(Se.current=de);let e;return de&&!Se.current&&(be||((0,_index2.setNativeValue)(je,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(je,{toValue:1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(je,{toValue:-1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(je,{toValue:1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(je,{toValue:-1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(je,{toValue:0,duration:100,useNativeDriver:!0})]),e.start()),(0,_index3.triggerHaptic)("notificationError")),Se.current=de,()=>e?.stop()},[de,je,we,be]);const Re=(0,_react.useCallback)(e=>{ee(!0),D?.(e)},[D]),Ne=(0,_react.useCallback)(e=>{ee(!1),C?.(e)},[C]),Te=(0,_react.useCallback)(()=>{(0,_index3.triggerHaptic)("selection"),ie(e=>!e)},[]),Fe=W.colors["field-caret"],Ve=W.settings.components.input?.tintLabelOnFocus??!1,Ae=Z&&Ve?W.colors["field-border-focus"]:W.colors["field-label"],Le=je.interpolate({inputRange:[-1,0,1],outputRange:[-6,0,6]}),Be=Boolean(f)||Boolean(g)||ae,Pe="underline"===Q,ke=_?X.icon+W.space.md+1+W.space.md:0,ze=(0,_useFloatingLabel.useFloatingLabel)({label:i,enabled:ye,floated:ge,required:R,variant:Q,sizeTokens:X,leadingOffset:ke,trailingOffset:Be?X.icon+W.space.sm:0,textAlign:F,paddingLeft:Pe?W.space.none:X["padding-x"],lineHeight:le?K:void 0,restNudge:se,floatTrim:le?2:0,color:Ae,style:k}),qe=(0,_FieldBase.resolveFieldTextStyle)(W,{disabled:x}),De=qe.color,Ce=qe.placeholderColor,Ee=R&&!xe&&!re&&"string"==typeof a&&a.length>0,He=de?r:o,Me=T&&"number"==typeof N&&"string"==typeof l?`${l.length} / ${N}`:null,Oe=de?W.colors["field-message"]:W.colors["text-muted"],Ue=(0,_textInk.useTextInk)(z,X["message-text"],Oe),Ge=E??(0,_FieldBase.fieldTextAsString)(i)??a,We=x?W.colors["field-icon-disabled"]:Z?W.colors["field-icon-focus"]:W.colors["field-icon"],$e={focused:Z,disabled:x,error:de,color:We,size:X.icon},renderSlot=e=>(0,_slotIcon.renderSlotIcon)(e,$e),Xe=(()=>{if(ae){const e=(te?W.settings.icons.eyeOff:W.settings.icons.eye)??(te?_defaultIcons.defaultIcons.eyeOff:_defaultIcons.defaultIcons.eye);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Te,disabled:!fe,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:te?G.hidePassword:G.showPassword,children:e({size:X.icon,color:We})})}const e=g?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[$.unit,{fontSize:X.text,color:Ce},m],children:g}):null,t=f?(0,_slotIcon.slotIconView)(f,renderSlot(f)):null;return e&&t?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$.trailingRow,children:[e,t]}):e??t})(),Je=_?(0,_slotIcon.slotIconView)(_,renderSlot(_)):null,Ke=_reactNative.StyleSheet.flatten(h),Qe=Ke?.fontSize??X.text,Ye=Ke?.color??Ce,Ze=(0,_react.useMemo)(()=>({fontSize:Qe,color:Ye}),[Qe,Ye]),et=pe?"string"==typeof v||"number"==typeof v?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[$.prefix,{fontSize:X.text,color:Ce,marginRight:W.space.xs,lineHeight:le?K:void 0,paddingTop:le?se:void 0},h],children:v}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[$.prefixNode,{marginRight:W.space.xs,minHeight:le?K:void 0,justifyContent:"center",paddingTop:le?se:void 0}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[$.prefix,{fontSize:X.text,color:Ce,lineHeight:le?K:void 0},h],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:Ze,children:v})})}):null,tt=j?(0,_jsxRuntime.jsx)(_index4.Button,{variant:j.variant??"outline",tone:j.tone??"primary",size:b,label:j.label,leftIcon:j.icon,loading:j.loading,disabled:x||j.disabled,onPress:j.onPress,pressAnimation:!1,testID:j.testID,style:[$.action,{minHeight:X["min-height"],alignSelf:le?"flex-start":"stretch"},I]}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[$.container,{transform:[{translateX:Le}]},L],children:[xe&&!ye?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:b,required:R,help:n,color:Ae,style:k,children:i}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[$.fieldRow,{columnGap:W.space.sm,alignItems:le?"flex-start":"stretch"}],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$.fieldWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:b,variant:Q,focused:Z,disabled:x,error:de,filled:re,minHeight:le?J:void 0,radius:q,leading:Je,leadingDivider:null!=_,paddingLeft:Pe?W.space.none:void 0,trailing:Xe,slotAlign:le?"top":"center",slotLineHeight:le?K:void 0,topNotch:ze.topNotch,onPress:he,pressFeedback:!1,style:B,children:[et,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$.inputWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:ve,style:[$.input,{color:De,fontSize:X.text,...qe.weightStyle,paddingLeft:Pe?W.space.none:void 0,minHeight:le?J-2*X["padding-y"]:void 0,lineHeight:le?K:void 0,paddingTop:le?se:void 0,textAlignVertical:le?"top":"center"},P],textAlign:F,placeholder:ye&&!ge||Ee?void 0:a,placeholderTextColor:Ce,value:V&&null!=l?V(l):l,onChangeText:e=>{s&&s(A?A(e):e)},onFocus:Re,onBlur:Ne,editable:fe,readOnly:y,secureTextEntry:ne&&!te,multiline:le,autoCapitalize:ne?"none":void 0,autoCorrect:!ne&&void 0,maxLength:N,selectionColor:Fe,accessibilityLabel:Ge,accessibilityState:{disabled:x},"aria-disabled":x,testID:M,...U}),Ee?(0,_jsxRuntime.jsx)(_FieldBase.RequiredPlaceholder,{text:a,color:Ce,fontSize:X.text,weightStyle:qe.weightStyle,align:le?"top":"center",paddingTop:le?se:void 0,textAlign:F}):null]})]}),ze.node]}),tt]}),ue||Me?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[$.footerRow,{marginTop:X["message-gap"]}],children:[ue?(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[$.messageRow,{columnGap:W.space.xs,opacity:Ie}],accessibilityLiveRegion:de?"polite":"none",children:[de?(0,_jsxRuntime.jsx)(_FieldBase.FieldErrorGlyph,{size:X["message-text"],color:Oe}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[$.messageText,{color:Oe,fontSize:X["message-text"],...(0,_index2.fontFor)(W,"normal")},z],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:Ue,children:He})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:$.footerSpacer}),Me?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[$.counterText,{color:W.colors["text-subtle"],fontSize:X["message-text"],...(0,_index2.fontFor)(W,"normal")}],children:Me}):null]}):null]})});Input.displayName="Input";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},fieldRow:{flexDirection:"row"},fieldWrapper:{position:"relative",overflow:"visible",flex:1},action:{flexShrink:0},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"},unit:{includeFontPadding:!1},trailingRow:{flexDirection:"row",alignItems:"center",columnGap:e.space.sm},footerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},footerSpacer:{flex:1},messageRow:{flex:1,flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1},counterText:{flexShrink:0,includeFontPadding:!1}});var _default=exports.default=Input;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Input=exports.DEFAULT_INPUT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../Button/index.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_textInk=require("../Text/textInk.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_INPUT_LABELS=exports.DEFAULT_INPUT_LABELS={showPassword:"Show password",hidePassword:"Hide password"},Input=exports.Input=(0,_react.forwardRef)((e,t)=>{const{label:i,help:n,placeholder:a,value:s,onChangeText:l,error:r,helperText:o,type:d="input",secureTextEntry:c=!1,showPasswordToggle:u=!1,disabled:x=!1,multiline:p=!1,leftIcon:_,rightIcon:f,unit:g,unitStyle:m,prefix:h,prefixStyle:v,readOnly:y=!1,action:j,actionStyle:b,size:S="md",variant:I,labelMode:R,required:w=!1,maxLength:N,showCounter:T=!0,textAlign:V,format:F,parse:A,style:L,containerStyle:B,inputStyle:P,labelStyle:k,messageStyle:z,radius:q,onFocus:D,onBlur:C,accessibilityLabel:E,labels:H,testID:M,editable:O,...U}=e;(0,_assertValidValue.assertValidValue)("Input","variant",I,["outline","filled","underline"]),(0,_assertValidValue.assertValidValue)("Input","size",e.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Input","labelMode",R,["float","top"]),(0,_assertValidValue.assertValidValue)("Input","type",e.type,["input","password","textarea"]);const G=(0,_react.useMemo)(()=>({...DEFAULT_INPUT_LABELS,...H}),[H]),W=(0,_index2.useTheme)(),$=(0,_react.useMemo)(()=>buildStyles(W),[W]),X=(0,_index2.resolveFieldSize)(W,S),J=W.components.input[S]["multiline-min-height"],K=Math.round(X.text*W.leading.body),Q=I??W.settings.components.input?.defaultVariant??W.settings.components.field?.defaultVariant??"outline",Y=R??W.settings.components.input?.defaultLabelMode??"top",[Z,ee]=(0,_react.useState)(!1),[te,ie]=(0,_react.useState)(!1),ne="password"===d||u||c,ae="password"===d||u,se="textarea"===d||p,le=se?Math.round(.1*X.text):0,re="string"==typeof s&&s.length>0,oe=(0,_FieldBase.hasFieldText)(r),de=!0===r||oe,ce=(0,_FieldBase.hasFieldText)(o),ue=oe||!de&&ce,xe=(0,_FieldBase.hasFieldText)(i),pe=(0,_FieldBase.hasFieldText)(h),fe=!x&&!1!==O,ge=Z||re||pe,me=(0,_react.useRef)(null),he=(0,_react.useMemo)(()=>(0,_index3.mergeRefs)(me,t),[t]),ve=(0,_react.useCallback)(()=>{fe&&me.current?.focus()},[fe]),ye=xe&&"float"===Y,je=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,be=(0,_react.useRef)((0,_index2.createAnimatedValue)(ue?1:0)).current;(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing(be,{toValue:ue?1:0,duration:W.motion.duration.fast,easing:_reactNative.Easing.bezier(...W.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[ue,be,W.motion.duration.fast,W.motion.ease["in-out"]]);const Se=(0,_index.useReducedMotion)(),Ie=W.settings.components.input?.shakeOnError??!1,Re=(0,_react.useRef)(de);(0,_react.useEffect)(()=>{if(!Ie)return void(Re.current=de);let e;return de&&!Re.current&&(Se||((0,_index2.setNativeValue)(je,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(je,{toValue:1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(je,{toValue:-1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(je,{toValue:1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(je,{toValue:-1,duration:50,useNativeDriver:!0}),_reactNative.Animated.timing(je,{toValue:0,duration:100,useNativeDriver:!0})]),e.start()),(0,_index3.triggerHaptic)("notificationError")),Re.current=de,()=>e?.stop()},[de,je,Ie,Se]);const we=(0,_react.useCallback)(e=>{ee(!0),D?.(e)},[D]),Ne=(0,_react.useCallback)(e=>{ee(!1),C?.(e)},[C]),Te=(0,_react.useCallback)(()=>{(0,_index3.triggerHaptic)("selection"),ie(e=>!e)},[]),Ve=W.colors["field-caret"],Fe=W.settings.components.input?.tintLabelOnFocus??!1,Ae=Z&&Fe?W.colors["field-border-focus"]:W.colors["field-label"],Le=je.interpolate({inputRange:[-1,0,1],outputRange:[-6,0,6]}),Be=Boolean(f)||Boolean(g)||ae,Pe="underline"===Q,ke=_?X.icon+W.space.md+1+W.space.md:0,ze=(0,_useFloatingLabel.useFloatingLabel)({label:i,enabled:ye,floated:ge,required:w,variant:Q,sizeTokens:X,leadingOffset:ke,trailingOffset:Be?X.icon+W.space.sm:0,textAlign:V,paddingLeft:Pe?W.space.none:X["padding-x"],lineHeight:se?K:void 0,restNudge:le,floatTrim:se?2:0,color:Ae,style:k}),qe=(0,_FieldBase.resolveFieldTextStyle)(W,{disabled:x}),De=qe.color,Ce=qe.placeholderColor,Ee=w&&!xe&&!re&&"string"==typeof a&&a.length>0,He=de?r:o,Me=T&&"number"==typeof N&&"string"==typeof s?`${s.length} / ${N}`:null,Oe=de?W.colors["field-message"]:W.colors["text-muted"],Ue=(0,_textInk.useTextInk)(z,X["message-text"],Oe),Ge=E??(0,_FieldBase.fieldTextAsString)(i)??a,We=x?W.colors["field-icon-disabled"]:Z?W.colors["field-icon-focus"]:W.colors["field-icon"],$e={focused:Z,disabled:x,error:de,color:We,size:X.icon},renderSlot=e=>(0,_slotIcon.renderSlotIcon)(e,$e),Xe=(()=>{if(ae){const e=(te?W.settings.icons.eyeOff:W.settings.icons.eye)??(te?_defaultIcons.defaultIcons.eyeOff:_defaultIcons.defaultIcons.eye);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Te,disabled:!fe,hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:te?G.hidePassword:G.showPassword,children:e({size:X.icon,color:We})})}const e=g?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[$.unit,{fontSize:X.text,color:Ce},m],children:g}):null,t=f?(0,_slotIcon.slotIconView)(f,renderSlot(f)):null;return e&&t?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$.trailingRow,children:[e,t]}):e??t})(),Je=_?(0,_slotIcon.slotIconView)(_,renderSlot(_)):null,Ke=_reactNative.StyleSheet.flatten(v),Qe=Ke?.fontSize??X.text,Ye=Ke?.color??Ce,Ze=(0,_react.useMemo)(()=>({fontSize:Qe,color:Ye}),[Qe,Ye]),et=pe?"string"==typeof h||"number"==typeof h?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[$.prefix,{fontSize:X.text,color:Ce,marginRight:W.space.xs,lineHeight:se?K:void 0,paddingTop:se?le:void 0},v],children:h}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[$.prefixNode,{marginRight:W.space.xs,minHeight:se?K:void 0,justifyContent:"center",paddingTop:se?le:void 0}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[$.prefix,{fontSize:X.text,color:Ce,lineHeight:se?K:void 0},v],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:Ze,children:h})})}):null,tt=j?(0,_jsxRuntime.jsx)(_index4.Button,{variant:j.variant??"outline",tone:j.tone??"primary",size:S,label:j.label,leftIcon:j.icon,loading:j.loading,disabled:x||j.disabled,onPress:j.onPress,pressAnimation:!1,testID:j.testID,style:[$.action,{minHeight:X["min-height"],alignSelf:se?"flex-start":"stretch"},b]}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[$.container,{transform:[{translateX:Le}]},L],children:[xe&&!ye?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:S,required:w,help:n,color:Ae,style:k,children:i}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[$.fieldRow,{columnGap:W.space.sm,alignItems:se?"flex-start":"stretch"}],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$.fieldWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:S,variant:Q,focused:Z,disabled:x,error:de,filled:re,minHeight:se?J:void 0,radius:q,leading:Je,leadingDivider:null!=_,paddingLeft:Pe?W.space.none:void 0,trailing:Xe,slotAlign:se?"top":"center",slotLineHeight:se?K:void 0,topNotch:ze.topNotch,onPress:ve,pressFeedback:!1,style:B,children:[et,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$.inputWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:he,style:[$.input,{color:De,fontSize:X.text,...qe.weightStyle,paddingLeft:Pe?W.space.none:void 0,minHeight:se?J-2*X["padding-y"]:void 0,lineHeight:se?K:void 0,paddingTop:se?le:void 0,textAlignVertical:se?"top":"center"},P],textAlign:V,placeholder:ye&&!ge||Ee?void 0:a,placeholderTextColor:Ce,value:F&&null!=s?F(s):s,onChangeText:e=>{l&&l(A?A(e):e)},onFocus:we,onBlur:Ne,editable:fe,readOnly:y,secureTextEntry:ne&&!te,multiline:se,autoCapitalize:ne?"none":void 0,autoCorrect:!ne&&void 0,maxLength:N,selectionColor:Ve,accessibilityLabel:Ge,accessibilityState:{disabled:x},"aria-disabled":x,testID:M,...U}),Ee?(0,_jsxRuntime.jsx)(_FieldBase.RequiredPlaceholder,{text:a,color:Ce,fontSize:X.text,weightStyle:qe.weightStyle,align:se?"top":"center",paddingTop:se?le:void 0,textAlign:V}):null]})]}),ze.node]}),tt]}),ue||Me?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[$.footerRow,{marginTop:X["message-gap"]}],children:[ue?(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[$.messageRow,{columnGap:W.space.xs,opacity:be}],accessibilityLiveRegion:de?"polite":"none",children:[de?(0,_jsxRuntime.jsx)(_FieldBase.FieldErrorGlyph,{size:X["message-text"],color:Oe}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[$.messageText,{color:Oe,fontSize:X["message-text"],...(0,_index2.fontFor)(W,"normal")},z],children:(0,_jsxRuntime.jsx)(_textInk.TextInkContext.Provider,{value:Ue,children:He})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:$.footerSpacer}),Me?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[$.counterText,{color:W.colors["text-subtle"],fontSize:X["message-text"],...(0,_index2.fontFor)(W,"normal")}],children:Me}):null]}):null]})});Input.displayName="Input";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},fieldRow:{flexDirection:"row"},fieldWrapper:{position:"relative",overflow:"visible",flex:1},action:{flexShrink:0},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"},unit:{includeFontPadding:!1},trailingRow:{flexDirection:"row",alignItems:"center",columnGap:e.space.sm},footerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},footerSpacer:{flex:1},messageRow:{flex:1,flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1},counterText:{flexShrink:0,includeFontPadding:!1}});var _default=exports.default=Input;
@@ -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"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_themeStyles=require("../../utils/themeStyles.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.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,ListItem=exports.ListItem=_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:v,selected:y=!1,expanded:f,disabled:w=!1,size:R="md",variant:S="list",divider:I=!1,chevron:L=!1,leftActions:k,rightActions:N,contextMenu:V,accessibilityLabel:C,accessibilityHint:A,style:q,containerStyle:B,titleStyle:P,subtitleStyle:z,descriptionStyle:O,leftSlotStyle:E,rightSlotStyle:M,testID:T}=e;(0,_warnInvalidValue.warnInvalidValue)("ListItem","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("ListItem","iconTone",e.iconTone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("ListItem","rightPlacement",e.rightPlacement,["auto","side","below"]),(0,_warnInvalidValue.warnInvalidValue)("ListItem","variant",e.variant,["list","menu"]);const D="menu"===S,W=a??(D?2:1),F=D?e.checked:void 0,H=(0,_index.useTheme)(),G=(0,_react.useMemo)(()=>(0,_index.resolveListItemSize)(H,R),[H,R]),U=stylesFor(H),{fontScale:K}=(0,_reactNative.useWindowDimensions)(),Z=!!m&&("below"===x||"auto"===x&&K>1.2),J=(0,_useContextMenu.useContextMenu)(w?void 0:V,{haptic:v||!1,testID:T}),Q=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,J.hostRef),[t,J.hostRef]),X=_||!!b,Y=X||J.enabled,$=Y&&!w,{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[R]})),le=_?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:U.selectionLead,children:[(0,_jsxRuntime.jsx)(SelectionBox,{checked:h,disabled:w}),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:y?H.colors["surface-selected"]:"transparent"},oe?U.divider:null,w&&!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:w?H.colors["text-disabled"]:H.colors["text-body"]},P],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:w?H.colors["text-disabled"]:H.colors["text-muted"]},D?U.menuSubtitle:null,z],numberOfLines:o,children:n}):n,r?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[U.description,{fontSize:G["subtitle-text"],color:w?H.colors["text-disabled"]:H.colors["text-subtle"]},O],numberOfLines:2,children:r}):null,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:w?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)&&(v&&(0,_hapticUtils.triggerHaptic)(v),_?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:f}:{selected:y,disabled:!$,expanded:f,...void 0!==F?{checked:F}:null},"aria-disabled":!$,"aria-expanded":f,..._?{"aria-checked":h}:void 0!==F?{"aria-checked":F}:{"aria-selected":y},...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:y,disabled:w},"aria-selected":y,"aria-disabled":w,testID:T,style:q,children:ce}),ue=k&&k.length>0||N&&N.length>0,me=ae?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[y?{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:N,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}));ListItem.displayName="ListItem";const ListItemSkeleton=({subtitle:e,description:t,leading:i,icon:s,trailing:n,chevron:r,size:l="md",variant:a="list",containerStyle:o,style:c})=>{const d=(0,_index.useTheme)(),u=(0,_index.resolveListItemSize)(d,l),m=Math.round(1.15*u["title-text"]),x=Math.round(1.15*u["subtitle-text"]),_="menu"===a;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"center",paddingHorizontal:d.space.md,paddingVertical:_?d.space.sm:u["padding-y"],minHeight:_?48:u["min-height"]},o,c],children:[void 0!==i||void 0!==s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:d.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:m,style:{marginBottom:d.space.xs}}),void 0!==e?(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"50%",height:x,style:void 0!==t?{marginBottom:d.space.xs}:void 0}):null,void 0!==t?(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"85%",height:x}):null]}),void 0!==n||r?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginLeft:d.space.sm},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:20,height:20,radius:"sm"})}):null]})};ListItemSkeleton.displayName="ListItemSkeleton",ListItem.Skeleton=ListItemSkeleton;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,ListItem=exports.ListItem=_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,containerStyle:B,titleStyle:P,subtitleStyle:z,descriptionStyle:O,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"]},P],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,z],numberOfLines:o,children:n}):n,r?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[U.description,{fontSize:G["subtitle-text"],color:R?H.colors["text-disabled"]:H.colors["text-subtle"]},O],numberOfLines:2,children:r}):null,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}));ListItem.displayName="ListItem";const ListItemSkeleton=({subtitle:e,description:t,leading:i,icon:s,trailing:n,chevron:r,size:l="md",variant:a="list",containerStyle:o,style:c})=>{const d=(0,_index.useTheme)(),u=(0,_index.resolveListItemSize)(d,l),m=Math.round(1.15*u["title-text"]),x=Math.round(1.15*u["subtitle-text"]),_="menu"===a;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"center",paddingHorizontal:d.space.md,paddingVertical:_?d.space.sm:u["padding-y"],minHeight:_?48:u["min-height"]},o,c],children:[void 0!==i||void 0!==s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:d.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:m,style:{marginBottom:d.space.xs}}),void 0!==e?(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"50%",height:x,style:void 0!==t?{marginBottom:d.space.xs}:void 0}):null,void 0!==t?(0,_jsxRuntime.jsx)(_index4.Skeleton,{shape:"text",width:"85%",height:x}):null]}),void 0!==n||r?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginLeft:d.space.sm},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:20,height:20,radius:"sm"})}):null]})};ListItemSkeleton.displayName="ListItemSkeleton",ListItem.Skeleton=ListItemSkeleton;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.ListSection=void 0;var _react=require("react"),_index=require("../../theme/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../Card/index.js"),_index3=require("../Divider/index.js"),_index4=require("../SectionHeader/index.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const useStyles=(0,_index.makeStyles)(e=>({label:{marginTop:e.space.xl,marginBottom:e.space.sm},footer:{marginTop:e.space.sm,paddingHorizontal:e.space.md}})),ListSection=e=>{const{title:i,action:t,footer:n,variant:r="outline",testID:a,children:s}=e;(0,_warnInvalidValue.warnInvalidValue)("ListSection","variant",e.variant,["elevated","outline","filled","flat"]);const d=useStyles(),l=_react.Children.toArray(s).filter(_react.isValidElement).flatMap((e,i)=>0===i?[e]:[(0,_jsxRuntime.jsx)(_index3.Divider,{},`divider-${e.key}`),e]);return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[i?(0,_jsxRuntime.jsx)(_index4.SectionHeader,{variant:"caps",action:t,style:d.label,children:i}):null,(0,_jsxRuntime.jsx)(_index2.Card,{variant:r,padding:"none",testID:a,children:l}),n?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",color:"secondary",style:d.footer,children:n}):null]})};exports.ListSection=ListSection;var _default=exports.default=ListSection;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ListSection=void 0;var _react=require("react"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index2=require("../Card/index.js"),_index3=require("../Divider/index.js"),_index4=require("../SectionHeader/index.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const useStyles=(0,_index.makeStyles)(e=>({label:{marginTop:e.space.xl,marginBottom:e.space.sm},footer:{marginTop:e.space.sm,paddingHorizontal:e.space.md}})),ListSection=e=>{const{title:i,action:t,footer:r,variant:n="outline",testID:a,children:s}=e;(0,_assertValidValue.assertValidValue)("ListSection","variant",e.variant,["elevated","outline","filled","flat"]);const d=useStyles(),l=_react.Children.toArray(s).filter(_react.isValidElement).flatMap((e,i)=>0===i?[e]:[(0,_jsxRuntime.jsx)(_index3.Divider,{},`divider-${e.key}`),e]);return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[i?(0,_jsxRuntime.jsx)(_index4.SectionHeader,{variant:"caps",action:t,style:d.label,children:i}):null,(0,_jsxRuntime.jsx)(_index2.Card,{variant:n,padding:"none",testID:a,children:l}),r?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",color:"secondary",style:d.footer,children:r}):null]})};exports.ListSection=ListSection;var _default=exports.default=ListSection;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Menu=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_MenuSurface=require("./MenuSurface.js"),_menuModel=require("./menuModel.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,l={__proto__:null,default:e};if(Object(e)!==e)return l;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,l)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(l,r,a):l[r]=e[r]);return l}const Menu=e=>{const{items:t,trigger:a,title:r,topActions:n,placement:l="bottom",presentation:u="auto",unavailable:s="disable",open:i,onOpenChange:o,haptic:c,accessibilityLabel:_,labels:p,testID:d}=e;(0,_warnInvalidValue.warnInvalidValue)("Menu","placement",e.placement,["top","bottom","auto"]),(0,_warnInvalidValue.warnInvalidValue)("Menu","presentation",e.presentation,["auto","popover","sheet"]),(0,_warnInvalidValue.warnInvalidValue)("Menu","unavailable",e.unavailable,["disable","hide"]);const f=(0,_react.useMemo)(()=>({..._menuModel.DEFAULT_MENU_LABELS,...p}),[p]),[m,b]=(0,_useControllableState.useControllableState)({value:i,defaultValue:!1,onChange:o}),[h,v]=(0,_react.useState)(null),[M,j]=(0,_react.useState)(m),x=(0,_react.useRef)(null),w=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{m?(j(!0),x.current?.measureInWindow((e,t,a,r)=>{v({x:e,y:t,width:a,height:r})})):v(null)},[m]);const g=(0,_react.useCallback)(()=>b(!1),[b]),R=(0,_react.useCallback)(()=>w.current??x.current,[]),I=a.props,S=I.ref,q={ref:(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(S,w),[S]),"aria-expanded":m,onPress:e=>{I.onPress?.(e),b(!0)}},V=_react.default.cloneElement(a,q);return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{ref:x,collapsable:!1,testID:d,children:V}),M?(0,_jsxRuntime.jsx)(_MenuSurface.MenuSurface,{open:m,anchor:h,items:t,title:r,topActions:n,placement:l,presentation:u,unavailable:s,onClose:g,restoreFocusTo:R,haptic:c,accessibilityLabel:_,labels:f,testID:d}):null]})};exports.Menu=Menu;var _default=exports.default=Menu;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Menu=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_MenuSurface=require("./MenuSurface.js"),_menuModel=require("./menuModel.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,s=Object.defineProperty,l={__proto__:null,default:e};if(Object(e)!==e)return l;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,l)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=s&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?s(l,r,a):l[r]=e[r]);return l}const Menu=e=>{const{items:t,trigger:a,title:r,topActions:s,placement:l="bottom",presentation:u="auto",unavailable:n="disable",open:i,onOpenChange:o,haptic:c,accessibilityLabel:_,labels:p,testID:d}=e;(0,_assertValidValue.assertValidValue)("Menu","placement",e.placement,["top","bottom","auto"]),(0,_assertValidValue.assertValidValue)("Menu","presentation",e.presentation,["auto","popover","sheet"]),(0,_assertValidValue.assertValidValue)("Menu","unavailable",e.unavailable,["disable","hide"]);const f=(0,_react.useMemo)(()=>({..._menuModel.DEFAULT_MENU_LABELS,...p}),[p]),[m,b]=(0,_useControllableState.useControllableState)({value:i,defaultValue:!1,onChange:o}),[h,M]=(0,_react.useState)(null),[j,V]=(0,_react.useState)(m),x=(0,_react.useRef)(null),v=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{m?(V(!0),x.current?.measureInWindow((e,t,a,r)=>{M({x:e,y:t,width:a,height:r})})):M(null)},[m]);const g=(0,_react.useCallback)(()=>b(!1),[b]),R=(0,_react.useCallback)(()=>v.current??x.current,[]),S=a.props,q=S.ref,C={ref:(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(q,v),[q]),"aria-expanded":m,onPress:e=>{S.onPress?.(e),b(!0)}},y=_react.default.cloneElement(a,C);return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{ref:x,collapsable:!1,testID:d,children:y}),j?(0,_jsxRuntime.jsx)(_MenuSurface.MenuSurface,{open:m,anchor:h,items:t,title:r,topActions:s,placement:l,presentation:u,unavailable:n,onClose:g,restoreFocusTo:R,haptic:c,accessibilityLabel:_,labels:f,testID:d}):null]})};exports.Menu=Menu;var _default=exports.default=Menu;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useContextMenu=void 0;var _react=require("react"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_MenuSurface=require("./MenuSurface.js"),_menuModel=require("./menuModel.js"),_webOnly=require("./webOnly.js"),_jsxRuntime=require("react/jsx-runtime");const useContextMenu=(e,t={})=>{const n=(0,_react.useRef)(null),[a,s]=(0,_react.useState)(!1),[i,r]=(0,_react.useState)(!1),[c,l]=(0,_react.useState)(null);(0,_warnInvalidValue.warnInvalidValue)("ContextMenu","unavailable",e?.unavailable,["hide","disable"]),(0,_warnInvalidValue.warnInvalidValue)("ContextMenu","presentation",e?.presentation,["auto","popover","sheet"]),(0,_warnInvalidValue.warnInvalidValue)("ContextMenu","placement",e?.placement,["top","bottom","auto"]);const u=e?.unavailable??"hide",o=e?.items,_=e?.topActions,p=(0,_react.useMemo)(()=>o?(0,_menuModel.visibleGroups)(o,u):[],[o,u]),b=(0,_react.useMemo)(()=>(0,_menuModel.visibleTopActions)(_,u),[_,u]),m=(0,_react.useMemo)(()=>(0,_menuModel.menuActions)(p,b),[p,b]),v=p.length>0||b.length>0,d=(0,_react.useRef)(e);d.current=e;const M=(0,_react.useRef)(t);M.current=t;const h=(0,_react.useRef)(m);h.current=m;const x=(0,_react.useCallback)(e=>{e&&r(!0),s(e),d.current?.onOpenChange?.(e)},[]);(0,_react.useEffect)(()=>{!v&&a&&x(!1)},[v,a,x]);const w=(0,_react.useCallback)(()=>{n.current?.measureInWindow((e,t,n,a)=>{l({x:e,y:t,width:n,height:a}),x(!0)})},[x]),f=(0,_react.useCallback)(()=>{const e=(0,_hapticUtils.resolveHaptic)(M.current.haptic,"longPress");e&&(0,_hapticUtils.triggerHaptic)(e),w()},[w]),C=(0,_react.useCallback)(e=>{const t=h.current.find(t=>t.name===e.nativeEvent.actionName);if(!t)return void M.current.onAccessibilityAction?.(e);const n=(0,_hapticUtils.resolveHaptic)(M.current.haptic,"selection");n&&(0,_hapticUtils.triggerHaptic)(n),t.item.onPress?.()},[]),A=t.accessibilityActions,y=(0,_react.useMemo)(()=>[...A??[],...m.map(e=>({name:e.name,label:e.label}))],[A,m]),I=(0,_react.useMemo)(()=>v?{onLongPress:f,accessibilityActions:y,onAccessibilityAction:C,...(0,_webOnly.webOnly)({onContextMenu:e=>{e.preventDefault?.(),w()}})}:{},[v,f,y,C,w]),g=(0,_react.useCallback)(()=>x(!1),[x]),j=(0,_react.useCallback)(()=>n.current,[]);return{enabled:v,hostRef:n,hostProps:I,renderSurface:n=>e&&v&&i?(0,_jsxRuntime.jsx)(_MenuSurface.MenuSurface,{open:a,anchor:c,items:e.items,title:e.title,topActions:e.topActions,placement:e.placement??"bottom",presentation:e.presentation??"auto",unavailable:u,context:!0,preview:!1===e.preview?void 0:e.preview??n,onClose:g,restoreFocusTo:j,haptic:t.haptic,accessibilityLabel:e.accessibilityLabel,labels:{..._menuModel.DEFAULT_MENU_LABELS,...e.labels},testID:t.testID?`${t.testID}-context`:void 0}):null}};exports.useContextMenu=useContextMenu;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useContextMenu=void 0;var _react=require("react"),_assertValidValue=require("../../utils/assertValidValue.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_MenuSurface=require("./MenuSurface.js"),_menuModel=require("./menuModel.js"),_webOnly=require("./webOnly.js"),_jsxRuntime=require("react/jsx-runtime");const useContextMenu=(e,t={})=>{const a=(0,_react.useRef)(null),[s,n]=(0,_react.useState)(!1),[i,r]=(0,_react.useState)(!1),[c,l]=(0,_react.useState)(null);(0,_assertValidValue.assertValidValue)("ContextMenu","unavailable",e?.unavailable,["hide","disable"]),(0,_assertValidValue.assertValidValue)("ContextMenu","presentation",e?.presentation,["auto","popover","sheet"]),(0,_assertValidValue.assertValidValue)("ContextMenu","placement",e?.placement,["top","bottom","auto"]);const u=e?.unavailable??"hide",o=e?.items,_=e?.topActions,p=(0,_react.useMemo)(()=>o?(0,_menuModel.visibleGroups)(o,u):[],[o,u]),b=(0,_react.useMemo)(()=>(0,_menuModel.visibleTopActions)(_,u),[_,u]),m=(0,_react.useMemo)(()=>(0,_menuModel.menuActions)(p,b),[p,b]),d=p.length>0||b.length>0,M=(0,_react.useRef)(e);M.current=e;const h=(0,_react.useRef)(t);h.current=t;const v=(0,_react.useRef)(m);v.current=m;const x=(0,_react.useCallback)(e=>{e&&r(!0),n(e),M.current?.onOpenChange?.(e)},[]);(0,_react.useEffect)(()=>{!d&&s&&x(!1)},[d,s,x]);const f=(0,_react.useCallback)(()=>{a.current?.measureInWindow((e,t,a,s)=>{l({x:e,y:t,width:a,height:s}),x(!0)})},[x]),C=(0,_react.useCallback)(()=>{const e=(0,_hapticUtils.resolveHaptic)(h.current.haptic,"longPress");e&&(0,_hapticUtils.triggerHaptic)(e),f()},[f]),V=(0,_react.useCallback)(e=>{const t=v.current.find(t=>t.name===e.nativeEvent.actionName);if(!t)return void h.current.onAccessibilityAction?.(e);const a=(0,_hapticUtils.resolveHaptic)(h.current.haptic,"selection");a&&(0,_hapticUtils.triggerHaptic)(a),t.item.onPress?.()},[]),A=t.accessibilityActions,y=(0,_react.useMemo)(()=>[...A??[],...m.map(e=>({name:e.name,label:e.label}))],[A,m]),g=(0,_react.useMemo)(()=>d?{onLongPress:C,accessibilityActions:y,onAccessibilityAction:V,...(0,_webOnly.webOnly)({onContextMenu:e=>{e.preventDefault?.(),f()}})}:{},[d,C,y,V,f]),j=(0,_react.useCallback)(()=>x(!1),[x]),w=(0,_react.useCallback)(()=>a.current,[]);return{enabled:d,hostRef:a,hostProps:g,renderSurface:a=>e&&d&&i?(0,_jsxRuntime.jsx)(_MenuSurface.MenuSurface,{open:s,anchor:c,items:e.items,title:e.title,topActions:e.topActions,placement:e.placement??"bottom",presentation:e.presentation??"auto",unavailable:u,context:!0,preview:!1===e.preview?void 0:e.preview??a,onClose:j,restoreFocusTo:w,haptic:t.haptic,accessibilityLabel:e.accessibilityLabel,labels:{..._menuModel.DEFAULT_MENU_LABELS,...e.labels},testID:t.testID?`${t.testID}-context`:void 0}):null}};exports.useContextMenu=useContextMenu;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.MessageBubble=exports.DEFAULT_MESSAGE_BUBBLE_LABELS=void 0;var _markdownCore=require("@webority/markdown-core"),_mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Button/index.js"),_index4=require("../Markdown/index.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_MESSAGE_BUBBLE_LABELS=exports.DEFAULT_MESSAGE_BUBBLE_LABELS=Object.freeze({you:"You",sending:"Sending",sent:"Sent",delivered:"Delivered",read:"Read",failed:"Not sent",retry:"Try again",copy:"Copy",replyTo:e=>e?`Reply to ${e}`:"Reply"}),MAX_WIDTH="85%",STATUS_ICON=14,statusIcon=e=>{switch(e){case"sending":return"clock";case"sent":return"check";case"failed":return"alert-circle";default:return"check-check"}},statusColour=(e,t)=>{switch(t){case"read":return e.colors["info-text"];case"failed":return e.colors["danger-text"];default:return e.colors["text-subtle"]}},MessageBubble=({side:e,text:t,children:s,markdown:r,groupPosition:n="single",author:i,time:a,status:o,replyTo:l,streaming:u=!1,error:c,onRetry:d,actions:x,onCopy:b,onLongPress:m,footer:_,labels:p,haptic:y,style:h,testID:g})=>{(0,_warnInvalidValue.warnInvalidValue)("MessageBubble","side",e,["mine","theirs"]),(0,_warnInvalidValue.warnInvalidValue)("MessageBubble","groupPosition",n,["single","first","middle","last"]),(0,_warnInvalidValue.warnInvalidValue)("MessageBubble","status",o,["sending","sent","delivered","read","failed"]);const f=(0,_index.useTheme)(),j=(0,_react.useMemo)(()=>buildStyles(f),[f]),v=p?{...DEFAULT_MESSAGE_BUBBLE_LABELS,...p}:DEFAULT_MESSAGE_BUBBLE_LABELS,B="mine"===e,L=!c&&(r??"theirs"===e),T="single"===n||"first"===n,R="single"===n||"last"===n,E=null==a?"":(0,_mobileCore.formatTime)(a),M=("failed"===o||Boolean(c))&&Boolean(d),S=B?v.you:i??"",w=(0,_react.useMemo)(()=>{const e=[];return b&&!x?.some(e=>"copy"===e.name)&&e.push({name:"copy",label:v.copy,onPress:()=>b(t)}),x&&e.push(...x),l?.onPress&&e.push({name:"openReply",label:v.replyTo(l.author),onPress:l.onPress}),M&&d&&e.push({name:"retry",label:v.retry,onPress:d}),e},[x,b,t,l,M,d,v]),A=(x?.length??0)>0||Boolean(b),I=(0,_react.useMemo)(()=>A?{items:w.map(({name:e,label:t,onPress:s})=>({key:e,label:t,onPress:s}))}:void 0,[A,w]),P=(0,_useContextMenu.useContextMenu)(I,{haptic:y,testID:g}),C=P.hostProps.onLongPress,k=!s||(x?.length??0)>0,q=o&&B?v[o]:"",D=(0,_react.useMemo)(()=>L&&null==s?(0,_markdownCore.markdownToPlainText)(t):t,[L,s,t]),V=[S,E,D,l?`${v.replyTo(l.author)}: ${l.text}`:"",q].filter(Boolean).join(", "),$=(0,_react.useRef)(u);(0,_react.useEffect)(()=>{$.current&&!u&&!c&&t&&(0,_announce.announce)(S?`${S}, ${D}`:D),$.current=u},[u,c,t,D,S]);const U=(0,_react.useRef)(c);(0,_react.useEffect)(()=>{c&&c!==U.current&&(0,_announce.announce)(c,{polite:!1}),U.current=c},[c]);const N=(0,_react.useCallback)(e=>{C?.(e),m?.()},[C,m]),F=(0,_react.useCallback)(e=>{w.find(t=>t.name===e.nativeEvent.actionName)?.onPress()},[w]),z=f.radius.xl,H=f.radius.sm,O=B?{borderTopRightRadius:T?z:H,borderBottomRightRadius:R?z:H}:{borderTopLeftRadius:T?z:H,borderBottomLeftRadius:R?z:H},G=s??(L?(0,_jsxRuntime.jsx)(_index4.Markdown,{children:t}):(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",children:t})),W=l?(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:l.onPress,disabled:!l.onPress,accessibilityRole:l.onPress?"button":void 0,accessibilityLabel:`${v.replyTo(l.author)}: ${l.text}`,style:j.quote,children:[l.author?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",weight:"semibold",color:"link",numberOfLines:1,children:l.author}):null,(0,_jsxRuntime.jsx)(_index5.Text,{variant:"bodySmall",color:"secondary",numberOfLines:2,children:l.text})]}):null,X=[j.bubble,B?j.mine:j.theirs,O],Y=k?{accessible:!0,accessibilityLabel:V,accessibilityState:{busy:u},"aria-busy":u,accessibilityActions:w.map(({name:e,label:t})=>({name:e,label:t})),onAccessibilityAction:F}:{accessible:!1},J=A?(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:P.hostRef,...P.hostProps,onLongPress:N,delayLongPress:350,style:X,testID:g?`${g}-bubble`:void 0,...Y,children:[W,G]}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:X,testID:g?`${g}-bubble`:void 0,...Y,children:[W,G]}),K=R&&(""!==E||B&&o);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[j.root,B?j.rootMine:j.rootTheirs,{marginTop:T?f.space.sm:f.space.xxs},h],accessibilityState:{busy:u},"aria-busy":u,testID:g,children:[!B&&T&&i?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",color:"secondary",style:j.author,numberOfLines:1,importantForAccessibility:k?"no-hide-descendants":"auto",accessibilityElementsHidden:k,children:i}):null,J,P.renderSurface(),K?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[j.meta,B?j.metaMine:null],importantForAccessibility:k?"no-hide-descendants":"auto",accessibilityElementsHidden:k,children:[E?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",color:"tertiary",children:E}):null,B&&o?(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:statusIcon(o),size:14,color:statusColour(f,o),accessibilityLabel:v[o],testID:g?`${g}-status-${o}`:void 0}):null]}):null,c?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"bodySmall",color:"danger",style:B?j.endText:null,children:c}):null,M?(0,_jsxRuntime.jsx)(_index3.Button,{label:v.retry,variant:"link",size:"sm",leftIcon:"refresh-cw",onPress:d,testID:g?`${g}-retry`:void 0}):null,_]})};exports.MessageBubble=MessageBubble;const buildStyles=e=>_reactNative.StyleSheet.create({root:{maxWidth:"85%",gap:e.space.xs},rootMine:{alignSelf:"flex-end",alignItems:"flex-end"},rootTheirs:{alignSelf:"flex-start",alignItems:"flex-start"},author:{paddingHorizontal:e.space.md},bubble:{borderRadius:e.radius.xl,..._corners.smoothCorners,paddingHorizontal:e.space.md,paddingVertical:e.space.sm,gap:e.space.xs},mine:{backgroundColor:e.colors["primary-soft"]},theirs:{backgroundColor:e.colors["bg-subtle"]},quote:{borderLeftWidth:3,borderLeftColor:e.colors.primary,paddingLeft:e.space.sm,paddingVertical:e.space.xs},meta:{flexDirection:"row",alignItems:"center",gap:e.space.xs,paddingHorizontal:e.space.xs},metaMine:{justifyContent:"flex-end"},endText:{textAlign:"right"}});var _default=exports.default=MessageBubble;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.MessageBubble=exports.DEFAULT_MESSAGE_BUBBLE_LABELS=void 0;var _markdownCore=require("@webority/markdown-core"),_mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Button/index.js"),_index4=require("../Markdown/index.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_MESSAGE_BUBBLE_LABELS=exports.DEFAULT_MESSAGE_BUBBLE_LABELS=Object.freeze({you:"You",sending:"Sending",sent:"Sent",delivered:"Delivered",read:"Read",failed:"Not sent",retry:"Try again",copy:"Copy",replyTo:e=>e?`Reply to ${e}`:"Reply"}),MAX_WIDTH="85%",STATUS_ICON=14,statusIcon=e=>{switch(e){case"sending":return"clock";case"sent":return"check";case"failed":return"alert-circle";default:return"check-check"}},statusColour=(e,s)=>{switch(s){case"read":return e.colors["info-text"];case"failed":return e.colors["danger-text"];default:return e.colors["text-subtle"]}},MessageBubble=({side:e,text:s,children:t,markdown:r,groupPosition:n="single",author:i,time:a,status:o,replyTo:l,streaming:u=!1,error:c,onRetry:d,actions:x,onCopy:b,onLongPress:m,footer:_,labels:p,haptic:y,style:h,testID:g})=>{(0,_assertValidValue.assertValidValue)("MessageBubble","side",e,["mine","theirs"]),(0,_assertValidValue.assertValidValue)("MessageBubble","groupPosition",n,["single","first","middle","last"]),(0,_assertValidValue.assertValidValue)("MessageBubble","status",o,["sending","sent","delivered","read","failed"]);const f=(0,_index.useTheme)(),j=(0,_react.useMemo)(()=>buildStyles(f),[f]),B=p?{...DEFAULT_MESSAGE_BUBBLE_LABELS,...p}:DEFAULT_MESSAGE_BUBBLE_LABELS,L="mine"===e,T=!c&&(r??"theirs"===e),R="single"===n||"first"===n,v="single"===n||"last"===n,E=null==a?"":(0,_mobileCore.formatTime)(a),M=("failed"===o||Boolean(c))&&Boolean(d),S=L?B.you:i??"",A=(0,_react.useMemo)(()=>{const e=[];return b&&!x?.some(e=>"copy"===e.name)&&e.push({name:"copy",label:B.copy,onPress:()=>b(s)}),x&&e.push(...x),l?.onPress&&e.push({name:"openReply",label:B.replyTo(l.author),onPress:l.onPress}),M&&d&&e.push({name:"retry",label:B.retry,onPress:d}),e},[x,b,s,l,M,d,B]),P=(x?.length??0)>0||Boolean(b),V=(0,_react.useMemo)(()=>P?{items:A.map(({name:e,label:s,onPress:t})=>({key:e,label:s,onPress:t}))}:void 0,[P,A]),C=(0,_useContextMenu.useContextMenu)(V,{haptic:y,testID:g}),k=C.hostProps.onLongPress,w=!t||(x?.length??0)>0,I=o&&L?B[o]:"",q=(0,_react.useMemo)(()=>T&&null==t?(0,_markdownCore.markdownToPlainText)(s):s,[T,t,s]),D=[S,E,q,l?`${B.replyTo(l.author)}: ${l.text}`:"",I].filter(Boolean).join(", "),$=(0,_react.useRef)(u);(0,_react.useEffect)(()=>{$.current&&!u&&!c&&s&&(0,_announce.announce)(S?`${S}, ${q}`:q),$.current=u},[u,c,s,q,S]);const U=(0,_react.useRef)(c);(0,_react.useEffect)(()=>{c&&c!==U.current&&(0,_announce.announce)(c,{polite:!1}),U.current=c},[c]);const N=(0,_react.useCallback)(e=>{k?.(e),m?.()},[k,m]),F=(0,_react.useCallback)(e=>{A.find(s=>s.name===e.nativeEvent.actionName)?.onPress()},[A]),z=f.radius.xl,H=f.radius.sm,O=L?{borderTopRightRadius:R?z:H,borderBottomRightRadius:v?z:H}:{borderTopLeftRadius:R?z:H,borderBottomLeftRadius:v?z:H},G=t??(T?(0,_jsxRuntime.jsx)(_index4.Markdown,{children:s}):(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",children:s})),W=l?(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:l.onPress,disabled:!l.onPress,accessibilityRole:l.onPress?"button":void 0,accessibilityLabel:`${B.replyTo(l.author)}: ${l.text}`,style:j.quote,children:[l.author?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",weight:"semibold",color:"link",numberOfLines:1,children:l.author}):null,(0,_jsxRuntime.jsx)(_index5.Text,{variant:"bodySmall",color:"secondary",numberOfLines:2,children:l.text})]}):null,X=[j.bubble,L?j.mine:j.theirs,O],Y=w?{accessible:!0,accessibilityLabel:D,accessibilityState:{busy:u},"aria-busy":u,accessibilityActions:A.map(({name:e,label:s})=>({name:e,label:s})),onAccessibilityAction:F}:{accessible:!1},J=P?(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:C.hostRef,...C.hostProps,onLongPress:N,delayLongPress:350,style:X,testID:g?`${g}-bubble`:void 0,...Y,children:[W,G]}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:X,testID:g?`${g}-bubble`:void 0,...Y,children:[W,G]}),K=v&&(""!==E||L&&o);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[j.root,L?j.rootMine:j.rootTheirs,{marginTop:R?f.space.sm:f.space.xxs},h],accessibilityState:{busy:u},"aria-busy":u,testID:g,children:[!L&&R&&i?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",color:"secondary",style:j.author,numberOfLines:1,importantForAccessibility:w?"no-hide-descendants":"auto",accessibilityElementsHidden:w,children:i}):null,J,C.renderSurface(),K?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[j.meta,L?j.metaMine:null],importantForAccessibility:w?"no-hide-descendants":"auto",accessibilityElementsHidden:w,children:[E?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",color:"tertiary",children:E}):null,L&&o?(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:statusIcon(o),size:14,color:statusColour(f,o),accessibilityLabel:B[o],testID:g?`${g}-status-${o}`:void 0}):null]}):null,c?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"bodySmall",color:"danger",style:L?j.endText:null,children:c}):null,M?(0,_jsxRuntime.jsx)(_index3.Button,{label:B.retry,variant:"link",size:"sm",leftIcon:"refresh-cw",onPress:d,testID:g?`${g}-retry`:void 0}):null,_]})};exports.MessageBubble=MessageBubble;const buildStyles=e=>_reactNative.StyleSheet.create({root:{maxWidth:"85%",gap:e.space.xs},rootMine:{alignSelf:"flex-end",alignItems:"flex-end"},rootTheirs:{alignSelf:"flex-start",alignItems:"flex-start"},author:{paddingHorizontal:e.space.md},bubble:{borderRadius:e.radius.xl,..._corners.smoothCorners,paddingHorizontal:e.space.md,paddingVertical:e.space.sm,gap:e.space.xs},mine:{backgroundColor:e.colors["primary-soft"]},theirs:{backgroundColor:e.colors["bg-subtle"]},quote:{borderLeftWidth:3,borderLeftColor:e.colors.primary,paddingLeft:e.space.sm,paddingVertical:e.space.xs},meta:{flexDirection:"row",alignItems:"center",gap:e.space.xs,paddingHorizontal:e.space.xs},metaMine:{justifyContent:"flex-end"},endText:{textAlign:"right"}});var _default=exports.default=MessageBubble;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Modal=exports.MODAL_DISMISS_GRACE_MS=exports.DEFAULT_MODAL_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_placement=require("../../utils/placement.js"),_squircle=require("../../utils/squircle.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_MODAL_LABELS=exports.DEFAULT_MODAL_LABELS=Object.freeze({close:"Close modal"}),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,_warnInvalidValue.warnInvalidValue)("Modal","presentation",e.presentation,MODAL_PRESENTATIONS);const{open:r,onClose:a,presentation:i="centered",backdropOpacity:o,backdropPressClose:n=!0,animationDuration:s,animateMount:c=!0,accessibilityLabel:l,hardwareBackPress:u=!0,children:d,contentStyle:m,backdropStyle:_,restoreFocusRef:p,onDismissed:f,haptic:h,labels:g,anchor:b,placement:v="auto",align:S="center",testID:A,bare:x=!1,onInsetsChange:M}=e,y=(0,_index.useTheme)(),N=(0,_react.useMemo)(()=>({...DEFAULT_MODAL_LABELS,...g}),[g]),R=(0,_usePresenceMotion.usePresenceMotion)(),[C,w]=(0,_ModalSafeArea.useModalInsets)();(0,_react.useEffect)(()=>{M?.(C)},[C,M]);const{width:j,height:D}=(0,_reactNative.useWindowDimensions)(),[E,L]=(0,_react.useState)({width:0,height:0}),T=s??R.duration("default"),V=_reactNative.Dimensions.get("window").height,q=(0,_react.useRef)(!c&&r),I=q.current,O=(0,_react.useRef)((0,_index.createAnimatedValue)(I?1:.9)).current,P=(0,_react.useRef)((0,_index.createAnimatedValue)(I?1:0)).current,F=(0,_react.useRef)((0,_index.createAnimatedValue)(I?0:V)).current,k=(0,_react.useRef)((0,_index.createAnimatedValue)(I?1:0)).current,z=(0,_react.useRef)(null),H=(0,_react.useRef)(!1),[W,U]=(0,_react.useState)(r),B=(0,_react.useMemo)(()=>buildStyles(y),[y]),G=(0,_react.useMemo)(()=>{if("anchored"!==i||void 0===b)return null;const e={width:j,height:D,insets:{top:C.top,bottom:C.bottom,left:0,right:0}},t=(0,_placement.computePlacement)(b,E,e,v,{align:S});return{...t,maxHeight:(0,_placement.placementMaxHeight)(t.placement,(0,_placement.placementRoom)(b,e))}},[i,b,E,v,S,j,D,C.top,C.bottom]),K=(0,_react.useMemo)(()=>{const e=y.colors.scrim;return"number"!=typeof o?"anchored"===i?(0,_color.transparentOf)(e):e:(0,_color.withAlpha)(e,o)??e},[y.colors.scrim,o,i]),Y=(0,_react.useMemo)(()=>k.interpolate({inputRange:[0,1],outputRange:[(0,_color.transparentOf)(K),K]}),[k,K]);(0,_react.useEffect)(()=>{r&&(_reactNative.Keyboard.dismiss(),U(!0))},[r]),(0,_react.useEffect)(()=>{const e=[];if(r&&W&&q.current)q.current=!1;else if(r&&W){const t=_reactNative.Animated.timing(k,{toValue:1,duration:R.duration("default"),useNativeDriver:!1});if(t.start(),e.push(t),R.reduced||"anchored"===i){P.setValue(0),F.setValue(0),O.setValue(1);const t=_reactNative.Animated.timing(P,{toValue:1,duration:T,useNativeDriver:!0});t.start(),e.push(t)}else if("bottom"===i){P.setValue(1);const t=_reactNative.Animated.spring(F,{toValue:0,damping:y.motion.spring.gentle.damping,stiffness:y.motion.spring.gentle.stiffness,mass:y.motion.spring.gentle.mass,useNativeDriver:!0});t.start(),e.push(t)}else{const t=_reactNative.Animated.parallel([_reactNative.Animated.spring(O,{toValue:1,damping:y.motion.spring.gentle.damping,stiffness:y.motion.spring.gentle.stiffness,mass:y.motion.spring.gentle.mass,useNativeDriver:!0}),_reactNative.Animated.timing(P,{toValue:1,duration:T,useNativeDriver:!0})]);t.start(),e.push(t)}}else if(W){const t=R.duration("fast"),r=_reactNative.Easing.bezier(...y.motion.ease.accelerate),a=_reactNative.Animated.timing(P,{toValue:0,duration:t,easing:r,useNativeDriver:!0}),o=R.reduced||"anchored"===i?a:"bottom"===i?_reactNative.Animated.timing(F,{toValue:V,duration:t,easing:r,useNativeDriver:!0}):_reactNative.Animated.parallel([_reactNative.Animated.timing(O,{toValue:.9,duration:t,easing:r,useNativeDriver:!0}),a]),n=_reactNative.Animated.parallel([o,_reactNative.Animated.timing(k,{toValue:0,duration:R.duration("default"),useNativeDriver:!1})]);n.start(({finished:e})=>{e&&(F.setValue(V),U(!1))}),e.push(n)}return()=>e.forEach(e=>{e.stop()})},[r,W,i,T,O,P,k,F,V,y.motion.spring.gentle.damping,y.motion.spring.gentle.stiffness,y.motion.spring.gentle.mass,R,y.motion.ease.accelerate]),(0,_react.useEffect)(()=>{if("web"===_reactNative.Platform.OS)return;let e,t;return r?(e=setTimeout(()=>{z.current&&_reactNative.AccessibilityInfo.sendAccessibilityEvent(z.current,"focus")},150),H.current=!0):H.current&&(H.current=!1,p?.current&&(t=setTimeout(()=>{const e=p.current;e&&_reactNative.AccessibilityInfo.sendAccessibilityEvent(e,"focus")},T))),()=>{e&&clearTimeout(e),t&&clearTimeout(t)}},[r,T,p]);const J=(0,_react.useRef)(f);J.current=f;const Q=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(r)return void(Q.current=!0);if(!Q.current)return;Q.current=!1;const e=setTimeout(()=>J.current?.(),MODAL_DISMISS_GRACE_MS);return()=>clearTimeout(e)},[r]);const X=(0,_react.useCallback)(()=>{if(!n)return;const e=(0,_hapticUtils.resolveHaptic)(h,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),a()},[n,a,h]),Z=(0,_react.useCallback)(()=>{u&&a()},[u,a]),$=(0,_SquircleFill.useSquircle)(!x&&"bottom"!==i&&"fullScreen"!==i&&"anchored"!==i,y.radius.xl),ee=(0,_react.useCallback)(e=>{$.onLayout(e);const{width:t,height:r}=e.nativeEvent.layout;L(e=>e.width===t&&e.height===r?e:{width:t,height:r})},[$.onLayout]),te=(0,_react.useMemo)(()=>x?"bottom"===i?B.bottomContent:"fullScreen"===i?B.fullScreenContent:B.bareCentredContent:"anchored"===i?[B.anchoredContent,{left:G?.x,top:G?.y,maxHeight:G?.maxHeight,backgroundColor:y.colors.surface,borderRadius:y.radius.lg,..._corners.smoothCorners},y.shadow.modal]:"fullScreen"===i?[B.fullScreenContent,{backgroundColor:y.colors.surface}]:"bottom"===i?[B.bottomContent,{backgroundColor:y.colors.surface,borderTopLeftRadius:y.radius.xl,borderTopRightRadius:y.radius.xl,..._corners.smoothCorners,paddingTop:y.space.lg,paddingHorizontal:y.space.lg,paddingBottom:y.space.lg+C.bottom},y.shadow.modal]:[B.centeredContent,{backgroundColor:y.colors.surface,borderRadius:$.active&&$.size?(0,_squircle.squircleHostRadius)($.size.width,$.size.height,y.radius.xl):y.radius.xl,..._corners.smoothCorners,padding:y.space.xl},y.shadow.modal],[i,y,B,C.bottom,$.active,$.size,G,x]),re=(0,_react.useMemo)(()=>"anchored"===i?B.anchoredWrapper:"bottom"===i?B.bottomWrapper:"fullScreen"===i?B.fullScreenWrapper:B.centeredWrapper,[i,B]),ae=(0,_react.useMemo)(()=>"bottom"===i?{opacity:P,transform:[{translateY:F}]}:"fullScreen"===i||"anchored"===i?{opacity:P}:{opacity:P,transform:[{scale:O}]},[i,O,P,F]);if("anchored"===i&&void 0===b)throw new Error('[@webority/mobile-ui] Modal: presentation "anchored" needs an anchor.');if(x&&"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:W,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:Z,testID:A,children:(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{z.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:w,children:[(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{collapsable:!1,style:[_reactNative.StyleSheet.absoluteFill,re,{backgroundColor:Y},_],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:X,accessibilityRole:n?"button":void 0,accessibilityLabel:n?N.close:void 0,accessible:!!n&&void 0,importantForAccessibility:n?void 0:"no",disabled:!n}),(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[te,ae,E.height>0||"anchored"!==i?null:B.unmeasured,m],onLayout:ee,pointerEvents:x&&"fullScreen"===i?"box-none":"auto",needsOffscreenAlphaCompositing:!0,children:[$.active&&$.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:$.size.width,height:$.size.height,radius:y.radius.xl,fill:y.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.default=exports.Modal=exports.MODAL_DISMISS_GRACE_MS=exports.DEFAULT_MODAL_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.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 DEFAULT_MODAL_LABELS=exports.DEFAULT_MODAL_LABELS=Object.freeze({close:"Close modal"}),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:o,backdropPressClose:s=!0,animationDuration:n,animateMount:c=!0,accessibilityLabel:l,hardwareBackPress:u=!0,children:d,contentStyle:m,backdropStyle:_,restoreFocusRef:p,onDismissed:f,haptic:h,labels:g,anchor:b,placement:v="auto",align:S="center",testID:A,bare:x=!1,onInsetsChange:M}=e,y=(0,_index.useTheme)(),N=(0,_react.useMemo)(()=>({...DEFAULT_MODAL_LABELS,...g}),[g]),R=(0,_usePresenceMotion.usePresenceMotion)(),[C,j]=(0,_ModalSafeArea.useModalInsets)();(0,_react.useEffect)(()=>{M?.(C)},[C,M]);const{width:D,height:w}=(0,_reactNative.useWindowDimensions)(),[E,L]=(0,_react.useState)({width:0,height:0}),V=n??R.duration("default"),T=_reactNative.Dimensions.get("window").height,q=(0,_react.useRef)(!c&&r),I=q.current,O=(0,_react.useRef)((0,_index.createAnimatedValue)(I?1:.9)).current,P=(0,_react.useRef)((0,_index.createAnimatedValue)(I?1:0)).current,F=(0,_react.useRef)((0,_index.createAnimatedValue)(I?0:T)).current,k=(0,_react.useRef)((0,_index.createAnimatedValue)(I?1:0)).current,z=(0,_react.useRef)(null),H=(0,_react.useRef)(!1),[W,U]=(0,_react.useState)(r),B=(0,_react.useMemo)(()=>buildStyles(y),[y]),G=(0,_react.useMemo)(()=>{if("anchored"!==i||void 0===b)return null;const e={width:D,height:w,insets:{top:C.top,bottom:C.bottom,left:0,right:0}},t=(0,_placement.computePlacement)(b,E,e,v,{align:S});return{...t,maxHeight:(0,_placement.placementMaxHeight)(t.placement,(0,_placement.placementRoom)(b,e))}},[i,b,E,v,S,D,w,C.top,C.bottom]),K=(0,_react.useMemo)(()=>{const e=y.colors.scrim;return"number"!=typeof o?"anchored"===i?(0,_color.transparentOf)(e):e:(0,_color.withAlpha)(e,o)??e},[y.colors.scrim,o,i]),Y=(0,_react.useMemo)(()=>k.interpolate({inputRange:[0,1],outputRange:[(0,_color.transparentOf)(K),K]}),[k,K]);(0,_react.useEffect)(()=>{r&&(_reactNative.Keyboard.dismiss(),U(!0))},[r]),(0,_react.useEffect)(()=>{const e=[];if(r&&W&&q.current)q.current=!1;else if(r&&W){const t=_reactNative.Animated.timing(k,{toValue:1,duration:R.duration("default"),useNativeDriver:!1});if(t.start(),e.push(t),R.reduced||"anchored"===i){P.setValue(0),F.setValue(0),O.setValue(1);const t=_reactNative.Animated.timing(P,{toValue:1,duration:V,useNativeDriver:!0});t.start(),e.push(t)}else if("bottom"===i){P.setValue(1);const t=_reactNative.Animated.spring(F,{toValue:0,damping:y.motion.spring.gentle.damping,stiffness:y.motion.spring.gentle.stiffness,mass:y.motion.spring.gentle.mass,useNativeDriver:!0});t.start(),e.push(t)}else{const t=_reactNative.Animated.parallel([_reactNative.Animated.spring(O,{toValue:1,damping:y.motion.spring.gentle.damping,stiffness:y.motion.spring.gentle.stiffness,mass:y.motion.spring.gentle.mass,useNativeDriver:!0}),_reactNative.Animated.timing(P,{toValue:1,duration:V,useNativeDriver:!0})]);t.start(),e.push(t)}}else if(W){const t=R.duration("fast"),r=_reactNative.Easing.bezier(...y.motion.ease.accelerate),a=_reactNative.Animated.timing(P,{toValue:0,duration:t,easing:r,useNativeDriver:!0}),o=R.reduced||"anchored"===i?a:"bottom"===i?_reactNative.Animated.timing(F,{toValue:T,duration:t,easing:r,useNativeDriver:!0}):_reactNative.Animated.parallel([_reactNative.Animated.timing(O,{toValue:.9,duration:t,easing:r,useNativeDriver:!0}),a]),s=_reactNative.Animated.parallel([o,_reactNative.Animated.timing(k,{toValue:0,duration:R.duration("default"),useNativeDriver:!1})]);s.start(({finished:e})=>{e&&(F.setValue(T),U(!1))}),e.push(s)}return()=>e.forEach(e=>{e.stop()})},[r,W,i,V,O,P,k,F,T,y.motion.spring.gentle.damping,y.motion.spring.gentle.stiffness,y.motion.spring.gentle.mass,R,y.motion.ease.accelerate]),(0,_react.useEffect)(()=>{if("web"===_reactNative.Platform.OS)return;let e,t;return r?(e=setTimeout(()=>{z.current&&_reactNative.AccessibilityInfo.sendAccessibilityEvent(z.current,"focus")},150),H.current=!0):H.current&&(H.current=!1,p?.current&&(t=setTimeout(()=>{const e=p.current;e&&_reactNative.AccessibilityInfo.sendAccessibilityEvent(e,"focus")},V))),()=>{e&&clearTimeout(e),t&&clearTimeout(t)}},[r,V,p]);const J=(0,_react.useRef)(f);J.current=f;const Q=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(r)return void(Q.current=!0);if(!Q.current)return;Q.current=!1;const e=setTimeout(()=>J.current?.(),MODAL_DISMISS_GRACE_MS);return()=>clearTimeout(e)},[r]);const X=(0,_react.useCallback)(()=>{if(!s)return;const e=(0,_hapticUtils.resolveHaptic)(h,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),a()},[s,a,h]),Z=(0,_react.useCallback)(()=>{u&&a()},[u,a]),$=(0,_SquircleFill.useSquircle)(!x&&"bottom"!==i&&"fullScreen"!==i&&"anchored"!==i,y.radius.xl),ee=(0,_react.useCallback)(e=>{$.onLayout(e);const{width:t,height:r}=e.nativeEvent.layout;L(e=>e.width===t&&e.height===r?e:{width:t,height:r})},[$.onLayout]),te=(0,_react.useMemo)(()=>x?"bottom"===i?B.bottomContent:"fullScreen"===i?B.fullScreenContent:B.bareCentredContent:"anchored"===i?[B.anchoredContent,{left:G?.x,top:G?.y,maxHeight:G?.maxHeight,backgroundColor:y.colors.surface,borderRadius:y.radius.lg,..._corners.smoothCorners},y.shadow.modal]:"fullScreen"===i?[B.fullScreenContent,{backgroundColor:y.colors.surface}]:"bottom"===i?[B.bottomContent,{backgroundColor:y.colors.surface,borderTopLeftRadius:y.radius.xl,borderTopRightRadius:y.radius.xl,..._corners.smoothCorners,paddingTop:y.space.lg,paddingHorizontal:y.space.lg,paddingBottom:y.space.lg+C.bottom},y.shadow.modal]:[B.centeredContent,{backgroundColor:y.colors.surface,borderRadius:$.active&&$.size?(0,_squircle.squircleHostRadius)($.size.width,$.size.height,y.radius.xl):y.radius.xl,..._corners.smoothCorners,padding:y.space.xl},y.shadow.modal],[i,y,B,C.bottom,$.active,$.size,G,x]),re=(0,_react.useMemo)(()=>"anchored"===i?B.anchoredWrapper:"bottom"===i?B.bottomWrapper:"fullScreen"===i?B.fullScreenWrapper:B.centeredWrapper,[i,B]),ae=(0,_react.useMemo)(()=>"bottom"===i?{opacity:P,transform:[{translateY:F}]}:"fullScreen"===i||"anchored"===i?{opacity:P}:{opacity:P,transform:[{scale:O}]},[i,O,P,F]);if("anchored"===i&&void 0===b)throw new Error('[@webority/mobile-ui] Modal: presentation "anchored" needs an anchor.');if(x&&"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:W,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:Z,testID:A,children:(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{z.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,re,{backgroundColor:Y},_],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:X,accessibilityRole:s?"button":void 0,accessibilityLabel:s?N.close:void 0,accessible:!!s&&void 0,importantForAccessibility:s?void 0:"no",disabled:!s}),(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[te,ae,E.height>0||"anchored"!==i?null:B.unmeasured,m],onLayout:ee,pointerEvents:x&&"fullScreen"===i?"box-none":"auto",needsOffscreenAlphaCompositing:!0,children:[$.active&&$.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:$.size.width,height:$.size.height,radius:y.radius.xl,fill:y.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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.NumberInput=exports.DEFAULT_NUMBER_INPUT_LABELS=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=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_NUMBER_INPUT_LABELS=exports.DEFAULT_NUMBER_INPUT_LABELS=Object.freeze({decrease:"Decrease",increase:"Increase",input:"Number input"}),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:p="md",variant:x="inline",unit:f,haptic:N,labels:h,accessibilityLabel:y,style:I,containerStyle:T,inputStyle:j,buttonStyle:S,unitStyle:g,labelStyle:v,textInputProps:R,testID:F}=e;(0,_warnInvalidValue.warnInvalidValue)("NumberInput","size",e.size,NUMBER_INPUT_SIZES),(0,_warnInvalidValue.warnInvalidValue)("NumberInput","variant",e.variant,NUMBER_INPUT_VARIANTS);const E=(0,_react.useMemo)(()=>({...DEFAULT_NUMBER_INPUT_LABELS,...h}),[h]),[L,P]=(0,_index.useControllableState)({value:i,defaultValue:r??e.min??0,onChange:a}),w=(0,_index2.useTheme)(),B=(0,_index2.resolveFieldSize)(w,p),V=(0,_FieldBase.resolveFieldTextStyle)(w,{disabled:m}),A=(0,_react.useMemo)(()=>buildStyles(w),[w]),U=(0,_react.useRef)(null),[C,z]=(0,_react.useState)(formatValue(L,c,u)),[M,k]=(0,_react.useState)(!1),[D,O]=(0,_react.useState)(!1),q=(0,_react.useCallback)(()=>{m||U.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)(()=>{M||z(formatValue(L,c,u))},[L,c,u,M]);const Y=L<=n,Z=L>=s,$=!m,J=(0,_react.useCallback)(e=>{const t=roundToPrecision(e,c?u:0),i=clamp(t,n,s);i!==L&&P(i)},[c,s,n,P,u,L]),K=(0,_react.useCallback)(()=>{if(!$||Y)return;const e=(0,_index3.resolveHaptic)(N,"selection");e&&(0,_index3.triggerHaptic)(e),J(L-l)},[Y,$,N,J,l,L]),Q=(0,_react.useCallback)(()=>{if(!$||Z)return;const e=(0,_index3.resolveHaptic)(N,"selection");e&&(0,_index3.triggerHaptic)(e),J(L+l)},[Z,$,N,J,l,L]);_react.default.useImperativeHandle(t,()=>({focus:()=>U.current?.focus(),blur:()=>U.current?.blur(),clear:()=>{z(""),Number.isFinite(n)&&n>0?P(n):P(0<n?n:0>s?s:0)}}),[s,n,P]);const X=(0,_react.useCallback)(e=>{$&&(G(),W.current=setTimeout(()=>{H.current=setInterval(()=>{"inc"===e?Q():K()},80)},500))},[G,K,Q,$]),ee=(0,_react.useCallback)(e=>{const t=sanitizeTyped(e,c);z(t);const i=Number(t);""!==t&&"-"!==t&&"."!==t&&Number.isFinite(i)&&i>=n&&i<=s&&i!==L&&P(roundToPrecision(i,c?u:0))},[c,s,n,P,u,L]),te=(0,_react.useCallback)(()=>{k(!1),O(!1);const e=Number(C);if(""===C||!Number.isFinite(e))return void z(formatValue(L,c,u));const t=roundToPrecision(e,c?u:0),i=clamp(t,n,s);i!==L&&P(i),z(formatValue(i,c,u))},[c,C,s,n,P,u,L]),ie=(0,_react.useCallback)(()=>{k(!0),O(!0)},[]),re=Y||m?w.colors["text-disabled"]:w.colors["text-body"],ae=Z||m?w.colors["text-disabled"]:w.colors["text-body"],ne=B.icon+8,renderStepper=(e,t,i,r,a,n)=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:t,onLongPress:()=>X(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,S],testID:`${F??"numberinput"}-${"inc"===e?"plus":"minus"}`,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",style:{fontSize:B.icon,color:a,fontWeight:w.weight.semibold,lineHeight:B.icon+2},children:n})}),se=y??(0,_FieldBase.fieldTextAsString)(o)??E.input,le=!0===b||(0,_FieldBase.hasFieldText)(b),ce=(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{size:p,disabled:m,error:le,filled:!0,focused:D,onPress:q,pressFeedback:!1,leading:renderStepper("dec",K,Y||m,E.decrease,re,"−"),trailing:renderStepper("inc",Q,Z||m,E.increase,ae,"+"),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:A.inputRow,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:U,value:C,onChangeText:ee,onFocus:ie,onBlur:te,editable:!m,keyboardType:c?"decimal-pad":"number-pad",selectTextOnFocus:!0,accessibilityRole:"adjustable",accessibilityLabel:se,accessibilityValue:{now:Number.isFinite(L)?L:0},accessibilityState:{disabled:m},"aria-disabled":m,accessibilityActions:[{name:"increment",label:E.increase},{name:"decrement",label:E.decrease}],onAccessibilityAction:e=>{"increment"===e.nativeEvent.actionName&&Q(),"decrement"===e.nativeEvent.actionName&&K()},style:[A.input,{fontSize:B.text,color:V.color,...V.weightStyle},j],...R}),f?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",style:[A.unit,{fontSize:B.text,color:V.placeholderColor},g],children:f}):null]})}),ue=(0,_FieldBase.hasFieldText)(o)?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:p,help:d,style:v,children:o}):null,oe=(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:p,error:le,text:le?b:_});return"horizontal"===x?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[A.horizontalContainer,T,I],testID:F,accessibilityState:{disabled:m},"aria-disabled":m,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:A.horizontalLabelWrap,children:ue}),(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[ce,oe]})]}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[T,I],testID:F,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.default=exports.NumberInput=exports.DEFAULT_NUMBER_INPUT_LABELS=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=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,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((i=a&&Object.getOwnPropertyDescriptor(e,r))&&(i.get||i.set)?a(s,r,i):s[r]=e[r]);return s}const NUMBER_INPUT_SIZES=["sm","md","lg"],NUMBER_INPUT_VARIANTS=["inline","horizontal"],DEFAULT_NUMBER_INPUT_LABELS=exports.DEFAULT_NUMBER_INPUT_LABELS=Object.freeze({decrease:"Decrease",increase:"Increase",input:"Number input"}),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:s=Number.NEGATIVE_INFINITY,max:n=Number.POSITIVE_INFINITY,step:l=1,allowDecimal:c=!1,precision:u=0,label:o,help:d,helperText:_,error:b,disabled:m=!1,size:p="md",variant:x="inline",unit:f,haptic:N,labels:h,accessibilityLabel:y,style:I,containerStyle:T,inputStyle:j,buttonStyle:S,unitStyle:g,labelStyle:R,textInputProps:F,testID:v}=e;(0,_assertValidValue.assertValidValue)("NumberInput","size",e.size,NUMBER_INPUT_SIZES),(0,_assertValidValue.assertValidValue)("NumberInput","variant",e.variant,NUMBER_INPUT_VARIANTS);const E=(0,_react.useMemo)(()=>({...DEFAULT_NUMBER_INPUT_LABELS,...h}),[h]),[V,L]=(0,_index.useControllableState)({value:i,defaultValue:r??e.min??0,onChange:a}),P=(0,_index2.useTheme)(),B=(0,_index2.resolveFieldSize)(P,p),A=(0,_FieldBase.resolveFieldTextStyle)(P,{disabled:m}),U=(0,_react.useMemo)(()=>buildStyles(P),[P]),C=(0,_react.useRef)(null),[w,z]=(0,_react.useState)(formatValue(V,c,u)),[M,k]=(0,_react.useState)(!1),[D,O]=(0,_react.useState)(!1),q=(0,_react.useCallback)(()=>{m||C.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)(()=>{M||z(formatValue(V,c,u))},[V,c,u,M]);const Y=V<=s,Z=V>=n,$=!m,J=(0,_react.useCallback)(e=>{const t=roundToPrecision(e,c?u:0),i=clamp(t,s,n);i!==V&&L(i)},[c,n,s,L,u,V]),K=(0,_react.useCallback)(()=>{if(!$||Y)return;const e=(0,_index3.resolveHaptic)(N,"selection");e&&(0,_index3.triggerHaptic)(e),J(V-l)},[Y,$,N,J,l,V]),Q=(0,_react.useCallback)(()=>{if(!$||Z)return;const e=(0,_index3.resolveHaptic)(N,"selection");e&&(0,_index3.triggerHaptic)(e),J(V+l)},[Z,$,N,J,l,V]);_react.default.useImperativeHandle(t,()=>({focus:()=>C.current?.focus(),blur:()=>C.current?.blur(),clear:()=>{z(""),Number.isFinite(s)&&s>0?L(s):L(0<s?s:0>n?n:0)}}),[n,s,L]);const X=(0,_react.useCallback)(e=>{$&&(G(),W.current=setTimeout(()=>{H.current=setInterval(()=>{"inc"===e?Q():K()},80)},500))},[G,K,Q,$]),ee=(0,_react.useCallback)(e=>{const t=sanitizeTyped(e,c);z(t);const i=Number(t);""!==t&&"-"!==t&&"."!==t&&Number.isFinite(i)&&i>=s&&i<=n&&i!==V&&L(roundToPrecision(i,c?u:0))},[c,n,s,L,u,V]),te=(0,_react.useCallback)(()=>{k(!1),O(!1);const e=Number(w);if(""===w||!Number.isFinite(e))return void z(formatValue(V,c,u));const t=roundToPrecision(e,c?u:0),i=clamp(t,s,n);i!==V&&L(i),z(formatValue(i,c,u))},[c,w,n,s,L,u,V]),ie=(0,_react.useCallback)(()=>{k(!0),O(!0)},[]),re=Y||m?P.colors["text-disabled"]:P.colors["text-body"],ae=Z||m?P.colors["text-disabled"]:P.colors["text-body"],se=B.icon+8,renderStepper=(e,t,i,r,a,s)=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:t,onLongPress:()=>X(e),onPressOut:G,delayLongPress:500,disabled:i,accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{disabled:i},"aria-disabled":i,style:({pressed:e})=>[{width:se,height:se,alignItems:"center",justifyContent:"center",borderRadius:P.radius.pill,..._corners.smoothCorners},e&&!i?{backgroundColor:P.colors["surface-pressed"]}:null,S],testID:`${v??"numberinput"}-${"inc"===e?"plus":"minus"}`,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",style:{fontSize:B.icon,color:a,fontWeight:P.weight.semibold,lineHeight:B.icon+2},children:s})}),ne=y??(0,_FieldBase.fieldTextAsString)(o)??E.input,le=!0===b||(0,_FieldBase.hasFieldText)(b),ce=(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{size:p,disabled:m,error:le,filled:!0,focused:D,onPress:q,pressFeedback:!1,leading:renderStepper("dec",K,Y||m,E.decrease,re,"−"),trailing:renderStepper("inc",Q,Z||m,E.increase,ae,"+"),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:U.inputRow,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:C,value:w,onChangeText:ee,onFocus:ie,onBlur:te,editable:!m,keyboardType:c?"decimal-pad":"number-pad",selectTextOnFocus:!0,accessibilityRole:"adjustable",accessibilityLabel:ne,accessibilityValue:{now:Number.isFinite(V)?V:0},accessibilityState:{disabled:m},"aria-disabled":m,accessibilityActions:[{name:"increment",label:E.increase},{name:"decrement",label:E.decrease}],onAccessibilityAction:e=>{"increment"===e.nativeEvent.actionName&&Q(),"decrement"===e.nativeEvent.actionName&&K()},style:[U.input,{fontSize:B.text,color:A.color,...A.weightStyle},j],...F}),f?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",style:[U.unit,{fontSize:B.text,color:A.placeholderColor},g],children:f}):null]})}),ue=(0,_FieldBase.hasFieldText)(o)?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:p,help:d,style:R,children:o}):null,oe=(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:p,error:le,text:le?b:_});return"horizontal"===x?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[U.horizontalContainer,T,I],testID:v,accessibilityState:{disabled:m},"aria-disabled":m,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:U.horizontalLabelWrap,children:ue}),(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[ce,oe]})]}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[T,I],testID:v,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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OTPInput=exports.DEFAULT_OTP_INPUT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_OTP_INPUT_LABELS=exports.DEFAULT_OTP_INPUT_LABELS=Object.freeze({field:e=>`Enter ${e}-digit code`}),sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=exports.OTPInput=(0,_react.forwardRef)((e,t)=>{const{value:a,defaultValue:i,onChange:n,onComplete:r,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:x,onFocus:g,accessibilityLabel:f,style:h,cellStyle:v,textStyle:b,testID:y}=e;(0,_warnInvalidValue.warnInvalidValue)("OTPInput","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("OTPInput","keyboardType",e.keyboardType,["number-pad","default"]);const T=x?{...DEFAULT_OTP_INPUT_LABELS,...x}:DEFAULT_OTP_INPUT_LABELS,[j,N]=(0,_index.useControllableState)({value:a,defaultValue:i??"",onChange:n}),I=(0,_index2.useTheme)(),E=(0,_react.useMemo)(()=>buildStyles(I),[I]),A=(0,_index2.resolveOtpInputSize)(I,_),w=I.components["otp-input"][_].radius,V=(0,_react.useRef)([]),[F,P]=(0,_react.useState)(-1),[R,C]=(0,_react.useState)(0),O=(0,_react.useRef)(null),k=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,S=(0,_react.useRef)(new Map),L=(0,_react.useMemo)(()=>{const e=S.current,t=[];for(let a=0;a<s;a+=1){let i=e.get(a);i||(i=new _reactNative.Animated.Value(0),e.set(a,i)),t.push(i)}for(const t of Array.from(e.keys()))t>=s&&e.delete(t);return t},[s]),B=(0,_react.useRef)(-1),D=I.settings.components["otp-input"]?.shakeOnError??!1,z=(0,_index.useReducedMotion)(),M=!0===d||(0,_FieldBase.hasFieldText)(d);(0,_react.useEffect)(()=>{let e;return null===O.current||!M||O.current||(m&&(0,_index3.triggerHaptic)("notificationError"),D&&!z&&((0,_index2.setNativeValue)(k,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(k,{toValue:1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(k,{toValue:-1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(k,{toValue:1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(k,{toValue:0,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0})]),e.start())),O.current=M,()=>e?.stop()},[M,k,D,m,z,I.motion.duration.instant]),(0,_react.useEffect)(()=>{const e=B.current;if(B.current=F,e===F)return;if(-1===e&&-1===F)return;const t=[];return L.forEach((a,i)=>{const n=i===F?1:0;if(i!==F&&i!==e)return;const r=_reactNative.Animated.timing(a,{toValue:n,duration:I.motion.duration.fast,easing:_reactNative.Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:!0});r.start(),t.push(r)}),()=>t.forEach(e=>{e.stop()})},[F,L,I]);const q=(0,_react.useCallback)(e=>{const t=V.current[e];t&&t.focus()},[]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>q(0),blur:()=>{const e=V.current[F>=0?F:0];e?.blur()},clear:()=>{N(""),q(0)}}),[q,F,N]),(0,_react.useEffect)(()=>{if(o&&!u){const e=setTimeout(()=>q(0),c);return()=>clearTimeout(e)}},[o,c,u,q]);const U=(0,_react.useMemo)(()=>{const e=new Array(s).fill("");for(let t=0;t<Math.min(j.length,s);t+=1)e[t]=j[t]??"";return e},[j,s]),H=(0,_react.useCallback)(e=>{const t=e.slice(0,s);t!==j&&(N(t),t.length===s&&r&&r(t))},[s,N,r,j]),W=(0,_react.useCallback)((e,t)=>{const a=t.replace(/\u200B/g,""),i=sanitizeChar(a,l);if(!i){const t=U.slice(),a=(t[e]??"").length>0;if(t[e]="",H(t.join("").slice(0,s)),!a&&e>0){const t=U.slice();t[e-1]="",H(t.join("")),q(e-1)}return}const n=U[e]??"",r=n&&i.length>s&&i.startsWith(n)?i.slice(n.length):i;if(r.length>=s){const t=r.slice(0,s),a=j.length;return H(t),t.length!==a&&m&&(0,_index3.triggerHaptic)(m),void V.current[e]?.blur()}const o=U.slice();let c=e;for(let e=0;e<i.length&&c<s;e+=1)o[c]=i[e]??"",c+=1;const u=o.join("").slice(0,s),d=j.length;H(u),u.length!==d&&m&&(0,_index3.triggerHaptic)(m);const _=Math.min(c,s-1);c>=s?V.current[e]?.blur():q(_)},[U,q,l,s,m,H,j]),$=(0,_react.useCallback)((e,t)=>{if("Backspace"!==t.nativeEvent.key)return;if(0===(U[e]??"").length){if(e>0){const t=U.slice();t[e-1]="",H(t.join("")),q(e-1)}}else{const t=U.slice();t[e]="",H(t.join(""))}},[U,q,H]),G=(0,_react.useCallback)((e,t)=>{P(e),g?.(t)},[g]),K=(0,_react.useCallback)(()=>{P(-1)},[]),X=(0,_react.useCallback)(()=>{if(u)return;const e=U.indexOf("");q(-1===e?s-1:e)},[U,u,q,s]),J=(0,_react.useCallback)(e=>{C(e.nativeEvent.layout.width)},[]),Q=f??T.field(s),Y=R>0?Math.max(24,Math.min(A.cell,Math.floor((R-A.gap*(s-1))/s))):A.cell,Z=k.interpolate({inputRange:[-1,1],outputRange:[-6,6]});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:h,onLayout:J,accessible:!0,accessibilityRole:"none",accessibilityLabel:Q,accessibilityValue:{text:a},accessibilityState:{disabled:u},"aria-disabled":u,testID:y,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:X,disabled:u,accessible:!1,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[E.row,{columnGap:A.gap,transform:[{translateX:Z}]}],children:U.map((e,t)=>{const a=F===t,i=e.length>0,n=M?I.colors["danger-border"]:I.colors["focus-ring"],r=L[t];if(!r)return null;const o=p&&i?"●":e;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E.cellWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:_,width:Y,height:Y,radius:w,borderWidth:1.5,focused:a,error:M,filled:i,disabled:u,paddingHorizontal:I.space.none,paddingVertical:I.space.none,gap:I.space.none,style:v,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:e=>{V.current[t]=e},value:(p&&i?"":e)||"​",onChangeText:e=>W(t,e),onKeyPress:e=>$(t,e),onFocus:e=>G(t,e),onBlur:K,keyboardType:l,editable:!u,selectTextOnFocus:!0,caretHidden:i,maxLength:s+1,textContentType:"oneTimeCode",autoComplete:0===t?"sms-otp":"off",importantForAutofill:0===t?"yes":"no",style:[E.input,{fontSize:A.text,color:I.colors["text-body"],...(0,_index2.fontFor)(I,"semibold")},b]}),p&&i?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:E.maskOverlay,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",style:[{fontSize:A.text},b],children:o})}):null]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[E.underline,{backgroundColor:n,opacity:r}]})]},`otp-cell-${t}`)})})}),(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.default=exports.OTPInput=exports.DEFAULT_OTP_INPUT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_OTP_INPUT_LABELS=exports.DEFAULT_OTP_INPUT_LABELS=Object.freeze({field:e=>`Enter ${e}-digit code`}),sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=exports.OTPInput=(0,_react.forwardRef)((e,t)=>{const{value:a,defaultValue:i,onChange:r,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:x,onFocus:g,accessibilityLabel:f,style:h,cellStyle:v,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 T=x?{...DEFAULT_OTP_INPUT_LABELS,...x}:DEFAULT_OTP_INPUT_LABELS,[j,N]=(0,_index.useControllableState)({value:a,defaultValue:i??"",onChange:r}),V=(0,_index2.useTheme)(),E=(0,_react.useMemo)(()=>buildStyles(V),[V]),A=(0,_index2.resolveOtpInputSize)(V,_),F=V.components["otp-input"][_].radius,P=(0,_react.useRef)([]),[R,C]=(0,_react.useState)(-1),[I,O]=(0,_react.useState)(0),k=(0,_react.useRef)(null),S=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,L=(0,_react.useRef)(new Map),w=(0,_react.useMemo)(()=>{const e=L.current,t=[];for(let a=0;a<s;a+=1){let i=e.get(a);i||(i=new _reactNative.Animated.Value(0),e.set(a,i)),t.push(i)}for(const t of Array.from(e.keys()))t>=s&&e.delete(t);return t},[s]),B=(0,_react.useRef)(-1),D=V.settings.components["otp-input"]?.shakeOnError??!1,z=(0,_index.useReducedMotion)(),M=!0===d||(0,_FieldBase.hasFieldText)(d);(0,_react.useEffect)(()=>{let e;return null===k.current||!M||k.current||(m&&(0,_index3.triggerHaptic)("notificationError"),D&&!z&&((0,_index2.setNativeValue)(S,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(S,{toValue:1,duration:V.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(S,{toValue:-1,duration:V.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(S,{toValue:1,duration:V.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(S,{toValue:0,duration:V.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0})]),e.start())),k.current=M,()=>e?.stop()},[M,S,D,m,z,V.motion.duration.instant]),(0,_react.useEffect)(()=>{const e=B.current;if(B.current=R,e===R)return;if(-1===e&&-1===R)return;const t=[];return w.forEach((a,i)=>{const r=i===R?1:0;if(i!==R&&i!==e)return;const n=_reactNative.Animated.timing(a,{toValue:r,duration:V.motion.duration.fast,easing:_reactNative.Easing.bezier(...V.motion.ease["in-out"]),useNativeDriver:!0});n.start(),t.push(n)}),()=>t.forEach(e=>{e.stop()})},[R,w,V]);const q=(0,_react.useCallback)(e=>{const t=P.current[e];t&&t.focus()},[]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>q(0),blur:()=>{const e=P.current[R>=0?R:0];e?.blur()},clear:()=>{N(""),q(0)}}),[q,R,N]),(0,_react.useEffect)(()=>{if(o&&!u){const e=setTimeout(()=>q(0),c);return()=>clearTimeout(e)}},[o,c,u,q]);const U=(0,_react.useMemo)(()=>{const e=new Array(s).fill("");for(let t=0;t<Math.min(j.length,s);t+=1)e[t]=j[t]??"";return e},[j,s]),H=(0,_react.useCallback)(e=>{const t=e.slice(0,s);t!==j&&(N(t),t.length===s&&n&&n(t))},[s,N,n,j]),W=(0,_react.useCallback)((e,t)=>{const a=t.replace(/\u200B/g,""),i=sanitizeChar(a,l);if(!i){const t=U.slice(),a=(t[e]??"").length>0;if(t[e]="",H(t.join("").slice(0,s)),!a&&e>0){const t=U.slice();t[e-1]="",H(t.join("")),q(e-1)}return}const r=U[e]??"",n=r&&i.length>s&&i.startsWith(r)?i.slice(r.length):i;if(n.length>=s){const t=n.slice(0,s),a=j.length;return H(t),t.length!==a&&m&&(0,_index3.triggerHaptic)(m),void P.current[e]?.blur()}const o=U.slice();let c=e;for(let e=0;e<i.length&&c<s;e+=1)o[c]=i[e]??"",c+=1;const u=o.join("").slice(0,s),d=j.length;H(u),u.length!==d&&m&&(0,_index3.triggerHaptic)(m);const _=Math.min(c,s-1);c>=s?P.current[e]?.blur():q(_)},[U,q,l,s,m,H,j]),$=(0,_react.useCallback)((e,t)=>{if("Backspace"!==t.nativeEvent.key)return;if(0===(U[e]??"").length){if(e>0){const t=U.slice();t[e-1]="",H(t.join("")),q(e-1)}}else{const t=U.slice();t[e]="",H(t.join(""))}},[U,q,H]),G=(0,_react.useCallback)((e,t)=>{C(e),g?.(t)},[g]),K=(0,_react.useCallback)(()=>{C(-1)},[]),X=(0,_react.useCallback)(()=>{if(u)return;const e=U.indexOf("");q(-1===e?s-1:e)},[U,u,q,s]),J=(0,_react.useCallback)(e=>{O(e.nativeEvent.layout.width)},[]),Q=f??T.field(s),Y=I>0?Math.max(24,Math.min(A.cell,Math.floor((I-A.gap*(s-1))/s))):A.cell,Z=S.interpolate({inputRange:[-1,1],outputRange:[-6,6]});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:h,onLayout:J,accessible:!0,accessibilityRole:"none",accessibilityLabel:Q,accessibilityValue:{text:a},accessibilityState:{disabled:u},"aria-disabled":u,testID:y,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:X,disabled:u,accessible:!1,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[E.row,{columnGap:A.gap,transform:[{translateX:Z}]}],children:U.map((e,t)=>{const a=R===t,i=e.length>0,r=M?V.colors["danger-border"]:V.colors["focus-ring"],n=w[t];if(!n)return null;const o=p&&i?"●":e;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E.cellWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:_,width:Y,height:Y,radius:F,borderWidth:1.5,focused:a,error:M,filled:i,disabled:u,paddingHorizontal:V.space.none,paddingVertical:V.space.none,gap:V.space.none,style:v,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:e=>{P.current[t]=e},value:(p&&i?"":e)||"​",onChangeText:e=>W(t,e),onKeyPress:e=>$(t,e),onFocus:e=>G(t,e),onBlur:K,keyboardType:l,editable:!u,selectTextOnFocus:!0,caretHidden:i,maxLength:s+1,textContentType:"oneTimeCode",autoComplete:0===t?"sms-otp":"off",importantForAutofill:0===t?"yes":"no",style:[E.input,{fontSize:A.text,color:V.colors["text-body"],...(0,_index2.fontFor)(V,"semibold")},b]}),p&&i?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:E.maskOverlay,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",style:[{fontSize:A.text},b],children:o})}):null]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[E.underline,{backgroundColor:r,opacity:n}]})]},`otp-cell-${t}`)})})}),(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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.PermissionPrompt=exports.DEFAULT_PERMISSION_PROMPT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../Button/index.js"),_index3=require("../IconBadge/index.js"),_index4=require("../Text/index.js"),_usePermissionPrompt=require("./usePermissionPrompt.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PERMISSION_PROMPT_LABELS=exports.DEFAULT_PERMISSION_PROMPT_LABELS=Object.freeze({proceed:"Continue",cancel:"Cancel",openSettings:"Open Settings",access:Object.freeze({camera:"Camera access",microphone:"Microphone access",photos:"Photo access",photosAdd:"Photo access",mediaLibrary:"Media library access",location:"Location access",locationAlways:"Location access",contacts:"Contacts access",calendar:"Calendar access",reminders:"Reminders access",notifications:"Notification access",bluetooth:"Bluetooth access",storage:"Storage access"}),notAvailable:e=>`${e} is not available on this device.`,offWithSettings:e=>`${e} is off for this app. You can turn it on in Settings.`,off:e=>`${e} is off, so this cannot be used right now.`}),unavailableMessage=(e,t,s,i)=>{const n=i.access[e];return"unavailable"===t?i.notAvailable(n):s?i.offWithSettings(n):i.off(n)},PermissionPrompt=e=>{const{kind:t,title:s,reason:i,icon:n,onResult:a,fallback:r,haptic:o="selection",labels:c,style:l,testID:u}=e;(0,_warnInvalidValue.warnInvalidValue)("PermissionPrompt","kind",t,Object.keys(DEFAULT_PERMISSION_PROMPT_LABELS.access));const d=c?{...DEFAULT_PERMISSION_PROMPT_LABELS,...c}:DEFAULT_PERMISSION_PROMPT_LABELS,_=(0,_index.useTheme)(),x=(0,_react.useMemo)(()=>buildStyles(_),[_]),m=(0,_usePermissionPrompt.usePermissionPrompt)(t,{onResult:a}),p=unavailableMessage(t,m.status,m.showSettings,d),P=(0,_react.useRef)(!1);if((0,_react.useEffect)(()=>{"explain"!==m.view?("unavailable"===m.view&&P.current&&(0,_announce.announce)(p),P.current=!1):P.current=!0},[m.view,p]),"explain"!==m.view&&"unavailable"!==m.view)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:l,testID:u});const j="explain"===m.view;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[x.root,l],testID:u,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:x.header,children:[n?(0,_jsxRuntime.jsx)(_index3.IconBadge,{icon:n,size:"lg",tone:j?"primary":"neutral"}):null,(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",align:"center",children:s}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",color:"secondary",align:"center",children:j?i:p})]}),j?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:x.actions,children:[(0,_jsxRuntime.jsx)(_index2.Button,{haptic:o,label:d.proceed,size:"lg",fullWidth:!0,loading:m.requesting,onPress:()=>{m.request()}}),m.cancellable?(0,_jsxRuntime.jsx)(_index2.Button,{haptic:o,label:d.cancel,size:"lg",fullWidth:!0,variant:"ghost",tone:"neutral",disabled:m.requesting,onPress:m.cancel}):null]}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:x.actions,children:[r?(0,_jsxRuntime.jsx)(_index2.Button,{haptic:o,label:r.label,size:"lg",fullWidth:!0,onPress:r.onPress}):null,m.showSettings?(0,_jsxRuntime.jsx)(_reactNative.View,{style:x.link,children:(0,_jsxRuntime.jsx)(_index2.Button,{haptic:o,label:d.openSettings,variant:"link",onPress:()=>{m.openSettings()}})}):null]})]})};exports.PermissionPrompt=PermissionPrompt;const buildStyles=e=>_reactNative.StyleSheet.create({root:{gap:e.space.lg,paddingVertical:e.space.lg},header:{alignItems:"center",gap:e.space.sm},actions:{gap:e.space.sm},link:{alignItems:"center",paddingVertical:e.space.sm}});var _default=exports.default=PermissionPrompt;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.PermissionPrompt=exports.DEFAULT_PERMISSION_PROMPT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index2=require("../Button/index.js"),_index3=require("../IconBadge/index.js"),_index4=require("../Text/index.js"),_usePermissionPrompt=require("./usePermissionPrompt.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PERMISSION_PROMPT_LABELS=exports.DEFAULT_PERMISSION_PROMPT_LABELS=Object.freeze({proceed:"Continue",cancel:"Cancel",openSettings:"Open Settings",access:Object.freeze({camera:"Camera access",microphone:"Microphone access",photos:"Photo access",photosAdd:"Photo access",mediaLibrary:"Media library access",location:"Location access",locationAlways:"Location access",contacts:"Contacts access",calendar:"Calendar access",reminders:"Reminders access",notifications:"Notification access",bluetooth:"Bluetooth access",storage:"Storage access"}),notAvailable:e=>`${e} is not available on this device.`,offWithSettings:e=>`${e} is off for this app. You can turn it on in Settings.`,off:e=>`${e} is off, so this cannot be used right now.`}),unavailableMessage=(e,s,t,i)=>{const n=i.access[e];return"unavailable"===s?i.notAvailable(n):t?i.offWithSettings(n):i.off(n)},PermissionPrompt=e=>{const{kind:s,title:t,reason:i,icon:n,onResult:a,fallback:r,haptic:o="selection",labels:c,style:l,testID:u}=e;(0,_assertValidValue.assertValidValue)("PermissionPrompt","kind",s,Object.keys(DEFAULT_PERMISSION_PROMPT_LABELS.access));const d=c?{...DEFAULT_PERMISSION_PROMPT_LABELS,...c}:DEFAULT_PERMISSION_PROMPT_LABELS,_=(0,_index.useTheme)(),x=(0,_react.useMemo)(()=>buildStyles(_),[_]),m=(0,_usePermissionPrompt.usePermissionPrompt)(s,{onResult:a}),p=unavailableMessage(s,m.status,m.showSettings,d),P=(0,_react.useRef)(!1);if((0,_react.useEffect)(()=>{"explain"!==m.view?("unavailable"===m.view&&P.current&&(0,_announce.announce)(p),P.current=!1):P.current=!0},[m.view,p]),"explain"!==m.view&&"unavailable"!==m.view)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:l,testID:u});const j="explain"===m.view;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[x.root,l],testID:u,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:x.header,children:[n?(0,_jsxRuntime.jsx)(_index3.IconBadge,{icon:n,size:"lg",tone:j?"primary":"neutral"}):null,(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",align:"center",children:t}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",color:"secondary",align:"center",children:j?i:p})]}),j?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:x.actions,children:[(0,_jsxRuntime.jsx)(_index2.Button,{haptic:o,label:d.proceed,size:"lg",fullWidth:!0,loading:m.requesting,onPress:()=>{m.request()}}),m.cancellable?(0,_jsxRuntime.jsx)(_index2.Button,{haptic:o,label:d.cancel,size:"lg",fullWidth:!0,variant:"ghost",tone:"neutral",disabled:m.requesting,onPress:m.cancel}):null]}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:x.actions,children:[r?(0,_jsxRuntime.jsx)(_index2.Button,{haptic:o,label:r.label,size:"lg",fullWidth:!0,onPress:r.onPress}):null,m.showSettings?(0,_jsxRuntime.jsx)(_reactNative.View,{style:x.link,children:(0,_jsxRuntime.jsx)(_index2.Button,{haptic:o,label:d.openSettings,variant:"link",onPress:()=>{m.openSettings()}})}):null]})]})};exports.PermissionPrompt=PermissionPrompt;const buildStyles=e=>_reactNative.StyleSheet.create({root:{gap:e.space.lg,paddingVertical:e.space.lg},header:{alignItems:"center",gap:e.space.sm},actions:{gap:e.space.sm},link:{alignItems:"center",paddingVertical:e.space.sm}});var _default=exports.default=PermissionPrompt;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseE164=exports.formatE164=exports.default=exports.PhoneNumberInput=exports.DEFAULT_PHONE_NUMBER_INPUT_LABELS=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("../../theme/index.js"),_index3=require("../../utils/index.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index4=require("../FieldBase/index.js"),_Chevron=require("../FieldBase/Chevron.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PHONE_NUMBER_INPUT_LABELS=exports.DEFAULT_PHONE_NUMBER_INPUT_LABELS=Object.freeze({placeholder:"Phone number",popular:"Popular",allCountries:"All countries",countrySheetTitle:"Country code",countrySearchPlaceholder:"Search…",invalid:"Enter a valid number",invalidMobile:"Enter a valid mobile number",countryButton:e=>`Country code, currently +${e}`}),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 n=e.replace(/[^0-9]/g,"");if(!n)return null;const o=(0,_mobileCore.splitPhoneNumber)(`+${n}`);let r=o?.callingCode,l=o?.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=>n.startsWith(e)),!r)return null;l=n.slice(r.length)}const a=t.filter(e=>e.code===r),s=a.find(e=>e.iso===i)?.iso??a.find(e=>e.iso===o?.country)?.iso??o?.country??a[0]?.iso??"";return{callingCode:r,nationalNumber:l,iso:s}};exports.parseE164=parseE164;const planOf=e=>(0,_mobileCore.isSupportedCountry)(e)?e:null,PhoneNumberInput=exports.PhoneNumberInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:n,onChange:o,e164:r,onChangeE164:l,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:c,onComplete:d,onValidityChange:b,countries:p=ALL_CALLING_CODES,popularCountries:_,hiddenCountries:m,showFlag:h=!0,renderFlag:f,renderCountry:g,showAlphabetIndex:x,defaultCountry:N,validation:C="any",maxLength:v,formatAsYouType:y=!0,countryLocked:S=!1,label:E,labelMode:L="top",labelStyle:I,placeholder:T,helperText:j,error:P,invalidMessage:A,required:F,disabled:O=!1,size:R="md",variant:w,radius:M,labels:U,haptic:D,accessibilityLabel:V,countryAccessibilityLabel:B,onFocus:q,onBlur:z,style:k,testID:$}=e;(0,_warnInvalidValue.warnInvalidValue)("PhoneNumberInput","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("PhoneNumberInput","variant",e.variant,["outline","filled","underline"]),(0,_warnInvalidValue.warnInvalidValue)("PhoneNumberInput","labelMode",e.labelMode,["top","float"]),(0,_warnInvalidValue.warnInvalidValue)("PhoneNumberInput","validation",!1===e.validation?void 0:e.validation,["any","mobile"]);const G=(0,_index2.useTheme)(),H=(0,_react.useMemo)(()=>buildStyles(G),[G]),W=(0,_react.useRef)(null),Y=(0,_react.useMemo)(()=>U?{...DEFAULT_PHONE_NUMBER_INPUT_LABELS,...U}:DEFAULT_PHONE_NUMBER_INPUT_LABELS,[U]),K=T??Y.placeholder,Z=(0,_react.useMemo)(()=>/-([A-Za-z]{2})(?:-|$)/.exec((0,_mobileCore.getFormatterConfig)().locale)?.[1]?.toUpperCase(),[]),J=(0,_react.useMemo)(()=>m?.length?p.filter(e=>!m.includes(e.iso)):p,[p,m]),Q=(0,_react.useMemo)(()=>{if(!_?.length)return;const e=_.map(e=>J.find(t=>t.iso===e)).filter(e=>void 0!==e);return e.length?[{title:Y.popular,options:e},{title:Y.allCountries,options:J}]:void 0},[_,Y.popular,Y.allCountries,J]),X=(0,_react.useCallback)((e,t,i)=>{if(!e)return null;if(f)return f(e);if(!h)return null;const n=(0,_mobileCore.countryFlagEmoji)(e.iso);return n?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",style:[H.flag,{fontSize:t}],testID:i,children:n}):null},[f,h,H.flag]),ee=(0,_react.useCallback)(e=>{const t=planOf(e),i=t?(0,_mobileCore.maxNationalNumberLength)(t,!1===C?"any":C):Number.POSITIVE_INFINITY;return v?Math.min(i,v):i},[v,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,n=(0,_mobileCore.splitPhoneNumber)(e,i);if(!n)return null;const o=n.country??t,r=p.find(e=>e.iso===o);return{callingCode:r?.code??n.callingCode,nationalNumber:te(n.nationalNumber,o),iso:r?.iso??o}},[p,te]),ne=(0,_react.useMemo)(()=>{const e=J.find(e=>e.iso===(N??Z))??J[0]??p[0],t={callingCode:e?.code??"",nationalNumber:"",iso:e?.iso??""};return"string"==typeof n?ie(n,t.iso)??t:n??t},[p,J,N,Z,n,ie]),oe=(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)(ne.iso),ae=(0,_react.useMemo)(()=>{if(void 0===r)return;const e=r?parseE164(r,p,re):null;if(e)return{...e,nationalNumber:te(e.nationalNumber,e.iso)};const t=p.find(e=>e.iso===re);return{callingCode:t?.code??ne.callingCode,nationalNumber:"",iso:re}},[r,p,re,ne.callingCode,te]),se=(0,_react.useCallback)(e=>{le(e.iso),o?.(e),l?.(e.nationalNumber?formatE164(e):"",{country:p.find(t=>t.iso===e.iso),national:e.nationalNumber,valid:oe(e)})},[o,l,p,oe]),[ue,ce]=(0,_index.useControllableState)({value:i??ae,defaultValue:ne,onChange:se}),[de,be]=(0,_react.useState)(!1),pe=(0,_react.useCallback)(()=>{O||W.current?.focus()},[O]),[me,he]=(0,_react.useState)(!1),[fe,ge]=(0,_react.useState)(!1),[xe,Ne]=(0,_react.useState)(!1),Ce=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{xe||(Ce.current=!1)},[xe]);const ve=(0,_index2.resolveFieldSize)(G,R),ye=(0,_index4.resolveFieldTextStyle)(G,{disabled:O}),Se=w??G.settings.components.field?.defaultVariant??"outline",Ee="underline"===Se,Le=G.space.md,[Ie,Te]=(0,_react.useState)(0),je=Ie+Le+1+Le,Pe=ue.nationalNumber.length>0,Ae=F&&!E&&!Pe&&K.length>0,Fe=de||Pe,Oe=Boolean(E)&&"float"===L&&Ie>0,Re=(0,_useFloatingLabel.useFloatingLabel)({label:E,enabled:Oe,floated:Fe,required:F,variant:Se,sizeTokens:ve,leadingOffset:je,paddingLeft:Ee?G.space.none:ve["padding-x"],color:G.colors["field-label"],style:I}),we=(0,_react.useMemo)(()=>p.find(e=>e.iso===ue.iso),[p,ue.iso]),Me=planOf(ue.iso),Ue=y&&Me?(0,_mobileCore.formatPhoneAsTyped)(ue.nationalNumber,Me):ue.nationalNumber,De=ee(ue.iso),Ve=0===ue.nationalNumber.length||me||!Number.isFinite(De)?void 0:Ue.length+Math.max(0,De-ue.nationalNumber.length),Be=oe(ue);(0,_react.useEffect)(()=>{Pe||ge(!1)},[Pe]);const qe=Me?(0,_mobileCore.maxNationalNumberLength)(Me,!1===C?"any":C):Number.POSITIVE_INFINITY,ze=ue.nationalNumber.length>=qe,ke=!1!==C&&!1!==A&&Pe&&!Be&&(fe||ze),$e="mobile"===C?Y.invalidMobile:Y.invalid,Ge=(0,_index4.hasFieldText)(P)?P:ke?A||$e:void 0,He=!0===P||(0,_index4.hasFieldText)(Ge),We=(0,_react.useRef)(Be),Ye=(0,_react.useRef)(ue);Ye.current=ue,(0,_react.useEffect)(()=>{We.current!==Be&&(We.current=Be,b?.(Be),Be&&d?.(formatE164(Ye.current)))},[Be,d,b]);const Ke=(0,_react.useCallback)(e=>{if(e.includes("+")){const t=ie(e,ue.iso);if(t&&!S&&J.some(e=>e.iso===t.iso))return void ce(t);if(t&&t.iso===ue.iso)return void ce(t)}ce({...ue,nationalNumber:te(digitsOnly(e),ue.iso)})},[J,S,ue,ie,te,ce]),Ze=(0,_react.useCallback)(e=>{ce({callingCode:e.code,iso:e.iso,nationalNumber:te(ue.nationalNumber,e.iso)}),Ne(!1);const t=(0,_index3.resolveHaptic)(D,"selection");t&&(0,_index3.triggerHaptic)(t)},[ue,D,te,ce]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>W.current?.focus(),blur:()=>W.current?.blur(),clear:()=>ce({...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:()=>oe(Ye.current),getCountry:()=>p.find(e=>e.iso===Ye.current.iso)}),[p,oe,ce]);const Je=O||S,Qe=(0,_jsxRuntime.jsx)(_index4.FieldBase,{size:R,variant:Se,radius:M,topNotch:Re.topNotch,focused:de,disabled:O,error:He,filled:Pe,onPress:pe,pressFeedback:!1,leadingDivider:!0,paddingLeft:Ee?G.space.none:void 0,leading:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{Je||(Ce.current=!0,Ne(!0))},disabled:Je,accessibilityRole:"button",accessibilityLabel:B??Y.countryButton(ue.callingCode),accessibilityState:{disabled:Je},"aria-disabled":Je,hitSlop:6,...(0,_hitSlop.hitSlopMarker)(6),onLayout:e=>{const{width:t}=e.nativeEvent.layout;Te(e=>e===t?e:t)},style:H.codeTrigger,testID:$?`${$}-code`:void 0,children:[X(we,ve.text,$?`${$}-flag`:void 0),(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",style:[H.codeText,{color:ye.color,fontSize:ve.text}],children:`+${ue.callingCode}`}),S?null:(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:O?G.colors["field-icon-disabled"]:G.colors["field-icon"],size:ve.icon,open:xe})]}),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.inputWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:W,value:Ue,maxLength:Ve,onChangeText:Ke,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:c,onSelectionChange:e=>{const{start:t,end:i}=e.nativeEvent.selection;he(t!==i)},onFocus:()=>{be(!0),q?.()},onBlur:()=>{be(!1),Pe&&!Ce.current&&ge(!0),z?.()},editable:!O,placeholder:Oe&&!Fe||Ae?void 0:K,placeholderTextColor:ye.placeholderColor,accessibilityLabel:V??E??K,selectionColor:G.colors["field-caret"],keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",style:[H.input,{color:ye.color,fontSize:ve.text,...ye.weightStyle,paddingLeft:Ee?G.space.none:void 0}],testID:$?`${$}-input`:void 0}),Ae?(0,_jsxRuntime.jsx)(_index4.RequiredPlaceholder,{text:K,color:ye.placeholderColor,fontSize:ve.text,weightStyle:ye.weightStyle}):null]})});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:k,testID:$,children:[E&&"top"===L?(0,_jsxRuntime.jsx)(_index4.FieldLabel,{size:R,required:F,children:E}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.fieldWrapper,children:[Qe,Re.node]}),(0,_jsxRuntime.jsx)(_index4.FieldMessage,{size:R,error:He,text:He?Ge:j}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:xe,haptic:D,onClose:()=>Ne(!1),title:Y.countrySheetTitle,options:J,sections:Q,getOptionLabel:e=>`${e.label} (+${e.code})`,getOptionValue:e=>e.iso,getOptionIcon:e=>X(e,G.text.lg.size),renderOption:g?({option:e,selected:t})=>g(e,{selected:t}):void 0,value:we?.iso,onChange:(e,t)=>Ze(t),searchable:J.length>8,labels:{searchPlaceholder:Y.countrySearchPlaceholder},alphabetIndex:x??J.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,_index2.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_PHONE_NUMBER_INPUT_LABELS=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("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_hitSlop=require("../../utils/hitSlop.js"),_index4=require("../FieldBase/index.js"),_Chevron=require("../FieldBase/Chevron.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PHONE_NUMBER_INPUT_LABELS=exports.DEFAULT_PHONE_NUMBER_INPUT_LABELS=Object.freeze({placeholder:"Phone number",popular:"Popular",allCountries:"All countries",countrySheetTitle:"Country code",countrySearchPlaceholder:"Search…",invalid:"Enter a valid number",invalidMobile:"Enter a valid mobile number",countryButton:e=>`Country code, currently +${e}`}),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,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,blurOnSubmit:c,onComplete:d,onValidityChange:b,countries:p=ALL_CALLING_CODES,popularCountries:_,hiddenCountries:m,showFlag:h=!0,renderFlag:f,renderCountry:g,showAlphabetIndex:x,defaultCountry:N,validation:C="any",maxLength:y,formatAsYouType:v=!0,countryLocked:S=!1,label:E,labelMode:L="top",labelStyle:I,placeholder:T,helperText:j,error:P,invalidMessage:A,required:F,disabled:O=!1,size:V="md",variant:R,radius:M,labels:U,haptic:D,accessibilityLabel:B,countryAccessibilityLabel:q,onFocus:w,onBlur:z,style:k,testID:$}=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 G=(0,_index2.useTheme)(),H=(0,_react.useMemo)(()=>buildStyles(G),[G]),W=(0,_react.useRef)(null),Y=(0,_react.useMemo)(()=>U?{...DEFAULT_PHONE_NUMBER_INPUT_LABELS,...U}:DEFAULT_PHONE_NUMBER_INPUT_LABELS,[U]),K=T??Y.placeholder,Z=(0,_react.useMemo)(()=>/-([A-Za-z]{2})(?:-|$)/.exec((0,_mobileCore.getFormatterConfig)().locale)?.[1]?.toUpperCase(),[]),J=(0,_react.useMemo)(()=>m?.length?p.filter(e=>!m.includes(e.iso)):p,[p,m]),Q=(0,_react.useMemo)(()=>{if(!_?.length)return;const e=_.map(e=>J.find(t=>t.iso===e)).filter(e=>void 0!==e);return e.length?[{title:Y.popular,options:e},{title:Y.allCountries,options:J}]:void 0},[_,Y.popular,Y.allCountries,J]),X=(0,_react.useCallback)((e,t,i)=>{if(!e)return null;if(f)return f(e);if(!h)return null;const o=(0,_mobileCore.countryFlagEmoji)(e.iso);return o?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",style:[H.flag,{fontSize:t}],testID:i,children:o}):null},[f,h,H.flag]),ee=(0,_react.useCallback)(e=>{const t=planOf(e),i=t?(0,_mobileCore.maxNationalNumberLength)(t,!1===C?"any":C):Number.POSITIVE_INFINITY;return y?Math.min(i,y):i},[y,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=p.find(e=>e.iso===n);return{callingCode:r?.code??o.callingCode,nationalNumber:te(o.nationalNumber,n),iso:r?.iso??n}},[p,te]),oe=(0,_react.useMemo)(()=>{const e=J.find(e=>e.iso===(N??Z))??J[0]??p[0],t={callingCode:e?.code??"",nationalNumber:"",iso:e?.iso??""};return"string"==typeof o?ie(o,t.iso)??t:o??t},[p,J,N,Z,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,p,re):null;if(e)return{...e,nationalNumber:te(e.nationalNumber,e.iso)};const t=p.find(e=>e.iso===re);return{callingCode:t?.code??oe.callingCode,nationalNumber:"",iso:re}},[r,p,re,oe.callingCode,te]),se=(0,_react.useCallback)(e=>{le(e.iso),n?.(e),l?.(e.nationalNumber?formatE164(e):"",{country:p.find(t=>t.iso===e.iso),national:e.nationalNumber,valid:ne(e)})},[n,l,p,ne]),[ue,ce]=(0,_index.useControllableState)({value:i??ae,defaultValue:oe,onChange:se}),[de,be]=(0,_react.useState)(!1),pe=(0,_react.useCallback)(()=>{O||W.current?.focus()},[O]),[me,he]=(0,_react.useState)(!1),[fe,ge]=(0,_react.useState)(!1),[xe,Ne]=(0,_react.useState)(!1),Ce=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{xe||(Ce.current=!1)},[xe]);const ye=(0,_index2.resolveFieldSize)(G,V),ve=(0,_index4.resolveFieldTextStyle)(G,{disabled:O}),Se=R??G.settings.components.field?.defaultVariant??"outline",Ee="underline"===Se,Le=G.space.md,[Ie,Te]=(0,_react.useState)(0),je=Ie+Le+1+Le,Pe=ue.nationalNumber.length>0,Ae=F&&!E&&!Pe&&K.length>0,Fe=de||Pe,Oe=Boolean(E)&&"float"===L&&Ie>0,Ve=(0,_useFloatingLabel.useFloatingLabel)({label:E,enabled:Oe,floated:Fe,required:F,variant:Se,sizeTokens:ye,leadingOffset:je,paddingLeft:Ee?G.space.none:ye["padding-x"],color:G.colors["field-label"],style:I}),Re=(0,_react.useMemo)(()=>p.find(e=>e.iso===ue.iso),[p,ue.iso]),Me=planOf(ue.iso),Ue=v&&Me?(0,_mobileCore.formatPhoneAsTyped)(ue.nationalNumber,Me):ue.nationalNumber,De=ee(ue.iso),Be=0===ue.nationalNumber.length||me||!Number.isFinite(De)?void 0:Ue.length+Math.max(0,De-ue.nationalNumber.length),qe=ne(ue);(0,_react.useEffect)(()=>{Pe||ge(!1)},[Pe]);const we=Me?(0,_mobileCore.maxNationalNumberLength)(Me,!1===C?"any":C):Number.POSITIVE_INFINITY,ze=ue.nationalNumber.length>=we,ke=!1!==C&&!1!==A&&Pe&&!qe&&(fe||ze),$e="mobile"===C?Y.invalidMobile:Y.invalid,Ge=(0,_index4.hasFieldText)(P)?P:ke?A||$e:void 0,He=!0===P||(0,_index4.hasFieldText)(Ge),We=(0,_react.useRef)(qe),Ye=(0,_react.useRef)(ue);Ye.current=ue,(0,_react.useEffect)(()=>{We.current!==qe&&(We.current=qe,b?.(qe),qe&&d?.(formatE164(Ye.current)))},[qe,d,b]);const Ke=(0,_react.useCallback)(e=>{if(e.includes("+")){const t=ie(e,ue.iso);if(t&&!S&&J.some(e=>e.iso===t.iso))return void ce(t);if(t&&t.iso===ue.iso)return void ce(t)}ce({...ue,nationalNumber:te(digitsOnly(e),ue.iso)})},[J,S,ue,ie,te,ce]),Ze=(0,_react.useCallback)(e=>{ce({callingCode:e.code,iso:e.iso,nationalNumber:te(ue.nationalNumber,e.iso)}),Ne(!1);const t=(0,_index3.resolveHaptic)(D,"selection");t&&(0,_index3.triggerHaptic)(t)},[ue,D,te,ce]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>W.current?.focus(),blur:()=>W.current?.blur(),clear:()=>ce({...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:()=>p.find(e=>e.iso===Ye.current.iso)}),[p,ne,ce]);const Je=O||S,Qe=(0,_jsxRuntime.jsx)(_index4.FieldBase,{size:V,variant:Se,radius:M,topNotch:Ve.topNotch,focused:de,disabled:O,error:He,filled:Pe,onPress:pe,pressFeedback:!1,leadingDivider:!0,paddingLeft:Ee?G.space.none:void 0,leading:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{Je||(Ce.current=!0,Ne(!0))},disabled:Je,accessibilityRole:"button",accessibilityLabel:q??Y.countryButton(ue.callingCode),accessibilityState:{disabled:Je},"aria-disabled":Je,hitSlop:6,...(0,_hitSlop.hitSlopMarker)(6),onLayout:e=>{const{width:t}=e.nativeEvent.layout;Te(e=>e===t?e:t)},style:H.codeTrigger,testID:$?`${$}-code`:void 0,children:[X(Re,ye.text,$?`${$}-flag`:void 0),(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",style:[H.codeText,{color:ve.color,fontSize:ye.text}],children:`+${ue.callingCode}`}),S?null:(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:O?G.colors["field-icon-disabled"]:G.colors["field-icon"],size:ye.icon,open:xe})]}),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.inputWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:W,value:Ue,maxLength:Be,onChangeText:Ke,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:c,onSelectionChange:e=>{const{start:t,end:i}=e.nativeEvent.selection;he(t!==i)},onFocus:()=>{be(!0),w?.()},onBlur:()=>{be(!1),Pe&&!Ce.current&&ge(!0),z?.()},editable:!O,placeholder:Oe&&!Fe||Ae?void 0:K,placeholderTextColor:ve.placeholderColor,accessibilityLabel:B??E??K,selectionColor:G.colors["field-caret"],keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",style:[H.input,{color:ve.color,fontSize:ye.text,...ve.weightStyle,paddingLeft:Ee?G.space.none:void 0}],testID:$?`${$}-input`:void 0}),Ae?(0,_jsxRuntime.jsx)(_index4.RequiredPlaceholder,{text:K,color:ve.placeholderColor,fontSize:ye.text,weightStyle:ve.weightStyle}):null]})});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:k,testID:$,children:[E&&"top"===L?(0,_jsxRuntime.jsx)(_index4.FieldLabel,{size:V,required:F,children:E}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.fieldWrapper,children:[Qe,Ve.node]}),(0,_jsxRuntime.jsx)(_index4.FieldMessage,{size:V,error:He,text:He?Ge:j}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:xe,haptic:D,onClose:()=>Ne(!1),title:Y.countrySheetTitle,options:J,sections:Q,getOptionLabel:e=>`${e.label} (+${e.code})`,getOptionValue:e=>e.iso,getOptionIcon:e=>X(e,G.text.lg.size),renderOption:g?({option:e,selected:t})=>g(e,{selected:t}):void 0,value:Re?.iso,onChange:(e,t)=>Ze(t),searchable:J.length>8,labels:{searchPlaceholder:Y.countrySearchPlaceholder},alphabetIndex:x??J.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,_index2.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=exports.DEFAULT_PICKER_TRIGGER_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../FieldBase/index.js"),_Chevron=require("../FieldBase/Chevron.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PICKER_TRIGGER_LABELS=exports.DEFAULT_PICKER_TRIGGER_LABELS=Object.freeze({placeholder:"Select…",selection:"Selection",noSelection:"No selection",clear:"Clear"}),PickerTrigger=exports.PickerTrigger=(0,_react.forwardRef)((e,i)=>{(0,_warnInvalidValue.warnInvalidValue)("PickerTrigger","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("PickerTrigger","variant",e.variant,["outline","filled","underline"]);const{value:l,placeholder:r,label:t,help:n,helperText:s,error:a,required:d=!1,onPress:o,clearable:c=!1,onClear:x,leftIcon:u,trailing:_,disabled:g=!1,size:v="md",variant:R,style:b,triggerStyle:T,valueStyle:y,labelStyle:j,messageStyle:h,accessibilityLabel:S,labels:m,testID:E}=e,I=m?{...DEFAULT_PICKER_TRIGGER_LABELS,...m}:DEFAULT_PICKER_TRIGGER_LABELS,L=(0,_index.useTheme)(),P=(0,_react.useMemo)(()=>buildStyles(L),[L]),p=(0,_index.resolveFieldSize)(L,v),f=(0,_index2.resolveFieldTextStyle)(L,{disabled:g}),F="string"==typeof l&&l.length>0,w=!0===a||(0,_index2.hasFieldText)(a),z=(0,_index2.hasFieldText)(t),C=F?l:r??I.placeholder,q=F?f.color:f.placeholderColor,A=F?`${(0,_index2.fieldTextAsString)(t)??I.selection}: ${l}`:r??I.noSelection,G=S??A,k={disabled:g},B=void 0===_,D=c&&F&&!g;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[P.root,b],testID:E,children:[z?(0,_jsxRuntime.jsx)(_index2.FieldLabel,{size:v,required:d,help:n,style:j,children:t}):null,(0,_jsxRuntime.jsx)(_index2.FieldBase,{size:v,variant:R,disabled:g,error:w,filled:F,onPress:o,leading:u,trailing:D||B||null!==_?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:P.trailingRow,children:[D?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",onPress:()=>{g||x?.()},accessibilityRole:"button",accessibilityLabel:I.clear,style:{fontSize:p.icon,color:L.colors["text-muted"],paddingHorizontal:L.space.xs},children:"×"}):null,void 0!==_?_:B?(0,_jsxRuntime.jsx)(_Chevron.Chevron,{size:p.icon,color:g?L.colors["text-disabled"]:L.colors["text-subtle"]}):null]}):null,accessibilityLabel:G,accessibilityState:k,accessibilityRole:"button",style:T,children:(0,_jsxRuntime.jsxs)(_index3.Text,{variant:"body",numberOfLines:1,style:[P.valueText,{color:q,fontSize:p.text,...f.weightStyle},y],children:[C,F||!d||z?null:(0,_jsxRuntime.jsx)(_index2.RequiredMark,{})]})}),(0,_jsxRuntime.jsx)(_index2.FieldMessage,{size:v,error:w,text:w?a:s,style:h})]})});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.default=exports.PickerTrigger=exports.DEFAULT_PICKER_TRIGGER_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index2=require("../FieldBase/index.js"),_Chevron=require("../FieldBase/Chevron.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PICKER_TRIGGER_LABELS=exports.DEFAULT_PICKER_TRIGGER_LABELS=Object.freeze({placeholder:"Select…",selection:"Selection",noSelection:"No selection",clear:"Clear"}),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:l,placeholder:t,label:r,help:s,helperText:a,error:n,required:d=!1,onPress:o,clearable:c=!1,onClear:x,leftIcon:u,trailing:_,disabled:g=!1,size:R="md",variant:b,style:T,triggerStyle:y,valueStyle:j,labelStyle:v,messageStyle:h,accessibilityLabel:S,labels:m,testID:E}=e,L=m?{...DEFAULT_PICKER_TRIGGER_LABELS,...m}:DEFAULT_PICKER_TRIGGER_LABELS,P=(0,_index.useTheme)(),p=(0,_react.useMemo)(()=>buildStyles(P),[P]),f=(0,_index.resolveFieldSize)(P,R),F=(0,_index2.resolveFieldTextStyle)(P,{disabled:g}),I="string"==typeof l&&l.length>0,V=!0===n||(0,_index2.hasFieldText)(n),z=(0,_index2.hasFieldText)(r),C=I?l:t??L.placeholder,q=I?F.color:F.placeholderColor,A=I?`${(0,_index2.fieldTextAsString)(r)??L.selection}: ${l}`:t??L.noSelection,G=S??A,k={disabled:g},w=void 0===_,B=c&&I&&!g;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[p.root,T],testID:E,children:[z?(0,_jsxRuntime.jsx)(_index2.FieldLabel,{size:R,required:d,help:s,style:v,children:r}):null,(0,_jsxRuntime.jsx)(_index2.FieldBase,{size:R,variant:b,disabled:g,error:V,filled:I,onPress:o,leading:u,trailing:B||w||null!==_?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:p.trailingRow,children:[B?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",onPress:()=>{g||x?.()},accessibilityRole:"button",accessibilityLabel:L.clear,style:{fontSize:f.icon,color:P.colors["text-muted"],paddingHorizontal:P.space.xs},children:"×"}):null,void 0!==_?_:w?(0,_jsxRuntime.jsx)(_Chevron.Chevron,{size:f.icon,color:g?P.colors["text-disabled"]:P.colors["text-subtle"]}):null]}):null,accessibilityLabel:G,accessibilityState:k,accessibilityRole:"button",style:y,children:(0,_jsxRuntime.jsxs)(_index3.Text,{variant:"body",numberOfLines:1,style:[p.valueText,{color:q,fontSize:f.text,...F.weightStyle},j],children:[C,I||!d||z?null:(0,_jsxRuntime.jsx)(_index2.RequiredMark,{})]})}),(0,_jsxRuntime.jsx)(_index2.FieldMessage,{size:R,error:V,text:V?n:a,style:h})]})});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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ProfileCompletion=exports.DEFAULT_PROFILE_COMPLETION_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Avatar/index.js"),_index4=require("../IconBadge/index.js"),_index5=require("../ProgressRing/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PROFILE_COMPLETION_LABELS=exports.DEFAULT_PROFILE_COMPLETION_LABELS=Object.freeze({summary:(e,r)=>`${e}, profile ${r}% complete`,avatar:e=>`${e}'s avatar`}),AVATAR_PX={sm:32,md:48,lg:64,xl:80},toneColor=(e,r)=>{switch(r){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["text-muted"];default:return e.colors.primary}},DEFAULT_RING_WIDTH=3,DEFAULT_RING_GAP=1,ProfileCompletion=exports.ProfileCompletion=(0,_react.forwardRef)((e,r)=>{const{progress:t,title:i,subtitle:n,description:a,source:s,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:y=!0,showCompleteBadge:f=!0,trailing:b,labels:j,accessibilityLabel:v,style:I,titleStyle:L,subtitleStyle:R,descriptionStyle:h,testID:w}=e;(0,_warnInvalidValue.warnInvalidValue)("ProfileCompletion","size",e.size,["sm","md","lg","xl"]),(0,_warnInvalidValue.warnInvalidValue)("ProfileCompletion","ringVariant",e.ringVariant,["banded","single"]),(0,_warnInvalidValue.warnInvalidValue)("ProfileCompletion","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const P=(0,_index.useTheme)(),A=(0,_react.useMemo)(()=>buildStyles(P),[P]),C=(0,_react.useMemo)(()=>({...DEFAULT_PROFILE_COMPLETION_LABELS,...j}),[j]),T=m??3,E=AVATAR_PX[o]+2*(x+T),V=Math.min(100,Math.max(0,Number.isNaN(t)?0:t)),N=Math.round(V),O=v??C.summary(i,N),D=w??"profile-completion",S=f&&V>=100,M=Math.max(16,Math.round(.3*E)),F=E/2*(1+Math.SQRT1_2)-T/2,q=g??("banded"===_&&null==p?P.colors.success:toneColor(P,p??"primary"));return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:r,style:[A.root,I],testID:w,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:A.summary,accessible:!0,accessibilityRole:"summary",accessibilityLabel:O,accessibilityValue:{min:0,max:100,now:N},testID:`${D}-summary`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{width:E,height:E},children:[(0,_jsxRuntime.jsx)(_index5.ProgressRing,{progress:V/100,size:E,strokeWidth:T,tone:p??"primary",ringColor:g,colorByProgress:"banded"===_&&null==p&&null==g,animated:y,testID:`${D}-ring`,children:(0,_jsxRuntime.jsx)(_index3.Avatar,{name:i,source:s,ImageComponent:l,size:o,tone:c,backgroundColor:u,color:d,accessibilityLabel:C.avatar(i)})}),S?(0,_jsxRuntime.jsx)(_index4.IconBadge,{dimension:M,fill:"surface",icon:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"verify",variant:"bold",size:M-2,color:q}),pointerEvents:"none",style:[A.badge,{left:F-M/2,top:F-M/2}],testID:`${D}-complete-badge`}):null]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:A.body,children:[(0,_jsxRuntime.jsx)(_index6.Text,{variant:"h3",numberOfLines:2,style:L,children:i}),n?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"label",color:"tertiary",numberOfLines:1,style:[A.subtitle,R],children:n}):null,a?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"body",color:"secondary",style:h,children:a}):null]})]}),null!=b?(0,_jsxRuntime.jsx)(_reactNative.View,{style:A.trailing,children:b}):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.default=exports.ProfileCompletion=exports.DEFAULT_PROFILE_COMPLETION_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Avatar/index.js"),_index4=require("../IconBadge/index.js"),_index5=require("../ProgressRing/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PROFILE_COMPLETION_LABELS=exports.DEFAULT_PROFILE_COMPLETION_LABELS=Object.freeze({summary:(e,t)=>`${e}, profile ${t}% complete`,avatar:e=>`${e}'s avatar`}),AVATAR_PX={sm:32,md:48,lg:64,xl:80},toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["text-muted"];default:return e.colors.primary}},DEFAULT_RING_WIDTH=3,DEFAULT_RING_GAP=1,ProfileCompletion=exports.ProfileCompletion=(0,_react.forwardRef)((e,t)=>{const{progress:r,title:i,subtitle:s,description:a,source:n,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:y=!0,showCompleteBadge:f=!0,trailing:b,labels:j,accessibilityLabel:L,style:R,titleStyle:V,subtitleStyle:h,descriptionStyle:v,testID:I}=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 P=(0,_index.useTheme)(),A=(0,_react.useMemo)(()=>buildStyles(P),[P]),C=(0,_react.useMemo)(()=>({...DEFAULT_PROFILE_COMPLETION_LABELS,...j}),[j]),T=m??3,E=AVATAR_PX[o]+2*(x+T),N=Math.min(100,Math.max(0,Number.isNaN(r)?0:r)),w=Math.round(N),O=L??C.summary(i,w),D=I??"profile-completion",S=f&&N>=100,M=Math.max(16,Math.round(.3*E)),F=E/2*(1+Math.SQRT1_2)-T/2,q=g??("banded"===_&&null==p?P.colors.success:toneColor(P,p??"primary"));return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[A.root,R],testID:I,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:A.summary,accessible:!0,accessibilityRole:"summary",accessibilityLabel:O,accessibilityValue:{min:0,max:100,now:w},testID:`${D}-summary`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{width:E,height:E},children:[(0,_jsxRuntime.jsx)(_index5.ProgressRing,{progress:N/100,size:E,strokeWidth:T,tone:p??"primary",ringColor:g,colorByProgress:"banded"===_&&null==p&&null==g,animated:y,testID:`${D}-ring`,children:(0,_jsxRuntime.jsx)(_index3.Avatar,{name:i,source:n,ImageComponent:l,size:o,tone:c,backgroundColor:u,color:d,accessibilityLabel:C.avatar(i)})}),S?(0,_jsxRuntime.jsx)(_index4.IconBadge,{dimension:M,fill:"surface",icon:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"verify",variant:"bold",size:M-2,color:q}),pointerEvents:"none",style:[A.badge,{left:F-M/2,top:F-M/2}],testID:`${D}-complete-badge`}):null]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:A.body,children:[(0,_jsxRuntime.jsx)(_index6.Text,{variant:"h3",numberOfLines:2,style:V,children:i}),s?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"label",color:"tertiary",numberOfLines:1,style:[A.subtitle,h],children:s}):null,a?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"body",color:"secondary",style:v,children:a}):null]})]}),null!=b?(0,_jsxRuntime.jsx)(_reactNative.View,{style:A.trailing,children:b}):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;