@webority/mobile-ui 0.12.0 → 0.12.1

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 (41) hide show
  1. package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
  2. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  3. package/lib/commonjs/components/Card/Card.js +1 -1
  4. package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
  5. package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +1 -1
  6. package/lib/commonjs/components/Input/Input.js +1 -1
  7. package/lib/commonjs/components/LoaderOverlay/LoaderOverlay.js +1 -1
  8. package/lib/commonjs/components/Menu/MenuSurface.js +1 -1
  9. package/lib/commonjs/components/Modal/Modal.js +1 -1
  10. package/lib/commonjs/components/ModalSafeArea/ModalSafeArea.js +1 -0
  11. package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
  12. package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  13. package/lib/commonjs/components/ProfilePicker/ProfilePicker.js +1 -1
  14. package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
  15. package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
  16. package/lib/commonjs/components/Slider/Slider.js +1 -1
  17. package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
  18. package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
  19. package/lib/commonjs/form/useForm.js +1 -1
  20. package/lib/commonjs/hooks/useDragToDismiss.js +1 -1
  21. package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
  22. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  23. package/lib/module/components/Card/Card.js +1 -1
  24. package/lib/module/components/DatePicker/DatePicker.js +1 -1
  25. package/lib/module/components/DateRangePicker/DateRangePicker.js +1 -1
  26. package/lib/module/components/Input/Input.js +1 -1
  27. package/lib/module/components/LoaderOverlay/LoaderOverlay.js +1 -1
  28. package/lib/module/components/Menu/MenuSurface.js +1 -1
  29. package/lib/module/components/Modal/Modal.js +1 -1
  30. package/lib/module/components/ModalSafeArea/ModalSafeArea.js +1 -0
  31. package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
  32. package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  33. package/lib/module/components/SearchBar/SearchBar.js +1 -1
  34. package/lib/module/components/Slider/Slider.js +1 -1
  35. package/lib/module/components/TimePicker/TimePicker.js +1 -1
  36. package/lib/module/components/Tooltip/Tooltip.js +1 -1
  37. package/lib/module/form/useForm.js +1 -1
  38. package/lib/module/hooks/useDragToDismiss.js +1 -1
  39. package/lib/typescript/commonjs/components/ModalSafeArea/ModalSafeArea.d.ts +26 -0
  40. package/lib/typescript/module/components/ModalSafeArea/ModalSafeArea.d.ts +26 -0
  41. package/package.json +2 -2
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OptionSheet=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");const SEARCH_ICON_SIZE=18,OptionSheet=e=>{const{open:t,onClose:r,onAfterClose:i,onOpenChange:o,title:a,options:s,sections:n,renderSectionHeader:l,renderOption:c,alphabetIndex:d=!1,searchPlaceholder:u="Search…",emptyText:p="No options",labelOf:m,getValue:h,disabledOf:g,destructiveOf:x,descriptionOf:_,iconOf:y,isSelected:f,onSelect:b,multi:v=!1,searchable:j=!1,searchSelectionColor:R,accessibilityLabel:S,optionStyle:N,selectedOptionStyle:T,optionTextStyle:C,selectedOptionTextStyle:w,testID:k}=e,I=(0,_index.useTheme)(),V=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),z=(0,_react.useMemo)(()=>buildStyles(I),[I]),[D,L]=(0,_react.useState)(""),P=_reactNative.Dimensions.get("window").height,H=Math.round(.7*P),[W,O]=(0,_react.useState)(t),A=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,M=(0,_react.useRef)((0,_index.createAnimatedValue)(H)).current,B=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,E=(0,_react.useMemo)(()=>_reactNative.Animated.add(M,B),[M,B]);(0,_react.useEffect)(()=>{t&&O(!0)},[t]);const F=(0,_react.useRef)(o);F.current=o;const q=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{q.current!==t&&(q.current=t,F.current?.(t))},[t]);const G=(0,_react.useRef)(i);G.current=i;const $=(0,_react.useRef)(W);(0,_react.useEffect)(()=>{$.current&&!W&&"ios"!==_reactNative.Platform.OS&&G.current?.(),$.current=W},[W]),(0,_react.useEffect)(()=>{if(!W)return;t&&(0,_index.setNativeValue)(B,0);const e=t?_reactNative.Animated.parallel([_reactNative.Animated.timing(A,{toValue:1,duration:I.motion.duration.fast,easing:_reactNative.Easing.bezier(...I.motion.easing.standard),useNativeDriver:!1}),_reactNative.Animated.spring(M,{toValue:0,damping:I.motion.spring.snappy.damping,stiffness:I.motion.spring.snappy.stiffness,mass:I.motion.spring.snappy.mass,useNativeDriver:!0})]):_reactNative.Animated.parallel([_reactNative.Animated.timing(A,{toValue:0,duration:I.motion.duration.fast,easing:_reactNative.Easing.bezier(...I.motion.easing.standard),useNativeDriver:!1}),_reactNative.Animated.timing(M,{toValue:H,duration:I.motion.duration.fast,easing:_reactNative.Easing.bezier(...I.motion.easing.accelerate),useNativeDriver:!0})]);return e.start(({finished:e})=>{e&&!t&&O(!1)}),()=>e.stop()},[t,W,A,M,B,H,I.motion.duration.fast,I.motion.easing.standard,I.motion.easing.accelerate,I.motion.spring.snappy]);const{handleGesture:K}=(0,_useDragToDismiss.useDragToDismiss)({drag:B,travel:H,onDismiss:r}),J=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native(),[]),[U,Y]=(0,_react.useState)(0),Z=(0,_reactNativeKeyboardController.useKeyboardState)(e=>e.height),Q=W?Math.max(0,Math.round(Z)):0,X=Math.max(V.top,_reactNative.StatusBar.currentHeight??0)+I.spacing.sm,ee=Q>0,te=ee?Math.max(0,Math.min(H,(U>0?U:P)-Q-X)):H;(0,_react.useEffect)(()=>{t||L("")},[t]);const re=(0,_react.useMemo)(()=>{const e=j?D.trim().toLowerCase():"",matches=t=>0===e.length||m(t).toLowerCase().includes(e)||(_(t)??"").toLowerCase().includes(e);if(!n)return s.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return n.forEach((e,r)=>{const i=e.options.filter(matches);if(0!==i.length){t.push({kind:"header",title:e.title});for(const e of i)t.push({kind:"option",option:e,section:r})}}),t},[j,D,s,n,m,_]),ie=(0,_react.useCallback)(()=>{r()},[r]),oe=(0,_react.useRef)(null),ae=(0,_react.useMemo)(()=>{const e=new Map;if(!d)return e;let t=0;if(n)for(let e=re.length-1;e>=0;e-=1)if("header"===re[e].kind){t=e+1;break}for(let r=t;r<re.length;r+=1){const t=re[r];if("option"!==t.kind)continue;const i=m(t.option).trim().charAt(0).toUpperCase(),o=/^[A-Z]$/.test(i)?i:"#";e.has(o)||e.set(o,r)}return e},[d,re,n,m]),se=d&&ae.size>0&&0===D.trim().length,ne=(0,_react.useMemo)(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...ae.has("#")?["#"]:[]],[ae]),le=(0,_react.useCallback)(e=>{const t=ae.get(e);void 0!==t&&oe.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[ae]),ce=(0,_react.useRef)(null),de=(0,_react.useCallback)(()=>{null!==ce.current&&(clearTimeout(ce.current),ce.current=null)},[]),ue=(0,_react.useCallback)(e=>{oe.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),de(),ce.current=setTimeout(()=>{ce.current=null,oe.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[de]);(0,_react.useEffect)(()=>(W||de(),de),[W,de]);return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:W,transparent:!0,animationType:"none",onRequestClose:ie,onDismiss:()=>G.current?.(),statusBarTranslucent:!0,navigationBarTranslucent:!0,children:(0,_jsxRuntime.jsxs)(_reactNativeGestureHandler.GestureHandlerRootView,{collapsable:!1,onLayout:e=>Y(e.nativeEvent.layout.height),style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:I.colors.background.overlay}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:ie,accessibilityRole:"button",accessibilityLabel:"Close picker"}),(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{testID:k,accessibilityViewIsModal:!0,accessibilityLabel:S??a??"Options",style:[z.sheet,{maxHeight:te,bottom:Q,paddingBottom:ee?16:V.bottom+16,backgroundColor:I.colors.background.elevated,borderTopLeftRadius:I.radius.xl,borderTopRightRadius:I.radius.xl,..._corners.smoothCorners,transform:[{translateY:E}],...I.shadows.xl}],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:K,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.sheetHandleRow,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[z.sheetHandle,{backgroundColor:I.components.select?.handleColor??I.components.bottomSheet?.handleColor??I.colors.border.primary}]})}),a?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.sheetTitle,{color:I.colors.text.primary,fontSize:I.typography.fontSize.lg,fontWeight:I.typography.fontWeight.semibold,paddingHorizontal:I.spacing.lg,marginBottom:I.spacing.sm}],children:a}):null]})}),j?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[z.searchWrap,{marginHorizontal:I.spacing.lg,marginBottom:I.spacing.sm}],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[z.searchBox,{backgroundColor:I.colors.background.secondary,borderColor:I.colors.border.primary,borderRadius:I.radius.md,..._corners.smoothCorners,paddingHorizontal:I.spacing.md,gap:I.spacing.sm}],children:[(I.icons?.search??_defaultIcons.defaultIcons.search)({size:18,color:I.colors.text.tertiary}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{value:D,onChangeText:L,placeholder:u,placeholderTextColor:I.colors.text.tertiary,selectionColor:R??I.colors.border.focus,accessibilityLabel:"Search options",style:[z.searchInput,{color:I.colors.text.primary,fontSize:I.typography.fontSize.base,paddingVertical:I.spacing.sm}]}),D.length>0?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>L(""),hitSlop:8,accessibilityRole:"button",accessibilityLabel:"Clear search",children:(I.icons?.close??_defaultIcons.defaultIcons.close)({size:18,color:I.colors.text.secondary})}):null]})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[z.listWrap,se?z.listRow:null],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:J,children:(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:oe,data:re,keyExtractor:e=>"header"===e.kind?`h:${e.title}`:`o:${e.section??""}:${String(h(e.option))}`,renderItem:({item:e})=>{if("header"===e.kind)return(0,_jsxRuntime.jsx)(_reactNative.View,{accessible:!0,accessibilityRole:"header",style:[z.sectionHeader,{paddingHorizontal:I.spacing.lg,paddingTop:I.spacing.md}],children:l?l(e.title):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.sectionTitle,{color:I.colors.text.tertiary,fontSize:I.typography.fontSize.xs,fontWeight:I.typography.fontWeight.semibold}],children:e.title.toUpperCase()})});const t=e.option,r=m(t),i=h(t),o=_(t),a=y(t),s=f(i),n=g(t),d=x?.(t)??!1;return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>b(t),disabled:n,android_ripple:{color:I.colors.surface.pressed,borderless:!1},accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{selected:s,disabled:n},"aria-selected":s,"aria-disabled":n,style:({pressed:e})=>[z.optionRow,{backgroundColor:s?I.colors.surface.selected:e?I.colors.surface.pressed:"transparent",opacity:n?.5:1,paddingHorizontal:I.spacing.lg,paddingVertical:I.spacing.md},N,s?T:null],children:[c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.optionTextWrap,children:c(t,{selected:s,disabled:n})}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.optionIcon,children:a}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:z.optionTextWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.optionLabel,{color:d?I.colors.toneText.error:s?I.colors.primary:I.colors.text.primary,fontSize:I.typography.fontSize.base,fontWeight:s?I.typography.fontWeight.semibold:I.typography.fontWeight.medium},C,s?w:null],children:r}),o?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.optionDescription,{color:I.colors.text.tertiary,fontSize:I.typography.fontSize.sm}],numberOfLines:2,children:o}):null]})]}),v?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[z.checkbox,{borderColor:s?I.colors.primary:I.colors.border.primary,backgroundColor:s?I.colors.primary:"transparent"}],children:s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.checkboxTick}):null}):s?"icon"===I.components.optionSheet?.selectedMarker?(0,_jsxRuntime.jsx)(_reactNative.View,{style:z.singleSelectedIcon,children:(I.icons?.selectedTick??_defaultIcons.defaultIcons.selectedTick)({size:20,color:I.colors.primary})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[z.singleSelectedDot,{backgroundColor:I.colors.primary}]}):null]})},onScrollToIndexFailed:ue,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!se,style:se?z.listBesideRail:null,ListEmptyComponent:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.empty,{color:I.colors.text.tertiary,fontSize:I.typography.fontSize.sm,paddingVertical:I.spacing.xl}],children:p})})}),se?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[z.rail,{paddingRight:I.spacing.xs}],accessibilityRole:"list",accessibilityLabel:"Jump to letter",testID:"option-sheet-alphabet",children:ne.map(e=>{const t=ae.has(e);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>le(e),disabled:!t,hitSlop:{left:8,right:8},accessibilityRole:"button",accessibilityLabel:`Jump to ${e}`,accessibilityState:{disabled:!t},"aria-disabled":!t,style:z.railLetter,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[z.railLetterText,{color:t?I.colors.primary:I.colors.text.tertiary,fontSize:I.typography.fontSize.xs,fontWeight:I.typography.fontWeight.semibold,opacity:t?1:.45}],children:e})},e)})}):null]}),v?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[z.sheetFooter,{borderTopColor:I.colors.border.secondary,paddingHorizontal:I.spacing.lg,paddingVertical:I.spacing.md}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:ie,accessibilityRole:"button",accessibilityLabel:"Done",style:({pressed:e})=>[z.doneButton,{backgroundColor:e?I.colors.primaryPressed:I.colors.primary,borderRadius:I.radius.md,..._corners.smoothCorners,paddingVertical:I.spacing.sm,paddingHorizontal:I.spacing.lg}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:I.colors.onPrimary,fontSize:I.typography.fontSize.base,fontWeight:I.typography.fontWeight.semibold},children:"Done"})})}):null]}),(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})})};exports.OptionSheet=OptionSheet,OptionSheet.displayName="OptionSheet";const buildStyles=e=>_reactNative.StyleSheet.create({sheet:{position:"absolute",left:0,right:0,bottom:0,paddingBottom:16,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:10,paddingBottom:8},sheetHandle:{width:36,height:4,borderRadius:2,..._corners.smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:4},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:4},railLetter:{paddingHorizontal:4,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:14},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:12},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:2},checkbox:{width:22,height:22,borderRadius:6,..._corners.smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:12},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors.onPrimary,transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:4,..._corners.smoothCorners,marginLeft:12},singleSelectedIcon:{marginLeft:12},empty:{textAlign:"center"},sheetFooter:{borderTopWidth:_reactNative.StyleSheet.hairlineWidth,alignItems:"flex-end"},doneButton:{alignSelf:"flex-end"}});var _default=exports.default=OptionSheet;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OptionSheet=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");const SEARCH_ICON_SIZE=18,OptionSheet=e=>{const{open:t,onClose:r,onAfterClose:i,onOpenChange:o,title:a,options:s,sections:n,renderSectionHeader:l,renderOption:c,alphabetIndex:d=!1,searchPlaceholder:u="Search…",emptyText:p="No options",labelOf:m,getValue:h,disabledOf:g,destructiveOf:x,descriptionOf:_,iconOf:y,isSelected:f,onSelect:b,multi:v=!1,searchable:j=!1,searchSelectionColor:R,accessibilityLabel:S,optionStyle:N,selectedOptionStyle:T,optionTextStyle:C,selectedOptionTextStyle:w,testID:k}=e,I=(0,_index.useTheme)(),[V,z]=(0,_ModalSafeArea.useModalInsets)(),D=(0,_react.useMemo)(()=>buildStyles(I),[I]),[L,P]=(0,_react.useState)(""),H=_reactNative.Dimensions.get("window").height,M=Math.round(.7*H),[W,A]=(0,_react.useState)(t),O=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,B=(0,_react.useRef)((0,_index.createAnimatedValue)(M)).current,E=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,F=(0,_react.useMemo)(()=>_reactNative.Animated.add(B,E),[B,E]);(0,_react.useEffect)(()=>{t&&A(!0)},[t]);const q=(0,_react.useRef)(o);q.current=o;const G=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{G.current!==t&&(G.current=t,q.current?.(t))},[t]);const $=(0,_react.useRef)(i);$.current=i;const K=(0,_react.useRef)(W);(0,_react.useEffect)(()=>{K.current&&!W&&"ios"!==_reactNative.Platform.OS&&$.current?.(),K.current=W},[W]),(0,_react.useEffect)(()=>{if(!W)return;t&&(0,_index.setNativeValue)(E,0);const e=t?_reactNative.Animated.parallel([_reactNative.Animated.timing(O,{toValue:1,duration:I.motion.duration.fast,easing:_reactNative.Easing.bezier(...I.motion.easing.standard),useNativeDriver:!1}),_reactNative.Animated.spring(B,{toValue:0,damping:I.motion.spring.snappy.damping,stiffness:I.motion.spring.snappy.stiffness,mass:I.motion.spring.snappy.mass,useNativeDriver:!0})]):_reactNative.Animated.parallel([_reactNative.Animated.timing(O,{toValue:0,duration:I.motion.duration.fast,easing:_reactNative.Easing.bezier(...I.motion.easing.standard),useNativeDriver:!1}),_reactNative.Animated.timing(B,{toValue:M,duration:I.motion.duration.fast,easing:_reactNative.Easing.bezier(...I.motion.easing.accelerate),useNativeDriver:!0})]);return e.start(({finished:e})=>{e&&!t&&A(!1)}),()=>e.stop()},[t,W,O,B,E,M,I.motion.duration.fast,I.motion.easing.standard,I.motion.easing.accelerate,I.motion.spring.snappy]);const{handleGesture:J}=(0,_useDragToDismiss.useDragToDismiss)({drag:E,travel:M,onDismiss:r}),U=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native(),[]),[Y,Z]=(0,_react.useState)(0),Q=(0,_reactNativeKeyboardController.useKeyboardState)(e=>e.height),X=W?Math.max(0,Math.round(Q)):0,ee=Math.max(V.top,_reactNative.StatusBar.currentHeight??0)+I.spacing.sm,te=X>0,re=te?Math.max(0,Math.min(M,(Y>0?Y:H)-X-ee)):M;(0,_react.useEffect)(()=>{t||P("")},[t]);const ie=(0,_react.useMemo)(()=>{const e=j?L.trim().toLowerCase():"",matches=t=>0===e.length||m(t).toLowerCase().includes(e)||(_(t)??"").toLowerCase().includes(e);if(!n)return s.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return n.forEach((e,r)=>{const i=e.options.filter(matches);if(0!==i.length){t.push({kind:"header",title:e.title});for(const e of i)t.push({kind:"option",option:e,section:r})}}),t},[j,L,s,n,m,_]),oe=(0,_react.useCallback)(()=>{r()},[r]),ae=(0,_react.useRef)(null),se=(0,_react.useMemo)(()=>{const e=new Map;if(!d)return e;let t=0;if(n)for(let e=ie.length-1;e>=0;e-=1)if("header"===ie[e].kind){t=e+1;break}for(let r=t;r<ie.length;r+=1){const t=ie[r];if("option"!==t.kind)continue;const i=m(t.option).trim().charAt(0).toUpperCase(),o=/^[A-Z]$/.test(i)?i:"#";e.has(o)||e.set(o,r)}return e},[d,ie,n,m]),ne=d&&se.size>0&&0===L.trim().length,le=(0,_react.useMemo)(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...se.has("#")?["#"]:[]],[se]),ce=(0,_react.useCallback)(e=>{const t=se.get(e);void 0!==t&&ae.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[se]),de=(0,_react.useRef)(null),ue=(0,_react.useCallback)(()=>{null!==de.current&&(clearTimeout(de.current),de.current=null)},[]),pe=(0,_react.useCallback)(e=>{ae.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),ue(),de.current=setTimeout(()=>{de.current=null,ae.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[ue]);(0,_react.useEffect)(()=>(W||ue(),ue),[W,ue]);return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:W,transparent:!0,animationType:"none",onRequestClose:oe,onDismiss:()=>$.current?.(),statusBarTranslucent:!0,navigationBarTranslucent:!0,children:(0,_jsxRuntime.jsx)(_ModalSafeArea.ModalSafeArea,{onInsets:z,children:(0,_jsxRuntime.jsxs)(_reactNativeGestureHandler.GestureHandlerRootView,{collapsable:!1,onLayout:e=>Z(e.nativeEvent.layout.height),style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:I.colors.background.overlay}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:oe,accessibilityRole:"button",accessibilityLabel:"Close picker"}),(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{testID:k,accessibilityViewIsModal:!0,accessibilityLabel:S??a??"Options",style:[D.sheet,{maxHeight:re,bottom:X,paddingBottom:te?16:V.bottom+16,backgroundColor:I.colors.background.elevated,borderTopLeftRadius:I.radius.xl,borderTopRightRadius:I.radius.xl,..._corners.smoothCorners,transform:[{translateY:F}],...I.shadows.xl}],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:J,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.sheetHandleRow,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.sheetHandle,{backgroundColor:I.components.select?.handleColor??I.components.bottomSheet?.handleColor??I.colors.border.primary}]})}),a?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.sheetTitle,{color:I.colors.text.primary,fontSize:I.typography.fontSize.lg,fontWeight:I.typography.fontWeight.semibold,paddingHorizontal:I.spacing.lg,marginBottom:I.spacing.sm}],children:a}):null]})}),j?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.searchWrap,{marginHorizontal:I.spacing.lg,marginBottom:I.spacing.sm}],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[D.searchBox,{backgroundColor:I.colors.background.secondary,borderColor:I.colors.border.primary,borderRadius:I.radius.md,..._corners.smoothCorners,paddingHorizontal:I.spacing.md,gap:I.spacing.sm}],children:[(I.icons?.search??_defaultIcons.defaultIcons.search)({size:18,color:I.colors.text.tertiary}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{value:L,onChangeText:P,placeholder:u,placeholderTextColor:I.colors.text.tertiary,selectionColor:R??I.colors.border.focus,accessibilityLabel:"Search options",style:[D.searchInput,{color:I.colors.text.primary,fontSize:I.typography.fontSize.base,paddingVertical:I.spacing.sm}]}),L.length>0?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>P(""),hitSlop:8,accessibilityRole:"button",accessibilityLabel:"Clear search",children:(I.icons?.close??_defaultIcons.defaultIcons.close)({size:18,color:I.colors.text.secondary})}):null]})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[D.listWrap,ne?D.listRow:null],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:U,children:(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:ae,data:ie,keyExtractor:e=>"header"===e.kind?`h:${e.title}`:`o:${e.section??""}:${String(h(e.option))}`,renderItem:({item:e})=>{if("header"===e.kind)return(0,_jsxRuntime.jsx)(_reactNative.View,{accessible:!0,accessibilityRole:"header",style:[D.sectionHeader,{paddingHorizontal:I.spacing.lg,paddingTop:I.spacing.md}],children:l?l(e.title):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.sectionTitle,{color:I.colors.text.tertiary,fontSize:I.typography.fontSize.xs,fontWeight:I.typography.fontWeight.semibold}],children:e.title.toUpperCase()})});const t=e.option,r=m(t),i=h(t),o=_(t),a=y(t),s=f(i),n=g(t),d=x?.(t)??!1;return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>b(t),disabled:n,android_ripple:{color:I.colors.surface.pressed,borderless:!1},accessibilityRole:"button",accessibilityLabel:r,accessibilityState:{selected:s,disabled:n},"aria-selected":s,"aria-disabled":n,style:({pressed:e})=>[D.optionRow,{backgroundColor:s?I.colors.surface.selected:e?I.colors.surface.pressed:"transparent",opacity:n?.5:1,paddingHorizontal:I.spacing.lg,paddingVertical:I.spacing.md},N,s?T:null],children:[c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.optionTextWrap,children:c(t,{selected:s,disabled:n})}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.optionIcon,children:a}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:D.optionTextWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.optionLabel,{color:d?I.colors.toneText.error:s?I.colors.primary:I.colors.text.primary,fontSize:I.typography.fontSize.base,fontWeight:s?I.typography.fontWeight.semibold:I.typography.fontWeight.medium},C,s?w:null],children:r}),o?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.optionDescription,{color:I.colors.text.tertiary,fontSize:I.typography.fontSize.sm}],numberOfLines:2,children:o}):null]})]}),v?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.checkbox,{borderColor:s?I.colors.primary:I.colors.border.primary,backgroundColor:s?I.colors.primary:"transparent"}],children:s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.checkboxTick}):null}):s?"icon"===I.components.optionSheet?.selectedMarker?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.singleSelectedIcon,children:(I.icons?.selectedTick??_defaultIcons.defaultIcons.selectedTick)({size:20,color:I.colors.primary})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.singleSelectedDot,{backgroundColor:I.colors.primary}]}):null]})},onScrollToIndexFailed:pe,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!ne,style:ne?D.listBesideRail:null,ListEmptyComponent:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.empty,{color:I.colors.text.tertiary,fontSize:I.typography.fontSize.sm,paddingVertical:I.spacing.xl}],children:p})})}),ne?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.rail,{paddingRight:I.spacing.xs}],accessibilityRole:"list",accessibilityLabel:"Jump to letter",testID:"option-sheet-alphabet",children:le.map(e=>{const t=se.has(e);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>ce(e),disabled:!t,hitSlop:{left:8,right:8},accessibilityRole:"button",accessibilityLabel:`Jump to ${e}`,accessibilityState:{disabled:!t},"aria-disabled":!t,style:D.railLetter,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.railLetterText,{color:t?I.colors.primary:I.colors.text.tertiary,fontSize:I.typography.fontSize.xs,fontWeight:I.typography.fontWeight.semibold,opacity:t?1:.45}],children:e})},e)})}):null]}),v?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.sheetFooter,{borderTopColor:I.colors.border.secondary,paddingHorizontal:I.spacing.lg,paddingVertical:I.spacing.md}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:oe,accessibilityRole:"button",accessibilityLabel:"Done",style:({pressed:e})=>[D.doneButton,{backgroundColor:e?I.colors.primaryPressed:I.colors.primary,borderRadius:I.radius.md,..._corners.smoothCorners,paddingVertical:I.spacing.sm,paddingHorizontal:I.spacing.lg}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:I.colors.onPrimary,fontSize:I.typography.fontSize.base,fontWeight:I.typography.fontWeight.semibold},children:"Done"})})}):null]}),(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})})})};exports.OptionSheet=OptionSheet,OptionSheet.displayName="OptionSheet";const buildStyles=e=>_reactNative.StyleSheet.create({sheet:{position:"absolute",left:0,right:0,bottom:0,paddingBottom:16,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:10,paddingBottom:8},sheetHandle:{width:36,height:4,borderRadius:2,..._corners.smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:4},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:4},railLetter:{paddingHorizontal:4,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:14},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:12},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:2},checkbox:{width:22,height:22,borderRadius:6,..._corners.smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:12},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors.onPrimary,transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:4,..._corners.smoothCorners,marginLeft:12},singleSelectedIcon:{marginLeft:12},empty:{textAlign:"center"},sheetFooter:{borderTopWidth:_reactNative.StyleSheet.hairlineWidth,alignItems:"flex-end"},doneButton:{alignSelf:"flex-end"}});var _default=exports.default=OptionSheet;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseE164=exports.formatE164=exports.default=exports.PhoneNumberInput=exports.DEFAULT_CALLING_CODES=exports.ALL_CALLING_CODES=void 0;var _mobileCore=require("@webority/mobile-core"),_countries=require("@webority/mobile-core/phone/countries"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_index4=require("../FieldBase/index.js"),_Chevron=require("../FieldBase/Chevron.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CALLING_CODES=exports.DEFAULT_CALLING_CODES=[{iso:"IN",code:"91",label:"India"},{iso:"AE",code:"971",label:"United Arab Emirates"},{iso:"GB",code:"44",label:"United Kingdom"},{iso:"US",code:"1",label:"United States"},{iso:"CA",code:"1",label:"Canada"},{iso:"AU",code:"61",label:"Australia"},{iso:"SG",code:"65",label:"Singapore"},{iso:"SA",code:"966",label:"Saudi Arabia"}],ALL_CALLING_CODES=exports.ALL_CALLING_CODES=(0,_mobileCore.getPhoneCountries)().map(e=>({iso:e.iso,code:e.callingCode,label:_countries.PHONE_COUNTRY_NAMES[e.iso]??e.iso})).sort((e,t)=>e.label.localeCompare(t.label)),digitsOnly=e=>e.replace(/[^0-9]/g,""),formatE164=e=>`+${e.callingCode}${e.nationalNumber}`;exports.formatE164=formatE164;const parseE164=(e,t,i)=>{const o=e.replace(/[^0-9]/g,"");if(!o)return null;const n=(0,_mobileCore.splitPhoneNumber)(`+${o}`);let r=n?.callingCode,l=n?.nationalNumber??"";if(!r){const e=Array.from(new Set(t.map(e=>e.code))).sort((e,t)=>t.length-e.length);if(r=e.find(e=>o.startsWith(e)),!r)return null;l=o.slice(r.length)}const a=t.filter(e=>e.code===r),s=a.find(e=>e.iso===i)?.iso??a.find(e=>e.iso===n?.country)?.iso??n?.country??a[0]?.iso??"";return{callingCode:r,nationalNumber:l,iso:s}};exports.parseE164=parseE164;const planOf=e=>(0,_mobileCore.isSupportedCountry)(e)?e:null,PhoneNumberInput=exports.PhoneNumberInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:o,onChange:n,e164:r,onChangeE164:l,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:c,onComplete:d,onValidityChange:b,countries:m=ALL_CALLING_CODES,popularCountries:p,popularCountriesTitle:_="Popular",allCountriesTitle:f="All countries",hiddenCountries:h,showFlag:g=!0,renderFlag:x,renderCountry:C,countrySearchPlaceholder:N,showAlphabetIndex:y,defaultIso:S="IN",validation:v="any",maxLength:L,formatAsYouType:E=!0,countryLocked:I=!1,label:j,labelMode:F="top",labelStyle:O,placeholder:T="Phone number",helperText:A,error:P,invalidMessage:R,required:D,disabled:z=!1,size:w="md",variant:q,borderRadius:k,countrySheetTitle:M="Country code",haptic:V,accessibilityLabel:B,countryAccessibilityLabel:$,onFocus:G,onBlur:U,style:W,testID:H}=e,Y=(0,_index2.useTheme)(),K=(0,_react.useMemo)(()=>buildStyles(Y),[Y]),J=(0,_react.useRef)(null),Q=(0,_react.useMemo)(()=>h?.length?m.filter(e=>!h.includes(e.iso)):m,[m,h]),X=(0,_react.useMemo)(()=>{if(!p?.length)return;const e=p.map(e=>Q.find(t=>t.iso===e)).filter(e=>void 0!==e);return e.length?[{title:_,options:e},{title:f,options:Q}]:void 0},[p,_,f,Q]),Z=(0,_react.useCallback)((e,t,i)=>{if(!e)return null;if(x)return x(e);if(!g)return null;const o=(0,_mobileCore.countryFlagEmoji)(e.iso);return o?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[K.flag,{fontSize:t}],testID:i,children:o}):null},[x,g,K.flag]),ee=(0,_react.useCallback)(e=>{const t=planOf(e),i=t?(0,_mobileCore.maxNationalNumberLength)(t,!1===v?"any":v):Number.POSITIVE_INFINITY;return L?Math.min(i,L):i},[L,v]),te=(0,_react.useCallback)((e,t)=>e.slice(0,ee(t)),[ee]),ie=(0,_react.useCallback)((e,t)=>{const i=planOf(t)??void 0,o=(0,_mobileCore.splitPhoneNumber)(e,i);if(!o)return null;const n=o.country??t,r=m.find(e=>e.iso===n);return{callingCode:r?.code??o.callingCode,nationalNumber:te(o.nationalNumber,n),iso:r?.iso??n}},[m,te]),oe=(0,_react.useMemo)(()=>{const e=Q.find(e=>e.iso===S)??Q[0]??m[0],t={callingCode:e?.code??"91",nationalNumber:"",iso:e?.iso??"IN"};return"string"==typeof o?ie(o,t.iso)??t:o??t},[m,Q,S,o,ie]),ne=(0,_react.useCallback)(e=>{if(!1===v)return e.nationalNumber.length>0;const t=planOf(e.iso);return t?(0,_mobileCore.isValidNationalNumber)(e.nationalNumber,t,v):e.nationalNumber.length>0},[v]),[re,le]=(0,_react.useState)(oe.iso),ae=(0,_react.useMemo)(()=>{if(void 0===r)return;const e=r?parseE164(r,m,re):null;if(e)return{...e,nationalNumber:te(e.nationalNumber,e.iso)};const t=m.find(e=>e.iso===re);return{callingCode:t?.code??oe.callingCode,nationalNumber:"",iso:re}},[r,m,re,oe.callingCode,te]),se=(0,_react.useCallback)(e=>{le(e.iso),n?.(e),l?.(e.nationalNumber?formatE164(e):"",{country:m.find(t=>t.iso===e.iso),national:e.nationalNumber,valid:ne(e)})},[n,l,m,ne]),[ue,ce]=(0,_index.useControllableState)({value:i??ae,defaultValue:oe,onChange:se}),[de,be]=(0,_react.useState)(!1),me=(0,_react.useCallback)(()=>{z||J.current?.focus()},[z]),[pe,_e]=(0,_react.useState)(!1),[fe,he]=(0,_react.useState)(!1),[ge,xe]=(0,_react.useState)(!1),Ce=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{ge||(Ce.current=!1)},[ge]);const Ne=(0,_index4.resolveFieldSize)(Y,w),ye=(0,_index4.resolveFieldTextStyle)(Y,{disabled:z}),Se=q??Y.components.field?.defaultVariant??"outlined",ve="underline"===Se,Le=k??Y.components.phoneNumberInput?.borderRadius,Ee=Y.spacing.md,[Ie,je]=(0,_react.useState)(0),Fe=Ie+Ee+1+Ee,Oe=ue.nationalNumber.length>0,Te=D&&!j&&!Oe&&T.length>0,Ae=de||Oe,Pe=Boolean(j)&&"float"===F&&Ie>0,Re=(0,_useFloatingLabel.useFloatingLabel)({label:j,enabled:Pe,floated:Ae,required:D,variant:Se,sizeTokens:Ne,leadingOffset:Fe,paddingLeft:ve?0:Ne.paddingHorizontal,color:Y.colors.field.label,style:O}),De=(0,_react.useMemo)(()=>m.find(e=>e.iso===ue.iso),[m,ue.iso]),ze=planOf(ue.iso),we=E&&ze?(0,_mobileCore.formatPhoneAsTyped)(ue.nationalNumber,ze):ue.nationalNumber,qe=ee(ue.iso),ke=0===ue.nationalNumber.length||pe||!Number.isFinite(qe)?void 0:we.length+Math.max(0,qe-ue.nationalNumber.length),Me=ne(ue);(0,_react.useEffect)(()=>{Oe||he(!1)},[Oe]);const Ve=ze?(0,_mobileCore.maxNationalNumberLength)(ze,!1===v?"any":v):Number.POSITIVE_INFINITY,Be=ue.nationalNumber.length>=Ve,$e=!1!==v&&!1!==R&&Oe&&!Me&&(fe||Be),Ge="mobile"===v?"Enter a valid mobile number":"Enter a valid number",Ue=(0,_index4.hasFieldText)(P)?P:$e?R||Ge:void 0,We=!0===P||(0,_index4.hasFieldText)(Ue),He=(0,_react.useRef)(Me),Ye=(0,_react.useRef)(ue);Ye.current=ue,(0,_react.useEffect)(()=>{He.current!==Me&&(He.current=Me,b?.(Me),Me&&d?.(formatE164(Ye.current)))},[Me,d,b]);const Ke=(0,_react.useCallback)(e=>{if(e.includes("+")){const t=ie(e,ue.iso);if(t&&!I&&Q.some(e=>e.iso===t.iso))return void ce(t);if(t&&t.iso===ue.iso)return void ce(t)}ce({...ue,nationalNumber:te(digitsOnly(e),ue.iso)})},[Q,I,ue,ie,te,ce]),Je=(0,_react.useCallback)(e=>{const t=e;ce({callingCode:t.code,iso:t.iso,nationalNumber:te(ue.nationalNumber,t.iso)}),xe(!1);const i=(0,_index3.resolveHaptic)(V,"selection");i&&(0,_index3.triggerHaptic)(i)},[ue,V,te,ce]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>J.current?.focus(),blur:()=>J.current?.blur(),clear:()=>ce({...Ye.current,nationalNumber:""}),isFocused:()=>J.current?.isFocused()??!1,getValue:()=>Ye.current,getE164:()=>formatE164(Ye.current),getFormatted:()=>{const e=Ye.current,t=planOf(e.iso);return t?(0,_mobileCore.formatPhoneAsTyped)(e.nationalNumber,t):e.nationalNumber},isValid:()=>ne(Ye.current),getCountry:()=>m.find(e=>e.iso===Ye.current.iso)}),[m,ne,ce]);const Qe=z||I,Xe=(0,_jsxRuntime.jsx)(_index4.FieldBase,{size:w,variant:Se,borderRadius:Le,topNotch:Re.topNotch,focused:de,disabled:z,error:We,filled:Oe,onPress:me,pressFeedback:!1,leadingDivider:!0,paddingLeft:ve?0:void 0,leading:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{Qe||(Ce.current=!0,xe(!0))},disabled:Qe,accessibilityRole:"button",accessibilityLabel:$??`Country code, currently +${ue.callingCode}`,accessibilityState:{disabled:Qe},"aria-disabled":Qe,hitSlop:6,onLayout:e=>{const{width:t}=e.nativeEvent.layout;je(e=>e===t?e:t)},style:K.codeTrigger,testID:H?`${H}-code`:void 0,children:[Z(De,Ne.fontSize,H?`${H}-flag`:void 0),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[K.codeText,{color:ye.color,fontSize:Ne.fontSize}],children:`+${ue.callingCode}`}),I?null:(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:z?Y.colors.field.iconDisabled:Y.colors.field.icon,size:Ne.iconSize,open:ge})]}),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:K.inputWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:J,value:we,maxLength:ke,onChangeText:Ke,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:c,onSelectionChange:e=>{const{start:t,end:i}=e.nativeEvent.selection;_e(t!==i)},onFocus:()=>{be(!0),G?.()},onBlur:()=>{be(!1),Oe&&!Ce.current&&he(!0),U?.()},editable:!z,placeholder:Pe&&!Ae||Te?void 0:T,placeholderTextColor:ye.placeholderColor,accessibilityLabel:B??j??T,selectionColor:Y.colors.field.caret,keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",style:[K.input,{color:ye.color,fontSize:Ne.fontSize,...ye.weightStyle,paddingLeft:ve?0:void 0}],testID:H?`${H}-input`:void 0}),Te?(0,_jsxRuntime.jsx)(_index4.RequiredPlaceholder,{text:T,color:ye.placeholderColor,fontSize:Ne.fontSize,weightStyle:ye.weightStyle}):null]})});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:W,testID:H,children:[j&&"top"===F?(0,_jsxRuntime.jsx)(_index4.FieldLabel,{size:w,required:D,children:j}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:K.fieldWrapper,children:[Xe,Re.node]}),(0,_jsxRuntime.jsx)(_index4.FieldMessage,{size:w,error:We,text:We?Ue:A}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:ge,onClose:()=>xe(!1),title:M,options:Q,sections:X,labelOf:e=>`${e.label} (+${e.code})`,getValue:e=>e.iso,disabledOf:()=>!1,descriptionOf:()=>{},iconOf:e=>Z(e,Y.typography.fontSize.lg),renderOption:C?(e,t)=>C(e,{selected:t.selected}):void 0,isSelected:e=>e===De?.iso,onSelect:Je,searchable:Q.length>8,searchPlaceholder:N,alphabetIndex:y??Q.length>20})]})});PhoneNumberInput.displayName="PhoneNumberInput";const buildStyles=e=>_reactNative.StyleSheet.create({fieldWrapper:{position:"relative",overflow:"visible"},codeTrigger:{flexDirection:"row",alignItems:"center",gap:2},flag:{includeFontPadding:!1,marginRight:4},codeText:{...(0,_index2.fontFor)(e,"semibold"),fontWeight:"600",includeFontPadding:!1,writingDirection:"ltr"},input:{padding:0,margin:0,includeFontPadding:!1,writingDirection:"ltr"},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"}});var _default=exports.default=PhoneNumberInput;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseE164=exports.formatE164=exports.default=exports.PhoneNumberInput=exports.DEFAULT_CALLING_CODES=exports.ALL_CALLING_CODES=void 0;var _mobileCore=require("@webority/mobile-core"),_countries=require("@webority/mobile-core/phone/countries"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_index4=require("../FieldBase/index.js"),_Chevron=require("../FieldBase/Chevron.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_CALLING_CODES=exports.DEFAULT_CALLING_CODES=[{iso:"IN",code:"91",label:"India"},{iso:"AE",code:"971",label:"United Arab Emirates"},{iso:"GB",code:"44",label:"United Kingdom"},{iso:"US",code:"1",label:"United States"},{iso:"CA",code:"1",label:"Canada"},{iso:"AU",code:"61",label:"Australia"},{iso:"SG",code:"65",label:"Singapore"},{iso:"SA",code:"966",label:"Saudi Arabia"}],ALL_CALLING_CODES=exports.ALL_CALLING_CODES=(0,_mobileCore.getPhoneCountries)().map(e=>({iso:e.iso,code:e.callingCode,label:_countries.PHONE_COUNTRY_NAMES[e.iso]??e.iso})).sort((e,t)=>e.label.localeCompare(t.label)),digitsOnly=e=>e.replace(/[^0-9]/g,""),formatE164=e=>`+${e.callingCode}${e.nationalNumber}`;exports.formatE164=formatE164;const parseE164=(e,t,i)=>{const o=e.replace(/[^0-9]/g,"");if(!o)return null;const n=(0,_mobileCore.splitPhoneNumber)(`+${o}`);let r=n?.callingCode,l=n?.nationalNumber??"";if(!r){const e=Array.from(new Set(t.map(e=>e.code))).sort((e,t)=>t.length-e.length);if(r=e.find(e=>o.startsWith(e)),!r)return null;l=o.slice(r.length)}const a=t.filter(e=>e.code===r),s=a.find(e=>e.iso===i)?.iso??a.find(e=>e.iso===n?.country)?.iso??n?.country??a[0]?.iso??"";return{callingCode:r,nationalNumber:l,iso:s}};exports.parseE164=parseE164;const planOf=e=>(0,_mobileCore.isSupportedCountry)(e)?e:null,PhoneNumberInput=exports.PhoneNumberInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:o,onChange:n,e164:r,onChangeE164:l,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:c,onComplete:d,onValidityChange:b,countries:m=ALL_CALLING_CODES,popularCountries:p,popularCountriesTitle:_="Popular",allCountriesTitle:f="All countries",hiddenCountries:h,showFlag:g=!0,renderFlag:x,renderCountry:C,countrySearchPlaceholder:N,showAlphabetIndex:y,defaultIso:S="IN",validation:v="any",maxLength:L,formatAsYouType:E=!0,countryLocked:I=!1,label:j,labelMode:F="top",labelStyle:O,placeholder:T="Phone number",helperText:A,error:P,invalidMessage:R,required:D,disabled:z=!1,size:w="md",variant:q,borderRadius:k,countrySheetTitle:M="Country code",haptic:V,accessibilityLabel:B,countryAccessibilityLabel:$,onFocus:G,onBlur:U,style:W,testID:H}=e,Y=(0,_index2.useTheme)(),K=(0,_react.useMemo)(()=>buildStyles(Y),[Y]),J=(0,_react.useRef)(null),Q=(0,_react.useMemo)(()=>h?.length?m.filter(e=>!h.includes(e.iso)):m,[m,h]),X=(0,_react.useMemo)(()=>{if(!p?.length)return;const e=p.map(e=>Q.find(t=>t.iso===e)).filter(e=>void 0!==e);return e.length?[{title:_,options:e},{title:f,options:Q}]:void 0},[p,_,f,Q]),Z=(0,_react.useCallback)((e,t,i)=>{if(!e)return null;if(x)return x(e);if(!g)return null;const o=(0,_mobileCore.countryFlagEmoji)(e.iso);return o?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[K.flag,{fontSize:t}],testID:i,children:o}):null},[x,g,K.flag]),ee=(0,_react.useCallback)(e=>{const t=planOf(e),i=t?(0,_mobileCore.maxNationalNumberLength)(t,!1===v?"any":v):Number.POSITIVE_INFINITY;return L?Math.min(i,L):i},[L,v]),te=(0,_react.useCallback)((e,t)=>e.slice(0,ee(t)),[ee]),ie=(0,_react.useCallback)((e,t)=>{const i=planOf(t)??void 0,o=(0,_mobileCore.splitPhoneNumber)(e,i);if(!o)return null;const n=o.country??t,r=m.find(e=>e.iso===n);return{callingCode:r?.code??o.callingCode,nationalNumber:te(o.nationalNumber,n),iso:r?.iso??n}},[m,te]),oe=(0,_react.useMemo)(()=>{const e=Q.find(e=>e.iso===S)??Q[0]??m[0],t={callingCode:e?.code??"91",nationalNumber:"",iso:e?.iso??"IN"};return"string"==typeof o?ie(o,t.iso)??t:o??t},[m,Q,S,o,ie]),ne=(0,_react.useCallback)(e=>{if(!1===v)return e.nationalNumber.length>0;const t=planOf(e.iso);return t?(0,_mobileCore.isValidNationalNumber)(e.nationalNumber,t,v):e.nationalNumber.length>0},[v]),[re,le]=(0,_react.useState)(oe.iso),ae=(0,_react.useMemo)(()=>{if(void 0===r)return;const e=r?parseE164(r,m,re):null;if(e)return{...e,nationalNumber:te(e.nationalNumber,e.iso)};const t=m.find(e=>e.iso===re);return{callingCode:t?.code??oe.callingCode,nationalNumber:"",iso:re}},[r,m,re,oe.callingCode,te]),se=(0,_react.useCallback)(e=>{le(e.iso),n?.(e),l?.(e.nationalNumber?formatE164(e):"",{country:m.find(t=>t.iso===e.iso),national:e.nationalNumber,valid:ne(e)})},[n,l,m,ne]),[ue,ce]=(0,_index.useControllableState)({value:i??ae,defaultValue:oe,onChange:se}),[de,be]=(0,_react.useState)(!1),me=(0,_react.useCallback)(()=>{z||J.current?.focus()},[z]),[pe,fe]=(0,_react.useState)(!1),[he,ge]=(0,_react.useState)(!1),[xe,Ce]=(0,_react.useState)(!1),Ne=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{xe||(Ne.current=!1)},[xe]);const ye=(0,_index4.resolveFieldSize)(Y,w),Se=(0,_index4.resolveFieldTextStyle)(Y,{disabled:z}),ve=q??Y.components.field?.defaultVariant??"outlined",Le="underline"===ve,Ee=k??Y.components.phoneNumberInput?.borderRadius,Ie=Y.spacing.md,[je,Fe]=(0,_react.useState)(0),Oe=je+Ie+1+Ie,Te=ue.nationalNumber.length>0,Ae=D&&!j&&!Te&&T.length>0,Pe=de||Te,Re=Boolean(j)&&"float"===F&&je>0,De=(0,_useFloatingLabel.useFloatingLabel)({label:j,enabled:Re,floated:Pe,required:D,variant:ve,sizeTokens:ye,leadingOffset:Oe,paddingLeft:Le?0:ye.paddingHorizontal,color:Y.colors.field.label,style:O}),ze=(0,_react.useMemo)(()=>m.find(e=>e.iso===ue.iso),[m,ue.iso]),we=planOf(ue.iso),qe=E&&we?(0,_mobileCore.formatPhoneAsTyped)(ue.nationalNumber,we):ue.nationalNumber,ke=ee(ue.iso),Me=0===ue.nationalNumber.length||pe||!Number.isFinite(ke)?void 0:qe.length+Math.max(0,ke-ue.nationalNumber.length),Ve=ne(ue);(0,_react.useEffect)(()=>{Te||ge(!1)},[Te]);const Be=we?(0,_mobileCore.maxNationalNumberLength)(we,!1===v?"any":v):Number.POSITIVE_INFINITY,$e=ue.nationalNumber.length>=Be,Ge=!1!==v&&!1!==R&&Te&&!Ve&&(he||$e),Ue="mobile"===v?"Enter a valid mobile number":"Enter a valid number",We=(0,_index4.hasFieldText)(P)?P:Ge?R||Ue:void 0,He=!0===P||(0,_index4.hasFieldText)(We),Ye=(0,_react.useRef)(Ve),Ke=(0,_react.useRef)(ue);Ke.current=ue,(0,_react.useEffect)(()=>{Ye.current!==Ve&&(Ye.current=Ve,b?.(Ve),Ve&&d?.(formatE164(Ke.current)))},[Ve,d,b]);const Je=(0,_react.useCallback)(e=>{if(e.includes("+")){const t=ie(e,ue.iso);if(t&&!I&&Q.some(e=>e.iso===t.iso))return void ce(t);if(t&&t.iso===ue.iso)return void ce(t)}ce({...ue,nationalNumber:te(digitsOnly(e),ue.iso)})},[Q,I,ue,ie,te,ce]),Qe=(0,_react.useCallback)(e=>{const t=e;ce({callingCode:t.code,iso:t.iso,nationalNumber:te(ue.nationalNumber,t.iso)}),Ce(!1);const i=(0,_index3.resolveHaptic)(V,"selection");i&&(0,_index3.triggerHaptic)(i)},[ue,V,te,ce]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>J.current?.focus(),blur:()=>J.current?.blur(),clear:()=>ce({...Ke.current,nationalNumber:""}),isFocused:()=>J.current?.isFocused()??!1,getValue:()=>Ke.current,getE164:()=>formatE164(Ke.current),getFormatted:()=>{const e=Ke.current,t=planOf(e.iso);return t?(0,_mobileCore.formatPhoneAsTyped)(e.nationalNumber,t):e.nationalNumber},isValid:()=>ne(Ke.current),getCountry:()=>m.find(e=>e.iso===Ke.current.iso)}),[m,ne,ce]);const Xe=z||I,Ze=(0,_jsxRuntime.jsx)(_index4.FieldBase,{size:w,variant:ve,borderRadius:Ee,topNotch:De.topNotch,focused:de,disabled:z,error:He,filled:Te,onPress:me,pressFeedback:!1,leadingDivider:!0,paddingLeft:Le?0:void 0,leading:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{Xe||(Ne.current=!0,Ce(!0))},disabled:Xe,accessibilityRole:"button",accessibilityLabel:$??`Country code, currently +${ue.callingCode}`,accessibilityState:{disabled:Xe},"aria-disabled":Xe,hitSlop:6,onLayout:e=>{const{width:t}=e.nativeEvent.layout;Fe(e=>e===t?e:t)},style:K.codeTrigger,testID:H?`${H}-code`:void 0,children:[Z(ze,ye.fontSize,H?`${H}-flag`:void 0),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[K.codeText,{color:Se.color,fontSize:ye.fontSize}],children:`+${ue.callingCode}`}),I?null:(0,_jsxRuntime.jsx)(_Chevron.Chevron,{color:z?Y.colors.field.iconDisabled:Y.colors.field.icon,size:ye.iconSize,open:xe})]}),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:K.inputWrap,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:J,value:qe,maxLength:Me,onChangeText:Je,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:c,onSelectionChange:e=>{const{start:t,end:i}=e.nativeEvent.selection;fe(t!==i)},onFocus:()=>{be(!0),G?.()},onBlur:()=>{be(!1),Te&&!Ne.current&&ge(!0),U?.()},editable:!z,placeholder:Re&&!Pe||Ae?void 0:T,placeholderTextColor:Se.placeholderColor,accessibilityLabel:B??j??T,selectionColor:Y.colors.field.caret,keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",style:[K.input,{color:Se.color,fontSize:ye.fontSize,...Se.weightStyle,paddingLeft:Le?0:void 0}],testID:H?`${H}-input`:void 0}),Ae?(0,_jsxRuntime.jsx)(_index4.RequiredPlaceholder,{text:T,color:Se.placeholderColor,fontSize:ye.fontSize,weightStyle:Se.weightStyle}):null]})});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:W,testID:H,children:[j&&"top"===F?(0,_jsxRuntime.jsx)(_index4.FieldLabel,{size:w,required:D,children:j}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:K.fieldWrapper,children:[Ze,De.node]}),(0,_jsxRuntime.jsx)(_index4.FieldMessage,{size:w,error:He,text:He?We:A}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:xe,onClose:()=>Ce(!1),title:M,options:Q,sections:X,labelOf:e=>`${e.label} (+${e.code})`,getValue:e=>e.iso,disabledOf:()=>!1,descriptionOf:()=>{},iconOf:e=>Z(e,Y.typography.fontSize.lg),renderOption:C?(e,t)=>C(e,{selected:t.selected}):void 0,isSelected:e=>e===ze?.iso,onSelect:Qe,searchable:Q.length>8,searchPlaceholder:N,alphabetIndex:y??Q.length>20})]})});PhoneNumberInput.displayName="PhoneNumberInput";const buildStyles=e=>_reactNative.StyleSheet.create({fieldWrapper:{position:"relative",overflow:"visible"},codeTrigger:{flexDirection:"row",alignItems:"center",gap:2},flag:{includeFontPadding:!1,marginRight:4},codeText:{...(0,_index2.fontFor)(e,"semibold"),fontWeight:"600",includeFontPadding:!1,writingDirection:"ltr"},input:{padding:0,margin:0,includeFontPadding:!1,writingDirection:"ltr"},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"}});var _default=exports.default=PhoneNumberInput;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ProfilePicker=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_index3=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../Avatar/index.js"),_index5=require("../FieldBase/index.js"),_FilePicker=require("../FilePicker/FilePicker.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index6=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_LABELS={pick:"Change profile photo",remove:"Remove photo",sheetTitle:"Change photo",errorTooLarge:e=>`The photo is larger than ${e} MB.`,errorWrongType:"That file is not a supported image."},DEFAULT_ACCEPT=["image/*"],SHEET_ICON_SIZE=20,SOFT_FILL_OPACITY=.14,SIZE_PX={sm:72,md:120,lg:160},clamp=(e,r,t)=>Math.min(t,Math.max(r,e)),toneFor=(e,r)=>{switch(r){case"success":return{base:e.colors.success,on:e.colors.onSuccess};case"warning":return{base:e.colors.warning,on:e.colors.onWarning};case"error":return{base:e.colors.error,on:e.colors.onError};case"info":return{base:e.colors.info,on:e.colors.onInfo};case"neutral":return{base:e.colors.text.secondary,on:e.colors.text.inverse};default:return{base:e.colors.primary,on:e.colors.onPrimary}}},badgeLookFor=(e,r,t,o)=>{const i=toneFor(e,r),n=o?.badgeColor??i.base,s=e.colors.background.primary,l="neutral"===r&&void 0===o?.badgeColor;let a;switch(t){case"soft":a={fill:l?e.colors.background.tertiary:(0,_color.blendOf)(n,.14,s,e.colors.background.secondary),ring:s,icon:n};break;case"outline":a={fill:s,ring:l?e.colors.border.primary:n,icon:n};break;default:a={fill:n,ring:s,icon:i.on}}return o?.badgeIconColor?{...a,icon:o.badgeIconColor}:a},resolveRadius=(e,r)=>"circle"===e?r/2:"rounded"===e?Math.max(6,Math.round(.22*r)):0,REMOVE_VALUE="__profile-picker-remove__",ProfilePicker=exports.ProfilePicker=(0,_react.forwardRef)((e,r)=>{const{value:t,name:o,sources:i,onPick:n,onRemove:s,loading:l=!1,disabled:a=!1,accept:c=DEFAULT_ACCEPT,maxSizeMB:u,size:d="md",shape:_="circle",badgeIcon:m="camera",tone:x,variant:p,avatarTone:b,avatarBackgroundColor:g,avatarColor:h,label:y,required:f=!1,helperText:v,error:j,layout:k="stacked",title:C,subtitle:S,ImageComponent:R,labels:I,haptic:T,onError:P,accessibilityLabel:F,style:E,testID:w}=e,A=(0,_index.useTheme)(),L=A.components.profilePicker,M=x??L?.defaultTone??"primary",O=p??L?.defaultVariant??"solid",q=(0,_react.useMemo)(()=>badgeLookFor(A,M,O,L),[A,M,O,L]),N=b??L?.defaultAvatarTone,z=(0,_react.useMemo)(()=>{const e=N?(0,_index4.avatarToneColors)(A,N):null;return{background:g??e?.background??A.colors.background.tertiary,icon:h??e?.color??A.colors.text.tertiary}},[A,N,g,h]),V=(0,_react.useMemo)(()=>({...DEFAULT_LABELS,...I}),[I]),[D,B]=(0,_react.useState)(null),[H,U]=(0,_react.useState)(null),[W,$]=(0,_react.useState)(!1),[Z,G]=(0,_react.useState)(t);t!==Z&&(G(t),B(null));const X=l||a,Q=D??t??null,Y=j??H??void 0,J=!X&&(null!==D||Boolean(t)&&Boolean(s)),K=i.length>0||J,ee="number"==typeof d?d:SIZE_PX[d],re=resolveRadius(_,ee),te=re*(1-Math.SQRT1_2),oe=clamp(Math.round(.28*ee),24,44),ie=te-oe/2,ne=Math.max(0,-ie),se=(0,_react.useCallback)(e=>{U(e),P?.(e),!1!==T&&(0,_index2.triggerHaptic)("notificationError")},[P,T]),le=(0,_react.useCallback)(async e=>{let r;try{r=await e.pick()}catch(e){return void se(e instanceof Error?e.message:String(e))}const t=r?.[0];if(!t)return;if("number"==typeof u&&"number"==typeof t.size&&t.size>1024*u*1024)return void se(V.errorTooLarge(u));if(t.type&&!(0,_FilePicker.matchesAccept)(t.type,c))return void se(V.errorWrongType);U(null),B(t.uri);const o=(0,_index2.resolveHaptic)(T,"selection");o&&(0,_index2.triggerHaptic)(o),n?.(t)},[u,c,V,T,n,se]),ae=(0,_react.useCallback)(()=>{X||(de.current=null,1!==i.length||J?(i.length>0||J)&&$(!0):le(i[0]))},[X,i,J,le]),ce=(0,_react.useCallback)(()=>{B(null),U(null);const e=(0,_index2.resolveHaptic)(T,"selection");e&&(0,_index2.triggerHaptic)(e),s?.()},[T,s]),ue=(0,_react.useMemo)(()=>{const e=i.map(e=>({kind:"source",source:e}));return J&&e.push({kind:"remove"}),e},[i,J]),de=(0,_react.useRef)(null),_e=(0,_react.useCallback)(e=>{de.current||($(!1),"remove"===e.kind?ce():de.current=e.source)},[ce]),me=(0,_react.useCallback)(()=>{const e=de.current;de.current=null,e&&le(e)},[le]),xe=w??"profile-picker",pe=F??(K?V.pick:o),be=(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.fill,{width:ee,height:ee,borderRadius:re,..._corners.smoothCorners,backgroundColor:z.background}],children:(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"user",size:Math.round(.45*ee),color:z.icon})}),ge=(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:ee,height:ee,marginBottom:ne,marginRight:ne},children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:ae,disabled:X||!K,accessibilityRole:K?"button":"image",accessibilityLabel:pe,accessibilityHint:(0,_index5.fieldTextAsString)(Y),accessibilityState:K?{disabled:X,busy:l}:{busy:l},"aria-disabled":K?X:void 0,"aria-busy":l,testID:`${xe}-button`,style:({pressed:e})=>[{width:ee,height:ee,borderRadius:re,..._corners.smoothCorners},{opacity:a?.55:e?.85:1}],children:[Q||o?(0,_jsxRuntime.jsx)(_index4.Avatar,{source:Q?{uri:Q}:void 0,name:o,size:ee,shape:_,tone:N,backgroundColor:g,color:h,ImageComponent:R,accessibilityLabel:pe},Q??"initials"):be,l?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.fill,styles.overlay,{borderRadius:re,..._corners.smoothCorners,backgroundColor:A.colors.background.overlay}],testID:`${xe}-loading`,children:(0,_jsxRuntime.jsx)(_index6.Spinner,{size:ee>=100?"md":"sm",color:A.colors.onPrimary})}):null,!a&&K?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:`${xe}-badge`,style:[styles.badge,{width:oe,height:oe,borderRadius:oe/2,..._corners.smoothCorners,right:ie,bottom:ie,backgroundColor:q.fill,borderColor:q.ring}],children:(0,_slotIcon.renderSlotIcon)(m,{color:q.icon,size:Math.round(.55*oe),disabled:!1})}):null]})}),he="stacked"!==k?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.meta,"profile"===k?styles.metaCentred:null],children:[C?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.title,"profile"===k?styles.textCentred:null,{color:A.colors.text.primary,fontSize:A.typography.fontSize.base,...(0,_index.fontFor)(A,"semibold")}],children:C}):null,S?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.subtitle,"profile"===k?styles.textCentred:null,{color:A.colors.text.secondary,fontSize:A.typography.fontSize.sm,...(0,_index.fontFor)(A,"normal")}],children:S}):null,(0,_jsxRuntime.jsx)(_index5.FieldMessage,{text:Y??v,error:(0,_index5.hasFieldText)(Y)})]}):(0,_jsxRuntime.jsx)(_index5.FieldMessage,{text:Y??v,error:(0,_index5.hasFieldText)(Y)});return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:r,style:E,testID:w,children:[y?(0,_jsxRuntime.jsx)(_index5.FieldLabel,{required:f,children:y}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:"inline"===k?[styles.row,{columnGap:A.spacing.md}]:["profile"===k?styles.columnCentred:styles.column,{rowGap:A.spacing.xs}],children:[ge,he]}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:W,onClose:()=>$(!1),onAfterClose:me,title:V.sheetTitle,options:ue,labelOf:e=>{const r=e;return"remove"===r.kind?V.remove:r.source.label},getValue:e=>{const r=e;return"remove"===r.kind?REMOVE_VALUE:r.source.key},disabledOf:()=>!1,destructiveOf:e=>"remove"===e.kind,descriptionOf:e=>{const r=e;return"remove"===r.kind?void 0:r.source.description},iconOf:e=>{const r=e;return"remove"===r.kind?(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"trash",size:20,color:A.colors.toneText.error}):r.source.icon},isSelected:()=>!1,onSelect:e=>_e(e)})]})});ProfilePicker.displayName="ProfilePicker";const styles=_reactNative.StyleSheet.create({fill:{alignItems:"center",justifyContent:"center",overflow:"hidden"},overlay:{..._reactNative.StyleSheet.absoluteFill},badge:{position:"absolute",alignItems:"center",justifyContent:"center",borderWidth:2},row:{flexDirection:"row",alignItems:"center"},column:{alignItems:"flex-start"},columnCentred:{alignItems:"center"},meta:{flexShrink:1},metaCentred:{alignItems:"center"},title:{includeFontPadding:!1},subtitle:{includeFontPadding:!1,marginTop:2},textCentred:{textAlign:"center"}});var _default=exports.default=ProfilePicker;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ProfilePicker=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_index3=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../Avatar/index.js"),_index5=require("../FieldBase/index.js"),_FilePicker=require("../FilePicker/FilePicker.js"),_OptionSheet=require("../OptionSheet/OptionSheet.js"),_index6=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_LABELS={pick:"Change profile photo",remove:"Remove photo",sheetTitle:"Change photo",errorTooLarge:e=>`The photo is larger than ${e} MB.`,errorWrongType:"That file is not a supported image."},DEFAULT_ACCEPT=["image/*"],SHEET_ICON_SIZE=20,SOFT_FILL_OPACITY=.14,SIZE_PX={sm:72,md:120,lg:160},clamp=(e,r,t)=>Math.min(t,Math.max(r,e)),toneFor=(e,r)=>{switch(r){case"success":return{base:e.colors.success,on:e.colors.onSuccess};case"warning":return{base:e.colors.warning,on:e.colors.onWarning};case"error":return{base:e.colors.error,on:e.colors.onError};case"info":return{base:e.colors.info,on:e.colors.onInfo};case"neutral":return{base:e.colors.text.secondary,on:e.colors.text.inverse};default:return{base:e.colors.primary,on:e.colors.onPrimary}}},badgeLookFor=(e,r,t,o)=>{const i=toneFor(e,r),n=o?.badgeColor??i.base,s=e.colors.background.primary,l="neutral"===r&&void 0===o?.badgeColor;let a;switch(t){case"soft":a={fill:l?e.colors.background.tertiary:(0,_color.blendOf)(n,.14,s,e.colors.background.secondary),ring:s,icon:n};break;case"outline":a={fill:s,ring:l?e.colors.border.primary:n,icon:n};break;default:a={fill:n,ring:s,icon:i.on}}return o?.badgeIconColor?{...a,icon:o.badgeIconColor}:a},resolveRadius=(e,r)=>"circle"===e?r/2:"rounded"===e?Math.max(6,Math.round(.22*r)):0,REMOVE_VALUE="__profile-picker-remove__",ProfilePicker=exports.ProfilePicker=(0,_react.forwardRef)((e,r)=>{const{value:t,name:o,sources:i,onPick:n,onRemove:s,loading:l=!1,disabled:a=!1,accept:c=DEFAULT_ACCEPT,maxSizeMB:u,size:d="md",shape:_="circle",badgeIcon:m="camera",tone:x,variant:p,avatarTone:b,avatarBackgroundColor:g,avatarColor:h,label:y,required:f=!1,helperText:v,error:j,layout:k="stacked",title:C,subtitle:S,ImageComponent:R,labels:I,haptic:T,onError:P,accessibilityLabel:F,style:E,testID:w}=e,A=(0,_index.useTheme)(),L=A.components.profilePicker,M=x??L?.defaultTone??"primary",O=p??L?.defaultVariant??"solid",q=(0,_react.useMemo)(()=>badgeLookFor(A,M,O,L),[A,M,O,L]),N=b??L?.defaultAvatarTone,z=(0,_react.useMemo)(()=>{const e=N?(0,_index4.avatarToneColors)(A,N):null;return{background:g??e?.background??A.colors.background.tertiary,icon:h??e?.color??A.colors.text.tertiary}},[A,N,g,h]),V=(0,_react.useMemo)(()=>({...DEFAULT_LABELS,...I}),[I]),[D,B]=(0,_react.useState)(null),[H,U]=(0,_react.useState)(null),[W,$]=(0,_react.useState)(!1),[Z,G]=(0,_react.useState)(t);t!==Z&&(G(t),B(null));const X=l||a,Q=D??t??null,Y=j??H??void 0,J=!X&&(null!==D||Boolean(t)&&Boolean(s)),K=i.length>0||J,ee="number"==typeof d?d:SIZE_PX[d],re=resolveRadius(_,ee),te=re*(1-Math.SQRT1_2),oe=clamp(Math.round(.28*ee),24,44),ie=te-oe/2,ne=Math.max(0,-ie),se=(0,_react.useCallback)(e=>{U(e),P?.(e),!1!==T&&(0,_index2.triggerHaptic)("notificationError")},[P,T]),le=(0,_react.useCallback)(async e=>{let r;try{r=await e.pick()}catch(e){return void se(e instanceof Error?e.message:String(e))}const t=r?.[0];if(!t)return;if("number"==typeof u&&"number"==typeof t.size&&t.size>1024*u*1024)return void se(V.errorTooLarge(u));if(t.type&&!(0,_FilePicker.matchesAccept)(t.type,c))return void se(V.errorWrongType);U(null),B(t.uri);const o=(0,_index2.resolveHaptic)(T,"selection");o&&(0,_index2.triggerHaptic)(o),n?.(t)},[u,c,V,T,n,se]),ae=(0,_react.useCallback)(()=>{X||(de.current=null,1!==i.length||J?(i.length>0||J)&&$(!0):le(i[0]))},[X,i,J,le]),ce=(0,_react.useCallback)(()=>{B(null),U(null);const e=(0,_index2.resolveHaptic)(T,"selection");e&&(0,_index2.triggerHaptic)(e),s?.()},[T,s]),ue=(0,_react.useMemo)(()=>{const e=i.map(e=>({kind:"source",source:e}));return J&&e.push({kind:"remove"}),e},[i,J]),de=(0,_react.useRef)(null),me=(0,_react.useCallback)(e=>{de.current||($(!1),"remove"===e.kind?ce():de.current=e.source)},[ce]),xe=(0,_react.useCallback)(()=>{const e=de.current;de.current=null,e&&le(e)},[le]),pe=w??"profile-picker",be=F??(K?V.pick:o),ge=(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.fill,{width:ee,height:ee,borderRadius:re,..._corners.smoothCorners,backgroundColor:z.background}],children:(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"user",size:Math.round(.45*ee),color:z.icon})}),he=(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:ee,height:ee,marginBottom:ne,marginRight:ne},children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:ae,disabled:X||!K,accessibilityRole:K?"button":"image",accessibilityLabel:be,accessibilityHint:(0,_index5.fieldTextAsString)(Y),accessibilityState:K?{disabled:X,busy:l}:{busy:l},"aria-disabled":K?X:void 0,"aria-busy":l,testID:`${pe}-button`,style:({pressed:e})=>[{width:ee,height:ee,borderRadius:re,..._corners.smoothCorners},{opacity:a?.55:e?.85:1}],children:[Q||o?(0,_jsxRuntime.jsx)(_index4.Avatar,{source:Q?{uri:Q}:void 0,name:o,size:ee,shape:_,tone:N,backgroundColor:g,color:h,ImageComponent:R,accessibilityLabel:be},Q??"initials"):ge,l?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.fill,styles.overlay,{borderRadius:re,..._corners.smoothCorners,backgroundColor:A.colors.background.overlay}],testID:`${pe}-loading`,children:(0,_jsxRuntime.jsx)(_index6.Spinner,{size:ee>=100?"md":"sm",color:A.colors.onPrimary})}):null,!a&&K?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:`${pe}-badge`,style:[styles.badge,{width:oe,height:oe,borderRadius:oe/2,..._corners.smoothCorners,right:ie,bottom:ie,backgroundColor:q.fill,borderColor:q.ring}],children:(0,_slotIcon.renderSlotIcon)(m,{color:q.icon,size:Math.round(.55*oe),disabled:!1})}):null]})}),ye="stacked"!==k?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.meta,"profile"===k?styles.metaCentred:null],children:[C?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.title,"profile"===k?styles.textCentred:null,{color:A.colors.text.primary,fontSize:A.typography.fontSize.base,...(0,_index.fontFor)(A,"semibold")}],children:C}):null,S?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.subtitle,"profile"===k?styles.textCentred:null,{color:A.colors.text.secondary,fontSize:A.typography.fontSize.sm,...(0,_index.fontFor)(A,"normal")}],children:S}):null,(0,_jsxRuntime.jsx)(_index5.FieldMessage,{text:Y??v,error:(0,_index5.hasFieldText)(Y)})]}):(0,_jsxRuntime.jsx)(_index5.FieldMessage,{text:Y??v,error:(0,_index5.hasFieldText)(Y)});return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:r,style:E,testID:w,children:[y?(0,_jsxRuntime.jsx)(_index5.FieldLabel,{required:f,children:y}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:"inline"===k?[styles.row,{columnGap:A.spacing.md}]:["profile"===k?styles.columnCentred:styles.column,{rowGap:A.spacing.xs}],children:[he,ye]}),(0,_jsxRuntime.jsx)(_OptionSheet.OptionSheet,{open:W,onClose:()=>$(!1),onAfterClose:xe,title:V.sheetTitle,options:ue,labelOf:e=>{const r=e;return"remove"===r.kind?V.remove:r.source.label},getValue:e=>{const r=e;return"remove"===r.kind?REMOVE_VALUE:r.source.key},disabledOf:()=>!1,destructiveOf:e=>"remove"===e.kind,descriptionOf:e=>{const r=e;return"remove"===r.kind?void 0:r.source.description},iconOf:e=>{const r=e;return"remove"===r.kind?(0,_jsxRuntime.jsx)(_index3.AppIcon,{name:"trash",size:20,color:A.colors.toneText.error}):r.source.icon},isSelected:()=>!1,onSelect:e=>me(e)})]})});ProfilePicker.displayName="ProfilePicker";const styles=_reactNative.StyleSheet.create({fill:{alignItems:"center",justifyContent:"center",overflow:"hidden"},overlay:{..._reactNative.StyleSheet.absoluteFill},badge:{position:"absolute",alignItems:"center",justifyContent:"center",borderWidth:2},row:{flexDirection:"row",alignItems:"center"},column:{alignItems:"flex-start"},columnCentred:{alignItems:"center"},meta:{flexShrink:1},metaCentred:{alignItems:"center"},title:{includeFontPadding:!1},subtitle:{includeFontPadding:!1,marginTop:2},textCentred:{textAlign:"center"}});var _default=exports.default=ProfilePicker;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SearchBar=void 0;var _react=require("react"),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_useDebounce=require("../../hooks/useDebounce.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_SearchPanel=require("./SearchPanel.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PANEL_ROWS=8,HOLD_RELEASE_MS=50,SearchBar=exports.SearchBar=(0,_react.forwardRef)((e,a)=>{const{value:t,onChangeText:l,onSubmit:s,onFocus:r,onBlur:c,placeholder:i="Search…",autoFocus:n=!1,disabled:o=!1,onClear:u,leftIcon:d,debounceMs:_,size:b="md",variant:h,borderRadius:p,label:S,labelMode:g="top",labelStyle:f,scopes:v,scope:m,onScopeChange:x,recents:R,recentsTitle:j="Recent searches",maxRecents:C=DEFAULT_PANEL_ROWS,onSelectRecent:y,onRemoveRecent:F,onClearRecents:B,suggestions:k,maxSuggestions:L=DEFAULT_PANEL_ROWS,onSelectSuggestion:z,haptic:I,style:q,inputStyle:E,accessibilityLabel:P,testID:T,...N}=e,H=(0,_index.useTheme)(),D=h??H.components.searchBar?.defaultVariant??H.components.field?.defaultVariant??"filled",w="underline"===D,A=(0,_FieldBase.resolveFieldSize)(H,b),U={...A,...H.components.searchBar?.[b]??{}},M=(0,_FieldBase.resolveFieldTextStyle)(H,{disabled:o}),O=(0,_react.useRef)(null),V=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(O,a),[a]),W=(0,_react.useCallback)(()=>{o||O.current?.focus()},[o]),$=(0,_react.useMemo)(()=>buildStyles(H),[H]),K="string"==typeof t?t:"",[G,J]=(0,_react.useState)(!1),Q=(0,_react.useCallback)(e=>{J(!0),r?.(e)},[r]),X=(0,_react.useCallback)(e=>{J(!1),c?.(e)},[c]),[Y,Z]=(0,_react.useState)(K),ee=(0,_useDebounce.useDebounce)(Y,_??0);(0,_react.useEffect)(()=>{void 0!==_&&K!==Y&&Z(K)},[K,_]);const ae=(0,_react.useRef)(K);(0,_react.useEffect)(()=>{void 0!==_&&ee!==ae.current&&(ae.current=ee,l(ee))},[ee,_,l]);const te=(0,_react.useCallback)(e=>{void 0===_?l(e):Z(e)},[_,l]),le=(0,_react.useCallback)(()=>{const e=(0,_hapticUtils.resolveHaptic)(I,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),void 0!==_&&(Z(""),ae.current=""),l(""),u?.()},[I,_,l,u]),se=(0,_react.useCallback)(()=>{s?.(void 0!==_?Y:K)},[s,_,Y,K]),re=void 0!==_?Y:K,ce=re.length>0,[ie,ne]=(0,_useControllableState.useControllableState)({value:m,defaultValue:v?.[0]?.value??"",onChange:x}),oe=(0,_react.useCallback)(e=>{ne(e);const a=v?.find(a=>a.value===e)?.label;a&&(0,_announce.announce)(`Searching ${a}`)},[v,ne]),[ue,de]=(0,_react.useState)(!1),_e=(0,_react.useRef)(null),be=(0,_react.useCallback)(()=>{_e.current&&(clearTimeout(_e.current),_e.current=null)},[]),he=(0,_react.useCallback)(()=>{be(),de(!0)},[be]),pe=(0,_react.useCallback)(()=>{be(),_e.current=setTimeout(()=>de(!1),50)},[be]);(0,_react.useEffect)(()=>be,[be]);const Se=!o&&(G||ue),ge=(0,_react.useMemo)(()=>(R??[]).slice(0,C),[R,C]),fe=(0,_react.useMemo)(()=>(k??[]).slice(0,L).map(_SearchPanel.normalizeSuggestion),[k,L]),ve=Se&&!ce&&ge.length>0,me=Se&&ce&&fe.length>0,xe=me?fe.length:0;(0,_react.useEffect)(()=>{xe>0&&(0,_announce.announce)(1===xe?"1 suggestion":`${xe} suggestions`)},[xe]);const Re=(0,_react.useCallback)(()=>{const e=(0,_hapticUtils.resolveHaptic)(I,"selection");e&&(0,_hapticUtils.triggerHaptic)(e)},[I]),je=(0,_react.useCallback)(e=>{Re(),O.current?.blur(),de(!1),y?.(e)},[Re,y]),Ce=(0,_react.useCallback)(e=>{Re(),O.current?.blur(),de(!1),z?.(e)},[Re,z]),ye=(0,_react.useCallback)(e=>{Re(),F?.(e),(0,_announce.announce)(`Removed ${e}`),W()},[Re,F,W]),Fe=(0,_react.useCallback)(()=>{Re(),B?.(),(0,_announce.announce)("Recent searches cleared"),W()},[Re,B,W]),Be={size:U.iconSize,color:o?H.colors.text.disabled:H.colors.text.tertiary,disabled:o},ke=d?(0,_slotIcon.renderSlotIcon)(d,Be):(H.icons?.search??_defaultIcons.defaultIcons.search)(Be),Le=Boolean(S)&&"float"===g,ze=(0,_useFloatingLabel.useFloatingLabel)({label:S,enabled:Le,floated:G||ce,variant:D,sizeTokens:{...A,...U},leadingOffset:U.iconSize+H.spacing.md,trailingOffset:ce?U.iconSize+H.spacing.md:0,paddingLeft:w?0:U.paddingHorizontal,color:H.colors.field.label,style:f}),Ie=ce&&!o?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:le,hitSlop:8,accessibilityRole:"button",accessibilityLabel:"Clear search",children:(H.icons?.close??_defaultIcons.defaultIcons.close)({size:U.iconSize,color:H.colors.text.secondary})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:q,testID:T,children:[S&&!Le?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:b,style:f,children:S}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:$.root,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$.fieldWrap,children:[(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{size:b,variant:D,focused:G,disabled:o,filled:ce,minHeight:U.minHeight,paddingHorizontal:w?0:U.paddingHorizontal,borderRadius:p??U.borderRadius,leading:ke,trailing:Ie,topNotch:ze.topNotch,onPress:W,pressFeedback:!1,accessibilityRole:"search",accessibilityLabel:P??i,children:(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:V,style:[$.input,{fontSize:U.fontSize,color:M.color,...M.weightStyle},E],value:re,onChangeText:te,onSubmitEditing:se,onFocus:Q,onBlur:X,placeholder:!Le||G||ce?i:void 0,placeholderTextColor:M.placeholderColor,autoFocus:n,editable:!o,returnKeyType:"search",selectionColor:(0,_FieldBase.resolveVariantColors)(H,D).borderFocusedRepresentative,accessibilityLabel:P??i,accessibilityState:{disabled:o},"aria-disabled":o,...N})}),ze.node]})}),v&&v.length>0?(0,_jsxRuntime.jsx)(_SearchPanel.SearchScopeBar,{scopes:v,scope:ie||(v[0]?.value??""),disabled:o,haptic:I,onChange:oe}):null,ve?(0,_jsxRuntime.jsx)(_SearchPanel.SearchRecents,{recents:ge,title:j,onSelect:je,onRemove:F?ye:void 0,onClear:B?Fe:void 0,onHold:he,onRelease:pe}):null,me?(0,_jsxRuntime.jsx)(_SearchPanel.SearchSuggestions,{suggestions:fe,query:re,onSelect:Ce,onHold:he,onRelease:pe}):null]})});SearchBar.displayName="SearchBar";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flexDirection:"row",alignItems:"center",width:"100%",position:"relative",overflow:"visible"},fieldWrap:{flex:1,position:"relative",overflow:"visible"},input:{flex:1,padding:0,margin:0,includeFontPadding:!1}});var _default=exports.default=SearchBar;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SearchBar=void 0;var _react=require("react"),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_useDebounce=require("../../hooks/useDebounce.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_useFloatingLabel=require("../FieldBase/useFloatingLabel.js"),_SearchPanel=require("./SearchPanel.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_PANEL_ROWS=8,HOLD_RELEASE_MS=50,SearchBar=exports.SearchBar=(0,_react.forwardRef)((e,a)=>{const{value:t,onChangeText:l,onSubmit:s,onFocus:r,onBlur:c,placeholder:i="Search…",autoFocus:n=!1,disabled:o=!1,onClear:u,leftIcon:d,debounceMs:_,size:b="md",variant:h,borderRadius:p,label:S,labelMode:g="top",labelStyle:f,scopes:v,scope:m,onScopeChange:x,recents:R,recentsTitle:j="Recent searches",maxRecents:C=DEFAULT_PANEL_ROWS,onSelectRecent:y,onRemoveRecent:F,onClearRecents:B,suggestions:k,maxSuggestions:L=DEFAULT_PANEL_ROWS,onSelectSuggestion:z,haptic:I,style:q,inputStyle:E,accessibilityLabel:P,testID:T,...N}=e,H=(0,_index.useTheme)(),D=h??H.components.searchBar?.defaultVariant??H.components.field?.defaultVariant??"filled",w="underline"===D,A=(0,_FieldBase.resolveFieldSize)(H,b),U={...A,...H.components.searchBar?.[b]??{}},M=(0,_FieldBase.resolveFieldTextStyle)(H,{disabled:o}),O=(0,_react.useRef)(null),V=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(O,a),[a]),W=(0,_react.useCallback)(()=>{o||O.current?.focus()},[o]),$=(0,_react.useMemo)(()=>buildStyles(H),[H]),K="string"==typeof t?t:"",[G,J]=(0,_react.useState)(!1),Q=(0,_react.useCallback)(e=>{J(!0),r?.(e)},[r]),X=(0,_react.useCallback)(e=>{J(!1),c?.(e)},[c]),[Y,Z]=(0,_react.useState)(K),ee=(0,_useDebounce.useDebounce)(Y,_??0);(0,_react.useEffect)(()=>{void 0!==_&&K!==Y&&Z(K)},[K,_]);const ae=(0,_react.useRef)(K);(0,_react.useEffect)(()=>{void 0!==_&&ee!==ae.current&&(ae.current=ee,l(ee))},[ee,_,l]);const te=(0,_react.useCallback)(e=>{void 0===_?l(e):Z(e)},[_,l]),le=(0,_react.useCallback)(()=>{const e=(0,_hapticUtils.resolveHaptic)(I,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),void 0!==_&&(Z(""),ae.current=""),l(""),u?.()},[I,_,l,u]),se=(0,_react.useCallback)(()=>{s?.(void 0!==_?Y:K)},[s,_,Y,K]),re=void 0!==_?Y:K,ce=re.length>0,[ie,ne]=(0,_useControllableState.useControllableState)({value:m,defaultValue:v?.[0]?.value??"",onChange:x}),oe=(0,_react.useCallback)(e=>{ne(e);const a=v?.find(a=>a.value===e)?.label;a&&(0,_announce.announce)(`Searching ${a}`)},[v,ne]),[ue,de]=(0,_react.useState)(!1),be=(0,_react.useRef)(null),he=(0,_react.useCallback)(()=>{be.current&&(clearTimeout(be.current),be.current=null)},[]),pe=(0,_react.useCallback)(()=>{he(),de(!0)},[he]),Se=(0,_react.useCallback)(()=>{he(),be.current=setTimeout(()=>de(!1),50)},[he]);(0,_react.useEffect)(()=>he,[he]);const ge=!o&&(G||ue),fe=(0,_react.useMemo)(()=>(R??[]).slice(0,C),[R,C]),ve=(0,_react.useMemo)(()=>(k??[]).slice(0,L).map(_SearchPanel.normalizeSuggestion),[k,L]),me=ge&&!ce&&fe.length>0,xe=ge&&ce&&ve.length>0,Re=xe?ve.length:0;(0,_react.useEffect)(()=>{Re>0&&(0,_announce.announce)(1===Re?"1 suggestion":`${Re} suggestions`)},[Re]);const je=(0,_react.useCallback)(()=>{const e=(0,_hapticUtils.resolveHaptic)(I,"selection");e&&(0,_hapticUtils.triggerHaptic)(e)},[I]),Ce=(0,_react.useCallback)(e=>{je(),O.current?.blur(),de(!1),y?.(e)},[je,y]),ye=(0,_react.useCallback)(e=>{je(),O.current?.blur(),de(!1),z?.(e)},[je,z]),Fe=(0,_react.useCallback)(e=>{je(),F?.(e),(0,_announce.announce)(`Removed ${e}`),W()},[je,F,W]),Be=(0,_react.useCallback)(()=>{je(),B?.(),(0,_announce.announce)("Recent searches cleared"),W()},[je,B,W]),ke={size:U.iconSize,color:o?H.colors.text.disabled:H.colors.text.tertiary,disabled:o},Le=d?(0,_slotIcon.renderSlotIcon)(d,ke):(H.icons?.search??_defaultIcons.defaultIcons.search)(ke),ze=Boolean(S)&&"float"===g,Ie=(0,_useFloatingLabel.useFloatingLabel)({label:S,enabled:ze,floated:G||ce,variant:D,sizeTokens:{...A,...U},leadingOffset:U.iconSize+H.spacing.md,trailingOffset:ce?U.iconSize+H.spacing.md:0,paddingLeft:w?0:U.paddingHorizontal,color:H.colors.field.label,style:f}),qe=ce&&!o?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:le,hitSlop:8,accessibilityRole:"button",accessibilityLabel:"Clear search",children:(H.icons?.close??_defaultIcons.defaultIcons.close)({size:U.iconSize,color:H.colors.text.secondary})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:q,testID:T,children:[S&&!ze?(0,_jsxRuntime.jsx)(_FieldBase.FieldLabel,{size:b,style:f,children:S}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:$.root,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$.fieldWrap,children:[(0,_jsxRuntime.jsx)(_FieldBase.FieldBase,{size:b,variant:D,focused:G,disabled:o,filled:ce,minHeight:U.minHeight,paddingHorizontal:w?0:U.paddingHorizontal,borderRadius:p??U.borderRadius,leading:Le,trailing:qe,topNotch:Ie.topNotch,onPress:W,pressFeedback:!1,accessibilityRole:"search",accessibilityLabel:P??i,children:(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:V,style:[$.input,{fontSize:U.fontSize,color:M.color,...M.weightStyle},E],value:re,onChangeText:te,onSubmitEditing:se,onFocus:Q,onBlur:X,placeholder:!ze||G||ce?i:void 0,placeholderTextColor:M.placeholderColor,autoFocus:n,editable:!o,returnKeyType:"search",selectionColor:(0,_FieldBase.resolveVariantColors)(H,D).borderFocusedRepresentative,accessibilityLabel:P??i,accessibilityState:{disabled:o},"aria-disabled":o,...N})}),Ie.node]})}),v&&v.length>0?(0,_jsxRuntime.jsx)(_SearchPanel.SearchScopeBar,{scopes:v,scope:ie||(v[0]?.value??""),disabled:o,haptic:I,onChange:oe}):null,me?(0,_jsxRuntime.jsx)(_SearchPanel.SearchRecents,{recents:fe,title:j,onSelect:Ce,onRemove:F?Fe:void 0,onClear:B?Be:void 0,onHold:pe,onRelease:Se}):null,xe?(0,_jsxRuntime.jsx)(_SearchPanel.SearchSuggestions,{suggestions:ve,query:re,onSelect:ye,onHold:pe,onRelease:Se}):null]})});SearchBar.displayName="SearchBar";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flexDirection:"row",alignItems:"center",width:"100%",position:"relative",overflow:"visible"},fieldWrap:{flex:1,position:"relative",overflow:"visible"},input:{flex:1,padding:0,margin:0,includeFontPadding:!1}});var _default=exports.default=SearchBar;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SignaturePad=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_index2=require("../Button/index.js"),_index3=require("../Input/index.js"),_index4=require("../Text/index.js"),_signatureGeometry=require("./signatureGeometry.js"),_writePng=require("./writePng"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var n=new WeakMap,r=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var a,i,o={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return o;if(a=t?r:n){if(a.has(e))return a.get(e);a.set(e,o)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((i=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(i.get||i.set)?a(o,t,i):o[t]=e[t]);return o})(e,t)}const DEFAULT_LABELS={pad:"Signature pad",padHint:"Draw with one finger. To sign without drawing, use the type your name action.",caption:"Sign above the line. To start with an up or down stroke, rest your finger a moment first.",typedCaption:"Your typed name is used as your signature.",undo:"Undo",clear:"Clear",typeInstead:"Type your name instead",drawInstead:"Draw instead",typedLabel:"Type your name",typedPlaceholder:"Your full name",empty:"Not signed",signed:"Signed",typingAnnouncement:"Signing by typing your name. Your typed name is used as your signature. Choose Draw instead to sign with your finger.",drawingAnnouncement:"Signing by drawing. Use one finger on the pad.",clearedAnnouncement:"Signature cleared",undoneAnnouncement:"Last stroke removed",emptyError:"Add a signature first."},STROKE_WIDTH=2.5,SIDEWAYS_TO_DRAW=6,UPRIGHT_TO_SCROLL=8,REST_TO_DRAW_MS=200,MIN_POINT_GAP=.8,DEFAULT_HEIGHT=180,DEFAULT_NAME_LENGTH=100,MAX_EXPORT_SCALE=3,MIN_TARGET=44,BASELINE_OPACITY=.3,DISABLED_OPACITY=.5,TARGET_STYLE={minHeight:44},defaultScriptFont=()=>_reactNative.Platform.select({ios:"Snell Roundhand",default:"cursive"}),cssFontStack=e=>"cursive"===e?"cursive":`'${e}', cursive`,useScreenReader=()=>{const[e,t]=(0,_react.useState)(!1);return(0,_react.useEffect)(()=>{let e=!0;_reactNative.AccessibilityInfo.isScreenReaderEnabled().then(n=>{e&&t(n)});const n=_reactNative.AccessibilityInfo.addEventListener("screenReaderChanged",t);return()=>{e=!1,n.remove()}},[]),e},StrokePath=(0,_react.memo)(({points:e,color:t})=>(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:(0,_signatureGeometry.strokePath)(e),stroke:t,strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}));StrokePath.displayName="SignaturePadStroke";const Marks=({mode:e,strokes:t,name:n,color:r,fontFamily:a,width:i,height:o})=>"draw"===e?(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:t.map(e=>(0,_jsxRuntime.jsx)(StrokePath,{points:e.points,color:r},e.id))}):n?(0,_jsxRuntime.jsx)(_reactNativeSvg.Text,{x:i/2,y:o*_signatureGeometry.BASELINE_RATIO,fontSize:(0,_signatureGeometry.typedFontSize)(i,n),fontFamily:a,textAnchor:"middle",fill:r,children:n}):null,SignaturePad=exports.SignaturePad=(0,_react.forwardRef)((e,t)=>{const{initialStrokes:n,onChange:r,initialTypedName:a="",onTypedNameChange:i,defaultMode:o="draw",onModeChange:s,onEmptyChange:c,allowTyped:u=!0,signedBy:d,signedAt:l,height:_=DEFAULT_HEIGHT,maxNameLength:m=DEFAULT_NAME_LENGTH,inkColor:g,paperColor:p,scriptFontFamily:y,labels:h,haptic:x="selection",disabled:f=!1,style:v,testID:w}=e,S=(0,_index.useTheme)(),R=void 0===g&&void 0===p,b=R?S.colors.text.primary:g??_index.lightTheme.colors.text.primary,T=R?S.colors.background.elevated:p??_index.lightTheme.colors.background.elevated,j=R?_index.lightTheme.colors.text.primary:b,E=R?_index.lightTheme.colors.background.elevated:T,A=j!==b||E!==T,C=y??defaultScriptFont(),N=(0,_react.useMemo)(()=>({...DEFAULT_LABELS,...h}),[h]),k=useScreenReader(),I=(0,_react.useRef)(null),L=(0,_react.useRef)(null),[P,D]=(0,_react.useState)(0),[G,M]=(0,_react.useState)(()=>(n??[]).map((e,t)=>({id:t+1,points:[...e]}))),F=(0,_react.useRef)(G),O=(0,_react.useRef)(G.length),H=(0,_react.useRef)(null),q=(0,_react.useRef)(null),[W,B]=(0,_react.useState)(u?o:"draw"),[Y,U]=(0,_react.useState)(a),[$,z]=(0,_react.useState)(null),V=(0,_react.useRef)(!1),K=(0,_react.useRef)({onChange:r,onTypedNameChange:i,onModeChange:s,onEmptyChange:c});(0,_react.useEffect)(()=>{K.current={onChange:r,onTypedNameChange:i,onModeChange:s,onEmptyChange:c}});const X="draw"===W&&!f,J="draw"===W?0===G.length:0===Y.trim().length,Q=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{Q.current!==J&&(Q.current=J,K.current.onEmptyChange?.(J))},[J]);const Z=(0,_react.useCallback)(e=>{F.current=e,M(e)},[]),ee=(0,_react.useCallback)(()=>{z(Date.now()),K.current.onChange?.(F.current.map(e=>e.points))},[]),te=(0,_react.useMemo)(()=>{const pan=e=>_reactNativeGestureHandler.Gesture.Pan().enabled(X).runOnJS(!0).onBegin(e=>{H.current=(0,_signatureGeometry.pointOf)(e.x,e.y)}).onStart(t=>{q.current=e,O.current+=1;const n=(0,_signatureGeometry.pointOf)(t.x,t.y);Z([...F.current,{id:O.current,points:[H.current??n,n]}])}).onUpdate(t=>{if(q.current!==e)return;const n=F.current[F.current.length-1],r=(0,_signatureGeometry.pointOf)(t.x,t.y);(0,_signatureGeometry.distanceBetween)(n.points[n.points.length-1],r)<.8||Z([...F.current.slice(0,-1),{...n,points:[...n.points,r]}])}).onFinalize(()=>{q.current===e&&(q.current=null,ee())}),e=pan("sideways").activeOffsetX([-6,6]).failOffsetY([-8,8]),t=pan("rested").activateAfterLongPress(200);return _reactNativeGestureHandler.Gesture.Race(e,t)},[X,Z,ee]),ne=(0,_react.useCallback)(e=>{B(e),K.current.onModeChange?.(e),(0,_announce.announce)("type"===e?N.typingAnnouncement:N.drawingAnnouncement)},[N.typingAnnouncement,N.drawingAnnouncement]);(0,_react.useEffect)(()=>{k&&u&&!V.current&&"draw"===W&&0===F.current.length&&ne("type")},[k,u,W,ne]);const re=(0,_react.useCallback)(()=>{V.current=!0,ne("draw"===W?"type":"draw")},[W,ne]),ae=(0,_react.useCallback)(e=>{U(e),z(Date.now()),K.current.onTypedNameChange?.(e)},[]),ie=(0,_react.useCallback)(()=>{"type"===W?ae(""):(Z([]),ee()),(0,_announce.announce)(N.clearedAnnouncement)},[W,ae,Z,ee,N.clearedAnnouncement]),oe=(0,_react.useCallback)(()=>{"draw"===W&&0!==F.current.length&&(Z(F.current.slice(0,-1)),ee(),(0,_announce.announce)(N.undoneAnnouncement))},[W,Z,ee,N.undoneAnnouncement]),se=P||_signatureGeometry.FALLBACK_WIDTH;(0,_react.useImperativeHandle)(t,()=>({toFile:()=>new Promise((e,t)=>{if(J)return void t(new Error(N.emptyError));const n=A?L.current:I.current;if(!n)return void t(new Error("The signature pad is not on screen."));const r=Math.min(3,Math.max(1,_reactNative.PixelRatio.get()));n.toDataURL(n=>{try{e((0,_writePng.writePng)(n))}catch(e){t(e)}},{width:se*r,height:_*r})}),toSvg:()=>(0,_signatureGeometry.buildSignatureSvg)({width:se,height:_,mode:W,strokes:G.map(e=>e.points),typedName:Y,ink:j,paper:E,strokeWidth:2.5,fontFamily:cssFontStack(C)}),clear:ie,undo:oe,isEmpty:()=>J}),[J,N.emptyError,se,_,W,G,Y,A,j,E,C,ie,oe]);const ce=(0,_react.useMemo)(()=>[{name:"undo",label:N.undo},{name:"clear",label:N.clear},...u?[{name:"toggleMode",label:"draw"===W?N.typeInstead:N.drawInstead}]:[]],[N.undo,N.clear,N.typeInstead,N.drawInstead,u,W]),ue=(0,_react.useCallback)(e=>{if(f)return;const{actionName:t}=e.nativeEvent;"undo"===t?oe():"clear"===t?ie():"toggleMode"===t&&u&&re()},[f,oe,ie,re,u]),de=(0,_react.useCallback)(e=>{D(e.nativeEvent.layout.width)},[]),le=(0,_react.useMemo)(()=>_reactNative.StyleSheet.create({root:{gap:S.spacing.sm},pad:{height:_,borderWidth:S.colors.border.width,borderColor:S.colors.border.primary,borderRadius:S.radius.md,..._corners.smoothCorners,overflow:"hidden",backgroundColor:T,opacity:f?.5:1},baseline:{position:"absolute",left:S.spacing.md,right:S.spacing.md,top:_*_signatureGeometry.BASELINE_RATIO,height:_reactNative.StyleSheet.hairlineWidth,backgroundColor:b,opacity:.3},actions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:S.spacing.xs},trailing:{flexDirection:"row",alignItems:"center",gap:S.spacing.xs}}),[S,_,T,b,f]),_e=Y.trim(),me=l??$,ge=d&&!J?`Signed by ${d}${me?`, ${(0,_mobileCore.formatDateTime)(me)}`:""}`:null,pe="type"===W&&_e?`${N.pad}. ${_e}`:N.pad;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[le.root,v],testID:w,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:te,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:le.pad,onLayout:de,accessible:!0,accessibilityRole:"image",accessibilityLabel:pe,accessibilityHint:"draw"===W?N.padHint:void 0,accessibilityValue:{text:J?N.empty:N.signed},accessibilityState:{disabled:f},"aria-disabled":f,accessibilityActions:ce,onAccessibilityAction:ue,children:[A?(0,_jsxRuntime.jsxs)(_reactNativeSvg.default,{ref:L,style:_reactNative.StyleSheet.absoluteFill,width:"100%",height:_,children:[(0,_jsxRuntime.jsx)(_reactNativeSvg.Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:E}),(0,_jsxRuntime.jsx)(Marks,{mode:W,strokes:G,name:_e,color:j,fontFamily:C,width:se,height:_})]}):null,(0,_jsxRuntime.jsxs)(_reactNativeSvg.default,{ref:I,width:"100%",height:_,children:[(0,_jsxRuntime.jsx)(_reactNativeSvg.Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:T}),(0,_jsxRuntime.jsx)(Marks,{mode:W,strokes:G,name:_e,color:b,fontFamily:C,width:se,height:_})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:le.baseline})]})}),"type"===W?(0,_jsxRuntime.jsx)(_index3.Input,{label:N.typedLabel,placeholder:N.typedPlaceholder,value:Y,onChangeText:ae,maxLength:m,disabled:f,autoComplete:"name",textContentType:"name",autoCapitalize:"words",autoCorrect:!1,returnKeyType:"done",testID:w?`${w}-name`:void 0}):null,(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",children:"draw"===W?N.caption:N.typedCaption}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:le.actions,children:[u?(0,_jsxRuntime.jsx)(_index2.Button,{title:"draw"===W?N.typeInstead:N.drawInstead,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:f,onPress:re,testID:w?`${w}-mode`:void 0}):(0,_jsxRuntime.jsx)(_reactNative.View,{}),"draw"===W&&G.length>0?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:le.trailing,children:[(0,_jsxRuntime.jsx)(_index2.Button,{title:N.undo,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:f,onPress:oe,testID:w?`${w}-undo`:void 0}),(0,_jsxRuntime.jsx)(_index2.Button,{title:N.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:f,onPress:ie,testID:w?`${w}-clear`:void 0})]}):null,"type"===W&&_e?(0,_jsxRuntime.jsx)(_index2.Button,{title:N.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:f,onPress:ie,testID:w?`${w}-clear`:void 0}):null]}),ge?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",children:ge}):null]})});SignaturePad.displayName="SignaturePad";var _default=exports.default=SignaturePad;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SignaturePad=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_index2=require("../Button/index.js"),_index3=require("../Input/index.js"),_index4=require("../Text/index.js"),_signatureGeometry=require("./signatureGeometry.js"),_writePng=require("./writePng"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var n=new WeakMap,r=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var a,i,o={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return o;if(a=t?r:n){if(a.has(e))return a.get(e);a.set(e,o)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((i=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(i.get||i.set)?a(o,t,i):o[t]=e[t]);return o})(e,t)}const DEFAULT_LABELS={pad:"Signature pad",padHint:"Draw with one finger. To sign without drawing, use the type your name action.",caption:"Sign above the line. To start with an up or down stroke, rest your finger a moment first.",typedCaption:"Your typed name is used as your signature.",undo:"Undo",clear:"Clear",typeInstead:"Type your name instead",drawInstead:"Draw instead",typedLabel:"Type your name",typedPlaceholder:"Your full name",empty:"Not signed",signed:"Signed",typingAnnouncement:"Signing by typing your name. Your typed name is used as your signature. Choose Draw instead to sign with your finger.",drawingAnnouncement:"Signing by drawing. Use one finger on the pad.",clearedAnnouncement:"Signature cleared",undoneAnnouncement:"Last stroke removed",emptyError:"Add a signature first."},STROKE_WIDTH=2.5,SIDEWAYS_TO_DRAW=6,UPRIGHT_TO_SCROLL=8,REST_TO_DRAW_MS=200,MIN_POINT_GAP=.8,DEFAULT_HEIGHT=180,DEFAULT_NAME_LENGTH=100,MAX_EXPORT_SCALE=3,MIN_TARGET=44,BASELINE_OPACITY=.3,DISABLED_OPACITY=.5,TARGET_STYLE={minHeight:44},defaultScriptFont=()=>_reactNative.Platform.select({ios:"Snell Roundhand",default:"cursive"}),cssFontStack=e=>"cursive"===e?"cursive":`'${e}', cursive`,useScreenReader=()=>{const[e,t]=(0,_react.useState)(!1);return(0,_react.useEffect)(()=>{let e=!0;_reactNative.AccessibilityInfo.isScreenReaderEnabled().then(n=>{e&&t(n)});const n=_reactNative.AccessibilityInfo.addEventListener("screenReaderChanged",t);return()=>{e=!1,n.remove()}},[]),e},StrokePath=(0,_react.memo)(({points:e,color:t})=>(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:(0,_signatureGeometry.strokePath)(e),stroke:t,strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}));StrokePath.displayName="SignaturePadStroke";const Marks=({mode:e,strokes:t,name:n,color:r,fontFamily:a,width:i,height:o})=>"draw"===e?(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:t.map(e=>(0,_jsxRuntime.jsx)(StrokePath,{points:e.points,color:r},e.id))}):n?(0,_jsxRuntime.jsx)(_reactNativeSvg.Text,{x:i/2,y:o*_signatureGeometry.BASELINE_RATIO,fontSize:(0,_signatureGeometry.typedFontSize)(i,n),fontFamily:a,textAnchor:"middle",fill:r,children:n}):null,SignaturePad=exports.SignaturePad=(0,_react.forwardRef)((e,t)=>{const{initialStrokes:n,onChange:r,initialTypedName:a="",onTypedNameChange:i,defaultMode:o="draw",onModeChange:s,onEmptyChange:c,allowTyped:u=!0,signedBy:d,signedAt:l,height:_=DEFAULT_HEIGHT,maxNameLength:m=DEFAULT_NAME_LENGTH,inkColor:g,paperColor:p,scriptFontFamily:y,labels:h,haptic:x="selection",disabled:f=!1,style:v,testID:w}=e,S=(0,_index.useTheme)(),R=void 0===g&&void 0===p,b=R?S.colors.text.primary:g??_index.lightTheme.colors.text.primary,T=R?S.colors.background.elevated:p??_index.lightTheme.colors.background.elevated,j=R?_index.lightTheme.colors.text.primary:b,E=R?_index.lightTheme.colors.background.elevated:T,A=j!==b||E!==T,C=y??defaultScriptFont(),N=(0,_react.useMemo)(()=>({...DEFAULT_LABELS,...h}),[h]),k=useScreenReader(),I=(0,_react.useRef)(null),L=(0,_react.useRef)(null),[P,D]=(0,_react.useState)(0),[G,M]=(0,_react.useState)(()=>(n??[]).map((e,t)=>({id:t+1,points:[...e]}))),F=(0,_react.useRef)(G),O=(0,_react.useRef)(G.length),H=(0,_react.useRef)(null),q=(0,_react.useRef)(null),[W,B]=(0,_react.useState)(u?o:"draw"),[Y,U]=(0,_react.useState)(a),[$,z]=(0,_react.useState)(null),V=(0,_react.useRef)(!1),K=(0,_react.useRef)({onChange:r,onTypedNameChange:i,onModeChange:s,onEmptyChange:c});(0,_react.useEffect)(()=>{K.current={onChange:r,onTypedNameChange:i,onModeChange:s,onEmptyChange:c}});const X="draw"===W&&!f,J="draw"===W?0===G.length:0===Y.trim().length,Q=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{Q.current!==J&&(Q.current=J,K.current.onEmptyChange?.(J))},[J]);const Z=(0,_react.useCallback)(e=>{F.current=e,M(e)},[]),ee=(0,_react.useCallback)(()=>{z(Date.now()),K.current.onChange?.(F.current.map(e=>e.points))},[]),te=(0,_react.useMemo)(()=>{const pan=e=>_reactNativeGestureHandler.Gesture.Pan().enabled(X).runOnJS(!0).onBegin(e=>{H.current=(0,_signatureGeometry.pointOf)(e.x,e.y)}).onStart(t=>{q.current=e,O.current+=1;const n=(0,_signatureGeometry.pointOf)(t.x,t.y);Z([...F.current,{id:O.current,points:[H.current??n,n]}])}).onUpdate(t=>{if(q.current!==e)return;const n=F.current[F.current.length-1],r=(0,_signatureGeometry.pointOf)(t.x,t.y);(0,_signatureGeometry.distanceBetween)(n.points[n.points.length-1],r)<.8||Z([...F.current.slice(0,-1),{...n,points:[...n.points,r]}])}).onFinalize(()=>{q.current===e&&(q.current=null,ee())}),e=pan("sideways").activeOffsetX([-6,6]).failOffsetY([-8,8]),t=pan("rested").activateAfterLongPress(200);return _reactNativeGestureHandler.Gesture.Race(e,t)},[X,Z,ee]),ne=(0,_react.useCallback)(e=>{B(e),K.current.onModeChange?.(e),(0,_announce.announce)("type"===e?N.typingAnnouncement:N.drawingAnnouncement)},[N.typingAnnouncement,N.drawingAnnouncement]);(0,_react.useEffect)(()=>{k&&u&&!V.current&&"draw"===W&&0===F.current.length&&ne("type")},[k,u,W,ne]);const re=(0,_react.useCallback)(()=>{V.current=!0,ne("draw"===W?"type":"draw")},[W,ne]),ae=(0,_react.useCallback)(e=>{U(e),z(Date.now()),K.current.onTypedNameChange?.(e)},[]),ie=(0,_react.useCallback)(()=>{"type"===W?ae(""):(Z([]),ee()),(0,_announce.announce)(N.clearedAnnouncement)},[W,ae,Z,ee,N.clearedAnnouncement]),oe=(0,_react.useCallback)(()=>{"draw"===W&&0!==F.current.length&&(Z(F.current.slice(0,-1)),ee(),(0,_announce.announce)(N.undoneAnnouncement))},[W,Z,ee,N.undoneAnnouncement]),se=P||_signatureGeometry.FALLBACK_WIDTH;(0,_react.useImperativeHandle)(t,()=>({toFile:()=>new Promise((e,t)=>{if(J)return void t(new Error(N.emptyError));const n=A?L.current:I.current;if(!n)return void t(new Error("The signature pad is not on screen."));const r=Math.min(3,Math.max(1,_reactNative.PixelRatio.get()));n.toDataURL(n=>{try{e((0,_writePng.writePng)(n))}catch(e){t(e)}},{width:se*r,height:_*r})}),toSvg:()=>(0,_signatureGeometry.buildSignatureSvg)({width:se,height:_,mode:W,strokes:G.map(e=>e.points),typedName:Y,ink:j,paper:E,strokeWidth:2.5,fontFamily:cssFontStack(C)}),clear:ie,undo:oe,isEmpty:()=>J}),[J,N.emptyError,se,_,W,G,Y,A,j,E,C,ie,oe]);const ce=(0,_react.useMemo)(()=>[{name:"undo",label:N.undo},{name:"clear",label:N.clear},...u?[{name:"toggleMode",label:"draw"===W?N.typeInstead:N.drawInstead}]:[]],[N.undo,N.clear,N.typeInstead,N.drawInstead,u,W]),ue=(0,_react.useCallback)(e=>{if(f)return;const{actionName:t}=e.nativeEvent;"undo"===t?oe():"clear"===t?ie():"toggleMode"===t&&u&&re()},[f,oe,ie,re,u]),de=(0,_react.useCallback)(e=>{D(e.nativeEvent.layout.width)},[]),le=(0,_react.useMemo)(()=>_reactNative.StyleSheet.create({root:{gap:S.spacing.sm},pad:{height:_,borderWidth:S.colors.border.width,borderColor:S.colors.border.primary,borderRadius:S.radius.md,..._corners.smoothCorners,overflow:"hidden",backgroundColor:T,opacity:f?.5:1},baseline:{position:"absolute",left:S.spacing.md,right:S.spacing.md,top:_*_signatureGeometry.BASELINE_RATIO,height:_reactNative.StyleSheet.hairlineWidth,backgroundColor:b,opacity:.3},actions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:S.spacing.xs},trailing:{flexDirection:"row",alignItems:"center",gap:S.spacing.xs}}),[S,_,T,b,f]),me=Y.trim(),ge=l??$,pe=d&&!J?`Signed by ${d}${ge?`, ${(0,_mobileCore.formatDateTime)(ge)}`:""}`:null,ye="type"===W&&me?`${N.pad}. ${me}`:N.pad;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[le.root,v],testID:w,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:te,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:le.pad,onLayout:de,accessible:!0,accessibilityRole:"image",accessibilityLabel:ye,accessibilityHint:"draw"===W?N.padHint:void 0,accessibilityValue:{text:J?N.empty:N.signed},accessibilityState:{disabled:f},"aria-disabled":f,accessibilityActions:ce,onAccessibilityAction:ue,children:[A?(0,_jsxRuntime.jsxs)(_reactNativeSvg.default,{ref:L,style:_reactNative.StyleSheet.absoluteFill,width:"100%",height:_,children:[(0,_jsxRuntime.jsx)(_reactNativeSvg.Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:E}),(0,_jsxRuntime.jsx)(Marks,{mode:W,strokes:G,name:me,color:j,fontFamily:C,width:se,height:_})]}):null,(0,_jsxRuntime.jsxs)(_reactNativeSvg.default,{ref:I,width:"100%",height:_,children:[(0,_jsxRuntime.jsx)(_reactNativeSvg.Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:T}),(0,_jsxRuntime.jsx)(Marks,{mode:W,strokes:G,name:me,color:b,fontFamily:C,width:se,height:_})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:le.baseline})]})}),"type"===W?(0,_jsxRuntime.jsx)(_index3.Input,{label:N.typedLabel,placeholder:N.typedPlaceholder,value:Y,onChangeText:ae,maxLength:m,disabled:f,autoComplete:"name",textContentType:"name",autoCapitalize:"words",autoCorrect:!1,returnKeyType:"done",testID:w?`${w}-name`:void 0}):null,(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",children:"draw"===W?N.caption:N.typedCaption}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:le.actions,children:[u?(0,_jsxRuntime.jsx)(_index2.Button,{title:"draw"===W?N.typeInstead:N.drawInstead,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:f,onPress:re,testID:w?`${w}-mode`:void 0}):(0,_jsxRuntime.jsx)(_reactNative.View,{}),"draw"===W&&G.length>0?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:le.trailing,children:[(0,_jsxRuntime.jsx)(_index2.Button,{title:N.undo,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:f,onPress:oe,testID:w?`${w}-undo`:void 0}),(0,_jsxRuntime.jsx)(_index2.Button,{title:N.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:f,onPress:ie,testID:w?`${w}-clear`:void 0})]}):null,"type"===W&&me?(0,_jsxRuntime.jsx)(_index2.Button,{title:N.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:f,onPress:ie,testID:w?`${w}-clear`:void 0}):null]}),pe?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",children:pe}):null]})});SignaturePad.displayName="SignaturePad";var _default=exports.default=SignaturePad;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Slider=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_valueText=require("./valueText.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var a=new WeakMap,r=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var i,n,s={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return s;if(i=t?r:a){if(i.has(e))return i.get(e);i.set(e,s)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((n=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(n.get||n.set)?i(s,t,n):s[t]=e[t]);return s})(e,t)}const SIZE_MAP={sm:{trackHeight:4,thumbDiameter:24},md:{trackHeight:6,thumbDiameter:28},lg:{trackHeight:8,thumbDiameter:32}},VARIANT_SIZE_MAP={inset:{sm:{trackHeight:14,thumbDiameter:10},md:{trackHeight:20,thumbDiameter:14},lg:{trackHeight:26,thumbDiameter:18}},minimal:{sm:{trackHeight:2,thumbDiameter:14},md:{trackHeight:3,thumbDiameter:18},lg:{trackHeight:4,thumbDiameter:22}},bar:{sm:{trackHeight:20,thumbDiameter:20},md:{trackHeight:28,thumbDiameter:28},lg:{trackHeight:36,thumbDiameter:36}}},INSET_RING_RATIO=.3,MIN_THUMB_TOUCH=44,TONE_TO_COLOR_KEY={primary:"primary",success:"success",warning:"warning",error:"error"},clamp=(e,t,a)=>Math.min(Math.max(e,t),a),snapToStep=(e,t,a,r)=>{if(r<=0)return clamp(e,t,a);const i=Math.round((e-t)/r)*r+t,n=String(r).split(".")[1]?.length??0,s=n>0?Number(i.toFixed(n)):i;return clamp(s,t,a)},BUBBLE_GAP=2,BUBBLE_CARET=8,BUBBLE_WRAP_WIDTH=160,NO_SHADOW={shadowOpacity:0,elevation:0},defaultFormatLabel=e=>String(e),Slider=exports.Slider=(0,_react.forwardRef)((e,t)=>{const{min:a=0,max:r=100,step:i=1,disabled:n=!1,tone:s="primary",size:o="md",variant:l="default",showLabel:c=!1,snapThumb:u=!1,formatLabel:d=defaultFormatLabel,renderLabel:m,accessibilityLabel:h,haptic:b,style:_,containerStyle:v,trackStyle:p,fillStyle:f,thumbStyle:g,labelStyle:R,thumbPressScale:y,labelShowDuration:x,labelOpacity:N,testID:w}=e,k=(0,_index2.useTheme)(),S=k.components.slider,j=S?.[o],C=(0,_react.useMemo)(()=>"default"===l?{trackHeight:j?.trackHeight??SIZE_MAP[o].trackHeight,thumbDiameter:j?.thumbDiameter??SIZE_MAP[o].thumbDiameter}:VARIANT_SIZE_MAP[l][o],[j,o,l]),M="inset"===l?C.trackHeight/2:0,O=S?.thumbPressAnimation??!1,H=y??S?.thumbPressScale??1.1,D=x??S?.labelShowDuration??k.motion.duration.fast,A=N??S?.labelOpacity??1,E=(0,_react.useMemo)(()=>buildStyles(k,C),[k,C]),T=(0,_react.useMemo)(()=>({damping:k.motion.spring.snappy.damping,stiffness:k.motion.spring.snappy.stiffness,mass:k.motion.spring.snappy.mass}),[k.motion.spring.snappy]),[V,W]=(0,_react.useState)(0),P=k.colors[TONE_TO_COLOR_KEY[s]],I=(0,_valueText.sliderToneInk)(k,s),L=!0===e.range,[q,X]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??(L?[a,r]:a),onChange:e.onChange}),B=(0,_reactNativeReanimated.useSharedValue)(0),G=(0,_reactNativeReanimated.useSharedValue)(0),F=(0,_reactNativeReanimated.useSharedValue)(L?q[0]:q),J=(0,_reactNativeReanimated.useSharedValue)(L?q[1]:q),U=(0,_reactNativeReanimated.useSharedValue)(0),z=(0,_reactNativeReanimated.useSharedValue)(0),Z=(0,_reactNativeReanimated.useSharedValue)(1),K=(0,_reactNativeReanimated.useSharedValue)(1),Y="always"===c,$=(0,_reactNativeReanimated.useSharedValue)(Y?1:0),Q=(0,_reactNativeReanimated.useSharedValue)(Y?1:0),ee=(0,_react.useMemo)(()=>10**(String(i).split(".")[1]?.length??0),[i]);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(B),(0,_reactNativeReanimated.cancelAnimation)(G),(0,_reactNativeReanimated.cancelAnimation)(Z),(0,_reactNativeReanimated.cancelAnimation)(K),(0,_reactNativeReanimated.cancelAnimation)($),(0,_reactNativeReanimated.cancelAnimation)(Q)},[B,G,Z,K,$,Q]);const te=(0,_react.useCallback)((e,t)=>{const i=t-2*M;return r===a||i<=0?M:M+(e-a)/(r-a)*i},[a,r,M]),ae=(0,_react.useCallback)((e,t)=>{const n=t-2*M;if(n<=0)return a;const s=clamp((e-M)/n,0,1);return snapToStep(a+s*(r-a),a,r,i)},[a,r,i,M]),re=(0,_react.useRef)(!1),ie=k.motion.duration.fast,ne=(0,_react.useRef)(q);ne.current=q;const se=(0,_react.useRef)(V);se.current=V;const oe=(0,_react.useCallback)((e=!1)=>{const t=se.current;if(t<=0)return;const place=t=>e?(0,_reactNativeReanimated.withTiming)(t,{duration:ie,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}):t,a=ne.current;if(L){const[e,r]=a,i=Math.min(e,r),n=Math.max(e,r);F.value=i,J.value=n,B.value=place(te(i,t)),G.value=place(te(n,t))}else{const e=a;F.value=e,J.value=e,B.value=place(te(e,t))}},[L,te,F,J,B,G,ie]),[le,ce]=(0,_react.useState)(0),ue=(0,_react.useRef)(!1),de=(0,_react.useCallback)(e=>{re.current=e,e||(ue.current=!0,ce(e=>e+1))},[]);(0,_react.useEffect)(()=>{if(re.current)return;const e=ue.current;ue.current=!1,oe(e)},[JSON.stringify(q),V,le,oe]);const me=(0,_react.useCallback)(e=>{const t=e.nativeEvent.layout.width;z.value=t,W(t)},[z]),he=(0,_react.useCallback)((e,t)=>{X(L?[e,t]:e)},[L,X]),be=(0,_react.useCallback)(()=>{const e=(0,_index3.resolveHaptic)(b,"selection");e&&(0,_index3.triggerHaptic)(e)},[b]),_e=(0,_react.useRef)(he);_e.current=he;const ve=(0,_react.useRef)(be);ve.current=be;const pe=(0,_react.useCallback)((e,t)=>_e.current(e,t),[]),fe=(0,_react.useCallback)(()=>ve.current(),[]),ge=Math.max(0,(44-C.thumbDiameter)/2),Re=ge>0?ge:void 0,ye=(0,_react.useCallback)(e=>{const t="low"===e?B:G,s="low"===e?F:J,o="low"===e?J:F,l="low"===e?Z:K,d="low"===e?$:Q,m="low"===e,h=a,b=r,_=i,v=ee,p=L,f=H,g=O,R=!0===c,y=u,x=A,N=D,w=T,k=M,follow=e=>{"worklet";const a=z.value-2*k;if(a<=0||!Number.isFinite(e))return;const r=Math.min(Math.max(U.value+e,k),z.value-k);let i=h+(r-k)/a*(b-h);_>0&&(i=Math.round((i-h)/_)*_+h,i=Math.round(i*v)/v),i=Math.min(Math.max(i,h),b),p&&(m&&i>o.value&&(i=o.value),!m&&i<o.value&&(i=o.value)),t.value=y||b===h?b===h?k:k+(i-h)/(b-h)*a:p?m?Math.min(r,G.value):Math.max(r,B.value):r,i!==s.value&&(s.value=i,i!==h&&i!==b||(0,_reactNativeReanimated.runOnJS)(fe)(),(0,_reactNativeReanimated.runOnJS)(pe)(F.value,J.value))},S=_reactNativeGestureHandler.Gesture.Pan().enabled(!n).minDistance(0);return(void 0===Re?S:S.hitSlop(Re)).onStart(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(de)(!0),U.value=t.value,g&&(l.value=(0,_reactNativeReanimated.withSpring)(f,w)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(x,{duration:N,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)})),(0,_reactNativeReanimated.runOnJS)(fe)()}).onUpdate(e=>{"worklet";follow(e.translationX)}).onEnd(e=>{"worklet";follow(e.translationX),g&&(l.value=(0,_reactNativeReanimated.withSpring)(1,w)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(0,{duration:N,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}))}).onFinalize(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(de)(!1)})},[n,a,r,i,ee,L,H,O,c,u,A,D,T,M,Re,pe,fe,de,B,G,F,J,Z,K,$,Q,U,z]),xe=(0,_react.useMemo)(()=>ye("low"),[ye]),Ne=(0,_react.useMemo)(()=>ye("high"),[ye]),we=(0,_react.useCallback)(e=>{if(n||L||V<=0)return;const t=clamp(e.nativeEvent.locationX,0,V),a=ae(t,V);a!==F.value&&(be(),F.value=a,B.value=(0,_reactNativeReanimated.withTiming)(te(a,V),{duration:k.motion.duration.fast,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}),he(a,a))},[n,L,V,ae,te,he,be,B,F,k.motion.duration.fast]),ke=(0,_react.useCallback)(e=>{if(n)return;const t="increment"===e.nativeEvent.actionName?i:-i,s=i>0?Math.round(t*ee)/ee:t;if(L){const e=Math.round((F.value+s)*ee)/ee,t=clamp(e,a,J.value);t!==F.value&&(F.value=t,B.value=te(t,V),be(),he(t,J.value))}else{const e=Math.round((F.value+s)*ee)/ee,t=clamp(e,a,r);t!==F.value&&(F.value=t,B.value=te(t,V),be(),he(t,t))}},[n,i,ee,L,a,r,te,V,B,F,J,he,be]),Se=C.thumbDiameter/2,je=n?k.colors.surface.disabled:P,Ce="inset"===l?{backgroundColor:je,borderColor:k.colors.background.elevated,borderWidth:Math.max(2,Math.round(.3*C.thumbDiameter)),...NO_SHADOW}:"minimal"===l?{backgroundColor:je,borderWidth:0}:"bar"===l?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:k.colors.background.elevated,borderColor:je},Me=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=z.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=n?.55:1;if(L){const a=Math.max(0,G.value-B.value+2*M);return{opacity:t,transform:[{translateX:B.value-M},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:B.value+M-e},{scaleX:1}]}}),Oe=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:B.value-Se},{scale:Z.value}]})),He=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:G.value-Se},{scale:K.value}]})),De=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:$.value})),Ae=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:Q.value})),clampDisplay=e=>clamp(e,a,r),Ee=clampDisplay(L?Math.min(...q):q),Te=clampDisplay(L?Math.max(...q):q);return(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:[E.container,v,_],testID:w,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:n},"aria-disabled":n,accessibilityValue:L?{min:a,max:r,now:Ee,text:`${Ee} to ${Te}`}:{min:a,max:r,now:Ee},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:ke,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:we,disabled:n||L,style:E.trackTouch,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E.trackWrap,onLayout:me,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E.trackClip,pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[E.track,{backgroundColor:n?k.colors.surface.disabled:k.colors.border.primary},p]}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[E.fill,{backgroundColor:n?k.colors.surface.disabled:P},f,Me]})]}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:xe,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[E.thumb,{width:C.thumbDiameter,height:C.thumbDiameter,borderRadius:Se,..._corners.smoothCorners,opacity:n?.55:1},Ce,g,Oe],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:c?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[E.bubbleWrap,De],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[E.bubble,{backgroundColor:P}],children:m?m(Ee):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[E.bubbleText,{color:I},R],numberOfLines:1,children:d(Ee)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[E.bubbleCaret,{backgroundColor:P}]})]}):null})}),L?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Ne,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[E.thumb,{width:C.thumbDiameter,height:C.thumbDiameter,borderRadius:Se,..._corners.smoothCorners,opacity:n?.55:1},Ce,g,He],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:c?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[E.bubbleWrap,Ae],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[E.bubble,{backgroundColor:P}],children:m?m(Te):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[E.bubbleText,{color:I},R],numberOfLines:1,children:d(Te)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[E.bubbleCaret,{backgroundColor:P}]})]}):null})}):null]})})})});Slider.displayName="Slider";const buildStyles=(e,t)=>{const a=e.shadows.md,r=Math.max(t.thumbDiameter,t.trackHeight),i=r/2+4;return _reactNative.StyleSheet.create({container:{width:"100%",paddingVertical:i,justifyContent:"center"},trackTouch:{width:"100%",justifyContent:"center"},trackWrap:{width:"100%",height:r,justifyContent:"center"},trackClip:{position:"absolute",left:0,right:0,height:t.trackHeight,top:(r-t.trackHeight)/2,borderRadius:t.trackHeight/2,..._corners.smoothCorners,overflow:"hidden"},track:{position:"absolute",top:0,right:0,bottom:0,left:0,borderRadius:t.trackHeight/2,..._corners.smoothCorners},fill:{position:"absolute",top:0,left:0,width:"100%",height:t.trackHeight,borderRadius:t.trackHeight/2,..._corners.smoothCorners,transformOrigin:"left"},thumb:{position:"absolute",top:(r-t.thumbDiameter)/2,left:0,borderWidth:2,shadowColor:a.shadowColor,shadowOffset:a.shadowOffset,shadowOpacity:a.shadowOpacity,shadowRadius:a.shadowRadius,elevation:a.elevation,alignItems:"center",justifyContent:"center"},bubbleWrap:{position:"absolute",bottom:t.thumbDiameter+2,left:t.thumbDiameter/2-80,width:160,alignItems:"center"},bubbleCaret:{width:8,height:8,marginTop:-5,borderRadius:1,..._corners.smoothCorners,transform:[{rotate:"45deg"}]},bubble:{paddingHorizontal:e.spacing.sm,paddingVertical:e.spacing.xxs,borderRadius:e.radius.md,..._corners.smoothCorners,minWidth:36,alignItems:"center",justifyContent:"center",..._reactNative.Platform.select({ios:{shadowColor:e.shadows.sm.shadowColor,shadowOffset:e.shadows.sm.shadowOffset,shadowOpacity:e.shadows.sm.shadowOpacity,shadowRadius:e.shadows.sm.shadowRadius},android:{elevation:e.shadows.sm.elevation},default:{}})},bubbleText:{color:e.colors.onPrimary,fontSize:e.typography.fontSize.xs,fontWeight:e.typography.fontWeight.semibold}})};var _default=exports.default=Slider;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Slider=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_valueText=require("./valueText.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var a=new WeakMap,r=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var i,n,s={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return s;if(i=t?r:a){if(i.has(e))return i.get(e);i.set(e,s)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((n=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(n.get||n.set)?i(s,t,n):s[t]=e[t]);return s})(e,t)}const SIZE_MAP={sm:{trackHeight:4,thumbDiameter:24},md:{trackHeight:6,thumbDiameter:28},lg:{trackHeight:8,thumbDiameter:32}},VARIANT_SIZE_MAP={inset:{sm:{trackHeight:14,thumbDiameter:10},md:{trackHeight:20,thumbDiameter:14},lg:{trackHeight:26,thumbDiameter:18}},minimal:{sm:{trackHeight:2,thumbDiameter:14},md:{trackHeight:3,thumbDiameter:18},lg:{trackHeight:4,thumbDiameter:22}},bar:{sm:{trackHeight:20,thumbDiameter:20},md:{trackHeight:28,thumbDiameter:28},lg:{trackHeight:36,thumbDiameter:36}}},INSET_RING_RATIO=.3,MIN_THUMB_TOUCH=44,TONE_TO_COLOR_KEY={primary:"primary",success:"success",warning:"warning",error:"error"},clamp=(e,t,a)=>Math.min(Math.max(e,t),a),snapToStep=(e,t,a,r)=>{if(r<=0)return clamp(e,t,a);const i=Math.round((e-t)/r)*r+t,n=String(r).split(".")[1]?.length??0,s=n>0?Number(i.toFixed(n)):i;return clamp(s,t,a)},BUBBLE_GAP=2,BUBBLE_CARET=8,BUBBLE_WRAP_WIDTH=160,NO_SHADOW={shadowOpacity:0,elevation:0},defaultFormatLabel=e=>String(e),Slider=exports.Slider=(0,_react.forwardRef)((e,t)=>{const{min:a=0,max:r=100,step:i=1,disabled:n=!1,tone:s="primary",size:o="md",variant:l="default",showLabel:c=!1,snapThumb:u=!1,formatLabel:d=defaultFormatLabel,renderLabel:m,accessibilityLabel:h,haptic:b,style:_,containerStyle:v,trackStyle:p,fillStyle:f,thumbStyle:g,labelStyle:R,thumbPressScale:y,labelShowDuration:x,labelOpacity:N,testID:w}=e,k=(0,_index2.useTheme)(),S=k.components.slider,j=S?.[o],C=(0,_react.useMemo)(()=>"default"===l?{trackHeight:j?.trackHeight??SIZE_MAP[o].trackHeight,thumbDiameter:j?.thumbDiameter??SIZE_MAP[o].thumbDiameter}:VARIANT_SIZE_MAP[l][o],[j,o,l]),M="inset"===l?C.trackHeight/2:0,O=S?.thumbPressAnimation??!1,H=y??S?.thumbPressScale??1.1,D=x??S?.labelShowDuration??k.motion.duration.fast,A=N??S?.labelOpacity??1,E=(0,_react.useMemo)(()=>buildStyles(k,C),[k,C]),T=(0,_react.useMemo)(()=>({damping:k.motion.spring.snappy.damping,stiffness:k.motion.spring.snappy.stiffness,mass:k.motion.spring.snappy.mass}),[k.motion.spring.snappy]),[V,W]=(0,_react.useState)(0),P=k.colors[TONE_TO_COLOR_KEY[s]],I=(0,_valueText.sliderToneInk)(k,s),L=!0===e.range,[q,X]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??(L?[a,r]:a),onChange:e.onChange}),B=(0,_reactNativeReanimated.useSharedValue)(0),G=(0,_reactNativeReanimated.useSharedValue)(0),F=(0,_reactNativeReanimated.useSharedValue)(L?q[0]:q),J=(0,_reactNativeReanimated.useSharedValue)(L?q[1]:q),U=(0,_reactNativeReanimated.useSharedValue)(0),z=(0,_reactNativeReanimated.useSharedValue)(0),Z=(0,_reactNativeReanimated.useSharedValue)(1),K=(0,_reactNativeReanimated.useSharedValue)(1),Y="always"===c,$=(0,_reactNativeReanimated.useSharedValue)(Y?1:0),Q=(0,_reactNativeReanimated.useSharedValue)(Y?1:0),ee=(0,_react.useMemo)(()=>10**(String(i).split(".")[1]?.length??0),[i]);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(B),(0,_reactNativeReanimated.cancelAnimation)(G),(0,_reactNativeReanimated.cancelAnimation)(Z),(0,_reactNativeReanimated.cancelAnimation)(K),(0,_reactNativeReanimated.cancelAnimation)($),(0,_reactNativeReanimated.cancelAnimation)(Q)},[B,G,Z,K,$,Q]);const te=(0,_react.useCallback)((e,t)=>{const i=t-2*M;return r===a||i<=0?M:M+(e-a)/(r-a)*i},[a,r,M]),ae=(0,_react.useCallback)((e,t)=>{const n=t-2*M;if(n<=0)return a;const s=clamp((e-M)/n,0,1);return snapToStep(a+s*(r-a),a,r,i)},[a,r,i,M]),re=(0,_react.useRef)(!1),ie=k.motion.duration.fast,ne=(0,_react.useRef)(q);ne.current=q;const se=(0,_react.useRef)(V);se.current=V;const oe=(0,_react.useCallback)((e=!1)=>{const t=se.current;if(t<=0)return;const place=t=>e?(0,_reactNativeReanimated.withTiming)(t,{duration:ie,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}):t,a=ne.current;if(L){const[e,r]=a,i=Math.min(e,r),n=Math.max(e,r);F.value=i,J.value=n,B.value=place(te(i,t)),G.value=place(te(n,t))}else{const e=a;F.value=e,J.value=e,B.value=place(te(e,t))}},[L,te,F,J,B,G,ie]),[le,ce]=(0,_react.useState)(0),ue=(0,_react.useRef)(!1),de=(0,_react.useCallback)(e=>{re.current=e,e||(ue.current=!0,ce(e=>e+1))},[]);(0,_react.useEffect)(()=>{if(re.current)return;const e=ue.current;ue.current=!1,oe(e)},[JSON.stringify(q),V,le,oe]);const me=(0,_react.useCallback)(e=>{const t=e.nativeEvent.layout.width;z.value=t,W(t)},[z]),he=(0,_react.useCallback)((e,t)=>{X(L?[e,t]:e)},[L,X]),be=(0,_react.useCallback)(()=>{const e=(0,_index3.resolveHaptic)(b,"selection");e&&(0,_index3.triggerHaptic)(e)},[b]),ve=(0,_react.useRef)(he);ve.current=he;const pe=(0,_react.useRef)(be);pe.current=be;const fe=(0,_react.useCallback)((e,t)=>ve.current(e,t),[]),ge=(0,_react.useCallback)(()=>pe.current(),[]),Re=Math.max(0,(44-C.thumbDiameter)/2),ye=Re>0?Re:void 0,xe=(0,_react.useCallback)(e=>{const t="low"===e?B:G,s="low"===e?F:J,o="low"===e?J:F,l="low"===e?Z:K,d="low"===e?$:Q,m="low"===e,h=a,b=r,_=i,v=ee,p=L,f=H,g=O,R=!0===c,y=u,x=A,N=D,w=T,k=M,follow=e=>{"worklet";const a=z.value-2*k;if(a<=0||!Number.isFinite(e))return;const r=Math.min(Math.max(U.value+e,k),z.value-k);let i=h+(r-k)/a*(b-h);_>0&&(i=Math.round((i-h)/_)*_+h,i=Math.round(i*v)/v),i=Math.min(Math.max(i,h),b),p&&(m&&i>o.value&&(i=o.value),!m&&i<o.value&&(i=o.value)),t.value=y||b===h?b===h?k:k+(i-h)/(b-h)*a:p?m?Math.min(r,G.value):Math.max(r,B.value):r,i!==s.value&&(s.value=i,i!==h&&i!==b||(0,_reactNativeReanimated.runOnJS)(ge)(),(0,_reactNativeReanimated.runOnJS)(fe)(F.value,J.value))},S=_reactNativeGestureHandler.Gesture.Pan().enabled(!n).minDistance(0);return(void 0===ye?S:S.hitSlop(ye)).onStart(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(de)(!0),U.value=t.value,g&&(l.value=(0,_reactNativeReanimated.withSpring)(f,w)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(x,{duration:N,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)})),(0,_reactNativeReanimated.runOnJS)(ge)()}).onUpdate(e=>{"worklet";follow(e.translationX)}).onEnd(e=>{"worklet";follow(e.translationX),g&&(l.value=(0,_reactNativeReanimated.withSpring)(1,w)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(0,{duration:N,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}))}).onFinalize(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(de)(!1)})},[n,a,r,i,ee,L,H,O,c,u,A,D,T,M,ye,fe,ge,de,B,G,F,J,Z,K,$,Q,U,z]),Ne=(0,_react.useMemo)(()=>xe("low"),[xe]),we=(0,_react.useMemo)(()=>xe("high"),[xe]),ke=(0,_react.useCallback)(e=>{if(n||L||V<=0)return;const t=clamp(e.nativeEvent.locationX,0,V),a=ae(t,V);a!==F.value&&(be(),F.value=a,B.value=(0,_reactNativeReanimated.withTiming)(te(a,V),{duration:k.motion.duration.fast,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}),he(a,a))},[n,L,V,ae,te,he,be,B,F,k.motion.duration.fast]),Se=(0,_react.useCallback)(e=>{if(n)return;const t="increment"===e.nativeEvent.actionName?i:-i,s=i>0?Math.round(t*ee)/ee:t;if(L){const e=Math.round((F.value+s)*ee)/ee,t=clamp(e,a,J.value);t!==F.value&&(F.value=t,B.value=te(t,V),be(),he(t,J.value))}else{const e=Math.round((F.value+s)*ee)/ee,t=clamp(e,a,r);t!==F.value&&(F.value=t,B.value=te(t,V),be(),he(t,t))}},[n,i,ee,L,a,r,te,V,B,F,J,he,be]),je=C.thumbDiameter/2,Ce=n?k.colors.surface.disabled:P,Me="inset"===l?{backgroundColor:Ce,borderColor:k.colors.background.elevated,borderWidth:Math.max(2,Math.round(.3*C.thumbDiameter)),...NO_SHADOW}:"minimal"===l?{backgroundColor:Ce,borderWidth:0}:"bar"===l?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:k.colors.background.elevated,borderColor:Ce},Oe=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=z.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=n?.55:1;if(L){const a=Math.max(0,G.value-B.value+2*M);return{opacity:t,transform:[{translateX:B.value-M},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:B.value+M-e},{scaleX:1}]}}),He=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:B.value-je},{scale:Z.value}]})),De=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:G.value-je},{scale:K.value}]})),Ae=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:$.value})),Ee=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:Q.value})),clampDisplay=e=>clamp(e,a,r),Te=clampDisplay(L?Math.min(...q):q),Ve=clampDisplay(L?Math.max(...q):q);return(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:[E.container,v,_],testID:w,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:n},"aria-disabled":n,accessibilityValue:L?{min:a,max:r,now:Te,text:`${Te} to ${Ve}`}:{min:a,max:r,now:Te},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Se,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:ke,disabled:n||L,style:E.trackTouch,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E.trackWrap,onLayout:me,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E.trackClip,pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[E.track,{backgroundColor:n?k.colors.surface.disabled:k.colors.border.primary},p]}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[E.fill,{backgroundColor:n?k.colors.surface.disabled:P},f,Oe]})]}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Ne,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[E.thumb,{width:C.thumbDiameter,height:C.thumbDiameter,borderRadius:je,..._corners.smoothCorners,opacity:n?.55:1},Me,g,He],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:c?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[E.bubbleWrap,Ae],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[E.bubble,{backgroundColor:P}],children:m?m(Te):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[E.bubbleText,{color:I},R],numberOfLines:1,children:d(Te)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[E.bubbleCaret,{backgroundColor:P}]})]}):null})}),L?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:we,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[E.thumb,{width:C.thumbDiameter,height:C.thumbDiameter,borderRadius:je,..._corners.smoothCorners,opacity:n?.55:1},Me,g,De],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:c?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[E.bubbleWrap,Ee],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[E.bubble,{backgroundColor:P}],children:m?m(Ve):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[E.bubbleText,{color:I},R],numberOfLines:1,children:d(Ve)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[E.bubbleCaret,{backgroundColor:P}]})]}):null})}):null]})})})});Slider.displayName="Slider";const buildStyles=(e,t)=>{const a=e.shadows.md,r=Math.max(t.thumbDiameter,t.trackHeight),i=r/2+4;return _reactNative.StyleSheet.create({container:{width:"100%",paddingVertical:i,justifyContent:"center"},trackTouch:{width:"100%",justifyContent:"center"},trackWrap:{width:"100%",height:r,justifyContent:"center"},trackClip:{position:"absolute",left:0,right:0,height:t.trackHeight,top:(r-t.trackHeight)/2,borderRadius:t.trackHeight/2,..._corners.smoothCorners,overflow:"hidden"},track:{position:"absolute",top:0,right:0,bottom:0,left:0,borderRadius:t.trackHeight/2,..._corners.smoothCorners},fill:{position:"absolute",top:0,left:0,width:"100%",height:t.trackHeight,borderRadius:t.trackHeight/2,..._corners.smoothCorners,transformOrigin:"left"},thumb:{position:"absolute",top:(r-t.thumbDiameter)/2,left:0,borderWidth:2,shadowColor:a.shadowColor,shadowOffset:a.shadowOffset,shadowOpacity:a.shadowOpacity,shadowRadius:a.shadowRadius,elevation:a.elevation,alignItems:"center",justifyContent:"center"},bubbleWrap:{position:"absolute",bottom:t.thumbDiameter+2,left:t.thumbDiameter/2-80,width:160,alignItems:"center"},bubbleCaret:{width:8,height:8,marginTop:-5,borderRadius:1,..._corners.smoothCorners,transform:[{rotate:"45deg"}]},bubble:{paddingHorizontal:e.spacing.sm,paddingVertical:e.spacing.xxs,borderRadius:e.radius.md,..._corners.smoothCorners,minWidth:36,alignItems:"center",justifyContent:"center",..._reactNative.Platform.select({ios:{shadowColor:e.shadows.sm.shadowColor,shadowOffset:e.shadows.sm.shadowOffset,shadowOpacity:e.shadows.sm.shadowOpacity,shadowRadius:e.shadows.sm.shadowRadius},android:{elevation:e.shadows.sm.elevation},default:{}})},bubbleText:{color:e.colors.onPrimary,fontSize:e.typography.fontSize.xs,fontWeight:e.typography.fontWeight.semibold}})};var _default=exports.default=Slider;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.TimePicker=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_Button=_interopRequireDefault(require("../Button/Button.js")),_PickerTrigger=require("../PickerTrigger/PickerTrigger.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_index2=require("../WheelPicker/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const range=(e,t,i=1)=>{const a=[];for(let r=e;r<=t;r+=i)a.push(r);return a},pad2=e=>e.toString().padStart(2,"0"),to24h=(e,t,i)=>"24h"===i?e:"AM"===t?12===e?0:e:12===e?12:e+12,from24h=(e,t)=>"24h"===t?{displayHour:e,period:"AM"}:0===e?{displayHour:12,period:"AM"}:12===e?{displayHour:12,period:"PM"}:e>12?{displayHour:e-12,period:"PM"}:{displayHour:e,period:"AM"},clampMinuteToStep=(e,t)=>{const i=Math.round(e/t)*t;return Math.min(59,Math.max(0,i))},TimePicker=e=>{const{visible:t,value:i,onChange:a,onClose:r,format:s="12h",minuteStep:n=1,title:o="Select Time",confirmLabel:l="Confirm",cancelLabel:c="Cancel",testID:u,style:d,containerStyle:m,headerLabelStyle:p,footerButtonStyle:g,label:h,placeholder:_,helperText:x,error:f,required:v,disabled:y,size:b,variant:j,clearable:N,onClear:M,formatValue:k,triggerStyle:R,haptic:S}=e,T=void 0!==e.visible,[D,P]=(0,_react.useState)(!1),C=T?t:D,w=T?u:u?`${u}-modal`:void 0,H=(0,_index.useTheme)(),A=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),q=(0,_react.useMemo)(()=>buildStyles(H),[H]),V=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,B=(0,_react.useRef)((0,_index.createAnimatedValue)(40)).current,$=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,I=(0,_react.useRef)(0),L=(0,_react.useCallback)(()=>{T?r?.():P(!1)},[T,r]),O=(0,_react.useCallback)(()=>{_reactNative.Animated.parallel([_reactNative.Animated.timing(V,{toValue:0,duration:H.motion.duration.fast,easing:_reactNative.Easing.bezier(...H.motion.easing.accelerate),useNativeDriver:!1}),_reactNative.Animated.timing(B,{toValue:40,duration:H.motion.duration.fast,easing:_reactNative.Easing.bezier(...H.motion.easing.accelerate),useNativeDriver:!0})]).start(()=>L())},[L,V,B,H.motion.duration.fast,H.motion.easing.accelerate]),{handleGesture:z}=(0,_useDragToDismiss.useDragToDismiss)({drag:$,travel:()=>I.current||320,onDismiss:O}),W=(0,_react.useMemo)(()=>"24h"===s?range(0,23):range(1,12),[s]),F=(0,_react.useMemo)(()=>range(0,59,n),[n]),E=(0,_react.useMemo)(()=>["AM","PM"],[]),G=(0,_react.useMemo)(()=>{const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),a=clampMinuteToStep(t,n),{displayHour:r,period:o}=from24h(e,s);return{displayHour:r,minute:a,period:o,hour24:e}},[i,s,n]),[U,Y]=(0,_react.useState)(()=>{const e=W.indexOf(G.displayHour);return e>=0?e:0}),[J,K]=(0,_react.useState)(()=>{const e=F.indexOf(G.minute);return e>=0?e:0}),[Q,X]=(0,_react.useState)(()=>"PM"===G.period?1:0);(0,_react.useEffect)(()=>{if(!C)return;const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),a=clampMinuteToStep(t,n),{displayHour:r,period:o}=from24h(e,s),l=W.indexOf(r);Y(l>=0?l:0);const c=F.indexOf(a);K(c>=0?c:0),X("PM"===o?1:0)},[C,i,s,n,W,F]),(0,_react.useEffect)(()=>{let e;return C?(e=_reactNative.Animated.parallel([_reactNative.Animated.timing(V,{toValue:1,duration:H.motion.duration.normal,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!1}),_reactNative.Animated.spring(B,{toValue:0,damping:H.motion.spring.snappy.damping,stiffness:H.motion.spring.snappy.stiffness,mass:H.motion.spring.snappy.mass,useNativeDriver:!0})]),e.start()):(V.setValue(0),(0,_index.setNativeValue)(B,40),(0,_index.setNativeValue)($,0)),()=>e?.stop()},[C,V,B,$,H.motion]);const Z=(0,_react.useCallback)((e,t)=>{"hour"===e?Y(Math.max(0,W.indexOf(Number(t)))):"minute"===e?K(Math.max(0,F.indexOf(Number(t)))):X("PM"===t?1:0)},[W,F]),ee=(0,_react.useCallback)(()=>{!1!==S&&(0,_hapticUtils.triggerHaptic)("selection"),O()},[O,S]),te=(0,_react.useCallback)(()=>{const e=W[U]??0,t=E[Q]??"AM",i=to24h(e,t,s),r=F[J]??0;!1!==S&&(0,_hapticUtils.triggerHaptic)("notificationSuccess"),a?.({hour:i,minute:r}),O()},[W,U,E,Q,F,J,s,a,O,S]),ie=(0,_react.useMemo)(()=>{const e=W[U]??0,t=F[J]??0;if("24h"===s)return`${pad2(e)}:${pad2(t)}`;const i=E[Q]??"AM";return`${pad2(e)}:${pad2(t)} ${i}`},[W,U,F,J,E,Q,s]),ae=(0,_react.useMemo)(()=>W.map(e=>({value:e,label:pad2(e),accessibilityLabel:`Hour ${e}`})),[W]),re=(0,_react.useMemo)(()=>F.map(e=>({value:e,label:pad2(e),accessibilityLabel:`${e} minutes`})),[F]),se=(0,_react.useMemo)(()=>E.map(e=>({value:e,label:e})),[E]),ne=(0,_react.useMemo)(()=>{const e=[{key:"hour",label:"Hour",items:ae,value:W[U]??0,separator:":",testID:"time-picker-hour"},{key:"minute",label:"Minute",items:re,value:F[J]??0,gapAfter:"12h"===s?H.spacing.md:void 0,testID:"time-picker-minute"}];return"12h"===s&&e.push({key:"period",label:"Period",items:se,value:E[Q]??"AM",testID:"time-picker-period"}),e},[ae,re,se,W,U,F,J,E,Q,s,H.spacing.md]),oe=(0,_react.useCallback)(e=>{if("24h"===s)return`${pad2(e.hour)}:${pad2(e.minute)}`;const{displayHour:t,period:i}=from24h(e.hour,"12h");return`${t}:${pad2(e.minute)} ${i}`},[s]),le=!T&&i&&Number.isFinite(i.hour)&&Number.isFinite(i.minute)?(k??oe)(i):void 0,ce=(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:C,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:O,testID:w,children:(0,_jsxRuntime.jsxs)(_reactNativeGestureHandler.GestureHandlerRootView,{collapsable:!1,style:q.backdrop,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:O,accessibilityLabel:"Close time picker",accessibilityRole:"button"}),(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[q.sheet,{paddingBottom:Math.max(A.bottom,H.spacing.lg),transform:[{translateY:_reactNative.Animated.add(B,$)}]},d,m],onLayout:e=>{I.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessible:!0,accessibilityRole:"none",accessibilityLabel:o,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:z,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:q.handle}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[q.title,p],accessibilityRole:"header",children:o})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:q.summaryWrap,accessibilityLiveRegion:"polite",accessibilityLabel:`Selected ${ie}`,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:q.summary,children:ie})}),(0,_jsxRuntime.jsx)(_index2.WheelPicker,{columns:ne,onChange:Z,haptic:S,style:q.wheels}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:q.footer,children:[(0,_jsxRuntime.jsx)(_Button.default,{title:c,haptic:!1,variant:"ghost",tone:"neutral",onPress:ee,style:[q.footerBtn,g],accessibilityHint:"Dismiss without changes",testID:"time-picker-cancel"}),(0,_jsxRuntime.jsx)(_Button.default,{title:l,variant:"solid",tone:"primary",haptic:!1,onPress:te,style:[q.footerBtn,g],accessibilityHint:"Confirm selected time",testID:"time-picker-confirm"})]})]}),(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})});return T?ce:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_PickerTrigger.PickerTrigger,{label:h,placeholder:_,helperText:x,error:f,required:v,disabled:y,size:b,variant:j,clearable:N,onClear:M,value:le,onPress:()=>P(!0),triggerStyle:R,testID:u}),ce]})};exports.TimePicker=TimePicker;const buildStyles=e=>{const t=e.shadows.xl;return _reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:e.colors.background.overlay,justifyContent:"flex-end"},sheet:{backgroundColor:e.colors.background.elevated,borderTopLeftRadius:e.radius.xl,borderTopRightRadius:e.radius.xl,..._corners.smoothCorners,paddingTop:e.spacing.sm,paddingHorizontal:e.spacing.lg,paddingBottom:e.spacing.xl,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},handle:{alignSelf:"center",width:e.components.timePicker?.handleWidth??36,height:e.components.timePicker?.handleHeight??4,borderRadius:e.radius.full,..._corners.smoothCorners,backgroundColor:e.colors.border.secondary,marginBottom:e.spacing.sm},title:{textAlign:"center",fontSize:e.typography.fontSize.lg,fontWeight:e.typography.fontWeight.semibold,color:e.colors.text.primary,marginBottom:e.spacing.sm},summaryWrap:{alignItems:"center",marginBottom:e.spacing.md},summary:{fontSize:e.typography.fontSize["2xl"],fontWeight:e.typography.fontWeight.bold,color:e.colors.primary,letterSpacing:e.typography.letterSpacing.wide},wheels:{marginBottom:e.spacing.lg},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:e.spacing.sm},footerBtn:{paddingHorizontal:e.spacing.lg}})};var _default=exports.default=TimePicker;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.TimePicker=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_useDragToDismiss=require("../../hooks/useDragToDismiss.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_Button=_interopRequireDefault(require("../Button/Button.js")),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_PickerTrigger=require("../PickerTrigger/PickerTrigger.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_index2=require("../WheelPicker/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const range=(e,t,i=1)=>{const a=[];for(let r=e;r<=t;r+=i)a.push(r);return a},pad2=e=>e.toString().padStart(2,"0"),to24h=(e,t,i)=>"24h"===i?e:"AM"===t?12===e?0:e:12===e?12:e+12,from24h=(e,t)=>"24h"===t?{displayHour:e,period:"AM"}:0===e?{displayHour:12,period:"AM"}:12===e?{displayHour:12,period:"PM"}:e>12?{displayHour:e-12,period:"PM"}:{displayHour:e,period:"AM"},clampMinuteToStep=(e,t)=>{const i=Math.round(e/t)*t;return Math.min(59,Math.max(0,i))},TimePicker=e=>{const{visible:t,value:i,onChange:a,onClose:r,format:s="12h",minuteStep:n=1,title:o="Select Time",confirmLabel:l="Confirm",cancelLabel:u="Cancel",testID:c,style:d,containerStyle:m,headerLabelStyle:p,footerButtonStyle:g,label:h,placeholder:_,helperText:f,error:x,required:y,disabled:b,size:v,variant:j,clearable:M,onClear:N,formatValue:R,triggerStyle:k,haptic:S}=e,T=void 0!==e.visible,[D,P]=(0,_react.useState)(!1),A=T?t:D,w=T?c:c?`${c}-modal`:void 0,H=(0,_index.useTheme)(),[C,q]=(0,_ModalSafeArea.useModalInsets)(),V=(0,_react.useMemo)(()=>buildStyles(H),[H]),B=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,$=(0,_react.useRef)((0,_index.createAnimatedValue)(40)).current,I=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,L=(0,_react.useRef)(0),O=(0,_react.useCallback)(()=>{T?r?.():P(!1)},[T,r]),z=(0,_react.useCallback)(()=>{_reactNative.Animated.parallel([_reactNative.Animated.timing(B,{toValue:0,duration:H.motion.duration.fast,easing:_reactNative.Easing.bezier(...H.motion.easing.accelerate),useNativeDriver:!1}),_reactNative.Animated.timing($,{toValue:40,duration:H.motion.duration.fast,easing:_reactNative.Easing.bezier(...H.motion.easing.accelerate),useNativeDriver:!0})]).start(()=>O())},[O,B,$,H.motion.duration.fast,H.motion.easing.accelerate]),{handleGesture:W}=(0,_useDragToDismiss.useDragToDismiss)({drag:I,travel:()=>L.current||320,onDismiss:z}),F=(0,_react.useMemo)(()=>"24h"===s?range(0,23):range(1,12),[s]),E=(0,_react.useMemo)(()=>range(0,59,n),[n]),G=(0,_react.useMemo)(()=>["AM","PM"],[]),U=(0,_react.useMemo)(()=>{const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),a=clampMinuteToStep(t,n),{displayHour:r,period:o}=from24h(e,s);return{displayHour:r,minute:a,period:o,hour24:e}},[i,s,n]),[Y,J]=(0,_react.useState)(()=>{const e=F.indexOf(U.displayHour);return e>=0?e:0}),[K,Q]=(0,_react.useState)(()=>{const e=E.indexOf(U.minute);return e>=0?e:0}),[X,Z]=(0,_react.useState)(()=>"PM"===U.period?1:0);(0,_react.useEffect)(()=>{if(!A)return;const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),a=clampMinuteToStep(t,n),{displayHour:r,period:o}=from24h(e,s),l=F.indexOf(r);J(l>=0?l:0);const u=E.indexOf(a);Q(u>=0?u:0),Z("PM"===o?1:0)},[A,i,s,n,F,E]),(0,_react.useEffect)(()=>{let e;return A?(e=_reactNative.Animated.parallel([_reactNative.Animated.timing(B,{toValue:1,duration:H.motion.duration.normal,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:!1}),_reactNative.Animated.spring($,{toValue:0,damping:H.motion.spring.snappy.damping,stiffness:H.motion.spring.snappy.stiffness,mass:H.motion.spring.snappy.mass,useNativeDriver:!0})]),e.start()):(B.setValue(0),(0,_index.setNativeValue)($,40),(0,_index.setNativeValue)(I,0)),()=>e?.stop()},[A,B,$,I,H.motion]);const ee=(0,_react.useCallback)((e,t)=>{"hour"===e?J(Math.max(0,F.indexOf(Number(t)))):"minute"===e?Q(Math.max(0,E.indexOf(Number(t)))):Z("PM"===t?1:0)},[F,E]),te=(0,_react.useCallback)(()=>{!1!==S&&(0,_hapticUtils.triggerHaptic)("selection"),z()},[z,S]),ie=(0,_react.useCallback)(()=>{const e=F[Y]??0,t=G[X]??"AM",i=to24h(e,t,s),r=E[K]??0;!1!==S&&(0,_hapticUtils.triggerHaptic)("notificationSuccess"),a?.({hour:i,minute:r}),z()},[F,Y,G,X,E,K,s,a,z,S]),ae=(0,_react.useMemo)(()=>{const e=F[Y]??0,t=E[K]??0;if("24h"===s)return`${pad2(e)}:${pad2(t)}`;const i=G[X]??"AM";return`${pad2(e)}:${pad2(t)} ${i}`},[F,Y,E,K,G,X,s]),re=(0,_react.useMemo)(()=>F.map(e=>({value:e,label:pad2(e),accessibilityLabel:`Hour ${e}`})),[F]),se=(0,_react.useMemo)(()=>E.map(e=>({value:e,label:pad2(e),accessibilityLabel:`${e} minutes`})),[E]),ne=(0,_react.useMemo)(()=>G.map(e=>({value:e,label:e})),[G]),oe=(0,_react.useMemo)(()=>{const e=[{key:"hour",label:"Hour",items:re,value:F[Y]??0,separator:":",testID:"time-picker-hour"},{key:"minute",label:"Minute",items:se,value:E[K]??0,gapAfter:"12h"===s?H.spacing.md:void 0,testID:"time-picker-minute"}];return"12h"===s&&e.push({key:"period",label:"Period",items:ne,value:G[X]??"AM",testID:"time-picker-period"}),e},[re,se,ne,F,Y,E,K,G,X,s,H.spacing.md]),le=(0,_react.useCallback)(e=>{if("24h"===s)return`${pad2(e.hour)}:${pad2(e.minute)}`;const{displayHour:t,period:i}=from24h(e.hour,"12h");return`${t}:${pad2(e.minute)} ${i}`},[s]),ue=!T&&i&&Number.isFinite(i.hour)&&Number.isFinite(i.minute)?(R??le)(i):void 0,ce=(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:A,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:z,testID:w,children:(0,_jsxRuntime.jsx)(_ModalSafeArea.ModalSafeArea,{onInsets:q,children:(0,_jsxRuntime.jsxs)(_reactNativeGestureHandler.GestureHandlerRootView,{collapsable:!1,style:V.backdrop,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:z,accessibilityLabel:"Close time picker",accessibilityRole:"button"}),(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[V.sheet,{paddingBottom:Math.max(C.bottom,H.spacing.lg),transform:[{translateY:_reactNative.Animated.add($,I)}]},d,m],onLayout:e=>{L.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessible:!0,accessibilityRole:"none",accessibilityLabel:o,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:W,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:V.handle}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[V.title,p],accessibilityRole:"header",children:o})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:V.summaryWrap,accessibilityLiveRegion:"polite",accessibilityLabel:`Selected ${ae}`,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:V.summary,children:ae})}),(0,_jsxRuntime.jsx)(_index2.WheelPicker,{columns:oe,onChange:ee,haptic:S,style:V.wheels}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:V.footer,children:[(0,_jsxRuntime.jsx)(_Button.default,{title:u,haptic:!1,variant:"ghost",tone:"neutral",onPress:te,style:[V.footerBtn,g],accessibilityHint:"Dismiss without changes",testID:"time-picker-cancel"}),(0,_jsxRuntime.jsx)(_Button.default,{title:l,variant:"solid",tone:"primary",haptic:!1,onPress:ie,style:[V.footerBtn,g],accessibilityHint:"Confirm selected time",testID:"time-picker-confirm"})]})]}),(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})})});return T?ce:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_PickerTrigger.PickerTrigger,{label:h,placeholder:_,helperText:f,error:x,required:y,disabled:b,size:v,variant:j,clearable:M,onClear:N,value:ue,onPress:()=>P(!0),triggerStyle:k,testID:c}),ce]})};exports.TimePicker=TimePicker;const buildStyles=e=>{const t=e.shadows.xl;return _reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:e.colors.background.overlay,justifyContent:"flex-end"},sheet:{backgroundColor:e.colors.background.elevated,borderTopLeftRadius:e.radius.xl,borderTopRightRadius:e.radius.xl,..._corners.smoothCorners,paddingTop:e.spacing.sm,paddingHorizontal:e.spacing.lg,paddingBottom:e.spacing.xl,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},handle:{alignSelf:"center",width:e.components.timePicker?.handleWidth??36,height:e.components.timePicker?.handleHeight??4,borderRadius:e.radius.full,..._corners.smoothCorners,backgroundColor:e.colors.border.secondary,marginBottom:e.spacing.sm},title:{textAlign:"center",fontSize:e.typography.fontSize.lg,fontWeight:e.typography.fontWeight.semibold,color:e.colors.text.primary,marginBottom:e.spacing.sm},summaryWrap:{alignItems:"center",marginBottom:e.spacing.md},summary:{fontSize:e.typography.fontSize["2xl"],fontWeight:e.typography.fontWeight.bold,color:e.colors.primary,letterSpacing:e.typography.letterSpacing.wide},wheels:{marginBottom:e.spacing.lg},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:e.spacing.sm},footerBtn:{paddingHorizontal:e.spacing.lg}})};var _default=exports.default=TimePicker;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Tooltip=void 0;var _react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_placement=require("../../utils/placement.js"),_focusHost=require("../Menu/focusHost.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_RichTooltipBody=require("./RichTooltipBody.js"),_tooltipPosition=require("./tooltipPosition.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap,i=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var o,a,s={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return s;if(o=t?i:r){if(o.has(e))return o.get(e);o.set(e,s)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((a=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?o(s,t,a):s[t]=e[t]);return s})(e,t)}const DEFAULT_TOOLTIP_GAP=8,DEFAULT_SCREEN_PADDING=8,DEFAULT_PRESS_AUTO_HIDE_MS=4e3,DEFAULT_ARROW_HALF_WIDTH=4,DEFAULT_ARROW_HEIGHT=6,DEFAULT_ARROW_CORNER_PADDING=12,DEFAULT_MAX_WIDTH=240,RICH_MAX_WIDTH=280,DEFAULT_LINE_HEIGHT=18,Tooltip=e=>{const{content:t,children:r,variant:i="plain",title:o,action:a,placement:s="auto",visible:n,onVisibleChange:c,hideOnContentPress:l=!0,maxWidth:u,showArrow:_=!0,accessibilityLabel:d,style:p,containerStyle:f,arrowStyle:m,messageStyle:h,closeLabel:g="Close tooltip",testID:v}=e,b="rich"===i,R=e.trigger??(b?"press":"longPress"),y=(0,_index.useTheme)(),x=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),T=(0,_reactNative.useWindowDimensions)(),j=(0,_react.useMemo)(()=>buildStyles(y),[y]),w=y.components.tooltip,A=w?.gap??8,N=w?.screenPadding??8,S=w?.pressAutoHideMs??4e3,P=w?.arrowHalfWidth??4,C=w?.arrowHeight??6,D=w?.arrowCornerPadding??12,E=w?.lineHeight??18,H=u??(b?280:w?.maxWidth??240),L="press"===R&&!b,W=w?.enableScaleAnimation??!1,O=w?.exitDurationMs??150,M="manual"===R||"boolean"==typeof n,[q,F]=(0,_react.useState)(!1),I=M?Boolean(n):q,[k,V]=(0,_react.useState)(null),[U,B]=(0,_react.useState)({width:0,height:0}),z=(0,_react.useRef)(null),G=(0,_react.useRef)(null),X=(0,_react.useRef)(null),Y=(0,_react.useRef)(null),J=(0,_react.useRef)(null),K=(0,_react.useRef)(!1),Q=(0,_react.useRef)(!1),Z=(0,_react.useRef)((0,_index.createAnimatedValue)(I?1:W?.85:1)).current,$=(0,_react.useRef)((0,_index.createAnimatedValue)(I?1:0)).current,ee=(0,_react.useRef)(null),te=(0,_react.useRef)(!1),re=(0,_react.useCallback)(e=>{M||F(e),c?.(e)},[M,c]),ie=(0,_react.useCallback)(()=>{z.current&&z.current.measureInWindow((e,t,r,i)=>{V({x:e,y:t,width:r,height:i})})},[]),oe=(0,_react.useCallback)(e=>{ie(),re(!0)},[ie,re]),ae=(0,_react.useCallback)(()=>{re(!1)},[re]),se=(0,_react.useRef)(ae);se.current=ae;const ne=(0,_react.useCallback)(()=>{if(!K.current)return;K.current=!1;const e=J.current;J.current=null,e?e():b&&(0,_focusHost.focusHost)(G.current??z.current)},[b]);(0,_react.useEffect)(()=>{if(I)return Q.current=!0,K.current=!1,(0,_placement.claimAnchoredSurface)(()=>se.current());Q.current&&(Q.current=!1,K.current=!0,"ios"!==_reactNative.Platform.OS&&ne())},[I]);const ce=(0,_react.useCallback)(()=>{J.current=a?.onPress??null,ae()},[a,ae]);(0,_react.useEffect)(()=>{if(!te.current)return te.current=!0,I&&(ie(),L&&(ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>{ae()},S))),()=>{ee.current&&(clearTimeout(ee.current),ee.current=null)};let e;if(I){ie();const t=[_reactNative.Animated.timing($,{toValue:1,duration:y.motion.duration.fast,useNativeDriver:!0})];W&&t.push(_reactNative.Animated.spring(Z,{toValue:1,damping:y.motion.spring.snappy.damping,stiffness:y.motion.spring.snappy.stiffness,mass:y.motion.spring.snappy.mass,useNativeDriver:!0})),e=_reactNative.Animated.parallel(t),e.start(),L&&(ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>{ae()},S))}else{const t=[_reactNative.Animated.timing($,{toValue:0,duration:O,easing:_reactNative.Easing.bezier(...y.motion.easing.accelerate),useNativeDriver:!0})];W&&t.push(_reactNative.Animated.timing(Z,{toValue:.85,duration:O,easing:_reactNative.Easing.bezier(...y.motion.easing.accelerate),useNativeDriver:!0})),e=_reactNative.Animated.parallel(t),e.start(),ee.current&&(clearTimeout(ee.current),ee.current=null)}return()=>{e?.stop(),ee.current&&(clearTimeout(ee.current),ee.current=null)}},[I]);const handleContentLayout=e=>{const{width:t,height:r}=e.nativeEvent.layout;t===U.width&&r===U.height||B({width:t,height:r})},le=(0,_react.useMemo)(()=>(0,_tooltipPosition.resolveTooltipPosition)({anchor:k,size:U,placement:s,rich:b,viewport:{width:T.width,height:T.height,insets:x},maxWidth:H,gap:A,padding:N,arrowCornerPadding:D}),[k,U,s,b,T.width,T.height,x,H,A,N,D]),ue=I&&null!==k&&U.width>0;(0,_react.useEffect)(()=>{if(!b||!ue)return;const e="web"===_reactNative.Platform.OS?Y:X,t=setTimeout(()=>(0,_focusHost.focusHost)(e.current),_focusHost.FOCUS_DELAY_MS);return()=>clearTimeout(t)},[b,ue]);const _e=r.props,de=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(_e.ref,G),[_e.ref]),pe={};"longPress"!==R||_e.contextMenu?"press"===R&&(pe.onPress=e=>{_e.onPress?.(e),oe(e)}):(pe.onLongPress=oe,pe.accessibilityHint="Long press for more info"),b&&(pe.ref=de);const fe=_react.default.cloneElement(r,pe),me=d??("string"==typeof t?t:"Tooltip"),he=(0,_react.useMemo)(()=>{if(!_)return null;const e=b?y.colors.background.elevated:y.colors.background.inverse,t={position:"absolute",width:0,height:0,backgroundColor:"transparent",borderStyle:"solid",borderLeftWidth:P,borderRightWidth:P,borderBottomWidth:C,borderTopWidth:0,borderLeftColor:"transparent",borderRightColor:"transparent",borderTopColor:"transparent",borderBottomColor:e};return"top"===le.placement?{...t,bottom:-C,left:le.arrowOffset-P,transform:[{rotate:"180deg"}]}:"bottom"===le.placement?{...t,top:-C,left:le.arrowOffset-P}:"left"===le.placement?{...t,right:-C,top:le.arrowOffset-P,transform:[{rotate:"90deg"}]}:{...t,left:-C,top:le.arrowOffset-P,transform:[{rotate:"-90deg"}]}},[_,le,y,b,P,C]),ge={position:"absolute",top:le.top,left:le.left,maxWidth:H,opacity:ue?$:0,transform:[{scale:Z}]},ve=he?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[he,m],pointerEvents:"none"}):null;return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{ref:z,collapsable:!1,onLayout:ie,testID:v,children:fe}),(0,_jsxRuntime.jsxs)(_reactNative.Modal,{visible:I,transparent:!0,statusBarTranslucent:!0,presentationStyle:"overFullScreen",animationType:"none",onRequestClose:ae,onDismiss:ne,children:[b?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:l?ae:void 0,accessibilityLabel:g,accessibilityRole:"button"}),I?(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{onLayout:handleContentLayout,style:[ge,p,f],children:[(0,_jsxRuntime.jsx)(_RichTooltipBody.RichTooltipBody,{title:o,content:t,action:a,onAction:ce,focusRef:X,actionRef:Y,messageStyle:h}),ve]}):null]}):(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:l?ae:void 0,accessibilityLabel:g,accessibilityRole:"button",children:I?(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{accessibilityRole:"tooltip",accessibilityLiveRegion:"polite",accessibilityLabel:me,onLayout:handleContentLayout,style:[ge,p,f],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[j.tooltip,{backgroundColor:y.colors.background.inverse,borderRadius:y.radius.md,..._corners.smoothCorners,paddingHorizontal:y.spacing.md,paddingVertical:y.spacing.sm,...y.shadows.lg,shadowColor:y.shadows.lg.shadowColor}],children:"string"==typeof t?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{color:y.colors.text.inverse,fontSize:y.typography.fontSize.sm,lineHeight:E},h],children:t}):t}),ve]}):null}),(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})]})};exports.Tooltip=Tooltip;const buildStyles=e=>_reactNative.StyleSheet.create({tooltip:{overflow:"hidden"}});var _default=exports.default=Tooltip;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Tooltip=void 0;var _react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_placement=require("../../utils/placement.js"),_focusHost=require("../Menu/focusHost.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_RichTooltipBody=require("./RichTooltipBody.js"),_tooltipPosition=require("./tooltipPosition.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap,o=new WeakMap;return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,s={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return s;if(i=t?o:r){if(i.has(e))return i.get(e);i.set(e,s)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(s,t,a):s[t]=e[t]);return s})(e,t)}const DEFAULT_TOOLTIP_GAP=8,DEFAULT_SCREEN_PADDING=8,DEFAULT_PRESS_AUTO_HIDE_MS=4e3,DEFAULT_ARROW_HALF_WIDTH=4,DEFAULT_ARROW_HEIGHT=6,DEFAULT_ARROW_CORNER_PADDING=12,DEFAULT_MAX_WIDTH=240,RICH_MAX_WIDTH=280,DEFAULT_LINE_HEIGHT=18,Tooltip=e=>{const{content:t,children:r,variant:o="plain",title:i,action:a,placement:s="auto",visible:n,onVisibleChange:l,hideOnContentPress:c=!0,maxWidth:u,showArrow:d=!0,accessibilityLabel:_,style:f,containerStyle:p,arrowStyle:m,messageStyle:h,closeLabel:g="Close tooltip",testID:b}=e,v="rich"===o,R=e.trigger??(v?"press":"longPress"),x=(0,_index.useTheme)(),y=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[T,j]=(0,_ModalSafeArea.useModalInsets)(),A=(0,_react.useMemo)(()=>({...y,top:T.top,bottom:T.bottom}),[y,T]),w=(0,_reactNative.useWindowDimensions)(),S=(0,_react.useMemo)(()=>buildStyles(x),[x]),N=x.components.tooltip,P=N?.gap??8,C=N?.screenPadding??8,D=N?.pressAutoHideMs??4e3,M=N?.arrowHalfWidth??4,E=N?.arrowHeight??6,H=N?.arrowCornerPadding??12,L=N?.lineHeight??18,W=u??(v?280:N?.maxWidth??240),O="press"===R&&!v,q=N?.enableScaleAnimation??!1,I=N?.exitDurationMs??150,F="manual"===R||"boolean"==typeof n,[k,V]=(0,_react.useState)(!1),U=F?Boolean(n):k,[B,z]=(0,_react.useState)(null),[G,X]=(0,_react.useState)({width:0,height:0}),Y=(0,_react.useRef)(null),J=(0,_react.useRef)(null),K=(0,_react.useRef)(null),Q=(0,_react.useRef)(null),Z=(0,_react.useRef)(null),$=(0,_react.useRef)(!1),ee=(0,_react.useRef)(!1),te=(0,_react.useRef)((0,_index.createAnimatedValue)(U?1:q?.85:1)).current,re=(0,_react.useRef)((0,_index.createAnimatedValue)(U?1:0)).current,oe=(0,_react.useRef)(null),ie=(0,_react.useRef)(!1),ae=(0,_react.useCallback)(e=>{F||V(e),l?.(e)},[F,l]),se=(0,_react.useCallback)(()=>{Y.current&&Y.current.measureInWindow((e,t,r,o)=>{z({x:e,y:t,width:r,height:o})})},[]),ne=(0,_react.useCallback)(e=>{se(),ae(!0)},[se,ae]),le=(0,_react.useCallback)(()=>{ae(!1)},[ae]),ce=(0,_react.useRef)(le);ce.current=le;const ue=(0,_react.useCallback)(()=>{if(!$.current)return;$.current=!1;const e=Z.current;Z.current=null,e?e():v&&(0,_focusHost.focusHost)(J.current??Y.current)},[v]);(0,_react.useEffect)(()=>{if(U)return ee.current=!0,$.current=!1,(0,_placement.claimAnchoredSurface)(()=>ce.current());ee.current&&(ee.current=!1,$.current=!0,"ios"!==_reactNative.Platform.OS&&ue())},[U]);const de=(0,_react.useCallback)(()=>{Z.current=a?.onPress??null,le()},[a,le]);(0,_react.useEffect)(()=>{if(!ie.current)return ie.current=!0,U&&(se(),O&&(oe.current&&clearTimeout(oe.current),oe.current=setTimeout(()=>{le()},D))),()=>{oe.current&&(clearTimeout(oe.current),oe.current=null)};let e;if(U){se();const t=[_reactNative.Animated.timing(re,{toValue:1,duration:x.motion.duration.fast,useNativeDriver:!0})];q&&t.push(_reactNative.Animated.spring(te,{toValue:1,damping:x.motion.spring.snappy.damping,stiffness:x.motion.spring.snappy.stiffness,mass:x.motion.spring.snappy.mass,useNativeDriver:!0})),e=_reactNative.Animated.parallel(t),e.start(),O&&(oe.current&&clearTimeout(oe.current),oe.current=setTimeout(()=>{le()},D))}else{const t=[_reactNative.Animated.timing(re,{toValue:0,duration:I,easing:_reactNative.Easing.bezier(...x.motion.easing.accelerate),useNativeDriver:!0})];q&&t.push(_reactNative.Animated.timing(te,{toValue:.85,duration:I,easing:_reactNative.Easing.bezier(...x.motion.easing.accelerate),useNativeDriver:!0})),e=_reactNative.Animated.parallel(t),e.start(),oe.current&&(clearTimeout(oe.current),oe.current=null)}return()=>{e?.stop(),oe.current&&(clearTimeout(oe.current),oe.current=null)}},[U]);const handleContentLayout=e=>{const{width:t,height:r}=e.nativeEvent.layout;t===G.width&&r===G.height||X({width:t,height:r})},fe=(0,_react.useMemo)(()=>(0,_tooltipPosition.resolveTooltipPosition)({anchor:B,size:G,placement:s,rich:v,viewport:{width:w.width,height:w.height,insets:A},maxWidth:W,gap:P,padding:C,arrowCornerPadding:H}),[B,G,s,v,w.width,w.height,A,W,P,C,H]),pe=U&&null!==B&&G.width>0;(0,_react.useEffect)(()=>{if(!v||!pe)return;const e="web"===_reactNative.Platform.OS?Q:K,t=setTimeout(()=>(0,_focusHost.focusHost)(e.current),_focusHost.FOCUS_DELAY_MS);return()=>clearTimeout(t)},[v,pe]);const me=r.props,he=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(me.ref,J),[me.ref]),ge={};"longPress"!==R||me.contextMenu?"press"===R&&(ge.onPress=e=>{me.onPress?.(e),ne(e)}):(ge.onLongPress=ne,ge.accessibilityHint="Long press for more info"),v&&(ge.ref=he);const be=_react.default.cloneElement(r,ge),ve=_??("string"==typeof t?t:"Tooltip"),Re=(0,_react.useMemo)(()=>{if(!d)return null;const e=v?x.colors.background.elevated:x.colors.background.inverse,t={position:"absolute",width:0,height:0,backgroundColor:"transparent",borderStyle:"solid",borderLeftWidth:M,borderRightWidth:M,borderBottomWidth:E,borderTopWidth:0,borderLeftColor:"transparent",borderRightColor:"transparent",borderTopColor:"transparent",borderBottomColor:e};return"top"===fe.placement?{...t,bottom:-E,left:fe.arrowOffset-M,transform:[{rotate:"180deg"}]}:"bottom"===fe.placement?{...t,top:-E,left:fe.arrowOffset-M}:"left"===fe.placement?{...t,right:-E,top:fe.arrowOffset-M,transform:[{rotate:"90deg"}]}:{...t,left:-E,top:fe.arrowOffset-M,transform:[{rotate:"-90deg"}]}},[d,fe,x,v,M,E]),xe={position:"absolute",top:fe.top,left:fe.left,maxWidth:W,opacity:pe?re:0,transform:[{scale:te}]},ye=Re?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[Re,m],pointerEvents:"none"}):null;return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.View,{ref:Y,collapsable:!1,onLayout:se,testID:b,children:be}),(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:U,transparent:!0,statusBarTranslucent:!0,presentationStyle:"overFullScreen",animationType:"none",onRequestClose:le,onDismiss:ue,children:(0,_jsxRuntime.jsxs)(_ModalSafeArea.ModalSafeArea,{onInsets:j,children:[v?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:c?le:void 0,accessibilityLabel:g,accessibilityRole:"button"}),U?(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{onLayout:handleContentLayout,style:[xe,f,p],children:[(0,_jsxRuntime.jsx)(_RichTooltipBody.RichTooltipBody,{title:i,content:t,action:a,onAction:de,focusRef:K,actionRef:Q,messageStyle:h}),ye]}):null]}):(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:c?le:void 0,accessibilityLabel:g,accessibilityRole:"button",children:U?(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{accessibilityRole:"tooltip",accessibilityLiveRegion:"polite",accessibilityLabel:ve,onLayout:handleContentLayout,style:[xe,f,p],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[S.tooltip,{backgroundColor:x.colors.background.inverse,borderRadius:x.radius.md,..._corners.smoothCorners,paddingHorizontal:x.spacing.md,paddingVertical:x.spacing.sm,...x.shadows.lg,shadowColor:x.shadows.lg.shadowColor}],children:"string"==typeof t?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{color:x.colors.text.inverse,fontSize:x.typography.fontSize.sm,lineHeight:L},h],children:t}):t}),ye]}):null}),(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})})]})};exports.Tooltip=Tooltip;const buildStyles=e=>_reactNative.StyleSheet.create({tooltip:{overflow:"hidden"}});var _default=exports.default=Tooltip;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useForm=useForm;var _react=require("react"),_equal=require("./equal.js"),_path=require("./path.js");const rulesFor=(e,r)=>{if(!e||"function"==typeof e)return[];const t=e[r];return t?Array.isArray(t)?t:[t]:[]};function useForm(e){const r=(0,_react.useRef)(e);r.current=e;const t=(0,_react.useRef)(e.initialValues),[u,a]=(0,_react.useState)(e.initialValues),[c,n]=(0,_react.useState)({}),[s,o]=(0,_react.useState)({}),[l,i]=(0,_react.useState)(!1),[f,_]=(0,_react.useState)(!1),[d,v]=(0,_react.useState)(0),b=(0,_react.useRef)({values:u,errors:c,touched:s,submitCount:d});b.current={values:u,errors:c,touched:s,submitCount:d};const h=(0,_react.useRef)(new Map),y=(0,_react.useRef)([]),C=(0,_react.useRef)(null),k=(0,_react.useRef)({values:e.initialValues,version:0});(0,_equal.valuesEqual)(e.initialValues,k.current.values)||(k.current={values:e.initialValues,version:k.current.version+1});const p=k.current.version;(0,_react.useEffect)(()=>{if(!r.current.enableReinitialize)return;const e=r.current.initialValues;t.current=e,b.current.values=e,b.current.errors={},b.current.touched={},a(e),n({}),o({})},[p]);const m=(0,_react.useCallback)(async e=>{const t=r.current.validate,u=b.current.values;if("function"==typeof t){return(await t(u)??{})[e]||void 0}const a=(0,_path.getPath)(u,e);for(const r of rulesFor(t,e)){const e=await r(a,u);if(e)return e}},[]),g=(0,_react.useCallback)(async e=>{const t=r.current.validate;if(!t)return{};if("function"==typeof t)return await t(e)??{};const u={};return await Promise.all(Object.keys(t).map(async r=>{const a=(0,_path.getPath)(e,r);for(const c of rulesFor(t,r)){const t=await c(a,e);if(t){u[r]=t;break}}})),u},[]),F=(0,_react.useCallback)(async e=>{const r=await m(e);n(t=>{if(t[e]===r)return t;const u={...t};return r?u[e]=r:delete u[e],b.current.errors=u,u})},[m]),w=(0,_react.useCallback)(async()=>{_(!0);const e=await g(b.current.values);return _(!1),b.current.errors=e,n(e),e},[g]),q=(0,_react.useCallback)((e,t,u)=>{const c=(0,_path.setPath)(b.current.values,e,t);b.current.values=c,a(c);const n=r.current,s=Boolean(b.current.errors[e])&&"blur"===n.revalidateOn;(u??(!s&&(b.current.touched[e]||b.current.submitCount>0||"change"===n.validateOn)))&&F(e)},[F]),E=(0,_react.useCallback)(e=>{o(r=>{if(r[e])return r;const t={...r,[e]:!0};return b.current.touched=t,t}),F(e)},[F]),P=(0,_react.useCallback)((e,r=!0,t)=>{const u={...b.current.touched,[e]:r};b.current.touched=u,o(u),(t??r)&&F(e)},[F]),S=(0,_react.useCallback)((e,r)=>{n(t=>{const u={...t};return r?u[e]=r:delete u[e],b.current.errors=u,u})},[]),V=(0,_react.useCallback)(e=>{b.current.errors=e,n(e)},[]),O=(0,_react.useCallback)((e,r)=>{const t="function"==typeof e?e(b.current.values):{...b.current.values,...e};b.current.values=t,a(t),r&&w()},[w]),j=(0,_react.useCallback)(e=>{const r=e?{...t.current,...e}:t.current;t.current=r,b.current.values=r,b.current.errors={},b.current.touched={},b.current.submitCount=0,a(r),n({}),o({}),v(0)},[]),R=(0,_react.useCallback)((e,r)=>{r?(h.current.set(e,r),y.current.includes(e)||y.current.push(e)):(h.current.delete(e),y.current=y.current.filter(r=>r!==e))},[]),M=(0,_react.useCallback)(e=>{C.current=e},[]),x=(0,_react.useCallback)(e=>{const r=y.current,t=C.current,u=t?r.indexOf(t):-1,a=r[u+e];a&&(C.current=a,h.current.get(a)?.focus?.())},[]),B=(0,_react.useCallback)(()=>x(1),[x]),A=(0,_react.useCallback)(()=>x(-1),[x]),T=(0,_react.useMemo)(()=>({setErrors:V,setFieldError:S,reset:j,setSubmitting:i}),[V,S,j]),z=(0,_react.useCallback)(()=>{(async()=>{const e=r.current,t=b.current.values;b.current.submitCount+=1,v(e=>e+1),_(!0);const u=await g(t);_(!1);const a=new Set([...y.current,...Object.keys(u)]),c={...b.current.touched};a.forEach(e=>{c[e]=!0}),b.current.touched=c,b.current.errors=u,o(c),n(u);const s=y.current.find(e=>u[e])??Object.keys(u).find(e=>u[e]);if(s)h.current.get(s)?.focus?.();else{i(!0);try{await e.onSubmit(t,T)}finally{i(!1)}}})()},[g,T]),N=(0,_react.useMemo)(()=>{const e={};for(const r of Object.keys(c))c[r]&&(s[r]||d>0)&&(e[r]=c[r]);return e},[c,s,d]),D=(0,_react.useMemo)(()=>{const e=r.current.validate;if(!e)return!0;if("function"==typeof e)return Object.values(c).every(e=>!e);for(const r of Object.keys(e)){const t=(0,_path.getPath)(u,r);for(const a of rulesFor(e,r)){const e=a(t,u);if("string"==typeof e&&e)return!1}}return!0},[u,c]),G=(0,_react.useMemo)(()=>!(0,_equal.valuesEqual)(u,t.current),[u]);return{values:u,errors:N,rawErrors:c,touched:s,dirty:G,isValid:D,isSubmitting:l,isValidating:f,submitCount:d,setFieldValue:q,setFieldTouched:P,setFieldError:S,setValues:O,setErrors:V,reset:j,validate:w,validateField:m,submit:z,handleBlur:E,focusNext:B,focusPrev:A,registerField:R,getFieldState:e=>{const r=(0,_path.getPath)(u,e),a=c[e],n=!!s[e];return{value:r,error:n||d>0?a:void 0,rawError:a,touched:n,dirty:!(0,_equal.valuesEqual)(r,(0,_path.getPath)(t.current,e))}},getFieldProps:e=>({name:e,value:(0,_path.getPath)(u,e),error:s[e]||d>0?c[e]:void 0,touched:!!s[e],onChange:r=>q(e,r),onChangeText:r=>q(e,r),onBlur:()=>E(e),onFocus:()=>M(e),setValue:(r,t)=>q(e,r,t)})}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useForm=useForm;var _react=require("react"),_equal=require("./equal.js"),_path=require("./path.js");const rulesFor=(e,r)=>{if(!e||"function"==typeof e)return[];const t=e[r];return t?Array.isArray(t)?t:[t]:[]};function useForm(e){const r=(0,_react.useRef)(e);r.current=e;const t=(0,_react.useRef)(e.initialValues),[u,a]=(0,_react.useState)(e.initialValues),[c,n]=(0,_react.useState)({}),[s,o]=(0,_react.useState)({}),[l,i]=(0,_react.useState)(!1),[f,_]=(0,_react.useState)(!1),[d,v]=(0,_react.useState)(0),b=(0,_react.useRef)({values:u,errors:c,touched:s,submitCount:d});b.current={values:u,errors:c,touched:s,submitCount:d};const h=(0,_react.useRef)(new Map),y=(0,_react.useRef)([]),C=(0,_react.useRef)(null),k=(0,_react.useRef)({values:e.initialValues,version:0});(0,_equal.valuesEqual)(e.initialValues,k.current.values)||(k.current={values:e.initialValues,version:k.current.version+1});const p=k.current.version;(0,_react.useEffect)(()=>{if(!r.current.enableReinitialize)return;const e=r.current.initialValues;t.current=e,b.current.values=e,b.current.errors={},b.current.touched={},a(e),n({}),o({})},[p]);const m=(0,_react.useCallback)(async e=>{const t=r.current.validate,u=b.current.values;if("function"==typeof t){return(await t(u)??{})[e]||void 0}const a=(0,_path.getPath)(u,e);for(const r of rulesFor(t,e)){const e=await r(a,u);if(e)return e}},[]),g=(0,_react.useCallback)(async e=>{const t=r.current.validate;if(!t)return{};if("function"==typeof t)return await t(e)??{};const u={};return await Promise.all(Object.keys(t).map(async r=>{const a=(0,_path.getPath)(e,r);for(const c of rulesFor(t,r)){const t=await c(a,e);if(t){u[r]=t;break}}})),u},[]),F=(0,_react.useCallback)(async e=>{const r=await m(e);n(t=>{if(t[e]===r)return t;const u={...t};return r?u[e]=r:delete u[e],b.current.errors=u,u})},[m]),w=(0,_react.useCallback)(async()=>{_(!0);const e=await g(b.current.values);return _(!1),b.current.errors=e,n(e),e},[g]),q=(0,_react.useCallback)((e,t,u)=>{const c=(0,_path.setPath)(b.current.values,e,t);b.current.values=c,a(c);const n=r.current,s=Boolean(b.current.errors[e])&&"blur"===n.revalidateOn;(u??(!s&&(b.current.touched[e]||b.current.submitCount>0||"change"===n.validateOn)))&&F(e)},[F]),E=(0,_react.useCallback)(e=>{o(r=>{if(r[e])return r;const t={...r,[e]:!0};return b.current.touched=t,t}),F(e)},[F]),P=(0,_react.useCallback)((e,r=!0,t)=>{const u={...b.current.touched,[e]:r};b.current.touched=u,o(u),(t??r)&&F(e)},[F]),S=(0,_react.useCallback)((e,r)=>{n(t=>{const u={...t};return r?u[e]=r:delete u[e],b.current.errors=u,u})},[]),V=(0,_react.useCallback)(e=>{b.current.errors=e,n(e)},[]),O=(0,_react.useCallback)((e,r)=>{const t="function"==typeof e?e(b.current.values):{...b.current.values,...e};b.current.values=t,a(t),r&&w()},[w]),j=(0,_react.useCallback)(e=>{const r=e?{...t.current,...e}:t.current;t.current=r,b.current.values=r,b.current.errors={},b.current.touched={},b.current.submitCount=0,a(r),n({}),o({}),v(0)},[]),R=(0,_react.useCallback)((e,r)=>{r?(h.current.set(e,r),y.current.includes(e)||y.current.push(e)):(h.current.delete(e),y.current=y.current.filter(r=>r!==e))},[]),M=(0,_react.useCallback)(e=>{C.current=e},[]),x=(0,_react.useCallback)(e=>{const r=y.current,t=C.current,u=t?r.indexOf(t):-1,a=r[u+e];a&&(C.current=a,h.current.get(a)?.focus?.())},[]),B=(0,_react.useCallback)(()=>x(1),[x]),A=(0,_react.useCallback)(()=>x(-1),[x]),T=(0,_react.useMemo)(()=>({setErrors:V,setFieldError:S,reset:j,setSubmitting:i}),[V,S,j]),z=(0,_react.useRef)(!1),N=(0,_react.useCallback)(()=>{z.current||(z.current=!0,(async()=>{try{const e=r.current,t=b.current.values;let u;b.current.submitCount+=1,v(e=>e+1),_(!0);try{u=await g(t)}finally{_(!1)}const a=new Set([...y.current,...Object.keys(u)]),c={...b.current.touched};a.forEach(e=>{c[e]=!0}),b.current.touched=c,b.current.errors=u,o(c),n(u);const s=y.current.find(e=>u[e])??Object.keys(u).find(e=>u[e]);if(s)return void h.current.get(s)?.focus?.();i(!0);try{await e.onSubmit(t,T)}finally{i(!1)}}finally{z.current=!1}})())},[g,T]),D=(0,_react.useMemo)(()=>{const e={};for(const r of Object.keys(c))c[r]&&(s[r]||d>0)&&(e[r]=c[r]);return e},[c,s,d]),G=(0,_react.useMemo)(()=>{const e=r.current.validate;if(!e)return!0;if("function"==typeof e)return Object.values(c).every(e=>!e);for(const r of Object.keys(e)){const t=(0,_path.getPath)(u,r);for(const a of rulesFor(e,r)){const e=a(t,u);if("string"==typeof e&&e)return!1}}return!0},[u,c]),H=(0,_react.useMemo)(()=>!(0,_equal.valuesEqual)(u,t.current),[u]);return{values:u,errors:D,rawErrors:c,touched:s,dirty:H,isValid:G,isSubmitting:l,isValidating:f,submitCount:d,setFieldValue:q,setFieldTouched:P,setFieldError:S,setValues:O,setErrors:V,reset:j,validate:w,validateField:m,submit:N,handleBlur:E,focusNext:B,focusPrev:A,registerField:R,getFieldState:e=>{const r=(0,_path.getPath)(u,e),a=c[e],n=!!s[e];return{value:r,error:n||d>0?a:void 0,rawError:a,touched:n,dirty:!(0,_equal.valuesEqual)(r,(0,_path.getPath)(t.current,e))}},getFieldProps:e=>({name:e,value:(0,_path.getPath)(u,e),error:s[e]||d>0?c[e]:void 0,touched:!!s[e],onChange:r=>q(e,r),onChangeText:r=>q(e,r),onBlur:()=>E(e),onFocus:()=>M(e),setValue:(r,t)=>q(e,r,t)})}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useDragToDismiss=exports.createDragToDismissController=exports.DRAG_DISMISS_VELOCITY=exports.DRAG_DISMISS_DISTANCE=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_index=require("../theme/index.js");const DRAG_DISMISS_DISTANCE=exports.DRAG_DISMISS_DISTANCE=100,DRAG_DISMISS_VELOCITY=exports.DRAG_DISMISS_VELOCITY=.5,createDragToDismissController=({drag:e,travel:t,onDismiss:r},s)=>{const{snappy:a}=s.spring,springBack=()=>_reactNative.Animated.spring(e,{toValue:0,damping:a.damping,stiffness:a.stiffness,mass:a.mass,useNativeDriver:!0}).start();return{move:t=>{(0,_index.setNativeValue)(e,Math.max(0,t))},release:(a,i)=>{a>DRAG_DISMISS_DISTANCE||i>DRAG_DISMISS_VELOCITY?_reactNative.Animated.timing(e,{toValue:"function"==typeof t?t():t,duration:s.duration.fast,easing:_reactNative.Easing.bezier(...s.easing.accelerate),useNativeDriver:!0}).start(()=>r()):springBack()},cancel:springBack}};exports.createDragToDismissController=createDragToDismissController;const useDragToDismiss=e=>{const{drag:t,travel:r,onDismiss:s,contentAtTop:a,scrollGesture:i}=e,{motion:n}=(0,_index.useTheme)();return(0,_react.useMemo)(()=>{const e=createDragToDismissController({drag:t,travel:r,onDismiss:s},n),o=_reactNativeGestureHandler.Gesture.Pan().runOnJS(!0).activeOffsetY(6).failOffsetX([-12,12]).onUpdate(t=>e.move(t.translationY)).onEnd(t=>e.release(t.translationY,t.velocityY/1e3)).onFinalize((t,r)=>{r||e.cancel()});let l=0,D=!1;const c=_reactNativeGestureHandler.Gesture.Pan().runOnJS(!0).activeOffsetY(8).failOffsetX([-12,12]).onBegin(()=>{l=0,D=!1}).onUpdate(t=>{if(!D){if(a&&!a())return;D=!0,l=t.translationY}e.move(t.translationY-l)}).onEnd(t=>{D&&e.release(t.translationY-l,t.velocityY/1e3)}).onFinalize((t,r)=>{!r&&D&&e.cancel()});return i&&c.simultaneousWithExternalGesture(i),{handleGesture:o,sheetGesture:c}},[t,r,s,a,i,n])};exports.useDragToDismiss=useDragToDismiss;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useDragToDismiss=exports.createDragToDismissController=exports.DRAG_DISMISS_VELOCITY=exports.DRAG_DISMISS_DISTANCE=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_index=require("../theme/index.js");const DRAG_DISMISS_DISTANCE=exports.DRAG_DISMISS_DISTANCE=100,DRAG_DISMISS_VELOCITY=exports.DRAG_DISMISS_VELOCITY=.5,createDragToDismissController=({drag:e,travel:t,onDismiss:r},s)=>{const{snappy:a}=s.spring,springBack=()=>_reactNative.Animated.spring(e,{toValue:0,damping:a.damping,stiffness:a.stiffness,mass:a.mass,useNativeDriver:!0}).start();return{move:t=>{(0,_index.setNativeValue)(e,Math.max(0,t))},release:(a,i)=>{a>DRAG_DISMISS_DISTANCE||i>DRAG_DISMISS_VELOCITY?_reactNative.Animated.timing(e,{toValue:"function"==typeof t?t():t,duration:s.duration.fast,easing:_reactNative.Easing.bezier(...s.easing.accelerate),useNativeDriver:!0}).start(()=>r()):springBack()},cancel:springBack}};exports.createDragToDismissController=createDragToDismissController;const useDragToDismiss=e=>{const{drag:t,travel:r,onDismiss:s,contentAtTop:a,scrollGesture:i}=e,{motion:n}=(0,_index.useTheme)();return(0,_react.useMemo)(()=>{const e=createDragToDismissController({drag:t,travel:r,onDismiss:s},n),o=_reactNativeGestureHandler.Gesture.Pan().runOnJS(!0).activeOffsetY(6).failOffsetX([-12,12]).onUpdate(t=>e.move(t.translationY)).onEnd(t=>e.release(t.translationY,t.velocityY/1e3)).onFinalize((_e,t)=>{t||e.cancel()});let l=0,D=!1;const c=_reactNativeGestureHandler.Gesture.Pan().runOnJS(!0).activeOffsetY(8).failOffsetX([-12,12]).onBegin(()=>{l=0,D=!1}).onUpdate(t=>{if(!D){if(a&&!a())return;D=!0,l=t.translationY}e.move(t.translationY-l)}).onEnd(t=>{D&&e.release(t.translationY-l,t.velocityY/1e3)}).onFinalize((_e,t)=>{!t&&D&&e.cancel()});return i&&c.simultaneousWithExternalGesture(i),{handleGesture:o,sheetGesture:c}},[t,r,s,a,i,n])};exports.useDragToDismiss=useDragToDismiss;
@@ -1 +1 @@
1
- "use strict";import React,{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,LayoutAnimation,Platform,Pressable,StyleSheet,Text,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{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{renderSlotIcon}from"../AppIcon/index.js";import{useScreenReaderEnabled}from"./useScreenReaderEnabled.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";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_PILL_INSET=16,DEFAULT_UNDERLINE_HEIGHT=3,DEFAULT_FLOATING_MARGIN=16,DEFAULT_FLOATING_RADIUS=28,DEFAULT_BUBBLE_SIZE=48,DEFAULT_BUBBLE_LIFT=14,DEFAULT_CENTER_SIZE=48,DEFAULT_CENTER_ICON_SIZE=24,CENTER_KEY="__webority_center_action__",TAB_PADDING_VERTICAL=6,BAR_PADDING_HORIZONTAL=4,BAR_PADDING_TOP=6,BAR_PADDING_TOP_BUBBLE=8,FLOATING_BAR_PADDING_VERTICAL=6,FLOATING_BAR_PADDING_HORIZONTAL=8,EXPANDED_FLEX=1.5,SOLID_INACTIVE_OPACITY=.7,TILE_INSET=2,TILE_LABEL_GAP=2,formatBadge=e=>null==e||!1===e?null:!0===e||"·"===e?{text:"",isDot:!0}:"number"==typeof e?e<=0?null:{text:e>99?"99+":String(e),isDot:!1}:"string"==typeof e?0===e.length?null:{text:e,isDot:!1}:null,badgeAccessibilitySuffix=e=>null==e||!1===e?"":"number"==typeof e?e>0?`, ${e} unread`:"":!0===e||"·"===e?", new updates":"string"==typeof e&&e.length>0?`, ${e}`:"",BottomNavigation=forwardRef((e,t)=>{const{tabs:i,centerAction:n,activeTab:o,onChange:r,haptic:a="selection",showLabels:l=!0,variant:s="pill",indicatorPosition:d="bottom",radius:c,indicatorRadius:u="auto",elevation:h,iconSize:m,marginHorizontal:p,marginVertical:g,paddingHorizontal:b,paddingVertical:y,border:f,minimizeOnScroll:x=!1,scrollDirection:_="idle",accessory:A,style:I,indicatorStyle:R,labelStyle:S,labelMaxFontScale:E,testID:w}=e,L=useTheme(),T=useSafeAreaInsets(),D=useMemo(()=>buildStyles(L),[L]),v=L.components.bottomNavigation,C=m??v?.iconSize??18,j=v?.pillHeight??C+4+8,B=v?.pillMaxWidth??64,N=v?.pillInset??16,V=v?.floatingMargin??16,P=v?.floatingRadius??28,M=v?.bubbleSize??48,k=v?.bubbleLift??14,F=useReducedMotion(),H=useScreenReaderEnabled(x),[z,O]=React.useState(null);useEffect(()=>{null!==z&&z!==_&&O(null)},[z,_]);const W=x&&!H&&"down"===_&&null===z,[U,G]=React.useState(W);useEffect(()=>{U!==W&&(F||"web"===Platform.OS||LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut),G(W))},[U,W,F]);const $="function"==typeof A?A({minimized:U}):A,X=null!=$&&!1!==$,Z=U&&X,[Y,K]=React.useState(0),q=X&&!Z?Y+L.spacing.xs:0,J="tile"===s,Q="floating"===s||J,ee="bubble"===s,te="expand"===s,ie="solid"===s,ne="pill"===s||Q||ie,oe=Math.max(0,i.findIndex(e=>e.key===o)),[re,ae]=React.useState(0),[le,se]=React.useState(0),de=n?Math.ceil(i.length/2):i.length,ce=i.length+(n?1:0),[ue,he]=React.useState({width:0,height:0}),me=n?.size??48,pe=void 0!==n?.gap,ge=Math.max(0,n?.gap??0),be=pe?(ue.width||me)+2*ge:0,ye=pe?i.length>0?Math.max(0,re-be)/i.length:0:ce>0?re/ce:0,fe=pe?be:ye,xe=useRef(createAnimatedValue(oe)).current,_e=useRef({}),Ae=useRef({});i.forEach(e=>{_e.current[e.key]||(_e.current[e.key]=new Animated.Value(1)),Ae.current[e.key]||(Ae.current[e.key]=createAnimatedValue(e.key===o?1:0))});const Ie=ye>0?J?Math.min(ye-4,96):Math.min(ye-N,B):0,Re=ye>0?(ye-Ie)/2:0,Se=ye>0?(ye-M)/2:0,hasLabel=e=>l&&!U&&!1!==e.showLabel&&e.label.trim().length>0,Ee=i[oe],we=Ee&&!hasLabel(Ee)&&le>0?le/2:6+(C+4)/2,Le=we-k-M/2,Te=Math.max(0,le-4),De=J?2:we-j/2,ve=useRef(oe);useEffect(()=>{if(ve.current===oe)return;ve.current=oe;const e=Animated.spring(xe,{toValue:oe,tension:120,friction:14,useNativeDriver:!0});return e.start(),()=>e.stop()},[oe,xe]);const Ce=Math.max(1,i.length-1),je=useMemo(()=>{const e=[],t=[];for(let i=0;i<=Ce;i++)e.push(i),t.push(i<de?i*ye:i*ye+fe);return xe.interpolate({inputRange:e,outputRange:t})},[xe,Ce,de,ye,fe]),Be=i.map(e=>e.key).join(" "),Ne=ee||te;useEffect(()=>{const e=Be.split(" ").flatMap(e=>{const t=e===o?1:0,i=Ae.current[e];return i?Ne?[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,Ne]);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()},Ve=useRef(new Animated.Value(1)).current,{colors:Pe}=L,Me=ie?Pe.primary:Pe.background.elevated,ke=ie?Pe.onPrimary:Pe.primary,Fe=ie?Pe.onPrimary:J?Pe.text.primary:Pe.text.tertiary,He=ie?Pe.onPrimary:Pe.primaryMuted,ze=ie?Pe.primary:ee?Pe.onPrimary:ke,Oe=p??V,We=g??(Q?V:0),Ue=We>0,Ge=y??(Q?6:ee?8:6),$e=b??(Q?8:4),Xe=Ue?Ge:Math.max(Ge,T.bottom),Ze=Ue?Math.max(We,T.bottom):0,Ye="full"===c,Ke=Q?le+q+2*Ge+2*StyleSheet.hairlineWidth:le+q+Ge+Xe,qe=Ye?le>0?Ke/2:L.radius.full:c??v?.borderRadius??(J?L.radius.full:Q?P:0),Je=void 0!==c||void 0!==v?.borderRadius,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&Je?Math.min(qe,e/2):t,Qe="underline"===s?Math.max($e,Ye&&0===le?0:qe):$e,et=h??"none",tt=L.shadows[et],it="none"===et?null:supportsBoxShadow()?{boxShadow:toBoxShadow(tt)}:tt,nt=f?StyleSheet.hairlineWidth:0,ot=ie?Pe.primary:Pe.border.primary,rt=n?.lift??0,at=Ge+nt+q,lt=n&&le>0?Math.max(0,(ue.height||me)/2+rt-le/2-at):0,st=n?_jsx(View,{style:[D.centerCell,pe?{flex:0,marginHorizontal:ge}:null],pointerEvents:"box-none",children:_jsx(Pressable,{onPress:()=>{if(!n)return;const e=n.haptic??a;!1!==e&&triggerHaptic(e),popIcon(Ve),n.onPress()},onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;he(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},style:({pressed:e})=>[{top:-rt},e?{opacity:.85}:null],testID:n.testID??(w?`${w}-center`:void 0),children:n.content?_jsx(Animated.View,{style:{transform:[{scale:Ve}]},children:n.content}):_jsx(View,{style:[D.centerCircle,{width:me,height:me,borderRadius:me/2,...smoothCorners,backgroundColor:n.color??Pe.primary}],children:_jsx(Animated.View,{style:{transform:[{scale:Ve}]},children:renderSlotIcon(n.icon??"add",{color:n.iconColor??Pe.onPrimary,size:n.iconSize??24,disabled:!1})})})})},CENTER_KEY):null,dt=X?_jsx(View,{style:Z?D.accessoryInline:D.accessoryStacked,onLayout:e=>K(e.nativeEvent.layout.height),testID:w?`${w}-accessory`:void 0,children:$}):null,ct=_jsxs(View,{style:Z?[D.tabRow,D.tabRowInline]:D.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ae(t),se(i)},children:[ne&&Ie>0&&(!J||Te>0)?_jsx(Animated.View,{pointerEvents:"none",style:[D.pill,{width:Ie,height:J?Te:j,left:Re,top:De,backgroundColor:He,borderRadius:J?activeBgRadius(Te,Te/2):activeBgRadius(j,L.radius.full),...smoothCorners,transform:[{translateX:je}]},R]}):null,ee&&ye>0?_jsx(Animated.View,{pointerEvents:"none",style:[D.bubble,L.shadows.md,{width:M,height:M,borderRadius:M/2,...smoothCorners,left:Se,top:Le,backgroundColor:Pe.primary,borderColor:Pe.background.elevated,transform:[{translateX:je}]},R]}):null,(ut=i.map(e=>{const t=e.key===o,i=t?ke:Fe,n=t?ze:Fe,l="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,s=t?e.activeIcon??l:e.icon,d=_e.current[e.key],c=Ae.current[e.key],u=formatBadge(e.badge??null),h=badgeAccessibilitySuffix(e.badge??null),m=ie&&!t?.7:1,p=ee&&t||ie?Pe.primary:Pe.background.elevated,g=hasLabel(e),b=g&&(!te||t),y=_jsxs(Animated.View,{style:[D.iconWrap,{width:C+4,height:C+4,opacity:m,transform:[{scale:d}]}],children:[renderSlotIcon(s,{color:n,size:C,focused:t,disabled:!1}),u?_jsx(View,{style:[u.isDot?D.badgeDot:D.badgePill,{backgroundColor:Pe.error,borderColor:p}],children:u.isDot?null:_jsx(Text,{style:[D.badgeText,{color:Pe.onError}],numberOfLines:1,children:u.text})}):null]}),f=ee?_jsx(Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-k]})},children:y}):y,x=b?_jsx(Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:E??L.maxFontSizeMultiplier??1.2,style:[D.label,te?D.labelInline:null,{color:i,opacity:te?c:m,fontWeight:t?L.typography.fontWeight.semibold:L.typography.fontWeight.normal},S],children:e.label}):null,A=_jsx(Pressable,{onPress:()=>(e=>{U&&O(_),e.key!==o&&!1!==a&&triggerHaptic(a);const t=_e.current[e.key];t&&popIcon(t),r(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${h}`,accessibilityHint:`Switches to ${e.label}`,hitSlop:{top:6,bottom:6,left:6,right:6},style:({pressed:e})=>[D.tab,J?D.tabTile:null,e?{opacity:.85}:null],testID:w?`${w}-tab-${e.key}`:void 0,children:te?_jsxs(View,{style:[D.expandPill,{height:j,paddingHorizontal:t&&g?L.spacing.md:Math.max(0,(j-(C+4))/2)}],children:[_jsx(View,{pointerEvents:"none",style:[D.expandFill,{borderRadius:activeBgRadius(j,j/2),...smoothCorners,backgroundColor:t?Pe.primaryMuted:"transparent"},t?R:null]}),f,x]}):_jsxs(_Fragment,{children:[f,x]})},e.key);return te?_jsx(Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,g?1.5:1]})},children:A},e.key):A}),st?[...ut.slice(0,de),st,...ut.slice(de)]:ut),"underline"===s&&ye>0?_jsx(Animated.View,{pointerEvents:"none",style:[D.underline,"top"===d?D.underlineTop:D.underlineBottom,"top"===d?{top:-Ge-q}:{bottom:-Ge},{width:ye,height:v?.underlineHeight??3,backgroundColor:Pe.primary,transform:[{translateX:je}]},R]}):null]});var ut;return _jsx(View,{ref:t,testID:w,accessibilityRole:"tablist",style:[D.outer,{paddingHorizontal:Oe,paddingTop:Math.max(We,lt),paddingBottom:Ze},I],children:_jsxs(View,{style:[Q?D.floatingBar:D.dockedBar,Z?D.barInline:null,it,{backgroundColor:Me,borderColor:ot,borderRadius:qe,...smoothCorners},Q?{borderWidth:nt,paddingHorizontal:$e,paddingVertical:Ge}:{borderTopWidth:nt,borderBottomWidth:nt,borderLeftWidth:nt,borderRightWidth:nt,paddingHorizontal:Qe,paddingTop:Ge,paddingBottom:Xe}],children:[dt,ct]})})});BottomNavigation.displayName="BottomNavigation";const buildStyles=e=>StyleSheet.create({outer:{backgroundColor:"transparent"},dockedBar:{paddingHorizontal:4},floatingBar:{paddingVertical:6,paddingHorizontal:8},tabRow:{flexDirection:"row",alignItems:"stretch",position:"relative"},tabRowInline:{flex:1},barInline:{flexDirection:"row",alignItems:"center"},accessoryStacked:{marginBottom:e.spacing.xs},accessoryInline:{flexShrink:0,marginRight:e.spacing.xs},tab:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center",paddingVertical:6,gap:4},tabTile:{paddingVertical:8,gap:2},centerCell:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center"},centerCircle:{alignItems:"center",justifyContent:"center"},iconWrap:{alignItems:"center",justifyContent:"center",position:"relative"},label:{fontSize:e.typography.fontSize.xs,lineHeight:e.typography.fontSize.xs*e.typography.lineHeight.tight,textAlign:"center",includeFontPadding:!1},labelInline:{fontSize:e.typography.fontSize.sm,lineHeight:e.typography.fontSize.sm*e.typography.lineHeight.tight,flexShrink:1,includeFontPadding:!1},expandPill:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:e.spacing.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:2,borderTopRightRadius:2,...smoothCorners},underlineTop:{borderBottomLeftRadius:2,borderBottomRightRadius:2,...smoothCorners},badgePill:{position:"absolute",top:-4,right:-8,minWidth:18,height:18,borderRadius:9,...smoothCorners,paddingHorizontal:4,paddingVertical:2,alignItems:"center",justifyContent:"center",borderWidth:1.5},badgeDot:{position:"absolute",top:-2,right:-2,width:10,height:10,borderRadius:5,...smoothCorners,borderWidth:1.5},badgeText:{fontSize:10,fontWeight:"700",lineHeight:12,textAlign:"center",includeFontPadding:!1}});export{BottomNavigation};export default BottomNavigation;
1
+ "use strict";import React,{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,LayoutAnimation,Platform,Pressable,StyleSheet,Text,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{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{renderSlotIcon}from"../AppIcon/index.js";import{useScreenReaderEnabled}from"./useScreenReaderEnabled.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";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_PILL_INSET=16,DEFAULT_UNDERLINE_HEIGHT=3,DEFAULT_FLOATING_MARGIN=16,DEFAULT_FLOATING_RADIUS=28,DEFAULT_BUBBLE_SIZE=48,DEFAULT_BUBBLE_LIFT=14,DEFAULT_CENTER_SIZE=48,DEFAULT_CENTER_ICON_SIZE=24,CENTER_KEY="__webority_center_action__",TAB_PADDING_VERTICAL=6,BAR_PADDING_HORIZONTAL=4,BAR_PADDING_TOP=6,BAR_PADDING_TOP_BUBBLE=8,FLOATING_BAR_PADDING_VERTICAL=6,FLOATING_BAR_PADDING_HORIZONTAL=8,EXPANDED_FLEX=1.5,SOLID_INACTIVE_OPACITY=.7,TILE_INSET=2,TILE_LABEL_GAP=2,formatBadge=e=>null==e||!1===e?null:!0===e||"·"===e?{text:"",isDot:!0}:"number"==typeof e?e<=0?null:{text:e>99?"99+":String(e),isDot:!1}:"string"==typeof e?0===e.length?null:{text:e,isDot:!1}:null,badgeAccessibilitySuffix=e=>null==e||!1===e?"":"number"==typeof e?e>0?`, ${e} unread`:"":!0===e||"·"===e?", new updates":"string"==typeof e&&e.length>0?`, ${e}`:"",BottomNavigation=forwardRef((e,t)=>{const{tabs:i,centerAction:n,activeTab:o,onChange:r,haptic:a="selection",showLabels:l=!0,variant:s="pill",indicatorPosition:d="bottom",radius:c,indicatorRadius:u="auto",elevation:h,iconSize:m,marginHorizontal:p,marginVertical:g,paddingHorizontal:b,paddingVertical:y,border:f,minimizeOnScroll:x=!1,scrollDirection:_="idle",accessory:A,style:I,indicatorStyle:R,labelStyle:S,labelMaxFontScale:E,testID:w}=e,L=useTheme(),T=useSafeAreaInsets(),D=useMemo(()=>buildStyles(L),[L]),v=L.components.bottomNavigation,C=m??v?.iconSize??18,j=v?.pillHeight??C+4+8,B=v?.pillMaxWidth??64,N=v?.pillInset??16,V=v?.floatingMargin??16,P=v?.floatingRadius??28,M=v?.bubbleSize??48,k=v?.bubbleLift??14,F=useReducedMotion(),H=useScreenReaderEnabled(x),[z,O]=React.useState(null);useEffect(()=>{null!==z&&z!==_&&O(null)},[z,_]);const W=x&&!H&&"down"===_&&null===z,[U,G]=React.useState(W);useEffect(()=>{U!==W&&(F||"web"===Platform.OS||LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut),G(W))},[U,W,F]);const $="function"==typeof A?A({minimized:U}):A,X=null!=$&&!1!==$,Z=U&&X,[Y,K]=React.useState(0),q=X&&!Z?Y+L.spacing.xs:0,J="tile"===s,Q="floating"===s||J,ee="bubble"===s,te="expand"===s,ie="solid"===s,ne="pill"===s||Q||ie,oe=Math.max(0,i.findIndex(e=>e.key===o)),[re,ae]=React.useState(0),[le,se]=React.useState(0),de=n?Math.ceil(i.length/2):i.length,ce=i.length+(n?1:0),[ue,he]=React.useState({width:0,height:0}),me=n?.size??48,pe=void 0!==n?.gap,ge=Math.max(0,n?.gap??0),be=pe?(ue.width||me)+2*ge:0,ye=pe?i.length>0?Math.max(0,re-be)/i.length:0:ce>0?re/ce:0,fe=pe?be:ye,xe=useRef(createAnimatedValue(oe)).current,Ae=useRef({}),Ie=useRef({});i.forEach(e=>{Ae.current[e.key]||(Ae.current[e.key]=new Animated.Value(1)),Ie.current[e.key]||(Ie.current[e.key]=createAnimatedValue(e.key===o?1:0))});const Re=ye>0?J?Math.min(ye-4,96):Math.min(ye-N,B):0,Se=ye>0?(ye-Re)/2:0,Ee=ye>0?(ye-M)/2:0,hasLabel=e=>l&&!U&&!1!==e.showLabel&&e.label.trim().length>0,we=i[oe],Le=we&&!hasLabel(we)&&le>0?le/2:6+(C+4)/2,Te=Le-k-M/2,De=Math.max(0,le-4),ve=J?2:Le-j/2,Ce=useRef(oe);useEffect(()=>{if(Ce.current===oe)return;Ce.current=oe;const e=Animated.spring(xe,{toValue:oe,tension:120,friction:14,useNativeDriver:!0});return e.start(),()=>e.stop()},[oe,xe]);const je=Math.max(1,i.length-1),Be=useMemo(()=>{const e=[],t=[];for(let i=0;i<=je;i++)e.push(i),t.push(i<de?i*ye:i*ye+fe);return xe.interpolate({inputRange:e,outputRange:t})},[xe,je,de,ye,fe]),Ne=i.map(e=>e.key).join(" "),Ve=ee||te;useEffect(()=>{const e=Ne.split(" ").flatMap(e=>{const t=e===o?1:0,i=Ie.current[e];return i?Ve?[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,Ne,Ve]);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()},Pe=useRef(new Animated.Value(1)).current,{colors:Me}=L,ke=ie?Me.primary:Me.background.elevated,Fe=ie?Me.onPrimary:Me.primary,He=ie?Me.onPrimary:J?Me.text.primary:Me.text.tertiary,ze=ie?Me.onPrimary:Me.primaryMuted,Oe=ie?Me.primary:ee?Me.onPrimary:Fe,We=p??V,Ue=g??(Q?V:0),Ge=Ue>0,$e=y??(Q?6:ee?8:6),Xe=b??(Q?8:4),Ze=Ge?$e:Math.max($e,T.bottom),Ye=Ge?Math.max(Ue,T.bottom):0,Ke="full"===c,qe=Q?le+q+2*$e+2*StyleSheet.hairlineWidth:le+q+$e+Ze,Je=Ke?le>0?qe/2:L.radius.full:c??v?.borderRadius??(J?L.radius.full:Q?P:0),Qe=void 0!==c||void 0!==v?.borderRadius,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&Qe?Math.min(Je,e/2):t,et="underline"===s?Math.max(Xe,Ke&&0===le?0:Je):Xe,tt=h??"none",it=L.shadows[tt],nt="none"===tt?null:supportsBoxShadow()?{boxShadow:toBoxShadow(it)}:it,ot=f?StyleSheet.hairlineWidth:0,rt=ie?Me.primary:Me.border.primary,at=n?.lift??0,lt=$e+ot+q,st=n&&le>0?Math.max(0,(ue.height||me)/2+at-le/2-lt):0,dt=n?_jsx(View,{style:[D.centerCell,pe?{flex:0,marginHorizontal:ge}:null],pointerEvents:"box-none",children:_jsx(Pressable,{onPress:()=>{if(!n)return;const e=n.haptic??a;!1!==e&&triggerHaptic(e),popIcon(Pe),n.onPress()},onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;he(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},style:({pressed:e})=>[{top:-at},e?{opacity:.85}:null],testID:n.testID??(w?`${w}-center`:void 0),children:n.content?_jsx(Animated.View,{style:{transform:[{scale:Pe}]},children:n.content}):_jsx(View,{style:[D.centerCircle,{width:me,height:me,borderRadius:me/2,...smoothCorners,backgroundColor:n.color??Me.primary}],children:_jsx(Animated.View,{style:{transform:[{scale:Pe}]},children:renderSlotIcon(n.icon??"add",{color:n.iconColor??Me.onPrimary,size:n.iconSize??24,disabled:!1})})})})},CENTER_KEY):null,ct=X?_jsx(View,{style:Z?D.accessoryInline:D.accessoryStacked,onLayout:e=>K(e.nativeEvent.layout.height),testID:w?`${w}-accessory`:void 0,children:$}):null,ut=_jsxs(View,{style:Z?[D.tabRow,D.tabRowInline]:D.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ae(t),se(i)},children:[ne&&Re>0&&(!J||De>0)?_jsx(Animated.View,{pointerEvents:"none",style:[D.pill,{width:Re,height:J?De:j,left:Se,top:ve,backgroundColor:ze,borderRadius:J?activeBgRadius(De,De/2):activeBgRadius(j,L.radius.full),...smoothCorners,transform:[{translateX:Be}]},R]}):null,ee&&ye>0?_jsx(Animated.View,{pointerEvents:"none",style:[D.bubble,L.shadows.md,{width:M,height:M,borderRadius:M/2,...smoothCorners,left:Ee,top:Te,backgroundColor:Me.primary,borderColor:Me.background.elevated,transform:[{translateX:Be}]},R]}):null,(ht=i.map(e=>{const t=e.key===o,i=t?Fe:He,n=t?Oe:He,l="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,s=t?e.activeIcon??l:e.icon,d=Ae.current[e.key],c=Ie.current[e.key],u=formatBadge(e.badge??null),h=badgeAccessibilitySuffix(e.badge??null),m=ie&&!t?.7:1,p=ee&&t||ie?Me.primary:Me.background.elevated,g=hasLabel(e),b=g&&(!te||t),y=_jsxs(Animated.View,{style:[D.iconWrap,{width:C+4,height:C+4,opacity:m,transform:[{scale:d}]}],children:[renderSlotIcon(s,{color:n,size:C,focused:t,disabled:!1}),u?_jsx(View,{style:[u.isDot?D.badgeDot:D.badgePill,{backgroundColor:Me.error,borderColor:p}],children:u.isDot?null:_jsx(Text,{style:[D.badgeText,{color:Me.onError}],numberOfLines:1,children:u.text})}):null]}),f=ee?_jsx(Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-k]})},children:y}):y,x=b?_jsx(Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:E??L.maxFontSizeMultiplier??1.2,style:[D.label,te?D.labelInline:null,{color:i,opacity:te?c:m,fontWeight:t?L.typography.fontWeight.semibold:L.typography.fontWeight.normal},S],children:e.label}):null,A=_jsx(Pressable,{onPress:()=>(e=>{U&&O(_),e.key!==o&&!1!==a&&triggerHaptic(a);const t=Ae.current[e.key];t&&popIcon(t),r(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${h}`,accessibilityHint:`Switches to ${e.label}`,hitSlop:{top:6,bottom:6,left:6,right:6},style:({pressed:e})=>[D.tab,J?D.tabTile:null,e?{opacity:.85}:null],testID:w?`${w}-tab-${e.key}`:void 0,children:te?_jsxs(View,{style:[D.expandPill,{height:j,paddingHorizontal:t&&g?L.spacing.md:Math.max(0,(j-(C+4))/2)}],children:[_jsx(View,{pointerEvents:"none",style:[D.expandFill,{borderRadius:activeBgRadius(j,j/2),...smoothCorners,backgroundColor:t?Me.primaryMuted:"transparent"},t?R:null]}),f,x]}):_jsxs(_Fragment,{children:[f,x]})},e.key);return te?_jsx(Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,g?1.5:1]})},children:A},e.key):A}),dt?[...ht.slice(0,de),dt,...ht.slice(de)]:ht),"underline"===s&&ye>0?_jsx(Animated.View,{pointerEvents:"none",style:[D.underline,"top"===d?D.underlineTop:D.underlineBottom,"top"===d?{top:-$e-q}:{bottom:-$e},{width:ye,height:v?.underlineHeight??3,backgroundColor:Me.primary,transform:[{translateX:Be}]},R]}):null]});var ht;return _jsx(View,{ref:t,testID:w,accessibilityRole:"tablist",style:[D.outer,{paddingHorizontal:We,paddingTop:Math.max(Ue,st),paddingBottom:Ye},I],children:_jsxs(View,{style:[Q?D.floatingBar:D.dockedBar,Z?D.barInline:null,nt,{backgroundColor:ke,borderColor:rt,borderRadius:Je,...smoothCorners},Q?{borderWidth:ot,paddingHorizontal:Xe,paddingVertical:$e}:{borderTopWidth:ot,borderBottomWidth:ot,borderLeftWidth:ot,borderRightWidth:ot,paddingHorizontal:et,paddingTop:$e,paddingBottom:Ze}],children:[ct,ut]})})});BottomNavigation.displayName="BottomNavigation";const buildStyles=e=>StyleSheet.create({outer:{backgroundColor:"transparent"},dockedBar:{paddingHorizontal:4},floatingBar:{paddingVertical:6,paddingHorizontal:8},tabRow:{flexDirection:"row",alignItems:"stretch",position:"relative"},tabRowInline:{flex:1},barInline:{flexDirection:"row",alignItems:"center"},accessoryStacked:{marginBottom:e.spacing.xs},accessoryInline:{flexShrink:0,marginRight:e.spacing.xs},tab:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center",paddingVertical:6,gap:4},tabTile:{paddingVertical:8,gap:2},centerCell:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center"},centerCircle:{alignItems:"center",justifyContent:"center"},iconWrap:{alignItems:"center",justifyContent:"center",position:"relative"},label:{fontSize:e.typography.fontSize.xs,lineHeight:e.typography.fontSize.xs*e.typography.lineHeight.tight,textAlign:"center",includeFontPadding:!1},labelInline:{fontSize:e.typography.fontSize.sm,lineHeight:e.typography.fontSize.sm*e.typography.lineHeight.tight,flexShrink:1,includeFontPadding:!1},expandPill:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:e.spacing.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:2,borderTopRightRadius:2,...smoothCorners},underlineTop:{borderBottomLeftRadius:2,borderBottomRightRadius:2,...smoothCorners},badgePill:{position:"absolute",top:-4,right:-8,minWidth:18,height:18,borderRadius:9,...smoothCorners,paddingHorizontal:4,paddingVertical:2,alignItems:"center",justifyContent:"center",borderWidth:1.5},badgeDot:{position:"absolute",top:-2,right:-2,width:10,height:10,borderRadius:5,...smoothCorners,borderWidth:1.5},badgeText:{fontSize:10,fontWeight:"700",lineHeight:12,textAlign:"center",includeFontPadding:!1}});export{BottomNavigation};export default BottomNavigation;