@webority/mobile-ui 0.144.2 → 0.146.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/dist/canvas-kit/kit.js +4429 -3708
  2. package/dist/canvas-kit/manifest.json +1 -1
  3. package/dist/canvas-kit/release.json +5 -5
  4. package/lib/commonjs/components/Accordion/Accordion.js +1 -1
  5. package/lib/commonjs/components/AmountSlider/AmountSlider.js +1 -1
  6. package/lib/commonjs/components/AnimatePresence/AnimatePresence.js +1 -1
  7. package/lib/commonjs/components/AppBar/AppBar.js +1 -1
  8. package/lib/commonjs/components/AppIcon/AppIcon.js +1 -1
  9. package/lib/commonjs/components/AsyncBlock/AsyncBlock.js +1 -1
  10. package/lib/commonjs/components/AuthedImage/AuthedImage.js +1 -1
  11. package/lib/commonjs/components/Autocomplete/Autocomplete.js +1 -1
  12. package/lib/commonjs/components/Avatar/Avatar.js +1 -1
  13. package/lib/commonjs/components/Badge/Badge.js +1 -1
  14. package/lib/commonjs/components/Banner/Banner.js +1 -1
  15. package/lib/commonjs/components/BarChart/BarChart.js +1 -1
  16. package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
  17. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  18. package/lib/commonjs/components/Button/Button.js +1 -1
  19. package/lib/commonjs/components/Calendar/Calendar.js +1 -1
  20. package/lib/commonjs/components/Card/Card.js +1 -1
  21. package/lib/commonjs/components/Carousel/Carousel.js +1 -1
  22. package/lib/commonjs/components/Checkbox/Checkbox.js +1 -1
  23. package/lib/commonjs/components/Chip/Chip.js +1 -1
  24. package/lib/commonjs/components/ChoiceGroup/ChoiceGroup.js +1 -1
  25. package/lib/commonjs/components/Confetti/Confetti.js +1 -1
  26. package/lib/commonjs/components/Descriptions/Descriptions.js +1 -1
  27. package/lib/commonjs/components/Dialog/Dialog.js +1 -1
  28. package/lib/commonjs/components/Dialog/OverlayActions.js +1 -1
  29. package/lib/commonjs/components/Divider/Divider.js +1 -1
  30. package/lib/commonjs/components/Drawer/Drawer.js +1 -1
  31. package/lib/commonjs/components/EmptyState/EmptyState.js +1 -1
  32. package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
  33. package/lib/commonjs/components/FilePicker/FilePicker.js +1 -1
  34. package/lib/commonjs/components/FileViewer/FileViewer.js +1 -1
  35. package/lib/commonjs/components/FilterChipRow/FilterChipRow.js +1 -1
  36. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  37. package/lib/commonjs/components/FormField/FormField.js +1 -1
  38. package/lib/commonjs/components/IconBadge/IconBadge.js +1 -1
  39. package/lib/commonjs/components/IconButton/IconButton.js +1 -1
  40. package/lib/commonjs/components/InlineSelect/InlineSelect.js +1 -1
  41. package/lib/commonjs/components/Input/Input.js +1 -1
  42. package/lib/commonjs/components/ListItem/ListItem.js +1 -1
  43. package/lib/commonjs/components/ListSection/ListSection.js +1 -1
  44. package/lib/commonjs/components/Menu/Menu.js +1 -1
  45. package/lib/commonjs/components/Menu/useContextMenu.js +1 -1
  46. package/lib/commonjs/components/MessageBubble/MessageBubble.js +1 -1
  47. package/lib/commonjs/components/Modal/Modal.js +1 -1
  48. package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
  49. package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
  50. package/lib/commonjs/components/PermissionPrompt/PermissionPrompt.js +1 -1
  51. package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  52. package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +1 -1
  53. package/lib/commonjs/components/ProfileCompletion/ProfileCompletion.js +1 -1
  54. package/lib/commonjs/components/ProfilePicker/ProfilePicker.js +1 -1
  55. package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
  56. package/lib/commonjs/components/ProgressRing/ProgressRing.js +1 -1
  57. package/lib/commonjs/components/Radio/Radio.js +1 -1
  58. package/lib/commonjs/components/Rating/Rating.js +1 -1
  59. package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -1
  60. package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
  61. package/lib/commonjs/components/SectionHeader/SectionHeader.js +1 -1
  62. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
  63. package/lib/commonjs/components/Select/Select.js +1 -1
  64. package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
  65. package/lib/commonjs/components/Skeleton/Skeleton.js +1 -1
  66. package/lib/commonjs/components/Skeleton/SkeletonContent.js +1 -1
  67. package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +1 -1
  68. package/lib/commonjs/components/Slider/Slider.js +1 -1
  69. package/lib/commonjs/components/SliderField/SliderField.js +1 -1
  70. package/lib/commonjs/components/Sparkline/Sparkline.js +1 -1
  71. package/lib/commonjs/components/Spinner/Spinner.js +1 -1
  72. package/lib/commonjs/components/StatTile/StatTile.js +1 -1
  73. package/lib/commonjs/components/StatusBadge/StatusBadge.js +1 -1
  74. package/lib/commonjs/components/Stepper/Stepper.js +1 -1
  75. package/lib/commonjs/components/Swipeable/Swipeable.js +1 -1
  76. package/lib/commonjs/components/Switch/Switch.js +1 -1
  77. package/lib/commonjs/components/Tabs/Tabs.js +1 -1
  78. package/lib/commonjs/components/TagInput/TagInput.js +1 -1
  79. package/lib/commonjs/components/Text/Text.js +1 -1
  80. package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
  81. package/lib/commonjs/components/Timeline/Timeline.js +1 -1
  82. package/lib/commonjs/components/Toast/Toast.js +1 -1
  83. package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
  84. package/lib/commonjs/components/WheelPicker/WheelPicker.js +1 -1
  85. package/lib/commonjs/utils/assertValidValue.js +1 -0
  86. package/lib/module/components/Accordion/Accordion.js +1 -1
  87. package/lib/module/components/AmountSlider/AmountSlider.js +1 -1
  88. package/lib/module/components/AnimatePresence/AnimatePresence.js +1 -1
  89. package/lib/module/components/AppBar/AppBar.js +1 -1
  90. package/lib/module/components/AppIcon/AppIcon.js +1 -1
  91. package/lib/module/components/AsyncBlock/AsyncBlock.js +1 -1
  92. package/lib/module/components/AuthedImage/AuthedImage.js +1 -1
  93. package/lib/module/components/Autocomplete/Autocomplete.js +1 -1
  94. package/lib/module/components/Avatar/Avatar.js +1 -1
  95. package/lib/module/components/Badge/Badge.js +1 -1
  96. package/lib/module/components/Banner/Banner.js +1 -1
  97. package/lib/module/components/BarChart/BarChart.js +1 -1
  98. package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
  99. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  100. package/lib/module/components/Button/Button.js +1 -1
  101. package/lib/module/components/Calendar/Calendar.js +1 -1
  102. package/lib/module/components/Card/Card.js +1 -1
  103. package/lib/module/components/Carousel/Carousel.js +1 -1
  104. package/lib/module/components/Checkbox/Checkbox.js +1 -1
  105. package/lib/module/components/Chip/Chip.js +1 -1
  106. package/lib/module/components/ChoiceGroup/ChoiceGroup.js +1 -1
  107. package/lib/module/components/Confetti/Confetti.js +1 -1
  108. package/lib/module/components/Descriptions/Descriptions.js +1 -1
  109. package/lib/module/components/Dialog/Dialog.js +1 -1
  110. package/lib/module/components/Dialog/OverlayActions.js +1 -1
  111. package/lib/module/components/Divider/Divider.js +1 -1
  112. package/lib/module/components/Drawer/Drawer.js +1 -1
  113. package/lib/module/components/EmptyState/EmptyState.js +1 -1
  114. package/lib/module/components/FieldBase/FieldBase.js +1 -1
  115. package/lib/module/components/FilePicker/FilePicker.js +1 -1
  116. package/lib/module/components/FileViewer/FileViewer.js +1 -1
  117. package/lib/module/components/FilterChipRow/FilterChipRow.js +1 -1
  118. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
  119. package/lib/module/components/FormField/FormField.js +1 -1
  120. package/lib/module/components/IconBadge/IconBadge.js +1 -1
  121. package/lib/module/components/IconButton/IconButton.js +1 -1
  122. package/lib/module/components/InlineSelect/InlineSelect.js +1 -1
  123. package/lib/module/components/Input/Input.js +1 -1
  124. package/lib/module/components/ListItem/ListItem.js +1 -1
  125. package/lib/module/components/ListSection/ListSection.js +1 -1
  126. package/lib/module/components/Menu/Menu.js +1 -1
  127. package/lib/module/components/Menu/useContextMenu.js +1 -1
  128. package/lib/module/components/MessageBubble/MessageBubble.js +1 -1
  129. package/lib/module/components/Modal/Modal.js +1 -1
  130. package/lib/module/components/NumberInput/NumberInput.js +1 -1
  131. package/lib/module/components/OTPInput/OTPInput.js +1 -1
  132. package/lib/module/components/PermissionPrompt/PermissionPrompt.js +1 -1
  133. package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  134. package/lib/module/components/PickerTrigger/PickerTrigger.js +1 -1
  135. package/lib/module/components/ProfileCompletion/ProfileCompletion.js +1 -1
  136. package/lib/module/components/ProfilePicker/ProfilePicker.js +1 -1
  137. package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
  138. package/lib/module/components/ProgressRing/ProgressRing.js +1 -1
  139. package/lib/module/components/Radio/Radio.js +1 -1
  140. package/lib/module/components/Rating/Rating.js +1 -1
  141. package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -1
  142. package/lib/module/components/SearchBar/SearchBar.js +1 -1
  143. package/lib/module/components/SectionHeader/SectionHeader.js +1 -1
  144. package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
  145. package/lib/module/components/Select/Select.js +1 -1
  146. package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
  147. package/lib/module/components/Skeleton/Skeleton.js +1 -1
  148. package/lib/module/components/Skeleton/SkeletonContent.js +1 -1
  149. package/lib/module/components/SlideToConfirm/SlideToConfirm.js +1 -1
  150. package/lib/module/components/Slider/Slider.js +1 -1
  151. package/lib/module/components/SliderField/SliderField.js +1 -1
  152. package/lib/module/components/Sparkline/Sparkline.js +1 -1
  153. package/lib/module/components/Spinner/Spinner.js +1 -1
  154. package/lib/module/components/StatTile/StatTile.js +1 -1
  155. package/lib/module/components/StatusBadge/StatusBadge.js +1 -1
  156. package/lib/module/components/Stepper/Stepper.js +1 -1
  157. package/lib/module/components/Swipeable/Swipeable.js +1 -1
  158. package/lib/module/components/Switch/Switch.js +1 -1
  159. package/lib/module/components/Tabs/Tabs.js +1 -1
  160. package/lib/module/components/TagInput/TagInput.js +1 -1
  161. package/lib/module/components/Text/Text.js +1 -1
  162. package/lib/module/components/TimePicker/TimePicker.js +1 -1
  163. package/lib/module/components/Timeline/Timeline.js +1 -1
  164. package/lib/module/components/Toast/Toast.js +1 -1
  165. package/lib/module/components/Tooltip/Tooltip.js +1 -1
  166. package/lib/module/components/WheelPicker/WheelPicker.js +1 -1
  167. package/lib/module/utils/assertValidValue.js +1 -0
  168. package/lib/typescript/commonjs/utils/assertValidValue.d.ts +10 -0
  169. package/lib/typescript/module/utils/assertValidValue.d.ts +10 -0
  170. package/package.json +7 -7
  171. package/lib/commonjs/utils/warnInvalidValue.js +0 -1
  172. package/lib/module/utils/warnInvalidValue.js +0 -1
  173. package/lib/typescript/commonjs/utils/warnInvalidValue.d.ts +0 -10
  174. package/lib/typescript/module/utils/warnInvalidValue.d.ts +0 -10
@@ -1 +1 @@
1
- "use strict";import React,{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,LayoutAnimation,Platform,Pressable,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/index.js";import{Badge}from"../Badge/index.js";import{Text}from"../Text/index.js";import{useScreenReaderEnabled}from"./useScreenReaderEnabled.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_BOTTOM_NAVIGATION_LABELS=Object.freeze({switchesTo:e=>`Switches to ${e}`,unread:e=>`${e} unread`,newUpdates:"new updates"});const DEFAULT_ICON_SIZE=18,DEFAULT_LABEL_MAX_FONT_SCALE=1.2,ICON_WRAP_AIR=4,PILL_AIR=8,DEFAULT_PILL_MAX_WIDTH=64,TILE_MAX_WIDTH=96,DEFAULT_UNDERLINE_HEIGHT=3,DEFAULT_BUBBLE_SIZE=48,DEFAULT_BUBBLE_LIFT=14,DEFAULT_CENTER_SIZE=48,DEFAULT_CENTER_ICON_SIZE=24,CENTER_KEY="__center_action__",EXPANDED_FLEX=1.5,SOLID_INACTIVE_OPACITY=.7,TILE_INSET=2,badgeVariantOf=e=>null==e||!1===e?null:!0===e||"·"===e?"dot":"number"==typeof e?e>0?"standard":null:e.length>0?"standard":null,badgeAccessibilitySuffix=(e,t)=>null==e||!1===e?"":"number"==typeof e?e>0?`, ${t.unread(e)}`:"":!0===e||"·"===e?`, ${t.newUpdates}`:"string"==typeof e&&e.length>0?`, ${e}`:"",BottomNavigation=forwardRef((e,t)=>{const{tabs:i,centerAction:n,activeTab:o,onChange:a,haptic:r="selection",showLabels:s=!0,variant:l="pill",indicatorPosition:d="bottom",radius:c,indicatorRadius:u="auto",elevation:p,iconSize:m,marginHorizontal:h,marginVertical:g,paddingHorizontal:b,paddingVertical:f,border:x,minimizeOnScroll:y=!1,scrollDirection:_="idle",accessory:S,style:w,indicatorStyle:I,labelStyle:A,labelMaxFontScale:E,labels:R,testID:v}=e;warnInvalidValue("BottomNavigation","variant",e.variant,["pill","underline","floating","bubble","expand","solid","tile"]),warnInvalidValue("BottomNavigation","indicatorPosition",e.indicatorPosition,["top","bottom"]);const T=useMemo(()=>R?{...DEFAULT_BOTTOM_NAVIGATION_LABELS,...R}:DEFAULT_BOTTOM_NAVIGATION_LABELS,[R]),L=useTheme(),j=useSafeAreaInsets(),V=useMemo(()=>buildStyles(L),[L]),B=m??18,C=B+4+8,M=L.space.lg,D=L.space.lg,k=L.radius.xl,N=useReducedMotion(),P=useScreenReaderEnabled(y),[z,F]=React.useState(null);useEffect(()=>{null!==z&&z!==_&&F(null)},[z,_]);const H=y&&!P&&"down"===_&&null===z,[O,W]=React.useState(H);useEffect(()=>{O!==H&&(N||"web"===Platform.OS||LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut),W(H))},[O,H,N]);const U="function"==typeof S?S({minimized:O}):S,$=null!=U&&!1!==U,X=O&&$,[G,Z]=React.useState(0),Y=$&&!X?G+L.space.xs:0,K="tile"===l,q="floating"===l||K,J="bubble"===l,Q="expand"===l,ee="solid"===l,te="pill"===l||q||ee,ie=Math.max(0,i.findIndex(e=>e.key===o)),[ne,oe]=React.useState(0),[ae,re]=React.useState(0),se=n?Math.ceil(i.length/2):i.length,le=i.length+(n?1:0),[de,ce]=React.useState({width:0,height:0}),ue=n?.size??48,pe=void 0!==n?.gap,me=Math.max(0,n?.gap??0),he=pe?(de.width||ue)+2*me:0,ge=pe?i.length>0?Math.max(0,ne-he)/i.length:0:le>0?ne/le:0,be=pe?he:ge,fe=useRef(createAnimatedValue(ie)).current,xe=useRef({}),ye=useRef({});i.forEach(e=>{xe.current[e.key]||(xe.current[e.key]=new Animated.Value(1)),ye.current[e.key]||(ye.current[e.key]=createAnimatedValue(e.key===o?1:0))});const Se=ge>0?K?Math.min(ge-4,96):Math.min(ge-M,64):0,we=ge>0?(ge-Se)/2:0,Ie=ge>0?(ge-48)/2:0,hasLabel=e=>s&&!O&&!1!==e.showLabel&&e.label.trim().length>0,Ae=i[ie],Ee=Ae&&!hasLabel(Ae)&&ae>0?ae/2:L.space.xs+(B+4)/2,Re=Ee-14-24,ve=Math.max(0,ae-4),Te=K?2:Ee-C/2,Le=useRef(ie);useEffect(()=>{if(Le.current===ie)return;Le.current=ie;const e=Animated.spring(fe,{toValue:ie,tension:120,friction:14,useNativeDriver:!0});return e.start(),()=>e.stop()},[ie,fe]);const je=Math.max(1,i.length-1),Ve=useMemo(()=>{const e=[],t=[];for(let i=0;i<=je;i++)e.push(i),t.push(i<se?i*ge:i*ge+be);return fe.interpolate({inputRange:e,outputRange:t})},[fe,je,se,ge,be]),Be=i.map(e=>e.key).join(" "),Ce=J||Q;useEffect(()=>{const e=Be.split(" ").flatMap(e=>{const t=e===o?1:0,i=ye.current[e];return i?Ce?[Animated.spring(i,{toValue:t,tension:140,friction:13,useNativeDriver:!1})]:(i.setValue(t),[]):[]});if(0===e.length)return;const t=Animated.parallel(e);return t.start(),()=>t.stop()},[o,Be,Ce]);const popIcon=e=>{Animated.sequence([Animated.timing(e,{toValue:1.15,duration:120,useNativeDriver:!0}),Animated.spring(e,{toValue:1,tension:200,friction:8,useNativeDriver:!0})]).start()},Me=useRef(new Animated.Value(1)).current,{colors:De}=L,ke=ee?De.primary:De.surface,Ne=ee?De["on-primary"]:De.primary,Pe=ee?De["on-primary"]:K?De["text-body"]:De["text-subtle"],ze=ee?De["on-primary"]:De["primary-soft"],Fe=ee?De.primary:J?De["on-primary"]:Ne,He=h??D,Oe=g??(q?D:0),We=Oe>0,Ue=f??L.space.sm,$e=b??(q?L.space.sm:L.space.xs),Xe=We?Ue:Math.max(Ue,j.bottom),Ge=We?Math.max(Oe,j.bottom>0?j.bottom+L.space.sm:0):0,Ze="pill"===c,Ye=q?ae+Y+2*Ue+2*StyleSheet.hairlineWidth:ae+Y+Ue+Xe,Ke=Ze?ae>0?Ye/2:L.radius.pill:c??(K?L.radius.pill:q?k:L.radius.none),qe=void 0!==c,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&qe?Math.min(Ke,e/2):t,Je="underline"===l?Math.max($e,Ze&&0===ae?0:Ke):$e,Qe=p??"none",et="none"===Qe?void 0:L.shadow[Qe],tt=void 0===et?null:supportsBoxShadow()?{boxShadow:toBoxShadow(et)}:et,it=x?StyleSheet.hairlineWidth:0,nt=ee?De.primary:De.border,ot=n?.lift??0,at=Ue+it+Y,rt=n&&ae>0?Math.max(0,(de.height||ue)/2+ot-ae/2-at):0,st=n?_jsx(View,{style:[V.centerCell,pe?{flex:0,marginHorizontal:me}:null],pointerEvents:"box-none",children:_jsxs(Pressable,{onPress:()=>{if(!n)return;const e=n.haptic??r;!1!==e&&triggerHaptic(e),popIcon(Me),n.onPress()},onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ce(e=>e.width===t&&e.height===i?e:{width:t,height:i})},accessibilityRole:"button",accessibilityLabel:n.label,hitSlop:{top:6,bottom:6,left:6,right:6},...hitSlopMarker({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.centerPressable,{top:-ot},e?{opacity:.85}:null],testID:n.testID??(v?`${v}-center`:void 0),children:[n.content?_jsx(Animated.View,{style:{transform:[{scale:Me}]},children:n.content}):_jsx(View,{style:[V.centerCircle,{width:ue,height:ue,borderRadius:L.radius.pill,...smoothCorners,backgroundColor:n.color??De.primary}],children:_jsx(Animated.View,{style:{transform:[{scale:Me}]},children:renderSlotIcon(n.icon??"add",{color:n.iconColor??De["on-primary"],size:n.iconSize??24,disabled:!1})})}),(lt=n,s&&!O&&lt.label.trim().length>0?_jsx(Text,{variant:"caption",numberOfLines:1,maxFontSizeMultiplier:E??L.settings.maxFontSizeMultiplier??1.2,style:[V.label,{color:Pe,opacity:ee?.7:1},A],children:n.label}):null)]})},CENTER_KEY):null;var lt;const dt=$?_jsx(View,{style:X?V.accessoryInline:V.accessoryStacked,onLayout:e=>Z(e.nativeEvent.layout.height),testID:v?`${v}-accessory`:void 0,children:U}):null,ct=_jsxs(View,{style:X?[V.tabRow,V.tabRowInline]:V.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;oe(t),re(i)},children:[te&&Se>0&&(!K||ve>0)?_jsx(Animated.View,{pointerEvents:"none",style:[V.pill,{width:Se,height:K?ve:C,left:we,top:Te,backgroundColor:ze,borderRadius:K?activeBgRadius(ve,ve/2):activeBgRadius(C,L.radius.pill),...smoothCorners,transform:[{translateX:Ve}]},I]}):null,J&&ge>0?_jsx(Animated.View,{pointerEvents:"none",style:[V.bubble,L.shadow.elevated,{width:48,height:48,borderRadius:L.radius.pill,...smoothCorners,left:Ie,top:Re,backgroundColor:De.primary,borderColor:De.surface,transform:[{translateX:Ve}]},I]}):null,(ut=i.map(e=>{const t=e.key===o,i=t?Ne:Pe,n=t?Fe:Pe,s="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,l=t?e.activeIcon??s:e.icon,d=xe.current[e.key],c=ye.current[e.key],u=badgeVariantOf(e.badge??null),p=badgeAccessibilitySuffix(e.badge??null,T),m=ee&&!t?.7:1,h=J&&t||ee?De.primary:De.surface,g=hasLabel(e),b=g&&(!Q||t),f=_jsxs(Animated.View,{style:[V.iconWrap,{width:B+4,height:B+4,opacity:m,transform:[{scale:d}]}],children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(l,{color:n,size:B,focused:t,disabled:!1})}),u?_jsx(Badge,{variant:u,value:"standard"===u?e.badge:void 0,tone:"danger",accessible:!1,style:"dot"===u?V.badgeDotPosition:V.badgePillPosition,badgeStyle:["dot"===u?V.badgeDot:V.badgePill,{borderColor:h}],textStyle:V.badgeText}):null]}),x=J?_jsx(Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-14]})},children:f}):f,y=b?_jsx(Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:E??L.settings.maxFontSizeMultiplier??1.2,style:[V.label,Q?V.labelInline:null,{color:i,opacity:Q?c:m,fontWeight:t?L.weight.semibold:L.weight.normal},A],children:e.label}):null,S=_jsx(Pressable,{onPress:()=>(e=>{O&&F(_),e.key!==o&&!1!==r&&triggerHaptic(r);const t=xe.current[e.key];t&&popIcon(t),a(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${p}`,accessibilityHint:T.switchesTo(e.label),hitSlop:{top:6,bottom:6,left:6,right:6},...hitSlopMarker({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.tab,K?V.tabTile:null,e?{opacity:.85}:null],testID:v?`${v}-tab-${e.key}`:void 0,children:Q?_jsxs(View,{style:[V.expandPill,{height:C,paddingHorizontal:t&&g?L.space.md:Math.max(0,(C-(B+4))/2)}],children:[_jsx(View,{pointerEvents:"none",style:[V.expandFill,{borderRadius:activeBgRadius(C,C/2),...smoothCorners,backgroundColor:t?De["primary-soft"]:"transparent"},t?I:null]}),x,y]}):_jsxs(_Fragment,{children:[x,y]})},e.key);return Q?_jsx(Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,g?1.5:1]})},children:S},e.key):S}),st?[...ut.slice(0,se),st,...ut.slice(se)]:ut),"underline"===l&&ge>0?_jsx(Animated.View,{pointerEvents:"none",style:[V.underline,"top"===d?V.underlineTop:V.underlineBottom,"top"===d?{top:-Ue-Y}:{bottom:-Ue},{width:ge,height:3,backgroundColor:De.primary,transform:[{translateX:Ve}]},I]}):null]});var ut;return _jsx(View,{ref:t,testID:v,accessibilityRole:"tablist",style:[V.outer,{paddingHorizontal:He,paddingTop:Math.max(Oe,rt),paddingBottom:Ge},w],children:_jsxs(View,{style:[q?V.floatingBar:V.dockedBar,X?V.barInline:null,tt,{backgroundColor:ke,borderColor:nt,borderRadius:Ke,...smoothCorners},q?{borderWidth:it,paddingHorizontal:$e,paddingVertical:Ue}:{borderTopWidth:it,borderBottomWidth:it,borderLeftWidth:it,borderRightWidth:it,paddingHorizontal:Je,paddingTop:Ue,paddingBottom:Xe}],children:[dt,ct]})})});BottomNavigation.displayName="BottomNavigation";const buildStyles=e=>StyleSheet.create({outer:{backgroundColor:"transparent"},dockedBar:{paddingHorizontal:e.space.xs},floatingBar:{paddingVertical:e.space.sm,paddingHorizontal:e.space.sm},tabRow:{flexDirection:"row",alignItems:"stretch",position:"relative"},tabRowInline:{flex:1},barInline:{flexDirection:"row",alignItems:"center"},accessoryStacked:{marginBottom:e.space.xs},accessoryInline:{flexShrink:0,marginRight:e.space.xs},tab:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center",paddingVertical:e.space.xs,gap:e.space.xs},tabTile:{paddingVertical:e.space.sm,gap:e.space.xxs},centerCell:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center"},centerPressable:{alignItems:"center",maxWidth:"100%",gap:e.space.xs},centerCircle:{alignItems:"center",justifyContent:"center"},iconWrap:{alignItems:"center",justifyContent:"center",position:"relative"},label:{fontSize:e.text.xs.size,lineHeight:e.text.xs.size*e.leading.heading,textAlign:"center",includeFontPadding:!1},labelInline:{fontSize:e.text.sm.size,lineHeight:e.text.sm.size*e.leading.heading,flexShrink:1,includeFontPadding:!1},expandPill:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:e.space.xs},expandFill:{position:"absolute",top:0,right:0,bottom:0,left:0,overflow:"hidden"},pill:{position:"absolute",left:0},bubble:{position:"absolute",left:0,borderWidth:3},underline:{position:"absolute",left:0,height:3},underlineBottom:{borderTopLeftRadius:e.radius.none,borderTopRightRadius:e.radius.none,...smoothCorners},underlineTop:{borderBottomLeftRadius:e.radius.none,borderBottomRightRadius:e.radius.none,...smoothCorners},badgePillPosition:{position:"absolute",top:-4,right:-8},badgePill:{minWidth:18,height:18,paddingHorizontal:e.space.xs,paddingVertical:e.space.xxs,borderWidth:1.5},badgeDotPosition:{position:"absolute",top:-2,right:-2},badgeDot:{width:10,height:10,borderRadius:e.radius.pill,borderWidth:1.5},badgeText:{lineHeight:13}});export{BottomNavigation};export default BottomNavigation;
1
+ "use strict";import React,{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,LayoutAnimation,Platform,Pressable,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{renderSlotIcon}from"../AppIcon/index.js";import{Badge}from"../Badge/index.js";import{Text}from"../Text/index.js";import{useScreenReaderEnabled}from"./useScreenReaderEnabled.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_BOTTOM_NAVIGATION_LABELS=Object.freeze({switchesTo:e=>`Switches to ${e}`,unread:e=>`${e} unread`,newUpdates:"new updates"});const DEFAULT_ICON_SIZE=18,DEFAULT_LABEL_MAX_FONT_SCALE=1.2,ICON_WRAP_AIR=4,PILL_AIR=8,DEFAULT_PILL_MAX_WIDTH=64,TILE_MAX_WIDTH=96,DEFAULT_UNDERLINE_HEIGHT=3,DEFAULT_BUBBLE_SIZE=48,DEFAULT_BUBBLE_LIFT=14,DEFAULT_CENTER_SIZE=48,DEFAULT_CENTER_ICON_SIZE=24,CENTER_KEY="__center_action__",EXPANDED_FLEX=1.5,SOLID_INACTIVE_OPACITY=.7,TILE_INSET=2,badgeVariantOf=e=>null==e||!1===e?null:!0===e||"·"===e?"dot":"number"==typeof e?e>0?"standard":null:e.length>0?"standard":null,badgeAccessibilitySuffix=(e,t)=>null==e||!1===e?"":"number"==typeof e?e>0?`, ${t.unread(e)}`:"":!0===e||"·"===e?`, ${t.newUpdates}`:"string"==typeof e&&e.length>0?`, ${e}`:"",BottomNavigation=forwardRef((e,t)=>{const{tabs:i,centerAction:n,activeTab:o,onChange:a,haptic:r="selection",showLabels:s=!0,variant:l="pill",indicatorPosition:d="bottom",radius:c,indicatorRadius:u="auto",elevation:p,iconSize:m,marginHorizontal:h,marginVertical:g,paddingHorizontal:b,paddingVertical:f,border:x,minimizeOnScroll:y=!1,scrollDirection:_="idle",accessory:S,style:w,indicatorStyle:A,labelStyle:E,labelMaxFontScale:I,labels:R,testID:T}=e;assertValidValue("BottomNavigation","variant",e.variant,["pill","underline","floating","bubble","expand","solid","tile"]),assertValidValue("BottomNavigation","indicatorPosition",e.indicatorPosition,["top","bottom"]);const v=useMemo(()=>R?{...DEFAULT_BOTTOM_NAVIGATION_LABELS,...R}:DEFAULT_BOTTOM_NAVIGATION_LABELS,[R]),V=useTheme(),L=useSafeAreaInsets(),j=useMemo(()=>buildStyles(V),[V]),B=m??18,C=B+4+8,M=V.space.lg,D=V.space.lg,k=V.radius.xl,N=useReducedMotion(),P=useScreenReaderEnabled(y),[z,F]=React.useState(null);useEffect(()=>{null!==z&&z!==_&&F(null)},[z,_]);const H=y&&!P&&"down"===_&&null===z,[O,W]=React.useState(H);useEffect(()=>{O!==H&&(N||"web"===Platform.OS||LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut),W(H))},[O,H,N]);const U="function"==typeof S?S({minimized:O}):S,$=null!=U&&!1!==U,X=O&&$,[G,Z]=React.useState(0),Y=$&&!X?G+V.space.xs:0,K="tile"===l,q="floating"===l||K,J="bubble"===l,Q="expand"===l,ee="solid"===l,te="pill"===l||q||ee,ie=Math.max(0,i.findIndex(e=>e.key===o)),[ne,oe]=React.useState(0),[ae,re]=React.useState(0),se=n?Math.ceil(i.length/2):i.length,le=i.length+(n?1:0),[de,ce]=React.useState({width:0,height:0}),ue=n?.size??48,pe=void 0!==n?.gap,me=Math.max(0,n?.gap??0),he=pe?(de.width||ue)+2*me:0,ge=pe?i.length>0?Math.max(0,ne-he)/i.length:0:le>0?ne/le:0,be=pe?he:ge,fe=useRef(createAnimatedValue(ie)).current,xe=useRef({}),ye=useRef({});i.forEach(e=>{xe.current[e.key]||(xe.current[e.key]=new Animated.Value(1)),ye.current[e.key]||(ye.current[e.key]=createAnimatedValue(e.key===o?1:0))});const Se=ge>0?K?Math.min(ge-4,96):Math.min(ge-M,64):0,we=ge>0?(ge-Se)/2:0,Ae=ge>0?(ge-48)/2:0,hasLabel=e=>s&&!O&&!1!==e.showLabel&&e.label.trim().length>0,Ee=i[ie],Ie=Ee&&!hasLabel(Ee)&&ae>0?ae/2:V.space.xs+(B+4)/2,Re=Ie-14-24,Te=Math.max(0,ae-4),ve=K?2:Ie-C/2,Ve=useRef(ie);useEffect(()=>{if(Ve.current===ie)return;Ve.current=ie;const e=Animated.spring(fe,{toValue:ie,tension:120,friction:14,useNativeDriver:!0});return e.start(),()=>e.stop()},[ie,fe]);const Le=Math.max(1,i.length-1),je=useMemo(()=>{const e=[],t=[];for(let i=0;i<=Le;i++)e.push(i),t.push(i<se?i*ge:i*ge+be);return fe.interpolate({inputRange:e,outputRange:t})},[fe,Le,se,ge,be]),Be=i.map(e=>e.key).join(" "),Ce=J||Q;useEffect(()=>{const e=Be.split(" ").flatMap(e=>{const t=e===o?1:0,i=ye.current[e];return i?Ce?[Animated.spring(i,{toValue:t,tension:140,friction:13,useNativeDriver:!1})]:(i.setValue(t),[]):[]});if(0===e.length)return;const t=Animated.parallel(e);return t.start(),()=>t.stop()},[o,Be,Ce]);const popIcon=e=>{Animated.sequence([Animated.timing(e,{toValue:1.15,duration:120,useNativeDriver:!0}),Animated.spring(e,{toValue:1,tension:200,friction:8,useNativeDriver:!0})]).start()},Me=useRef(new Animated.Value(1)).current,{colors:De}=V,ke=ee?De.primary:De.surface,Ne=ee?De["on-primary"]:De.primary,Pe=ee?De["on-primary"]:K?De["text-body"]:De["text-subtle"],ze=ee?De["on-primary"]:De["primary-soft"],Fe=ee?De.primary:J?De["on-primary"]:Ne,He=h??D,Oe=g??(q?D:0),We=Oe>0,Ue=f??V.space.sm,$e=b??(q?V.space.sm:V.space.xs),Xe=We?Ue:Math.max(Ue,L.bottom),Ge=We?Math.max(Oe,L.bottom>0?L.bottom+V.space.sm:0):0,Ze="pill"===c,Ye=q?ae+Y+2*Ue+2*StyleSheet.hairlineWidth:ae+Y+Ue+Xe,Ke=Ze?ae>0?Ye/2:V.radius.pill:c??(K?V.radius.pill:q?k:V.radius.none),qe=void 0!==c,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&qe?Math.min(Ke,e/2):t,Je="underline"===l?Math.max($e,Ze&&0===ae?0:Ke):$e,Qe=p??"none",et="none"===Qe?void 0:V.shadow[Qe],tt=void 0===et?null:supportsBoxShadow()?{boxShadow:toBoxShadow(et)}:et,it=x?StyleSheet.hairlineWidth:0,nt=ee?De.primary:De.border,ot=n?.lift??0,at=Ue+it+Y,rt=n&&ae>0?Math.max(0,(de.height||ue)/2+ot-ae/2-at):0,st=n?_jsx(View,{style:[j.centerCell,pe?{flex:0,marginHorizontal:me}:null],pointerEvents:"box-none",children:_jsxs(Pressable,{onPress:()=>{if(!n)return;const e=n.haptic??r;!1!==e&&triggerHaptic(e),popIcon(Me),n.onPress()},onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ce(e=>e.width===t&&e.height===i?e:{width:t,height:i})},accessibilityRole:"button",accessibilityLabel:n.label,hitSlop:{top:6,bottom:6,left:6,right:6},...hitSlopMarker({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[j.centerPressable,{top:-ot},e?{opacity:.85}:null],testID:n.testID??(T?`${T}-center`:void 0),children:[n.content?_jsx(Animated.View,{style:{transform:[{scale:Me}]},children:n.content}):_jsx(View,{style:[j.centerCircle,{width:ue,height:ue,borderRadius:V.radius.pill,...smoothCorners,backgroundColor:n.color??De.primary}],children:_jsx(Animated.View,{style:{transform:[{scale:Me}]},children:renderSlotIcon(n.icon??"add",{color:n.iconColor??De["on-primary"],size:n.iconSize??24,disabled:!1})})}),(lt=n,s&&!O&&lt.label.trim().length>0?_jsx(Text,{variant:"caption",numberOfLines:1,maxFontSizeMultiplier:I??V.settings.maxFontSizeMultiplier??1.2,style:[j.label,{color:Pe,opacity:ee?.7:1},E],children:n.label}):null)]})},CENTER_KEY):null;var lt;const dt=$?_jsx(View,{style:X?j.accessoryInline:j.accessoryStacked,onLayout:e=>Z(e.nativeEvent.layout.height),testID:T?`${T}-accessory`:void 0,children:U}):null,ct=_jsxs(View,{style:X?[j.tabRow,j.tabRowInline]:j.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;oe(t),re(i)},children:[te&&Se>0&&(!K||Te>0)?_jsx(Animated.View,{pointerEvents:"none",style:[j.pill,{width:Se,height:K?Te:C,left:we,top:ve,backgroundColor:ze,borderRadius:K?activeBgRadius(Te,Te/2):activeBgRadius(C,V.radius.pill),...smoothCorners,transform:[{translateX:je}]},A]}):null,J&&ge>0?_jsx(Animated.View,{pointerEvents:"none",style:[j.bubble,V.shadow.elevated,{width:48,height:48,borderRadius:V.radius.pill,...smoothCorners,left:Ae,top:Re,backgroundColor:De.primary,borderColor:De.surface,transform:[{translateX:je}]},A]}):null,(ut=i.map(e=>{const t=e.key===o,i=t?Ne:Pe,n=t?Fe:Pe,s="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,l=t?e.activeIcon??s:e.icon,d=xe.current[e.key],c=ye.current[e.key],u=badgeVariantOf(e.badge??null),p=badgeAccessibilitySuffix(e.badge??null,v),m=ee&&!t?.7:1,h=J&&t||ee?De.primary:De.surface,g=hasLabel(e),b=g&&(!Q||t),f=_jsxs(Animated.View,{style:[j.iconWrap,{width:B+4,height:B+4,opacity:m,transform:[{scale:d}]}],children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(l,{color:n,size:B,focused:t,disabled:!1})}),u?_jsx(Badge,{variant:u,value:"standard"===u?e.badge:void 0,tone:"danger",accessible:!1,style:"dot"===u?j.badgeDotPosition:j.badgePillPosition,badgeStyle:["dot"===u?j.badgeDot:j.badgePill,{borderColor:h}],textStyle:j.badgeText}):null]}),x=J?_jsx(Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-14]})},children:f}):f,y=b?_jsx(Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:I??V.settings.maxFontSizeMultiplier??1.2,style:[j.label,Q?j.labelInline:null,{color:i,opacity:Q?c:m,fontWeight:t?V.weight.semibold:V.weight.normal},E],children:e.label}):null,S=_jsx(Pressable,{onPress:()=>(e=>{O&&F(_),e.key!==o&&!1!==r&&triggerHaptic(r);const t=xe.current[e.key];t&&popIcon(t),a(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${p}`,accessibilityHint:v.switchesTo(e.label),hitSlop:{top:6,bottom:6,left:6,right:6},...hitSlopMarker({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[j.tab,K?j.tabTile:null,e?{opacity:.85}:null],testID:T?`${T}-tab-${e.key}`:void 0,children:Q?_jsxs(View,{style:[j.expandPill,{height:C,paddingHorizontal:t&&g?V.space.md:Math.max(0,(C-(B+4))/2)}],children:[_jsx(View,{pointerEvents:"none",style:[j.expandFill,{borderRadius:activeBgRadius(C,C/2),...smoothCorners,backgroundColor:t?De["primary-soft"]:"transparent"},t?A:null]}),x,y]}):_jsxs(_Fragment,{children:[x,y]})},e.key);return Q?_jsx(Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,g?1.5:1]})},children:S},e.key):S}),st?[...ut.slice(0,se),st,...ut.slice(se)]:ut),"underline"===l&&ge>0?_jsx(Animated.View,{pointerEvents:"none",style:[j.underline,"top"===d?j.underlineTop:j.underlineBottom,"top"===d?{top:-Ue-Y}:{bottom:-Ue},{width:ge,height:3,backgroundColor:De.primary,transform:[{translateX:je}]},A]}):null]});var ut;return _jsx(View,{ref:t,testID:T,accessibilityRole:"tablist",style:[j.outer,{paddingHorizontal:He,paddingTop:Math.max(Oe,rt),paddingBottom:Ge},w],children:_jsxs(View,{style:[q?j.floatingBar:j.dockedBar,X?j.barInline:null,tt,{backgroundColor:ke,borderColor:nt,borderRadius:Ke,...smoothCorners},q?{borderWidth:it,paddingHorizontal:$e,paddingVertical:Ue}:{borderTopWidth:it,borderBottomWidth:it,borderLeftWidth:it,borderRightWidth:it,paddingHorizontal:Je,paddingTop:Ue,paddingBottom:Xe}],children:[dt,ct]})})});BottomNavigation.displayName="BottomNavigation";const buildStyles=e=>StyleSheet.create({outer:{backgroundColor:"transparent"},dockedBar:{paddingHorizontal:e.space.xs},floatingBar:{paddingVertical:e.space.sm,paddingHorizontal:e.space.sm},tabRow:{flexDirection:"row",alignItems:"stretch",position:"relative"},tabRowInline:{flex:1},barInline:{flexDirection:"row",alignItems:"center"},accessoryStacked:{marginBottom:e.space.xs},accessoryInline:{flexShrink:0,marginRight:e.space.xs},tab:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center",paddingVertical:e.space.xs,gap:e.space.xs},tabTile:{paddingVertical:e.space.sm,gap:e.space.xxs},centerCell:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center"},centerPressable:{alignItems:"center",maxWidth:"100%",gap:e.space.xs},centerCircle:{alignItems:"center",justifyContent:"center"},iconWrap:{alignItems:"center",justifyContent:"center",position:"relative"},label:{fontSize:e.text.xs.size,lineHeight:e.text.xs.size*e.leading.heading,textAlign:"center",includeFontPadding:!1},labelInline:{fontSize:e.text.sm.size,lineHeight:e.text.sm.size*e.leading.heading,flexShrink:1,includeFontPadding:!1},expandPill:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:e.space.xs},expandFill:{position:"absolute",top:0,right:0,bottom:0,left:0,overflow:"hidden"},pill:{position:"absolute",left:0},bubble:{position:"absolute",left:0,borderWidth:3},underline:{position:"absolute",left:0,height:3},underlineBottom:{borderTopLeftRadius:e.radius.none,borderTopRightRadius:e.radius.none,...smoothCorners},underlineTop:{borderBottomLeftRadius:e.radius.none,borderBottomRightRadius:e.radius.none,...smoothCorners},badgePillPosition:{position:"absolute",top:-4,right:-8},badgePill:{minWidth:18,height:18,paddingHorizontal:e.space.xs,paddingVertical:e.space.xxs,borderWidth:1.5},badgeDotPosition:{position:"absolute",top:-2,right:-2},badgeDot:{width:10,height:10,borderRadius:e.radius.pill,borderWidth:1.5},badgeText:{lineHeight:13}});export{BottomNavigation};export default BottomNavigation;
@@ -1 +1 @@
1
- "use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,runOnJS,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"});const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:n,onSnapChange:r,onAnimate:a,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:S,onContentSizeChange:b,onScrollLayout:p,scrollEventThrottle:v,keyboardBehavior:y="shift",inline:g=!1,presentation:w="sheet",animateMount:C=!0,handleIndicatorStyle:x,containerStyle:_,header:M,actions:E,actionsLayout:O="auto",footer:T,headerStyle:k,footerStyle:I,children:R,accessibilityLabel:A,accessibilityViewIsModal:j,testID:V}=e;warnInvalidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),warnInvalidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),warnInvalidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const D=useMemo(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,...h}),[h]),B=null!=M||null!=d,L=null!=E&&E.length>0,P=null!=T||L,N=g?"inline":"modal",H=useTheme(),G=usePresenceMotion(),F=useSafeAreaInsets(),[U,J]=useState(()=>Dimensions.get("window").height),[z,Y]=useState(()=>Dimensions.get("window").width),K=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&J(e=>e===t?e:t),o>0&&Y(e=>e===o?e:o)},[]),$=useWindowDimensions(),W="dialog"===w||"auto"===w&&Math.min($.width,$.height)>=600,X=Math.min(560,z-2*H.space.xl),[q,Q]=useModalInsets(),Z="modal"===N?q.top:F.top,ee="modal"===N?q.bottom:F.bottom,te=t.includes("content"),[oe,se]=useMeasuredHeight(),[ne,re]=useMeasuredHeight(),[ae,le,ie]=useMeasuredHeight(),[ue,ce]=useMeasuredHeight(),de=W?H.space.md:oe,he=te?Math.min(de+(B?ne:0)+ae+(P?ue:0)+ee,U-Z):0,me=useCallback((e,t)=>{te&&ie(t),b?.(e,t)},[te,b,ie]),fe=useMemo(()=>resolveSnapPoints(t,U,he),[t,U,he]),Se=U,be=fe[fe.length-1]??0,pe=useSharedValue(Se),ve=useSharedValue(Se),ye=useSharedValue(1),ge=useSharedValue(-1),[we,Ce]=useState(-1),xe=useRef(!1),[Me,Ee]=useState(!1),[Oe,Te]=useState(!1),ke=useRef(!1),Ie=useRef(l);Ie.current=l;const[Re,Ae]=useState(!1),je=useRef(!C&&o),Ve=useRef(-1),De=useRef(!1);De.current="modal"===N?Oe:Re;const Be=useRef(c);Be.current=c;const Le=useRef(s);Le.current=s;const Pe=useRef(!1),Ne=useRef(!0),He=useRef([]),Ge=useCallback(e=>{const t=He.current;He.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Ne.current=!0,()=>{Ne.current=!1,Ge(!1)}),[Ge]);const Fe=useCallback(e=>{if(e<0||e>=fe.length)return Se;const t=fe[e];return W?(U-t)/2:U-t},[fe,U,Se,W]),Ue=useCallback(e=>{Ve.current=e;we!==e&&(Ce(e),ge.value=e,e>=0&&r?.(e))},[we,ge,r]),Je=useCallback(()=>{xe.current=!1,ge.value<0&&(ke.current=!0,"modal"===N?(Ee(!1),"ios"!==Platform.OS&&Te(!1)):Ae(!1))},[N,ge]),ze=useCallback(()=>{ke.current&&Te(!1)},[]);useEffect(()=>{("modal"===N?!Oe:!Re)&&ke.current&&(ke.current=!1,Ie.current?.(),Ge(!0))},[N,Oe,Re,Ge]);const Ye=useCallback((e,t,o)=>{xe.current=!0,a?.(t,o),pe.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(Je)()})},[a,pe,Je]),Ke=useCallback(e=>{const t="number"==typeof e?clamp(e,0,fe.length-1):we>=0?we:0,o=ge.value,s=Fe(t);return ke.current=!1,Ge(!1),"modal"===N?(Te(!0),Ee(!0)):Ae(!0),o<0&&je.current?(pe.value=s,ye.value=1,Ue(t),void a?.(o,t)):o<0&&G.reduced?(pe.value=s,ye.value=0,ye.value=withTiming(1,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ue(t),void a?.(o,t)):(o<0&&(pe.value=Se,ye.value=1),Ue(t),void Ye(s,o,t))},[Ye,Se,we,ge,N,a,G,ye,fe.length,Ue,Ge,H.motion.ease.decelerate,pe,Fe]),$e=useCallback(()=>new Promise(e=>{if(Ve.current<0)return void(De.current?He.current.push(e):e(!0));He.current.push(e),je.current=!1;const t=ge.value;Ue(-1),xe.current=!0,a?.(t,-1);const o=G.reduced?ye:pe,s=G.reduced?0:Se;o.value=withTiming(s,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&runOnJS(Je)()})}),[Se,ge,Je,a,G,ye,Ue,pe,H.motion.ease.accelerate]),We=useCallback((e,t,o)=>{const s=Be.current;if(!s)return void e();if(Pe.current)return void t?.();const n=s();"boolean"!=typeof n?(Pe.current=!0,o?.(),n.then(o=>{Pe.current=!1,o&&Ne.current&&Ve.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(n?e:t)?.()},[]),Xe=useCallback(()=>new Promise(e=>{Ve.current<0?e(!0):We(()=>{Le.current(),$e(),e(!0)},()=>e(!1))}),[$e,We]),qe=useCallback(()=>{Le.current()},[]),Qe=useCallback(()=>{u&&Xe()},[u,Xe]),Ze=useRef(null);useEffect(()=>{const e=Ze.current!==o;Ze.current=o,e?o?Ke(n??0):$e():o&&"number"==typeof n&&n!==ge.value&&Ke(n)},[o,n]);const et=useRef({hostHeight:U,contentSnap:he});useEffect(()=>{const e=et.current;if(e.hostHeight===U&&e.contentSnap===he)return;if(et.current={hostHeight:U,contentSnap:he},e.hostHeight===U&&ge.value<0)return;const t=Fe(ge.value);pe.value=je.current?t:withSpring(t,SPRING_CONFIG)},[U,he]);const tt=U-be,ot=useMemo(()=>fe.map(e=>U-e),[fe,U]),st=useCallback(()=>{const e=Ve.current;e<0||Ye(Fe(e),e,e)},[Ye,Fe]),nt=useCallback((e,t)=>{const o=ge.value;-1!==e?(Ue(e),Ye(t,o,e)):We(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Le.current(),$e()},st,st)},[Ye,$e,ge,We,Ue,st]),rt=useMemo(()=>Gesture.Native().withTestId(V?`${V}-content-gesture`:"bottom-sheet-content-gesture"),[V]),at=useMemo(()=>{const e=ot,t=Se,o=tt,s=i;return Gesture.Pan().withTestId(V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";ve.value=pe.value}).onUpdate(e=>{"worklet";const t=ve.value+e.translationY;pe.value=t<o?o+.25*(t-o):t}).onEnd(o=>{"worklet";const n=pe.value;if(o.velocityY>1e3)return s?void runOnJS(nt)(-1,t):void runOnJS(nt)(0,e[0]);let r=0,a=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const o=Math.abs(n-e[t]);o<a&&(a=o,r=t)}const l=e[0];s&&n-l>80?runOnJS(nt)(-1,t):runOnJS(nt)(r,e[r])})},[Se,ve,i,nt,tt,ot,V,pe]),{height:lt}=useReanimatedKeyboardAnimation(),it="shift"===y,ut=useDerivedValue(()=>it?lt.value:0,[it,lt]),ct=fe[we>=0?we:0]??be,dt=H.space.md,ht=useAnimatedStyle(()=>{if(W){const e=ut.value,t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value;return{top:o<Z?Z:o,opacity:ye.value}}const e=pe.value+ut.value,t=ut.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}},[W,ut,U,ct,dt,pe,Z,ye,tt]),mt=useAnimatedStyle(()=>{const e=ut.value;if(W){const t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value,s=U+e-dt-(o<Z?Z:o);return{height:s<0?0:s>ct?ct:s}}const t=e<0?Z:tt,o=pe.value+e,s=U+e-(o<t?t:o);return{height:s<0?0:s>be?be:s}},[ut,W,U,ct,dt,pe,Z,tt,be]),ft=we>=0,St=useMemo(()=>buildStyles(H),[H]),bt=useCallback(()=>{u&&We(()=>{triggerHaptic("selection"),Le.current(),$e()})},[u,$e,We]),pt=useMemo(()=>Gesture.Tap().withTestId(V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&runOnJS(bt)()}),[bt,V]),vt=useMemo(()=>({snapIndex:we,snapPoints:fe,close:qe,requestClose:Xe}),[we,fe,qe,Xe]);if("inline"===N&&!Re)return null;if("modal"===N&&!Oe)return null;const yt=_jsxs(View,{collapsable:!1,style:["modal"===N?St.backdropModal:St.backdropInline,{backgroundColor:"modal"===N?transparentOf(H.colors.scrim):H.colors.scrim}],onLayout:K,testID:V,accessibilityViewIsModal:j??ft,children:[_jsx(GestureDetector,{gesture:pt,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:D.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:A,accessibilityViewIsModal:j??ft,accessibilityActions:[{name:"escape",label:D.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[St.sheet,{height:be,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,...smoothCorners,...H.shadow.modal},W?{height:ct,left:(z-X)/2,right:void 0,width:X,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,_,ht],children:_jsxs(SheetBody,{style:[St.body,mt],keyboardOffset:ut,children:[W?_jsx(View,{style:{height:H.space.md}}):_jsx(GestureDetector,{gesture:at,children:_jsx(View,{style:St.handleRow,onLayout:te?se:void 0,accessible:!0,accessibilityLabel:D.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[St.handle,{backgroundColor:H.colors.border},x]})})}),B&&_jsxs(View,{style:[St.header,k],onLayout:te?re:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,M]}),m?_jsx(GestureDetector,{gesture:rt,children:_jsx(ScrollView,{ref:f,style:St.scrollContent,onScroll:S,onContentSizeChange:me,onLayout:p,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:R})}):_jsx(View,{style:te?[St.content,{overflow:"visible"}]:St.content,children:te?_jsx(View,{onLayout:le,children:R}):R}),P&&_jsxs(View,{style:[St.footer,I],onLayout:te?ce:void 0,children:[L?_jsx(View,{style:St.actions,children:_jsx(OverlayActions,{actions:E??[],layout:O})}):null,T]})]})})]}),gt=_jsx(BottomSheetContext.Provider,{value:vt,children:yt});return"modal"===N?_jsx(Modal,{open:Me,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===Platform.OS?ze:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:St.modalRoot,children:gt}):gt}):gt},SheetBody=({style:e,keyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,n=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:e>0?e:0}},[s,t]);return _jsx(Animated.View,{style:[e,n],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
1
+ "use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,runOnJS,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"});const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:n,onSnapChange:r,onAnimate:a,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:S,onContentSizeChange:b,onScrollLayout:p,scrollEventThrottle:y,keyboardBehavior:v="shift",inline:g=!1,presentation:w="sheet",animateMount:C=!0,handleIndicatorStyle:x,containerStyle:_,header:M,actions:E,actionsLayout:O="auto",footer:T,headerStyle:k,footerStyle:R,children:A,accessibilityLabel:I,accessibilityViewIsModal:j,testID:V}=e;assertValidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),assertValidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),assertValidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const D=useMemo(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,...h}),[h]),B=null!=M||null!=d,L=null!=E&&E.length>0,P=null!=T||L,N=g?"inline":"modal",H=useTheme(),G=usePresenceMotion(),F=useSafeAreaInsets(),[U,J]=useState(()=>Dimensions.get("window").height),[z,Y]=useState(()=>Dimensions.get("window").width),K=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&J(e=>e===t?e:t),o>0&&Y(e=>e===o?e:o)},[]),$=useWindowDimensions(),W="dialog"===w||"auto"===w&&Math.min($.width,$.height)>=600,X=Math.min(560,z-2*H.space.xl),[q,Q]=useModalInsets(),Z="modal"===N?q.top:F.top,ee="modal"===N?q.bottom:F.bottom,te=t.includes("content"),[oe,se]=useMeasuredHeight(),[ne,re]=useMeasuredHeight(),[ae,le,ie]=useMeasuredHeight(),[ue,ce]=useMeasuredHeight(),de=W?H.space.md:oe,he=te?Math.min(de+(B?ne:0)+ae+(P?ue:0)+ee,U-Z):0,me=useCallback((e,t)=>{te&&ie(t),b?.(e,t)},[te,b,ie]),fe=useMemo(()=>resolveSnapPoints(t,U,he),[t,U,he]),Se=U,be=fe[fe.length-1]??0,pe=useSharedValue(Se),ye=useSharedValue(Se),ve=useSharedValue(1),ge=useSharedValue(-1),[we,Ce]=useState(-1),xe=useRef(!1),[Me,Ee]=useState(!1),[Oe,Te]=useState(!1),ke=useRef(!1),Re=useRef(l);Re.current=l;const[Ae,Ie]=useState(!1),je=useRef(!C&&o),Ve=useRef(-1),De=useRef(!1);De.current="modal"===N?Oe:Ae;const Be=useRef(c);Be.current=c;const Le=useRef(s);Le.current=s;const Pe=useRef(!1),Ne=useRef(!0),He=useRef([]),Ge=useCallback(e=>{const t=He.current;He.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Ne.current=!0,()=>{Ne.current=!1,Ge(!1)}),[Ge]);const Fe=useCallback(e=>{if(e<0||e>=fe.length)return Se;const t=fe[e];return W?(U-t)/2:U-t},[fe,U,Se,W]),Ue=useCallback(e=>{Ve.current=e;we!==e&&(Ce(e),ge.value=e,e>=0&&r?.(e))},[we,ge,r]),Je=useCallback(()=>{xe.current=!1,ge.value<0&&(ke.current=!0,"modal"===N?(Ee(!1),"ios"!==Platform.OS&&Te(!1)):Ie(!1))},[N,ge]),ze=useCallback(()=>{ke.current&&Te(!1)},[]);useEffect(()=>{("modal"===N?!Oe:!Ae)&&ke.current&&(ke.current=!1,Re.current?.(),Ge(!0))},[N,Oe,Ae,Ge]);const Ye=useCallback((e,t,o)=>{xe.current=!0,a?.(t,o),pe.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(Je)()})},[a,pe,Je]),Ke=useCallback(e=>{const t="number"==typeof e?clamp(e,0,fe.length-1):we>=0?we:0,o=ge.value,s=Fe(t);return ke.current=!1,Ge(!1),"modal"===N?(Te(!0),Ee(!0)):Ie(!0),o<0&&je.current?(pe.value=s,ve.value=1,Ue(t),void a?.(o,t)):o<0&&G.reduced?(pe.value=s,ve.value=0,ve.value=withTiming(1,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ue(t),void a?.(o,t)):(o<0&&(pe.value=Se,ve.value=1),Ue(t),void Ye(s,o,t))},[Ye,Se,we,ge,N,a,G,ve,fe.length,Ue,Ge,H.motion.ease.decelerate,pe,Fe]),$e=useCallback(()=>new Promise(e=>{if(Ve.current<0)return void(De.current?He.current.push(e):e(!0));He.current.push(e),je.current=!1;const t=ge.value;Ue(-1),xe.current=!0,a?.(t,-1);const o=G.reduced?ve:pe,s=G.reduced?0:Se;o.value=withTiming(s,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&runOnJS(Je)()})}),[Se,ge,Je,a,G,ve,Ue,pe,H.motion.ease.accelerate]),We=useCallback((e,t,o)=>{const s=Be.current;if(!s)return void e();if(Pe.current)return void t?.();const n=s();"boolean"!=typeof n?(Pe.current=!0,o?.(),n.then(o=>{Pe.current=!1,o&&Ne.current&&Ve.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(n?e:t)?.()},[]),Xe=useCallback(()=>new Promise(e=>{Ve.current<0?e(!0):We(()=>{Le.current(),$e(),e(!0)},()=>e(!1))}),[$e,We]),qe=useCallback(()=>{Le.current()},[]),Qe=useCallback(()=>{u&&Xe()},[u,Xe]),Ze=useRef(null);useEffect(()=>{const e=Ze.current!==o;Ze.current=o,e?o?Ke(n??0):$e():o&&"number"==typeof n&&n!==ge.value&&Ke(n)},[o,n]);const et=useRef({hostHeight:U,contentSnap:he});useEffect(()=>{const e=et.current;if(e.hostHeight===U&&e.contentSnap===he)return;if(et.current={hostHeight:U,contentSnap:he},e.hostHeight===U&&ge.value<0)return;const t=Fe(ge.value);pe.value=je.current?t:withSpring(t,SPRING_CONFIG)},[U,he]);const tt=U-be,ot=useMemo(()=>fe.map(e=>U-e),[fe,U]),st=useCallback(()=>{const e=Ve.current;e<0||Ye(Fe(e),e,e)},[Ye,Fe]),nt=useCallback((e,t)=>{const o=ge.value;-1!==e?(Ue(e),Ye(t,o,e)):We(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Le.current(),$e()},st,st)},[Ye,$e,ge,We,Ue,st]),rt=useMemo(()=>Gesture.Native().withTestId(V?`${V}-content-gesture`:"bottom-sheet-content-gesture"),[V]),at=useMemo(()=>{const e=ot,t=Se,o=tt,s=i;return Gesture.Pan().withTestId(V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";ye.value=pe.value}).onUpdate(e=>{"worklet";const t=ye.value+e.translationY;pe.value=t<o?o+.25*(t-o):t}).onEnd(o=>{"worklet";const n=pe.value;if(o.velocityY>1e3)return s?void runOnJS(nt)(-1,t):void runOnJS(nt)(0,e[0]);let r=0,a=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const o=Math.abs(n-e[t]);o<a&&(a=o,r=t)}const l=e[0];s&&n-l>80?runOnJS(nt)(-1,t):runOnJS(nt)(r,e[r])})},[Se,ye,i,nt,tt,ot,V,pe]),{height:lt}=useReanimatedKeyboardAnimation(),it="shift"===v,ut=useDerivedValue(()=>it?lt.value:0,[it,lt]),ct=fe[we>=0?we:0]??be,dt=H.space.md,ht=useAnimatedStyle(()=>{if(W){const e=ut.value,t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value;return{top:o<Z?Z:o,opacity:ve.value}}const e=pe.value+ut.value,t=ut.value<0?Z:tt;return{top:e<t?t:e,opacity:ve.value}},[W,ut,U,ct,dt,pe,Z,ve,tt]),mt=useAnimatedStyle(()=>{const e=ut.value;if(W){const t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value,s=U+e-dt-(o<Z?Z:o);return{height:s<0?0:s>ct?ct:s}}const t=e<0?Z:tt,o=pe.value+e,s=U+e-(o<t?t:o);return{height:s<0?0:s>be?be:s}},[ut,W,U,ct,dt,pe,Z,tt,be]),ft=we>=0,St=useMemo(()=>buildStyles(H),[H]),bt=useCallback(()=>{u&&We(()=>{triggerHaptic("selection"),Le.current(),$e()})},[u,$e,We]),pt=useMemo(()=>Gesture.Tap().withTestId(V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&runOnJS(bt)()}),[bt,V]),yt=useMemo(()=>({snapIndex:we,snapPoints:fe,close:qe,requestClose:Xe}),[we,fe,qe,Xe]);if("inline"===N&&!Ae)return null;if("modal"===N&&!Oe)return null;const vt=_jsxs(View,{collapsable:!1,style:["modal"===N?St.backdropModal:St.backdropInline,{backgroundColor:"modal"===N?transparentOf(H.colors.scrim):H.colors.scrim}],onLayout:K,testID:V,accessibilityViewIsModal:j??ft,children:[_jsx(GestureDetector,{gesture:pt,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:D.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:I,accessibilityViewIsModal:j??ft,accessibilityActions:[{name:"escape",label:D.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[St.sheet,{height:be,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,...smoothCorners,...H.shadow.modal},W?{height:ct,left:(z-X)/2,right:void 0,width:X,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,_,ht],children:_jsxs(SheetBody,{style:[St.body,mt],keyboardOffset:ut,children:[W?_jsx(View,{style:{height:H.space.md}}):_jsx(GestureDetector,{gesture:at,children:_jsx(View,{style:St.handleRow,onLayout:te?se:void 0,accessible:!0,accessibilityLabel:D.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[St.handle,{backgroundColor:H.colors.border},x]})})}),B&&_jsxs(View,{style:[St.header,k],onLayout:te?re:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,M]}),m?_jsx(GestureDetector,{gesture:rt,children:_jsx(ScrollView,{ref:f,style:St.scrollContent,onScroll:S,onContentSizeChange:me,onLayout:p,scrollEventThrottle:y,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:A})}):_jsx(View,{style:te?[St.content,{overflow:"visible"}]:St.content,children:te?_jsx(View,{onLayout:le,children:A}):A}),P&&_jsxs(View,{style:[St.footer,R],onLayout:te?ce:void 0,children:[L?_jsx(View,{style:St.actions,children:_jsx(OverlayActions,{actions:E??[],layout:O})}):null,T]})]})})]}),gt=_jsx(BottomSheetContext.Provider,{value:yt,children:vt});return"modal"===N?_jsx(Modal,{open:Me,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===Platform.OS?ze:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:St.modalRoot,children:gt}):gt}):gt},SheetBody=({style:e,keyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,n=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:e>0?e:0}},[s,t]);return _jsx(Animated.View,{style:[e,n],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{Gradient,resolveButtonSize,useTheme}from"../../theme/index.js";import{createAnimatedValue}from"../../theme/animatedValue.js";import{ariaFromState}from"../../utils/ariaState.js";import{ACCENT_PRESSED_TINT,tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"});const Button=forwardRef((e,t)=>{const{label:o,variant:r,tone:s="primary",size:i,loading:n=!1,disabled:l=!1,fullWidth:a=!1,leftIcon:d,rightIcon:c,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:p=!1,gradient:m,style:f,containerStyle:h,textStyle:x,pressAnimation:y,onPress:S,accessibilityLabel:C,accessibilityHint:I,accessibilityState:_,testID:v,onLayout:w,labels:T,...j}=e;warnInvalidValue("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),warnInvalidValue("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Button","size",e.size,["xs","sm","md","lg","xl"]);const k=useTheme(),F=k.settings.components.button,L=r??F?.defaultVariant??"solid",A=i??F?.defaultSize??"md",O=useMemo(()=>({...DEFAULT_BUTTON_LABELS,...T}),[T]),R=!l&&!n,V={..._,disabled:!R,busy:n},B="link"===L,E=y??F?.defaultPressAnimation??(!B&&"scale"),P=usePressAnimation({preset:E||"scale",enabled:!1!==E&&R}),z=useFlickGuard(),H=useMemo(()=>buildStyles(k),[k]),W=useMemo(()=>resolveButtonSize(k,A),[k,A]),D=useMemo(()=>toneFor(k,s),[k,s]),N=useMemo(()=>variantFor(k,L,D,l),[k,L,D,l]),M=useMemo(()=>!m||l||"solid"!==L?null:"string"==typeof m?k.settings.gradients[m]??null:m,[m,l,L,k.settings.gradients]),U=StyleSheet.flatten(f)?.borderRadius,q=B?0:"number"==typeof U?U:p?k.radius.pill:W.radius,G=useSquircle(!M&&"link"!==L,q,w),K=useRef(createAnimatedValue(0)).current,[X,Y]=useState(0),[J,Q]=useState(null),Z=B?e=>Y(e.nativeEvent.layout.width):void 0,$=C??o,ee="outline"===L||"ghost"===L,te=!ee&&!B,oe={color:N.textColor,size:W.icon,disabled:l},re=b&&!B&&Boolean(d),se=k.space.xs,ie=W["min-height"]-2*se-2*N.borderWidth,ne={color:N.badgeInk,size:W["badge-icon"],disabled:l},le=n?_jsx(Spinner,{variant:"circular",size:"sm",color:re?N.badgeInk:N.textColor,accessibilityLabel:O.loading}):d?_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(d,re?ne:oe,u)}):null,ae=_jsxs(View,{style:H.contentRow,children:[re?_jsx(View,{testID:"button-icon-badge",style:[H.iconLeft,H.iconBadge,{width:ie,height:ie,borderRadius:ie/2,backgroundColor:N.badgeFill}],children:le}):le?_jsx(View,{style:H.iconLeft,children:le}):null,_jsxs(View,{onLayout:Z,children:[_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[H.label,{color:N.textColor,fontSize:W.text,lineHeight:Math.round(W.text*k.leading.body)},x],children:o}),B?_jsx(Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[H.linkUnderline,{backgroundColor:N.textColor,transform:[{translateX:K.interpolate({inputRange:[0,1],outputRange:[-X/2,0]})},{scaleX:K.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),c?_jsx(View,{style:H.iconRight,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(c,oe,u)}):null]}),de=B?null===J?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(J)):touchSlopFor(W["min-height"]),ce={top:de,bottom:de,left:B?LINK_HIT_SLOP:0,right:B?LINK_HIT_SLOP:0};return _jsx(Animated.View,{style:[P.style,a?H.fullWidth:null,h],children:_jsx(Pressable,{ref:t,onPress:e=>{if(!R||z.isFlick(e))return;P.press();const t=resolveHaptic(g,"impactLight");t&&triggerHaptic(t),S?.(e)},onPressIn:e=>{z.onPressIn(e),P.pressIn(),B&&R&&(K.stopAnimation(),K.setValue(0),Animated.timing(K,{toValue:1,duration:k.motion.duration.slower,easing:Easing.bezier(...k.motion.ease.decelerate),useNativeDriver:!0}).start())},onPressOut:()=>{P.pressOut()},disabled:!R,hitSlop:ce,...hitSlopMarker(ce),accessibilityRole:"button",accessibilityLabel:$,accessibilityHint:I,accessibilityState:V,...ariaFromState(V),testID:v,onLayout:e=>{G.onLayout(e),B&&Q(e.nativeEvent.layout.height)},style:({pressed:e})=>[H.base,{paddingHorizontal:B?0:W["padding-x"],paddingVertical:B?0:re?se:W["padding-y"],paddingLeft:re?se:void 0,minHeight:B?void 0:W["min-height"],borderRadius:q,...smoothCorners,backgroundColor:M||G.active?"transparent":N.backgroundColor,borderWidth:N.borderWidth,borderColor:G.active?"transparent":N.borderColor,opacity:n?.55:1,overflow:G.active||B?"visible":"hidden"},e&&ee&&!G.active?{backgroundColor:k.colors["surface-pressed"]}:null,a?H.fullWidth:null,f],...j,"aria-disabled":!R,"aria-busy":n,children:({pressed:e})=>_jsxs(_Fragment,{children:[G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:e&&ee?k.colors["surface-pressed"]:N.backgroundColor,stroke:N.borderColor,strokeWidth:N.borderWidth}):null,M?_jsx(Gradient,{gradient:M,style:[StyleSheet.absoluteFill,{borderRadius:q,...smoothCorners}]}):null,e&&te?G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:N.pressedTint,testID:"button-pressed"}):_jsx(View,{pointerEvents:"none",style:[H.pressedOverlay,{borderRadius:q,backgroundColor:N.pressedTint,...smoothCorners}],testID:"button-pressed"}):null,ae]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:tintOf(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:tintOf(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:tintOf(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:tintOf(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:tintOf(e.colors.info,.14,e.colors["bg-subtle"])};default:return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,t,o,r)=>{const s=r?e.colors["text-disabled"]:o.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=r?i:{badgeFill:o.on,badgeInk:o.base},l=r?i:{badgeFill:o.base,badgeInk:o.on};switch(t){case"solid":return{backgroundColor:r?e.colors["surface-disabled"]:o.base,borderColor:"transparent",borderWidth:1,textColor:r?e.colors["text-disabled"]:o.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:r?e.colors["surface-disabled"]:o.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"outline":return{backgroundColor:"transparent",borderColor:r?e.colors.border:o.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:r?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...l};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:r?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:r?e.colors["text-disabled"]:o.base};default:return{backgroundColor:o.base,borderColor:"transparent",borderWidth:1,textColor:o.on,pressedTint:e.colors["surface-pressed"],...n}}};export function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:1},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});export{Button};export default Button;
1
+ "use strict";import{forwardRef,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{Gradient,resolveButtonSize,useTheme}from"../../theme/index.js";import{createAnimatedValue}from"../../theme/animatedValue.js";import{ariaFromState}from"../../utils/ariaState.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{ACCENT_PRESSED_TINT,tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"});const Button=forwardRef((e,t)=>{const{label:o,variant:r,tone:s="primary",size:i,loading:n=!1,disabled:l=!1,fullWidth:a=!1,leftIcon:d,rightIcon:c,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:p=!1,gradient:m,style:f,containerStyle:h,textStyle:x,pressAnimation:y,onPress:S,accessibilityLabel:C,accessibilityHint:_,accessibilityState:I,testID:T,onLayout:j,labels:k,...v}=e;assertValidValue("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),assertValidValue("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Button","size",e.size,["xs","sm","md","lg","xl"]);const F=useTheme(),w=F.settings.components.button,L=r??w?.defaultVariant??"solid",V=i??w?.defaultSize??"md",A=useMemo(()=>({...DEFAULT_BUTTON_LABELS,...k}),[k]),O=!l&&!n,R={...I,disabled:!O,busy:n},B="link"===L,E=y??w?.defaultPressAnimation??(!B&&"scale"),P=usePressAnimation({preset:E||"scale",enabled:!1!==E&&O}),z=useFlickGuard(),H=useMemo(()=>buildStyles(F),[F]),W=useMemo(()=>resolveButtonSize(F,V),[F,V]),D=useMemo(()=>toneFor(F,s),[F,s]),N=useMemo(()=>variantFor(F,L,D,l),[F,L,D,l]),M=useMemo(()=>!m||l||"solid"!==L?null:"string"==typeof m?F.settings.gradients[m]??null:m,[m,l,L,F.settings.gradients]),U=StyleSheet.flatten(f)?.borderRadius,q=B?0:"number"==typeof U?U:p?F.radius.pill:W.radius,G=useSquircle(!M&&"link"!==L,q,j),K=useRef(createAnimatedValue(0)).current,[X,Y]=useState(0),[J,Q]=useState(null),Z=B?e=>Y(e.nativeEvent.layout.width):void 0,$=C??o,ee="outline"===L||"ghost"===L,te=!ee&&!B,oe={color:N.textColor,size:W.icon,disabled:l},re=b&&!B&&Boolean(d),se=F.space.xs,ie=W["min-height"]-2*se-2*N.borderWidth,ne={color:N.badgeInk,size:W["badge-icon"],disabled:l},le=n?_jsx(Spinner,{variant:"circular",size:"sm",color:re?N.badgeInk:N.textColor,accessibilityLabel:A.loading}):d?_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(d,re?ne:oe,u)}):null,ae=_jsxs(View,{style:H.contentRow,children:[re?_jsx(View,{testID:"button-icon-badge",style:[H.iconLeft,H.iconBadge,{width:ie,height:ie,borderRadius:ie/2,backgroundColor:N.badgeFill}],children:le}):le?_jsx(View,{style:H.iconLeft,children:le}):null,_jsxs(View,{onLayout:Z,children:[_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[H.label,{color:N.textColor,fontSize:W.text,lineHeight:Math.round(W.text*F.leading.body)},x],children:o}),B?_jsx(Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[H.linkUnderline,{backgroundColor:N.textColor,transform:[{translateX:K.interpolate({inputRange:[0,1],outputRange:[-X/2,0]})},{scaleX:K.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),c?_jsx(View,{style:H.iconRight,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(c,oe,u)}):null]}),de=B?null===J?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(J)):touchSlopFor(W["min-height"]),ce={top:de,bottom:de,left:B?LINK_HIT_SLOP:0,right:B?LINK_HIT_SLOP:0};return _jsx(Animated.View,{style:[P.style,a?H.fullWidth:null,h],children:_jsx(Pressable,{ref:t,onPress:e=>{if(!O||z.isFlick(e))return;P.press();const t=resolveHaptic(g,"impactLight");t&&triggerHaptic(t),S?.(e)},onPressIn:e=>{z.onPressIn(e),P.pressIn(),B&&O&&(K.stopAnimation(),K.setValue(0),Animated.timing(K,{toValue:1,duration:F.motion.duration.slower,easing:Easing.bezier(...F.motion.ease.decelerate),useNativeDriver:!0}).start())},onPressOut:()=>{P.pressOut()},disabled:!O,hitSlop:ce,...hitSlopMarker(ce),accessibilityRole:"button",accessibilityLabel:$,accessibilityHint:_,accessibilityState:R,...ariaFromState(R),testID:T,onLayout:e=>{G.onLayout(e),B&&Q(e.nativeEvent.layout.height)},style:({pressed:e})=>[H.base,{paddingHorizontal:B?0:W["padding-x"],paddingVertical:B?0:re?se:W["padding-y"],paddingLeft:re?se:void 0,minHeight:B?void 0:W["min-height"],borderRadius:q,...smoothCorners,backgroundColor:M||G.active?"transparent":N.backgroundColor,borderWidth:N.borderWidth,borderColor:G.active?"transparent":N.borderColor,opacity:n?.55:1,overflow:G.active||B?"visible":"hidden"},e&&ee&&!G.active?{backgroundColor:F.colors["surface-pressed"]}:null,a?H.fullWidth:null,f],...v,"aria-disabled":!O,"aria-busy":n,children:({pressed:e})=>_jsxs(_Fragment,{children:[G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:e&&ee?F.colors["surface-pressed"]:N.backgroundColor,stroke:N.borderColor,strokeWidth:N.borderWidth}):null,M?_jsx(Gradient,{gradient:M,style:[StyleSheet.absoluteFill,{borderRadius:q,...smoothCorners}]}):null,e&&te?G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:N.pressedTint,testID:"button-pressed"}):_jsx(View,{pointerEvents:"none",style:[H.pressedOverlay,{borderRadius:q,backgroundColor:N.pressedTint,...smoothCorners}],testID:"button-pressed"}):null,ae]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:tintOf(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:tintOf(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:tintOf(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:tintOf(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:tintOf(e.colors.info,.14,e.colors["bg-subtle"])};default:return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,t,o,r)=>{const s=r?e.colors["text-disabled"]:o.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=r?i:{badgeFill:o.on,badgeInk:o.base},l=r?i:{badgeFill:o.base,badgeInk:o.on};switch(t){case"solid":return{backgroundColor:r?e.colors["surface-disabled"]:o.base,borderColor:"transparent",borderWidth:1,textColor:r?e.colors["text-disabled"]:o.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:r?e.colors["surface-disabled"]:o.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"outline":return{backgroundColor:"transparent",borderColor:r?e.colors.border:o.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:r?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...l};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:r?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:r?e.colors["text-disabled"]:o.base};default:return{backgroundColor:o.base,borderColor:"transparent",borderWidth:1,textColor:o.on,pressedTint:e.colors["surface-pressed"],...n}}};export function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:1},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});export{Button};export default Button;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useEffect,useLayoutEffect,useMemo,useRef}from"react";import{AccessibilityInfo,Animated,Easing,Pressable,View}from"react-native";import{useControllableState,usePresenceMotion}from"../../hooks/index.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Text}from"../Text/index.js";import{CalendarDay}from"./CalendarDay.js";import{addMonths,buildMonthMatrix,GRID_CELLS,startOfDay,startOfMonth,toIso,weekdayLabels}from"./calendarDates.js";import{buildCalendarStyles,MIN_CELL_SIZE,NAV_BUTTON_SIZE}from"./calendarStyles.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_CALENDAR_LABELS=Object.freeze({previousMonth:"Previous month",nextMonth:"Next month",marked:"Marked"});const MAX_DOTS=3,DAY_TEXT_MAX_SCALE=1.5,toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"primary":return e.colors.primary;default:return e.colors["text-muted"]}},Calendar=forwardRef((e,t)=>{const{selectionMode:a="single",value:s,onChange:i,month:n,onMonthChange:r,minDate:l,maxDate:o,disabledDates:d,weekStartsOn:u=0,locale:c="en-IN",marks:m,cellSize:h,haptic:y,accessibilityLabel:f,onTitlePress:p,labels:g,style:b,headerLabelStyle:M,navButtonStyle:x,testID:v}=e;warnInvalidValue("Calendar","selectionMode",e.selectionMode,["single","range"]);const _=useMemo(()=>({...DEFAULT_CALENDAR_LABELS,...g}),[g]),w=_.marked,S=useTheme(),D=usePresenceMotion(),L=useMemo(()=>buildCalendarStyles(S),[S]),[T,C]=useControllableState({value:n?startOfMonth(n):void 0,defaultValue:startOfMonth(s?.start??new Date),onChange:r}),A=12*T.getFullYear()+T.getMonth(),j=s?.start?startOfDay(s.start):null,E="range"===a&&s?.end?startOfDay(s.end):null,k=j?.getTime()??null,I=E?.getTime()??null,V=toIso(new Date),R=l?startOfDay(l).getTime():null,N=o?startOfDay(o).getTime():null,O=useMemo(()=>new Set((d??[]).map(e=>toIso(e))),[d]),P=useCallback(e=>null!==R&&e.getTime()<R||null!==N&&e.getTime()>N||O.has(toIso(e)),[R,N,O]),F=useMemo(()=>{const e=new Map;for(const t of m??[]){const a=t.date;let s=e.get(a);s||(s={dots:[],spoken:[]},e.set(a,s)),s.dots.length<3&&s.dots.push({key:`${t.tone}-${s.dots.length}`,color:toneColor(S,t.tone)}),s.spoken.push(t.label??w)}return e},[m,S,w]),B=useMemo(()=>buildMonthMatrix(new Date(Math.floor(A/12),A%12,1),u),[A,u]),z=useMemo(()=>weekdayLabels(c,u),[c,u]),H=useMemo(()=>new Intl.DateTimeFormat(c,{month:"long",year:"numeric"}),[c]),Z=useMemo(()=>new Intl.DateTimeFormat(c,{weekday:"short",day:"numeric",month:"long"}),[c]),$=H.format(T),X=null===R||startOfMonth(new Date(R)).getTime()<T.getTime(),U=null===N||startOfMonth(new Date(N)).getTime()>T.getTime(),q=useRef(createAnimatedValue(0)).current,G=useRef(createAnimatedValue(1)).current,Y=useRef(null);useEffect(()=>()=>Y.current?.stop(),[]);const W=useCallback(e=>{!1!==y&&triggerHaptic("impactLight");const t=S.motion.duration.fast,a=S.motion.duration.fast,[s]=D.range(32*-e,0),[i]=D.range(32*e,0),n=D.reduced?D.duration("fast"):t,r=D.reduced?D.duration("fast"):a;Y.current?.stop(),Y.current=Animated.sequence([Animated.parallel([Animated.timing(q,{toValue:s,duration:t,easing:Easing.out(Easing.quad),useNativeDriver:!0}),Animated.timing(G,{toValue:0,duration:n,useNativeDriver:!0})]),Animated.timing(q,{toValue:i,duration:0,useNativeDriver:!0}),Animated.parallel([Animated.timing(q,{toValue:0,duration:a,easing:Easing.out(Easing.cubic),useNativeDriver:!0}),Animated.timing(G,{toValue:1,duration:r,useNativeDriver:!0})])]),Y.current.start();const l=addMonths(T,e);C(l),AccessibilityInfo.announceForAccessibility(H.format(l))},[y,T,G,H,q,D,C,S]),J=useCallback(()=>W(-1),[W]),K=useCallback(()=>W(1),[W]),pressDay=e=>{if(P(e.date))return;const t=resolveHaptic(y,"selection");t&&triggerHaptic(t);const s=e.date;"single"===a||!j||E||s.getTime()<j.getTime()?i({start:s}):i({start:j,end:s}),e.inMonth||C(startOfMonth(s))},Q=useRef(pressDay);useLayoutEffect(()=>{Q.current=pressDay});const ee=useCallback(e=>Q.current(e),[]),te=void 0===h?void 0:Math.max(h,MIN_CELL_SIZE),ae=useMemo(()=>void 0===te?{flex:1}:{width:te},[te]),se=useMemo(()=>void 0===te?{flex:1,aspectRatio:1,minHeight:MIN_CELL_SIZE}:{width:te,height:te},[te]),ie=Math.max(S.space.sm,(MIN_CELL_SIZE-NAV_BUTTON_SIZE)/2),ne=Math.min(S.settings.maxFontSizeMultiplier??1.5,1.5),re=[];for(let e=0;e<GRID_CELLS;e+=7)re.push(B.slice(e,e+7));const le=_jsx(Text,{variant:"title",accessibilityRole:"header",accessibilityLabel:f?`${f}, ${$}`:void 0,style:L.headerLabel,children:$});return _jsxs(View,{ref:t,style:[L.root,b],testID:v,children:[_jsxs(View,{style:L.headerRow,children:[_jsx(Pressable,{onPress:J,disabled:!X,style:({pressed:e})=>[L.navBtn,e&&L.navBtnPressed,!X&&L.navBtnDisabled,x],accessibilityRole:"button",accessibilityLabel:_.previousMonth,accessibilityState:{disabled:!X},"aria-disabled":!X,hitSlop:ie,...hitSlopMarker(ie),children:_jsx(Text,{variant:"title",style:L.navText,maxFontSizeMultiplier:ne,children:"‹"})}),_jsx(Animated.View,{style:[L.headerLabelWrap,{opacity:G,transform:[{translateX:q}]},M],children:p?_jsx(Pressable,{onPress:p,accessibilityRole:"button",accessibilityLabel:f?`${f}, ${$}`:$,hitSlop:ie,...hitSlopMarker(ie),children:le}):le}),_jsx(Pressable,{onPress:K,disabled:!U,style:({pressed:e})=>[L.navBtn,e&&L.navBtnPressed,!U&&L.navBtnDisabled,x],accessibilityRole:"button",accessibilityLabel:_.nextMonth,accessibilityState:{disabled:!U},"aria-disabled":!U,hitSlop:ie,...hitSlopMarker(ie),children:_jsx(Text,{variant:"title",style:L.navText,maxFontSizeMultiplier:ne,children:"›"})})]}),_jsx(View,{style:L.weekdayRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:z.map(({weekday:e,label:t})=>_jsx(View,{style:[L.weekdayCell,ae],children:_jsx(Text,{variant:"caption",style:L.weekdayText,maxFontSizeMultiplier:ne,children:t})},e))}),_jsx(Animated.View,{style:{opacity:G,transform:[{translateX:q}]},children:re.map(e=>_jsx(View,{style:L.gridRow,children:e.map(e=>{const t=e.date.getTime(),s=null!==k&&t===k,i=null!==I&&t===I,n=null!==k&&null!==I&&t>=k&&t<=I,r=n&&!s&&!i,l=e.iso===V,o=F.get(e.iso),d=[Z.format(e.date),...o?.spoken??[]];return l&&d.push("today"),"range"===a&&(s&&i?d.push("start and end of your range"):s?d.push("start of your range"):i?d.push("end of your range"):r&&d.push("in your range")),_jsx(CalendarDay,{cell:e,accessibilityLabel:d.join(", "),disabled:P(e.date),edge:s||i,mid:r,barLeft:n&&(i||r)&&!(s&&i),barRight:n&&(s||r)&&!(s&&i),today:l,dots:o?.dots,cellStyle:se,styles:L,maxFontSizeMultiplier:ne,onPressDay:ee},e.iso)})},e[0].iso))})]})});Calendar.displayName="Calendar";export{Calendar};export default Calendar;
1
+ "use strict";import{forwardRef,useCallback,useEffect,useLayoutEffect,useMemo,useRef}from"react";import{AccessibilityInfo,Animated,Easing,Pressable,View}from"react-native";import{useControllableState,usePresenceMotion}from"../../hooks/index.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{Text}from"../Text/index.js";import{CalendarDay}from"./CalendarDay.js";import{addMonths,buildMonthMatrix,GRID_CELLS,startOfDay,startOfMonth,toIso,weekdayLabels}from"./calendarDates.js";import{buildCalendarStyles,MIN_CELL_SIZE,NAV_BUTTON_SIZE}from"./calendarStyles.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_CALENDAR_LABELS=Object.freeze({previousMonth:"Previous month",nextMonth:"Next month",marked:"Marked"});const MAX_DOTS=3,DAY_TEXT_MAX_SCALE=1.5,toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"primary":return e.colors.primary;default:return e.colors["text-muted"]}},Calendar=forwardRef((e,t)=>{const{selectionMode:a="single",value:s,onChange:i,month:n,onMonthChange:r,minDate:l,maxDate:o,disabledDates:d,weekStartsOn:u=0,locale:c="en-IN",marks:m,cellSize:h,haptic:y,accessibilityLabel:f,onTitlePress:p,labels:g,style:b,headerLabelStyle:M,navButtonStyle:x,testID:_}=e;assertValidValue("Calendar","selectionMode",e.selectionMode,["single","range"]);const S=useMemo(()=>({...DEFAULT_CALENDAR_LABELS,...g}),[g]),v=S.marked,D=useTheme(),L=usePresenceMotion(),T=useMemo(()=>buildCalendarStyles(D),[D]),[w,C]=useControllableState({value:n?startOfMonth(n):void 0,defaultValue:startOfMonth(s?.start??new Date),onChange:r}),A=12*w.getFullYear()+w.getMonth(),j=s?.start?startOfDay(s.start):null,E="range"===a&&s?.end?startOfDay(s.end):null,k=j?.getTime()??null,V=E?.getTime()??null,I=toIso(new Date),R=l?startOfDay(l).getTime():null,N=o?startOfDay(o).getTime():null,O=useMemo(()=>new Set((d??[]).map(e=>toIso(e))),[d]),P=useCallback(e=>null!==R&&e.getTime()<R||null!==N&&e.getTime()>N||O.has(toIso(e)),[R,N,O]),F=useMemo(()=>{const e=new Map;for(const t of m??[]){const a=t.date;let s=e.get(a);s||(s={dots:[],spoken:[]},e.set(a,s)),s.dots.length<3&&s.dots.push({key:`${t.tone}-${s.dots.length}`,color:toneColor(D,t.tone)}),s.spoken.push(t.label??v)}return e},[m,D,v]),B=useMemo(()=>buildMonthMatrix(new Date(Math.floor(A/12),A%12,1),u),[A,u]),z=useMemo(()=>weekdayLabels(c,u),[c,u]),H=useMemo(()=>new Intl.DateTimeFormat(c,{month:"long",year:"numeric"}),[c]),Z=useMemo(()=>new Intl.DateTimeFormat(c,{weekday:"short",day:"numeric",month:"long"}),[c]),$=H.format(w),X=null===R||startOfMonth(new Date(R)).getTime()<w.getTime(),U=null===N||startOfMonth(new Date(N)).getTime()>w.getTime(),q=useRef(createAnimatedValue(0)).current,G=useRef(createAnimatedValue(1)).current,Y=useRef(null);useEffect(()=>()=>Y.current?.stop(),[]);const W=useCallback(e=>{!1!==y&&triggerHaptic("impactLight");const t=D.motion.duration.fast,a=D.motion.duration.fast,[s]=L.range(32*-e,0),[i]=L.range(32*e,0),n=L.reduced?L.duration("fast"):t,r=L.reduced?L.duration("fast"):a;Y.current?.stop(),Y.current=Animated.sequence([Animated.parallel([Animated.timing(q,{toValue:s,duration:t,easing:Easing.out(Easing.quad),useNativeDriver:!0}),Animated.timing(G,{toValue:0,duration:n,useNativeDriver:!0})]),Animated.timing(q,{toValue:i,duration:0,useNativeDriver:!0}),Animated.parallel([Animated.timing(q,{toValue:0,duration:a,easing:Easing.out(Easing.cubic),useNativeDriver:!0}),Animated.timing(G,{toValue:1,duration:r,useNativeDriver:!0})])]),Y.current.start();const l=addMonths(w,e);C(l),AccessibilityInfo.announceForAccessibility(H.format(l))},[y,w,G,H,q,L,C,D]),J=useCallback(()=>W(-1),[W]),K=useCallback(()=>W(1),[W]),pressDay=e=>{if(P(e.date))return;const t=resolveHaptic(y,"selection");t&&triggerHaptic(t);const s=e.date;"single"===a||!j||E||s.getTime()<j.getTime()?i({start:s}):i({start:j,end:s}),e.inMonth||C(startOfMonth(s))},Q=useRef(pressDay);useLayoutEffect(()=>{Q.current=pressDay});const ee=useCallback(e=>Q.current(e),[]),te=void 0===h?void 0:Math.max(h,MIN_CELL_SIZE),ae=useMemo(()=>void 0===te?{flex:1}:{width:te},[te]),se=useMemo(()=>void 0===te?{flex:1,aspectRatio:1,minHeight:MIN_CELL_SIZE}:{width:te,height:te},[te]),ie=Math.max(D.space.sm,(MIN_CELL_SIZE-NAV_BUTTON_SIZE)/2),ne=Math.min(D.settings.maxFontSizeMultiplier??1.5,1.5),re=[];for(let e=0;e<GRID_CELLS;e+=7)re.push(B.slice(e,e+7));const le=_jsx(Text,{variant:"title",accessibilityRole:"header",accessibilityLabel:f?`${f}, ${$}`:void 0,style:T.headerLabel,children:$});return _jsxs(View,{ref:t,style:[T.root,b],testID:_,children:[_jsxs(View,{style:T.headerRow,children:[_jsx(Pressable,{onPress:J,disabled:!X,style:({pressed:e})=>[T.navBtn,e&&T.navBtnPressed,!X&&T.navBtnDisabled,x],accessibilityRole:"button",accessibilityLabel:S.previousMonth,accessibilityState:{disabled:!X},"aria-disabled":!X,hitSlop:ie,...hitSlopMarker(ie),children:_jsx(Text,{variant:"title",style:T.navText,maxFontSizeMultiplier:ne,children:"‹"})}),_jsx(Animated.View,{style:[T.headerLabelWrap,{opacity:G,transform:[{translateX:q}]},M],children:p?_jsx(Pressable,{onPress:p,accessibilityRole:"button",accessibilityLabel:f?`${f}, ${$}`:$,hitSlop:ie,...hitSlopMarker(ie),children:le}):le}),_jsx(Pressable,{onPress:K,disabled:!U,style:({pressed:e})=>[T.navBtn,e&&T.navBtnPressed,!U&&T.navBtnDisabled,x],accessibilityRole:"button",accessibilityLabel:S.nextMonth,accessibilityState:{disabled:!U},"aria-disabled":!U,hitSlop:ie,...hitSlopMarker(ie),children:_jsx(Text,{variant:"title",style:T.navText,maxFontSizeMultiplier:ne,children:"›"})})]}),_jsx(View,{style:T.weekdayRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:z.map(({weekday:e,label:t})=>_jsx(View,{style:[T.weekdayCell,ae],children:_jsx(Text,{variant:"caption",style:T.weekdayText,maxFontSizeMultiplier:ne,children:t})},e))}),_jsx(Animated.View,{style:{opacity:G,transform:[{translateX:q}]},children:re.map(e=>_jsx(View,{style:T.gridRow,children:e.map(e=>{const t=e.date.getTime(),s=null!==k&&t===k,i=null!==V&&t===V,n=null!==k&&null!==V&&t>=k&&t<=V,r=n&&!s&&!i,l=e.iso===I,o=F.get(e.iso),d=[Z.format(e.date),...o?.spoken??[]];return l&&d.push("today"),"range"===a&&(s&&i?d.push("start and end of your range"):s?d.push("start of your range"):i?d.push("end of your range"):r&&d.push("in your range")),_jsx(CalendarDay,{cell:e,accessibilityLabel:d.join(", "),disabled:P(e.date),edge:s||i,mid:r,barLeft:n&&(i||r)&&!(s&&i),barRight:n&&(s||r)&&!(s&&i),today:l,dots:o?.dots,cellStyle:se,styles:T,maxFontSizeMultiplier:ne,onPressDay:ee},e.iso)})},e[0].iso))})]})});Calendar.displayName="Calendar";export{Calendar};export default Calendar;
@@ -1 +1 @@
1
- "use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,Gradient,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{squircleHostRadius}from"../../utils/squircle.js";import{themeStyles}from"../../utils/themeStyles.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"];export const DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"});const paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=React.memo(forwardRef((e,t)=>{const{children:i,variant:o,elevation:s="card",radius:a,padding:r,interactive:l=!1,pressAnimation:n="scale",bg:d,header:c,title:u,titleFont:m,lead:h,action:p,headerActions:g,collapsible:b=!1,collapsed:y,defaultCollapsed:x=!1,onCollapsedChange:f,collapsedSummary:S,onRemove:v,separatorHeight:j=StyleSheet.hairlineWidth,footer:C,imageSource:w,imageHeight:_=160,imageAspectRatio:R,imageOverlay:A,loading:F=!1,gradient:T,onPress:k,haptic:V,contextMenu:I,accessibilityLabel:B,accessibilityHint:L,accessibilityRole:H,style:P,containerStyle:z,headerStyle:M,bodyStyle:D,footerStyle:E,testID:q,labels:O,onLayout:W,...N}=e;warnInvalidValue("Card","variant",e.variant,["elevated","outline","filled","flat"]),warnInvalidValue("Card","radius",e.radius,["sm","md","lg","xl","pill"]),warnInvalidValue("Card","padding",e.padding,["none","sm","md","lg","xl"]),warnInvalidValue("Card","titleFont",e.titleFont,["sans","serif"]),warnInvalidValue("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const G=useTheme(),U=G.settings.components.card,K=o??U?.defaultVariant??"elevated",$=a??U?.defaultRadius??"lg",J=r??U?.defaultPadding??"md",Q=m??U?.defaultTitleFont??"sans",X=useMemo(()=>({...DEFAULT_CARD_LABELS,...O}),[O]),Y=l||"function"==typeof k,Z=useContextMenu(I,{haptic:V||!1,testID:q,accessibilityActions:N.accessibilityActions,onAccessibilityAction:N.onAccessibilityAction}),ee=useMemo(()=>mergeRefs(t,Z.hostRef),[t,Z.hostRef]),te=Y||Z.enabled,{style:ie,pressIn:oe,pressOut:se}=usePressAnimation({preset:n||"scale",enabled:te&&!1!==n}),ae=stylesFor(G),re=Boolean(w),le=G.space[paddingMap[J]],ne=useMemo(()=>T?"string"==typeof T?G.settings.gradients[T]??null:T:null,[T,G.settings.gradients]),de="flat"===K,ce=de?G.radius.none:G.radius[$],ue=resolveBackground(G,d),[me,he]=useControllableState({value:y,defaultValue:x,onChange:f}),pe=b&&me,ge=hasBuiltInHeaderContent(e),be=Boolean(c)||ge,ye=useSquircle(!re&&!ne&&!de,ce,W),xe=StyleSheet.flatten([z,P])??{},fe=xe.backgroundColor,Se=xe.borderColor,ve=fe??ue??("filled"===K?G.colors["bg-subtle"]:G.colors.surface),je="outline"===K?G.size.border:0,Ce=Se??G.colors.border,we="none"===s?void 0:G.shadow[s],Re="elevated"===K&&supportsBoxShadow()&&we?toBoxShadow(we):void 0,Ae=ye.active&&"elevated"===K&&!Re,Fe=ye.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,Te=useMemo(()=>{const e={borderRadius:Ae&&ye.size?squircleHostRadius(ye.size.width,ye.size.height,ce):ce,...smoothCorners,padding:re||ye.active?G.space.none:le,overflow:ye.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:ue??G.colors.surface,borderBottomWidth:j,borderBottomColor:G.colors.border};case"outline":return{...e,backgroundColor:ye.active?"transparent":ue??G.colors.surface,borderWidth:G.size.border,borderColor:ye.active?"transparent":G.colors.border};case"filled":return{...e,backgroundColor:ye.active?"transparent":ue??G.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??G.colors.surface,...Re?{boxShadow:Re}:we}}},[G,K,we,ce,re,le,ye.active,ye.size,Re,Ae,ue,j]),ke=useMemo(()=>({..."number"==typeof R?{width:"100%",aspectRatio:R}:{width:"100%",height:_},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:G.radius.none,borderBottomRightRadius:G.radius.none,...smoothCorners}),[G,ce,R,_]),Ve=u??"",Ie=_jsxs(_Fragment,{children:[_jsxs(View,{style:ae.titleColumn,children:[u?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(G,Q),children:u}):null,h?_jsx(Text,{variant:"bodySmall",style:ae.lead,children:h}):null,pe&&S?_jsx(Text,{variant:"caption",style:ae.lead,children:S}):null]}),isCardTextAction(p)?_jsx(CardTextActionButton,{action:p,haptic:V}):p?_jsx(View,{style:ae.actionNode,children:p}):null,g,b?_jsx(CardIconAction,{icon:pe?"chevron-down":"chevron-up",label:`${pe?X.show:X.hide} ${Ve}`.trim(),expanded:!pe,onPress:()=>he(!pe),haptic:V}):null,v?_jsx(CardIconAction,{icon:"trash",label:X.remove,onPress:v,color:G.colors["danger-text"],haptic:V}):null]}),Be=_jsxs(_Fragment,{children:[be?_jsx(View,{style:[ae.header,!c&&ae.headerRow,pe&&ae.headerFolded,M],children:c??Ie}):null,pe?null:_jsx(View,{style:[be||C?ae.body:null,D],children:i}),C&&!pe?_jsx(View,{style:[ae.footer,E],children:C}):null]}),Le=re?_jsxs(_Fragment,{children:[_jsxs(View,{style:ae.imageWrapper,children:[_jsx(Image,{source:w,resizeMode:"cover",style:ke,accessibilityLabel:"",accessible:!1}),A?_jsx(View,{pointerEvents:"box-none",style:ae.imageOverlay,children:A}):null]}),_jsx(View,{style:{padding:le},children:Be})]}):Be,He=ne?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:ne,style:StyleSheet.absoluteFill}),Le]}):ye.active&&ye.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:ye.size.width,height:ye.size.height,radius:ce,fill:ve,stroke:je?Ce:void 0,strokeWidth:je}),_jsx(View,{style:[ae.squircleClip,{padding:le,borderRadius:ye.size?squircleHostRadius(ye.size.width,ye.size.height,ce):ce}],children:Le})]}):Le;let Pe;if(te){const handlePress=e=>{Y&&(V&&triggerHaptic(V),k?.(e))};Pe=_jsx(Animated.View,{style:ie,children:_jsx(Pressable,{ref:ee,onPress:handlePress,onPressIn:oe,onPressOut:se,accessibilityRole:H??(Y?"button":void 0),accessibilityLabel:B,accessibilityHint:L,testID:q,onLayout:ye.onLayout,style:[Te,z,P,Fe],...N,...Z.hostProps,children:He})})}else Pe=_jsx(View,{ref:t,accessibilityLabel:B,accessibilityHint:L,accessibilityRole:H,testID:q,onLayout:ye.onLayout,style:[Te,z,P,Fe],...N,children:He});return F?_jsx(CardSkeleton,{...e}):Z.enabled?_jsxs(_Fragment,{children:[Pe,Z.renderSurface(_jsx(View,{style:[Te,z,P,Fe,ae.preview],children:He}))]}):Pe}));Card.displayName="Card";const CardSkeleton=({variant:e,elevation:t,radius:i,padding:o,bg:s,header:a,footer:r,imageSource:l,imageHeight:n=160,imageAspectRatio:d,containerStyle:c,headerStyle:u,bodyStyle:m,footerStyle:h,style:p,labels:g,...b})=>{const y=useTheme(),x=y.settings.components.card,f=e??x?.defaultVariant??"elevated",S=i??x?.defaultRadius??"lg",v=o??x?.defaultPadding??"md",j={...DEFAULT_CARD_LABELS,...g},C=paddingMap[v],w=y.space[C],_="flat"===f?y.radius.none:y.radius[S],R=void 0!==a||hasBuiltInHeaderContent(b),A=resolveBackground(y,s)??y.colors.surface,F="outline"===f?1:0,T="outline"===f?y.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:A,borderRadius:_,...smoothCorners,borderWidth:F,borderColor:T,overflow:"hidden"},c,p],accessibilityRole:"progressbar",accessibilityLabel:j.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,R?_jsx(View,{style:[{padding:w,paddingBottom:y.space.sm},u],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:w},m],children:_jsx(SkeletonText,{lines:3,fontSize:y.text.base.size,lastLineWidth:"55%"})}),void 0!==r?_jsx(View,{style:[{padding:w,paddingTop:y.space.sm,flexDirection:"row"},h],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:o,color:s,haptic:a})=>{const r=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===o?void 0:{expanded:o},"aria-expanded":o,onPress:()=>{a&&triggerHaptic(a),i()},style:iconActionStyle,children:_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:_jsx(AppIcon,{name:e,size:20,color:s??r.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&triggerHaptic(t),e.onPress()},style:textActionStyle,children:_jsx(Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?fontFor(e,"semibold","display"):{fontFamily:void 0,...fontFor(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",...smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=themeStyles(buildStyles);export{Card};export default Card;
1
+ "use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,Gradient,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{squircleHostRadius}from"../../utils/squircle.js";import{themeStyles}from"../../utils/themeStyles.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"];export const DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"});const paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=React.memo(forwardRef((e,t)=>{const{children:i,variant:s,elevation:o="card",radius:a,padding:r,interactive:l=!1,pressAnimation:n="scale",bg:d,header:c,title:u,titleFont:m,lead:h,action:p,headerActions:g,collapsible:b=!1,collapsed:y,defaultCollapsed:x=!1,onCollapsedChange:f,collapsedSummary:S,onRemove:j,separatorHeight:v=StyleSheet.hairlineWidth,footer:C,imageSource:_,imageHeight:w=160,imageAspectRatio:R,imageOverlay:A,loading:V=!1,gradient:F,onPress:T,haptic:k,contextMenu:B,accessibilityLabel:L,accessibilityHint:I,accessibilityRole:H,style:P,containerStyle:z,headerStyle:M,bodyStyle:D,footerStyle:E,testID:q,labels:O,onLayout:W,...N}=e;assertValidValue("Card","variant",e.variant,["elevated","outline","filled","flat"]),assertValidValue("Card","radius",e.radius,["sm","md","lg","xl","pill"]),assertValidValue("Card","padding",e.padding,["none","sm","md","lg","xl"]),assertValidValue("Card","titleFont",e.titleFont,["sans","serif"]),assertValidValue("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const G=useTheme(),U=G.settings.components.card,K=s??U?.defaultVariant??"elevated",$=a??U?.defaultRadius??"lg",J=r??U?.defaultPadding??"md",Q=m??U?.defaultTitleFont??"sans",X=useMemo(()=>({...DEFAULT_CARD_LABELS,...O}),[O]),Y=l||"function"==typeof T,Z=useContextMenu(B,{haptic:k||!1,testID:q,accessibilityActions:N.accessibilityActions,onAccessibilityAction:N.onAccessibilityAction}),ee=useMemo(()=>mergeRefs(t,Z.hostRef),[t,Z.hostRef]),te=Y||Z.enabled,{style:ie,pressIn:se,pressOut:oe}=usePressAnimation({preset:n||"scale",enabled:te&&!1!==n}),ae=stylesFor(G),re=Boolean(_),le=G.space[paddingMap[J]],ne=useMemo(()=>F?"string"==typeof F?G.settings.gradients[F]??null:F:null,[F,G.settings.gradients]),de="flat"===K,ce=de?G.radius.none:G.radius[$],ue=resolveBackground(G,d),[me,he]=useControllableState({value:y,defaultValue:x,onChange:f}),pe=b&&me,ge=hasBuiltInHeaderContent(e),be=Boolean(c)||ge,ye=useSquircle(!re&&!ne&&!de,ce,W),xe=StyleSheet.flatten([z,P])??{},fe=xe.backgroundColor,Se=xe.borderColor,je=fe??ue??("filled"===K?G.colors["bg-subtle"]:G.colors.surface),ve="outline"===K?G.size.border:0,Ce=Se??G.colors.border,we="none"===o?void 0:G.shadow[o],Re="elevated"===K&&supportsBoxShadow()&&we?toBoxShadow(we):void 0,Ae=ye.active&&"elevated"===K&&!Re,Ve=ye.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,Fe=useMemo(()=>{const e={borderRadius:Ae&&ye.size?squircleHostRadius(ye.size.width,ye.size.height,ce):ce,...smoothCorners,padding:re||ye.active?G.space.none:le,overflow:ye.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:ue??G.colors.surface,borderBottomWidth:v,borderBottomColor:G.colors.border};case"outline":return{...e,backgroundColor:ye.active?"transparent":ue??G.colors.surface,borderWidth:G.size.border,borderColor:ye.active?"transparent":G.colors.border};case"filled":return{...e,backgroundColor:ye.active?"transparent":ue??G.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??G.colors.surface,...Re?{boxShadow:Re}:we}}},[G,K,we,ce,re,le,ye.active,ye.size,Re,Ae,ue,v]),Te=useMemo(()=>({..."number"==typeof R?{width:"100%",aspectRatio:R}:{width:"100%",height:w},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:G.radius.none,borderBottomRightRadius:G.radius.none,...smoothCorners}),[G,ce,R,w]),ke=u??"",Be=_jsxs(_Fragment,{children:[_jsxs(View,{style:ae.titleColumn,children:[u?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(G,Q),children:u}):null,h?_jsx(Text,{variant:"bodySmall",style:ae.lead,children:h}):null,pe&&S?_jsx(Text,{variant:"caption",style:ae.lead,children:S}):null]}),isCardTextAction(p)?_jsx(CardTextActionButton,{action:p,haptic:k}):p?_jsx(View,{style:ae.actionNode,children:p}):null,g,b?_jsx(CardIconAction,{icon:pe?"chevron-down":"chevron-up",label:`${pe?X.show:X.hide} ${ke}`.trim(),expanded:!pe,onPress:()=>he(!pe),haptic:k}):null,j?_jsx(CardIconAction,{icon:"trash",label:X.remove,onPress:j,color:G.colors["danger-text"],haptic:k}):null]}),Le=_jsxs(_Fragment,{children:[be?_jsx(View,{style:[ae.header,!c&&ae.headerRow,pe&&ae.headerFolded,M],children:c??Be}):null,pe?null:_jsx(View,{style:[be||C?ae.body:null,D],children:i}),C&&!pe?_jsx(View,{style:[ae.footer,E],children:C}):null]}),Ie=re?_jsxs(_Fragment,{children:[_jsxs(View,{style:ae.imageWrapper,children:[_jsx(Image,{source:_,resizeMode:"cover",style:Te,accessibilityLabel:"",accessible:!1}),A?_jsx(View,{pointerEvents:"box-none",style:ae.imageOverlay,children:A}):null]}),_jsx(View,{style:{padding:le},children:Le})]}):Le,He=ne?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:ne,style:StyleSheet.absoluteFill}),Ie]}):ye.active&&ye.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:ye.size.width,height:ye.size.height,radius:ce,fill:je,stroke:ve?Ce:void 0,strokeWidth:ve}),_jsx(View,{style:[ae.squircleClip,{padding:le,borderRadius:ye.size?squircleHostRadius(ye.size.width,ye.size.height,ce):ce}],children:Ie})]}):Ie;let Pe;if(te){const handlePress=e=>{Y&&(k&&triggerHaptic(k),T?.(e))};Pe=_jsx(Animated.View,{style:ie,children:_jsx(Pressable,{ref:ee,onPress:handlePress,onPressIn:se,onPressOut:oe,accessibilityRole:H??(Y?"button":void 0),accessibilityLabel:L,accessibilityHint:I,testID:q,onLayout:ye.onLayout,style:[Fe,z,P,Ve],...N,...Z.hostProps,children:He})})}else Pe=_jsx(View,{ref:t,accessibilityLabel:L,accessibilityHint:I,accessibilityRole:H,testID:q,onLayout:ye.onLayout,style:[Fe,z,P,Ve],...N,children:He});return V?_jsx(CardSkeleton,{...e}):Z.enabled?_jsxs(_Fragment,{children:[Pe,Z.renderSurface(_jsx(View,{style:[Fe,z,P,Ve,ae.preview],children:He}))]}):Pe}));Card.displayName="Card";const CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:o,header:a,footer:r,imageSource:l,imageHeight:n=160,imageAspectRatio:d,containerStyle:c,headerStyle:u,bodyStyle:m,footerStyle:h,style:p,labels:g,...b})=>{const y=useTheme(),x=y.settings.components.card,f=e??x?.defaultVariant??"elevated",S=i??x?.defaultRadius??"lg",j=s??x?.defaultPadding??"md",v={...DEFAULT_CARD_LABELS,...g},C=paddingMap[j],_=y.space[C],w="flat"===f?y.radius.none:y.radius[S],R=void 0!==a||hasBuiltInHeaderContent(b),A=resolveBackground(y,o)??y.colors.surface,V="outline"===f?1:0,F="outline"===f?y.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:A,borderRadius:w,...smoothCorners,borderWidth:V,borderColor:F,overflow:"hidden"},c,p],accessibilityRole:"progressbar",accessibilityLabel:v.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,R?_jsx(View,{style:[{padding:_,paddingBottom:y.space.sm},u],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:_},m],children:_jsx(SkeletonText,{lines:3,fontSize:y.text.base.size,lastLineWidth:"55%"})}),void 0!==r?_jsx(View,{style:[{padding:_,paddingTop:y.space.sm,flexDirection:"row"},h],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:o,haptic:a})=>{const r=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{a&&triggerHaptic(a),i()},style:iconActionStyle,children:_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:_jsx(AppIcon,{name:e,size:20,color:o??r.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&triggerHaptic(t),e.onPress()},style:textActionStyle,children:_jsx(Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?fontFor(e,"semibold","display"):{fontFamily:void 0,...fontFor(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",...smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=themeStyles(buildStyles);export{Card};export default Card;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Animated,AppState,Dimensions,FlatList,Image,Pressable,ScrollView,StyleSheet,View}from"react-native";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_CAROUSEL_LABELS=Object.freeze({carousel:"Carousel",slideOf:(e,t)=>`Slide ${e} of ${t}`,goToSlide:e=>`Go to slide ${e}`});const CarouselInner=forwardRef((e,t)=>{const{data:n,renderItem:r,keyExtractor:a,index:i,defaultIndex:l=0,onIndexChange:s,onScrollOffsetChange:o,autoPlay:c=!1,autoPlayInterval:u=4e3,loop:d=!1,showPagination:m=!0,paginationStyle:h="dots",itemWidth:g="screen",spacing:b=0,containerStyle:p,accessibilityLabel:f,testID:x,showThumbnails:y=!1,haptic:S,renderThumbnail:w,loading:v=!1,labels:C}=e;warnInvalidValue("Carousel","paginationStyle",e.paginationStyle,["dots","bars","numbers"]);const T=useMemo(()=>({...DEFAULT_CAROUSEL_LABELS,...C}),[C]),j=useTheme(),I="number"==typeof i,k=d||c,[_,A]=useState(()=>Dimensions.get("window").width),E="screen"===g?_:g,R=E+b,V=useRef(null),L=useRef(createAnimatedValue(0)).current,O=clamp(I?i:l,0,Math.max(0,n.length-1)),[H,D]=useState(O),M=useRef(null),P=useRef(null),z=useRef(!1),N=useRef(H);N.current=H;const W=useCallback(e=>{const t=clamp(e,0,Math.max(0,n.length-1));D(e=>e===t?e:(s?.(t),t))},[n.length,s]),F=useCallback((e,t=!0)=>{if(0===n.length)return;const r=clamp(e,0,n.length-1);V.current?.scrollToOffset({offset:r*R,animated:t}),W(r)},[n.length,R,W]),$=useCallback(()=>{if(0===n.length)return;const e=N.current+1;e>=n.length?k&&F(0,!1):F(e,!0)},[n.length,k,F]),U=useCallback(()=>{if(0===n.length)return;const e=N.current-1;e<0?k&&F(n.length-1,!1):F(e,!0)},[n.length,k,F]);useImperativeHandle(t,()=>({scrollTo:F,next:$,prev:U}),[F,$,U]),useEffect(()=>{I&&i!==H&&F(i,!0)},[i]);const B=useCallback(()=>{M.current&&(clearInterval(M.current),M.current=null)},[]),G=useCallback(()=>{!c||n.length<=1||(B(),M.current=setInterval(()=>{if(z.current)return;const e=N.current+1;e>=n.length?F(0,!1):F(e,!0)},u))},[c,u,n.length,F,B]);useEffect(()=>(G(),()=>{B(),P.current&&clearTimeout(P.current)}),[G,B]),useEffect(()=>{const e=AppState.addEventListener("change",e=>{"active"!==e?(B(),P.current&&(clearTimeout(P.current),P.current=null)):G()});return()=>e.remove()},[G,B]);const K=m&&n.length>1&&"numbers"!==h||void 0!==o,X=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{x:L}}}],{useNativeDriver:!1,listener:o?e=>o(e.nativeEvent.contentOffset.x):void 0}),[L,o]),q=useCallback(e=>{if(R<=0)return;const t=e.nativeEvent.contentOffset.x,n=Math.round(t/R);W(n)},[R,W]),J=useCallback(()=>{z.current=!0,B(),P.current&&(clearTimeout(P.current),P.current=null)},[B]),Q=useCallback(()=>{z.current=!1,c&&(P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{G()},1e3))},[c,G]),Y=useCallback(e=>{switch(e.nativeEvent.actionName){case"increment":$();break;case"decrement":U()}},[$,U]),Z=useMemo(()=>buildStyles(j),[j]),ee=useCallback(({item:e,index:t})=>_jsx(View,{style:{width:E,marginRight:t===n.length-1?0:b},accessibilityElementsHidden:t!==H,importantForAccessibility:t===H?"yes":"no-hide-descendants",children:r(e,t)}),[r,E,b,n.length,H]),te=useCallback((e,t)=>String(t),[]),ne=useCallback((e,t)=>({length:R,offset:R*t,index:t}),[R]);return v?_jsx(CarouselSkeleton,{...e,containerWidth:_}):_jsxs(View,{style:[Z.container,p],onLayout:e=>A(e.nativeEvent.layout.width),accessibilityRole:"adjustable",accessibilityLabel:f??T.carousel,accessibilityValue:{min:0,max:Math.max(0,n.length-1),now:H,text:T.slideOf(H+1,n.length)},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Y,testID:x,children:[_jsx(FlatList,{ref:V,data:n,keyExtractor:a??te,renderItem:ee,horizontal:!0,pagingEnabled:"screen"===g&&0===b,snapToInterval:R,snapToAlignment:"start",decelerationRate:"fast",showsHorizontalScrollIndicator:!1,onScroll:K?X:void 0,scrollEventThrottle:K?16:void 0,onMomentumScrollEnd:q,onScrollBeginDrag:J,onScrollEndDrag:Q,getItemLayout:ne,initialScrollIndex:O,bounces:!1}),m&&n.length>1?_jsx(Pagination,{count:n.length,currentIndex:H,scrollX:L,slideStride:R,variant:h,theme:j,labels:T}):null,y&&n.length>0?_jsx(ThumbnailStrip,{data:n,currentIndex:H,renderThumbnail:w,labels:T,onSelect:e=>{const t=resolveHaptic(S,"selection");t&&triggerHaptic(t),F(e,!0)},theme:j}):null]})});CarouselInner.displayName="Carousel";const CarouselSkeleton=({itemWidth:e="screen",showPagination:t=!0,paginationStyle:n="dots",containerStyle:r,containerWidth:a})=>{const i=useTheme(),l="screen"===e?a||320:e;return _jsxs(View,{style:[carouselSkeletonStyles.container,r],children:[_jsx(Skeleton,{width:l,height:160,radius:"md"}),t?_jsx(View,{style:[carouselSkeletonStyles.paginationRow,{marginTop:i.space.md}],children:SKELETON_PAGINATION_DOTS.map(e=>_jsx(Skeleton,"numbers"===n?{width:24,height:16,radius:"sm",style:{marginHorizontal:i.space.xs}}:"bars"===n?{width:20,height:4,radius:"pill",style:{marginHorizontal:i.space.xxs}}:{shape:"circle",width:8,height:8,style:{marginHorizontal:i.space.xs}},e))}):null]})};CarouselSkeleton.displayName="CarouselSkeleton";const SKELETON_PAGINATION_DOTS=["first","second","third"],carouselSkeletonStyles=StyleSheet.create({container:{alignItems:"center"},paginationRow:{flexDirection:"row",justifyContent:"center"}}),Carousel=CarouselInner;Carousel.Skeleton=CarouselSkeleton;const Pagination=({count:e,currentIndex:t,scrollX:n,slideStride:r,variant:a,theme:i,labels:l})=>{const s=useMemo(()=>buildPaginationStyles(i),[i]);if("numbers"===a)return _jsx(View,{style:s.numbersWrap,children:_jsx(Text,{variant:"bodySmall",weight:"medium",color:"secondary",style:s.numbersText,accessibilityLabel:l.slideOf(t+1,e),children:`${t+1} / ${e}`})});const o=Array.from({length:e},(e,t)=>t),c="bars"===a,u=c?24:6,d=c?36:16,m=c?3:6;return _jsx(View,{style:s.dotRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o.map(e=>{const a=[(e-1)*r,e*r,(e+1)*r],l=n.interpolate({inputRange:a,outputRange:[u,d,u],extrapolate:"clamp"}),s=n.interpolate({inputRange:a,outputRange:[.5,1,.5],extrapolate:"clamp"});return _jsx(Animated.View,{style:[{width:l,height:m,marginHorizontal:i.space.xs,borderRadius:i.radius.pill,...smoothCorners,backgroundColor:e===t?i.colors.primary:i.colors.border,opacity:s}]},e)})})},ThumbnailStrip=({data:e,currentIndex:t,renderThumbnail:n,onSelect:r,theme:a,labels:i})=>{const l=useMemo(()=>buildThumbStyles(a),[a]);return _jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:l.row,accessibilityRole:"tablist",children:e.map((e,s)=>_jsx(ThumbnailItem,{item:e,index:s,isActive:s===t,renderThumbnail:n,onPress:()=>r(s),theme:a,styles:l,labels:i},s))})},ThumbnailItem=({item:e,index:t,isActive:n,renderThumbnail:r,onPress:a,theme:i,styles:l,labels:s})=>{const o=useRef(createAnimatedValue(n?1.1:1)).current;useEffect(()=>{const e=Animated.spring(o,{toValue:n?1.1:1,useNativeDriver:!0,friction:6,tension:80});return e.start(),()=>e.stop()},[n,o]);const c=useMemo(()=>r?r(e,t):e&&"object"==typeof e&&"uri"in e&&"string"==typeof e.uri?_jsx(Image,{source:{uri:e.uri},style:l.image,resizeMode:"cover"}):_jsx(View,{style:[l.placeholder,{backgroundColor:i.colors["bg-subtle"]}],children:_jsx(Text,{variant:"caption",weight:"semibold",color:"secondary",children:t+1})}),[e,t,r,i,l]);return _jsx(Pressable,{onPress:a,accessibilityRole:"tab",accessibilityState:{selected:n},"aria-selected":n,accessibilityLabel:s.goToSlide(t+1),children:_jsx(Animated.View,{style:[l.thumb,{borderColor:n?i.colors.primary:"transparent",transform:[{scale:o}]}],children:c})})},buildThumbStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.sm,paddingVertical:e.space.sm},thumb:{width:40,height:40,marginHorizontal:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,borderWidth:2,overflow:"hidden"},image:{width:"100%",height:"100%"},placeholder:{flex:1,alignItems:"center",justifyContent:"center"}}),clamp=(e,t,n)=>Math.min(Math.max(e,t),n),buildStyles=e=>StyleSheet.create({container:{width:"100%"}}),buildPaginationStyles=e=>StyleSheet.create({dotRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersWrap:{alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersText:{textAlign:"center"}});export{Carousel};export default Carousel;
1
+ "use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Animated,AppState,Dimensions,FlatList,Image,Pressable,ScrollView,StyleSheet,View}from"react-native";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_CAROUSEL_LABELS=Object.freeze({carousel:"Carousel",slideOf:(e,t)=>`Slide ${e} of ${t}`,goToSlide:e=>`Go to slide ${e}`});const CarouselInner=forwardRef((e,t)=>{const{data:n,renderItem:r,keyExtractor:s,index:a,defaultIndex:i=0,onIndexChange:l,onScrollOffsetChange:o,autoPlay:c=!1,autoPlayInterval:u=4e3,loop:d=!1,showPagination:m=!0,paginationStyle:h="dots",itemWidth:g="screen",spacing:b=0,containerStyle:p,accessibilityLabel:f,testID:x,showThumbnails:y=!1,haptic:S,renderThumbnail:w,loading:C=!1,labels:T}=e;assertValidValue("Carousel","paginationStyle",e.paginationStyle,["dots","bars","numbers"]);const v=useMemo(()=>({...DEFAULT_CAROUSEL_LABELS,...T}),[T]),j=useTheme(),I="number"==typeof a,k=d||c,[_,A]=useState(()=>Dimensions.get("window").width),E="screen"===g?_:g,R=E+b,V=useRef(null),L=useRef(createAnimatedValue(0)).current,O=clamp(I?a:i,0,Math.max(0,n.length-1)),[H,D]=useState(O),M=useRef(null),P=useRef(null),z=useRef(!1),N=useRef(H);N.current=H;const W=useCallback(e=>{const t=clamp(e,0,Math.max(0,n.length-1));D(e=>e===t?e:(l?.(t),t))},[n.length,l]),F=useCallback((e,t=!0)=>{if(0===n.length)return;const r=clamp(e,0,n.length-1);V.current?.scrollToOffset({offset:r*R,animated:t}),W(r)},[n.length,R,W]),$=useCallback(()=>{if(0===n.length)return;const e=N.current+1;e>=n.length?k&&F(0,!1):F(e,!0)},[n.length,k,F]),U=useCallback(()=>{if(0===n.length)return;const e=N.current-1;e<0?k&&F(n.length-1,!1):F(e,!0)},[n.length,k,F]);useImperativeHandle(t,()=>({scrollTo:F,next:$,prev:U}),[F,$,U]),useEffect(()=>{I&&a!==H&&F(a,!0)},[a]);const B=useCallback(()=>{M.current&&(clearInterval(M.current),M.current=null)},[]),G=useCallback(()=>{!c||n.length<=1||(B(),M.current=setInterval(()=>{if(z.current)return;const e=N.current+1;e>=n.length?F(0,!1):F(e,!0)},u))},[c,u,n.length,F,B]);useEffect(()=>(G(),()=>{B(),P.current&&clearTimeout(P.current)}),[G,B]),useEffect(()=>{const e=AppState.addEventListener("change",e=>{"active"!==e?(B(),P.current&&(clearTimeout(P.current),P.current=null)):G()});return()=>e.remove()},[G,B]);const K=m&&n.length>1&&"numbers"!==h||void 0!==o,X=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{x:L}}}],{useNativeDriver:!1,listener:o?e=>o(e.nativeEvent.contentOffset.x):void 0}),[L,o]),q=useCallback(e=>{if(R<=0)return;const t=e.nativeEvent.contentOffset.x,n=Math.round(t/R);W(n)},[R,W]),J=useCallback(()=>{z.current=!0,B(),P.current&&(clearTimeout(P.current),P.current=null)},[B]),Q=useCallback(()=>{z.current=!1,c&&(P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{G()},1e3))},[c,G]),Y=useCallback(e=>{switch(e.nativeEvent.actionName){case"increment":$();break;case"decrement":U()}},[$,U]),Z=useMemo(()=>buildStyles(j),[j]),ee=useCallback(({item:e,index:t})=>_jsx(View,{style:{width:E,marginRight:t===n.length-1?0:b},accessibilityElementsHidden:t!==H,importantForAccessibility:t===H?"yes":"no-hide-descendants",children:r(e,t)}),[r,E,b,n.length,H]),te=useCallback((e,t)=>String(t),[]),ne=useCallback((e,t)=>({length:R,offset:R*t,index:t}),[R]);return C?_jsx(CarouselSkeleton,{...e,containerWidth:_}):_jsxs(View,{style:[Z.container,p],onLayout:e=>A(e.nativeEvent.layout.width),accessibilityRole:"adjustable",accessibilityLabel:f??v.carousel,accessibilityValue:{min:0,max:Math.max(0,n.length-1),now:H,text:v.slideOf(H+1,n.length)},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Y,testID:x,children:[_jsx(FlatList,{ref:V,data:n,keyExtractor:s??te,renderItem:ee,horizontal:!0,pagingEnabled:"screen"===g&&0===b,snapToInterval:R,snapToAlignment:"start",decelerationRate:"fast",showsHorizontalScrollIndicator:!1,onScroll:K?X:void 0,scrollEventThrottle:K?16:void 0,onMomentumScrollEnd:q,onScrollBeginDrag:J,onScrollEndDrag:Q,getItemLayout:ne,initialScrollIndex:O,bounces:!1}),m&&n.length>1?_jsx(Pagination,{count:n.length,currentIndex:H,scrollX:L,slideStride:R,variant:h,theme:j,labels:v}):null,y&&n.length>0?_jsx(ThumbnailStrip,{data:n,currentIndex:H,renderThumbnail:w,labels:v,onSelect:e=>{const t=resolveHaptic(S,"selection");t&&triggerHaptic(t),F(e,!0)},theme:j}):null]})});CarouselInner.displayName="Carousel";const CarouselSkeleton=({itemWidth:e="screen",showPagination:t=!0,paginationStyle:n="dots",containerStyle:r,containerWidth:s})=>{const a=useTheme(),i="screen"===e?s||320:e;return _jsxs(View,{style:[carouselSkeletonStyles.container,r],children:[_jsx(Skeleton,{width:i,height:160,radius:"md"}),t?_jsx(View,{style:[carouselSkeletonStyles.paginationRow,{marginTop:a.space.md}],children:SKELETON_PAGINATION_DOTS.map(e=>_jsx(Skeleton,"numbers"===n?{width:24,height:16,radius:"sm",style:{marginHorizontal:a.space.xs}}:"bars"===n?{width:20,height:4,radius:"pill",style:{marginHorizontal:a.space.xxs}}:{shape:"circle",width:8,height:8,style:{marginHorizontal:a.space.xs}},e))}):null]})};CarouselSkeleton.displayName="CarouselSkeleton";const SKELETON_PAGINATION_DOTS=["first","second","third"],carouselSkeletonStyles=StyleSheet.create({container:{alignItems:"center"},paginationRow:{flexDirection:"row",justifyContent:"center"}}),Carousel=CarouselInner;Carousel.Skeleton=CarouselSkeleton;const Pagination=({count:e,currentIndex:t,scrollX:n,slideStride:r,variant:s,theme:a,labels:i})=>{const l=useMemo(()=>buildPaginationStyles(a),[a]);if("numbers"===s)return _jsx(View,{style:l.numbersWrap,children:_jsx(Text,{variant:"bodySmall",weight:"medium",color:"secondary",style:l.numbersText,accessibilityLabel:i.slideOf(t+1,e),children:`${t+1} / ${e}`})});const o=Array.from({length:e},(e,t)=>t),c="bars"===s,u=c?24:6,d=c?36:16,m=c?3:6;return _jsx(View,{style:l.dotRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o.map(e=>{const s=[(e-1)*r,e*r,(e+1)*r],i=n.interpolate({inputRange:s,outputRange:[u,d,u],extrapolate:"clamp"}),l=n.interpolate({inputRange:s,outputRange:[.5,1,.5],extrapolate:"clamp"});return _jsx(Animated.View,{style:[{width:i,height:m,marginHorizontal:a.space.xs,borderRadius:a.radius.pill,...smoothCorners,backgroundColor:e===t?a.colors.primary:a.colors.border,opacity:l}]},e)})})},ThumbnailStrip=({data:e,currentIndex:t,renderThumbnail:n,onSelect:r,theme:s,labels:a})=>{const i=useMemo(()=>buildThumbStyles(s),[s]);return _jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:i.row,accessibilityRole:"tablist",children:e.map((e,l)=>_jsx(ThumbnailItem,{item:e,index:l,isActive:l===t,renderThumbnail:n,onPress:()=>r(l),theme:s,styles:i,labels:a},l))})},ThumbnailItem=({item:e,index:t,isActive:n,renderThumbnail:r,onPress:s,theme:a,styles:i,labels:l})=>{const o=useRef(createAnimatedValue(n?1.1:1)).current;useEffect(()=>{const e=Animated.spring(o,{toValue:n?1.1:1,useNativeDriver:!0,friction:6,tension:80});return e.start(),()=>e.stop()},[n,o]);const c=useMemo(()=>r?r(e,t):e&&"object"==typeof e&&"uri"in e&&"string"==typeof e.uri?_jsx(Image,{source:{uri:e.uri},style:i.image,resizeMode:"cover"}):_jsx(View,{style:[i.placeholder,{backgroundColor:a.colors["bg-subtle"]}],children:_jsx(Text,{variant:"caption",weight:"semibold",color:"secondary",children:t+1})}),[e,t,r,a,i]);return _jsx(Pressable,{onPress:s,accessibilityRole:"tab",accessibilityState:{selected:n},"aria-selected":n,accessibilityLabel:l.goToSlide(t+1),children:_jsx(Animated.View,{style:[i.thumb,{borderColor:n?a.colors.primary:"transparent",transform:[{scale:o}]}],children:c})})},buildThumbStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.sm,paddingVertical:e.space.sm},thumb:{width:40,height:40,marginHorizontal:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,borderWidth:2,overflow:"hidden"},image:{width:"100%",height:"100%"},placeholder:{flex:1,alignItems:"center",justifyContent:"center"}}),clamp=(e,t,n)=>Math.min(Math.max(e,t),n),buildStyles=e=>StyleSheet.create({container:{width:"100%"}}),buildPaginationStyles=e=>StyleSheet.create({dotRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersWrap:{alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersText:{textAlign:"center"}});export{Carousel};export default Carousel;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useControllableState}from"../../hooks/index.js";import{createAnimatedValue,resolveCheckboxSize,spaceOf,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{ChoiceText,hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{fieldTextAsString,hasFieldText}from"../FieldBase/FieldBase.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const CHECKBOX_SHAPES=["circle"],toneColor=(e,r)=>{switch(r){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;default:return e.colors.primary}},toneOnColor=(e,r)=>{switch(r){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];case"neutral":return e.colors["on-neutral"];default:return e.colors["on-primary"]}},Checkbox=forwardRef((e,r)=>{const{checked:t,defaultChecked:s,onChange:o,indeterminate:i=!1,disabled:a=!1,label:n,helperText:l,description:c,error:d,help:h,size:u="md",tone:p="primary",shape:m,accessibilityLabel:x,haptic:f,style:b,boxStyle:g,indeterminateBarStyle:y,containerStyle:C,labelStyle:w,testID:S,hitSlop:k,...j}=e,[v,T]=useControllableState({value:t,defaultValue:s??!1,onChange:o}),V=useTheme(),_=useMemo(()=>buildStyles(V),[V]),{"box-size":I}=useMemo(()=>resolveCheckboxSize(V,u),[V,u]),R=V.size.border,A=spaceOf(V,V.components.checkbox["label-gap"]),H=toneColor(V,p),M=k??6;warnInvalidValue("Checkbox","shape",m,CHECKBOX_SHAPES),warnInvalidValue("Checkbox","size",e.size,["sm","md","lg"]),warnInvalidValue("Checkbox","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const D="circle"===m,P="string"==typeof d?d:void 0,z={description:c,helperText:l,error:P},B=v||i,F=useRef(createAnimatedValue(B?1:0)).current;useEffect(()=>{const e=Animated.spring(F,{toValue:B?1:0,damping:V.motion.spring.snappy.damping,stiffness:V.motion.spring.snappy.stiffness,mass:V.motion.spring.snappy.mass,useNativeDriver:!0});return e.start(),()=>e.stop()},[B,F,V.motion.spring.snappy]);const L=F.interpolate({inputRange:[0,1],outputRange:[0,1]}),O=x??fieldTextAsString(n),E=!0===d||hasFieldText(d),W=B?H:a?V.colors.border:E?V.colors["field-border-error"]:V.colors.border,K=B?H:a?V.colors["surface-disabled"]:"transparent",N=a&&!B?V.colors["text-disabled"]:toneOnColor(V,p),X=Math.round(.72*I),U=Math.round(.55*I),q=Math.max(2,Math.round(.12*I)),G=_jsxs(Pressable,{ref:r,onPress:e=>{if(a)return;const r=resolveHaptic(f,"selection");r&&triggerHaptic(r),T(!v),j.onPressOut?.(e)},disabled:a,accessibilityRole:"checkbox",accessibilityLabel:O,accessibilityHint:j.accessibilityHint??fieldTextAsString(l??c),accessibilityState:{checked:i?"mixed":v,disabled:a},"aria-checked":i?"mixed":v,"aria-disabled":a,testID:S,hitSlop:M,...hitSlopMarker(M),...j,style:({pressed:e})=>[_.row,hasChoiceDetail(z)?_.rowTop:null,hasFieldText(h)?_.rowShrink:null,{opacity:a?.55:e?.85:1},C,b],children:[_jsx(View,{style:[_.box,{width:I,height:I,borderWidth:R,borderRadius:D?I/2:V.radius.sm,...D?{}:smoothCorners,borderColor:W,backgroundColor:K},g],children:_jsx(Animated.View,{style:[_.glyphWrap,{opacity:F,transform:[{scale:L}]}],children:i?_jsx(View,{style:[{width:U,height:q,borderRadius:V.radius.pill,...smoothCorners,backgroundColor:N},y]}):_jsx(Svg,{width:X,height:X,viewBox:"0 0 24 24",children:_jsx(Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:N,strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})})}),_jsx(ChoiceText,{label:n,helperText:l,description:c,error:P,disabled:a,style:{marginLeft:A},labelStyle:w})]});return hasFieldText(h)?_jsxs(View,{style:[_.helpRow,hasChoiceDetail(z)?_.rowTop:null],children:[G,_jsx(View,{style:[_.help,{marginLeft:V.space.xs}],children:h})]}):G});Checkbox.displayName="Checkbox";const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"},rowShrink:{flexShrink:1},helpRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0},box:{alignItems:"center",justifyContent:"center"},glyphWrap:{alignItems:"center",justifyContent:"center"}});export{Checkbox};export default Checkbox;
1
+ "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useControllableState}from"../../hooks/index.js";import{createAnimatedValue,resolveCheckboxSize,spaceOf,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{ChoiceText,hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{fieldTextAsString,hasFieldText}from"../FieldBase/FieldBase.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const CHECKBOX_SHAPES=["circle"],toneColor=(e,r)=>{switch(r){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;default:return e.colors.primary}},toneOnColor=(e,r)=>{switch(r){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];case"neutral":return e.colors["on-neutral"];default:return e.colors["on-primary"]}},Checkbox=forwardRef((e,r)=>{const{checked:t,defaultChecked:s,onChange:o,indeterminate:i=!1,disabled:a=!1,label:l,helperText:n,description:c,error:d,help:h,size:u="md",tone:p="primary",shape:m,accessibilityLabel:x,haptic:f,style:b,boxStyle:g,indeterminateBarStyle:y,containerStyle:C,labelStyle:S,testID:w,hitSlop:k,...j}=e,[V,T]=useControllableState({value:t,defaultValue:s??!1,onChange:o}),v=useTheme(),_=useMemo(()=>buildStyles(v),[v]),{"box-size":R}=useMemo(()=>resolveCheckboxSize(v,u),[v,u]),A=v.size.border,H=spaceOf(v,v.components.checkbox["label-gap"]),M=toneColor(v,p),D=k??6;assertValidValue("Checkbox","shape",m,CHECKBOX_SHAPES),assertValidValue("Checkbox","size",e.size,["sm","md","lg"]),assertValidValue("Checkbox","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const P="circle"===m,z="string"==typeof d?d:void 0,B={description:c,helperText:n,error:z},F=V||i,I=useRef(createAnimatedValue(F?1:0)).current;useEffect(()=>{const e=Animated.spring(I,{toValue:F?1:0,damping:v.motion.spring.snappy.damping,stiffness:v.motion.spring.snappy.stiffness,mass:v.motion.spring.snappy.mass,useNativeDriver:!0});return e.start(),()=>e.stop()},[F,I,v.motion.spring.snappy]);const L=I.interpolate({inputRange:[0,1],outputRange:[0,1]}),O=x??fieldTextAsString(l),E=!0===d||hasFieldText(d),W=F?M:a?v.colors.border:E?v.colors["field-border-error"]:v.colors.border,K=F?M:a?v.colors["surface-disabled"]:"transparent",N=a&&!F?v.colors["text-disabled"]:toneOnColor(v,p),X=Math.round(.72*R),U=Math.round(.55*R),q=Math.max(2,Math.round(.12*R)),G=_jsxs(Pressable,{ref:r,onPress:e=>{if(a)return;const r=resolveHaptic(f,"selection");r&&triggerHaptic(r),T(!V),j.onPressOut?.(e)},disabled:a,accessibilityRole:"checkbox",accessibilityLabel:O,accessibilityHint:j.accessibilityHint??fieldTextAsString(n??c),accessibilityState:{checked:i?"mixed":V,disabled:a},"aria-checked":i?"mixed":V,"aria-disabled":a,testID:w,hitSlop:D,...hitSlopMarker(D),...j,style:({pressed:e})=>[_.row,hasChoiceDetail(B)?_.rowTop:null,hasFieldText(h)?_.rowShrink:null,{opacity:a?.55:e?.85:1},C,b],children:[_jsx(View,{style:[_.box,{width:R,height:R,borderWidth:A,borderRadius:P?R/2:v.radius.sm,...P?{}:smoothCorners,borderColor:W,backgroundColor:K},g],children:_jsx(Animated.View,{style:[_.glyphWrap,{opacity:I,transform:[{scale:L}]}],children:i?_jsx(View,{style:[{width:U,height:q,borderRadius:v.radius.pill,...smoothCorners,backgroundColor:N},y]}):_jsx(Svg,{width:X,height:X,viewBox:"0 0 24 24",children:_jsx(Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:N,strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})})}),_jsx(ChoiceText,{label:l,helperText:n,description:c,error:z,disabled:a,style:{marginLeft:H},labelStyle:S})]});return hasFieldText(h)?_jsxs(View,{style:[_.helpRow,hasChoiceDetail(B)?_.rowTop:null],children:[G,_jsx(View,{style:[_.help,{marginLeft:v.space.xs}],children:h})]}):G});Checkbox.displayName="Checkbox";const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"},rowShrink:{flexShrink:1},helpRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0},box:{alignItems:"center",justifyContent:"center"},glyphWrap:{alignItems:"center",justifyContent:"center"}});export{Checkbox};export default Checkbox;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useMemo}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{resolveChipSize,useTheme}from"../../theme/index.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_CHIP_LABELS=Object.freeze({remove:e=>`Remove ${e}`});const toneFor=(e,r)=>{switch(r){case"primary":return{base:e.colors["primary-soft"],on:e.colors.primary,ink:e.colors["primary-text"],border:e.colors.primary,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"success":return{base:e.colors["bg-muted"],on:e.colors.success,ink:e.colors["success-text"],border:e.colors.success,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"warning":return{base:e.colors["bg-muted"],on:e.colors.warning,ink:e.colors["warning-text"],border:e.colors.warning,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"danger":return{base:e.colors["bg-muted"],on:e.colors.danger,ink:e.colors["danger-text"],border:e.colors.danger,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"info":return{base:e.colors["bg-muted"],on:e.colors.info,ink:e.colors["info-text"],border:e.colors.info,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};default:return{base:e.colors["bg-muted"],on:e.colors["text-body"],ink:e.colors["text-body"],border:e.colors.border,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary}}},SOFT_FILL_OPACITY=.14,SOFT_SELECTED_FILL_OPACITY=.24,hasChipCount=e=>null!=e&&""!==e,Chip=forwardRef((e,r)=>{const{label:s,count:t,selected:o=!1,selectionMode:i="single",onPress:l,onRemove:n,leftIcon:a,iconVariant:c,variant:d="soft",tone:p="neutral",size:m="md",disabled:u=!1,loading:h=!1,accessibilityLabel:b,haptic:y,style:g,textStyle:f,containerStyle:x,countStyle:S,closeButtonStyle:C,closeIconStyle:I,labels:k,removeTestID:v,testID:j}=e;warnInvalidValue("Chip","variant",e.variant,["solid","soft","outline"]),warnInvalidValue("Chip","tone",e.tone,["primary","neutral","success","warning","danger","info"]),warnInvalidValue("Chip","size",e.size,["sm","md"]),warnInvalidValue("Chip","selectionMode",e.selectionMode,["single","multiple","radio"]);const w=useTheme(),_=useMemo(()=>({...DEFAULT_CHIP_LABELS,...k}),[k]),z=!!l&&!u,L="radio"===i,B=!!l&&(!u||L),O=hasChipCount(t),{style:M,pressIn:T,pressOut:P}=usePressAnimation({enabled:z}),A=useMemo(()=>toneFor(w,p),[w,p]),V=useMemo(()=>resolveChipSize(w,m),[w,m]),H=Math.max(0,Math.ceil((44-V["min-height"])/2)),R=L?{top:H,bottom:H}:void 0,D="solid"===d,F="soft"===d,E=(()=>{if(F){const e=o?A.selectedOn:A.on;return tintOf(e,o?.24:.14,o?A.selectedBg:A.base)}return o?D?A.selectedBg:"transparent":D?A.base:"transparent"})(),U=F?"transparent":o?A.selectedBorder:D?"transparent":A.border,$=u?w.colors["text-disabled"]:o?F?w.colors["text-body"]:A.selectedInk:A.ink,N=D||F?0:w.size.border,handlePress=()=>{if(!z)return;const e=resolveHaptic(y,"selection");e&&triggerHaptic(e),l?.()},Y=b??(O?`${s}, ${t}`:s),W=_jsxs(View,{style:styles.row,children:[a?_jsx(View,{style:{marginRight:V.gap},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(a,{color:$,size:V.icon,disabled:u},c)}):null,_jsx(Text,{variant:"label",weight:"medium",numberOfLines:1,style:[styles.label,{color:$,fontSize:V.text,lineHeight:Math.round(V.text*w.leading.body)},f],children:s??" "}),O?_jsx(Text,{variant:"caption",numberOfLines:1,style:[styles.count,{color:$,fontSize:Math.min(w.text.xs.size,V.text),marginLeft:w.space.xs},S],children:t}):null,n?_jsx(Pressable,{onPress:()=>{u||(!1!==y&&triggerHaptic("impactLight"),n?.())},disabled:u,accessibilityRole:"button",accessibilityLabel:_.remove(s),accessibilityState:{disabled:u},"aria-disabled":u,testID:v,hitSlop:6,...hitSlopMarker(6),style:({pressed:e})=>[styles.close,{width:V["close-size"],height:V["close-size"],borderRadius:V["close-size"]/2,...smoothCorners,marginLeft:V.gap,backgroundColor:e?w.colors["surface-pressed"]:w.colors["surface-hover"]},C],children:_jsx(Text,{variant:"label",weight:"bold",maxFontSizeMultiplier:1,style:[{color:$,fontSize:V["close-text"],lineHeight:V["close-text"]+2},I],children:"×"})}):null]}),q={paddingHorizontal:V["padding-x"],paddingVertical:V["padding-y"],minHeight:V["min-height"],borderRadius:w.radius.pill,...smoothCorners,overflow:"hidden",backgroundColor:E,borderWidth:N,borderColor:U,opacity:u?.55:1};let G;return G=B?_jsx(Animated.View,{style:[M,{alignSelf:"flex-start",borderRadius:w.radius.pill,...smoothCorners,overflow:"hidden"}],children:_jsx(Pressable,{ref:r,onPress:handlePress,onPressIn:T,onPressOut:P,disabled:!z,accessibilityRole:L?"radio":"multiple"===i?"checkbox":"button",accessibilityLabel:Y,accessibilityState:L||"multiple"===i?{checked:o,disabled:u}:{selected:o,disabled:u},"aria-checked":L||"multiple"===i?o:void 0,"aria-selected":L||"multiple"===i?void 0:o,"aria-disabled":u,hitSlop:R,...R?hitSlopMarker(R):{},android_ripple:{color:w.colors["surface-pressed"],borderless:!1},testID:j,style:({pressed:e})=>[styles.base,q,e&&"outline"===d?{backgroundColor:w.colors["surface-pressed"]}:null,x,g],children:W})}):_jsx(View,{ref:r,style:[styles.base,q,x,g],accessible:!0,accessibilityRole:"text",accessibilityLabel:Y,accessibilityState:{selected:o,disabled:u},"aria-selected":o,"aria-disabled":u,testID:j,children:W}),h?_jsx(ChipSkeleton,{...e}):G});Chip.displayName="Chip";const ChipSkeleton=({label:e,count:r,size:s="md",leftIcon:t,onRemove:o,style:i,containerStyle:l})=>{const n=useTheme(),a=resolveChipSize(n,s),c=Math.max(40,Math.min(120,7*(e??"").length)),d=a["min-height"],p=d/2,m=c+2*a["padding-x"]+(hasChipCount(r)?a.gap/2+7*String(r).length:0)+(void 0!==t?a.gap+14:0)+(void 0!==o?a.gap+a["close-size"]:0);return _jsx(Skeleton,{width:m,height:d,radius:p,style:[{alignSelf:"flex-start"},l,i]})};ChipSkeleton.displayName="ChipSkeleton",Chip.Skeleton=ChipSkeleton;const styles=StyleSheet.create({base:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",justifyContent:"center"},row:{flexDirection:"row",alignItems:"center"},label:{flexShrink:1,textAlign:"center"},count:{flexShrink:0,fontVariant:["tabular-nums"]},close:{alignItems:"center",justifyContent:"center"}});export{Chip};export default Chip;
1
+ "use strict";import{forwardRef,useMemo}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{resolveChipSize,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_CHIP_LABELS=Object.freeze({remove:e=>`Remove ${e}`});const toneFor=(e,s)=>{switch(s){case"primary":return{base:e.colors["primary-soft"],on:e.colors.primary,ink:e.colors["primary-text"],border:e.colors.primary,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"success":return{base:e.colors["bg-muted"],on:e.colors.success,ink:e.colors["success-text"],border:e.colors.success,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"warning":return{base:e.colors["bg-muted"],on:e.colors.warning,ink:e.colors["warning-text"],border:e.colors.warning,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"danger":return{base:e.colors["bg-muted"],on:e.colors.danger,ink:e.colors["danger-text"],border:e.colors.danger,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"info":return{base:e.colors["bg-muted"],on:e.colors.info,ink:e.colors["info-text"],border:e.colors.info,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};default:return{base:e.colors["bg-muted"],on:e.colors["text-body"],ink:e.colors["text-body"],border:e.colors.border,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary}}},SOFT_FILL_OPACITY=.14,SOFT_SELECTED_FILL_OPACITY=.24,hasChipCount=e=>null!=e&&""!==e,Chip=forwardRef((e,s)=>{const{label:r,count:t,selected:o=!1,selectionMode:i="single",onPress:l,onRemove:a,leftIcon:n,iconVariant:c,variant:d="soft",tone:p="neutral",size:m="md",disabled:u=!1,loading:h=!1,accessibilityLabel:b,haptic:y,style:g,textStyle:f,containerStyle:x,countStyle:S,closeButtonStyle:C,closeIconStyle:k,labels:I,removeTestID:j,testID:v}=e;assertValidValue("Chip","variant",e.variant,["solid","soft","outline"]),assertValidValue("Chip","tone",e.tone,["primary","neutral","success","warning","danger","info"]),assertValidValue("Chip","size",e.size,["sm","md"]),assertValidValue("Chip","selectionMode",e.selectionMode,["single","multiple","radio"]);const w=useTheme(),_=useMemo(()=>({...DEFAULT_CHIP_LABELS,...I}),[I]),z=!!l&&!u,L="radio"===i,V=!!l&&(!u||L),B=hasChipCount(t),{style:O,pressIn:M,pressOut:T}=usePressAnimation({enabled:z}),P=useMemo(()=>toneFor(w,p),[w,p]),A=useMemo(()=>resolveChipSize(w,m),[w,m]),H=Math.max(0,Math.ceil((44-A["min-height"])/2)),R=L?{top:H,bottom:H}:void 0,D="solid"===d,F="soft"===d,E=(()=>{if(F){const e=o?P.selectedOn:P.on;return tintOf(e,o?.24:.14,o?P.selectedBg:P.base)}return o?D?P.selectedBg:"transparent":D?P.base:"transparent"})(),U=F?"transparent":o?P.selectedBorder:D?"transparent":P.border,$=u?w.colors["text-disabled"]:o?F?w.colors["text-body"]:P.selectedInk:P.ink,N=D||F?0:w.size.border,handlePress=()=>{if(!z)return;const e=resolveHaptic(y,"selection");e&&triggerHaptic(e),l?.()},Y=b??(B?`${r}, ${t}`:r),W=_jsxs(View,{style:styles.row,children:[n?_jsx(View,{style:{marginRight:A.gap},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(n,{color:$,size:A.icon,disabled:u},c)}):null,_jsx(Text,{variant:"label",weight:"medium",numberOfLines:1,style:[styles.label,{color:$,fontSize:A.text,lineHeight:Math.round(A.text*w.leading.body)},f],children:r??" "}),B?_jsx(Text,{variant:"caption",numberOfLines:1,style:[styles.count,{color:$,fontSize:Math.min(w.text.xs.size,A.text),marginLeft:w.space.xs},S],children:t}):null,a?_jsx(Pressable,{onPress:()=>{u||(!1!==y&&triggerHaptic("impactLight"),a?.())},disabled:u,accessibilityRole:"button",accessibilityLabel:_.remove(r),accessibilityState:{disabled:u},"aria-disabled":u,testID:j,hitSlop:6,...hitSlopMarker(6),style:({pressed:e})=>[styles.close,{width:A["close-size"],height:A["close-size"],borderRadius:A["close-size"]/2,...smoothCorners,marginLeft:A.gap,backgroundColor:e?w.colors["surface-pressed"]:w.colors["surface-hover"]},C],children:_jsx(Text,{variant:"label",weight:"bold",maxFontSizeMultiplier:1,style:[{color:$,fontSize:A["close-text"],lineHeight:A["close-text"]+2},k],children:"×"})}):null]}),q={paddingHorizontal:A["padding-x"],paddingVertical:A["padding-y"],minHeight:A["min-height"],borderRadius:w.radius.pill,...smoothCorners,overflow:"hidden",backgroundColor:E,borderWidth:N,borderColor:U,opacity:u?.55:1};let G;return G=V?_jsx(Animated.View,{style:[O,{alignSelf:"flex-start",borderRadius:w.radius.pill,...smoothCorners,overflow:"hidden"}],children:_jsx(Pressable,{ref:s,onPress:handlePress,onPressIn:M,onPressOut:T,disabled:!z,accessibilityRole:L?"radio":"multiple"===i?"checkbox":"button",accessibilityLabel:Y,accessibilityState:L||"multiple"===i?{checked:o,disabled:u}:{selected:o,disabled:u},"aria-checked":L||"multiple"===i?o:void 0,"aria-selected":L||"multiple"===i?void 0:o,"aria-disabled":u,hitSlop:R,...R?hitSlopMarker(R):{},android_ripple:{color:w.colors["surface-pressed"],borderless:!1},testID:v,style:({pressed:e})=>[styles.base,q,e&&"outline"===d?{backgroundColor:w.colors["surface-pressed"]}:null,x,g],children:W})}):_jsx(View,{ref:s,style:[styles.base,q,x,g],accessible:!0,accessibilityRole:"text",accessibilityLabel:Y,accessibilityState:{selected:o,disabled:u},"aria-selected":o,"aria-disabled":u,testID:v,children:W}),h?_jsx(ChipSkeleton,{...e}):G});Chip.displayName="Chip";const ChipSkeleton=({label:e,count:s,size:r="md",leftIcon:t,onRemove:o,style:i,containerStyle:l})=>{const a=useTheme(),n=resolveChipSize(a,r),c=Math.max(40,Math.min(120,7*(e??"").length)),d=n["min-height"],p=d/2,m=c+2*n["padding-x"]+(hasChipCount(s)?n.gap/2+7*String(s).length:0)+(void 0!==t?n.gap+14:0)+(void 0!==o?n.gap+n["close-size"]:0);return _jsx(Skeleton,{width:m,height:d,radius:p,style:[{alignSelf:"flex-start"},l,i]})};ChipSkeleton.displayName="ChipSkeleton",Chip.Skeleton=ChipSkeleton;const styles=StyleSheet.create({base:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",justifyContent:"center"},row:{flexDirection:"row",alignItems:"center"},label:{flexShrink:1,textAlign:"center"},count:{flexShrink:0,fontVariant:["tabular-nums"]},close:{alignItems:"center",justifyContent:"center"}});export{Chip};export default Chip;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useMemo}from"react";import{Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{RadioDot}from"../Radio/RadioDot.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const sizeTokensOf=e=>({sm:{paddingHorizontal:e.space.sm,chipPaddingHorizontal:e.space.md,paddingVertical:e.space.xs,fontSize:e.text.sm.size,minHeight:32,iconSize:14},md:{paddingHorizontal:e.space.md,chipPaddingHorizontal:e.space.lg,paddingVertical:e.space.sm,fontSize:e.text.base.size,minHeight:40,iconSize:16},lg:{paddingHorizontal:e.space.lg,chipPaddingHorizontal:e.space.xl,paddingVertical:e.space.md,fontSize:e.text.lg.size,minHeight:48,iconSize:18}}),ChoiceGroup=forwardRef((e,i)=>{const{options:o,getOptionLabel:t,getOptionValue:r,isOptionDisabled:l,getOptionDescription:s,getOptionIcon:a,getOptionColor:n,renderOption:d,variant:c="card",indicatorPosition:p="trailing",direction:u="row",gap:m,wrap:h=!1,fullWidth:g,disabled:b=!1,size:x="md",labelLines:f,descriptionLines:y=2,haptic:z,accessibilityLabel:C,style:j,optionStyle:S,description:v,helperText:w,error:H,testID:V}=e,T=useTheme(),_=useMemo(()=>buildStyles(T),[T]),k=useMemo(()=>sizeTokensOf(T)[x],[T,x]);warnInvalidValue("ChoiceGroup","variant",e.variant,["card","chip"]),warnInvalidValue("ChoiceGroup","size",e.size,["sm","md","lg"]),warnInvalidValue("ChoiceGroup","direction",e.direction,["row","column"]),warnInvalidValue("ChoiceGroup","indicatorPosition",e.indicatorPosition,["leading","trailing"]),warnInvalidValue("ChoiceGroup","selectionMode",e.selectionMode,["single","multiple"]);const I=useCallback(e=>t?t(e):e.label??"",[t]),D=useCallback(e=>r?r(e):e.value,[r]),O=useCallback(e=>l?l(e):!0===e.disabled,[l]),G=useCallback(e=>s?s(e):e.description,[s]),L=useCallback(e=>a?a(e):e.icon,[a]),M=useCallback(e=>n?n(e):e.color,[n]),P="multiple"===e.selectionMode,{min:R,max:F}=e,[W,A]=useControllableState({value:e.value,defaultValue:e.defaultValue??(P?[]:void 0),onChange:e.onChange}),B=Array.isArray(W)?W:[],E=useCallback(e=>{const i=D(e);if(P){const e=B.includes(i);if(e&&null!=R&&B.length<=R)return;if(!e&&null!=F&&B.length>=F)return;const o=resolveHaptic(z,"selection");return o&&triggerHaptic(o),void A(e?B.filter(e=>e!==i):[...B,i])}const o=resolveHaptic(z,"selection");o&&triggerHaptic(o),A(i)},[z,P,R,F,B,A,D]),$=g??("card"===c&&"row"===u&&!h),N=h||$&&"row"===u,q=T.radius.md,surfaceFor=(e,i,o)=>i?{borderColor:T.colors.border,backgroundColor:T.colors["surface-disabled"]}:{borderColor:e?o:T.colors.border,backgroundColor:e?tintOf(o,.12,T.colors["surface-selected"]):T.colors.bg},renderIcon=(e,i,o,t)=>{const r=L(e);if(null==r)return null;return renderSlotIcon("string"==typeof r&&i?{name:r,variant:"bold"}:r,{color:o,size:k.iconSize,disabled:t})},renderChip=e=>{const{option:i,selected:o,disabled:t,color:r}=e,l=t?T.colors["text-disabled"]:o?r:T.colors["text-body"],s=renderIcon(i,o,l,t);return _jsxs(View,{style:[_.chip,{minHeight:k.minHeight,paddingHorizontal:k.chipPaddingHorizontal,paddingVertical:k.paddingVertical,borderRadius:T.radius.pill,...smoothCorners,borderWidth:T.size.border,...surfaceFor(o,t,r),columnGap:T.space.xs}],children:[s?_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:s}):null,_jsx(Text,{weight:"medium",numberOfLines:f,ellipsizeMode:"tail",style:[_.cardLabel,{color:l,fontSize:k.fontSize,lineHeight:Math.round(k.fontSize*T.leading.body)}],children:I(i)})]})},renderDefaultCard=e=>{const{option:i,selected:o,disabled:t,color:r}=e,l=M(i),s=t?T.colors["text-disabled"]:l??T.colors["text-body"],a=G(i),n=renderIcon(i,o,s,t),d=_jsx(RadioDot,{selected:o,color:r,disabled:t,size:x});return _jsxs(View,{style:[_.card,{minHeight:k.minHeight,paddingHorizontal:k.paddingHorizontal,paddingVertical:k.paddingVertical,borderRadius:q,...smoothCorners,borderWidth:T.size.border,...surfaceFor(o,t,r),columnGap:T.space.sm}],children:["leading"===p?d:null,n?_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:n}):null,_jsxs(View,{style:_.cardTextWrap,children:[_jsx(Text,{weight:"medium",numberOfLines:f,ellipsizeMode:"tail",style:[_.cardLabel,{color:s,fontSize:k.fontSize,lineHeight:Math.round(k.fontSize*T.leading.body)}],children:I(i)}),a?_jsx(Text,{numberOfLines:y,ellipsizeMode:"tail",style:[_.cardDescription,{color:o?T.colors["text-muted"]:T.colors["text-subtle"],fontSize:T.text.xs.size,lineHeight:Math.round(T.text.xs.size*T.leading.body)}],children:a}):null]}),"trailing"===p?d:null]})},J="string"==typeof H&&""!==H?H:void 0,K=!0===H||void 0!==J?null:w,Q=_jsx(View,{ref:i,accessibilityRole:P?void 0:"radiogroup",accessibilityLabel:C,accessibilityState:{disabled:b},"aria-disabled":b,testID:V,style:[{flexDirection:u,gap:m??T.space.sm,flexWrap:N?"wrap":"nowrap"},j],children:o.map((e,i)=>{const o=D(e),t=P?B.includes(o):W===o,r=P&&null!=F&&!t&&B.length>=F,l=b||r||O(e),s=M(e)??T.colors.primary,a=d||"card"!==c?void 0:G(e);return _jsx(Pressable,{testID:e.testID,onPress:()=>{l||E(e)},disabled:l,accessibilityRole:P?"checkbox":"radio",accessibilityLabel:a?`${I(e)}, ${a}`:I(e),accessibilityState:{checked:t,disabled:l},"aria-checked":t,"aria-disabled":l,style:[$?_.stretchOption:null,{opacity:l&&d?.55:1},S],children:({pressed:o})=>{const r={option:e,index:i,selected:t,pressed:o&&!l,disabled:l,color:s};return _jsx(_Fragment,{children:d?d(r):"chip"===c?renderChip(r):renderDefaultCard(r)})}},String(o))})});return hasChoiceDetail({description:v,error:J,helperText:K??void 0})?_jsxs(View,{children:[v?_jsx(Text,{variant:"bodySmall",color:"secondary",style:{marginBottom:T.space.xs},children:v}):null,Q,void 0!==J?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",style:{marginTop:T.space.xs},children:J}):K?_jsx(Text,{variant:"caption",color:"tertiary",style:{marginTop:T.space.xs},children:K}):null]}):Q});ChoiceGroup.displayName="ChoiceGroup";const buildStyles=e=>StyleSheet.create({stretchOption:{flexGrow:1,flexShrink:0,flexBasis:"auto"},card:{flexDirection:"row",alignItems:"center"},chip:{flexDirection:"row",alignItems:"center",justifyContent:"center"},cardTextWrap:{flexGrow:1,flexShrink:1,flexBasis:"auto"},cardLabel:{includeFontPadding:!1},cardDescription:{includeFontPadding:!1,marginTop:e.space.xxs}});export{ChoiceGroup};export default ChoiceGroup;
1
+ "use strict";import{forwardRef,useCallback,useMemo}from"react";import{Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{RadioDot}from"../Radio/RadioDot.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const sizeTokensOf=e=>({sm:{paddingHorizontal:e.space.sm,chipPaddingHorizontal:e.space.md,paddingVertical:e.space.xs,fontSize:e.text.sm.size,minHeight:32,iconSize:14},md:{paddingHorizontal:e.space.md,chipPaddingHorizontal:e.space.lg,paddingVertical:e.space.sm,fontSize:e.text.base.size,minHeight:40,iconSize:16},lg:{paddingHorizontal:e.space.lg,chipPaddingHorizontal:e.space.xl,paddingVertical:e.space.md,fontSize:e.text.lg.size,minHeight:48,iconSize:18}}),ChoiceGroup=forwardRef((e,i)=>{const{options:o,getOptionLabel:t,getOptionValue:r,isOptionDisabled:s,getOptionDescription:l,getOptionIcon:a,getOptionColor:n,renderOption:d,variant:c="card",indicatorPosition:p="trailing",direction:u="row",gap:m,wrap:h=!1,fullWidth:g,disabled:b=!1,size:x="md",labelLines:f,descriptionLines:y=2,haptic:z,accessibilityLabel:C,style:j,optionStyle:V,description:S,helperText:H,error:v,testID:w}=e,T=useTheme(),_=useMemo(()=>buildStyles(T),[T]),k=useMemo(()=>sizeTokensOf(T)[x],[T,x]);assertValidValue("ChoiceGroup","variant",e.variant,["card","chip"]),assertValidValue("ChoiceGroup","size",e.size,["sm","md","lg"]),assertValidValue("ChoiceGroup","direction",e.direction,["row","column"]),assertValidValue("ChoiceGroup","indicatorPosition",e.indicatorPosition,["leading","trailing"]),assertValidValue("ChoiceGroup","selectionMode",e.selectionMode,["single","multiple"]);const D=useCallback(e=>t?t(e):e.label??"",[t]),O=useCallback(e=>r?r(e):e.value,[r]),G=useCallback(e=>s?s(e):!0===e.disabled,[s]),L=useCallback(e=>l?l(e):e.description,[l]),M=useCallback(e=>a?a(e):e.icon,[a]),P=useCallback(e=>n?n(e):e.color,[n]),I="multiple"===e.selectionMode,{min:R,max:F}=e,[W,A]=useControllableState({value:e.value,defaultValue:e.defaultValue??(I?[]:void 0),onChange:e.onChange}),B=Array.isArray(W)?W:[],E=useCallback(e=>{const i=O(e);if(I){const e=B.includes(i);if(e&&null!=R&&B.length<=R)return;if(!e&&null!=F&&B.length>=F)return;const o=resolveHaptic(z,"selection");return o&&triggerHaptic(o),void A(e?B.filter(e=>e!==i):[...B,i])}const o=resolveHaptic(z,"selection");o&&triggerHaptic(o),A(i)},[z,I,R,F,B,A,O]),$=g??("card"===c&&"row"===u&&!h),N=h||$&&"row"===u,q=T.radius.md,surfaceFor=(e,i,o)=>i?{borderColor:T.colors.border,backgroundColor:T.colors["surface-disabled"]}:{borderColor:e?o:T.colors.border,backgroundColor:e?tintOf(o,.12,T.colors["surface-selected"]):T.colors.bg},renderIcon=(e,i,o,t)=>{const r=M(e);if(null==r)return null;return renderSlotIcon("string"==typeof r&&i?{name:r,variant:"bold"}:r,{color:o,size:k.iconSize,disabled:t})},renderChip=e=>{const{option:i,selected:o,disabled:t,color:r}=e,s=t?T.colors["text-disabled"]:o?r:T.colors["text-body"],l=renderIcon(i,o,s,t);return _jsxs(View,{style:[_.chip,{minHeight:k.minHeight,paddingHorizontal:k.chipPaddingHorizontal,paddingVertical:k.paddingVertical,borderRadius:T.radius.pill,...smoothCorners,borderWidth:T.size.border,...surfaceFor(o,t,r),columnGap:T.space.xs}],children:[l?_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:l}):null,_jsx(Text,{weight:"medium",numberOfLines:f,ellipsizeMode:"tail",style:[_.cardLabel,{color:s,fontSize:k.fontSize,lineHeight:Math.round(k.fontSize*T.leading.body)}],children:D(i)})]})},renderDefaultCard=e=>{const{option:i,selected:o,disabled:t,color:r}=e,s=P(i),l=t?T.colors["text-disabled"]:s??T.colors["text-body"],a=L(i),n=renderIcon(i,o,l,t),d=_jsx(RadioDot,{selected:o,color:r,disabled:t,size:x});return _jsxs(View,{style:[_.card,{minHeight:k.minHeight,paddingHorizontal:k.paddingHorizontal,paddingVertical:k.paddingVertical,borderRadius:q,...smoothCorners,borderWidth:T.size.border,...surfaceFor(o,t,r),columnGap:T.space.sm}],children:["leading"===p?d:null,n?_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:n}):null,_jsxs(View,{style:_.cardTextWrap,children:[_jsx(Text,{weight:"medium",numberOfLines:f,ellipsizeMode:"tail",style:[_.cardLabel,{color:l,fontSize:k.fontSize,lineHeight:Math.round(k.fontSize*T.leading.body)}],children:D(i)}),a?_jsx(Text,{numberOfLines:y,ellipsizeMode:"tail",style:[_.cardDescription,{color:o?T.colors["text-muted"]:T.colors["text-subtle"],fontSize:T.text.xs.size,lineHeight:Math.round(T.text.xs.size*T.leading.body)}],children:a}):null]}),"trailing"===p?d:null]})},J="string"==typeof v&&""!==v?v:void 0,K=!0===v||void 0!==J?null:H,Q=_jsx(View,{ref:i,accessibilityRole:I?void 0:"radiogroup",accessibilityLabel:C,accessibilityState:{disabled:b},"aria-disabled":b,testID:w,style:[{flexDirection:u,gap:m??T.space.sm,flexWrap:N?"wrap":"nowrap"},j],children:o.map((e,i)=>{const o=O(e),t=I?B.includes(o):W===o,r=I&&null!=F&&!t&&B.length>=F,s=b||r||G(e),l=P(e)??T.colors.primary,a=d||"card"!==c?void 0:L(e);return _jsx(Pressable,{testID:e.testID,onPress:()=>{s||E(e)},disabled:s,accessibilityRole:I?"checkbox":"radio",accessibilityLabel:a?`${D(e)}, ${a}`:D(e),accessibilityState:{checked:t,disabled:s},"aria-checked":t,"aria-disabled":s,style:[$?_.stretchOption:null,{opacity:s&&d?.55:1},V],children:({pressed:o})=>{const r={option:e,index:i,selected:t,pressed:o&&!s,disabled:s,color:l};return _jsx(_Fragment,{children:d?d(r):"chip"===c?renderChip(r):renderDefaultCard(r)})}},String(o))})});return hasChoiceDetail({description:S,error:J,helperText:K??void 0})?_jsxs(View,{children:[S?_jsx(Text,{variant:"bodySmall",color:"secondary",style:{marginBottom:T.space.xs},children:S}):null,Q,void 0!==J?_jsx(Text,{variant:"caption",color:"danger",accessibilityLiveRegion:"polite",style:{marginTop:T.space.xs},children:J}):K?_jsx(Text,{variant:"caption",color:"tertiary",style:{marginTop:T.space.xs},children:K}):null]}):Q});ChoiceGroup.displayName="ChoiceGroup";const buildStyles=e=>StyleSheet.create({stretchOption:{flexGrow:1,flexShrink:0,flexBasis:"auto"},card:{flexDirection:"row",alignItems:"center"},chip:{flexDirection:"row",alignItems:"center",justifyContent:"center"},cardTextWrap:{flexGrow:1,flexShrink:1,flexBasis:"auto"},cardLabel:{includeFontPadding:!1},cardDescription:{includeFontPadding:!1,marginTop:e.space.xxs}});export{ChoiceGroup};export default ChoiceGroup;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useState}from"react";import{StyleSheet,useWindowDimensions,View}from"react-native";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withRepeat,withTiming}from"react-native-reanimated";import Svg,{Path,Polygon}from"react-native-svg";import{useReducedMotion}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{jsx as _jsx}from"react/jsx-runtime";const TAU=2*Math.PI,DEG=Math.PI/180,SPEED_FACTOR={slow:1.6,normal:1,fast:.6};export const DEFAULT_PHYSICS={velocity:1,drag:1,fallSpeed:1,spread:0};const PRESET_SHAPES={pop:["strip","strip","strip","square","circle","triangle","star","streamer"],rain:["strip","strip","strip","circle","square"],fireworks:["circle","circle","star","star","triangle","strip"]},rand=(e,a)=>e+Math.random()*(a-e),pick=e=>e[Math.floor(Math.random()*e.length)]??e[0],commonPiece=(e,a)=>({color:e.colors[a%e.colors.length]??e.colors[0],size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:Math.random()<.5?1:-1,flutterFreq:rand(2,5)}),popPiece=(e,a)=>{const r=e.physics.spread>0?e.physics.spread/2:100,t=(-90+rand(-r,r))*DEG,s=rand(1.8,4.2)*e.physics.velocity;return{...commonPiece(e,a),x0Frac:e.originXFrac,y0Frac:e.originYFrac,vxFrac:Math.cos(t)*s*.7,vyFrac:Math.sin(t)*s,drag:rand(5.5,7.5)*e.physics.drag,terminalFrac:rand(.22,.44)*e.physics.fallSpeed,delay:rand(0,.05),swayAmp:rand(4,16),swayFreq:rand(1,3)}},rainPiece=(e,a)=>({...commonPiece(e,a),x0Frac:Math.random(),y0Frac:-.05,vxFrac:rand(-.12,.12)*e.physics.velocity,vyFrac:rand(.05,.25)*e.physics.velocity,drag:rand(2.5,4)*e.physics.drag,terminalFrac:rand(.95,1.35)*e.physics.fallSpeed,delay:rand(0,.35),swayAmp:rand(10,30),swayFreq:rand(1,3)}),FIREWORK_BURSTS=4,buildFireworks=(e,a)=>{const r=Math.max(1,Math.round(e/4)),t=a.physics.spread>0?a.physics.spread/2:180,s=[];for(let i=0;i<4&&s.length<e;i+=1){const n=rand(.18,.82),o=rand(.18,.52),c=i/4*.5+rand(0,.06);for(let i=0;i<r&&s.length<e;i+=1){const e=rand(-t,t)*DEG,r=rand(1.4,3.4)*a.physics.velocity;s.push({...commonPiece(a,s.length),x0Frac:n,y0Frac:o,vxFrac:Math.cos(e)*r*.7,vyFrac:Math.sin(e)*r,drag:rand(6.5,8.5)*a.physics.drag,terminalFrac:rand(.18,.38)*a.physics.fallSpeed,delay:c,swayAmp:rand(3,12),swayFreq:rand(1,3)})}}return s};export const buildPieces=(e,a,r)=>{if("fireworks"===a)return buildFireworks(e,r);const t="rain"===a?rainPiece:popPiece;return Array.from({length:e},(e,a)=>t(r,a))};const SHAPE_BOX={strip:{w:1,h:.45},square:{w:1,h:1},circle:{w:1,h:1},triangle:{w:1,h:1},star:{w:1.2,h:1.2},streamer:{w:3,h:1.2}},TRIANGLE_POINTS="50,4 96,96 4,96",STAR_POINTS="50,2 61,36 97,36 68,58 79,94 50,72 21,94 32,58 3,36 39,36",STREAMER_PATH="M2,50 C20,6 44,94 62,50 S92,6 98,50",ShapeBody=({shape:e,color:a})=>"triangle"===e||"star"===e?_jsx(Svg,{width:"100%",height:"100%",viewBox:"0 0 100 100",children:_jsx(Polygon,{points:"star"===e?STAR_POINTS:TRIANGLE_POINTS,fill:a})}):"streamer"===e?_jsx(Svg,{width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:_jsx(Path,{d:STREAMER_PATH,stroke:a,strokeWidth:22,strokeLinecap:"round",fill:"none"})}):null,ConfettiPiece=({piece:e,progress:a,width:r,height:t,fadeOut:s})=>{const i=useAnimatedStyle(()=>{const i=1-e.delay,n=i<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/i)),o=(1-Math.exp(-e.drag*n))/e.drag,c=e.x0Frac*r+e.vxFrac*r*o,l=e.y0Frac*t+e.terminalFrac*t*n+(e.vyFrac-e.terminalFrac)*t*o,h=Math.sin(n*e.swayFreq*TAU)*e.swayAmp,d=e.rotateDir*e.rotations*360*n,p=.35+.65*Math.abs(Math.cos(n*e.flutterFreq*TAU));return{opacity:s?Math.max(0,1-Math.max(0,n-.75)/.25):1,transform:[{translateX:c+h},{translateY:l},{rotate:`${d}deg`},{scaleY:p}]}},[e,a,r,t,s]),n=SHAPE_BOX[e.shape],o="triangle"===e.shape||"star"===e.shape||"streamer"===e.shape;return _jsx(Animated.View,{style:[{position:"absolute",width:e.size*n.w,height:e.size*n.h,borderRadius:"circle"===e.shape?e.size*n.h/2:1,backgroundColor:o?"transparent":e.color},i],children:_jsx(ShapeBody,{shape:e.shape,color:e.color})})},Confetti=forwardRef(({count:e=80,colors:a,preset:r="pop",shapes:t,speed:s="normal",physics:i,origin:n,duration:o=2800,fadeOut:c=!0,autoStart:l=!1,recycle:h=!1,size:d=10,onComplete:p,style:u,testID:m},y)=>{warnInvalidValue("Confetti","preset",r,["pop","rain","fireworks"]),warnInvalidValue("Confetti","speed",s,["slow","normal","fast"]);for(const e of t??[])warnInvalidValue("Confetti","shapes",e,["strip","square","circle","triangle","star","streamer"]);const g=useTheme(),w=useReducedMotion(),f=useWindowDimensions(),[S,F]=useState({width:f.width,height:f.height}),[v,x]=useState(!1),[P,A]=useState([]),E=useMemo(()=>a??[g.colors.primary,g.colors.neutral,g.colors.success,g.colors.warning,g.colors.danger,g.colors.info],[a,g.colors]),M=useSharedValue(0),T=o*SPEED_FACTOR[s],_=useCallback(()=>{x(!1),p?.()},[p]),R=useCallback(()=>{if(w)return void p?.();cancelAnimation(M),M.value=0,A(buildPieces(e,r,{colors:E,baseSize:d,originXFrac:n?n.x/Math.max(1,S.width):.5,originYFrac:n?n.y/Math.max(1,S.height):.5,physics:{...DEFAULT_PHYSICS,...i},shapes:t??PRESET_SHAPES[r]})),x(!0);const a=withTiming(1,{duration:T,easing:Easing.linear},e=>{"worklet";e&&!h&&runOnJS(_)()});M.value=h?withRepeat(a,-1,!1):a},[w,M,T,h,_,p,e,E,r,t,i,d,n,S.width,S.height]),C=useCallback(()=>{cancelAnimation(M),x(!1)},[M]);useImperativeHandle(y,()=>({start:R,stop:C}),[R,C]),useEffect(()=>(l&&R(),()=>cancelAnimation(M)),[]);const I=useCallback(e=>{const{width:a,height:r}=e.nativeEvent.layout;a>0&&r>0&&F({width:a,height:r})},[]);return _jsx(View,{style:[StyleSheet.absoluteFill,u],pointerEvents:"none",onLayout:I,testID:m,children:v?P.map((e,a)=>_jsx(ConfettiPiece,{piece:e,progress:M,width:S.width,height:S.height,fadeOut:c},a)):null})});Confetti.displayName="Confetti";export{Confetti};export default Confetti;
1
+ "use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useState}from"react";import{StyleSheet,useWindowDimensions,View}from"react-native";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withRepeat,withTiming}from"react-native-reanimated";import Svg,{Path,Polygon}from"react-native-svg";import{useReducedMotion}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{jsx as _jsx}from"react/jsx-runtime";const TAU=2*Math.PI,DEG=Math.PI/180,SPEED_FACTOR={slow:1.6,normal:1,fast:.6};export const DEFAULT_PHYSICS={velocity:1,drag:1,fallSpeed:1,spread:0};const PRESET_SHAPES={pop:["strip","strip","strip","square","circle","triangle","star","streamer"],rain:["strip","strip","strip","circle","square"],fireworks:["circle","circle","star","star","triangle","strip"]},rand=(e,a)=>e+Math.random()*(a-e),pick=e=>e[Math.floor(Math.random()*e.length)]??e[0],commonPiece=(e,a)=>({color:e.colors[a%e.colors.length]??e.colors[0],size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:Math.random()<.5?1:-1,flutterFreq:rand(2,5)}),popPiece=(e,a)=>{const r=e.physics.spread>0?e.physics.spread/2:100,t=(-90+rand(-r,r))*DEG,s=rand(1.8,4.2)*e.physics.velocity;return{...commonPiece(e,a),x0Frac:e.originXFrac,y0Frac:e.originYFrac,vxFrac:Math.cos(t)*s*.7,vyFrac:Math.sin(t)*s,drag:rand(5.5,7.5)*e.physics.drag,terminalFrac:rand(.22,.44)*e.physics.fallSpeed,delay:rand(0,.05),swayAmp:rand(4,16),swayFreq:rand(1,3)}},rainPiece=(e,a)=>({...commonPiece(e,a),x0Frac:Math.random(),y0Frac:-.05,vxFrac:rand(-.12,.12)*e.physics.velocity,vyFrac:rand(.05,.25)*e.physics.velocity,drag:rand(2.5,4)*e.physics.drag,terminalFrac:rand(.95,1.35)*e.physics.fallSpeed,delay:rand(0,.35),swayAmp:rand(10,30),swayFreq:rand(1,3)}),FIREWORK_BURSTS=4,buildFireworks=(e,a)=>{const r=Math.max(1,Math.round(e/4)),t=a.physics.spread>0?a.physics.spread/2:180,s=[];for(let i=0;i<4&&s.length<e;i+=1){const o=rand(.18,.82),n=rand(.18,.52),c=i/4*.5+rand(0,.06);for(let i=0;i<r&&s.length<e;i+=1){const e=rand(-t,t)*DEG,r=rand(1.4,3.4)*a.physics.velocity;s.push({...commonPiece(a,s.length),x0Frac:o,y0Frac:n,vxFrac:Math.cos(e)*r*.7,vyFrac:Math.sin(e)*r,drag:rand(6.5,8.5)*a.physics.drag,terminalFrac:rand(.18,.38)*a.physics.fallSpeed,delay:c,swayAmp:rand(3,12),swayFreq:rand(1,3)})}}return s};export const buildPieces=(e,a,r)=>{if("fireworks"===a)return buildFireworks(e,r);const t="rain"===a?rainPiece:popPiece;return Array.from({length:e},(e,a)=>t(r,a))};const SHAPE_BOX={strip:{w:1,h:.45},square:{w:1,h:1},circle:{w:1,h:1},triangle:{w:1,h:1},star:{w:1.2,h:1.2},streamer:{w:3,h:1.2}},TRIANGLE_POINTS="50,4 96,96 4,96",STAR_POINTS="50,2 61,36 97,36 68,58 79,94 50,72 21,94 32,58 3,36 39,36",STREAMER_PATH="M2,50 C20,6 44,94 62,50 S92,6 98,50",ShapeBody=({shape:e,color:a})=>"triangle"===e||"star"===e?_jsx(Svg,{width:"100%",height:"100%",viewBox:"0 0 100 100",children:_jsx(Polygon,{points:"star"===e?STAR_POINTS:TRIANGLE_POINTS,fill:a})}):"streamer"===e?_jsx(Svg,{width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:_jsx(Path,{d:STREAMER_PATH,stroke:a,strokeWidth:22,strokeLinecap:"round",fill:"none"})}):null,ConfettiPiece=({piece:e,progress:a,width:r,height:t,fadeOut:s})=>{const i=useAnimatedStyle(()=>{const i=1-e.delay,o=i<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/i)),n=(1-Math.exp(-e.drag*o))/e.drag,c=e.x0Frac*r+e.vxFrac*r*n,l=e.y0Frac*t+e.terminalFrac*t*o+(e.vyFrac-e.terminalFrac)*t*n,h=Math.sin(o*e.swayFreq*TAU)*e.swayAmp,d=e.rotateDir*e.rotations*360*o,p=.35+.65*Math.abs(Math.cos(o*e.flutterFreq*TAU));return{opacity:s?Math.max(0,1-Math.max(0,o-.75)/.25):1,transform:[{translateX:c+h},{translateY:l},{rotate:`${d}deg`},{scaleY:p}]}},[e,a,r,t,s]),o=SHAPE_BOX[e.shape],n="triangle"===e.shape||"star"===e.shape||"streamer"===e.shape;return _jsx(Animated.View,{style:[{position:"absolute",width:e.size*o.w,height:e.size*o.h,borderRadius:"circle"===e.shape?e.size*o.h/2:1,backgroundColor:n?"transparent":e.color},i],children:_jsx(ShapeBody,{shape:e.shape,color:e.color})})},Confetti=forwardRef(({count:e=80,colors:a,preset:r="pop",shapes:t,speed:s="normal",physics:i,origin:o,duration:n=2800,fadeOut:c=!0,autoStart:l=!1,recycle:h=!1,size:d=10,onComplete:p,style:u,testID:m},y)=>{assertValidValue("Confetti","preset",r,["pop","rain","fireworks"]),assertValidValue("Confetti","speed",s,["slow","normal","fast"]);for(const e of t??[])assertValidValue("Confetti","shapes",e,["strip","square","circle","triangle","star","streamer"]);const g=useTheme(),f=useReducedMotion(),S=useWindowDimensions(),[w,F]=useState({width:S.width,height:S.height}),[x,P]=useState(!1),[A,v]=useState([]),E=useMemo(()=>a??[g.colors.primary,g.colors.neutral,g.colors.success,g.colors.warning,g.colors.danger,g.colors.info],[a,g.colors]),M=useSharedValue(0),T=n*SPEED_FACTOR[s],_=useCallback(()=>{P(!1),p?.()},[p]),R=useCallback(()=>{if(f)return void p?.();cancelAnimation(M),M.value=0,v(buildPieces(e,r,{colors:E,baseSize:d,originXFrac:o?o.x/Math.max(1,w.width):.5,originYFrac:o?o.y/Math.max(1,w.height):.5,physics:{...DEFAULT_PHYSICS,...i},shapes:t??PRESET_SHAPES[r]})),P(!0);const a=withTiming(1,{duration:T,easing:Easing.linear},e=>{"worklet";e&&!h&&runOnJS(_)()});M.value=h?withRepeat(a,-1,!1):a},[f,M,T,h,_,p,e,E,r,t,i,d,o,w.width,w.height]),C=useCallback(()=>{cancelAnimation(M),P(!1)},[M]);useImperativeHandle(y,()=>({start:R,stop:C}),[R,C]),useEffect(()=>(l&&R(),()=>cancelAnimation(M)),[]);const k=useCallback(e=>{const{width:a,height:r}=e.nativeEvent.layout;a>0&&r>0&&F({width:a,height:r})},[]);return _jsx(View,{style:[StyleSheet.absoluteFill,u],pointerEvents:"none",onLayout:k,testID:m,children:x?A.map((e,a)=>_jsx(ConfettiPiece,{piece:e,progress:M,width:w.width,height:w.height,fadeOut:c},a)):null})});Confetti.displayName="Confetti";export{Confetti};export default Confetti;
@@ -1 +1 @@
1
- "use strict";import{isValidElement,useMemo}from"react";import{StyleSheet,Text,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{resolveColor}from"../Text/Text.js";import{TextInkContext}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const EMPTY_VALUE="-",rowKey=(e,t)=>e.key??("string"==typeof e.label?`${e.label}-${t}`:`row-${t}`),isEmptyValue=e=>null==e||""===e||Array.isArray(e)&&!e.length,isInlineText=e=>"string"==typeof e||"number"==typeof e||isValidElement(e)&&!0===e.type.inlineText||Array.isArray(e)&&e.length>0&&e.every(isInlineText);export const Descriptions=({items:e,columns:t=1,size:l="md",bordered:r=!1,title:s,variant:o="list",style:i,testID:n})=>{warnInvalidValue("Descriptions","size",l,["sm","md"]),warnInvalidValue("Descriptions","variant",o,["list","summary"]),warnInvalidValue("Descriptions","columns",t,[1,2]);const a=useTheme(),m=useMemo(()=>buildStyles(a),[a]),x="sm"===l?a.text.xs.size:a.text.sm.size,u="sm"===l?a.text.sm.size:a.text.base.size,d="sm"===l?a.space.xs:a.space.sm,c="summary"===o,y=useMemo(()=>({fontSize:x,color:a.colors["text-subtle"]}),[x,a.colors["text-subtle"]]),b=useMemo(()=>({fontSize:u,color:a.colors["text-muted"]}),[u,a.colors["text-muted"]]);return _jsxs(View,{style:[c?null:{gap:d},i],testID:n,children:[s?_jsx(Text,{style:[m.title,{fontSize:a.text.lg.size,color:a.colors["text-body"]}],children:s}):null,e.map((e,l)=>{const s=isEmptyValue(e.value),o=2===t&&!e.full,i=s?a.colors["text-subtle"]:resolveColor(a,e.tone??"primary"),n=fontFor(a,e.strong?"semibold":"normal"),f=s||isInlineText(e.value),p=s?"-":"string"==typeof e.value?e.value:_jsx(TextInkContext.Provider,{value:{fontSize:u,color:i},children:e.value});return _jsxs(View,c?{testID:e.testID,style:[m.summaryRow,{paddingVertical:d,borderBottomColor:a.colors["border-subtle"]}],children:[_jsx(Text,{style:[m.summaryLabel,{fontSize:u,color:a.colors["text-muted"]}],children:_jsx(TextInkContext.Provider,{value:b,children:e.label})}),f?_jsx(Text,{style:[m.summaryValue,{fontSize:u,color:i},n],children:p}):_jsx(View,{style:m.summaryValueView,children:e.value})]}:{testID:e.testID,style:[o?m.rowSide:m.rowStack,{paddingVertical:d},r&&l>0?m.bordered:null,r&&l>0?{borderTopColor:a.colors["border-subtle"]}:null],children:["string"==typeof e.label?_jsx(Text,{style:[m.label,{fontSize:x,color:a.colors["text-subtle"]},o?m.labelSide:null],children:e.label}):_jsx(View,{style:o?m.labelSide:null,children:_jsx(Text,{style:[m.label,{fontSize:x,color:a.colors["text-subtle"]}],children:_jsx(TextInkContext.Provider,{value:y,children:e.label})})}),f?_jsx(Text,{style:[m.value,{fontSize:u,color:i},e.strong?n:null,o?m.valueSide:null],children:p}):_jsx(View,{style:o?m.valueSide:null,children:e.value})]},rowKey(e,l))})]})};const buildStyles=e=>StyleSheet.create({title:{...fontFor(e,"semibold")},rowStack:{gap:e.space.xxs},rowSide:{flexDirection:"row",alignItems:"flex-start",gap:e.space.md},bordered:{borderTopWidth:StyleSheet.hairlineWidth},label:{...fontFor(e,"semibold")},labelSide:{flex:4},value:{...fontFor(e,"normal")},valueSide:{flex:6},summaryRow:{flexDirection:"row",alignItems:"center",gap:e.space.md,borderBottomWidth:StyleSheet.hairlineWidth},summaryLabel:{flex:1,...fontFor(e,"normal")},summaryValue:{textAlign:"right",flexShrink:1,maxWidth:"60%"},summaryValueView:{flexShrink:1,maxWidth:"60%",alignItems:"flex-end"}});export default Descriptions;
1
+ "use strict";import{isValidElement,useMemo}from"react";import{StyleSheet,Text,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{resolveColor}from"../Text/Text.js";import{TextInkContext}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const EMPTY_VALUE="-",rowKey=(e,t)=>e.key??("string"==typeof e.label?`${e.label}-${t}`:`row-${t}`),isEmptyValue=e=>null==e||""===e||Array.isArray(e)&&!e.length,isInlineText=e=>"string"==typeof e||"number"==typeof e||isValidElement(e)&&!0===e.type.inlineText||Array.isArray(e)&&e.length>0&&e.every(isInlineText);export const Descriptions=({items:e,columns:t=1,size:l="md",bordered:s=!1,title:r,variant:o="list",style:i,testID:a})=>{assertValidValue("Descriptions","size",l,["sm","md"]),assertValidValue("Descriptions","variant",o,["list","summary"]),assertValidValue("Descriptions","columns",t,[1,2]);const n=useTheme(),m=useMemo(()=>buildStyles(n),[n]),x="sm"===l?n.text.xs.size:n.text.sm.size,u="sm"===l?n.text.sm.size:n.text.base.size,d="sm"===l?n.space.xs:n.space.sm,c="summary"===o,y=useMemo(()=>({fontSize:x,color:n.colors["text-subtle"]}),[x,n.colors["text-subtle"]]),b=useMemo(()=>({fontSize:u,color:n.colors["text-muted"]}),[u,n.colors["text-muted"]]);return _jsxs(View,{style:[c?null:{gap:d},i],testID:a,children:[r?_jsx(Text,{style:[m.title,{fontSize:n.text.lg.size,color:n.colors["text-body"]}],children:r}):null,e.map((e,l)=>{const r=isEmptyValue(e.value),o=2===t&&!e.full,i=r?n.colors["text-subtle"]:resolveColor(n,e.tone??"primary"),a=fontFor(n,e.strong?"semibold":"normal"),f=r||isInlineText(e.value),p=r?"-":"string"==typeof e.value?e.value:_jsx(TextInkContext.Provider,{value:{fontSize:u,color:i},children:e.value});return _jsxs(View,c?{testID:e.testID,style:[m.summaryRow,{paddingVertical:d,borderBottomColor:n.colors["border-subtle"]}],children:[_jsx(Text,{style:[m.summaryLabel,{fontSize:u,color:n.colors["text-muted"]}],children:_jsx(TextInkContext.Provider,{value:b,children:e.label})}),f?_jsx(Text,{style:[m.summaryValue,{fontSize:u,color:i},a],children:p}):_jsx(View,{style:m.summaryValueView,children:e.value})]}:{testID:e.testID,style:[o?m.rowSide:m.rowStack,{paddingVertical:d},s&&l>0?m.bordered:null,s&&l>0?{borderTopColor:n.colors["border-subtle"]}:null],children:["string"==typeof e.label?_jsx(Text,{style:[m.label,{fontSize:x,color:n.colors["text-subtle"]},o?m.labelSide:null],children:e.label}):_jsx(View,{style:o?m.labelSide:null,children:_jsx(Text,{style:[m.label,{fontSize:x,color:n.colors["text-subtle"]}],children:_jsx(TextInkContext.Provider,{value:y,children:e.label})})}),f?_jsx(Text,{style:[m.value,{fontSize:u,color:i},e.strong?a:null,o?m.valueSide:null],children:p}):_jsx(View,{style:o?m.valueSide:null,children:e.value})]},rowKey(e,l))})]})};const buildStyles=e=>StyleSheet.create({title:{...fontFor(e,"semibold")},rowStack:{gap:e.space.xxs},rowSide:{flexDirection:"row",alignItems:"flex-start",gap:e.space.md},bordered:{borderTopWidth:StyleSheet.hairlineWidth},label:{...fontFor(e,"semibold")},labelSide:{flex:4},value:{...fontFor(e,"normal")},valueSide:{flex:6},summaryRow:{flexDirection:"row",alignItems:"center",gap:e.space.md,borderBottomWidth:StyleSheet.hairlineWidth},summaryLabel:{flex:1,...fontFor(e,"normal")},summaryValue:{textAlign:"right",flexShrink:1,maxWidth:"60%"},summaryValueView:{flexShrink:1,maxWidth:"60%",alignItems:"flex-end"}});export default Descriptions;
@@ -1 +1 @@
1
- "use strict";import{isValidElement,useCallback,useMemo,useState}from"react";import{Image,StyleSheet,Text,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{AppIcon}from"../AppIcon/index.js";import{MODAL_DISMISS_GRACE_MS,Modal}from"../Modal/Modal.js";import{ACTIONS_LAYOUTS,OVERLAY_TONES,OverlayActions}from"./OverlayActions.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DIALOG_ILLUSTRATION_SIZE=120,STATUS_MARK={success:"check-circle",warning:"alert-triangle",danger:"alert-circle",info:"info-circle"},Dialog=e=>{const{open:t,onClose:o,title:s,message:l,children:i,icon:n,illustration:r,tone:a="neutral",actions:c,actionsLayout:m="auto",dismissOnAction:u=!0,accessibilityLabel:d,contentStyle:p,containerStyle:g,titleStyle:S,messageStyle:y,iconWrapperStyle:x,actionsRowStyle:h,actionButtonStyle:f,actionTextStyle:_,haptic:A,testID:I}=e;warnInvalidValue("Dialog","tone",e.tone,OVERLAY_TONES),warnInvalidValue("Dialog","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const b=useTheme(),j=useMemo(()=>buildStyles(),[]),O=useMemo(()=>discFor(b,a),[b,a]),T=b.components.dialog["icon-wrapper-size"],M=Boolean(c&&c.length>0),w=useState(null),L=useCallback(e=>{if(e.loading||e.disabled)return;const t=resolveHaptic(A,"selection");t&&triggerHaptic(t),u?(o(),setTimeout(e.onPress,MODAL_DISMISS_GRACE_MS)):e.onPress()},[u,o,A]),C=useMemo(()=>(c??[]).map(e=>({...e,onPress:()=>L(e)})),[c,L]),D=null==n&&null==r&&STATUS_MARK[a]?_jsx(AppIcon,{name:STATUS_MARK[a],size:Math.round(T/2),color:b.colors[a]}):null,V=n??D;return _jsx(Modal,{open:t,onClose:o,haptic:A,presentation:"centered",accessibilityLabel:d??s,contentStyle:p,testID:I,children:_jsxs(View,{accessibilityRole:"alert",accessibilityLabel:d??s,style:[j.container,g],children:[null!=r?_jsx(View,{style:{alignItems:"center",marginBottom:b.space.md},children:isValidElement(r)?r:_jsx(Image,{source:r,style:{width:120,height:120},resizeMode:"contain",accessibilityIgnoresInvertColors:!0})}):null,V?_jsx(View,{style:[j.iconWrapper,{width:T,height:T,borderRadius:b.radius.pill,...smoothCorners,backgroundColor:O,marginBottom:b.space.md},x],children:V}):null,s?_jsx(Text,{style:[j.title,{color:b.colors["text-body"],fontSize:b.text.xl.size,...fontFor(b,"semibold"),marginBottom:l||null!=i?b.space.sm:b.space.md},S],accessibilityRole:"header",children:s}):null,l?_jsx(Text,{style:[j.message,{color:b.colors["text-muted"],fontSize:b.text.base.size,lineHeight:b.text.base.size*b.leading.body,marginBottom:null!=i?b.space.md:M?b.space.lg:0},y],children:l}):null,null!=i?_jsx(View,{style:{marginBottom:M?b.space.lg:0},children:i}):null,M?_jsx(OverlayActions,{actions:C,layout:m,stackedLabels:w,rowStyle:h,buttonStyle:f,textStyle:_}):null]})})};Dialog.displayName="Dialog";const SOFT_DISC_OPACITY=.14,discFor=(e,t)=>{const o=e.colors["bg-subtle"];switch(t){case"success":return tintOf(e.colors.success,.14,o);case"warning":return tintOf(e.colors.warning,.14,o);case"danger":return tintOf(e.colors.danger,.14,o);case"info":return tintOf(e.colors.info,.14,o);default:return e.colors["primary-soft"]}},buildStyles=()=>StyleSheet.create({container:{alignItems:"stretch"},iconWrapper:{alignItems:"center",justifyContent:"center",alignSelf:"center"},title:{textAlign:"center"},message:{textAlign:"center"}});export{Dialog};export default Dialog;
1
+ "use strict";import{isValidElement,useCallback,useMemo,useState}from"react";import{Image,StyleSheet,Text,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{AppIcon}from"../AppIcon/index.js";import{MODAL_DISMISS_GRACE_MS,Modal}from"../Modal/Modal.js";import{ACTIONS_LAYOUTS,OVERLAY_TONES,OverlayActions}from"./OverlayActions.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DIALOG_ILLUSTRATION_SIZE=120,STATUS_MARK={success:"check-circle",warning:"alert-triangle",danger:"alert-circle",info:"info-circle"},Dialog=e=>{const{open:t,onClose:s,title:o,message:l,children:i,icon:n,illustration:r,tone:a="neutral",actions:c,actionsLayout:m="auto",dismissOnAction:u=!0,accessibilityLabel:d,contentStyle:p,containerStyle:g,titleStyle:S,messageStyle:y,iconWrapperStyle:x,actionsRowStyle:h,actionButtonStyle:f,actionTextStyle:_,haptic:A,testID:b}=e;assertValidValue("Dialog","tone",e.tone,OVERLAY_TONES),assertValidValue("Dialog","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const j=useTheme(),I=useMemo(()=>buildStyles(),[]),O=useMemo(()=>discFor(j,a),[j,a]),T=j.components.dialog["icon-wrapper-size"],M=Boolean(c&&c.length>0),V=useState(null),L=useCallback(e=>{if(e.loading||e.disabled)return;const t=resolveHaptic(A,"selection");t&&triggerHaptic(t),u?(s(),setTimeout(e.onPress,MODAL_DISMISS_GRACE_MS)):e.onPress()},[u,s,A]),C=useMemo(()=>(c??[]).map(e=>({...e,onPress:()=>L(e)})),[c,L]),D=null==n&&null==r&&STATUS_MARK[a]?_jsx(AppIcon,{name:STATUS_MARK[a],size:Math.round(T/2),color:j.colors[a]}):null,w=n??D;return _jsx(Modal,{open:t,onClose:s,haptic:A,presentation:"centered",accessibilityLabel:d??o,contentStyle:p,testID:b,children:_jsxs(View,{accessibilityRole:"alert",accessibilityLabel:d??o,style:[I.container,g],children:[null!=r?_jsx(View,{style:{alignItems:"center",marginBottom:j.space.md},children:isValidElement(r)?r:_jsx(Image,{source:r,style:{width:120,height:120},resizeMode:"contain",accessibilityIgnoresInvertColors:!0})}):null,w?_jsx(View,{style:[I.iconWrapper,{width:T,height:T,borderRadius:j.radius.pill,...smoothCorners,backgroundColor:O,marginBottom:j.space.md},x],children:w}):null,o?_jsx(Text,{style:[I.title,{color:j.colors["text-body"],fontSize:j.text.xl.size,...fontFor(j,"semibold"),marginBottom:l||null!=i?j.space.sm:j.space.md},S],accessibilityRole:"header",children:o}):null,l?_jsx(Text,{style:[I.message,{color:j.colors["text-muted"],fontSize:j.text.base.size,lineHeight:j.text.base.size*j.leading.body,marginBottom:null!=i?j.space.md:M?j.space.lg:0},y],children:l}):null,null!=i?_jsx(View,{style:{marginBottom:M?j.space.lg:0},children:i}):null,M?_jsx(OverlayActions,{actions:C,layout:m,stackedLabels:V,rowStyle:h,buttonStyle:f,textStyle:_}):null]})})};Dialog.displayName="Dialog";const SOFT_DISC_OPACITY=.14,discFor=(e,t)=>{const s=e.colors["bg-subtle"];switch(t){case"success":return tintOf(e.colors.success,.14,s);case"warning":return tintOf(e.colors.warning,.14,s);case"danger":return tintOf(e.colors.danger,.14,s);case"info":return tintOf(e.colors.info,.14,s);default:return e.colors["primary-soft"]}},buildStyles=()=>StyleSheet.create({container:{alignItems:"stretch"},iconWrapper:{alignItems:"center",justifyContent:"center",alignSelf:"center"},title:{textAlign:"center"},message:{textAlign:"center"}});export{Dialog};export default Dialog;