@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
@@ -2,7 +2,7 @@
2
2
  "kind": "WeborityPhone",
3
3
  "library": {
4
4
  "name": "@webority/mobile-ui",
5
- "version": "0.144.2"
5
+ "version": "0.146.0"
6
6
  },
7
7
  "rendererProtocolVersion": 13,
8
8
  "platform": "Phone",
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "webority-phone",
3
- "version": "0.144.2",
3
+ "version": "0.146.0",
4
4
  "platform": "Phone",
5
5
  "kitModuleVersion": 2,
6
6
  "rendererProtocolVersion": 13,
7
7
  "library": {
8
8
  "name": "@webority/mobile-ui",
9
- "version": "0.144.2"
9
+ "version": "0.146.0"
10
10
  },
11
11
  "files": {
12
12
  "manifest.json": {
13
- "sha256": "50eb537c2d560a3052e3457c32c9190d2b099ffc6b55d3c16e236113a3e8fbe3",
13
+ "sha256": "1016b09756d6e839d88107c22d3795bc0a2052b0b9d120ad76f97a278f5da90e",
14
14
  "bytes": 664145
15
15
  },
16
16
  "kit.js": {
17
- "sha256": "4152db15f48a2d88dd98927786b7eac1fd4109d92628e0b5c1605e533672c943",
18
- "bytes": 6121660
17
+ "sha256": "d4b21ab009d50eae320f2fe1756b2a1292336fd555be70ae567e998facf832ac",
18
+ "bytes": 6136410
19
19
  },
20
20
  "kit.css": {
21
21
  "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.AccordionGroup=exports.Accordion=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index2=require("../Skeleton/index.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const AccordionGroupContext=(0,_react.createContext)(null),useAccordionGroup=()=>(0,_react.useContext)(AccordionGroupContext),AccordionGroup=({children:e,allowMultiple:t=!1,defaultExpandedKeys:i,expandedKeys:r,onChange:a,style:n,testID:o})=>{const s=void 0!==r,[c,l]=(0,_react.useState)(i??[]),d=s?r:c,u=(0,_react.useCallback)(e=>{s||l(e),a?.(e)},[s,a]),p=(0,_react.useCallback)(e=>{let i;i=d.includes(e)?d.filter(t=>t!==e):t?[...d,e]:[e],u(i)},[d,t,u]),_=(0,_react.useCallback)(e=>d.includes(e),[d]),x=(0,_react.useMemo)(()=>({isExpanded:_,toggle:p,allowMultiple:t}),[_,p,t]);return(0,_jsxRuntime.jsx)(AccordionGroupContext.Provider,{value:x,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:n,testID:o,children:e})})};exports.AccordionGroup=AccordionGroup,AccordionGroup.displayName="AccordionGroup";const Chevron=({rotate:e,color:t})=>{const i=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[chevronStyles.icon,{transform:[{rotate:e}]}],accessible:!1,children:(i.settings.icons.chevronDown??_defaultIcons.defaultIcons.chevronDown)({size:16,color:t})})},chevronStyles=_reactNative.StyleSheet.create({icon:{width:16,height:16,alignItems:"center",justifyContent:"center"}}),Accordion=e=>{const{title:t,children:i,id:r,expanded:a,defaultExpanded:n=!1,onChange:o,icon:s,disabled:c=!1,variant:l="plain",accessibilityLabel:d,style:u,headerStyle:p,contentStyle:_,contentWrapperStyle:x,containerStyle:m,testID:h,loading:v=!1,haptic:y}=e;(0,_warnInvalidValue.warnInvalidValue)("Accordion","variant",e.variant,["plain","card"]);const g=(0,_index.useTheme)(),j=(0,_usePresenceMotion.usePresenceMotion)(),A=j.duration("default"),b=(0,_react.useMemo)(()=>buildStyles(g),[g]),f=useAccordionGroup(),R=void 0!==a,[N,w]=(0,_react.useState)(n),S=f&&r?f.isExpanded(r):null,V=null!==S?S:R?!!a:N,[C,k]=(0,_react.useState)(null),I=(0,_react.useRef)((0,_index.createAnimatedValue)(V?1:0)).current,q=(0,_react.useRef)((0,_index.createAnimatedValue)(V?1:0)).current,D=(0,_react.useRef)((0,_index.createAnimatedValue)(V?1:0)).current,G=(0,_react.useRef)(V);(0,_react.useEffect)(()=>{if(G.current===V)return;G.current=V;const e=V?1:0,t=_reactNative.Easing.bezier(...g.motion.ease["in-out"]),i=_reactNative.Animated.timing(I,{toValue:e,duration:g.motion.duration.default,easing:t,useNativeDriver:!1}),r=_reactNative.Animated.timing(q,{toValue:e,duration:A,easing:t,useNativeDriver:!1}),a=_reactNative.Animated.timing(D,{toValue:e,duration:g.motion.duration.default,easing:t,useNativeDriver:!1}),n=j.reduced&&!V?_reactNative.Animated.sequence([r,_reactNative.Animated.parallel([i,a])]):_reactNative.Animated.parallel([i,r,a]);return n.start(),()=>n.stop()},[V,I,q,D,A,j.reduced,g.motion]);const L=(0,_react.useCallback)(e=>{const t=e.nativeEvent.layout.height;t>0&&t!==C&&k(t)},[C]),M=(0,_react.useCallback)(()=>{if(c)return;const e=(0,_hapticUtils.resolveHaptic)(y,"selection");if(e&&(0,_hapticUtils.triggerHaptic)(e),f&&r)return f.toggle(r),void o?.(!V);R||w(!V),o?.(!V)},[c,f,r,V,R,o,y]),E=D.interpolate({inputRange:[0,1],outputRange:["0deg","180deg"]}),P=null===C?void 0:I.interpolate({inputRange:[0,1],outputRange:[0,C]}),z="card"===l?[b.card,g.shadow.card,{backgroundColor:g.colors.surface,borderRadius:g.radius.md,..._corners.smoothCorners}]:null;return v?(0,_jsxRuntime.jsx)(AccordionSkeleton,{...e}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[z,m,u],testID:h,children:[(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:M,disabled:c,accessibilityRole:"button",accessibilityLabel:d??t,accessibilityState:{expanded:V,disabled:c},"aria-expanded":V,"aria-disabled":c,style:({pressed:e})=>[b.header,p,{opacity:c?.55:e?.85:1}],children:[s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:b.iconLeft,children:s}):null,(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",weight:"semibold",color:c?"disabled":"primary",numberOfLines:2,style:b.title,children:t}),(0,_jsxRuntime.jsx)(Chevron,{rotate:E,color:c?g.colors["text-disabled"]:g.colors["text-muted"]})]}),null===C?(0,_jsxRuntime.jsx)(_reactNative.View,{style:b.measurer,pointerEvents:"none",onLayout:L,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[b.content,_],children:i})}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[b.contentWrapper,null===C?{height:0,opacity:0}:{height:P,opacity:q},x],children:(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:L,style:[b.content,_],children:i})})]})};exports.Accordion=Accordion,Accordion.displayName="Accordion";const AccordionSkeleton=({variant:e="plain",style:t})=>{const i=(0,_index.useTheme)(),r="card"===e;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[r?{paddingHorizontal:i.space.md,paddingVertical:i.space.sm,backgroundColor:i.colors.surface,borderRadius:i.radius.md,..._corners.smoothCorners}:{paddingVertical:i.space.sm},t],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center"},children:[(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:"60%",height:18,style:{flex:1}}),(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:16,height:16,radius:"sm",style:{marginLeft:i.space.sm}})]})})};AccordionSkeleton.displayName="AccordionSkeleton",Accordion.Skeleton=AccordionSkeleton,_reactNative.LayoutAnimation;const buildStyles=e=>_reactNative.StyleSheet.create({card:{paddingHorizontal:e.space.md,paddingVertical:e.space.xs,marginVertical:e.space.xs},header:{flexDirection:"row",alignItems:"center",paddingVertical:e.space.sm},iconLeft:{marginRight:e.space.sm},title:{flex:1},contentWrapper:{overflow:"hidden"},content:{paddingBottom:e.space.sm},measurer:{position:"absolute",opacity:0,left:0,right:0,top:0,zIndex:-1}});var _default=exports.default=Accordion;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.AccordionGroup=exports.Accordion=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"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index2=require("../Skeleton/index.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const AccordionGroupContext=(0,_react.createContext)(null),useAccordionGroup=()=>(0,_react.useContext)(AccordionGroupContext),AccordionGroup=({children:e,allowMultiple:t=!1,defaultExpandedKeys:i,expandedKeys:r,onChange:a,style:n,testID:s})=>{const o=void 0!==r,[c,l]=(0,_react.useState)(i??[]),d=o?r:c,u=(0,_react.useCallback)(e=>{o||l(e),a?.(e)},[o,a]),p=(0,_react.useCallback)(e=>{let i;i=d.includes(e)?d.filter(t=>t!==e):t?[...d,e]:[e],u(i)},[d,t,u]),_=(0,_react.useCallback)(e=>d.includes(e),[d]),x=(0,_react.useMemo)(()=>({isExpanded:_,toggle:p,allowMultiple:t}),[_,p,t]);return(0,_jsxRuntime.jsx)(AccordionGroupContext.Provider,{value:x,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:n,testID:s,children:e})})};exports.AccordionGroup=AccordionGroup,AccordionGroup.displayName="AccordionGroup";const Chevron=({rotate:e,color:t})=>{const i=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[chevronStyles.icon,{transform:[{rotate:e}]}],accessible:!1,children:(i.settings.icons.chevronDown??_defaultIcons.defaultIcons.chevronDown)({size:16,color:t})})},chevronStyles=_reactNative.StyleSheet.create({icon:{width:16,height:16,alignItems:"center",justifyContent:"center"}}),Accordion=e=>{const{title:t,children:i,id:r,expanded:a,defaultExpanded:n=!1,onChange:s,icon:o,disabled:c=!1,variant:l="plain",accessibilityLabel:d,style:u,headerStyle:p,contentStyle:_,contentWrapperStyle:x,containerStyle:m,testID:h,loading:v=!1,haptic:y}=e;(0,_assertValidValue.assertValidValue)("Accordion","variant",e.variant,["plain","card"]);const g=(0,_index.useTheme)(),j=(0,_usePresenceMotion.usePresenceMotion)(),A=j.duration("default"),b=(0,_react.useMemo)(()=>buildStyles(g),[g]),f=useAccordionGroup(),R=void 0!==a,[V,N]=(0,_react.useState)(n),S=f&&r?f.isExpanded(r):null,w=null!==S?S:R?!!a:V,[C,k]=(0,_react.useState)(null),I=(0,_react.useRef)((0,_index.createAnimatedValue)(w?1:0)).current,q=(0,_react.useRef)((0,_index.createAnimatedValue)(w?1:0)).current,D=(0,_react.useRef)((0,_index.createAnimatedValue)(w?1:0)).current,G=(0,_react.useRef)(w);(0,_react.useEffect)(()=>{if(G.current===w)return;G.current=w;const e=w?1:0,t=_reactNative.Easing.bezier(...g.motion.ease["in-out"]),i=_reactNative.Animated.timing(I,{toValue:e,duration:g.motion.duration.default,easing:t,useNativeDriver:!1}),r=_reactNative.Animated.timing(q,{toValue:e,duration:A,easing:t,useNativeDriver:!1}),a=_reactNative.Animated.timing(D,{toValue:e,duration:g.motion.duration.default,easing:t,useNativeDriver:!1}),n=j.reduced&&!w?_reactNative.Animated.sequence([r,_reactNative.Animated.parallel([i,a])]):_reactNative.Animated.parallel([i,r,a]);return n.start(),()=>n.stop()},[w,I,q,D,A,j.reduced,g.motion]);const L=(0,_react.useCallback)(e=>{const t=e.nativeEvent.layout.height;t>0&&t!==C&&k(t)},[C]),M=(0,_react.useCallback)(()=>{if(c)return;const e=(0,_hapticUtils.resolveHaptic)(y,"selection");if(e&&(0,_hapticUtils.triggerHaptic)(e),f&&r)return f.toggle(r),void s?.(!w);R||N(!w),s?.(!w)},[c,f,r,w,R,s,y]),E=D.interpolate({inputRange:[0,1],outputRange:["0deg","180deg"]}),P=null===C?void 0:I.interpolate({inputRange:[0,1],outputRange:[0,C]}),z="card"===l?[b.card,g.shadow.card,{backgroundColor:g.colors.surface,borderRadius:g.radius.md,..._corners.smoothCorners}]:null;return v?(0,_jsxRuntime.jsx)(AccordionSkeleton,{...e}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[z,m,u],testID:h,children:[(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:M,disabled:c,accessibilityRole:"button",accessibilityLabel:d??t,accessibilityState:{expanded:w,disabled:c},"aria-expanded":w,"aria-disabled":c,style:({pressed:e})=>[b.header,p,{opacity:c?.55:e?.85:1}],children:[o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:b.iconLeft,children:o}):null,(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",weight:"semibold",color:c?"disabled":"primary",numberOfLines:2,style:b.title,children:t}),(0,_jsxRuntime.jsx)(Chevron,{rotate:E,color:c?g.colors["text-disabled"]:g.colors["text-muted"]})]}),null===C?(0,_jsxRuntime.jsx)(_reactNative.View,{style:b.measurer,pointerEvents:"none",onLayout:L,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[b.content,_],children:i})}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[b.contentWrapper,null===C?{height:0,opacity:0}:{height:P,opacity:q},x],children:(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:L,style:[b.content,_],children:i})})]})};exports.Accordion=Accordion,Accordion.displayName="Accordion";const AccordionSkeleton=({variant:e="plain",style:t})=>{const i=(0,_index.useTheme)(),r="card"===e;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[r?{paddingHorizontal:i.space.md,paddingVertical:i.space.sm,backgroundColor:i.colors.surface,borderRadius:i.radius.md,..._corners.smoothCorners}:{paddingVertical:i.space.sm},t],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",alignItems:"center"},children:[(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:"60%",height:18,style:{flex:1}}),(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:16,height:16,radius:"sm",style:{marginLeft:i.space.sm}})]})})};AccordionSkeleton.displayName="AccordionSkeleton",Accordion.Skeleton=AccordionSkeleton,_reactNative.LayoutAnimation;const buildStyles=e=>_reactNative.StyleSheet.create({card:{paddingHorizontal:e.space.md,paddingVertical:e.space.xs,marginVertical:e.space.xs},header:{flexDirection:"row",alignItems:"center",paddingVertical:e.space.sm},iconLeft:{marginRight:e.space.sm},title:{flex:1},contentWrapper:{overflow:"hidden"},content:{paddingBottom:e.space.sm},measurer:{position:"absolute",opacity:0,left:0,right:0,top:0,zIndex:-1}});var _default=exports.default=Accordion;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.scaleAmount=exports.default=exports.DEFAULT_AMOUNT_SLIDER_LABELS=exports.AmountSlider=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index3=require("../Input/index.js"),_index4=require("../Slider/index.js"),_valueText=require("../Slider/valueText.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_AMOUNT_SLIDER_LABELS=exports.DEFAULT_AMOUNT_SLIDER_LABELS=Object.freeze({inputLabel:"Amount",thousand:"Thousand",lakh:"Lakh",crore:"Crore",million:"Million",billion:"Billion"}),tiersFor=(e,t)=>"indian"===e?[[1e7,t.crore],[1e5,t.lakh],[1e3,t.thousand]]:[[1e9,t.billion],[1e6,t.million],[1e3,t.thousand]],scaleAmount=(e,t,i=DEFAULT_AMOUNT_SLIDER_LABELS)=>{const n=Math.abs(e);for(const[a,r]of tiersFor(t,i))if(n>=a)return{amount:e/a,unit:r};return{amount:e,unit:""}};exports.scaleAmount=scaleAmount;const formatAmount=(e,t,i)=>{const n=Math.round(100*e)/100;return t?String(n):(0,_mobileCore.formatNumber)(Math.round(e),{grouping:i,maximumFractionDigits:0})},AmountSlider=exports.AmountSlider=(0,_react.forwardRef)((e,t)=>{const{min:i=0,max:n=100,step:a=1,disabled:r=!1,tone:o,size:l,variant:u="inset",currency:s,labels:d,formatInput:c,animationDuration:m,haptic:x,accessibilityLabel:_,style:b,headerStyle:v,valueStyle:h,unitStyle:p,inputStyle:y,sliderStyle:f,testID:S}=e;(0,_warnInvalidValue.warnInvalidValue)("AmountSlider","units",e.units,["indian","international"]),(0,_warnInvalidValue.warnInvalidValue)("AmountSlider","variant",e.variant,["default","inset","minimal","bar"]);const A=(0,_index2.useTheme)(),g=(0,_react.useMemo)(()=>buildStyles(A),[A]),j=m??A.motion.duration.default,L=(0,_react.useMemo)(()=>({...DEFAULT_AMOUNT_SLIDER_LABELS,...d}),[d]),T=e.units??("indian"===(0,_mobileCore.groupingForLocale)((0,_mobileCore.getFormatterConfig)().locale)?"indian":"international"),D=(0,_react.useMemo)(()=>(0,_mobileCore.formatCurrency)(0,{currency:s,maximumFractionDigits:0}).replace(/[\d\s.,]/g,""),[s]),I=(0,_react.useCallback)(e=>(0,_mobileCore.formatCurrency)(e,{currency:s,maximumFractionDigits:0}),[s]),R=c??I,[w,C]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??i,onChange:e.onChange}),E=(0,_valueText.clampValue)(w,i,n),F=(0,_valueText.useValueDraft)({value:E,min:i,max:n,step:a,format:R,onChange:C}),V=scaleAmount(E,T,L),M=""!==V.unit,N=(0,_react.useRef)(E),q=(0,_react.useRef)("up");E!==N.current&&(q.current=E>N.current?"up":"down",N.current=E);const U=q.current,B=`${D}${formatAmount(V.amount,M,T)}${M?` ${V.unit}`:""}`;return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[g.container,b],testID:S,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[g.header,v],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:g.valueRow,accessible:!0,accessibilityRole:"text",accessibilityLabel:B,children:[D?(0,_jsxRuntime.jsxs)(_index5.Text,{variant:"body",style:[g.value,h],children:[D," "]}):null,(0,_jsxRuntime.jsx)(_valueText.RollingText,{text:formatAmount(V.amount,M,T),direction:U,duration:j,style:[g.value,h],testID:S?`${S}-value`:void 0}),M?(0,_jsxRuntime.jsx)(_valueText.RollingText,{text:` ${V.unit}`,direction:U,duration:j,perCharacter:!1,style:[g.unit,p],testID:S?`${S}-unit`:void 0}):null]}),(0,_jsxRuntime.jsx)(_index3.Input,{size:"sm",value:F.text,onChangeText:F.onChangeText,onFocus:F.onFocus,onBlur:F.onBlur,onSubmitEditing:F.onBlur,keyboardType:"number-pad",returnKeyType:"done",disabled:r,accessibilityLabel:L.inputLabel,style:[g.input,y],testID:S?`${S}-input`:void 0})]}),(0,_jsxRuntime.jsx)(_index4.Slider,{value:E,onChange:C,min:i,max:n,step:a,disabled:r,tone:o,size:l,variant:u,haptic:x,accessibilityLabel:_,style:f,testID:S?`${S}-slider`:void 0})]})});AmountSlider.displayName="AmountSlider";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:e.space.md},valueRow:{flexDirection:"row",alignItems:"baseline",flexShrink:1},value:{color:e.colors["text-body"],fontSize:e.text["3xl"].size,fontWeight:e.weight.bold,fontVariant:["tabular-nums"]},unit:{color:e.colors["text-body"],fontSize:e.text.lg.size,fontWeight:e.weight.semibold},input:{width:"45%",maxWidth:180}});var _default=exports.default=AmountSlider;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.scaleAmount=exports.default=exports.DEFAULT_AMOUNT_SLIDER_LABELS=exports.AmountSlider=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index3=require("../Input/index.js"),_index4=require("../Slider/index.js"),_valueText=require("../Slider/valueText.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_AMOUNT_SLIDER_LABELS=exports.DEFAULT_AMOUNT_SLIDER_LABELS=Object.freeze({inputLabel:"Amount",thousand:"Thousand",lakh:"Lakh",crore:"Crore",million:"Million",billion:"Billion"}),tiersFor=(e,t)=>"indian"===e?[[1e7,t.crore],[1e5,t.lakh],[1e3,t.thousand]]:[[1e9,t.billion],[1e6,t.million],[1e3,t.thousand]],scaleAmount=(e,t,i=DEFAULT_AMOUNT_SLIDER_LABELS)=>{const n=Math.abs(e);for(const[a,r]of tiersFor(t,i))if(n>=a)return{amount:e/a,unit:r};return{amount:e,unit:""}};exports.scaleAmount=scaleAmount;const formatAmount=(e,t,i)=>{const n=Math.round(100*e)/100;return t?String(n):(0,_mobileCore.formatNumber)(Math.round(e),{grouping:i,maximumFractionDigits:0})},AmountSlider=exports.AmountSlider=(0,_react.forwardRef)((e,t)=>{const{min:i=0,max:n=100,step:a=1,disabled:r=!1,tone:o,size:l,variant:u="inset",currency:s,labels:d,formatInput:c,animationDuration:m,haptic:x,accessibilityLabel:_,style:b,headerStyle:h,valueStyle:p,unitStyle:y,inputStyle:v,sliderStyle:f,testID:S}=e;(0,_assertValidValue.assertValidValue)("AmountSlider","units",e.units,["indian","international"]),(0,_assertValidValue.assertValidValue)("AmountSlider","variant",e.variant,["default","inset","minimal","bar"]);const A=(0,_index2.useTheme)(),g=(0,_react.useMemo)(()=>buildStyles(A),[A]),j=m??A.motion.duration.default,L=(0,_react.useMemo)(()=>({...DEFAULT_AMOUNT_SLIDER_LABELS,...d}),[d]),T=e.units??("indian"===(0,_mobileCore.groupingForLocale)((0,_mobileCore.getFormatterConfig)().locale)?"indian":"international"),D=(0,_react.useMemo)(()=>(0,_mobileCore.formatCurrency)(0,{currency:s,maximumFractionDigits:0}).replace(/[\d\s.,]/g,""),[s]),R=(0,_react.useCallback)(e=>(0,_mobileCore.formatCurrency)(e,{currency:s,maximumFractionDigits:0}),[s]),C=c??R,[V,E]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??i,onChange:e.onChange}),I=(0,_valueText.clampValue)(V,i,n),w=(0,_valueText.useValueDraft)({value:I,min:i,max:n,step:a,format:C,onChange:E}),F=scaleAmount(I,T,L),M=""!==F.unit,N=(0,_react.useRef)(I),q=(0,_react.useRef)("up");I!==N.current&&(q.current=I>N.current?"up":"down",N.current=I);const U=q.current,B=`${D}${formatAmount(F.amount,M,T)}${M?` ${F.unit}`:""}`;return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[g.container,b],testID:S,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[g.header,h],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:g.valueRow,accessible:!0,accessibilityRole:"text",accessibilityLabel:B,children:[D?(0,_jsxRuntime.jsxs)(_index5.Text,{variant:"body",style:[g.value,p],children:[D," "]}):null,(0,_jsxRuntime.jsx)(_valueText.RollingText,{text:formatAmount(F.amount,M,T),direction:U,duration:j,style:[g.value,p],testID:S?`${S}-value`:void 0}),M?(0,_jsxRuntime.jsx)(_valueText.RollingText,{text:` ${F.unit}`,direction:U,duration:j,perCharacter:!1,style:[g.unit,y],testID:S?`${S}-unit`:void 0}):null]}),(0,_jsxRuntime.jsx)(_index3.Input,{size:"sm",value:w.text,onChangeText:w.onChangeText,onFocus:w.onFocus,onBlur:w.onBlur,onSubmitEditing:w.onBlur,keyboardType:"number-pad",returnKeyType:"done",disabled:r,accessibilityLabel:L.inputLabel,style:[g.input,v],testID:S?`${S}-input`:void 0})]}),(0,_jsxRuntime.jsx)(_index4.Slider,{value:I,onChange:E,min:i,max:n,step:a,disabled:r,tone:o,size:l,variant:u,haptic:x,accessibilityLabel:_,style:f,testID:S?`${S}-slider`:void 0})]})});AmountSlider.displayName="AmountSlider";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:e.space.md},valueRow:{flexDirection:"row",alignItems:"baseline",flexShrink:1},value:{color:e.colors["text-body"],fontSize:e.text["3xl"].size,fontWeight:e.weight.bold,fontVariant:["tabular-nums"]},unit:{color:e.colors["text-body"],fontSize:e.text.lg.size,fontWeight:e.weight.semibold},input:{width:"45%",maxWidth:180}});var _default=exports.default=AmountSlider;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.AnimatePresence=void 0;var cache,_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,n,r=Object.defineProperty,i={__proto__:null,default:e};if(Object(e)!==e)return i;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,i)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((t=r&&Object.getOwnPropertyDescriptor(e,n))&&(t.get||t.set)?r(i,n,t):i[n]=e[n]);return i}const AnimatePresence=({children:e,preset:a="fade",duration:t,style:n,testID:r})=>{(0,_warnInvalidValue.warnInvalidValue)("AnimatePresence","preset",a,["fade","scale","slide-up","slide-down"]);const i=(0,_usePresenceMotion.usePresenceMotion)();if(!(null!=e&&!1!==e))return null;const d=t??i.duration("default");let c,u;if(i.reduced)c=_reactNativeReanimated.FadeIn.duration(d).reduceMotion(_usePresenceMotion.PRESENCE_REDUCE_MOTION),u=_reactNativeReanimated.FadeOut.duration(d).reduceMotion(_usePresenceMotion.PRESENCE_REDUCE_MOTION);else switch(a){case"scale":c=_reactNativeReanimated.ZoomIn.duration(d),u=_reactNativeReanimated.ZoomOut.duration(d);break;case"slide-up":c=_reactNativeReanimated.FadeInUp.duration(d),u=_reactNativeReanimated.FadeOutDown.duration(d);break;case"slide-down":c=_reactNativeReanimated.FadeInDown.duration(d),u=_reactNativeReanimated.FadeOutUp.duration(d);break;default:c=_reactNativeReanimated.FadeIn.duration(d),u=_reactNativeReanimated.FadeOut.duration(d)}return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{entering:c,exiting:u,style:n,testID:r,children:e})};exports.AnimatePresence=AnimatePresence,AnimatePresence.displayName="AnimatePresence";var _default=exports.default=AnimatePresence;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.AnimatePresence=void 0;var cache,_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,i=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)&&((a=i&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?i(n,r,a):n[r]=e[r]);return n}const AnimatePresence=({children:e,preset:t="fade",duration:a,style:r,testID:i})=>{(0,_assertValidValue.assertValidValue)("AnimatePresence","preset",t,["fade","scale","slide-up","slide-down"]);const n=(0,_usePresenceMotion.usePresenceMotion)();if(!(null!=e&&!1!==e))return null;const s=a??n.duration("default");let d,c;if(n.reduced)d=_reactNativeReanimated.FadeIn.duration(s).reduceMotion(_usePresenceMotion.PRESENCE_REDUCE_MOTION),c=_reactNativeReanimated.FadeOut.duration(s).reduceMotion(_usePresenceMotion.PRESENCE_REDUCE_MOTION);else switch(t){case"scale":d=_reactNativeReanimated.ZoomIn.duration(s),c=_reactNativeReanimated.ZoomOut.duration(s);break;case"slide-up":d=_reactNativeReanimated.FadeInUp.duration(s),c=_reactNativeReanimated.FadeOutDown.duration(s);break;case"slide-down":d=_reactNativeReanimated.FadeInDown.duration(s),c=_reactNativeReanimated.FadeOutUp.duration(s);break;default:d=_reactNativeReanimated.FadeIn.duration(s),c=_reactNativeReanimated.FadeOut.duration(s)}return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{entering:d,exiting:c,style:r,testID:i,children:e})};exports.AnimatePresence=AnimatePresence,AnimatePresence.displayName="AnimatePresence";var _default=exports.default=AnimatePresence;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_APP_BAR_LABELS=exports.AppBar=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_index2=require("../Menu/index.js"),_Text=require("../Text/Text.js"),_jsxRuntime=require("react/jsx-runtime");const ACTION_BUTTON_SIZE=44,DOT_OFFSET=10,DOT_SIZE=8,BADGE_OFFSET=4,DEFAULT_APP_BAR_LABELS=exports.DEFAULT_APP_BAR_LABELS=Object.freeze({back:"Back"}),variantSize=(e,t)=>{switch(t){case"compact":return{height:44,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1};case"large":return{height:56,titleSize:e.text["2xl"].size,titleWeight:"bold",subtitleLines:2};default:return{height:56,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1}}},ActionButton=(0,_react.forwardRef)(({action:e,side:t,badgeStyle:i,haptic:n,flush:a,onPress:l},r)=>{const s=(0,_index.useTheme)(),{style:o,pressIn:c,pressOut:d}=(0,_usePressAnimation.usePressAnimation)({enabled:!0}),u=(0,_react.useMemo)(()=>buildActionStyles(s),[s]),p=e.badge,h=void 0!==p&&0!==p,x=void 0!==e.label;return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:o,children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:r,onPress:t=>{const i=(0,_hapticUtils.resolveHaptic)(n,"selection");i&&(0,_hapticUtils.triggerHaptic)(i),"onPress"in e&&e.onPress(),l?.(t)},onPressIn:c,onPressOut:d,accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,testID:e.testID,android_ripple:{color:s.colors["surface-pressed"],borderless:!x},style:({pressed:e})=>[x?u.textButton:u.actionButton,a?null:"left"===t?u.actionLeft:u.actionRight,e&&!x?u.actionPressed:null,e&&x?u.textPressed:null],children:[x?(0,_jsxRuntime.jsx)(_Text.Text,{variant:"body",weight:"semibold",color:"link",numberOfLines:1,children:e.label}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.iconWrap,children:e.icon}),h?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[u.badge,i],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_Text.Text,{variant:"caption",weight:"semibold",numberOfLines:1,style:u.badgeText,children:String(p)})}):null,e.dot?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:e.testID?`${e.testID}-dot`:"appbar-action-dot",style:u.dot,pointerEvents:"none"}):null]})})}),COLLAPSE_RANGE=60,AppBar=exports.AppBar=(0,_react.forwardRef)((e,t)=>{const{title:i,subtitle:n,titleAlignment:a="left",leftAction:l,rightActions:r,leading:s,trailing:o,onBack:c,gutter:d,titleVariant:u,titleOffset:p,height:h,divider:x,elevated:g=!1,variant:m="default",transparent:_=!1,scrollY:b,style:f,containerStyle:j,titleStyle:v,subtitleStyle:y,badgeStyle:A,haptic:R,labels:S,testID:w}=e;(0,_warnInvalidValue.warnInvalidValue)("AppBar","variant",e.variant,["default","large","compact"]),(0,_warnInvalidValue.warnInvalidValue)("AppBar","titleAlignment",e.titleAlignment,["left","center"]);const I=(0,_react.useMemo)(()=>({...DEFAULT_APP_BAR_LABELS,...S}),[S]),B=(0,_index.useTheme)(),L=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),N=(0,_react.useMemo)(()=>variantSize(B,m),[B,m]),T=(0,_react.useMemo)(()=>buildStyles(B),[B]),P="large"===m,C=P&&void 0!==b,[z,V]=(0,_react.useState)(40),O=(0,_react.useCallback)(e=>V(e.nativeEvent.layout.height),[]),E=l??(c?{icon:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:"arrow-left",size:24,color:B.colors["text-body"]}),onPress:c,accessibilityLabel:I.back}:void 0),D=o?void 0:r?.[r.length-1],opticalInset=e=>void 0===e?0:void 0!==e.label?B.space.sm:Math.max((44-(e.glyphSize??24))/2,0),W=void 0===d?null:{paddingLeft:Math.max(d-opticalInset(E),0),paddingRight:Math.max(d-opticalInset(D),0)},k=void 0!==p,F=Boolean(E)||Boolean(s),q=!k&&"left"===a&&Boolean(E),H=k||q||!F&&"left"===a,M="default"!==m||F?N.titleSize:B.text.xl.size,U=x??!1,$=_reactNative.StyleSheet.hairlineWidth,G=(0,_react.useMemo)(()=>b?{rootHeight:b.interpolate({inputRange:[0,60],outputRange:[L.top+N.height+z,L.top+N.height],extrapolate:"clamp"}),titleRowOpacity:b.interpolate({inputRange:[0,30],outputRange:[1,0],extrapolate:"clamp"}),compactTitleOpacity:b.interpolate({inputRange:[30,60],outputRange:[0,1],extrapolate:"clamp"}),borderOpacity:b.interpolate({inputRange:[0,60],outputRange:[0,1],extrapolate:"clamp"})}:null,[b,L.top,N.height,z]),Z=i?u?(0,_jsxRuntime.jsx)(_Text.Text,{variant:u,align:"center"===a?"center":"left",accessibilityRole:"header",numberOfLines:1,style:[T.titleVariant,v],children:i}):(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityRole:"header",style:[T.title,{fontSize:M,fontWeight:B.weight[N.titleWeight],textAlign:"center"===a?"center":"left"},n?T.stackedText:null,v],numberOfLines:1,children:i}):null,Y=C&&G&&i?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:[T.title,{fontSize:B.text.lg.size,fontWeight:B.weight.semibold,textAlign:"center"===a?"center":"left",opacity:G.compactTitleOpacity}],numberOfLines:1,children:i}):null,J=n?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{style:[T.subtitle,{textAlign:"center"===a?"center":"left"},y],numberOfLines:N.subtitleLines,children:n}):null,K=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[T.titleColumn,"center"===a?T.titleColumnCenter:null],children:[Z,J]}),Q=C?_reactNative.Animated.View:_reactNative.View,X=C&&G?{height:G.rootHeight,overflow:"hidden"}:P&&void 0===h?null:{height:(h??N.height)+L.top};return(0,_jsxRuntime.jsxs)(Q,{ref:t,testID:w,style:[T.root,{paddingTop:L.top,backgroundColor:_?"transparent":B.colors.surface},X,!C&&U?{borderBottomWidth:$,borderBottomColor:B.colors.border}:null,g&&!_?B.shadow.card:null,j,f],children:[C&&G&&U?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[T.animatedBorder,{backgroundColor:B.colors.border,opacity:G.borderOpacity}]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:P&&w?`${w}-bar-row`:void 0,style:[T.row,P?{height:N.height}:{flex:1},W],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:w?`${w}-leading-slot`:void 0,style:[T.sideSlot,H?T.sideSlotCompact:null],children:[E?(0,_jsxRuntime.jsx)(ActionButton,{action:E,side:"left",haptic:R,flush:k||q}):null,null!=s&&!1!==s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:T.slotNode,children:s}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[T.center,"center"===a?T.centerAligned:T.centerLeft,k?{paddingLeft:F?p:B.space.none,paddingRight:B.space.none}:H?{paddingLeft:B.space.none}:null],children:P?Y:K}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[T.sideSlot,T.sideSlotRight,k?T.sideSlotCompact:null],children:[r?.map((e,t)=>(0,_jsxRuntime.jsx)(_react.Fragment,{children:"menu"in e?(0,_jsxRuntime.jsx)(_index2.Menu,{items:e.menu,title:e.menuTitle,haptic:R,trigger:(0,_jsxRuntime.jsx)(ActionButton,{action:e,side:"right",badgeStyle:A,haptic:R,flush:k})}):(0,_jsxRuntime.jsx)(ActionButton,{action:e,side:"right",badgeStyle:A,haptic:R,flush:k})},`appbar-right-${t}`)),null!=o&&!1!==o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:T.slotNode,children:o}):null]})]}),P?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{testID:w?`${w}-title-row`:void 0,onLayout:C?O:void 0,pointerEvents:"none",style:[{paddingHorizontal:d??B.space.md,paddingBottom:B.space.sm},C&&G?{opacity:G.titleRowOpacity}:null],children:K}):null]})});AppBar.displayName="AppBar";const buildStyles=e=>_reactNative.StyleSheet.create({root:{width:"100%"},row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.xs},sideSlot:{flexDirection:"row",alignItems:"center",minWidth:48},sideSlotRight:{justifyContent:"flex-end"},sideSlotCompact:{minWidth:0},slotNode:{flexDirection:"row",alignItems:"center"},center:{flex:1,minWidth:0,paddingHorizontal:e.space.xs},centerAligned:{alignItems:"center"},centerLeft:{alignItems:"flex-start"},titleColumn:{flexDirection:"column",maxWidth:"100%"},titleColumnCenter:{alignItems:"center"},title:{color:e.colors["text-body"]},titleVariant:{includeFontPadding:!1,textAlignVertical:"center"},stackedText:{includeFontPadding:!1},subtitle:{includeFontPadding:!1,color:e.colors["text-subtle"],fontSize:e.text.sm.size,fontWeight:e.weight.normal},animatedBorder:{position:"absolute",left:0,right:0,bottom:0,height:_reactNative.StyleSheet.hairlineWidth}}),buildActionStyles=e=>_reactNative.StyleSheet.create({actionButton:{width:44,height:44,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},actionLeft:{marginRight:e.space.xs},actionRight:{marginLeft:e.space.xs},actionPressed:{backgroundColor:e.colors["surface-pressed"]},textButton:{minWidth:44,minHeight:44,paddingHorizontal:e.space.sm,alignItems:"center",justifyContent:"center"},textPressed:{opacity:.6},dot:{position:"absolute",top:10,right:10,width:8,height:8,borderRadius:e.radius.pill,backgroundColor:e.colors.danger},iconWrap:{alignItems:"center",justifyContent:"center"},badge:{position:"absolute",top:4,right:4,minWidth:16,height:16,paddingHorizontal:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors.danger,alignItems:"center",justifyContent:"center"},badgeText:{color:e.colors["on-danger"],fontSize:e.text.xs.size,fontWeight:e.weight.semibold,lineHeight:13}});var _default=exports.default=AppBar;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_APP_BAR_LABELS=exports.AppBar=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_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"),_AppIcon=require("../AppIcon/AppIcon.js"),_index2=require("../Menu/index.js"),_Text=require("../Text/Text.js"),_jsxRuntime=require("react/jsx-runtime");const ACTION_BUTTON_SIZE=44,DOT_OFFSET=10,DOT_SIZE=8,BADGE_OFFSET=4,DEFAULT_APP_BAR_LABELS=exports.DEFAULT_APP_BAR_LABELS=Object.freeze({back:"Back"}),variantSize=(e,t)=>{switch(t){case"compact":return{height:44,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1};case"large":return{height:56,titleSize:e.text["2xl"].size,titleWeight:"bold",subtitleLines:2};default:return{height:56,titleSize:e.text.lg.size,titleWeight:"semibold",subtitleLines:1}}},ActionButton=(0,_react.forwardRef)(({action:e,side:t,badgeStyle:i,haptic:n,flush:a,onPress:s},l)=>{const r=(0,_index.useTheme)(),{style:o,pressIn:c,pressOut:d}=(0,_usePressAnimation.usePressAnimation)({enabled:!0}),u=(0,_react.useMemo)(()=>buildActionStyles(r),[r]),p=e.badge,h=void 0!==p&&0!==p,x=void 0!==e.label;return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:o,children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{ref:l,onPress:t=>{const i=(0,_hapticUtils.resolveHaptic)(n,"selection");i&&(0,_hapticUtils.triggerHaptic)(i),"onPress"in e&&e.onPress(),s?.(t)},onPressIn:c,onPressOut:d,accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,testID:e.testID,android_ripple:{color:r.colors["surface-pressed"],borderless:!x},style:({pressed:e})=>[x?u.textButton:u.actionButton,a?null:"left"===t?u.actionLeft:u.actionRight,e&&!x?u.actionPressed:null,e&&x?u.textPressed:null],children:[x?(0,_jsxRuntime.jsx)(_Text.Text,{variant:"body",weight:"semibold",color:"link",numberOfLines:1,children:e.label}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.iconWrap,children:e.icon}),h?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[u.badge,i],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_Text.Text,{variant:"caption",weight:"semibold",numberOfLines:1,style:u.badgeText,children:String(p)})}):null,e.dot?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:e.testID?`${e.testID}-dot`:"appbar-action-dot",style:u.dot,pointerEvents:"none"}):null]})})}),COLLAPSE_RANGE=60,AppBar=exports.AppBar=(0,_react.forwardRef)((e,t)=>{const{title:i,subtitle:n,titleAlignment:a="left",leftAction:s,rightActions:l,leading:r,trailing:o,onBack:c,gutter:d,titleVariant:u,titleOffset:p,height:h,divider:x,elevated:g=!1,variant:m="default",transparent:_=!1,scrollY:b,style:f,containerStyle:j,titleStyle:y,subtitleStyle:v,badgeStyle:A,haptic:R,labels:S,testID:w}=e;(0,_assertValidValue.assertValidValue)("AppBar","variant",e.variant,["default","large","compact"]),(0,_assertValidValue.assertValidValue)("AppBar","titleAlignment",e.titleAlignment,["left","center"]);const B=(0,_react.useMemo)(()=>({...DEFAULT_APP_BAR_LABELS,...S}),[S]),L=(0,_index.useTheme)(),N=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),T=(0,_react.useMemo)(()=>variantSize(L,m),[L,m]),I=(0,_react.useMemo)(()=>buildStyles(L),[L]),V="large"===m,P=V&&void 0!==b,[C,z]=(0,_react.useState)(40),O=(0,_react.useCallback)(e=>z(e.nativeEvent.layout.height),[]),E=s??(c?{icon:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:"arrow-left",size:24,color:L.colors["text-body"]}),onPress:c,accessibilityLabel:B.back}:void 0),D=o?void 0:l?.[l.length-1],opticalInset=e=>void 0===e?0:void 0!==e.label?L.space.sm:Math.max((44-(e.glyphSize??24))/2,0),W=void 0===d?null:{paddingLeft:Math.max(d-opticalInset(E),0),paddingRight:Math.max(d-opticalInset(D),0)},k=void 0!==p,F=Boolean(E)||Boolean(r),q=!k&&"left"===a&&Boolean(E),H=k||q||!F&&"left"===a,M="default"!==m||F?T.titleSize:L.text.xl.size,U=x??!1,$=_reactNative.StyleSheet.hairlineWidth,G=(0,_react.useMemo)(()=>b?{rootHeight:b.interpolate({inputRange:[0,60],outputRange:[N.top+T.height+C,N.top+T.height],extrapolate:"clamp"}),titleRowOpacity:b.interpolate({inputRange:[0,30],outputRange:[1,0],extrapolate:"clamp"}),compactTitleOpacity:b.interpolate({inputRange:[30,60],outputRange:[0,1],extrapolate:"clamp"}),borderOpacity:b.interpolate({inputRange:[0,60],outputRange:[0,1],extrapolate:"clamp"})}:null,[b,N.top,T.height,C]),Z=i?u?(0,_jsxRuntime.jsx)(_Text.Text,{variant:u,align:"center"===a?"center":"left",accessibilityRole:"header",numberOfLines:1,style:[I.titleVariant,y],children:i}):(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityRole:"header",style:[I.title,{fontSize:M,fontWeight:L.weight[T.titleWeight],textAlign:"center"===a?"center":"left"},n?I.stackedText:null,y],numberOfLines:1,children:i}):null,Y=P&&G&&i?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:[I.title,{fontSize:L.text.lg.size,fontWeight:L.weight.semibold,textAlign:"center"===a?"center":"left",opacity:G.compactTitleOpacity}],numberOfLines:1,children:i}):null,J=n?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{style:[I.subtitle,{textAlign:"center"===a?"center":"left"},v],numberOfLines:T.subtitleLines,children:n}):null,K=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[I.titleColumn,"center"===a?I.titleColumnCenter:null],children:[Z,J]}),Q=P?_reactNative.Animated.View:_reactNative.View,X=P&&G?{height:G.rootHeight,overflow:"hidden"}:V&&void 0===h?null:{height:(h??T.height)+N.top};return(0,_jsxRuntime.jsxs)(Q,{ref:t,testID:w,style:[I.root,{paddingTop:N.top,backgroundColor:_?"transparent":L.colors.surface},X,!P&&U?{borderBottomWidth:$,borderBottomColor:L.colors.border}:null,g&&!_?L.shadow.card:null,j,f],children:[P&&G&&U?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[I.animatedBorder,{backgroundColor:L.colors.border,opacity:G.borderOpacity}]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:V&&w?`${w}-bar-row`:void 0,style:[I.row,V?{height:T.height}:{flex:1},W],children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:w?`${w}-leading-slot`:void 0,style:[I.sideSlot,H?I.sideSlotCompact:null],children:[E?(0,_jsxRuntime.jsx)(ActionButton,{action:E,side:"left",haptic:R,flush:k||q}):null,null!=r&&!1!==r?(0,_jsxRuntime.jsx)(_reactNative.View,{style:I.slotNode,children:r}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[I.center,"center"===a?I.centerAligned:I.centerLeft,k?{paddingLeft:F?p:L.space.none,paddingRight:L.space.none}:H?{paddingLeft:L.space.none}:null],children:V?Y:K}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[I.sideSlot,I.sideSlotRight,k?I.sideSlotCompact:null],children:[l?.map((e,t)=>(0,_jsxRuntime.jsx)(_react.Fragment,{children:"menu"in e?(0,_jsxRuntime.jsx)(_index2.Menu,{items:e.menu,title:e.menuTitle,haptic:R,trigger:(0,_jsxRuntime.jsx)(ActionButton,{action:e,side:"right",badgeStyle:A,haptic:R,flush:k})}):(0,_jsxRuntime.jsx)(ActionButton,{action:e,side:"right",badgeStyle:A,haptic:R,flush:k})},`appbar-right-${t}`)),null!=o&&!1!==o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:I.slotNode,children:o}):null]})]}),V?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{testID:w?`${w}-title-row`:void 0,onLayout:P?O:void 0,pointerEvents:"none",style:[{paddingHorizontal:d??L.space.md,paddingBottom:L.space.sm},P&&G?{opacity:G.titleRowOpacity}:null],children:K}):null]})});AppBar.displayName="AppBar";const buildStyles=e=>_reactNative.StyleSheet.create({root:{width:"100%"},row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.xs},sideSlot:{flexDirection:"row",alignItems:"center",minWidth:48},sideSlotRight:{justifyContent:"flex-end"},sideSlotCompact:{minWidth:0},slotNode:{flexDirection:"row",alignItems:"center"},center:{flex:1,minWidth:0,paddingHorizontal:e.space.xs},centerAligned:{alignItems:"center"},centerLeft:{alignItems:"flex-start"},titleColumn:{flexDirection:"column",maxWidth:"100%"},titleColumnCenter:{alignItems:"center"},title:{color:e.colors["text-body"]},titleVariant:{includeFontPadding:!1,textAlignVertical:"center"},stackedText:{includeFontPadding:!1},subtitle:{includeFontPadding:!1,color:e.colors["text-subtle"],fontSize:e.text.sm.size,fontWeight:e.weight.normal},animatedBorder:{position:"absolute",left:0,right:0,bottom:0,height:_reactNative.StyleSheet.hairlineWidth}}),buildActionStyles=e=>_reactNative.StyleSheet.create({actionButton:{width:44,height:44,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center"},actionLeft:{marginRight:e.space.xs},actionRight:{marginLeft:e.space.xs},actionPressed:{backgroundColor:e.colors["surface-pressed"]},textButton:{minWidth:44,minHeight:44,paddingHorizontal:e.space.sm,alignItems:"center",justifyContent:"center"},textPressed:{opacity:.6},dot:{position:"absolute",top:10,right:10,width:8,height:8,borderRadius:e.radius.pill,backgroundColor:e.colors.danger},iconWrap:{alignItems:"center",justifyContent:"center"},badge:{position:"absolute",top:4,right:4,minWidth:16,height:16,paddingHorizontal:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors.danger,alignItems:"center",justifyContent:"center"},badgeText:{color:e.colors["on-danger"],fontSize:e.text.xs.size,fontWeight:e.weight.semibold,lineHeight:13}});var _default=exports.default=AppBar;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppIcon=exports.APP_ICON_SIZES=void 0,Object.defineProperty(exports,"CURATED_ICON_NAMES",{enumerable:!0,get:function(){return _glyphsG.CURATED_ICON_NAMES}}),exports.ICONSAX_SUFFIX=void 0,Object.defineProperty(exports,"ICON_NAMES",{enumerable:!0,get:function(){return _catalogG.ICON_NAMES}}),exports.resolveGlyph=exports.default=exports.buildIconXml=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNativeSvg=require("react-native-svg"),_index=require("../../theme/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_Text=require("../Text/Text.js"),_catalogG=require("./catalog.g.js"),_glyphsG=require("./glyphs.g.js"),_jsxRuntime=require("react/jsx-runtime");const ICONSAX_SUFFIX=exports.ICONSAX_SUFFIX="-iconsax",APP_ICON_SIZES=exports.APP_ICON_SIZES={xs:14,sm:18,md:22,lg:28,xl:36},tryRequire=e=>{try{return e()}catch{return null}};let curatedVariants=null;const loadCuratedVariants=()=>(curatedVariants||(curatedVariants=tryRequire(()=>require("./variants.g").VARIANT_GLYPHS)??{}),curatedVariants),shardCache=new Map,loadShard=(e,r)=>{const t=r[0]?.toLowerCase()??"",n=`${e}:${t}`,a=shardCache.get(n);if(void 0!==a)return a;const o=_catalogG.CATALOG_LOADERS[e]?.[t],l=o?tryRequire(o):null;return shardCache.set(n,l),l},warned=new Set,resolveCatalogue=(e,r)=>{const t=loadShard(r,e)?.[e];return t||("linear"===r?null:loadShard("linear",e)?.[e]??null)},resolveGlyph=(e,r="linear")=>{if(e.endsWith(ICONSAX_SUFFIX)){const t=e.slice(0,-ICONSAX_SUFFIX.length);return t in _glyphsG.GLYPHS?resolveCatalogue(t,r):null}const t=_glyphsG.GLYPHS[e];return t?"linear"===r?t:loadCuratedVariants()[r]?.[e]??t:resolveCatalogue(e,r)};exports.resolveGlyph=resolveGlyph;const buildIconXml=(e,r,t)=>`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${r}" viewBox="0 0 24 24" fill="none">${e.replace(/currentColor/g,t)}</svg>`;exports.buildIconXml=buildIconXml;const iconXmlCache=new Map,AppIcon=({name:e,size:r="md",color:t,variant:n="linear",style:a,accessibilityLabel:o,testID:l})=>{const i=(0,_index.useTheme)();"string"==typeof r&&(0,_warnInvalidValue.warnInvalidValue)("AppIcon","size",r,Object.keys(APP_ICON_SIZES)),(0,_warnInvalidValue.warnInvalidValue)("AppIcon","variant",n,["linear","bold","bulk","broken","outline","twotone"]);const s="number"==typeof r?r:APP_ICON_SIZES[r]??APP_ICON_SIZES.md,c=void 0===t?i.colors["text-body"]:(0,_Text.resolveColor)(i,t),u=resolveGlyph(e,n),d=(0,_react.useMemo)(()=>{if(!u)return null;const r=`${e}|${n}|${s}|${c}`,t=iconXmlCache.get(r);if(void 0!==t)return t;iconXmlCache.size>=500&&iconXmlCache.clear();const a=buildIconXml(u,s,c);return iconXmlCache.set(r,a),a},[e,n,u,s,c]);return d?(0,_jsxRuntime.jsx)(_reactNativeSvg.SvgXml,{xml:d,width:s,height:s,style:a,accessible:null!=o,accessibilityLabel:o,accessibilityRole:null!=o?"image":void 0,testID:l}):(__DEV__&&!warned.has(e)&&(warned.add(e),_mobileCore.Logger.warn(`[@webority/mobile-ui] AppIcon: Unknown icon "${e}". Names come from webority-ui's icon map and the Iconsax catalogue; run node scripts/gen-icons.mjs after adding one there.`)),null)};exports.AppIcon=AppIcon,AppIcon.displayName="AppIcon";var _default=exports.default=AppIcon;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AppIcon=exports.APP_ICON_SIZES=void 0,Object.defineProperty(exports,"CURATED_ICON_NAMES",{enumerable:!0,get:function(){return _glyphsG.CURATED_ICON_NAMES}}),exports.ICONSAX_SUFFIX=void 0,Object.defineProperty(exports,"ICON_NAMES",{enumerable:!0,get:function(){return _catalogG.ICON_NAMES}}),exports.resolveGlyph=exports.default=exports.buildIconXml=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNativeSvg=require("react-native-svg"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_Text=require("../Text/Text.js"),_catalogG=require("./catalog.g.js"),_glyphsG=require("./glyphs.g.js"),_jsxRuntime=require("react/jsx-runtime");const ICONSAX_SUFFIX=exports.ICONSAX_SUFFIX="-iconsax",APP_ICON_SIZES=exports.APP_ICON_SIZES={xs:14,sm:18,md:22,lg:28,xl:36},tryRequire=e=>{try{return e()}catch{return null}};let curatedVariants=null;const loadCuratedVariants=()=>(curatedVariants||(curatedVariants=tryRequire(()=>require("./variants.g").VARIANT_GLYPHS)??{}),curatedVariants),shardCache=new Map,loadShard=(e,r)=>{const t=r[0]?.toLowerCase()??"",a=`${e}:${t}`,o=shardCache.get(a);if(void 0!==o)return o;const l=_catalogG.CATALOG_LOADERS[e]?.[t],n=l?tryRequire(l):null;return shardCache.set(a,n),n},warned=new Set,resolveCatalogue=(e,r)=>{const t=loadShard(r,e)?.[e];return t||("linear"===r?null:loadShard("linear",e)?.[e]??null)},resolveGlyph=(e,r="linear")=>{if(e.endsWith(ICONSAX_SUFFIX)){const t=e.slice(0,-ICONSAX_SUFFIX.length);return t in _glyphsG.GLYPHS?resolveCatalogue(t,r):null}const t=_glyphsG.GLYPHS[e];return t?"linear"===r?t:loadCuratedVariants()[r]?.[e]??t:resolveCatalogue(e,r)};exports.resolveGlyph=resolveGlyph;const buildIconXml=(e,r,t)=>`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${r}" viewBox="0 0 24 24" fill="none">${e.replace(/currentColor/g,t)}</svg>`;exports.buildIconXml=buildIconXml;const iconXmlCache=new Map,AppIcon=({name:e,size:r="md",color:t,variant:a="linear",style:o,accessibilityLabel:l,testID:n})=>{const s=(0,_index.useTheme)();"string"==typeof r&&(0,_assertValidValue.assertValidValue)("AppIcon","size",r,Object.keys(APP_ICON_SIZES)),(0,_assertValidValue.assertValidValue)("AppIcon","variant",a,["linear","bold","bulk","broken","outline","twotone"]);const i="number"==typeof r?r:APP_ICON_SIZES[r]??APP_ICON_SIZES.md,c=void 0===t?s.colors["text-body"]:(0,_Text.resolveColor)(s,t),u=resolveGlyph(e,a),d=(0,_react.useMemo)(()=>{if(!u)return null;const r=`${e}|${a}|${i}|${c}`,t=iconXmlCache.get(r);if(void 0!==t)return t;iconXmlCache.size>=500&&iconXmlCache.clear();const o=buildIconXml(u,i,c);return iconXmlCache.set(r,o),o},[e,a,u,i,c]);return d?(0,_jsxRuntime.jsx)(_reactNativeSvg.SvgXml,{xml:d,width:i,height:i,style:o,accessible:null!=l,accessibilityLabel:l,accessibilityRole:null!=l?"image":void 0,testID:n}):(__DEV__&&!warned.has(e)&&(warned.add(e),_mobileCore.Logger.warn(`[@webority/mobile-ui] AppIcon: Unknown icon "${e}". Names come from webority-ui's icon map and the Iconsax catalogue; run node scripts/gen-icons.mjs after adding one there.`)),null)};exports.AppIcon=AppIcon,AppIcon.displayName="AppIcon";var _default=exports.default=AppIcon;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_ASYNC_BLOCK_LABELS=exports.AsyncBlock=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../EmptyState/index.js"),_index4=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_ASYNC_BLOCK_LABELS=exports.DEFAULT_ASYNC_BLOCK_LABELS=Object.freeze({emptyTitle:"Nothing here yet",errorTitle:"That didn't load",offlineTitle:"You're offline",offlineHint:"Check your connection, then try again.",retry:"Try again"}),isNode=e=>(0,_react.isValidElement)(e)||Array.isArray(e),AsyncBlock=({loading:e=!1,error:t,errorVariant:i,empty:r=!1,onRetry:n,skeleton:l,emptyTitle:s,emptyDescription:o,emptyIcon:a,errorTitle:c,offlineTitle:_,labels:d,children:u,style:x,testID:m})=>{const y=(0,_index.useTheme)(),f=(0,_react.useMemo)(()=>({...DEFAULT_ASYNC_BLOCK_LABELS,...d}),[d]);if((0,_warnInvalidValue.warnInvalidValue)("AsyncBlock","errorVariant",i,["default","offline"]),e)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:x,testID:m,children:l??(0,_jsxRuntime.jsx)(_reactNative.View,{style:{paddingVertical:y.space["2xl"],alignItems:"center"},children:(0,_jsxRuntime.jsx)(_index4.Spinner,{})})});if(t){const e="string"==typeof t?t:null,r=null!==e||isNode(t)?null:(0,_mobileCore.extractApiError)(t),l="offline"===(i??(r?.code===_mobileCore.OFFLINE_CODE?"offline":"default")),s=e??r?.message??(l?f.offlineHint:void 0);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:x,testID:m,children:[(0,_jsxRuntime.jsx)(_index3.EmptyState,{icon:l?(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"cloud-cross",size:"xl",color:y.colors["text-subtle"],testID:"async-block-offline-icon"}):void 0,title:l?_??f.offlineTitle:c??f.errorTitle,description:s,action:n?{label:f.retry,onPress:n}:void 0}),isNode(t)?t:null]})}return r?(0,_jsxRuntime.jsx)(_reactNative.View,{style:x,testID:m,children:(0,_jsxRuntime.jsx)(_index3.EmptyState,{icon:a,title:s??f.emptyTitle,description:o})}):(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:u})};exports.AsyncBlock=AsyncBlock;var _default=exports.default=AsyncBlock;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_ASYNC_BLOCK_LABELS=exports.AsyncBlock=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../EmptyState/index.js"),_index4=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_ASYNC_BLOCK_LABELS=exports.DEFAULT_ASYNC_BLOCK_LABELS=Object.freeze({emptyTitle:"Nothing here yet",errorTitle:"That didn't load",offlineTitle:"You're offline",offlineHint:"Check your connection, then try again.",retry:"Try again"}),isNode=e=>(0,_react.isValidElement)(e)||Array.isArray(e),AsyncBlock=({loading:e=!1,error:t,errorVariant:i,empty:r=!1,onRetry:n,skeleton:s,emptyTitle:l,emptyDescription:o,emptyIcon:a,errorTitle:c,offlineTitle:_,labels:d,children:u,style:x,testID:m})=>{const y=(0,_index.useTheme)(),f=(0,_react.useMemo)(()=>({...DEFAULT_ASYNC_BLOCK_LABELS,...d}),[d]);if((0,_assertValidValue.assertValidValue)("AsyncBlock","errorVariant",i,["default","offline"]),e)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:x,testID:m,children:s??(0,_jsxRuntime.jsx)(_reactNative.View,{style:{paddingVertical:y.space["2xl"],alignItems:"center"},children:(0,_jsxRuntime.jsx)(_index4.Spinner,{})})});if(t){const e="string"==typeof t?t:null,r=null!==e||isNode(t)?null:(0,_mobileCore.extractApiError)(t),s="offline"===(i??(r?.code===_mobileCore.OFFLINE_CODE?"offline":"default")),l=e??r?.message??(s?f.offlineHint:void 0);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:x,testID:m,children:[(0,_jsxRuntime.jsx)(_index3.EmptyState,{icon:s?(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"cloud-cross",size:"xl",color:y.colors["text-subtle"],testID:"async-block-offline-icon"}):void 0,title:s?_??f.offlineTitle:c??f.errorTitle,description:l,action:n?{label:f.retry,onPress:n}:void 0}),isNode(t)?t:null]})}return r?(0,_jsxRuntime.jsx)(_reactNative.View,{style:x,testID:m,children:(0,_jsxRuntime.jsx)(_index3.EmptyState,{icon:a,title:l??f.emptyTitle,description:o})}):(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:u})};exports.AsyncBlock=AsyncBlock;var _default=exports.default=AsyncBlock;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_AUTHED_IMAGE_LABELS=exports.AuthedImage=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../Spinner/index.js"),_index3=require("../Text/index.js"),_authedImageCache=require("./authedImageCache.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_AUTHED_IMAGE_LABELS=exports.DEFAULT_AUTHED_IMAGE_LABELS=Object.freeze({loading:"Loading image",unavailable:"Image unavailable",unavailableNamed:e=>`${e}, image unavailable`}),CONTENT_FIT={cover:"cover",contain:"contain",stretch:"fill",center:"scale-down",repeat:"cover"},toError=e=>e instanceof Error?e:new Error(String(e)),AuthedImage=e=>{const{uri:t,headers:r,client:a,authenticated:i=!0,ttlMs:s=_authedImageCache.DEFAULT_TTL_MS,placeholder:n,fallback:o,onLoadStart:c,onLoadEnd:l,onError:u,cacheKey:d,testID:_,accessibilityLabel:h,style:m,resizeMode:g,fadeDuration:I,contentFit:b,transition:y,labels:x,cachePolicy:E="memory",...v}=e;(0,_warnInvalidValue.warnInvalidValue)("AuthedImage","resizeMode",g,Object.keys(CONTENT_FIT));const f=(0,_react.useMemo)(()=>({...DEFAULT_AUTHED_IMAGE_LABELS,...x}),[x]),j=(0,_index.useTheme)(),L=(0,_react.useMemo)(()=>buildStyles(j),[j]),[A,p]=(0,_react.useState)({status:"loading"}),C=(0,_react.useRef)({onLoadStart:c,onLoadEnd:l,onError:u});C.current={onLoadStart:c,onLoadEnd:l,onError:u};const T=JSON.stringify(r??{});return(0,_react.useEffect)(()=>{let e=!1,r=null;const finish=t=>{e||(p(t),C.current.onLoadEnd?.())};return(async()=>{if(!t){const t=new Error("[@webority/mobile-ui] AuthedImage was given an empty `uri`. Pass the image URL, or render nothing while the URL is still unknown.");return void(e||(p({status:"error"}),C.current.onError?.(t)))}p({status:"loading"}),C.current.onLoadStart?.();const n=(0,_authedImageCache.deriveCacheKey)(t,d),o=await(0,_authedImageCache.readEntry)(n);if(e)return;if(o&&(0,_authedImageCache.isFresh)(o.meta,s))return(0,_authedImageCache.touchEntry)(n),void finish({status:"ready",fileUri:o.fileUri});const c=(0,_authedImageCache.acquireFetch)(n,{uri:t,headers:JSON.parse(T),authenticated:i,client:a});r={key:n,entry:c};try{const e=await c.promise;finish({status:"ready",fileUri:e.fileUri})}catch(t){if(e)return;if(o&&!(0,_authedImageCache.isPermanentRefusal)(t))return void finish({status:"ready",fileUri:o.fileUri});if(o&&(await(0,_authedImageCache.removeEntry)(n),e))return;p({status:"error"}),C.current.onError?.(toError(t)),C.current.onLoadEnd?.()}})(),()=>{e=!0,r&&(0,_authedImageCache.releaseFetch)(r.key,r.entry)}},[t,d,s,i,a,T]),"loading"===A.status?void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:m,testID:_,children:n}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[L.placeholder,m],testID:_,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:L.stateFill,testID:_?`${_}-placeholder`:void 0,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index2.Spinner,{size:"sm",accessibilityLabel:f.loading})})}):"error"===A.status?void 0!==o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:m,testID:_,children:o}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[L.fallback,m],testID:_,children:(0,_jsxRuntime.jsx)(_reactNative.View,{accessible:!0,accessibilityRole:"image",accessibilityLabel:h?f.unavailableNamed(h):f.unavailable,testID:_?`${_}-fallback`:void 0,style:L.stateFill,children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",color:"tertiary",accessible:!1,children:"!"})})}):(0,_jsxRuntime.jsx)(_expoImage.Image,{...v,accessible:!0,accessibilityRole:"image",accessibilityLabel:h,testID:_,style:m,contentFit:b??(g?CONTENT_FIT[g]:void 0),transition:y??I,cachePolicy:E,source:{uri:A.fileUri}})};exports.AuthedImage=AuthedImage,AuthedImage.displayName="AuthedImage";const buildStyles=e=>_reactNative.StyleSheet.create({placeholder:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.md,..._corners.smoothCorners},fallback:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.md,..._corners.smoothCorners,borderWidth:e.size.border,borderColor:e.colors["border-subtle"],padding:e.space.sm},stateFill:{alignItems:"center",flex:1,justifyContent:"center"}});var _default=exports.default=AuthedImage;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_AUTHED_IMAGE_LABELS=exports.AuthedImage=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index2=require("../Spinner/index.js"),_index3=require("../Text/index.js"),_authedImageCache=require("./authedImageCache.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_AUTHED_IMAGE_LABELS=exports.DEFAULT_AUTHED_IMAGE_LABELS=Object.freeze({loading:"Loading image",unavailable:"Image unavailable",unavailableNamed:e=>`${e}, image unavailable`}),CONTENT_FIT={cover:"cover",contain:"contain",stretch:"fill",center:"scale-down",repeat:"cover"},toError=e=>e instanceof Error?e:new Error(String(e)),AuthedImage=e=>{const{uri:t,headers:r,client:a,authenticated:i=!0,ttlMs:s=_authedImageCache.DEFAULT_TTL_MS,placeholder:n,fallback:o,onLoadStart:c,onLoadEnd:l,onError:u,cacheKey:d,testID:_,accessibilityLabel:h,style:m,resizeMode:g,fadeDuration:b,contentFit:y,transition:x,labels:I,cachePolicy:E="memory",...v}=e;(0,_assertValidValue.assertValidValue)("AuthedImage","resizeMode",g,Object.keys(CONTENT_FIT));const f=(0,_react.useMemo)(()=>({...DEFAULT_AUTHED_IMAGE_LABELS,...I}),[I]),j=(0,_index.useTheme)(),L=(0,_react.useMemo)(()=>buildStyles(j),[j]),[A,p]=(0,_react.useState)({status:"loading"}),C=(0,_react.useRef)({onLoadStart:c,onLoadEnd:l,onError:u});C.current={onLoadStart:c,onLoadEnd:l,onError:u};const T=JSON.stringify(r??{});return(0,_react.useEffect)(()=>{let e=!1,r=null;const finish=t=>{e||(p(t),C.current.onLoadEnd?.())};return(async()=>{if(!t){const t=new Error("[@webority/mobile-ui] AuthedImage was given an empty `uri`. Pass the image URL, or render nothing while the URL is still unknown.");return void(e||(p({status:"error"}),C.current.onError?.(t)))}p({status:"loading"}),C.current.onLoadStart?.();const n=(0,_authedImageCache.deriveCacheKey)(t,d),o=await(0,_authedImageCache.readEntry)(n);if(e)return;if(o&&(0,_authedImageCache.isFresh)(o.meta,s))return(0,_authedImageCache.touchEntry)(n),void finish({status:"ready",fileUri:o.fileUri});const c=(0,_authedImageCache.acquireFetch)(n,{uri:t,headers:JSON.parse(T),authenticated:i,client:a});r={key:n,entry:c};try{const e=await c.promise;finish({status:"ready",fileUri:e.fileUri})}catch(t){if(e)return;if(o&&!(0,_authedImageCache.isPermanentRefusal)(t))return void finish({status:"ready",fileUri:o.fileUri});if(o&&(await(0,_authedImageCache.removeEntry)(n),e))return;p({status:"error"}),C.current.onError?.(toError(t)),C.current.onLoadEnd?.()}})(),()=>{e=!0,r&&(0,_authedImageCache.releaseFetch)(r.key,r.entry)}},[t,d,s,i,a,T]),"loading"===A.status?void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:m,testID:_,children:n}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[L.placeholder,m],testID:_,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:L.stateFill,testID:_?`${_}-placeholder`:void 0,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index2.Spinner,{size:"sm",accessibilityLabel:f.loading})})}):"error"===A.status?void 0!==o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:m,testID:_,children:o}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[L.fallback,m],testID:_,children:(0,_jsxRuntime.jsx)(_reactNative.View,{accessible:!0,accessibilityRole:"image",accessibilityLabel:h?f.unavailableNamed(h):f.unavailable,testID:_?`${_}-fallback`:void 0,style:L.stateFill,children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",color:"tertiary",accessible:!1,children:"!"})})}):(0,_jsxRuntime.jsx)(_expoImage.Image,{...v,accessible:!0,accessibilityRole:"image",accessibilityLabel:h,testID:_,style:m,contentFit:y??(g?CONTENT_FIT[g]:void 0),transition:x??b,cachePolicy:E,source:{uri:A.fileUri}})};exports.AuthedImage=AuthedImage,AuthedImage.displayName="AuthedImage";const buildStyles=e=>_reactNative.StyleSheet.create({placeholder:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.md,..._corners.smoothCorners},fallback:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.md,..._corners.smoothCorners,borderWidth:e.size.border,borderColor:e.colors["border-subtle"],padding:e.space.sm},stateFill:{alignItems:"center",flex:1,justifyContent:"center"}});var _default=exports.default=AuthedImage;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Autocomplete=Autocomplete,exports.default=exports.DEFAULT_AUTOCOMPLETE_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"),_index4=require("../Input/index.js"),_index5=require("../Spinner/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var r,i,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(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((r=a&&Object.getOwnPropertyDescriptor(e,i))&&(r.get||r.set)?a(n,i,r):n[i]=e[i]);return n}const DEFAULT_AUTOCOMPLETE_LABELS=exports.DEFAULT_AUTOCOMPLETE_LABELS=Object.freeze({empty:"No matches",searching:"Searching…"}),defaultGetLabel=e=>"string"==typeof e?e:String(e);function Autocomplete(e){const{options:t,value:r,defaultValue:i,onChangeText:a,onSelect:n,getOptionLabel:l,getOptionKey:o,filter:s,minChars:c=1,maxResults:d=8,loading:u=!1,filterMode:p="client",loadingText:_,labels:x,placeholder:m,label:h,error:b,helperText:f,disabled:g=!1,size:y="md",variant:j,haptic:v,style:T,listStyle:S,optionTextStyle:L,testID:w}=e;(0,_warnInvalidValue.warnInvalidValue)("Autocomplete","filterMode",e.filterMode,["client","none"]);const C=(0,_react.useMemo)(()=>({...DEFAULT_AUTOCOMPLETE_LABELS,...x}),[x]),R=(0,_index2.useTheme)(),A=(0,_react.useMemo)(()=>buildStyles(R),[R]),[E,O]=(0,_index.useControllableState)({value:r,defaultValue:i??"",onChange:a}),[M,P]=(0,_react.useState)(!1),[q,N]=(0,_react.useState)(0),V=(0,_react.useRef)(null),I=(0,_react.useCallback)(e=>l?l(e):defaultGetLabel(e),[l]),k=(0,_react.useMemo)(()=>{if("none"===p)return t.slice(0,d);const e=E.trim();if(e.length<c)return[];const r=e.toLowerCase(),i=s?t=>s(t,e):e=>I(e).toLowerCase().includes(r);return t.filter(i).slice(0,d)},[t,E,c,d,s,I,p]),z=M&&(u||E.trim().length>=c),D=(0,_react.useCallback)(e=>{const t=(0,_index3.resolveHaptic)(v,"selection");t&&(0,_index3.triggerHaptic)(t),V.current&&clearTimeout(V.current),O(I(e)),P(!1),_reactNative.Keyboard.dismiss(),n(e)},[v,O,I,n]);_react.default.useEffect(()=>()=>{V.current&&clearTimeout(V.current)},[]);const F=(0,_react.useCallback)(e=>{N(e.nativeEvent.layout.height)},[]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[A.container,T],testID:w,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:F,children:(0,_jsxRuntime.jsx)(_index4.Input,{value:E,onChangeText:O,onFocus:()=>{V.current&&clearTimeout(V.current),P(!0)},onBlur:()=>{V.current=setTimeout(()=>P(!1),120)},placeholder:m,label:h,error:b,helperText:f,editable:!g,accessibilityState:{disabled:g},"aria-disabled":g,size:y,variant:j,autoCorrect:!1,autoCapitalize:"none"})}),z?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[A.list,{top:q,backgroundColor:R.colors.surface,borderColor:R.colors.border,borderRadius:R.radius.md,..._corners.smoothCorners,...R.shadow.popover},S],children:u?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:A.loadingRow,children:[(0,_jsxRuntime.jsx)(_index5.Spinner,{size:"sm"}),(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",color:"secondary",style:A.loadingText,children:_??C.searching})]}):0===k.length?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",color:"tertiary",align:"center",style:A.empty,children:C.empty}):(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:A.scroll,children:k.map(e=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>D(e),android_ripple:{color:R.colors["surface-pressed"]},style:({pressed:e})=>[A.option,{paddingHorizontal:R.space.md,paddingVertical:R.space.sm,backgroundColor:e?R.colors["surface-pressed"]:"transparent"}],accessibilityRole:"button",accessibilityLabel:I(e),accessibilityState:{selected:I(e)===E},"aria-selected":I(e)===E,children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"body",numberOfLines:1,style:[A.optionText,L],children:I(e)})},o?o(e):I(e)))})}):null]})}Autocomplete.displayName="Autocomplete";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%",position:"relative",zIndex:10},list:{position:"absolute",left:0,right:0,borderWidth:_reactNative.StyleSheet.hairlineWidth,overflow:"hidden",zIndex:20,maxHeight:240},scroll:{maxHeight:240},option:{width:"100%"},optionText:{includeFontPadding:!1},empty:{padding:e.space.md,includeFontPadding:!1},loadingRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm,padding:e.space.md},loadingText:{includeFontPadding:!1}});var _default=exports.default=Autocomplete;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Autocomplete=Autocomplete,exports.default=exports.DEFAULT_AUTOCOMPLETE_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"),_index4=require("../Input/index.js"),_index5=require("../Spinner/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var r,i,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(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((r=a&&Object.getOwnPropertyDescriptor(e,i))&&(r.get||r.set)?a(n,i,r):n[i]=e[i]);return n}const DEFAULT_AUTOCOMPLETE_LABELS=exports.DEFAULT_AUTOCOMPLETE_LABELS=Object.freeze({empty:"No matches",searching:"Searching…"}),defaultGetLabel=e=>"string"==typeof e?e:String(e);function Autocomplete(e){const{options:t,value:r,defaultValue:i,onChangeText:a,onSelect:n,getOptionLabel:s,getOptionKey:l,filter:o,minChars:c=1,maxResults:d=8,loading:u=!1,filterMode:p="client",loadingText:_,labels:x,placeholder:m,label:h,error:b,helperText:f,disabled:g=!1,size:y="md",variant:j,haptic:T,style:v,listStyle:S,optionTextStyle:L,testID:C}=e;(0,_assertValidValue.assertValidValue)("Autocomplete","filterMode",e.filterMode,["client","none"]);const R=(0,_react.useMemo)(()=>({...DEFAULT_AUTOCOMPLETE_LABELS,...x}),[x]),A=(0,_index2.useTheme)(),E=(0,_react.useMemo)(()=>buildStyles(A),[A]),[O,w]=(0,_index.useControllableState)({value:r,defaultValue:i??"",onChange:a}),[V,M]=(0,_react.useState)(!1),[P,q]=(0,_react.useState)(0),N=(0,_react.useRef)(null),k=(0,_react.useCallback)(e=>s?s(e):defaultGetLabel(e),[s]),z=(0,_react.useMemo)(()=>{if("none"===p)return t.slice(0,d);const e=O.trim();if(e.length<c)return[];const r=e.toLowerCase(),i=o?t=>o(t,e):e=>k(e).toLowerCase().includes(r);return t.filter(i).slice(0,d)},[t,O,c,d,o,k,p]),D=V&&(u||O.trim().length>=c),F=(0,_react.useCallback)(e=>{const t=(0,_index3.resolveHaptic)(T,"selection");t&&(0,_index3.triggerHaptic)(t),N.current&&clearTimeout(N.current),w(k(e)),M(!1),_reactNative.Keyboard.dismiss(),n(e)},[T,w,k,n]);_react.default.useEffect(()=>()=>{N.current&&clearTimeout(N.current)},[]);const U=(0,_react.useCallback)(e=>{q(e.nativeEvent.layout.height)},[]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[E.container,v],testID:C,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:U,children:(0,_jsxRuntime.jsx)(_index4.Input,{value:O,onChangeText:w,onFocus:()=>{N.current&&clearTimeout(N.current),M(!0)},onBlur:()=>{N.current=setTimeout(()=>M(!1),120)},placeholder:m,label:h,error:b,helperText:f,editable:!g,accessibilityState:{disabled:g},"aria-disabled":g,size:y,variant:j,autoCorrect:!1,autoCapitalize:"none"})}),D?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[E.list,{top:P,backgroundColor:A.colors.surface,borderColor:A.colors.border,borderRadius:A.radius.md,..._corners.smoothCorners,...A.shadow.popover},S],children:u?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E.loadingRow,children:[(0,_jsxRuntime.jsx)(_index5.Spinner,{size:"sm"}),(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",color:"secondary",style:E.loadingText,children:_??R.searching})]}):0===z.length?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",color:"tertiary",align:"center",style:E.empty,children:R.empty}):(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:E.scroll,children:z.map(e=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>F(e),android_ripple:{color:A.colors["surface-pressed"]},style:({pressed:e})=>[E.option,{paddingHorizontal:A.space.md,paddingVertical:A.space.sm,backgroundColor:e?A.colors["surface-pressed"]:"transparent"}],accessibilityRole:"button",accessibilityLabel:k(e),accessibilityState:{selected:k(e)===O},"aria-selected":k(e)===O,children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"body",numberOfLines:1,style:[E.optionText,L],children:k(e)})},l?l(e):k(e)))})}):null]})}Autocomplete.displayName="Autocomplete";const buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%",position:"relative",zIndex:10},list:{position:"absolute",left:0,right:0,borderWidth:_reactNative.StyleSheet.hairlineWidth,overflow:"hidden",zIndex:20,maxHeight:240},scroll:{maxHeight:240},option:{width:"100%"},optionText:{includeFontPadding:!1},empty:{padding:e.space.md,includeFontPadding:!1},loadingRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm,padding:e.space.md},loadingText:{includeFontPadding:!1}});var _default=exports.default=Autocomplete;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.avatarToneColors=exports.DEFAULT_AVATAR_LABELS=exports.AvatarGroup=exports.Avatar=exports.AVATAR_COLORS=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_AuthedImage=require("../AuthedImage/AuthedImage.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2,AVATAR_COLORS=exports.AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],avatarToneColors=(e,t)=>{const soft=(e,t)=>(0,_color.tintOf)(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};default:return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};exports.avatarToneColors=avatarToneColors;const DEFAULT_AVATAR_LABELS=exports.DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"}),sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,a)=>{switch(t){case"circle":return r/2;case"rounded":return a?e.radius[a]:Math.max(e.radius.sm,Math.round(.22*r));default:return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean);return 0===t.length?"":1===t.length?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[1].charAt(0)).toUpperCase()},hashColor=(e,t)=>{if(!e)return t[0];let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t[Math.abs(r)%t.length]},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,uriOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:void 0,isRingStatus=e=>"verified"===e||"pending"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":return e.colors.danger;case"away":case"pending":return e.colors.warning;default:return e.colors["text-subtle"]}},Avatar=exports.Avatar=(0,_react.forwardRef)((e,t)=>{const{source:r,ImageComponent:a,imageClient:o,name:s,size:i="md",shape:n="circle",dimension:l,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:h,status:m=null,statusPosition:v="bottomRight",tone:g,backgroundColor:p,color:_,fontSize:b,loading:x=!1,accessibilityLabel:A,onPress:y,onLongPress:f,haptic:R,hitSlop:I,style:j,textStyle:S,testID:w,labels:C}=e;(0,_warnInvalidValue.warnInvalidValue)("Avatar","size",e.size,Object.keys(sizeMap)),(0,_warnInvalidValue.warnInvalidValue)("Avatar","shape",e.shape,["circle","square","rounded"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","radius",e.radius,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","contentFit",e.contentFit,["cover","contain"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","status",e.status,["online","offline","busy","away","verified","pending"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),(0,_warnInvalidValue.warnInvalidValue)("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const V=(0,_react.useMemo)(()=>C?{...DEFAULT_AVATAR_LABELS,...C}:DEFAULT_AVATAR_LABELS,[C]),T=(0,_index.useTheme)(),[L,M]=(0,_react.useState)(null),E=(0,_react.useMemo)(()=>l??resolveSize(i),[l,i]),O=(0,_react.useMemo)(()=>resolveRadius(T,n,E,c),[T,n,E,c]),k=u?T.size.border:0,N=T.colors.border,z=T.colors.surface,F=(0,_react.useMemo)(()=>initialsFromName(s),[s]),D=(0,_react.useMemo)(()=>g?avatarToneColors(T,g):null,[T,g]),G=(0,_react.useMemo)(()=>p||(D?.background??T.colors[hashColor(s??"",AVATAR_COLORS)]),[p,D,s,T]),U=_??D?.color??T.colors["on-primary"],q=r?keyOfSource(r):null,P=null!==q&&q!==L,$=!P&&""===F&&null!=h,B=_??D?.color??T.colors["text-subtle"],W=b??Math.max(T.text.xs.size,Math.round(.4*E)),H=Math.max(8,Math.round(.25*E)),Y=isRingStatus(m),X=E-2*(Y?3:k),J=Y?resolveRadius(T,n,X,c):Math.max(0,O-k),K=$?(0,_slotIcon.renderSlotIcon)(h,{color:B,size:Math.round(.45*X),disabled:!1}):null,Q=Y?statusColor(T,m):"transparent",Z=Math.max(12,Math.round(.32*E)),ee=Math.max(10,Z-4),te=p??D?.background??T.colors["bg-muted"],re=P?"contain"===d?"transparent":T.colors["bg-muted"]:$?te:G,ae=w??"avatar",oe=s?V.avatarOf(s):V.avatar,se="verified"===m?`, ${V.verified}`:"pending"===m?`, ${V.pendingVerification}`:"",ie=A??`${oe}${se}`,ne="function"==typeof y||"function"==typeof f,le=A??`${s||oe}${se}`,ce=Math.max(0,Math.ceil((44-E)/2)),ue=I??ce,de=[styles.root,{width:E,height:E,borderRadius:O,..._corners.smoothCorners,borderWidth:Y?0:k,borderColor:N,backgroundColor:Y?"transparent":re},j],he=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.ring,{borderRadius:O,..._corners.smoothCorners,borderWidth:1.5,borderColor:Q}],accessible:!1,pointerEvents:"none",testID:`${ae}-ring`}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.picture,{width:X,height:X,borderRadius:J,..._corners.smoothCorners,borderWidth:Y?k:0,borderColor:N,backgroundColor:Y?re:"transparent"}],children:P?(()=>{const e={width:X,height:X,borderRadius:J,..._corners.smoothCorners},onError=()=>M(q),t=uriOfSource(r);return a?(0,_jsxRuntime.jsx)(a,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):o&&void 0!==t?(0,_jsxRuntime.jsx)(_AuthedImage.AuthedImage,{uri:t,client:o,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):(0,_jsxRuntime.jsx)(_expoImage.Image,{source:r,onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0})})():K||(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:U,fontSize:W,lineHeight:Math.round(W*T.leading.body)},S],children:F??" "})}),"verified"===m?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===v?styles.badgeTopRight:styles.badgeBottomRight,{width:Z,height:Z,borderRadius:Z/2,..._corners.smoothCorners,backgroundColor:z}],accessible:!1,pointerEvents:"none",testID:`${ae}-badge`,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"verify",variant:"bold",size:ee,color:Q})}):null,m&&!Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===v?styles.statusTopRight:styles.statusBottomRight,{width:H,height:H,borderRadius:H/2,..._corners.smoothCorners,backgroundColor:statusColor(T,m),borderWidth:2,borderColor:z}],accessible:!1,pointerEvents:"none"}):null]}),me=ne?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:y?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),y?.(e)}:void 0,onLongPress:f?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"longPress");t&&(0,_hapticUtils.triggerHaptic)(t),f?.(e)}:void 0,hitSlop:ue,...(0,_hitSlop.hitSlopMarker)(ue),accessibilityRole:"button",accessibilityLabel:le,testID:w,style:({pressed:e})=>[de,e?styles.pressed:null],children:he}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:de,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:w,children:he});return x?(0,_jsxRuntime.jsx)(AvatarSkeleton,{...e}):me});Avatar.displayName="Avatar";const AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:a})=>{const o=r??resolveSize(e),s="circle"===t?"circle":"rounded"===t?"rounded":"rect";return(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:s,width:o,height:o,style:a})};AvatarSkeleton.displayName="AvatarSkeleton",Avatar.Skeleton=AvatarSkeleton;const styles=_reactNative.StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:a,children:o})=>{const s=(0,_index.useTheme)(),i=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current;return(0,_react.useEffect)(()=>{const t=_reactNative.Animated.timing(i,{toValue:1,duration:220,delay:e,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0});return t.start(),()=>t.stop()},[e,i]),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:s.radius.pill,borderColor:r,borderWidth:a,opacity:i}],children:o})},AvatarGroup=e=>{const{children:t,max:r=4,size:a="md",spacing:o="normal",overflowVariant:s="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;(0,_warnInvalidValue.warnInvalidValue)("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),(0,_warnInvalidValue.warnInvalidValue)("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),(0,_warnInvalidValue.warnInvalidValue)("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=(0,_react.useMemo)(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=(0,_index.useTheme)(),h=(0,_react.useMemo)(()=>_react.Children.toArray(t).filter(e=>(0,_react.isValidElement)(e)),[t]),m=h.length,v=h.slice(0,r),g=Math.max(0,m-r),p=g>0,_=-d.space[SPACING_OFFSET[o]],b=d.colors.surface,x=i??u.groupOf(m),A=(0,_react.useMemo)(()=>resolveSize(a),[a]),y=Math.max(d.text.xs.size,Math.round(.34*A));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:x,accessibilityRole:"summary",testID:l,children:[v.map((e,t)=>{const r=e.key??`avatar-${t}`,o=(0,_react.cloneElement)(e,{size:a,labels:e.props.labels??c});return(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:_,borderColor:b,borderWidth:1.5,children:o},r)}),p?(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*v.length,marginLeft:0===v.length?0:_,borderColor:b,borderWidth:1.5,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,..._corners.smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===s?u.moreCount(g):u.moreAvatars,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:y,lineHeight:Math.round(y*d.leading.body)},children:"count"===s?`+${g}`:"+"})})},"avatar-overflow"):null]})};exports.AvatarGroup=AvatarGroup;const groupStyles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{..._corners.smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Avatar;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.avatarToneColors=exports.DEFAULT_AVATAR_LABELS=exports.AvatarGroup=exports.Avatar=exports.AVATAR_COLORS=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_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"),_hitSlop=require("../../utils/hitSlop.js"),_index2=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_AuthedImage=require("../AuthedImage/AuthedImage.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2,AVATAR_COLORS=exports.AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],avatarToneColors=(e,t)=>{const soft=(e,t)=>(0,_color.tintOf)(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};default:return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};exports.avatarToneColors=avatarToneColors;const DEFAULT_AVATAR_LABELS=exports.DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"}),sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,s)=>{switch(t){case"circle":return r/2;case"rounded":return s?e.radius[s]:Math.max(e.radius.sm,Math.round(.22*r));default:return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean);return 0===t.length?"":1===t.length?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[1].charAt(0)).toUpperCase()},hashColor=(e,t)=>{if(!e)return t[0];let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t[Math.abs(r)%t.length]},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,uriOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:void 0,isRingStatus=e=>"verified"===e||"pending"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":return e.colors.danger;case"away":case"pending":return e.colors.warning;default:return e.colors["text-subtle"]}},Avatar=exports.Avatar=(0,_react.forwardRef)((e,t)=>{const{source:r,ImageComponent:s,imageClient:a,name:o,size:i="md",shape:n="circle",dimension:l,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:h,status:m=null,statusPosition:g="bottomRight",tone:p,backgroundColor:_,color:b,fontSize:v,loading:x=!1,accessibilityLabel:A,onPress:y,onLongPress:f,haptic:R,hitSlop:V,style:j,textStyle:S,testID:C,labels:I}=e;(0,_assertValidValue.assertValidValue)("Avatar","size",e.size,Object.keys(sizeMap)),(0,_assertValidValue.assertValidValue)("Avatar","shape",e.shape,["circle","square","rounded"]),(0,_assertValidValue.assertValidValue)("Avatar","radius",e.radius,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Avatar","contentFit",e.contentFit,["cover","contain"]),(0,_assertValidValue.assertValidValue)("Avatar","status",e.status,["online","offline","busy","away","verified","pending"]),(0,_assertValidValue.assertValidValue)("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),(0,_assertValidValue.assertValidValue)("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const T=(0,_react.useMemo)(()=>I?{...DEFAULT_AVATAR_LABELS,...I}:DEFAULT_AVATAR_LABELS,[I]),L=(0,_index.useTheme)(),[M,w]=(0,_react.useState)(null),E=(0,_react.useMemo)(()=>l??resolveSize(i),[l,i]),O=(0,_react.useMemo)(()=>resolveRadius(L,n,E,c),[L,n,E,c]),k=u?L.size.border:0,N=L.colors.border,z=L.colors.surface,F=(0,_react.useMemo)(()=>initialsFromName(o),[o]),D=(0,_react.useMemo)(()=>p?avatarToneColors(L,p):null,[L,p]),G=(0,_react.useMemo)(()=>_||(D?.background??L.colors[hashColor(o??"",AVATAR_COLORS)]),[_,D,o,L]),U=b??D?.color??L.colors["on-primary"],q=r?keyOfSource(r):null,P=null!==q&&q!==M,$=!P&&""===F&&null!=h,B=b??D?.color??L.colors["text-subtle"],W=v??Math.max(L.text.xs.size,Math.round(.4*E)),H=Math.max(8,Math.round(.25*E)),Y=isRingStatus(m),X=E-2*(Y?3:k),J=Y?resolveRadius(L,n,X,c):Math.max(0,O-k),K=$?(0,_slotIcon.renderSlotIcon)(h,{color:B,size:Math.round(.45*X),disabled:!1}):null,Q=Y?statusColor(L,m):"transparent",Z=Math.max(12,Math.round(.32*E)),ee=Math.max(10,Z-4),te=_??D?.background??L.colors["bg-muted"],re=P?"contain"===d?"transparent":L.colors["bg-muted"]:$?te:G,se=C??"avatar",ae=o?T.avatarOf(o):T.avatar,oe="verified"===m?`, ${T.verified}`:"pending"===m?`, ${T.pendingVerification}`:"",ie=A??`${ae}${oe}`,ne="function"==typeof y||"function"==typeof f,le=A??`${o||ae}${oe}`,ce=Math.max(0,Math.ceil((44-E)/2)),ue=V??ce,de=[styles.root,{width:E,height:E,borderRadius:O,..._corners.smoothCorners,borderWidth:Y?0:k,borderColor:N,backgroundColor:Y?"transparent":re},j],he=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.ring,{borderRadius:O,..._corners.smoothCorners,borderWidth:1.5,borderColor:Q}],accessible:!1,pointerEvents:"none",testID:`${se}-ring`}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.picture,{width:X,height:X,borderRadius:J,..._corners.smoothCorners,borderWidth:Y?k:0,borderColor:N,backgroundColor:Y?re:"transparent"}],children:P?(()=>{const e={width:X,height:X,borderRadius:J,..._corners.smoothCorners},onError=()=>w(q),t=uriOfSource(r);return s?(0,_jsxRuntime.jsx)(s,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):a&&void 0!==t?(0,_jsxRuntime.jsx)(_AuthedImage.AuthedImage,{uri:t,client:a,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):(0,_jsxRuntime.jsx)(_expoImage.Image,{source:r,onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0})})():K||(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:U,fontSize:W,lineHeight:Math.round(W*L.leading.body)},S],children:F??" "})}),"verified"===m?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===g?styles.badgeTopRight:styles.badgeBottomRight,{width:Z,height:Z,borderRadius:Z/2,..._corners.smoothCorners,backgroundColor:z}],accessible:!1,pointerEvents:"none",testID:`${se}-badge`,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"verify",variant:"bold",size:ee,color:Q})}):null,m&&!Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===g?styles.statusTopRight:styles.statusBottomRight,{width:H,height:H,borderRadius:H/2,..._corners.smoothCorners,backgroundColor:statusColor(L,m),borderWidth:2,borderColor:z}],accessible:!1,pointerEvents:"none"}):null]}),me=ne?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:y?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),y?.(e)}:void 0,onLongPress:f?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"longPress");t&&(0,_hapticUtils.triggerHaptic)(t),f?.(e)}:void 0,hitSlop:ue,...(0,_hitSlop.hitSlopMarker)(ue),accessibilityRole:"button",accessibilityLabel:le,testID:C,style:({pressed:e})=>[de,e?styles.pressed:null],children:he}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:de,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:C,children:he});return x?(0,_jsxRuntime.jsx)(AvatarSkeleton,{...e}):me});Avatar.displayName="Avatar";const AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:s})=>{const a=r??resolveSize(e),o="circle"===t?"circle":"rounded"===t?"rounded":"rect";return(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:o,width:a,height:a,style:s})};AvatarSkeleton.displayName="AvatarSkeleton",Avatar.Skeleton=AvatarSkeleton;const styles=_reactNative.StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:s,children:a})=>{const o=(0,_index.useTheme)(),i=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current;return(0,_react.useEffect)(()=>{const t=_reactNative.Animated.timing(i,{toValue:1,duration:220,delay:e,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!0});return t.start(),()=>t.stop()},[e,i]),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:o.radius.pill,borderColor:r,borderWidth:s,opacity:i}],children:a})},AvatarGroup=e=>{const{children:t,max:r=4,size:s="md",spacing:a="normal",overflowVariant:o="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;(0,_assertValidValue.assertValidValue)("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=(0,_react.useMemo)(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=(0,_index.useTheme)(),h=(0,_react.useMemo)(()=>_react.Children.toArray(t).filter(e=>(0,_react.isValidElement)(e)),[t]),m=h.length,g=h.slice(0,r),p=Math.max(0,m-r),_=p>0,b=-d.space[SPACING_OFFSET[a]],v=d.colors.surface,x=i??u.groupOf(m),A=(0,_react.useMemo)(()=>resolveSize(s),[s]),y=Math.max(d.text.xs.size,Math.round(.34*A));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:x,accessibilityRole:"summary",testID:l,children:[g.map((e,t)=>{const r=e.key??`avatar-${t}`,a=(0,_react.cloneElement)(e,{size:s,labels:e.props.labels??c});return(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:b,borderColor:v,borderWidth:1.5,children:a},r)}),_?(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*g.length,marginLeft:0===g.length?0:b,borderColor:v,borderWidth:1.5,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,..._corners.smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===o?u.moreCount(p):u.moreAvatars,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:y,lineHeight:Math.round(y*d.leading.body)},children:"count"===o?`+${p}`:"+"})})},"avatar-overflow"):null]})};exports.AvatarGroup=AvatarGroup;const groupStyles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{..._corners.smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Avatar;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BADGE_LABELS=exports.Badge=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../Skeleton/index.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BADGE_LABELS=exports.DEFAULT_BADGE_LABELS=Object.freeze({indicator:"Notification indicator",unread:e=>`${e} unread`}),toneFor=(e,t)=>{switch(t){case"primary":return{background:e.colors.primary,text:e.colors["on-primary"]};case"success":return{background:e.colors.success,text:e.colors["on-success"]};case"warning":return{background:e.colors.warning,text:e.colors["on-warning"]};case"info":return{background:e.colors.info,text:e.colors["on-info"]};case"neutral":return{background:e.colors["bg-muted"],text:e.colors["text-body"]};default:return{background:e.colors.danger,text:e.colors["on-danger"]}}},softToneFor=(e,t)=>{switch(t){case"primary":return{background:e.colors["primary-soft"],text:e.colors.primary};case"success":return{background:e.colors["success-soft"],text:e.colors.success};case"warning":return{background:e.colors["warning-soft"],text:e.colors.warning};case"info":return{background:e.colors["info-soft"],text:e.colors.info};case"neutral":return{background:e.colors["bg-muted"],text:e.colors["text-muted"]};default:return{background:e.colors["danger-soft"],text:e.colors.danger}}},anchorPosition=(e,t)=>{const r=-t;switch(e){case"topLeft":return{top:r,left:r};case"bottomRight":return{bottom:r,right:r};case"bottomLeft":return{bottom:r,left:r};default:return{top:r,right:r}}},formatValue=(e,t)=>{if(null==e)return null;if("number"==typeof e)return e<=0?null:e>t?`${t}+`:String(e);const r=String(e);return 0===r.length?null:r},Badge=exports.Badge=(0,_react.forwardRef)((e,t)=>{const{value:r,max:i=99,variant:n="standard",tone:o="danger",size:a="sm",fill:s="solid",accessible:l=!0,invisible:d=!1,loading:c=!1,children:u,anchor:g="topRight",pulse:h=!1,accessibilityLabel:m,labels:x,style:f,badgeStyle:_,textStyle:b,testID:v}=e;(0,_warnInvalidValue.warnInvalidValue)("Badge","variant",e.variant,["standard","dot"]),(0,_warnInvalidValue.warnInvalidValue)("Badge","tone",e.tone,["primary","success","warning","danger","neutral","info"]),(0,_warnInvalidValue.warnInvalidValue)("Badge","size",e.size,["sm","md"]),(0,_warnInvalidValue.warnInvalidValue)("Badge","anchor",e.anchor,["topRight","topLeft","bottomRight","bottomLeft"]),(0,_warnInvalidValue.warnInvalidValue)("Badge","fill",e.fill,["solid","soft"]);const p=(0,_react.useMemo)(()=>({...DEFAULT_BADGE_LABELS,...x}),[x]),w=(0,_index.useTheme)(),y=(0,_react.useMemo)(()=>"soft"===s?softToneFor(w,o):toneFor(w,o),[w,o,s]),j=(0,_index.resolveBadgeSize)(w,a),B=w.components.badge["border-width"],S=w.components.badge["anchor-offset"],k="dot"===n?null:formatValue(r,i),V=!d&&("dot"===n||null!==k),L=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!h||!V)return void(0,_index.setNativeValue)(L,1);const e=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(L,{toValue:1.15,duration:w.motion.duration.slow,easing:_reactNative.Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:!0}),_reactNative.Animated.timing(L,{toValue:1,duration:w.motion.duration.slow,easing:_reactNative.Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:!0})]));return e.start(),()=>{e.stop()}},[h,V,L,w]);const R="dot"===n,A=R?"image":"text",N=m??(R?p.indicator:k?p.unread(k):void 0),z=V?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[styles.badge,R?{width:j["dot-size"],height:j["dot-size"],borderRadius:j["dot-size"]/2,..._corners.smoothCorners,paddingHorizontal:0}:{minWidth:j["min-width"],minHeight:j.height,borderRadius:w.radius.pill,..._corners.smoothCorners,paddingHorizontal:j["padding-x"]},{backgroundColor:y.background,transform:[{scale:L}]},u?{position:"absolute",borderWidth:B,borderColor:w.colors.surface,...anchorPosition(g,S)}:null,_],accessible:l,importantForAccessibility:l?void 0:"no-hide-descendants",accessibilityElementsHidden:!l||void 0,accessibilityRole:l?A:void 0,accessibilityLabel:l?N:void 0,children:R||null===k?null:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",weight:"soft"===s?"semibold":"bold",numberOfLines:1,style:[styles.text,{color:y.text,fontSize:j.text,lineHeight:Math.round(j.text*w.leading.body)},b],children:k??" "})}):null,E=u?(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[styles.wrapper,f],testID:v,children:[u,z]}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:f,testID:v,children:z});return c?(0,_jsxRuntime.jsx)(BadgeSkeleton,{...e}):E});Badge.displayName="Badge";const BadgeSkeleton=({variant:e="standard",size:t="md",children:r,anchor:i,style:n,badgeStyle:o})=>{const a=(0,_index.useTheme)(),s=(0,_index.resolveBadgeSize)(a,t);if("dot"===e)return(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"circle",width:s["dot-size"],height:s["dot-size"],style:[o,n]});const l=s.height/2;if(void 0!==r){const e="topLeft"===i?{top:-s.height/2,left:-s.height/2}:"bottomRight"===i?{bottom:-s.height/2,right:-s.height/2}:"bottomLeft"===i?{bottom:-s.height/2,left:-s.height/2}:{top:-s.height/2,right:-s.height/2};return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.wrapper,n],children:[r,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{position:"absolute"},e],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:s["min-width"]+s["padding-x"],height:s.height,radius:l,style:o})})]})}return(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:s["min-width"]+s["padding-x"],height:s.height,radius:l,style:[o,n]})};BadgeSkeleton.displayName="BadgeSkeleton",Badge.Skeleton=BadgeSkeleton;const styles=_reactNative.StyleSheet.create({wrapper:{position:"relative",alignSelf:"flex-start"},badge:{alignItems:"center",justifyContent:"center",flexDirection:"row"},text:{textAlign:"center",includeFontPadding:!1}});var _default=exports.default=Badge;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BADGE_LABELS=exports.Badge=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index2=require("../Skeleton/index.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BADGE_LABELS=exports.DEFAULT_BADGE_LABELS=Object.freeze({indicator:"Notification indicator",unread:e=>`${e} unread`}),toneFor=(e,t)=>{switch(t){case"primary":return{background:e.colors.primary,text:e.colors["on-primary"]};case"success":return{background:e.colors.success,text:e.colors["on-success"]};case"warning":return{background:e.colors.warning,text:e.colors["on-warning"]};case"info":return{background:e.colors.info,text:e.colors["on-info"]};case"neutral":return{background:e.colors["bg-muted"],text:e.colors["text-body"]};default:return{background:e.colors.danger,text:e.colors["on-danger"]}}},softToneFor=(e,t)=>{switch(t){case"primary":return{background:e.colors["primary-soft"],text:e.colors.primary};case"success":return{background:e.colors["success-soft"],text:e.colors.success};case"warning":return{background:e.colors["warning-soft"],text:e.colors.warning};case"info":return{background:e.colors["info-soft"],text:e.colors.info};case"neutral":return{background:e.colors["bg-muted"],text:e.colors["text-muted"]};default:return{background:e.colors["danger-soft"],text:e.colors.danger}}},anchorPosition=(e,t)=>{const r=-t;switch(e){case"topLeft":return{top:r,left:r};case"bottomRight":return{bottom:r,right:r};case"bottomLeft":return{bottom:r,left:r};default:return{top:r,right:r}}},formatValue=(e,t)=>{if(null==e)return null;if("number"==typeof e)return e<=0?null:e>t?`${t}+`:String(e);const r=String(e);return 0===r.length?null:r},Badge=exports.Badge=(0,_react.forwardRef)((e,t)=>{const{value:r,max:i=99,variant:o="standard",tone:a="danger",size:s="sm",fill:n="solid",accessible:l=!0,invisible:d=!1,loading:c=!1,children:u,anchor:g="topRight",pulse:h=!1,accessibilityLabel:m,labels:x,style:f,badgeStyle:_,textStyle:b,testID:p}=e;(0,_assertValidValue.assertValidValue)("Badge","variant",e.variant,["standard","dot"]),(0,_assertValidValue.assertValidValue)("Badge","tone",e.tone,["primary","success","warning","danger","neutral","info"]),(0,_assertValidValue.assertValidValue)("Badge","size",e.size,["sm","md"]),(0,_assertValidValue.assertValidValue)("Badge","anchor",e.anchor,["topRight","topLeft","bottomRight","bottomLeft"]),(0,_assertValidValue.assertValidValue)("Badge","fill",e.fill,["solid","soft"]);const v=(0,_react.useMemo)(()=>({...DEFAULT_BADGE_LABELS,...x}),[x]),y=(0,_index.useTheme)(),V=(0,_react.useMemo)(()=>"soft"===n?softToneFor(y,a):toneFor(y,a),[y,a,n]),w=(0,_index.resolveBadgeSize)(y,s),j=y.components.badge["border-width"],B=y.components.badge["anchor-offset"],S="dot"===o?null:formatValue(r,i),k=!d&&("dot"===o||null!==S),L=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!h||!k)return void(0,_index.setNativeValue)(L,1);const e=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(L,{toValue:1.15,duration:y.motion.duration.slow,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:!0}),_reactNative.Animated.timing(L,{toValue:1,duration:y.motion.duration.slow,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:!0})]));return e.start(),()=>{e.stop()}},[h,k,L,y]);const R="dot"===o,A=R?"image":"text",N=m??(R?v.indicator:S?v.unread(S):void 0),z=k?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[styles.badge,R?{width:w["dot-size"],height:w["dot-size"],borderRadius:w["dot-size"]/2,..._corners.smoothCorners,paddingHorizontal:0}:{minWidth:w["min-width"],minHeight:w.height,borderRadius:y.radius.pill,..._corners.smoothCorners,paddingHorizontal:w["padding-x"]},{backgroundColor:V.background,transform:[{scale:L}]},u?{position:"absolute",borderWidth:j,borderColor:y.colors.surface,...anchorPosition(g,B)}:null,_],accessible:l,importantForAccessibility:l?void 0:"no-hide-descendants",accessibilityElementsHidden:!l||void 0,accessibilityRole:l?A:void 0,accessibilityLabel:l?N:void 0,children:R||null===S?null:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",weight:"soft"===n?"semibold":"bold",numberOfLines:1,style:[styles.text,{color:V.text,fontSize:w.text,lineHeight:Math.round(w.text*y.leading.body)},b],children:S??" "})}):null,E=u?(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[styles.wrapper,f],testID:p,children:[u,z]}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:f,testID:p,children:z});return c?(0,_jsxRuntime.jsx)(BadgeSkeleton,{...e}):E});Badge.displayName="Badge";const BadgeSkeleton=({variant:e="standard",size:t="md",children:r,anchor:i,style:o,badgeStyle:a})=>{const s=(0,_index.useTheme)(),n=(0,_index.resolveBadgeSize)(s,t);if("dot"===e)return(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"circle",width:n["dot-size"],height:n["dot-size"],style:[a,o]});const l=n.height/2;if(void 0!==r){const e="topLeft"===i?{top:-n.height/2,left:-n.height/2}:"bottomRight"===i?{bottom:-n.height/2,right:-n.height/2}:"bottomLeft"===i?{bottom:-n.height/2,left:-n.height/2}:{top:-n.height/2,right:-n.height/2};return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.wrapper,o],children:[r,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{position:"absolute"},e],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:n["min-width"]+n["padding-x"],height:n.height,radius:l,style:a})})]})}return(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:n["min-width"]+n["padding-x"],height:n.height,radius:l,style:[a,o]})};BadgeSkeleton.displayName="BadgeSkeleton",Badge.Skeleton=BadgeSkeleton;const styles=_reactNative.StyleSheet.create({wrapper:{position:"relative",alignSelf:"flex-start"},badge:{alignItems:"center",justifyContent:"center",flexDirection:"row"},text:{textAlign:"center",includeFontPadding:!1}});var _default=exports.default=Badge;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BANNER_LABELS=exports.Banner=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../IconBadge/index.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BANNER_LABELS=exports.DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"}),Banner=exports.Banner=(0,_react.forwardRef)((e,t)=>{const{title:r,message:n,tone:i="neutral",variant:s="bar",icon:a,actions:o,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:m=!0,loading:x=!1,accessibilityRole:p="alert",accessibilityLabel:_,labels:g,style:h,containerStyle:y,iconCircleStyle:b,tintBarStyle:v,closeButtonStyle:f,actionButtonStyle:j,testID:w}=e;(0,_warnInvalidValue.warnInvalidValue)("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("Banner","variant",e.variant,["bar","wash","tint"]),(0,_warnInvalidValue.warnInvalidValue)("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const R=(0,_index.useTheme)(),B=(0,_usePresenceMotion.usePresenceMotion)(),S=(0,_react.useMemo)(()=>buildStyles(R),[R]),N=(0,_react.useMemo)(()=>tintFor(R,i),[R,i]),I=(0,_react.useMemo)(()=>({...DEFAULT_BANNER_LABELS,...g}),[g]),[C,V]=B.range(-20,0),k=(0,_react.useRef)((0,_index.createAnimatedValue)(m&&u?C:0)).current,A=(0,_react.useRef)((0,_index.createAnimatedValue)(m&&u?0:u?1:0)).current,[L,E]=(0,_react.useState)(u),D=(0,_react.useRef)(!0);if((0,_react.useEffect)(()=>{if(D.current&&(D.current=!1,!m))return;let e;return u?(E(!0),e=_reactNative.Animated.parallel([_reactNative.Animated.timing(k,{toValue:V,duration:R.motion.duration.default,useNativeDriver:!0}),_reactNative.Animated.timing(A,{toValue:1,duration:B.duration("default"),useNativeDriver:!0})]),e.start()):L&&(e=_reactNative.Animated.parallel([_reactNative.Animated.timing(k,{toValue:C,duration:R.motion.duration.fast,useNativeDriver:!0}),_reactNative.Animated.timing(A,{toValue:0,duration:B.duration("fast"),useNativeDriver:!0})]),e.start(()=>{E(!1)})),()=>e?.stop()},[u]),!L)return null;const T=r??" ",q="string"==typeof n?n??" ":"",H="wash"===s,M="bar"!==s,z="alert"===p?"danger"===i?"assertive":"polite":"none",P=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{ref:t,accessibilityRole:p,accessibilityLiveRegion:z,accessibilityLabel:_,testID:w,style:[S.container,{backgroundColor:M?N.soft:R.colors["bg-subtle"],borderRadius:H?R.radius.sm:R.radius.md,..._corners.smoothCorners,padding:R.space.md,opacity:A,transform:[{translateY:k}]},y,h],children:[!H&&R.components.banner["tint-bar-width"]>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[S.tintBar,{backgroundColor:N.bar},v]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[S.row,void 0===r&&S.rowCentred],children:[!1===a?null:a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:S.iconWrap,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(a,{color:N.ink,size:R.text.xl.size,disabled:!1})}):(0,_jsxRuntime.jsx)(_index2.IconBadge,{dimension:ICON_CIRCLE_SIZE,color:N.bar,icon:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"bold",accessible:!1,style:[S.iconGlyph,{color:N.ink}],children:N.glyph}),style:[S.iconCircle,b]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:S.textBlock,children:[r||x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",numberOfLines:2,style:{lineHeight:20,...H?{color:N.ink}:null},children:T}):null,"string"==typeof n||x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{lineHeight:18,marginTop:r?R.space.xxs:0},children:q||" "}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginTop:r?R.space.xxs:0},children:n})]}),l?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:I.dismiss,onPress:()=>{const e=(0,_hapticUtils.resolveHaptic)(d,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),c?.()},hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),style:({pressed:e})=>[S.closeBtn,{backgroundColor:e?R.colors["surface-pressed"]:"transparent"},f],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:17},children:"×"})}):null]}),o&&o.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:S.actionsRow,children:o.map((e,t)=>{(0,_warnInvalidValue.warnInvalidValue)("Banner","action.tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("Banner","action.variant",e.variant,["solid","outline","ghost"]),(0,_warnInvalidValue.warnInvalidValue)("Banner","action.size",e.size,["sm","md"]);const r=e.tone??"primary",n=e.variant??"ghost",i="primary"===r?N.glyphColor:"neutral"===r?R.colors["text-muted"]:R.colors[r],s="primary"===r?N.ink:"neutral"===r?R.colors["text-muted"]:R.colors[`${r}-text`],a="primary"===r?N.on:"neutral"===r?R.colors["on-neutral-strong"]:R.colors[`on-${r}`],o="solid"===n;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,testID:e.testID,onPress:()=>{const t=(0,_hapticUtils.resolveHaptic)(d,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:({pressed:t})=>[S.actionBtn,"md"===e.size&&S.actionBtnMd,"outline"===n&&{borderWidth:1,borderColor:s},{backgroundColor:o?i:t?R.colors["surface-pressed"]:"transparent",opacity:o&&t?.85:1},j],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:o?a:s},children:e.label})},`${e.label}-${t}`)})}):null]});return x?(0,_jsxRuntime.jsx)(BannerSkeleton,{...e}):P});Banner.displayName="Banner";const BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:n,style:i})=>{const s=(0,_index.useTheme)(),a=!1!==r;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:s.colors.surface,borderRadius:s.radius.md,..._corners.smoothCorners,padding:s.space.md,borderWidth:1,borderColor:s.colors.border},n,i],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:s.space.sm},children:(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"circle",width:32,height:32})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},children:[void 0!==e?(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:s.space.xs}}):null,(0,_jsxRuntime.jsx)(_index3.SkeletonText,{lines:2,fontSize:s.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:s.space.sm},children:t.map((e,t)=>(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:s.space.sm}},`sk-banner-action-${t}`))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton",Banner.Skeleton=BannerSkeleton;const tintFor=(e,t)=>{switch(t){case"success":return{soft:e.colors["success-soft"],bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{soft:e.colors["warning-soft"],bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{soft:e.colors["danger-soft"],bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{soft:e.colors["bg-subtle"],bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};case"primary":return{soft:e.colors["primary-soft"],bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"};case"info":return{soft:e.colors["info-soft"],bar:e.colors.info,glyphColor:e.colors.info,ink:e.colors["info-text"],on:e.colors["on-info"],glyph:"i"};default:return tintFor(e,"neutral")}},ICON_CIRCLE_SIZE=28,buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return _reactNative.StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},rowCentred:{alignItems:"center"},iconWrap:{marginRight:r},iconCircle:{marginRight:r},iconGlyph:{lineHeight:17},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,..._corners.smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};var _default=exports.default=Banner;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BANNER_LABELS=exports.Banner=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"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../IconBadge/index.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BANNER_LABELS=exports.DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"}),Banner=exports.Banner=(0,_react.forwardRef)((e,t)=>{const{title:r,message:i,tone:s="neutral",variant:n="bar",icon:a,actions:o,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:m=!0,loading:x=!1,accessibilityRole:p="alert",accessibilityLabel:_,labels:g,style:h,containerStyle:y,iconCircleStyle:b,tintBarStyle:f,closeButtonStyle:j,actionButtonStyle:R,testID:v}=e;(0,_assertValidValue.assertValidValue)("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Banner","variant",e.variant,["bar","wash","tint"]),(0,_assertValidValue.assertValidValue)("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const w=(0,_index.useTheme)(),V=(0,_usePresenceMotion.usePresenceMotion)(),B=(0,_react.useMemo)(()=>buildStyles(w),[w]),S=(0,_react.useMemo)(()=>tintFor(w,s),[w,s]),N=(0,_react.useMemo)(()=>({...DEFAULT_BANNER_LABELS,...g}),[g]),[C,k]=V.range(-20,0),A=(0,_react.useRef)((0,_index.createAnimatedValue)(m&&u?C:0)).current,L=(0,_react.useRef)((0,_index.createAnimatedValue)(m&&u?0:u?1:0)).current,[I,E]=(0,_react.useState)(u),D=(0,_react.useRef)(!0);if((0,_react.useEffect)(()=>{if(D.current&&(D.current=!1,!m))return;let e;return u?(E(!0),e=_reactNative.Animated.parallel([_reactNative.Animated.timing(A,{toValue:k,duration:w.motion.duration.default,useNativeDriver:!0}),_reactNative.Animated.timing(L,{toValue:1,duration:V.duration("default"),useNativeDriver:!0})]),e.start()):I&&(e=_reactNative.Animated.parallel([_reactNative.Animated.timing(A,{toValue:C,duration:w.motion.duration.fast,useNativeDriver:!0}),_reactNative.Animated.timing(L,{toValue:0,duration:V.duration("fast"),useNativeDriver:!0})]),e.start(()=>{E(!1)})),()=>e?.stop()},[u]),!I)return null;const T=r??" ",q="string"==typeof i?i??" ":"",H="wash"===n,M="bar"!==n,z="alert"===p?"danger"===s?"assertive":"polite":"none",P=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{ref:t,accessibilityRole:p,accessibilityLiveRegion:z,accessibilityLabel:_,testID:v,style:[B.container,{backgroundColor:M?S.soft:w.colors["bg-subtle"],borderRadius:H?w.radius.sm:w.radius.md,..._corners.smoothCorners,padding:w.space.md,opacity:L,transform:[{translateY:A}]},y,h],children:[!H&&w.components.banner["tint-bar-width"]>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[B.tintBar,{backgroundColor:S.bar},f]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[B.row,void 0===r&&B.rowCentred],children:[!1===a?null:a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.iconWrap,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(a,{color:S.ink,size:w.text.xl.size,disabled:!1})}):(0,_jsxRuntime.jsx)(_index2.IconBadge,{dimension:ICON_CIRCLE_SIZE,color:S.bar,icon:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"bold",accessible:!1,style:[B.iconGlyph,{color:S.ink}],children:S.glyph}),style:[B.iconCircle,b]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:B.textBlock,children:[r||x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",numberOfLines:2,style:{lineHeight:20,...H?{color:S.ink}:null},children:T}):null,"string"==typeof i||x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{lineHeight:18,marginTop:r?w.space.xxs:0},children:q||" "}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginTop:r?w.space.xxs:0},children:i})]}),l?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:N.dismiss,onPress:()=>{const e=(0,_hapticUtils.resolveHaptic)(d,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),c?.()},hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),style:({pressed:e})=>[B.closeBtn,{backgroundColor:e?w.colors["surface-pressed"]:"transparent"},j],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:17},children:"×"})}):null]}),o&&o.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.actionsRow,children:o.map((e,t)=>{(0,_assertValidValue.assertValidValue)("Banner","action.tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Banner","action.variant",e.variant,["solid","outline","ghost"]),(0,_assertValidValue.assertValidValue)("Banner","action.size",e.size,["sm","md"]);const r=e.tone??"primary",i=e.variant??"ghost",s="primary"===r?S.glyphColor:"neutral"===r?w.colors["text-muted"]:w.colors[r],n="primary"===r?S.ink:"neutral"===r?w.colors["text-muted"]:w.colors[`${r}-text`],a="primary"===r?S.on:"neutral"===r?w.colors["on-neutral-strong"]:w.colors[`on-${r}`],o="solid"===i;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,testID:e.testID,onPress:()=>{const t=(0,_hapticUtils.resolveHaptic)(d,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:({pressed:t})=>[B.actionBtn,"md"===e.size&&B.actionBtnMd,"outline"===i&&{borderWidth:1,borderColor:n},{backgroundColor:o?s:t?w.colors["surface-pressed"]:"transparent",opacity:o&&t?.85:1},R],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:o?a:n},children:e.label})},`${e.label}-${t}`)})}):null]});return x?(0,_jsxRuntime.jsx)(BannerSkeleton,{...e}):P});Banner.displayName="Banner";const BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:i,style:s})=>{const n=(0,_index.useTheme)(),a=!1!==r;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:n.colors.surface,borderRadius:n.radius.md,..._corners.smoothCorners,padding:n.space.md,borderWidth:1,borderColor:n.colors.border},i,s],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:n.space.sm},children:(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"circle",width:32,height:32})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},children:[void 0!==e?(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:n.space.xs}}):null,(0,_jsxRuntime.jsx)(_index3.SkeletonText,{lines:2,fontSize:n.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:n.space.sm},children:t.map((e,t)=>(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:n.space.sm}},`sk-banner-action-${t}`))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton",Banner.Skeleton=BannerSkeleton;const tintFor=(e,t)=>{switch(t){case"success":return{soft:e.colors["success-soft"],bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{soft:e.colors["warning-soft"],bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{soft:e.colors["danger-soft"],bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{soft:e.colors["bg-subtle"],bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};case"primary":return{soft:e.colors["primary-soft"],bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"};case"info":return{soft:e.colors["info-soft"],bar:e.colors.info,glyphColor:e.colors.info,ink:e.colors["info-text"],on:e.colors["on-info"],glyph:"i"};default:return tintFor(e,"neutral")}},ICON_CIRCLE_SIZE=28,buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return _reactNative.StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},rowCentred:{alignItems:"center"},iconWrap:{marginRight:r},iconCircle:{marginRight:r},iconGlyph:{lineHeight:17},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,..._corners.smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};var _default=exports.default=Banner;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BAR_CHART_LABELS=exports.BarChart=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_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"),_index4=require("../Text/index.js"),_scale=require("./scale.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BAR_CHART_LABELS=exports.DEFAULT_BAR_CHART_LABELS=Object.freeze({chart:"Bar chart",noData:"no data",highest:(e,t)=>`Highest: ${e}, ${t}`}),AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=8,SWATCH_SIZE=10,STACK_TONES=["primary","info","success","warning","danger","neutral"],FONT_SCALE_CAP=1.2,toneColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],safe=e=>"number"==typeof e&&Number.isFinite(e)?e:0,defaultFormatValue=e=>(0,_mobileCore.formatNumber)(e),defaultFormatTick=e=>(0,_mobileCore.formatCompactNumber)(e),BarChart=exports.BarChart=(0,_react.forwardRef)((e,t)=>{const{data:r,tone:a="primary",color:i,series:s,height:n=160,label:l,summary:o,formatValue:c=defaultFormatValue,formatTick:u=defaultFormatTick,showValues:d,selection:m,defaultSelection:_=null,onSelect:x,haptic:h,labels:p,style:b,testID:f}=e;(0,_warnInvalidValue.warnInvalidValue)("BarChart","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const y=(0,_react.useMemo)(()=>({...DEFAULT_BAR_CHART_LABELS,...p}),[p]),j=(0,_index2.useTheme)(),v=r.length,[R,g]=(0,_react.useState)(0),[w,S]=(0,_index.useControllableState)({value:m,defaultValue:_,onChange:x}),T=null!==w&&w>=0&&w<v?w:null,C=(0,_react.useRef)(T);C.current=T;const A=(0,_react.useRef)(-1),M=(0,_index3.resolveHaptic)(h,"tick"),N=(0,_react.useCallback)(()=>{M&&(0,_index3.triggerHaptic)(M)},[M]),L=d??(v>0&&v<=7),V=void 0!==s&&s.length>0,E=(0,_react.useMemo)(()=>V?s.map((e,t)=>e.tone??STACK_TONES[t%STACK_TONES.length]):[],[V,s]),I=(0,_react.useMemo)(()=>V?s.map(e=>e.key):[],[V,s]),B=(0,_react.useMemo)(()=>V?r.map(e=>s.map(t=>safe(e.values?.[t.key]))):null,[r,s,V]),D=(0,_react.useMemo)(()=>B?B.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,B]),H=(0,_react.useMemo)(()=>B?B.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):D,[B,D]),$=(0,_react.useMemo)(()=>(0,_scale.barScale)(H),[H]),k=L?20:6,O=L&&$.min<0?20:6,F=Math.max(1,n-k-O),G=(0,_react.useCallback)(e=>k+($.max-e)/($.max-$.min)*F,[k,$.max,$.min,F]),q=G(0),W=(0,_react.useMemo)(()=>$.ticks.map(e=>u(e)),[$.ticks,u]),U=Math.ceil(8*Math.max(...W.map(e=>e.length),1)*1.2)+j.space.xs,z=v>0?R/v:0,P=Math.max(1,Math.ceil(44/Math.max(1,z||44))),X=(0,_react.useCallback)(e=>{const t=r[e];return t.accessibilityLabel?t.accessibilityLabel:B&&s?`${t.label}, ${s.map((t,r)=>`${t.label} ${c(B[e][r])}`).join(", ")}`:`${t.label}, ${c(D[e])}`},[r,c,D,B,s]),K=(0,_react.useMemo)(()=>{let e=-1;return D.forEach((t,r)=>{(-1===e||t>D[e])&&(e=r)}),e},[D]),J=o??(K>=0?y.highest(r[K].label,c(D[K])):""),Y=(0,_react.useRef)({fire:N,setSelected:S,count:v,plotWidth:R});Y.current={fire:N,setSelected:S,count:v,plotWidth:R};const Z=(0,_react.useMemo)(()=>{const indexAt=e=>{const{count:t,plotWidth:r}=Y.current;return 0===t||r<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e/r*t)))},scrubTo=e=>{const t=indexAt(e);t<0||t===A.current||(A.current=t,Y.current.fire(),Y.current.setSelected(t))},e=_reactNativeGestureHandler.Gesture.Pan().runOnJS(!0).activeOffsetX([-8,8]).failOffsetY([-12,12]).onStart(e=>{A.current=C.current??-1,scrubTo(e.x)}).onUpdate(e=>scrubTo(e.x)).withTestId(f?`${f}-pan`:"bar-chart-pan"),t=_reactNativeGestureHandler.Gesture.Tap().runOnJS(!0).onEnd((e,t)=>{if(!t)return;const r=indexAt(e.x);r<0||(Y.current.fire(),A.current=r,Y.current.setSelected(r===C.current?null:r))}).withTestId(f?`${f}-tap`:"bar-chart-tap");return _reactNativeGestureHandler.Gesture.Race(e,t)},[f]),Q=(0,_react.useCallback)(e=>{if(0===v)return;const t=C.current,r="increment"===e.nativeEvent.actionName?null===t?0:Math.min(v-1,t+1):null===t?v-1:Math.max(0,t-1);r!==t&&(N(),S(r))},[v,N,S]),ee=(0,_react.useCallback)(e=>{const t=Math.round(e.nativeEvent.layout.width);g(e=>e===t?e:t)},[]),te=i??toneColor(j,a),re=j.radius.sm,ae=l??y.chart,ie=0===v?`${ae}, ${y.noData}`:J?`${ae}, ${J}`:ae,se=null===T?J:X(T),ne=Math.min(40,Math.max(4,.6*z)),renderStack=(e,t,r)=>{const a=e.reduce((e,t)=>t>0?e+t:e,0),i=e.reduce((e,t)=>t<0?e+t:e,0);if(0===a&&0===i)return null;const s=G(a),n=[];let l=0,o=0;return e.forEach((e,r)=>{if(0===e)return;const a=e>0?l:o,i=a+e;e>0?l=i:o=i;const c=G(a),u=G(i);n.push((0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}-series-${r}`:void 0,style:{position:"absolute",left:0,right:0,top:Math.min(c,u)-s,height:Math.abs(c-u),backgroundColor:toneColor(j,E[r])}},I[r]))}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:s,width:ne,height:Math.max(2,G(i)-s),overflow:"hidden",opacity:r?.4:1,..._corners.smoothCorners,...a>0?{borderTopLeftRadius:re,borderTopRightRadius:re}:null,...i<0?{borderBottomLeftRadius:re,borderBottomRightRadius:re}:null},children:n})},le=D.map((e,t)=>{const r=G(e),a=e>=0?r:q,i=0===e?0:Math.max(2,Math.abs(r-q)),s=null!==T&&T!==t;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.slot,{height:n}],children:[R>0&&B?renderStack(B[t],t,s):null,R>0&&!B&&i>0?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:a,width:ne,height:i,backgroundColor:te,opacity:s?.4:1,..._corners.smoothCorners,...e>=0?{borderTopLeftRadius:re,borderTopRightRadius:re}:{borderBottomLeftRadius:re,borderBottomRightRadius:re}}}):null,L&&R>0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",left:0,right:0,top:e>=0?(B?G(H[2*t]):r)-20+2:(B?G(H[2*t+1]):r)+2},children:u(e)}):null]},t)});return 0===v?(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:f,style:[styles.root,b],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:"No data"})}):(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:ie,accessibilityValue:{min:0,max:v-1,now:T??0,text:se},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Q,testID:f,style:[styles.root,b],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.header,{minHeight:48,marginBottom:j.space.sm}],children:null===T?J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:J}):null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:r[T].label}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",numberOfLines:1,testID:f?`${f}-callout`:void 0,children:c(D[T])})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.body,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:U,height:n},children:$.ticks.map((e,t)=>(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",align:"right",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",right:j.space.xs,left:0,top:G(e)-8},children:W[t]},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.plotColumn,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Z,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{height:n},onLayout:ee,testID:f?`${f}-plot`:void 0,children:[$.ticks.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:{position:"absolute",left:0,right:0,top:G(e)-(0===e?.75:_reactNative.StyleSheet.hairlineWidth),height:0===e?1.5:2*_reactNative.StyleSheet.hairlineWidth,backgroundColor:0===e?j.colors["text-subtle"]:j.colors["border-subtle"]}},e)),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.slots,{height:n}],children:le})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axis,children:r.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axisSlot,children:t%P===0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:T===t?"primary":"tertiary",weight:T===t?"semibold":void 0,align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:z>0?{width:z*P}:void 0,children:e.axisLabel??e.label}):null},t))})]})]}),s&&V?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.legend,{marginTop:j.space.sm,columnGap:j.space.md,rowGap:j.space.xs}],children:s.map((e,t)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.legendItem,{columnGap:j.space.xs}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:10,height:10,borderRadius:j.radius.sm,..._corners.smoothCorners,backgroundColor:toneColor(j,E[t])}}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,children:e.label})]},e.key))}):null]})});BarChart.displayName="BarChart";const styles=_reactNative.StyleSheet.create({root:{alignSelf:"stretch"},header:{justifyContent:"center"},body:{flexDirection:"row"},plotColumn:{flex:1},slots:{flexDirection:"row"},slot:{flex:1},axis:{flexDirection:"row"},legend:{flexDirection:"row",flexWrap:"wrap"},legendItem:{flexDirection:"row",alignItems:"center"},axisSlot:{flex:1,alignItems:"center",overflow:"visible"}});var _default=exports.default=BarChart;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BAR_CHART_LABELS=exports.BarChart=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_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"),_index4=require("../Text/index.js"),_scale=require("./scale.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BAR_CHART_LABELS=exports.DEFAULT_BAR_CHART_LABELS=Object.freeze({chart:"Bar chart",noData:"no data",highest:(e,t)=>`Highest: ${e}, ${t}`}),AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=8,SWATCH_SIZE=10,STACK_TONES=["primary","info","success","warning","danger","neutral"],FONT_SCALE_CAP=1.2,toneColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],safe=e=>"number"==typeof e&&Number.isFinite(e)?e:0,defaultFormatValue=e=>(0,_mobileCore.formatNumber)(e),defaultFormatTick=e=>(0,_mobileCore.formatCompactNumber)(e),BarChart=exports.BarChart=(0,_react.forwardRef)((e,t)=>{const{data:r,tone:a="primary",color:i,series:s,height:n=160,label:l,summary:o,formatValue:c=defaultFormatValue,formatTick:u=defaultFormatTick,showValues:d,selection:m,defaultSelection:_=null,onSelect:x,haptic:h,labels:p,style:b,testID:f}=e;(0,_assertValidValue.assertValidValue)("BarChart","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const y=(0,_react.useMemo)(()=>({...DEFAULT_BAR_CHART_LABELS,...p}),[p]),j=(0,_index2.useTheme)(),R=r.length,[v,g]=(0,_react.useState)(0),[S,T]=(0,_index.useControllableState)({value:m,defaultValue:_,onChange:x}),C=null!==S&&S>=0&&S<R?S:null,w=(0,_react.useRef)(C);w.current=C;const A=(0,_react.useRef)(-1),M=(0,_index3.resolveHaptic)(h,"tick"),N=(0,_react.useCallback)(()=>{M&&(0,_index3.triggerHaptic)(M)},[M]),L=d??(R>0&&R<=7),V=void 0!==s&&s.length>0,E=(0,_react.useMemo)(()=>V?s.map((e,t)=>e.tone??STACK_TONES[t%STACK_TONES.length]):[],[V,s]),B=(0,_react.useMemo)(()=>V?s.map(e=>e.key):[],[V,s]),D=(0,_react.useMemo)(()=>V?r.map(e=>s.map(t=>safe(e.values?.[t.key]))):null,[r,s,V]),H=(0,_react.useMemo)(()=>D?D.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,D]),I=(0,_react.useMemo)(()=>D?D.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):H,[D,H]),$=(0,_react.useMemo)(()=>(0,_scale.barScale)(I),[I]),k=L?20:6,O=L&&$.min<0?20:6,F=Math.max(1,n-k-O),G=(0,_react.useCallback)(e=>k+($.max-e)/($.max-$.min)*F,[k,$.max,$.min,F]),q=G(0),W=(0,_react.useMemo)(()=>$.ticks.map(e=>u(e)),[$.ticks,u]),U=Math.ceil(8*Math.max(...W.map(e=>e.length),1)*1.2)+j.space.xs,z=R>0?v/R:0,P=Math.max(1,Math.ceil(44/Math.max(1,z||44))),X=(0,_react.useCallback)(e=>{const t=r[e];return t.accessibilityLabel?t.accessibilityLabel:D&&s?`${t.label}, ${s.map((t,r)=>`${t.label} ${c(D[e][r])}`).join(", ")}`:`${t.label}, ${c(H[e])}`},[r,c,H,D,s]),K=(0,_react.useMemo)(()=>{let e=-1;return H.forEach((t,r)=>{(-1===e||t>H[e])&&(e=r)}),e},[H]),J=o??(K>=0?y.highest(r[K].label,c(H[K])):""),Y=(0,_react.useRef)({fire:N,setSelected:T,count:R,plotWidth:v});Y.current={fire:N,setSelected:T,count:R,plotWidth:v};const Z=(0,_react.useMemo)(()=>{const indexAt=e=>{const{count:t,plotWidth:r}=Y.current;return 0===t||r<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e/r*t)))},scrubTo=e=>{const t=indexAt(e);t<0||t===A.current||(A.current=t,Y.current.fire(),Y.current.setSelected(t))},e=_reactNativeGestureHandler.Gesture.Pan().runOnJS(!0).activeOffsetX([-8,8]).failOffsetY([-12,12]).onStart(e=>{A.current=w.current??-1,scrubTo(e.x)}).onUpdate(e=>scrubTo(e.x)).withTestId(f?`${f}-pan`:"bar-chart-pan"),t=_reactNativeGestureHandler.Gesture.Tap().runOnJS(!0).onEnd((e,t)=>{if(!t)return;const r=indexAt(e.x);r<0||(Y.current.fire(),A.current=r,Y.current.setSelected(r===w.current?null:r))}).withTestId(f?`${f}-tap`:"bar-chart-tap");return _reactNativeGestureHandler.Gesture.Race(e,t)},[f]),Q=(0,_react.useCallback)(e=>{if(0===R)return;const t=w.current,r="increment"===e.nativeEvent.actionName?null===t?0:Math.min(R-1,t+1):null===t?R-1:Math.max(0,t-1);r!==t&&(N(),T(r))},[R,N,T]),ee=(0,_react.useCallback)(e=>{const t=Math.round(e.nativeEvent.layout.width);g(e=>e===t?e:t)},[]),te=i??toneColor(j,a),re=j.radius.sm,ae=l??y.chart,ie=0===R?`${ae}, ${y.noData}`:J?`${ae}, ${J}`:ae,se=null===C?J:X(C),ne=Math.min(40,Math.max(4,.6*z)),renderStack=(e,t,r)=>{const a=e.reduce((e,t)=>t>0?e+t:e,0),i=e.reduce((e,t)=>t<0?e+t:e,0);if(0===a&&0===i)return null;const s=G(a),n=[];let l=0,o=0;return e.forEach((e,r)=>{if(0===e)return;const a=e>0?l:o,i=a+e;e>0?l=i:o=i;const c=G(a),u=G(i);n.push((0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}-series-${r}`:void 0,style:{position:"absolute",left:0,right:0,top:Math.min(c,u)-s,height:Math.abs(c-u),backgroundColor:toneColor(j,E[r])}},B[r]))}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:s,width:ne,height:Math.max(2,G(i)-s),overflow:"hidden",opacity:r?.4:1,..._corners.smoothCorners,...a>0?{borderTopLeftRadius:re,borderTopRightRadius:re}:null,...i<0?{borderBottomLeftRadius:re,borderBottomRightRadius:re}:null},children:n})},le=H.map((e,t)=>{const r=G(e),a=e>=0?r:q,i=0===e?0:Math.max(2,Math.abs(r-q)),s=null!==C&&C!==t;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.slot,{height:n}],children:[v>0&&D?renderStack(D[t],t,s):null,v>0&&!D&&i>0?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:f?`${f}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:a,width:ne,height:i,backgroundColor:te,opacity:s?.4:1,..._corners.smoothCorners,...e>=0?{borderTopLeftRadius:re,borderTopRightRadius:re}:{borderBottomLeftRadius:re,borderBottomRightRadius:re}}}):null,L&&v>0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",left:0,right:0,top:e>=0?(D?G(I[2*t]):r)-20+2:(D?G(I[2*t+1]):r)+2},children:u(e)}):null]},t)});return 0===R?(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:f,style:[styles.root,b],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:"No data"})}):(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:ie,accessibilityValue:{min:0,max:R-1,now:C??0,text:se},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Q,testID:f,style:[styles.root,b],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.header,{minHeight:48,marginBottom:j.space.sm}],children:null===C?J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:J}):null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:r[C].label}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",numberOfLines:1,testID:f?`${f}-callout`:void 0,children:c(H[C])})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.body,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:U,height:n},children:$.ticks.map((e,t)=>(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",align:"right",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",right:j.space.xs,left:0,top:G(e)-8},children:W[t]},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.plotColumn,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Z,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{height:n},onLayout:ee,testID:f?`${f}-plot`:void 0,children:[$.ticks.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:{position:"absolute",left:0,right:0,top:G(e)-(0===e?.75:_reactNative.StyleSheet.hairlineWidth),height:0===e?1.5:2*_reactNative.StyleSheet.hairlineWidth,backgroundColor:0===e?j.colors["text-subtle"]:j.colors["border-subtle"]}},e)),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.slots,{height:n}],children:le})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axis,children:r.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axisSlot,children:t%P===0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:C===t?"primary":"tertiary",weight:C===t?"semibold":void 0,align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:z>0?{width:z*P}:void 0,children:e.axisLabel??e.label}):null},t))})]})]}),s&&V?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.legend,{marginTop:j.space.sm,columnGap:j.space.md,rowGap:j.space.xs}],children:s.map((e,t)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.legendItem,{columnGap:j.space.xs}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:10,height:10,borderRadius:j.radius.sm,..._corners.smoothCorners,backgroundColor:toneColor(j,E[t])}}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,children:e.label})]},e.key))}):null]})});BarChart.displayName="BarChart";const styles=_reactNative.StyleSheet.create({root:{alignSelf:"stretch"},header:{justifyContent:"center"},body:{flexDirection:"row"},plotColumn:{flex:1},slots:{flexDirection:"row"},slot:{flex:1},axis:{flexDirection:"row"},legend:{flexDirection:"row",flexWrap:"wrap"},legendItem:{flexDirection:"row",alignItems:"center"},axisSlot:{flex:1,alignItems:"center",overflow:"visible"}});var _default=exports.default=BarChart;