@webority/mobile-ui 0.98.0 → 0.100.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/canvas-kit/kit.js +6169 -6148
  2. package/dist/canvas-kit/manifest.json +2 -2
  3. package/dist/canvas-kit/release.json +6 -6
  4. package/lib/commonjs/components/Banner/Banner.js +1 -1
  5. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  6. package/lib/commonjs/components/Card/Card.js +1 -1
  7. package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
  8. package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
  9. package/lib/commonjs/components/FilePicker/FilePicker.js +1 -1
  10. package/lib/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +1 -1
  11. package/lib/commonjs/components/ListItem/ListItem.js +1 -1
  12. package/lib/commonjs/components/MessageList/MessageList.js +1 -1
  13. package/lib/commonjs/components/Modal/Modal.js +1 -1
  14. package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
  15. package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
  16. package/lib/commonjs/components/Swipeable/Swipeable.js +1 -1
  17. package/lib/commonjs/components/Toast/Toast.js +1 -1
  18. package/lib/commonjs/form/path.js +1 -1
  19. package/lib/commonjs/utils/announce.js +1 -1
  20. package/lib/module/components/Banner/Banner.js +1 -1
  21. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  22. package/lib/module/components/Card/Card.js +1 -1
  23. package/lib/module/components/DatePicker/DatePicker.js +1 -1
  24. package/lib/module/components/FieldBase/FieldBase.js +1 -1
  25. package/lib/module/components/FilePicker/FilePicker.js +1 -1
  26. package/lib/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +1 -1
  27. package/lib/module/components/ListItem/ListItem.js +1 -1
  28. package/lib/module/components/MessageList/MessageList.js +1 -1
  29. package/lib/module/components/Modal/Modal.js +1 -1
  30. package/lib/module/components/OTPInput/OTPInput.js +1 -1
  31. package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
  32. package/lib/module/components/Swipeable/Swipeable.js +1 -1
  33. package/lib/module/components/Toast/Toast.js +1 -1
  34. package/lib/module/form/path.js +1 -1
  35. package/lib/module/utils/announce.js +1 -1
  36. package/package.json +7 -7
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Modal=exports.MODAL_DISMISS_GRACE_MS=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_squircle=require("../../utils/squircle.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");const MODAL_DISMISS_GRACE_MS=exports.MODAL_DISMISS_GRACE_MS=300,SCALE_START_VALUE=.9,Modal=exports.Modal=(0,_react.forwardRef)((e,t)=>{const{visible:r,onRequestClose:a,presentation:i="centered",backdropOpacity:s,backdropPressClose:n=!0,animationDuration:o,animateMount:l=!0,accessibilityLabel:c,hardwareBackPress:u=!0,children:d,contentStyle:m,backdropStyle:_,restoreFocusRef:f,onDismissed:p,haptic:v,testID:g}=e,b=(0,_index.useTheme)(),S=(0,_usePresenceMotion.usePresenceMotion)(),[h,x]=(0,_ModalSafeArea.useModalInsets)(),A=o??S.duration("default"),M=_reactNative.Dimensions.get("window").height,N=(0,_react.useRef)(!l&&r),R=N.current,y=(0,_react.useRef)((0,_index.createAnimatedValue)(R?1:.9)).current,j=(0,_react.useRef)((0,_index.createAnimatedValue)(R?1:0)).current,q=(0,_react.useRef)((0,_index.createAnimatedValue)(R?0:M)).current,C=(0,_react.useRef)((0,_index.createAnimatedValue)(R?1:0)).current,V=(0,_react.useRef)(null),D=(0,_react.useRef)(!1),[T,w]=(0,_react.useState)(r),I=(0,_react.useMemo)(()=>buildStyles(b),[b]),E=(0,_react.useMemo)(()=>{const e=b.colors.scrim;return"number"!=typeof s?e:(0,_color.withAlpha)(e,s)??e},[b.colors.scrim,s]),P=(0,_react.useMemo)(()=>C.interpolate({inputRange:[0,1],outputRange:[(0,_color.transparentOf)(E),E]}),[C,E]);(0,_react.useEffect)(()=>{r&&w(!0)},[r]),(0,_react.useEffect)(()=>{const e=[];if(r&&T&&N.current)N.current=!1;else if(r&&T){const t=_reactNative.Animated.timing(C,{toValue:1,duration:S.duration("default"),useNativeDriver:!1});if(t.start(),e.push(t),S.reduced){j.setValue(0),q.setValue(0),y.setValue(1);const t=_reactNative.Animated.timing(j,{toValue:1,duration:A,useNativeDriver:!0});t.start(),e.push(t)}else if("bottom"===i){j.setValue(1);const t=_reactNative.Animated.spring(q,{toValue:0,damping:b.motion.spring.gentle.damping,stiffness:b.motion.spring.gentle.stiffness,mass:b.motion.spring.gentle.mass,useNativeDriver:!0});t.start(),e.push(t)}else{const t=_reactNative.Animated.parallel([_reactNative.Animated.spring(y,{toValue:1,damping:b.motion.spring.gentle.damping,stiffness:b.motion.spring.gentle.stiffness,mass:b.motion.spring.gentle.mass,useNativeDriver:!0}),_reactNative.Animated.timing(j,{toValue:1,duration:A,useNativeDriver:!0})]);t.start(),e.push(t)}}else if(T){const t=S.duration("fast"),r=_reactNative.Easing.bezier(...b.motion.ease.accelerate),a=_reactNative.Animated.timing(j,{toValue:0,duration:t,easing:r,useNativeDriver:!0}),s=S.reduced?a:"bottom"===i?_reactNative.Animated.timing(q,{toValue:M,duration:t,easing:r,useNativeDriver:!0}):_reactNative.Animated.parallel([_reactNative.Animated.timing(y,{toValue:.9,duration:t,easing:r,useNativeDriver:!0}),a]),n=_reactNative.Animated.parallel([s,_reactNative.Animated.timing(C,{toValue:0,duration:S.duration("default"),useNativeDriver:!1})]);n.start(({finished:e})=>{e&&(q.setValue(M),w(!1))}),e.push(n)}return()=>e.forEach(e=>e.stop())},[r,T,i,A,y,j,C,q,M,b.motion.spring.gentle.damping,b.motion.spring.gentle.stiffness,b.motion.spring.gentle.mass,S,b.motion.ease.accelerate]),(0,_react.useEffect)(()=>{if("web"===_reactNative.Platform.OS)return;let e,t;return r?(e=setTimeout(()=>{V.current&&_reactNative.AccessibilityInfo.sendAccessibilityEvent(V.current,"focus")},150),D.current=!0):D.current&&(D.current=!1,f&&f.current&&(t=setTimeout(()=>{const e=f.current;e&&_reactNative.AccessibilityInfo.sendAccessibilityEvent(e,"focus")},A))),()=>{e&&clearTimeout(e),t&&clearTimeout(t)}},[r,A,f]);const L=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(r)return void(L.current=!0);if(!L.current)return;if(L.current=!1,!p)return;const e=setTimeout(p,MODAL_DISMISS_GRACE_MS);return()=>clearTimeout(e)},[r,p]);const k=(0,_react.useCallback)(()=>{if(!n)return;const e=(0,_hapticUtils.resolveHaptic)(v,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),a()},[n,a,v]),z=(0,_react.useCallback)(()=>{u&&a()},[u,a]),F=(0,_SquircleFill.useSquircle)("bottom"!==i&&"fullScreen"!==i,b.radius.xl),O=(0,_react.useMemo)(()=>"fullScreen"===i?[I.fullScreenContent,{backgroundColor:b.colors.surface}]:"bottom"===i?[I.bottomContent,{backgroundColor:b.colors.surface,borderTopLeftRadius:b.radius.xl,borderTopRightRadius:b.radius.xl,..._corners.smoothCorners,paddingTop:b.space.lg,paddingHorizontal:b.space.lg,paddingBottom:b.space.lg+h.bottom},b.shadow.modal]:[I.centeredContent,{backgroundColor:b.colors.surface,borderRadius:F.active&&F.size?(0,_squircle.squircleHostRadius)(F.size.width,F.size.height,b.radius.xl):b.radius.xl,..._corners.smoothCorners,padding:b.space.xl},b.shadow.modal],[i,b,I,h.bottom,F.active,F.size]),W=(0,_react.useMemo)(()=>"bottom"===i?I.bottomWrapper:"fullScreen"===i?I.fullScreenWrapper:I.centeredWrapper,[i,I]),H=(0,_react.useMemo)(()=>"bottom"===i?{opacity:j,transform:[{translateY:q}]}:"fullScreen"===i?{opacity:j}:{opacity:j,transform:[{scale:y}]},[i,y,j,q]);return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:T,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:z,testID:g,children:(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{V.current=e,"function"==typeof t?t(e):t&&(t.current=e)},style:I.root,accessible:!1,accessibilityViewIsModal:!0,accessibilityRole:"alert",accessibilityLabel:c,children:(0,_jsxRuntime.jsxs)(_ModalSafeArea.ModalSafeArea,{onInsets:x,children:[(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{collapsable:!1,style:[_reactNative.StyleSheet.absoluteFill,W,{backgroundColor:P},_],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:k,accessibilityRole:"button",accessibilityLabel:"Close modal",disabled:!n}),(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[O,H,m],onLayout:F.onLayout,pointerEvents:"auto",children:[F.active&&F.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:F.size.width,height:F.size.height,radius:b.radius.xl,fill:b.colors.surface}):null,d]})]}),(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})})})});Modal.displayName="Modal";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1},centeredWrapper:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},centeredContent:{maxWidth:"90%",width:"90%"},bottomWrapper:{flex:1,justifyContent:"flex-end"},bottomContent:{width:"100%"},fullScreenWrapper:{flex:1},fullScreenContent:{flex:1}});var _default=exports.default=Modal;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Modal=exports.MODAL_DISMISS_GRACE_MS=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_squircle=require("../../utils/squircle.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");const MODAL_DISMISS_GRACE_MS=exports.MODAL_DISMISS_GRACE_MS=300,SCALE_START_VALUE=.9,Modal=exports.Modal=(0,_react.forwardRef)((e,t)=>{const{visible:r,onRequestClose:a,presentation:i="centered",backdropOpacity:s,backdropPressClose:n=!0,animationDuration:o,animateMount:l=!0,accessibilityLabel:c,hardwareBackPress:u=!0,children:d,contentStyle:m,backdropStyle:_,restoreFocusRef:f,onDismissed:p,haptic:v,testID:g}=e,b=(0,_index.useTheme)(),S=(0,_usePresenceMotion.usePresenceMotion)(),[h,x]=(0,_ModalSafeArea.useModalInsets)(),A=o??S.duration("default"),M=_reactNative.Dimensions.get("window").height,N=(0,_react.useRef)(!l&&r),y=N.current,R=(0,_react.useRef)((0,_index.createAnimatedValue)(y?1:.9)).current,j=(0,_react.useRef)((0,_index.createAnimatedValue)(y?1:0)).current,C=(0,_react.useRef)((0,_index.createAnimatedValue)(y?0:M)).current,q=(0,_react.useRef)((0,_index.createAnimatedValue)(y?1:0)).current,V=(0,_react.useRef)(null),D=(0,_react.useRef)(!1),[T,w]=(0,_react.useState)(r),I=(0,_react.useMemo)(()=>buildStyles(b),[b]),E=(0,_react.useMemo)(()=>{const e=b.colors.scrim;return"number"!=typeof s?e:(0,_color.withAlpha)(e,s)??e},[b.colors.scrim,s]),P=(0,_react.useMemo)(()=>q.interpolate({inputRange:[0,1],outputRange:[(0,_color.transparentOf)(E),E]}),[q,E]);(0,_react.useEffect)(()=>{r&&(_reactNative.Keyboard.dismiss(),w(!0))},[r]),(0,_react.useEffect)(()=>{const e=[];if(r&&T&&N.current)N.current=!1;else if(r&&T){const t=_reactNative.Animated.timing(q,{toValue:1,duration:S.duration("default"),useNativeDriver:!1});if(t.start(),e.push(t),S.reduced){j.setValue(0),C.setValue(0),R.setValue(1);const t=_reactNative.Animated.timing(j,{toValue:1,duration:A,useNativeDriver:!0});t.start(),e.push(t)}else if("bottom"===i){j.setValue(1);const t=_reactNative.Animated.spring(C,{toValue:0,damping:b.motion.spring.gentle.damping,stiffness:b.motion.spring.gentle.stiffness,mass:b.motion.spring.gentle.mass,useNativeDriver:!0});t.start(),e.push(t)}else{const t=_reactNative.Animated.parallel([_reactNative.Animated.spring(R,{toValue:1,damping:b.motion.spring.gentle.damping,stiffness:b.motion.spring.gentle.stiffness,mass:b.motion.spring.gentle.mass,useNativeDriver:!0}),_reactNative.Animated.timing(j,{toValue:1,duration:A,useNativeDriver:!0})]);t.start(),e.push(t)}}else if(T){const t=S.duration("fast"),r=_reactNative.Easing.bezier(...b.motion.ease.accelerate),a=_reactNative.Animated.timing(j,{toValue:0,duration:t,easing:r,useNativeDriver:!0}),s=S.reduced?a:"bottom"===i?_reactNative.Animated.timing(C,{toValue:M,duration:t,easing:r,useNativeDriver:!0}):_reactNative.Animated.parallel([_reactNative.Animated.timing(R,{toValue:.9,duration:t,easing:r,useNativeDriver:!0}),a]),n=_reactNative.Animated.parallel([s,_reactNative.Animated.timing(q,{toValue:0,duration:S.duration("default"),useNativeDriver:!1})]);n.start(({finished:e})=>{e&&(C.setValue(M),w(!1))}),e.push(n)}return()=>e.forEach(e=>{e.stop()})},[r,T,i,A,R,j,q,C,M,b.motion.spring.gentle.damping,b.motion.spring.gentle.stiffness,b.motion.spring.gentle.mass,S,b.motion.ease.accelerate]),(0,_react.useEffect)(()=>{if("web"===_reactNative.Platform.OS)return;let e,t;return r?(e=setTimeout(()=>{V.current&&_reactNative.AccessibilityInfo.sendAccessibilityEvent(V.current,"focus")},150),D.current=!0):D.current&&(D.current=!1,f?.current&&(t=setTimeout(()=>{const e=f.current;e&&_reactNative.AccessibilityInfo.sendAccessibilityEvent(e,"focus")},A))),()=>{e&&clearTimeout(e),t&&clearTimeout(t)}},[r,A,f]);const L=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(r)return void(L.current=!0);if(!L.current)return;if(L.current=!1,!p)return;const e=setTimeout(p,MODAL_DISMISS_GRACE_MS);return()=>clearTimeout(e)},[r,p]);const k=(0,_react.useCallback)(()=>{if(!n)return;const e=(0,_hapticUtils.resolveHaptic)(v,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),a()},[n,a,v]),z=(0,_react.useCallback)(()=>{u&&a()},[u,a]),F=(0,_SquircleFill.useSquircle)("bottom"!==i&&"fullScreen"!==i,b.radius.xl),O=(0,_react.useMemo)(()=>"fullScreen"===i?[I.fullScreenContent,{backgroundColor:b.colors.surface}]:"bottom"===i?[I.bottomContent,{backgroundColor:b.colors.surface,borderTopLeftRadius:b.radius.xl,borderTopRightRadius:b.radius.xl,..._corners.smoothCorners,paddingTop:b.space.lg,paddingHorizontal:b.space.lg,paddingBottom:b.space.lg+h.bottom},b.shadow.modal]:[I.centeredContent,{backgroundColor:b.colors.surface,borderRadius:F.active&&F.size?(0,_squircle.squircleHostRadius)(F.size.width,F.size.height,b.radius.xl):b.radius.xl,..._corners.smoothCorners,padding:b.space.xl},b.shadow.modal],[i,b,I,h.bottom,F.active,F.size]),W=(0,_react.useMemo)(()=>"bottom"===i?I.bottomWrapper:"fullScreen"===i?I.fullScreenWrapper:I.centeredWrapper,[i,I]),H=(0,_react.useMemo)(()=>"bottom"===i?{opacity:j,transform:[{translateY:C}]}:"fullScreen"===i?{opacity:j}:{opacity:j,transform:[{scale:R}]},[i,R,j,C]);return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:T,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:z,testID:g,children:(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e=>{V.current=e,"function"==typeof t?t(e):t&&(t.current=e)},style:I.root,accessible:!1,accessibilityViewIsModal:!0,accessibilityRole:"alert",accessibilityLabel:c,children:(0,_jsxRuntime.jsxs)(_ModalSafeArea.ModalSafeArea,{onInsets:x,children:[(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{collapsable:!1,style:[_reactNative.StyleSheet.absoluteFill,W,{backgroundColor:P},_],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:k,accessibilityRole:"button",accessibilityLabel:"Close modal",disabled:!n}),(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[O,H,m],onLayout:F.onLayout,pointerEvents:"auto",needsOffscreenAlphaCompositing:!0,children:[F.active&&F.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:F.size.width,height:F.size.height,radius:b.radius.xl,fill:b.colors.surface}):null,d]})]}),(0,_jsxRuntime.jsx)(_ToastProvider.ToastHost,{})]})})})});Modal.displayName="Modal";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1},centeredWrapper:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},centeredContent:{maxWidth:"90%",width:"90%"},bottomWrapper:{flex:1,justifyContent:"flex-end"},bottomContent:{width:"100%"},fullScreenWrapper:{flex:1},fullScreenContent:{flex:1}});var _default=exports.default=Modal;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OTPInput=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_jsxRuntime=require("react/jsx-runtime");const sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=exports.OTPInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:r,onChange:n,onComplete:a,length:s=6,keyboardType:o="number-pad",autoFocus:l=!1,autoFocusDelay:c=0,disabled:u=!1,error:d,size:_="md",secure:m=!1,haptic:p,onFocus:g,accessibilityLabel:x,style:f,cellStyle:h,textStyle:v,testID:b}=e,[y,j]=(0,_index.useControllableState)({value:i,defaultValue:r??"",onChange:n}),N=(0,_index2.useTheme)(),R=(0,_react.useMemo)(()=>buildStyles(N),[N]),C=(0,_index2.resolveOtpInputSize)(N,_),T=(0,_react.useRef)([]),[F,k]=(0,_react.useState)(-1),V=(0,_react.useRef)(null),w=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,E=(0,_react.useRef)(new Map),A=(0,_react.useMemo)(()=>{const e=E.current,t=[];for(let i=0;i<s;i+=1){let r=e.get(i);r||(r=new _reactNative.Animated.Value(0),e.set(i,r)),t.push(r)}for(const t of Array.from(e.keys()))t>=s&&e.delete(t);return t},[s]),I=(0,_react.useRef)(-1),S=N.settings.components["otp-input"]?.shakeOnError??!1,O=(0,_index.useReducedMotion)(),z=!0===d||(0,_FieldBase.hasFieldText)(d);(0,_react.useEffect)(()=>{let e;return null===V.current||!z||V.current||(p&&(0,_index3.triggerHaptic)("notificationError"),S&&!O&&((0,_index2.setNativeValue)(w,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(w,{toValue:1,duration:N.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(w,{toValue:-1,duration:N.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(w,{toValue:1,duration:N.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(w,{toValue:0,duration:N.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0})]),e.start())),V.current=z,()=>e?.stop()},[z,w,S,p,O,N.motion.duration.instant]),(0,_react.useEffect)(()=>{const e=I.current;if(I.current=F,e===F)return;if(-1===e&&-1===F)return;const t=[];return A.forEach((i,r)=>{const n=r===F?1:0;if(r!==F&&r!==e)return;const a=_reactNative.Animated.timing(i,{toValue:n,duration:N.motion.duration.fast,easing:_reactNative.Easing.bezier(...N.motion.ease["in-out"]),useNativeDriver:!0});a.start(),t.push(a)}),()=>t.forEach(e=>e.stop())},[F,A,N]);const B=(0,_react.useCallback)(e=>{const t=T.current[e];t&&t.focus()},[]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>B(0),blur:()=>{const e=T.current[F>=0?F:0];e?.blur()},clear:()=>{j(""),B(0)}}),[B,F,j]),(0,_react.useEffect)(()=>{if(l&&!u){const e=setTimeout(()=>B(0),c);return()=>clearTimeout(e)}},[l,c,u,B]);const D=(0,_react.useMemo)(()=>{const e=new Array(s).fill("");for(let t=0;t<Math.min(y.length,s);t+=1)e[t]=y[t]??"";return e},[y,s]),P=(0,_react.useCallback)(e=>{const t=e.slice(0,s);t!==y&&(j(t),t.length===s&&a&&a(t))},[s,j,a,y]),q=(0,_react.useCallback)((e,t)=>{const i=t.replace(/\u200B/g,""),r=sanitizeChar(i,o);if(!r){const t=D.slice(),i=(t[e]??"").length>0;if(t[e]="",P(t.join("").slice(0,s)),!i&&e>0){const t=D.slice();t[e-1]="",P(t.join("")),B(e-1)}return}const n=D[e]??"",a=n&&r.length>s&&r.startsWith(n)?r.slice(n.length):r;if(a.length>=s){const t=a.slice(0,s),i=y.length;return P(t),t.length!==i&&p&&(0,_index3.triggerHaptic)(p),void T.current[e]?.blur()}const l=D.slice();let c=e;for(let e=0;e<r.length&&c<s;e+=1)l[c]=r[e]??"",c+=1;const u=l.join("").slice(0,s),d=y.length;P(u),u.length!==d&&p&&(0,_index3.triggerHaptic)(p);const _=Math.min(c,s-1);c>=s?T.current[e]?.blur():B(_)},[D,B,o,s,p,P,y]),M=(0,_react.useCallback)((e,t)=>{if("Backspace"!==t.nativeEvent.key)return;if(0===(D[e]??"").length){if(e>0){const t=D.slice();t[e-1]="",P(t.join("")),B(e-1)}}else{const t=D.slice();t[e]="",P(t.join(""))}},[D,B,P]),H=(0,_react.useCallback)((e,t)=>{k(e),g?.(t)},[g]),W=(0,_react.useCallback)(()=>{k(-1)},[]),L=(0,_react.useCallback)(()=>{if(u)return;const e=D.indexOf("");B(-1===e?s-1:e)},[D,u,B,s]),$=x??`Enter ${s}-digit code`,G=w.interpolate({inputRange:[-1,1],outputRange:[-6,6]});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:f,accessible:!0,accessibilityRole:"none",accessibilityLabel:$,accessibilityValue:{text:i},accessibilityState:{disabled:u},"aria-disabled":u,testID:b,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:L,disabled:u,accessible:!1,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[R.row,{columnGap:C.gap,transform:[{translateX:G}]}],children:D.map((e,t)=>{const i=F===t,r=e.length>0,n=z?N.colors["danger-border"]:N.colors["focus-ring"],a=A[t];if(!a)return null;const l=m&&r?"●":e;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:R.cellWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:_,width:C.cell,height:C.cell,borderRadius:C.radius,borderWidth:1.5,focused:i,error:z,filled:r,disabled:u,paddingHorizontal:N.space.none,paddingVertical:N.space.none,gap:N.space.none,style:h,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:e=>{T.current[t]=e},value:(m&&r?"":e)||"​",onChangeText:e=>q(t,e),onKeyPress:e=>M(t,e),onFocus:e=>H(t,e),onBlur:W,keyboardType:o,editable:!u,selectTextOnFocus:!0,caretHidden:r,maxLength:s+1,textContentType:"oneTimeCode",autoComplete:0===t?"sms-otp":"off",importantForAutofill:0===t?"yes":"no",style:[R.input,{fontSize:C.text,color:N.colors["text-body"],...(0,_index2.fontFor)(N,"semibold")},v]}),m&&r?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:R.maskOverlay,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{fontSize:C.text,color:N.colors["text-body"],...(0,_index2.fontFor)(N,"semibold")},v],children:l})}):null]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[R.underline,{backgroundColor:n,opacity:a}]})]},`otp-cell-${t}`)})})}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:_,error:!0,text:d})]})});OTPInput.displayName="OTPInput";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},cellWrapper:{alignItems:"center"},input:{width:"100%",height:"100%",textAlign:"center",padding:e.space.none},maskOverlay:{..._reactNative.StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center"},underline:{marginTop:e.space.xs,height:2,width:"60%",borderRadius:e.radius.pill,..._corners.smoothCorners}});var _default=exports.default=OTPInput;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OTPInput=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_jsxRuntime=require("react/jsx-runtime");const sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=exports.OTPInput=(0,_react.forwardRef)((e,t)=>{const{value:i,defaultValue:r,onChange:n,onComplete:a,length:s=6,keyboardType:o="number-pad",autoFocus:l=!1,autoFocusDelay:c=0,disabled:u=!1,error:d,size:_="md",secure:m=!1,haptic:p,onFocus:g,accessibilityLabel:x,style:f,cellStyle:h,textStyle:v,testID:b}=e,[y,j]=(0,_index.useControllableState)({value:i,defaultValue:r??"",onChange:n}),N=(0,_index2.useTheme)(),R=(0,_react.useMemo)(()=>buildStyles(N),[N]),C=(0,_index2.resolveOtpInputSize)(N,_),T=(0,_react.useRef)([]),[F,k]=(0,_react.useState)(-1),V=(0,_react.useRef)(null),w=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,E=(0,_react.useRef)(new Map),A=(0,_react.useMemo)(()=>{const e=E.current,t=[];for(let i=0;i<s;i+=1){let r=e.get(i);r||(r=new _reactNative.Animated.Value(0),e.set(i,r)),t.push(r)}for(const t of Array.from(e.keys()))t>=s&&e.delete(t);return t},[s]),I=(0,_react.useRef)(-1),S=N.settings.components["otp-input"]?.shakeOnError??!1,O=(0,_index.useReducedMotion)(),z=!0===d||(0,_FieldBase.hasFieldText)(d);(0,_react.useEffect)(()=>{let e;return null===V.current||!z||V.current||(p&&(0,_index3.triggerHaptic)("notificationError"),S&&!O&&((0,_index2.setNativeValue)(w,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(w,{toValue:1,duration:N.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(w,{toValue:-1,duration:N.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(w,{toValue:1,duration:N.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(w,{toValue:0,duration:N.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0})]),e.start())),V.current=z,()=>e?.stop()},[z,w,S,p,O,N.motion.duration.instant]),(0,_react.useEffect)(()=>{const e=I.current;if(I.current=F,e===F)return;if(-1===e&&-1===F)return;const t=[];return A.forEach((i,r)=>{const n=r===F?1:0;if(r!==F&&r!==e)return;const a=_reactNative.Animated.timing(i,{toValue:n,duration:N.motion.duration.fast,easing:_reactNative.Easing.bezier(...N.motion.ease["in-out"]),useNativeDriver:!0});a.start(),t.push(a)}),()=>t.forEach(e=>{e.stop()})},[F,A,N]);const B=(0,_react.useCallback)(e=>{const t=T.current[e];t&&t.focus()},[]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>B(0),blur:()=>{const e=T.current[F>=0?F:0];e?.blur()},clear:()=>{j(""),B(0)}}),[B,F,j]),(0,_react.useEffect)(()=>{if(l&&!u){const e=setTimeout(()=>B(0),c);return()=>clearTimeout(e)}},[l,c,u,B]);const D=(0,_react.useMemo)(()=>{const e=new Array(s).fill("");for(let t=0;t<Math.min(y.length,s);t+=1)e[t]=y[t]??"";return e},[y,s]),P=(0,_react.useCallback)(e=>{const t=e.slice(0,s);t!==y&&(j(t),t.length===s&&a&&a(t))},[s,j,a,y]),q=(0,_react.useCallback)((e,t)=>{const i=t.replace(/\u200B/g,""),r=sanitizeChar(i,o);if(!r){const t=D.slice(),i=(t[e]??"").length>0;if(t[e]="",P(t.join("").slice(0,s)),!i&&e>0){const t=D.slice();t[e-1]="",P(t.join("")),B(e-1)}return}const n=D[e]??"",a=n&&r.length>s&&r.startsWith(n)?r.slice(n.length):r;if(a.length>=s){const t=a.slice(0,s),i=y.length;return P(t),t.length!==i&&p&&(0,_index3.triggerHaptic)(p),void T.current[e]?.blur()}const l=D.slice();let c=e;for(let e=0;e<r.length&&c<s;e+=1)l[c]=r[e]??"",c+=1;const u=l.join("").slice(0,s),d=y.length;P(u),u.length!==d&&p&&(0,_index3.triggerHaptic)(p);const _=Math.min(c,s-1);c>=s?T.current[e]?.blur():B(_)},[D,B,o,s,p,P,y]),M=(0,_react.useCallback)((e,t)=>{if("Backspace"!==t.nativeEvent.key)return;if(0===(D[e]??"").length){if(e>0){const t=D.slice();t[e-1]="",P(t.join("")),B(e-1)}}else{const t=D.slice();t[e]="",P(t.join(""))}},[D,B,P]),H=(0,_react.useCallback)((e,t)=>{k(e),g?.(t)},[g]),W=(0,_react.useCallback)(()=>{k(-1)},[]),L=(0,_react.useCallback)(()=>{if(u)return;const e=D.indexOf("");B(-1===e?s-1:e)},[D,u,B,s]),$=x??`Enter ${s}-digit code`,G=w.interpolate({inputRange:[-1,1],outputRange:[-6,6]});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:f,accessible:!0,accessibilityRole:"none",accessibilityLabel:$,accessibilityValue:{text:i},accessibilityState:{disabled:u},"aria-disabled":u,testID:b,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:L,disabled:u,accessible:!1,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[R.row,{columnGap:C.gap,transform:[{translateX:G}]}],children:D.map((e,t)=>{const i=F===t,r=e.length>0,n=z?N.colors["danger-border"]:N.colors["focus-ring"],a=A[t];if(!a)return null;const l=m&&r?"●":e;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:R.cellWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:_,width:C.cell,height:C.cell,borderRadius:C.radius,borderWidth:1.5,focused:i,error:z,filled:r,disabled:u,paddingHorizontal:N.space.none,paddingVertical:N.space.none,gap:N.space.none,style:h,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:e=>{T.current[t]=e},value:(m&&r?"":e)||"​",onChangeText:e=>q(t,e),onKeyPress:e=>M(t,e),onFocus:e=>H(t,e),onBlur:W,keyboardType:o,editable:!u,selectTextOnFocus:!0,caretHidden:r,maxLength:s+1,textContentType:"oneTimeCode",autoComplete:0===t?"sms-otp":"off",importantForAutofill:0===t?"yes":"no",style:[R.input,{fontSize:C.text,color:N.colors["text-body"],...(0,_index2.fontFor)(N,"semibold")},v]}),m&&r?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:R.maskOverlay,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{fontSize:C.text,color:N.colors["text-body"],...(0,_index2.fontFor)(N,"semibold")},v],children:l})}):null]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[R.underline,{backgroundColor:n,opacity:a}]})]},`otp-cell-${t}`)})})}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:_,error:!0,text:d})]})});OTPInput.displayName="OTPInput";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},cellWrapper:{alignItems:"center"},input:{width:"100%",height:"100%",textAlign:"center",padding:e.space.none},maskOverlay:{..._reactNative.StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center"},underline:{marginTop:e.space.xs,height:2,width:"60%",borderRadius:e.radius.pill,..._corners.smoothCorners}});var _default=exports.default=OTPInput;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.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"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");const AnimatedGestureRoot=_reactNative.Animated.createAnimatedComponent(_reactNativeGestureHandler.GestureHandlerRootView),SEARCH_ICON_SIZE=18,OptionSheet=e=>{const{open:t,onClose:i,onAfterClose:r,onOpenChange:s,title:a,options:o,sections:n,renderSectionHeader:l,renderOption:c,alphabetIndex:d=!1,searchPlaceholder:u="Search…",emptyText:p="No options",labelOf:m,getValue:h,disabledOf:_,destructiveOf:x,descriptionOf:g,iconOf:b,isSelected:f,onSelect:y,multi:v=!1,searchable:j=!1,searchSelectionColor:R,accessibilityLabel:N,optionStyle:S,selectedOptionStyle:T,optionTextStyle:w,selectedOptionTextStyle:C,testID:k}=e,I=(0,_index.useTheme)(),V=(0,_usePresenceMotion.usePresenceMotion)(),[M,z]=(0,_ModalSafeArea.useModalInsets)(),D=(0,_react.useMemo)(()=>buildStyles(I),[I]),[A,P]=(0,_react.useState)(""),L=_reactNative.Dimensions.get("window").height,H=Math.round(.7*L),[O,W]=(0,_react.useState)(t),B=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,E=(0,_react.useRef)((0,_index.createAnimatedValue)(H)).current,q=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,F=(0,_react.useMemo)(()=>V.reduced?q:_reactNative.Animated.add(E,q),[V.reduced,E,q]),G=(0,_react.useMemo)(()=>V.reduced?E.interpolate({inputRange:[0,H],outputRange:[1,0],extrapolate:"clamp"}):1,[V.reduced,E,H]),{handleGesture:$,opacity:K}=(0,_useDragToDismiss.useDragToDismiss)({drag:q,travel:H,onDismiss:i}),J=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(G,K),[G,K]),U=(0,_react.useMemo)(()=>{const e=I.colors.scrim;return B.interpolate({inputRange:[0,1],outputRange:[(0,_color.transparentOf)(e),e]})},[B,I.colors.scrim]);(0,_react.useEffect)(()=>{t&&W(!0)},[t]);const Y=(0,_react.useRef)(s);Y.current=s;const Z=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{Z.current!==t&&(Z.current=t,Y.current?.(t))},[t]);const Q=(0,_react.useRef)(r);Q.current=r;const X=(0,_react.useRef)(O);(0,_react.useEffect)(()=>{X.current&&!O&&"ios"!==_reactNative.Platform.OS&&Q.current?.(),X.current=O},[O]),(0,_react.useEffect)(()=>{if(!O)return;t&&((0,_index.setNativeValue)(q,0),(0,_index.setNativeValue)(K,1));const e=t?_reactNative.Animated.parallel([_reactNative.Animated.timing(B,{toValue:1,duration:V.duration("default"),easing:_reactNative.Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:!1}),V.reduced?_reactNative.Animated.timing(E,{toValue:0,duration:V.duration("default"),easing:_reactNative.Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:!0}):_reactNative.Animated.spring(E,{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(B,{toValue:0,duration:V.duration("default"),easing:_reactNative.Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:!1}),_reactNative.Animated.timing(E,{toValue:H,duration:V.duration("fast"),easing:_reactNative.Easing.bezier(...I.motion.ease.accelerate),useNativeDriver:!0})]);return e.start(({finished:e})=>{e&&!t&&W(!1)}),()=>e.stop()},[t,O,B,E,q,K,H,V,I.motion.ease["in-out"],I.motion.ease.accelerate,I.motion.spring.snappy]);const ee=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native(),[]),[te,ie]=(0,_react.useState)(0),re=(0,_reactNativeKeyboardController.useKeyboardState)(e=>e.height),se=O?Math.max(0,Math.round(re)):0,ae=Math.max(M.top,_reactNative.StatusBar.currentHeight??0)+I.space.sm,oe=se>0,ne=oe?Math.max(0,Math.min(H,(te>0?te:L)-se-ae)):H;(0,_react.useEffect)(()=>{t||P("")},[t]);const le=(0,_react.useMemo)(()=>{const e=j?A.trim().toLowerCase():"",matches=t=>0===e.length||m(t).toLowerCase().includes(e)||(g(t)??"").toLowerCase().includes(e);if(!n)return o.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return n.forEach((e,i)=>{const r=e.options.filter(matches);if(0!==r.length){t.push({kind:"header",title:e.title});for(const e of r)t.push({kind:"option",option:e,section:i})}}),t},[j,A,o,n,m,g]),ce=(0,_react.useCallback)(()=>{i()},[i]),de=(0,_react.useRef)(null),ue=(0,_react.useMemo)(()=>{const e=new Map;if(!d)return e;let t=0;if(n)for(let e=le.length-1;e>=0;e-=1)if("header"===le[e].kind){t=e+1;break}for(let i=t;i<le.length;i+=1){const t=le[i];if("option"!==t.kind)continue;const r=m(t.option).trim().charAt(0).toUpperCase(),s=/^[A-Z]$/.test(r)?r:"#";e.has(s)||e.set(s,i)}return e},[d,le,n,m]),pe=d&&ue.size>0&&0===A.trim().length,me=(0,_react.useMemo)(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...ue.has("#")?["#"]:[]],[ue]),he=(0,_react.useCallback)(e=>{const t=ue.get(e);void 0!==t&&de.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[ue]),xe=(0,_react.useRef)(null),ge=(0,_react.useCallback)(()=>{null!==xe.current&&(clearTimeout(xe.current),xe.current=null)},[]),be=(0,_react.useCallback)(e=>{de.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),ge(),xe.current=setTimeout(()=>{xe.current=null,de.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[ge]);(0,_react.useEffect)(()=>(O||ge(),ge),[O,ge]);return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:O,transparent:!0,animationType:"none",onRequestClose:ce,onDismiss:()=>Q.current?.(),statusBarTranslucent:!0,navigationBarTranslucent:!0,children:(0,_jsxRuntime.jsx)(_ModalSafeArea.ModalSafeArea,{onInsets:z,children:(0,_jsxRuntime.jsxs)(AnimatedGestureRoot,{collapsable:!1,onLayout:e=>ie(e.nativeEvent.layout.height),style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:U}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:ce,accessibilityRole:"button",accessibilityLabel:"Close picker"}),(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{testID:k,accessibilityViewIsModal:!0,accessibilityLabel:N??a??"Options",style:[D.sheet,{maxHeight:ne,bottom:se,paddingBottom:oe?I.space.lg:M.bottom+I.space.lg,backgroundColor:I.colors.surface,borderTopLeftRadius:I.radius.xl,borderTopRightRadius:I.radius.xl,..._corners.smoothCorners,opacity:J,transform:[{translateY:F}],...I.shadow.modal}],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:$,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.colors.border}]})}),a?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.sheetTitle,{color:I.colors["text-body"],fontSize:I.text.lg.size,fontWeight:I.weight.semibold,paddingHorizontal:I.space.lg,marginBottom:I.space.sm}],children:a}):null]})}),j?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.searchWrap,{marginHorizontal:I.space.lg,marginBottom:I.space.sm}],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[D.searchBox,{backgroundColor:I.colors["bg-subtle"],borderColor:I.colors.border,borderRadius:I.radius.md,..._corners.smoothCorners,paddingHorizontal:I.space.md,gap:I.space.sm}],children:[(I.settings.icons.search??_defaultIcons.defaultIcons.search)({size:18,color:I.colors["text-subtle"]}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{value:A,onChangeText:P,placeholder:u,placeholderTextColor:I.colors["text-subtle"],selectionColor:R??I.colors["focus-ring"],accessibilityLabel:"Search options",style:[D.searchInput,{color:I.colors["text-body"],fontSize:I.text.base.size,paddingVertical:I.space.sm}]}),A.length>0?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>P(""),hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:"Clear search",children:(I.settings.icons.close??_defaultIcons.defaultIcons.close)({size:18,color:I.colors["text-muted"]})}):null]})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[D.listWrap,pe?D.listRow:null],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ee,children:(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:de,data:le,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.space.lg,paddingTop:I.space.md}],children:l?l(e.title):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.sectionTitle,{color:I.colors["text-subtle"],fontSize:I.text.xs.size,fontWeight:I.weight.semibold}],children:e.title.toUpperCase()})});const t=e.option,i=m(t),r=h(t),s=g(t),a=b(t),o=f(r),n=_(t),d=x?.(t)??!1;return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>y(t),disabled:n,android_ripple:{color:I.colors["surface-pressed"],borderless:!1},accessibilityRole:"button",accessibilityLabel:i,accessibilityState:{selected:o,disabled:n},"aria-selected":o,"aria-disabled":n,style:({pressed:e})=>[D.optionRow,{backgroundColor:o?I.colors["surface-selected"]:e?I.colors["surface-pressed"]:"transparent",opacity:n?.5:1,paddingHorizontal:I.space.lg,paddingVertical:I.space.md},S,o?T:null],children:[c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.optionTextWrap,children:c(t,{selected:o,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["danger-text"]:o?I.colors.primary:I.colors["text-body"],fontSize:I.text.base.size,fontWeight:o?I.weight.semibold:I.weight.medium},w,o?C:null],children:i}),s?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.optionDescription,{color:I.colors["text-subtle"],fontSize:I.text.sm.size}],numberOfLines:2,children:s}):null]})]}),v?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.checkbox,{borderColor:o?I.colors.primary:I.colors.border,backgroundColor:o?I.colors.primary:"transparent"}],children:o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.checkboxTick}):null}):o?"icon"===I.settings.components["option-sheet"]?.selectedMarker?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.singleSelectedIcon,children:(I.settings.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:be,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!pe,style:pe?D.listBesideRail:null,ListEmptyComponent:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.empty,{color:I.colors["text-subtle"],fontSize:I.text.sm.size,paddingVertical:I.space.xl}],children:p})})}),pe?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.rail,{paddingRight:I.space.xs}],accessibilityRole:"list",accessibilityLabel:"Jump to letter",testID:"option-sheet-alphabet",children:me.map(e=>{const t=ue.has(e);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>he(e),disabled:!t,hitSlop:{left:8,right:8},...(0,_hitSlop.hitSlopMarker)({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-subtle"],fontSize:I.text.xs.size,fontWeight:I.weight.semibold,opacity:t?1:.45}],children:e})},e)})}):null]}),v?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.sheetFooter,{borderTopColor:I.colors["border-subtle"],paddingHorizontal:I.space.lg,paddingVertical:I.space.md}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:ce,accessibilityRole:"button",accessibilityLabel:"Done",style:({pressed:e})=>[D.doneButton,{backgroundColor:e?I.colors["primary-pressed"]:I.colors.primary,borderRadius:I.radius.md,..._corners.smoothCorners,paddingVertical:I.space.sm,paddingHorizontal:I.space.lg}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:I.colors["on-primary"],fontSize:I.text.base.size,fontWeight:I.weight.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:e.space.lg,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:e.space.sm,paddingBottom:e.space.sm},sheetHandle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:e.space.xs},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:e.space.xs},railLetter:{paddingHorizontal:e.space.xs,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:14},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:e.space.md},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:e.space.xxs},checkbox:{width:22,height:22,borderRadius:e.radius.sm,..._corners.smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:e.space.md},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors["on-primary"],transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:e.radius.pill,..._corners.smoothCorners,marginLeft:e.space.md},singleSelectedIcon:{marginLeft:e.space.md},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"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_ToastProvider=require("../Toast/ToastProvider.js"),_jsxRuntime=require("react/jsx-runtime");const AnimatedGestureRoot=_reactNative.Animated.createAnimatedComponent(_reactNativeGestureHandler.GestureHandlerRootView),SEARCH_ICON_SIZE=18,OptionSheet=e=>{const{open:t,onClose:i,onAfterClose:r,onOpenChange:s,title:a,options:o,sections:n,renderSectionHeader:l,renderOption:c,alphabetIndex:d=!1,searchPlaceholder:u="Search…",emptyText:p="No options",labelOf:m,getValue:h,disabledOf:_,destructiveOf:x,descriptionOf:g,iconOf:b,isSelected:f,onSelect:y,multi:v=!1,searchable:j=!1,searchSelectionColor:R,accessibilityLabel:N,optionStyle:S,selectedOptionStyle:T,optionTextStyle:w,selectedOptionTextStyle:C,testID:k}=e,I=(0,_index.useTheme)(),V=(0,_usePresenceMotion.usePresenceMotion)(),[M,z]=(0,_ModalSafeArea.useModalInsets)(),D=(0,_react.useMemo)(()=>buildStyles(I),[I]),[A,P]=(0,_react.useState)(""),L=_reactNative.Dimensions.get("window").height,H=Math.round(.7*L),[O,W]=(0,_react.useState)(t),B=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,E=(0,_react.useRef)((0,_index.createAnimatedValue)(H)).current,q=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,F=(0,_react.useMemo)(()=>V.reduced?q:_reactNative.Animated.add(E,q),[V.reduced,E,q]),G=(0,_react.useMemo)(()=>V.reduced?E.interpolate({inputRange:[0,H],outputRange:[1,0],extrapolate:"clamp"}):1,[V.reduced,E,H]),{handleGesture:K,opacity:$}=(0,_useDragToDismiss.useDragToDismiss)({drag:q,travel:H,onDismiss:i}),J=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(G,$),[G,$]),U=(0,_react.useMemo)(()=>{const e=I.colors.scrim;return B.interpolate({inputRange:[0,1],outputRange:[(0,_color.transparentOf)(e),e]})},[B,I.colors.scrim]);(0,_react.useEffect)(()=>{t&&(_reactNative.Keyboard.dismiss(),W(!0))},[t]);const Y=(0,_react.useRef)(s);Y.current=s;const Z=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{Z.current!==t&&(Z.current=t,Y.current?.(t))},[t]);const Q=(0,_react.useRef)(r);Q.current=r;const X=(0,_react.useRef)(O);(0,_react.useEffect)(()=>{X.current&&!O&&"ios"!==_reactNative.Platform.OS&&Q.current?.(),X.current=O},[O]),(0,_react.useEffect)(()=>{if(!O)return;t&&((0,_index.setNativeValue)(q,0),(0,_index.setNativeValue)($,1));const e=t?_reactNative.Animated.parallel([_reactNative.Animated.timing(B,{toValue:1,duration:V.duration("default"),easing:_reactNative.Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:!1}),V.reduced?_reactNative.Animated.timing(E,{toValue:0,duration:V.duration("default"),easing:_reactNative.Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:!0}):_reactNative.Animated.spring(E,{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(B,{toValue:0,duration:V.duration("default"),easing:_reactNative.Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:!1}),_reactNative.Animated.timing(E,{toValue:H,duration:V.duration("fast"),easing:_reactNative.Easing.bezier(...I.motion.ease.accelerate),useNativeDriver:!0})]);return e.start(({finished:e})=>{e&&!t&&W(!1)}),()=>e.stop()},[t,O,B,E,q,$,H,V,I.motion.ease["in-out"],I.motion.ease.accelerate,I.motion.spring.snappy]);const ee=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native(),[]),[te,ie]=(0,_react.useState)(0),re=(0,_reactNativeKeyboardController.useKeyboardState)(e=>e.height),se=O?Math.max(0,Math.round(re)):0,ae=Math.max(M.top,_reactNative.StatusBar.currentHeight??0)+I.space.sm,oe=se>0,ne=oe?Math.max(0,Math.min(H,(te>0?te:L)-se-ae)):H;(0,_react.useEffect)(()=>{t||P("")},[t]);const le=(0,_react.useMemo)(()=>{const e=j?A.trim().toLowerCase():"",matches=t=>0===e.length||m(t).toLowerCase().includes(e)||(g(t)??"").toLowerCase().includes(e);if(!n)return o.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return n.forEach((e,i)=>{const r=e.options.filter(matches);if(0!==r.length){t.push({kind:"header",title:e.title});for(const e of r)t.push({kind:"option",option:e,section:i})}}),t},[j,A,o,n,m,g]),ce=(0,_react.useCallback)(()=>{i()},[i]),de=(0,_react.useRef)(null),ue=(0,_react.useMemo)(()=>{const e=new Map;if(!d)return e;let t=0;if(n)for(let e=le.length-1;e>=0;e-=1)if("header"===le[e].kind){t=e+1;break}for(let i=t;i<le.length;i+=1){const t=le[i];if("option"!==t.kind)continue;const r=m(t.option).trim().charAt(0).toUpperCase(),s=/^[A-Z]$/.test(r)?r:"#";e.has(s)||e.set(s,i)}return e},[d,le,n,m]),pe=d&&ue.size>0&&0===A.trim().length,me=(0,_react.useMemo)(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...ue.has("#")?["#"]:[]],[ue]),he=(0,_react.useCallback)(e=>{const t=ue.get(e);void 0!==t&&de.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[ue]),xe=(0,_react.useRef)(null),ge=(0,_react.useCallback)(()=>{null!==xe.current&&(clearTimeout(xe.current),xe.current=null)},[]),be=(0,_react.useCallback)(e=>{de.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),ge(),xe.current=setTimeout(()=>{xe.current=null,de.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[ge]);(0,_react.useEffect)(()=>(O||ge(),ge),[O,ge]);return(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:O,transparent:!0,animationType:"none",onRequestClose:ce,onDismiss:()=>Q.current?.(),statusBarTranslucent:!0,navigationBarTranslucent:!0,children:(0,_jsxRuntime.jsx)(_ModalSafeArea.ModalSafeArea,{onInsets:z,children:(0,_jsxRuntime.jsxs)(AnimatedGestureRoot,{collapsable:!1,onLayout:e=>ie(e.nativeEvent.layout.height),style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:U}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:ce,accessibilityRole:"button",accessibilityLabel:"Close picker"}),(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{testID:k,accessibilityViewIsModal:!0,accessibilityLabel:N??a??"Options",style:[D.sheet,{maxHeight:ne,bottom:se,paddingBottom:oe?I.space.lg:M.bottom+I.space.lg,backgroundColor:I.colors.surface,borderTopLeftRadius:I.radius.xl,borderTopRightRadius:I.radius.xl,..._corners.smoothCorners,opacity:J,transform:[{translateY:F}],...I.shadow.modal}],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:K,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.colors.border}]})}),a?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.sheetTitle,{color:I.colors["text-body"],fontSize:I.text.lg.size,fontWeight:I.weight.semibold,paddingHorizontal:I.space.lg,marginBottom:I.space.sm}],children:a}):null]})}),j?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.searchWrap,{marginHorizontal:I.space.lg,marginBottom:I.space.sm}],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[D.searchBox,{backgroundColor:I.colors["bg-subtle"],borderColor:I.colors.border,borderRadius:I.radius.md,..._corners.smoothCorners,paddingHorizontal:I.space.md,gap:I.space.sm}],children:[(I.settings.icons.search??_defaultIcons.defaultIcons.search)({size:18,color:I.colors["text-subtle"]}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{value:A,onChangeText:P,placeholder:u,placeholderTextColor:I.colors["text-subtle"],selectionColor:R??I.colors["focus-ring"],accessibilityLabel:"Search options",style:[D.searchInput,{color:I.colors["text-body"],fontSize:I.text.base.size,paddingVertical:I.space.sm}]}),A.length>0?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>P(""),hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),accessibilityRole:"button",accessibilityLabel:"Clear search",children:(I.settings.icons.close??_defaultIcons.defaultIcons.close)({size:18,color:I.colors["text-muted"]})}):null]})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[D.listWrap,pe?D.listRow:null],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ee,children:(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:de,data:le,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.space.lg,paddingTop:I.space.md}],children:l?l(e.title):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.sectionTitle,{color:I.colors["text-subtle"],fontSize:I.text.xs.size,fontWeight:I.weight.semibold}],children:e.title.toUpperCase()})});const t=e.option,i=m(t),r=h(t),s=g(t),a=b(t),o=f(r),n=_(t),d=x?.(t)??!1;return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>y(t),disabled:n,android_ripple:{color:I.colors["surface-pressed"],borderless:!1},accessibilityRole:"button",accessibilityLabel:i,accessibilityState:{selected:o,disabled:n},"aria-selected":o,"aria-disabled":n,style:({pressed:e})=>[D.optionRow,{backgroundColor:o?I.colors["surface-selected"]:e?I.colors["surface-pressed"]:"transparent",opacity:n?.5:1,paddingHorizontal:I.space.lg,paddingVertical:I.space.md},S,o?T:null],children:[c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.optionTextWrap,children:c(t,{selected:o,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["danger-text"]:o?I.colors.primary:I.colors["text-body"],fontSize:I.text.base.size,fontWeight:o?I.weight.semibold:I.weight.medium},w,o?C:null],children:i}),s?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.optionDescription,{color:I.colors["text-subtle"],fontSize:I.text.sm.size}],numberOfLines:2,children:s}):null]})]}),v?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.checkbox,{borderColor:o?I.colors.primary:I.colors.border,backgroundColor:o?I.colors.primary:"transparent"}],children:o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.checkboxTick}):null}):o?"icon"===I.settings.components["option-sheet"]?.selectedMarker?(0,_jsxRuntime.jsx)(_reactNative.View,{style:D.singleSelectedIcon,children:(I.settings.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:be,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!pe,style:pe?D.listBesideRail:null,ListEmptyComponent:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[D.empty,{color:I.colors["text-subtle"],fontSize:I.text.sm.size,paddingVertical:I.space.xl}],children:p})})}),pe?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.rail,{paddingRight:I.space.xs}],accessibilityRole:"list",accessibilityLabel:"Jump to letter",testID:"option-sheet-alphabet",children:me.map(e=>{const t=ue.has(e);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>he(e),disabled:!t,hitSlop:{left:8,right:8},...(0,_hitSlop.hitSlopMarker)({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-subtle"],fontSize:I.text.xs.size,fontWeight:I.weight.semibold,opacity:t?1:.45}],children:e})},e)})}):null]}),v?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.sheetFooter,{borderTopColor:I.colors["border-subtle"],paddingHorizontal:I.space.lg,paddingVertical:I.space.md}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:ce,accessibilityRole:"button",accessibilityLabel:"Done",style:({pressed:e})=>[D.doneButton,{backgroundColor:e?I.colors["primary-pressed"]:I.colors.primary,borderRadius:I.radius.md,..._corners.smoothCorners,paddingVertical:I.space.sm,paddingHorizontal:I.space.lg}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:I.colors["on-primary"],fontSize:I.text.base.size,fontWeight:I.weight.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:e.space.lg,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:e.space.sm,paddingBottom:e.space.sm},sheetHandle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:e.space.xs},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:e.space.xs},railLetter:{paddingHorizontal:e.space.xs,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:14},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:e.space.md},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:e.space.xxs},checkbox:{width:22,height:22,borderRadius:e.radius.sm,..._corners.smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:e.space.md},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors["on-primary"],transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:e.radius.pill,..._corners.smoothCorners,marginLeft:e.space.md},singleSelectedIcon:{marginLeft:e.space.md},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.default=exports.Swipeable=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,i,n=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((a=n&&Object.getOwnPropertyDescriptor(e,i))&&(a.get||a.set)?n(r,i,a):r[i]=e[i]);return r}const SPRING_CONFIG={damping:22,stiffness:260,mass:1},DRAG_ACTIVATION_OFFSET=10,RUBBER_BAND_FACTOR=.35,FAIL_OFFSET_Y=15,toneToBg=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;default:return e.colors.neutral}},toneToOnColor=(e,t)=>{switch(t){case"primary":return e.colors["on-primary"];case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];default:return e.colors["on-neutral"]}},Swipeable=e=>{const{children:t,leftActions:a,rightActions:i,threshold:n,fullSwipeThreshold:r,onSwipeOpen:c,onSwipeClose:s,disabled:o=!1,haptic:l,containerStyle:u,contentStyle:d,actionStyle:_,accessibilityLabel:m,testID:h}=e,v=(0,_index.useTheme)(),p=n??80,R=r??200,N=(0,_react.useMemo)(()=>buildStyles(v),[v]),S=(0,_react.useMemo)(()=>buildActionStyles(v),[v]),b=!!a&&a.length>0,f=!!i&&i.length>0,w=_reactNative.Dimensions.get("window").width,x=b?p*(a?.length??0):0,g=f?p*(i?.length??0):0,y=(0,_reactNativeReanimated.useSharedValue)(0),j=(0,_reactNativeReanimated.useSharedValue)(0),O=(0,_react.useRef)(null);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(y),(0,_reactNativeReanimated.cancelAnimation)(j)},[y,j]);const I=(0,_react.useCallback)(e=>{O.current!==e&&(O.current=e,c?.(e))},[c]),C=(0,_react.useCallback)(()=>{null!==O.current&&(O.current=null,s?.())},[s]),G=(0,_react.useCallback)(e=>{const t="left"===e?a:i,n=t?.[0];n&&(!1!==l&&(0,_index2.triggerHaptic)("notificationSuccess"),n.onPress(),y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),O.current=null,s?.())},[a,i,y,s,l]),A=(0,_react.useCallback)(()=>{y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),C()},[y,C]),P=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(l,"selection");t&&(0,_index2.triggerHaptic)(t),e.onPress(),A()},[A,l]),k=(0,_react.useMemo)(()=>{const e=x,t=g,a=R,i=-R,n=w,r=-w,c=p,s=b,l=f;return _reactNativeGestureHandler.Gesture.Pan().enabled(!o).withTestId(h?`${h}-gesture`:"swipeable-gesture").activeOffsetX([-10,10]).failOffsetY([-15,15]).onStart(()=>{"worklet";j.value=y.value}).onUpdate(a=>{"worklet";const i=j.value+a.translationX;y.value=i>0&&!s||i<0&&!l?0:i>e&&s?e+.35*(i-e):i<-t&&l?.35*(i+t)-t:i}).onEnd(()=>{"worklet";const o=y.value;return s&&o>=a?(y.value=(0,_reactNativeReanimated.withSpring)(n,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(G)("left")):l&&o<=i?(y.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(G)("right")):s&&o>=c?(y.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(I)("left")):l&&o<=-c?(y.value=(0,_reactNativeReanimated.withSpring)(-t,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(I)("right")):(y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(C)())})},[o,j,G,R,b,f,x,C,I,g,w,p,y,h]),F=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:y.value}]})),T=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:x>0?Math.min(1,Math.max(0,y.value/x)):0})),M=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:g>0?Math.min(1,Math.max(0,-y.value/g)):0})),E=(0,_react.useMemo)(()=>{const e=[];return a?.forEach(t=>e.push({name:t.key,label:t.label})),i?.forEach(t=>e.push({name:t.key,label:t.label})),e},[a,i]),q=(0,_react.useCallback)(e=>{const t=e.nativeEvent.actionName,n=[...a??[],...i??[]].find(e=>e.key===t);n&&(!1!==l&&(0,_index2.triggerHaptic)("selection"),n.onPress())},[a,i,l]);return b||f?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[N.root,u],testID:h,accessibilityLabel:m,accessibilityActions:E,onAccessibilityAction:q,children:[b?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[N.actionsRow,N.actionsLeft,{width:x},_,T],pointerEvents:"box-none",children:a?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:v,actionStyles:S,width:p,onPress:P},e.key))}):null,f?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[N.actionsRow,N.actionsRight,{width:g},_,M],pointerEvents:"box-none",children:i?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:v,actionStyles:S,width:p,onPress:P},e.key))}):null,(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:k,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[N.content,d,F],children:t})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u,testID:h,children:t})};exports.Swipeable=Swipeable,Swipeable.displayName="Swipeable";const ActionButton=({action:e,theme:t,actionStyles:a,width:i,onPress:n})=>{const r=e.tone??"neutral",c=toneToBg(t,r);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>n(e),accessibilityRole:"button",accessibilityLabel:e.label,style:[a.button,{width:i,backgroundColor:c,paddingHorizontal:t.space.sm}],children:[e.icon?(0,_jsxRuntime.jsx)(_reactNative.View,{style:a.icon,children:e.icon}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[a.label,{color:toneToOnColor(t,r),fontSize:t.text.sm.size,fontWeight:t.weight.semibold}],numberOfLines:1,children:e.label})]})},buildActionStyles=e=>_reactNative.StyleSheet.create({button:{flexGrow:0,flexShrink:0,alignItems:"center",justifyContent:"center"},icon:{marginBottom:e.space.xxs},label:{textAlign:"center"}}),buildStyles=e=>_reactNative.StyleSheet.create({root:{position:"relative",overflow:"hidden"},content:{backgroundColor:"transparent"},actionsRow:{position:"absolute",top:0,bottom:0,flexDirection:"row"},actionsLeft:{left:0},actionsRight:{right:0,justifyContent:"flex-end"}});var _default=exports.default=Swipeable;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Swipeable=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,i,n=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((a=n&&Object.getOwnPropertyDescriptor(e,i))&&(a.get||a.set)?n(r,i,a):r[i]=e[i]);return r}const SPRING_CONFIG={damping:22,stiffness:260,mass:1},DRAG_ACTIVATION_OFFSET=10,RUBBER_BAND_FACTOR=.35,FAIL_OFFSET_Y=15,toneToBg=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;default:return e.colors.neutral}},toneToOnColor=(e,t)=>{switch(t){case"primary":return e.colors["on-primary"];case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];default:return e.colors["on-neutral"]}},Swipeable=e=>{const{children:t,leftActions:a,rightActions:i,threshold:n,fullSwipeThreshold:r,onSwipeOpen:c,onSwipeClose:s,disabled:o=!1,haptic:l,containerStyle:u,contentStyle:d,actionStyle:_,accessibilityLabel:m,testID:h}=e,v=(0,_index.useTheme)(),p=n??80,R=r??200,N=(0,_react.useMemo)(()=>buildStyles(v),[v]),S=(0,_react.useMemo)(()=>buildActionStyles(v),[v]),b=!!a&&a.length>0,f=!!i&&i.length>0,w=_reactNative.Dimensions.get("window").width,x=b?p*(a?.length??0):0,g=f?p*(i?.length??0):0,y=(0,_reactNativeReanimated.useSharedValue)(0),j=(0,_reactNativeReanimated.useSharedValue)(0),O=(0,_react.useRef)(null);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(y),(0,_reactNativeReanimated.cancelAnimation)(j)},[y,j]);const I=(0,_react.useCallback)(e=>{O.current!==e&&(O.current=e,c?.(e))},[c]),C=(0,_react.useCallback)(()=>{null!==O.current&&(O.current=null,s?.())},[s]),G=(0,_react.useCallback)(e=>{const t="left"===e?a:i,n=t?.[0];n&&(!1!==l&&(0,_index2.triggerHaptic)("notificationSuccess"),n.onPress(),y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),O.current=null,s?.())},[a,i,y,s,l]),A=(0,_react.useCallback)(()=>{y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),C()},[y,C]),P=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(l,"selection");t&&(0,_index2.triggerHaptic)(t),e.onPress(),A()},[A,l]),k=(0,_react.useMemo)(()=>{const e=x,t=g,a=R,i=-R,n=w,r=-w,c=p,s=b,l=f;return _reactNativeGestureHandler.Gesture.Pan().enabled(!o).withTestId(h?`${h}-gesture`:"swipeable-gesture").activeOffsetX([-10,10]).failOffsetY([-15,15]).onStart(()=>{"worklet";j.value=y.value}).onUpdate(a=>{"worklet";const i=j.value+a.translationX;y.value=i>0&&!s||i<0&&!l?0:i>e&&s?e+.35*(i-e):i<-t&&l?.35*(i+t)-t:i}).onEnd(()=>{"worklet";const o=y.value;return s&&o>=a?(y.value=(0,_reactNativeReanimated.withSpring)(n,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(G)("left")):l&&o<=i?(y.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(G)("right")):s&&o>=c?(y.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(I)("left")):l&&o<=-c?(y.value=(0,_reactNativeReanimated.withSpring)(-t,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(I)("right")):(y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(C)())})},[o,j,G,R,b,f,x,C,I,g,w,p,y,h]),F=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:y.value}]})),T=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:x>0?Math.min(1,Math.max(0,y.value/x)):0})),M=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:g>0?Math.min(1,Math.max(0,-y.value/g)):0})),E=(0,_react.useMemo)(()=>{const e=[];return a?.forEach(t=>{e.push({name:t.key,label:t.label})}),i?.forEach(t=>{e.push({name:t.key,label:t.label})}),e},[a,i]),q=(0,_react.useCallback)(e=>{const t=e.nativeEvent.actionName,n=[...a??[],...i??[]].find(e=>e.key===t);n&&(!1!==l&&(0,_index2.triggerHaptic)("selection"),n.onPress())},[a,i,l]);return b||f?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[N.root,u],testID:h,accessibilityLabel:m,accessibilityActions:E,onAccessibilityAction:q,children:[b?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[N.actionsRow,N.actionsLeft,{width:x},_,T],pointerEvents:"box-none",children:a?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:v,actionStyles:S,width:p,onPress:P},e.key))}):null,f?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[N.actionsRow,N.actionsRight,{width:g},_,M],pointerEvents:"box-none",children:i?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:v,actionStyles:S,width:p,onPress:P},e.key))}):null,(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:k,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[N.content,d,F],children:t})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u,testID:h,children:t})};exports.Swipeable=Swipeable,Swipeable.displayName="Swipeable";const ActionButton=({action:e,theme:t,actionStyles:a,width:i,onPress:n})=>{const r=e.tone??"neutral",c=toneToBg(t,r);return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>n(e),accessibilityRole:"button",accessibilityLabel:e.label,style:[a.button,{width:i,backgroundColor:c,paddingHorizontal:t.space.sm}],children:[e.icon?(0,_jsxRuntime.jsx)(_reactNative.View,{style:a.icon,children:e.icon}):null,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[a.label,{color:toneToOnColor(t,r),fontSize:t.text.sm.size,fontWeight:t.weight.semibold}],numberOfLines:1,children:e.label})]})},buildActionStyles=e=>_reactNative.StyleSheet.create({button:{flexGrow:0,flexShrink:0,alignItems:"center",justifyContent:"center"},icon:{marginBottom:e.space.xxs},label:{textAlign:"center"}}),buildStyles=e=>_reactNative.StyleSheet.create({root:{position:"relative",overflow:"hidden"},content:{backgroundColor:"transparent"},actionsRow:{position:"absolute",top:0,bottom:0,flexDirection:"row"},actionsLeft:{left:0},actionsRight:{right:0,justifyContent:"flex-end"}});var _default=exports.default=Swipeable;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Toast=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_jsxRuntime=require("react/jsx-runtime");const SWIPE_DISMISS_THRESHOLD=80,SWIPE_VELOCITY_THRESHOLD=.5,STACK_OFFSET=8,STACK_SCALE_STEP=.04,DEFAULT_AUTO_DISMISS_MS=3e3,WEB_ACTION_MIN_DURATION_MS=8e3,COUNTDOWN_BAR_HEIGHT=3,ACTION_HIT_SLOP={top:10,bottom:10,left:10,right:10},DISMISS_ACTIONS=[{name:"dismiss",label:"Dismiss"}],Toast=({toast:e,index:t,onDismiss:i,shownAt:a,runtime:n})=>{const r=(0,_index.useTheme)(),s=(0,_usePresenceMotion.usePresenceMotion)(),o=s.duration("fast"),c=e.variant??"default",l=e.position??"bottom",u=(0,_react.useMemo)(()=>buildStyles(r),[r]),d=(0,_react.useMemo)(()=>tintFor(r,c),[r,c]),m=(0,_react.useMemo)(()=>inkFor(r,c),[r,c]),_=r.components.toast["icon-circle-size"],p=r.text[r.components.toast["icon-glyph-text"]].size,v=r.components.toast["tint-bar-width"],g=r.settings.components.toast?.defaultDurationMs??3e3,h=r.settings.components.toast?.enableSwipeDismiss??!0,x="top"===l?-120:120,f=(0,_react.useRef)((0,_index.createAnimatedValue)(s.reduced?0:x)).current,N=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,b=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,A=(0,_react.useRef)(!1),S="top"===l?8*t:8*-t,y=Math.max(1-.04*t,.9),w=(0,_react.useRef)((0,_index.createAnimatedValue)(S)).current;(0,_react.useEffect)(()=>{(0,_index.setNativeValue)(w,S)},[S,w]);const R=(0,_react.useMemo)(()=>_reactNative.Animated.add(f,w),[f,w]),M=void 0!==e.action,T=e.duration??g,V=T>0&&M&&"web"===_reactNative.Platform.OS?Math.max(T,8e3):T,D=V<=0||M&&!0===n?.screenReaderOn,j=!0===e.countdown&&!D,C=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,I=(0,_react.useRef)({initialised:!1,timer:null,remaining:0,startedAt:0}),E=(0,_react.useRef)({touch:!1,pan:!1,hover:!1}),O=(0,_react.useRef)(()=>{}),P=(0,_react.useRef)({id:e.id,totalMs:V,shownAt:a,runtime:n,persistent:D,animateBar:!1});P.current={id:e.id,totalMs:V,shownAt:a,runtime:n,persistent:D,animateBar:j&&!s.reduced};const k=(0,_react.useCallback)(()=>{const e=I.current,t=P.current,i=E.current;if(!e.initialised){e.initialised=!0;const i=t.runtime?.readRemaining(t.id),a=void 0===t.shownAt?0:Date.now()-t.shownAt;e.remaining=i??(t.totalMs>0?Math.max(t.totalMs-a,0):0),t.totalMs>0&&e.remaining<t.totalMs&&(0,_index.setNativeValue)(C,e.remaining/t.totalMs)}const a=!(t.persistent||A.current||i.touch||i.pan||i.hover);a&&null===e.timer?(e.startedAt=Date.now(),e.timer=setTimeout(()=>{e.timer=null,e.remaining=0,O.current()},e.remaining),t.animateBar&&_reactNative.Animated.timing(C,{toValue:0,duration:e.remaining,easing:_reactNative.Easing.linear,useNativeDriver:!0}).start()):a||null===e.timer||(clearTimeout(e.timer),e.timer=null,e.remaining=Math.max(e.remaining-(Date.now()-e.startedAt),0),C.stopAnimation())},[C]),dismiss=()=>{if(A.current)return;A.current=!0,k();const t=[_reactNative.Animated.timing(b,{toValue:0,duration:o,easing:_reactNative.Easing.bezier(...r.motion.ease.accelerate),useNativeDriver:!0})];s.reduced||t.push(_reactNative.Animated.timing(f,{toValue:x,duration:r.motion.duration.fast,easing:_reactNative.Easing.bezier(...r.motion.ease.accelerate),useNativeDriver:!0})),_reactNative.Animated.parallel(t).start(()=>i(e.id))};O.current=dismiss,(0,_react.useEffect)(()=>{const e=s.reduced?_reactNative.Animated.timing(b,{toValue:1,duration:o,useNativeDriver:!0}):_reactNative.Animated.parallel([_reactNative.Animated.spring(f,{toValue:0,damping:18,stiffness:180,mass:1,useNativeDriver:!0}),_reactNative.Animated.timing(b,{toValue:1,duration:o,useNativeDriver:!0})]);return e.start(),()=>e.stop()},[]),(0,_react.useEffect)(()=>{k()},[D,k]),(0,_react.useEffect)(()=>()=>{const e=I.current,t=P.current;null!==e.timer&&(clearTimeout(e.timer),e.timer=null,e.remaining=Math.max(e.remaining-(Date.now()-e.startedAt),0)),C.stopAnimation(),e.initialised&&t.totalMs>0&&!A.current&&t.runtime?.writeRemaining(t.id,e.remaining)},[C]);const L=(0,_react.useCallback)((e,t)=>{E.current[e]=t,k()},[k]),H=(0,_react.useCallback)(()=>L("touch",!0),[L]),F=(0,_react.useCallback)(e=>L("touch",(e.nativeEvent.touches?.length??0)>0),[L]),z=(0,_react.useCallback)(()=>L("hover",!0),[L]),B=(0,_react.useCallback)(()=>L("hover",!1),[L]),q=(0,_react.useMemo)(()=>_reactNative.PanResponder.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>Math.abs(t.dy)&&Math.abs(t.dx)>6,onPanResponderGrant:()=>L("pan",!0),onPanResponderMove:(e,t)=>{(0,_index.setNativeValue)(N,t.dx);const i=1-.7*Math.min(Math.abs(t.dx)/200,1);(0,_index.setNativeValue)(b,i)},onPanResponderTerminate:()=>{if(L("pan",!1),s.reduced)return(0,_index.setNativeValue)(N,0),void _reactNative.Animated.timing(b,{toValue:1,duration:o,useNativeDriver:!0}).start();_reactNative.Animated.parallel([_reactNative.Animated.spring(N,{toValue:0,damping:r.motion.spring.snappy.damping,stiffness:r.motion.spring.snappy.stiffness,mass:r.motion.spring.snappy.mass,useNativeDriver:!0}),_reactNative.Animated.timing(b,{toValue:1,duration:o,useNativeDriver:!0})]).start()},onPanResponderRelease:(t,a)=>{if(Math.abs(a.dx)>80||Math.abs(a.vx)>.5){const t=a.dx>=0?1:-1;A.current=!0,L("pan",!1);const n=[_reactNative.Animated.timing(b,{toValue:0,duration:o,useNativeDriver:!0})];s.reduced||n.push(_reactNative.Animated.timing(N,{toValue:500*t,duration:r.motion.duration.fast,useNativeDriver:!0})),_reactNative.Animated.parallel(n).start(()=>i(e.id))}else L("pan",!1),s.reduced?((0,_index.setNativeValue)(N,0),_reactNative.Animated.timing(b,{toValue:1,duration:o,useNativeDriver:!0}).start()):_reactNative.Animated.parallel([_reactNative.Animated.spring(N,{toValue:0,useNativeDriver:!0}),_reactNative.Animated.spring(b,{toValue:1,useNativeDriver:!0})]).start()}}),[N,b,L,o,s.reduced,r.motion.duration.fast,r.motion.spring.snappy.damping,r.motion.spring.snappy.stiffness,r.motion.spring.snappy.mass,i,e.id]),G={accessibilityActions:DISMISS_ACTIONS,onAccessibilityAction:e=>{"dismiss"===e.nativeEvent.actionName&&dismiss()}},[W,U]=(0,_react.useState)(0),$=(0,_react.useMemo)(()=>C.interpolate({inputRange:[0,1],outputRange:[-W,0]}),[C,W]),K=e.description?`${e.message}. ${e.description}`:e.message,X=e.action&&j?`${e.action.label}, ${Math.ceil(V/1e3)} seconds`:e.action?.label;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{...h?q.panHandlers:{},...M?{}:{accessible:!0,...G},..."web"===_reactNative.Platform.OS?{onPointerEnter:z,onPointerLeave:B}:{},onTouchStart:H,onTouchEnd:F,onTouchCancel:F,accessibilityLabel:K,testID:e.testID,style:[u.container,{backgroundColor:r.colors.surface,borderRadius:r.radius.lg,..._corners.smoothCorners,padding:r.space.md,...r.shadow.elevated,opacity:b,transform:[{translateY:R},{translateX:N},{scale:y}]},e.style,e.containerStyle],children:[v>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[u.tintBar,{width:v,backgroundColor:d}]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:u.row,children:[(()=>{if(e.icon)return e.icon;const t=defaultGlyph(c);return t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[u.iconCircle,{width:_,height:_,borderRadius:r.radius.pill,..._corners.smoothCorners,backgroundColor:d+"22"},e.iconCircleStyle],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[u.iconGlyph,{color:m,fontSize:p}],accessible:!1,children:t})}):null})(),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:u.textBlock,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[u.message,{color:r.colors["text-body"],fontSize:r.text.base.size,...(0,_index.fontFor)(r,"semibold")},e.textStyle,e.messageStyle],numberOfLines:2,children:e.message}),e.description?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[u.description,{color:r.colors["text-muted"],fontSize:r.text.sm.size}],numberOfLines:3,children:e.description}):null]}),e.action?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:X,hitSlop:ACTION_HIT_SLOP,...(0,_hitSlop.hitSlopMarker)(ACTION_HIT_SLOP),...G,onPress:()=>{e.action?.onPress(),dismiss()},style:({pressed:t})=>[u.actionBtn,{backgroundColor:t?r.colors["surface-pressed"]:"transparent"},e.actionButtonStyle],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:d,fontSize:r.text.sm.size,...(0,_index.fontFor)(r,"semibold")},numberOfLines:1,children:e.action.label})}):null]}),j?(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",onLayout:e=>U(e.nativeEvent.layout.width),testID:"toast-countdown",style:[u.countdownTrack,{backgroundColor:d+"22"}],children:[s.reduced?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[u.countdownFill,{backgroundColor:d}]}):null,!s.reduced&&W>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[u.countdownFill,{backgroundColor:d,transform:[{translateX:$}]}]}):null]}):null]})};exports.Toast=Toast;const tintFor=(e,t)=>{switch(t){case"success":return e.colors.success;case"danger":return e.colors.danger;case"warning":return e.colors.warning;case"info":return e.colors.info;default:return e.colors["text-body"]}},inkFor=(e,t)=>{switch(t){case"success":return e.colors["success-text"];case"danger":return e.colors["danger-text"];case"warning":return e.colors["warning-text"];case"info":return e.colors["info-text"];default:return e.colors["text-body"]}},defaultGlyph=e=>{switch(e){case"success":return"✓";case"danger":return"×";case"warning":return"!";case"info":return"i";default:return""}},buildStyles=e=>_reactNative.StyleSheet.create({container:{overflow:"hidden",marginVertical:e.space.xs},tintBar:{position:"absolute",left:0,top:0,bottom:0},row:{flexDirection:"row",alignItems:"center",paddingLeft:e.space.sm},iconCircle:{alignItems:"center",justifyContent:"center",marginRight:e.space.md},iconGlyph:{fontWeight:"700",lineHeight:19},textBlock:{flex:1,paddingRight:e.space.sm},message:{lineHeight:20},description:{marginTop:e.space.xxs,lineHeight:18},countdownTrack:{position:"absolute",left:0,right:0,bottom:0,height:3,overflow:"hidden"},countdownFill:{position:"absolute",left:0,right:0,top:0,bottom:0},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,minHeight:e.components.toast["action-min-height"],borderRadius:e.radius.md,..._corners.smoothCorners,marginLeft:e.space.sm}});var _default=exports.default=Toast;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Toast=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_jsxRuntime=require("react/jsx-runtime");const SWIPE_DISMISS_THRESHOLD=80,SWIPE_VELOCITY_THRESHOLD=.5,STACK_OFFSET=8,STACK_SCALE_STEP=.04,DEFAULT_AUTO_DISMISS_MS=3e3,WEB_ACTION_MIN_DURATION_MS=8e3,COUNTDOWN_BAR_HEIGHT=3,ACTION_HIT_SLOP={top:10,bottom:10,left:10,right:10},DISMISS_ACTIONS=[{name:"dismiss",label:"Dismiss"}],Toast=({toast:e,index:t,onDismiss:i,shownAt:a,runtime:n})=>{const r=(0,_index.useTheme)(),s=(0,_usePresenceMotion.usePresenceMotion)(),o=s.duration("fast"),c=e.variant??"default",l=e.position??"bottom",u=(0,_react.useMemo)(()=>buildStyles(r),[r]),d=(0,_react.useMemo)(()=>tintFor(r,c),[r,c]),m=(0,_react.useMemo)(()=>inkFor(r,c),[r,c]),_=r.components.toast["icon-circle-size"],p=r.text[r.components.toast["icon-glyph-text"]].size,v=r.components.toast["tint-bar-width"],g=r.settings.components.toast?.defaultDurationMs??3e3,h=r.settings.components.toast?.enableSwipeDismiss??!0,x="top"===l?-120:120,f=(0,_react.useRef)((0,_index.createAnimatedValue)(s.reduced?0:x)).current,N=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,b=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current,A=(0,_react.useRef)(!1),S="top"===l?8*t:8*-t,y=Math.max(1-.04*t,.9),w=(0,_react.useRef)((0,_index.createAnimatedValue)(S)).current;(0,_react.useEffect)(()=>{(0,_index.setNativeValue)(w,S)},[S,w]);const R=(0,_react.useMemo)(()=>_reactNative.Animated.add(f,w),[f,w]),M=void 0!==e.action,T=e.duration??g,V=T>0&&M&&"web"===_reactNative.Platform.OS?Math.max(T,8e3):T,D=V<=0||M&&!0===n?.screenReaderOn,j=!0===e.countdown&&!D,C=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,I=(0,_react.useRef)({initialised:!1,timer:null,remaining:0,startedAt:0}),E=(0,_react.useRef)({touch:!1,pan:!1,hover:!1}),O=(0,_react.useRef)(()=>{}),P=(0,_react.useRef)({id:e.id,totalMs:V,shownAt:a,runtime:n,persistent:D,animateBar:!1});P.current={id:e.id,totalMs:V,shownAt:a,runtime:n,persistent:D,animateBar:j&&!s.reduced};const k=(0,_react.useCallback)(()=>{const e=I.current,t=P.current,i=E.current;if(!e.initialised){e.initialised=!0;const i=t.runtime?.readRemaining(t.id),a=void 0===t.shownAt?0:Date.now()-t.shownAt;e.remaining=i??(t.totalMs>0?Math.max(t.totalMs-a,0):0),t.totalMs>0&&e.remaining<t.totalMs&&(0,_index.setNativeValue)(C,e.remaining/t.totalMs)}const a=!(t.persistent||A.current||i.touch||i.pan||i.hover);a&&null===e.timer?(e.startedAt=Date.now(),e.timer=setTimeout(()=>{e.timer=null,e.remaining=0,O.current()},e.remaining),t.animateBar&&_reactNative.Animated.timing(C,{toValue:0,duration:e.remaining,easing:_reactNative.Easing.linear,useNativeDriver:!0}).start()):a||null===e.timer||(clearTimeout(e.timer),e.timer=null,e.remaining=Math.max(e.remaining-(Date.now()-e.startedAt),0),C.stopAnimation())},[C]),dismiss=()=>{if(A.current)return;A.current=!0,k();const t=[_reactNative.Animated.timing(b,{toValue:0,duration:o,easing:_reactNative.Easing.bezier(...r.motion.ease.accelerate),useNativeDriver:!0})];s.reduced||t.push(_reactNative.Animated.timing(f,{toValue:x,duration:r.motion.duration.fast,easing:_reactNative.Easing.bezier(...r.motion.ease.accelerate),useNativeDriver:!0})),_reactNative.Animated.parallel(t).start(()=>i(e.id))};O.current=dismiss,(0,_react.useEffect)(()=>{const e=s.reduced?_reactNative.Animated.timing(b,{toValue:1,duration:o,useNativeDriver:!0}):_reactNative.Animated.parallel([_reactNative.Animated.spring(f,{toValue:0,damping:18,stiffness:180,mass:1,useNativeDriver:!0}),_reactNative.Animated.timing(b,{toValue:1,duration:o,useNativeDriver:!0})]);return e.start(),()=>e.stop()},[]),(0,_react.useEffect)(()=>{k()},[D,k]),(0,_react.useEffect)(()=>()=>{const e=I.current,t=P.current;null!==e.timer&&(clearTimeout(e.timer),e.timer=null,e.remaining=Math.max(e.remaining-(Date.now()-e.startedAt),0)),C.stopAnimation(),e.initialised&&t.totalMs>0&&!A.current&&t.runtime?.writeRemaining(t.id,e.remaining)},[C]);const L=(0,_react.useCallback)((e,t)=>{E.current[e]=t,k()},[k]),H=(0,_react.useCallback)(()=>L("touch",!0),[L]),F=(0,_react.useCallback)(e=>L("touch",(e.nativeEvent.touches?.length??0)>0),[L]),z=(0,_react.useCallback)(()=>L("hover",!0),[L]),B=(0,_react.useCallback)(()=>L("hover",!1),[L]),q=(0,_react.useMemo)(()=>_reactNative.PanResponder.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>Math.abs(t.dy)&&Math.abs(t.dx)>6,onPanResponderGrant:()=>L("pan",!0),onPanResponderMove:(e,t)=>{(0,_index.setNativeValue)(N,t.dx);const i=1-.7*Math.min(Math.abs(t.dx)/200,1);(0,_index.setNativeValue)(b,i)},onPanResponderTerminate:()=>{if(L("pan",!1),s.reduced)return(0,_index.setNativeValue)(N,0),void _reactNative.Animated.timing(b,{toValue:1,duration:o,useNativeDriver:!0}).start();_reactNative.Animated.parallel([_reactNative.Animated.spring(N,{toValue:0,damping:r.motion.spring.snappy.damping,stiffness:r.motion.spring.snappy.stiffness,mass:r.motion.spring.snappy.mass,useNativeDriver:!0}),_reactNative.Animated.timing(b,{toValue:1,duration:o,useNativeDriver:!0})]).start()},onPanResponderRelease:(t,a)=>{if(Math.abs(a.dx)>80||Math.abs(a.vx)>.5){const t=a.dx>=0?1:-1;A.current=!0,L("pan",!1);const n=[_reactNative.Animated.timing(b,{toValue:0,duration:o,useNativeDriver:!0})];s.reduced||n.push(_reactNative.Animated.timing(N,{toValue:500*t,duration:r.motion.duration.fast,useNativeDriver:!0})),_reactNative.Animated.parallel(n).start(()=>i(e.id))}else L("pan",!1),s.reduced?((0,_index.setNativeValue)(N,0),_reactNative.Animated.timing(b,{toValue:1,duration:o,useNativeDriver:!0}).start()):_reactNative.Animated.parallel([_reactNative.Animated.spring(N,{toValue:0,useNativeDriver:!0}),_reactNative.Animated.spring(b,{toValue:1,useNativeDriver:!0})]).start()}}),[N,b,L,o,s.reduced,r.motion.duration.fast,r.motion.spring.snappy.damping,r.motion.spring.snappy.stiffness,r.motion.spring.snappy.mass,i,e.id]),G={accessibilityActions:DISMISS_ACTIONS,onAccessibilityAction:e=>{"dismiss"===e.nativeEvent.actionName&&dismiss()}},[$,W]=(0,_react.useState)(0),U=(0,_react.useMemo)(()=>C.interpolate({inputRange:[0,1],outputRange:[-$,0]}),[C,$]),K=e.description?`${e.message}. ${e.description}`:e.message,X=e.action&&j?`${e.action.label}, ${Math.ceil(V/1e3)} seconds`:e.action?.label;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{...h?q.panHandlers:{},...M?{}:{accessible:!0,...G},..."web"===_reactNative.Platform.OS?{onPointerEnter:z,onPointerLeave:B}:{},onTouchStart:H,onTouchEnd:F,onTouchCancel:F,accessibilityLabel:K,testID:e.testID,style:[u.container,{backgroundColor:r.colors.surface,borderRadius:r.radius.lg,..._corners.smoothCorners,padding:r.space.md,...r.shadow.elevated,opacity:b,transform:[{translateY:R},{translateX:N},{scale:y}]},e.style,e.containerStyle],children:[v>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[u.tintBar,{width:v,backgroundColor:d}]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:u.row,children:[(()=>{if(e.icon)return e.icon;const t=defaultGlyph(c);return t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[u.iconCircle,{width:_,height:_,borderRadius:r.radius.pill,..._corners.smoothCorners,backgroundColor:`${d}22`},e.iconCircleStyle],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[u.iconGlyph,{color:m,fontSize:p}],accessible:!1,children:t})}):null})(),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:u.textBlock,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[u.message,{color:r.colors["text-body"],fontSize:r.text.base.size,...(0,_index.fontFor)(r,"semibold")},e.textStyle,e.messageStyle],numberOfLines:2,children:e.message}),e.description?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[u.description,{color:r.colors["text-muted"],fontSize:r.text.sm.size}],numberOfLines:3,children:e.description}):null]}),e.action?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:X,hitSlop:ACTION_HIT_SLOP,...(0,_hitSlop.hitSlopMarker)(ACTION_HIT_SLOP),...G,onPress:()=>{e.action?.onPress(),dismiss()},style:({pressed:t})=>[u.actionBtn,{backgroundColor:t?r.colors["surface-pressed"]:"transparent"},e.actionButtonStyle],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:{color:d,fontSize:r.text.sm.size,...(0,_index.fontFor)(r,"semibold")},numberOfLines:1,children:e.action.label})}):null]}),j?(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",onLayout:e=>W(e.nativeEvent.layout.width),testID:"toast-countdown",style:[u.countdownTrack,{backgroundColor:`${d}22`}],children:[s.reduced?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[u.countdownFill,{backgroundColor:d}]}):null,!s.reduced&&$>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[u.countdownFill,{backgroundColor:d,transform:[{translateX:U}]}]}):null]}):null]})};exports.Toast=Toast;const tintFor=(e,t)=>{switch(t){case"success":return e.colors.success;case"danger":return e.colors.danger;case"warning":return e.colors.warning;case"info":return e.colors.info;default:return e.colors["text-body"]}},inkFor=(e,t)=>{switch(t){case"success":return e.colors["success-text"];case"danger":return e.colors["danger-text"];case"warning":return e.colors["warning-text"];case"info":return e.colors["info-text"];default:return e.colors["text-body"]}},defaultGlyph=e=>{switch(e){case"success":return"✓";case"danger":return"×";case"warning":return"!";case"info":return"i";default:return""}},buildStyles=e=>_reactNative.StyleSheet.create({container:{overflow:"hidden",marginVertical:e.space.xs},tintBar:{position:"absolute",left:0,top:0,bottom:0},row:{flexDirection:"row",alignItems:"center",paddingLeft:e.space.sm},iconCircle:{alignItems:"center",justifyContent:"center",marginRight:e.space.md},iconGlyph:{fontWeight:"700",lineHeight:19},textBlock:{flex:1,paddingRight:e.space.sm},message:{lineHeight:20},description:{marginTop:e.space.xxs,lineHeight:18},countdownTrack:{position:"absolute",left:0,right:0,bottom:0,height:3,overflow:"hidden"},countdownFill:{position:"absolute",left:0,right:0,top:0,bottom:0},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,minHeight:e.components.toast["action-min-height"],borderRadius:e.radius.md,..._corners.smoothCorners,marginLeft:e.space.sm}});var _default=exports.default=Toast;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setPath=exports.getPath=exports.deletePath=void 0;const tokenize=t=>{const e=[],r=/[^.[\]]+/g;let o;for(;null!==(o=r.exec(t));){const t=o[0];e.push(/^\d+$/.test(t)?Number(t):t)}return e},getPath=(t,e)=>{const r=tokenize(e);let o=t;for(const t of r){if(null==o||"object"!=typeof o)return;o=o[t]}return o};exports.getPath=getPath;const setPath=(t,e,r)=>{const o=tokenize(e);if(0===o.length)return t;const n=Array.isArray(t)?[...t]:{...t};let s=n;for(let t=0;t<o.length-1;t++){const e=o[t],r=o[t+1],n=s[e],l=null!=n&&"object"==typeof n?Array.isArray(n)?[...n]:{...n}:"number"==typeof r?[]:{};s[e]=l,s=l}return s[o[o.length-1]]=r,n};exports.setPath=setPath;const deletePath=(t,e)=>{const r=tokenize(e);if(0===r.length)return t;const o=Array.isArray(t)?[...t]:{...t};let n=o;for(let t=0;t<r.length-1;t++){const e=r[t],s=n[e];if(null==s||"object"!=typeof s)return o;const l=Array.isArray(s)?[...s]:{...s};n[e]=l,n=l}const s=r[r.length-1];return Array.isArray(n)&&"number"==typeof s?n.splice(s,1):delete n[s],o};exports.deletePath=deletePath;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setPath=exports.getPath=exports.deletePath=void 0;const tokenize=t=>{const e=[],r=/[^.[\]]+/g;for(const o of t.matchAll(r)){const t=o[0];e.push(/^\d+$/.test(t)?Number(t):t)}return e},getPath=(t,e)=>{const r=tokenize(e);let o=t;for(const t of r){if(null==o||"object"!=typeof o)return;o=o[t]}return o};exports.getPath=getPath;const setPath=(t,e,r)=>{const o=tokenize(e);if(0===o.length)return t;const n=Array.isArray(t)?[...t]:{...t};let s=n;for(let t=0;t<o.length-1;t++){const e=o[t],r=o[t+1],n=s[e],l=null!=n&&"object"==typeof n?Array.isArray(n)?[...n]:{...n}:"number"==typeof r?[]:{};s[e]=l,s=l}return s[o[o.length-1]]=r,n};exports.setPath=setPath;const deletePath=(t,e)=>{const r=tokenize(e);if(0===r.length)return t;const o=Array.isArray(t)?[...t]:{...t};let n=o;for(let t=0;t<r.length-1;t++){const e=r[t],s=n[e];if(null==s||"object"!=typeof s)return o;const l=Array.isArray(s)?[...s]:{...s};n[e]=l,n=l}const s=r[r.length-1];return Array.isArray(n)&&"number"==typeof s?n.splice(s,1):delete n[s],o};exports.deletePath=deletePath;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.announce=void 0;var _reactNative=require("react-native");let webRegions=null;const webRegion=e=>{if("undefined"==typeof document)return null;if(!webRegions||!webRegions.polite.isConnected){const make=e=>{const t=document.createElement("div");return t.setAttribute("aria-live",e),t.setAttribute("aria-atomic","true"),t.setAttribute("role","assertive"===e?"alert":"status"),Object.assign(t.style,{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"}),document.body.appendChild(t),t};webRegions={polite:make("polite"),assertive:make("assertive")}}return e?webRegions.polite:webRegions.assertive},announce=(e,t)=>{if(!e)return;const i=!1!==t?.polite;if("web"===_reactNative.Platform.OS){const t=webRegion(i);return void(t&&(t.textContent="",setTimeout(()=>{t.textContent=e},50)))}"ios"!==_reactNative.Platform.OS?_reactNative.AccessibilityInfo.announceForAccessibility(e):_reactNative.AccessibilityInfo.announceForAccessibilityWithOptions(e,i?{queue:!0}:{queue:!1,priority:"high"})};exports.announce=announce;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.announce=void 0;var _reactNative=require("react-native");let webRegions=null;const webRegion=e=>{if("undefined"==typeof document)return null;if(!webRegions?.polite.isConnected){const make=e=>{const t=document.createElement("div");return t.setAttribute("aria-live",e),t.setAttribute("aria-atomic","true"),t.setAttribute("role","assertive"===e?"alert":"status"),Object.assign(t.style,{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"}),document.body.appendChild(t),t};webRegions={polite:make("polite"),assertive:make("assertive")}}return e?webRegions.polite:webRegions.assertive},announce=(e,t)=>{if(!e)return;const i=!1!==t?.polite;if("web"===_reactNative.Platform.OS){const t=webRegion(i);return void(t&&(t.textContent="",setTimeout(()=>{t.textContent=e},50)))}"ios"!==_reactNative.Platform.OS?_reactNative.AccessibilityInfo.announceForAccessibility(e):_reactNative.AccessibilityInfo.announceForAccessibilityWithOptions(e,i?{queue:!0}:{queue:!1,priority:"high"})};exports.announce=announce;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,Text,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,fontFor,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Banner=forwardRef((e,t)=>{const{title:r,message:o,variant:s="info",icon:n,actions:i,dismissible:l=!1,onDismiss:a,haptic:c,visible:d=!0,animateMount:u=!0,loading:m=!1,accessibilityRole:p="alert",accessibilityLabel:g,style:h,containerStyle:x,iconCircleStyle:y,tintBarStyle:b,closeButtonStyle:f,actionButtonStyle:w,testID:j}=e,S=useTheme(),k=usePresenceMotion(),C=useMemo(()=>buildStyles(S),[S]),B=useMemo(()=>tintFor(S,s),[S,s]),[_,R]=k.range(-20,0),V=useRef(createAnimatedValue(u&&d?_:0)).current,v=useRef(createAnimatedValue(u&&d?0:d?1:0)).current,[z,T]=useState(d),H=useRef(!0);if(useEffect(()=>{if(H.current&&(H.current=!1,!u))return;let e;return d?(T(!0),e=Animated.parallel([Animated.timing(V,{toValue:R,duration:S.motion.duration.default,useNativeDriver:!0}),Animated.timing(v,{toValue:1,duration:k.duration("default"),useNativeDriver:!0})]),e.start()):z&&(e=Animated.parallel([Animated.timing(V,{toValue:_,duration:S.motion.duration.fast,useNativeDriver:!0}),Animated.timing(v,{toValue:0,duration:k.duration("fast"),useNativeDriver:!0})]),e.start(()=>{T(!1)})),()=>e?.stop()},[d]),!z)return null;const A=r??" ",D="string"==typeof o?o??" ":"",M="alert"===p?"danger"===s?"assertive":"polite":"none",L=_jsxs(Animated.View,{ref:t,accessibilityRole:p,accessibilityLiveRegion:M,accessibilityLabel:g,testID:j,style:[C.container,{backgroundColor:S.colors["bg-subtle"],borderRadius:S.radius.md,...smoothCorners,padding:S.space.md,opacity:v,transform:[{translateY:V}]},h,x],children:[S.components.banner["tint-bar-width"]>0?_jsx(View,{style:[C.tintBar,{backgroundColor:B.bar},b]}):null,_jsxs(View,{style:C.row,children:[!1===n?null:_jsx(View,n?{style:C.iconWrap,children:n}:{style:[C.iconCircle,{backgroundColor:B.bar+"22"},y],children:_jsx(Text,{style:[C.iconGlyph,{color:B.ink}],accessible:!1,children:B.glyph})}),_jsxs(View,{style:C.textBlock,children:[r||m?_jsx(Text,{style:{color:S.colors["text-body"],fontSize:S.text.base.size,...fontFor(S,"semibold"),lineHeight:20},numberOfLines:2,children:A}):null,"string"==typeof o||m?_jsx(Text,{style:{color:S.colors["text-muted"],fontSize:S.text.sm.size,...fontFor(S,"normal"),lineHeight:18,marginTop:r?S.space.xxs:0},children:D||" "}):_jsx(View,{style:{marginTop:r?S.space.xxs:0},children:o})]}),l?_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:"Dismiss banner",onPress:()=>{const e=resolveHaptic(c,"selection");e&&triggerHaptic(e),a?.()},hitSlop:8,...hitSlopMarker(8),style:({pressed:e})=>[C.closeBtn,{backgroundColor:e?S.colors["surface-pressed"]:"transparent"},f],children:_jsx(Text,{style:{color:S.colors["text-muted"],fontSize:S.text.lg.size,fontWeight:S.weight.bold,lineHeight:17},accessible:!1,children:"×"})}):null]}),i&&i.length>0?_jsx(View,{style:C.actionsRow,children:i.map((e,t)=>{const r=e.tone??"primary",o=e.variant??"ghost",s="danger"===r?S.colors.danger:"neutral"===r?S.colors["text-muted"]:B.glyphColor,n="danger"===r?S.colors["danger-text"]:"neutral"===r?S.colors["text-muted"]:B.ink,i="danger"===r?S.colors["on-danger"]:"neutral"===r?S.colors["on-neutral-strong"]:B.on,l="solid"===o;return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{const t=resolveHaptic(c,"selection");t&&triggerHaptic(t),e.onPress()},style:({pressed:t})=>[C.actionBtn,"md"===e.size&&C.actionBtnMd,"outline"===o&&{borderWidth:1,borderColor:n},{backgroundColor:l?s:t?S.colors["surface-pressed"]:"transparent",opacity:l&&t?.85:1},w],children:_jsx(Text,{style:{color:l?i:n,fontSize:S.text.sm.size,textAlign:"center",...fontFor(S,"semibold")},children:e.label})},`${e.label}-${t}`)})}):null]});return m?_jsx(BannerSkeleton,{...e}):L});Banner.displayName="Banner";const BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:o,style:s})=>{const n=useTheme(),i=!1!==r;return _jsxs(View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:n.colors.surface,borderRadius:n.radius.md,...smoothCorners,padding:n.space.md,borderWidth:1,borderColor:n.colors.border},o,s],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[i?_jsx(View,{style:{marginRight:n.space.sm},children:_jsx(Skeleton,{shape:"circle",width:32,height:32})}):null,_jsxs(View,{style:{flex:1},children:[void 0!==e?_jsx(Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:n.space.xs}}):null,_jsx(SkeletonText,{lines:2,fontSize:n.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?_jsx(View,{style:{flexDirection:"row",marginTop:n.space.sm},children:t.map((e,t)=>_jsx(Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:n.space.sm}},`sk-banner-action-${t}`))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton",Banner.Skeleton=BannerSkeleton;const tintFor=(e,t)=>{switch(t){case"success":return{bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};default:return{bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"}}},buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},iconWrap:{marginRight:r},iconCircle:{width:28,height:28,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",marginRight:r},iconGlyph:{fontSize:e.text.base.size,fontWeight:"700",lineHeight:17},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};export{Banner};export default Banner;
1
+ "use strict";import{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,Text,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,fontFor,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const Banner=forwardRef((e,t)=>{const{title:r,message:o,variant:s="info",icon:n,actions:i,dismissible:l=!1,onDismiss:a,haptic:c,visible:d=!0,animateMount:u=!0,loading:m=!1,accessibilityRole:p="alert",accessibilityLabel:g,style:h,containerStyle:x,iconCircleStyle:y,tintBarStyle:b,closeButtonStyle:f,actionButtonStyle:w,testID:j}=e,S=useTheme(),k=usePresenceMotion(),C=useMemo(()=>buildStyles(S),[S]),B=useMemo(()=>tintFor(S,s),[S,s]),[_,R]=k.range(-20,0),V=useRef(createAnimatedValue(u&&d?_:0)).current,v=useRef(createAnimatedValue(u&&d?0:d?1:0)).current,[z,T]=useState(d),H=useRef(!0);if(useEffect(()=>{if(H.current&&(H.current=!1,!u))return;let e;return d?(T(!0),e=Animated.parallel([Animated.timing(V,{toValue:R,duration:S.motion.duration.default,useNativeDriver:!0}),Animated.timing(v,{toValue:1,duration:k.duration("default"),useNativeDriver:!0})]),e.start()):z&&(e=Animated.parallel([Animated.timing(V,{toValue:_,duration:S.motion.duration.fast,useNativeDriver:!0}),Animated.timing(v,{toValue:0,duration:k.duration("fast"),useNativeDriver:!0})]),e.start(()=>{T(!1)})),()=>e?.stop()},[d]),!z)return null;const A=r??" ",D="string"==typeof o?o??" ":"",M="alert"===p?"danger"===s?"assertive":"polite":"none",L=_jsxs(Animated.View,{ref:t,accessibilityRole:p,accessibilityLiveRegion:M,accessibilityLabel:g,testID:j,style:[C.container,{backgroundColor:S.colors["bg-subtle"],borderRadius:S.radius.md,...smoothCorners,padding:S.space.md,opacity:v,transform:[{translateY:V}]},h,x],children:[S.components.banner["tint-bar-width"]>0?_jsx(View,{style:[C.tintBar,{backgroundColor:B.bar},b]}):null,_jsxs(View,{style:C.row,children:[!1===n?null:_jsx(View,n?{style:C.iconWrap,children:n}:{style:[C.iconCircle,{backgroundColor:`${B.bar}22`},y],children:_jsx(Text,{style:[C.iconGlyph,{color:B.ink}],accessible:!1,children:B.glyph})}),_jsxs(View,{style:C.textBlock,children:[r||m?_jsx(Text,{style:{color:S.colors["text-body"],fontSize:S.text.base.size,...fontFor(S,"semibold"),lineHeight:20},numberOfLines:2,children:A}):null,"string"==typeof o||m?_jsx(Text,{style:{color:S.colors["text-muted"],fontSize:S.text.sm.size,...fontFor(S,"normal"),lineHeight:18,marginTop:r?S.space.xxs:0},children:D||" "}):_jsx(View,{style:{marginTop:r?S.space.xxs:0},children:o})]}),l?_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:"Dismiss banner",onPress:()=>{const e=resolveHaptic(c,"selection");e&&triggerHaptic(e),a?.()},hitSlop:8,...hitSlopMarker(8),style:({pressed:e})=>[C.closeBtn,{backgroundColor:e?S.colors["surface-pressed"]:"transparent"},f],children:_jsx(Text,{style:{color:S.colors["text-muted"],fontSize:S.text.lg.size,fontWeight:S.weight.bold,lineHeight:17},accessible:!1,children:"×"})}):null]}),i&&i.length>0?_jsx(View,{style:C.actionsRow,children:i.map((e,t)=>{const r=e.tone??"primary",o=e.variant??"ghost",s="danger"===r?S.colors.danger:"neutral"===r?S.colors["text-muted"]:B.glyphColor,n="danger"===r?S.colors["danger-text"]:"neutral"===r?S.colors["text-muted"]:B.ink,i="danger"===r?S.colors["on-danger"]:"neutral"===r?S.colors["on-neutral-strong"]:B.on,l="solid"===o;return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,onPress:()=>{const t=resolveHaptic(c,"selection");t&&triggerHaptic(t),e.onPress()},style:({pressed:t})=>[C.actionBtn,"md"===e.size&&C.actionBtnMd,"outline"===o&&{borderWidth:1,borderColor:n},{backgroundColor:l?s:t?S.colors["surface-pressed"]:"transparent",opacity:l&&t?.85:1},w],children:_jsx(Text,{style:{color:l?i:n,fontSize:S.text.sm.size,textAlign:"center",...fontFor(S,"semibold")},children:e.label})},`${e.label}-${t}`)})}):null]});return m?_jsx(BannerSkeleton,{...e}):L});Banner.displayName="Banner";const BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:o,style:s})=>{const n=useTheme(),i=!1!==r;return _jsxs(View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:n.colors.surface,borderRadius:n.radius.md,...smoothCorners,padding:n.space.md,borderWidth:1,borderColor:n.colors.border},o,s],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[i?_jsx(View,{style:{marginRight:n.space.sm},children:_jsx(Skeleton,{shape:"circle",width:32,height:32})}):null,_jsxs(View,{style:{flex:1},children:[void 0!==e?_jsx(Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:n.space.xs}}):null,_jsx(SkeletonText,{lines:2,fontSize:n.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?_jsx(View,{style:{flexDirection:"row",marginTop:n.space.sm},children:t.map((e,t)=>_jsx(Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:n.space.sm}},`sk-banner-action-${t}`))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton",Banner.Skeleton=BannerSkeleton;const tintFor=(e,t)=>{switch(t){case"success":return{bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};default:return{bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"}}},buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},iconWrap:{marginRight:r},iconCircle:{width:28,height:28,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",marginRight:r},iconGlyph:{fontSize:e.text.base.size,fontWeight:"700",lineHeight:17},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};export{Banner};export default Banner;
@@ -1 +1 @@
1
- "use strict";import{createContext,forwardRef,useCallback,useContext,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Dimensions,Modal,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,runOnJS,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{ModalSafeArea,useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{ToastHost}from"../Toast/ToastProvider.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=forwardRef((e,t)=>{const{snapPoints:o,index:s,onChange:n,onAnimate:r,onAfterClose:a,enablePanDownToClose:l=!0,enableBackdropPress:i=!0,confirmDismiss:u,scrollable:c=!1,scrollRef:d,onScroll:h,onContentSizeChange:m,onScrollLayout:f,scrollEventThrottle:b,keyboardBehavior:p="shift",mode:S="modal",presentation:v="sheet",animateMount:g=!0,handleIndicatorStyle:y,containerStyle:w,header:C,footer:x,headerStyle:M,footerStyle:R,children:k,accessibilityLabel:_,accessibilityViewIsModal:E,testID:I}=e,T=useTheme(),j=usePresenceMotion(),O=useSafeAreaInsets(),[A,D]=useState(()=>Dimensions.get("window").height),[V,P]=useState(()=>Dimensions.get("window").width),H=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&D(e=>e===t?e:t),o>0&&P(e=>e===o?e:o)},[]),B=useWindowDimensions(),N="dialog"===v||"auto"===v&&Math.min(B.width,B.height)>=600,G=Math.min(560,V-2*T.space.xl),[L,F]=useModalInsets(),J="modal"===S?L.top:O.top,z="modal"===S?L.bottom:O.bottom,U=o.includes("content"),[Y,$]=useMeasuredHeight(),[q,W]=useMeasuredHeight(),[K,X,Q]=useMeasuredHeight(),[Z,ee]=useMeasuredHeight(),te=N?T.space.md:Y,oe=U?Math.min(te+(null!=C?q:0)+K+(null!=x?Z:0)+z,A-J):0,se=useCallback((e,t)=>{U&&Q(t),m?.(e,t)},[U,m,Q]),ne=useMemo(()=>resolveSnapPoints(o,A,oe),[o,A,oe]),re=A,ae=ne[ne.length-1]??0,le=useSharedValue(re),ie=useSharedValue(re),ue=useSharedValue(1),ce=useSharedValue(-1),[de,he]=useState(-1),me=useRef(!1),[fe,be]=useState(!1),[pe,Se]=useState(!1),ve=useRef(!1),ge=useRef(a);ge.current=a;const[ye,we]=useState(!1),Ce=useRef(!g&&"number"==typeof s&&s>=0),xe=useRef(-1),Me=useRef(!1);Me.current="modal"===S?pe:ye;const Re=useRef(u);Re.current=u;const ke=useRef(!1),Ee=useRef(!0),Ie=useRef([]),Te=useCallback(e=>{const t=Ie.current;Ie.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Ee.current=!0,()=>{Ee.current=!1,Te(!1)}),[Te]);const je=useCallback(e=>{if(e<0||e>=ne.length)return re;const t=ne[e];return N?(A-t)/2:A-t},[ne,A,re,N]),Oe=useCallback(e=>{xe.current=e;de!==e&&(he(e),ce.value=e,n?.(e))},[de,ce,n]),Ae=useCallback(()=>{me.current=!1,ce.value<0&&(ve.current=!0,"modal"===S?(be(!1),"ios"!==Platform.OS&&Se(!1)):we(!1))},[S,ce]),De=useCallback(()=>{ve.current&&Se(!1)},[]);useEffect(()=>{("modal"===S?!pe:!ye)&&ve.current&&(ve.current=!1,ge.current?.(),Te(!0))},[S,pe,ye,Te]);const Ve=useCallback((e,t,o)=>{me.current=!0,r?.(t,o),le.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(Ae)()})},[r,le,Ae]),Pe=useCallback(e=>{const t="number"==typeof e?clamp(e,0,ne.length-1):de>=0?de:0,o=ce.value,s=je(t);return ve.current=!1,Te(!1),"modal"===S?(Se(!0),be(!0)):we(!0),o<0&&Ce.current?(le.value=s,ue.value=1,Oe(t),void r?.(o,t)):o<0&&j.reduced?(le.value=s,ue.value=0,ue.value=withTiming(1,{duration:j.duration("fast"),easing:Easing.bezier(...T.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Oe(t),void r?.(o,t)):(o<0&&(le.value=re,ue.value=1),Oe(t),void Ve(s,o,t))},[Ve,re,de,ce,S,r,j,ue,ne.length,Oe,Te,T.motion.ease.decelerate,le,je]),He=useCallback(()=>{if(0===ne.length)return;const e=ce.value,t=je(0);Oe(0),Ve(t,e,0)},[Ve,ce,ne.length,Oe,je]),Be=useCallback(()=>new Promise(e=>{if(xe.current<0)return void(Me.current?Ie.current.push(e):e(!0));Ie.current.push(e),Ce.current=!1;const t=ce.value;Oe(-1),me.current=!0,r?.(t,-1);const o=j.reduced?ue:le,s=j.reduced?0:re;o.value=withTiming(s,{duration:j.duration("fast"),easing:Easing.bezier(...T.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&runOnJS(Ae)()})}),[re,ce,Ae,r,j,ue,Oe,le,T.motion.ease.accelerate]),Ne=useCallback(async()=>{await Be()},[Be]),Ge=useCallback((e,t,o)=>{const s=Re.current;if(!s)return void e();if(ke.current)return void t?.();const n=s();"boolean"!=typeof n?(ke.current=!0,o?.(),n.then(o=>{ke.current=!1,o&&Ee.current&&xe.current>=0?e():t?.()},e=>{throw ke.current=!1,e})):(n?e:t)?.()},[]),Le=useCallback(()=>new Promise(e=>{xe.current<0?Be().then(e):Ge(()=>{Be().then(e)},()=>e(!1))}),[Be,Ge]),Fe=useCallback(()=>{i&&Le()},[i,Le]);useImperativeHandle(t,()=>({expand:Pe,collapse:He,close:Ne,requestClose:Le}),[Pe,He,Ne,Le]),useEffect(()=>{"number"==typeof s&&s!==de&&(-1===s?Ne():Pe(s))},[s]);const Je=useRef({hostHeight:A,contentSnap:oe});useEffect(()=>{const e=Je.current;if(e.hostHeight===A&&e.contentSnap===oe)return;if(Je.current={hostHeight:A,contentSnap:oe},e.hostHeight===A&&ce.value<0)return;const t=je(ce.value);le.value=Ce.current?t:withSpring(t,SPRING_CONFIG)},[A,oe]);const ze=A-ae,Ue=useMemo(()=>ne.map(e=>A-e),[ne,A]),Ye=useCallback(()=>{const e=xe.current;e<0||Ve(je(e),e,e)},[Ve,je]),$e=useCallback((e,t)=>{const o=ce.value;-1!==e?(Oe(e),Ve(t,o,e)):Ge(()=>{triggerHaptic("selection"),Ne()},Ye,Ye)},[Ve,Ne,ce,Ge,Oe,Ye]),qe=useMemo(()=>Gesture.Native().withTestId(I?`${I}-content-gesture`:"bottom-sheet-content-gesture"),[I]),We=useMemo(()=>{const e=Ue,t=re,o=ze,s=l;return Gesture.Pan().withTestId(I?`${I}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";ie.value=le.value}).onUpdate(e=>{"worklet";const t=ie.value+e.translationY;le.value=t<o?o+.25*(t-o):t}).onEnd(o=>{"worklet";const n=le.value;if(o.velocityY>1e3)return s?void runOnJS($e)(-1,t):void runOnJS($e)(0,e[0]);let r=0,a=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const o=Math.abs(n-e[t]);o<a&&(a=o,r=t)}const l=e[0];s&&n-l>80?runOnJS($e)(-1,t):runOnJS($e)(r,e[r])})},[re,ie,l,$e,ze,Ue,I,le]),{height:Ke}=useReanimatedKeyboardAnimation(),Xe="shift"===p,Qe=useDerivedValue(()=>Xe?Ke.value:0),Ze=ne[de>=0?de:0]??ae,et=T.space.md,tt=useAnimatedStyle(()=>{if(N){const e=Qe.value,t=A+e-Ze-et,o=e<0&&le.value>t?t:le.value;return{top:o<J?J:o,opacity:ue.value}}const e=le.value+Qe.value,t=Qe.value<0?J:ze;return{top:e<t?t:e,opacity:ue.value}}),ot=useAnimatedStyle(()=>{const e=Qe.value;if(N){const t=A+e-Ze-et,o=e<0&&le.value>t?t:le.value,s=A+e-et-(o<J?J:o);return{height:s<0?0:s>Ze?Ze:s}}const t=e<0?J:ze,o=le.value+e,s=A+e-(o<t?t:o);return{height:s<0?0:s>ae?ae:s}}),st=de>=0,nt=useMemo(()=>buildStyles(T),[T]),rt=useCallback(()=>{i&&Ge(()=>{triggerHaptic("selection"),Ne()})},[i,Ne,Ge]),at=useMemo(()=>Gesture.Tap().withTestId(I?`${I}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&runOnJS(rt)()}),[rt,I]),lt=useMemo(()=>({snapIndex:de,snapPoints:ne,expand:Pe,collapse:He,close:Ne,requestClose:Le}),[de,ne,Pe,He,Ne,Le]);if("inline"===S&&!ye)return null;if("modal"===S&&!pe)return null;const it=_jsxs(View,{collapsable:!1,style:["modal"===S?nt.backdropModal:nt.backdropInline,{backgroundColor:T.colors.scrim}],onLayout:H,testID:I,accessibilityViewIsModal:E??st,children:[_jsx(GestureDetector,{gesture:at,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:"Close bottom sheet"})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:_,accessibilityViewIsModal:E??st,accessibilityActions:[{name:"escape",label:"Close bottom sheet"}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Fe()},onAccessibilityEscape:Fe,style:[nt.sheet,{height:ae,backgroundColor:T.colors.surface,borderTopLeftRadius:T.radius.xl,borderTopRightRadius:T.radius.xl,...smoothCorners,...T.shadow.modal},N?{height:Ze,left:(V-G)/2,right:void 0,width:G,borderBottomLeftRadius:T.radius.xl,borderBottomRightRadius:T.radius.xl}:null,w,tt],children:_jsxs(SheetBody,{style:[nt.body,ot],keyboardOffset:Qe,children:[N?_jsx(View,{style:{height:T.space.md}}):_jsx(GestureDetector,{gesture:We,children:_jsx(View,{style:nt.handleRow,onLayout:U?$:void 0,accessible:!0,accessibilityLabel:"Drag handle",accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:I?`${I}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[nt.handle,{backgroundColor:T.colors.border},y]})})}),null!=C&&_jsx(View,{style:[nt.header,M],onLayout:U?W:void 0,children:C}),c?_jsx(GestureDetector,{gesture:qe,children:_jsx(ScrollView,{ref:d,style:nt.scrollContent,onScroll:h,onContentSizeChange:se,onLayout:f,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:k})}):_jsx(View,{style:U?[nt.content,{overflow:"visible"}]:nt.content,children:U?_jsx(View,{onLayout:X,children:k}):k}),null!=x&&_jsx(View,{style:[nt.footer,R],onLayout:U?ee:void 0,children:x})]})})]}),ut=_jsx(BottomSheetContext.Provider,{value:lt,children:it});return"modal"===S?_jsx(Modal,{transparent:!0,visible:fe,onRequestClose:Fe,onDismiss:"ios"===Platform.OS?De:void 0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",supportedOrientations:["portrait","landscape"],children:_jsxs(ModalSafeArea,{onInsets:F,children:["android"===Platform.OS?_jsx(GestureHandlerRootView,{style:nt.modalRoot,children:ut}):ut,_jsx(ToastHost,{})]})}):ut}),SheetBody=({style:e,keyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,n=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:e>0?e:0}});return _jsx(Animated.View,{style:[e,n],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
1
+ "use strict";import{createContext,forwardRef,useCallback,useContext,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Modal,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,runOnJS,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{ModalSafeArea,useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{ToastHost}from"../Toast/ToastProvider.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=forwardRef((e,t)=>{const{snapPoints:o,index:s,onChange:n,onAnimate:r,onAfterClose:a,enablePanDownToClose:l=!0,enableBackdropPress:i=!0,confirmDismiss:u,scrollable:c=!1,scrollRef:d,onScroll:h,onContentSizeChange:m,onScrollLayout:f,scrollEventThrottle:b,keyboardBehavior:p="shift",mode:S="modal",presentation:v="sheet",animateMount:y=!0,handleIndicatorStyle:g,containerStyle:w,header:C,footer:x,headerStyle:M,footerStyle:R,children:k,accessibilityLabel:_,accessibilityViewIsModal:E,testID:I}=e,T=useTheme(),j=usePresenceMotion(),O=useSafeAreaInsets(),[A,D]=useState(()=>Dimensions.get("window").height),[V,P]=useState(()=>Dimensions.get("window").width),H=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&D(e=>e===t?e:t),o>0&&P(e=>e===o?e:o)},[]),B=useWindowDimensions(),N="dialog"===v||"auto"===v&&Math.min(B.width,B.height)>=600,G=Math.min(560,V-2*T.space.xl),[L,F]=useModalInsets(),J="modal"===S?L.top:O.top,z="modal"===S?L.bottom:O.bottom,K=o.includes("content"),[U,Y]=useMeasuredHeight(),[$,q]=useMeasuredHeight(),[W,X,Q]=useMeasuredHeight(),[Z,ee]=useMeasuredHeight(),te=N?T.space.md:U,oe=K?Math.min(te+(null!=C?$:0)+W+(null!=x?Z:0)+z,A-J):0,se=useCallback((e,t)=>{K&&Q(t),m?.(e,t)},[K,m,Q]),ne=useMemo(()=>resolveSnapPoints(o,A,oe),[o,A,oe]),re=A,ae=ne[ne.length-1]??0,le=useSharedValue(re),ie=useSharedValue(re),ue=useSharedValue(1),ce=useSharedValue(-1),[de,he]=useState(-1),me=useRef(!1),[fe,be]=useState(!1),[pe,Se]=useState(!1),ve=useRef(!1),ye=useRef(a);ye.current=a;const[ge,we]=useState(!1),Ce=useRef(!y&&"number"==typeof s&&s>=0),xe=useRef(-1),Me=useRef(!1);Me.current="modal"===S?pe:ge;const Re=useRef(u);Re.current=u;const ke=useRef(!1),Ee=useRef(!0),Ie=useRef([]),Te=useCallback(e=>{const t=Ie.current;Ie.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Ee.current=!0,()=>{Ee.current=!1,Te(!1)}),[Te]);const je=useCallback(e=>{if(e<0||e>=ne.length)return re;const t=ne[e];return N?(A-t)/2:A-t},[ne,A,re,N]),Oe=useCallback(e=>{xe.current=e;de!==e&&(he(e),ce.value=e,n?.(e))},[de,ce,n]),Ae=useCallback(()=>{me.current=!1,ce.value<0&&(ve.current=!0,"modal"===S?(be(!1),"ios"!==Platform.OS&&Se(!1)):we(!1))},[S,ce]),De=useCallback(()=>{ve.current&&Se(!1)},[]);useEffect(()=>{("modal"===S?!pe:!ge)&&ve.current&&(ve.current=!1,ye.current?.(),Te(!0))},[S,pe,ge,Te]);const Ve=useCallback((e,t,o)=>{me.current=!0,r?.(t,o),le.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(Ae)()})},[r,le,Ae]),Pe=useCallback(e=>{const t="number"==typeof e?clamp(e,0,ne.length-1):de>=0?de:0,o=ce.value,s=je(t);return ve.current=!1,Te(!1),"modal"===S?(Se(!0),be(!0)):we(!0),o<0&&Ce.current?(le.value=s,ue.value=1,Oe(t),void r?.(o,t)):o<0&&j.reduced?(le.value=s,ue.value=0,ue.value=withTiming(1,{duration:j.duration("fast"),easing:Easing.bezier(...T.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Oe(t),void r?.(o,t)):(o<0&&(le.value=re,ue.value=1),Oe(t),void Ve(s,o,t))},[Ve,re,de,ce,S,r,j,ue,ne.length,Oe,Te,T.motion.ease.decelerate,le,je]),He=useCallback(()=>{if(0===ne.length)return;const e=ce.value,t=je(0);Oe(0),Ve(t,e,0)},[Ve,ce,ne.length,Oe,je]),Be=useCallback(()=>new Promise(e=>{if(xe.current<0)return void(Me.current?Ie.current.push(e):e(!0));Ie.current.push(e),Ce.current=!1;const t=ce.value;Oe(-1),me.current=!0,r?.(t,-1);const o=j.reduced?ue:le,s=j.reduced?0:re;o.value=withTiming(s,{duration:j.duration("fast"),easing:Easing.bezier(...T.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&runOnJS(Ae)()})}),[re,ce,Ae,r,j,ue,Oe,le,T.motion.ease.accelerate]),Ne=useCallback(async()=>{await Be()},[Be]),Ge=useCallback((e,t,o)=>{const s=Re.current;if(!s)return void e();if(ke.current)return void t?.();const n=s();"boolean"!=typeof n?(ke.current=!0,o?.(),n.then(o=>{ke.current=!1,o&&Ee.current&&xe.current>=0?e():t?.()},e=>{throw ke.current=!1,e})):(n?e:t)?.()},[]),Le=useCallback(()=>new Promise(e=>{xe.current<0?Be().then(e):Ge(()=>{Be().then(e)},()=>e(!1))}),[Be,Ge]),Fe=useCallback(()=>{i&&Le()},[i,Le]);useImperativeHandle(t,()=>({expand:Pe,collapse:He,close:Ne,requestClose:Le}),[Pe,He,Ne,Le]),useEffect(()=>{"number"==typeof s&&s!==de&&(-1===s?Ne():Pe(s))},[s]);const Je=useRef({hostHeight:A,contentSnap:oe});useEffect(()=>{const e=Je.current;if(e.hostHeight===A&&e.contentSnap===oe)return;if(Je.current={hostHeight:A,contentSnap:oe},e.hostHeight===A&&ce.value<0)return;const t=je(ce.value);le.value=Ce.current?t:withSpring(t,SPRING_CONFIG)},[A,oe]);const ze=A-ae,Ke=useMemo(()=>ne.map(e=>A-e),[ne,A]),Ue=useCallback(()=>{const e=xe.current;e<0||Ve(je(e),e,e)},[Ve,je]),Ye=useCallback((e,t)=>{const o=ce.value;-1!==e?(Oe(e),Ve(t,o,e)):Ge(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Ne()},Ue,Ue)},[Ve,Ne,ce,Ge,Oe,Ue]),$e=useMemo(()=>Gesture.Native().withTestId(I?`${I}-content-gesture`:"bottom-sheet-content-gesture"),[I]),qe=useMemo(()=>{const e=Ke,t=re,o=ze,s=l;return Gesture.Pan().withTestId(I?`${I}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";ie.value=le.value}).onUpdate(e=>{"worklet";const t=ie.value+e.translationY;le.value=t<o?o+.25*(t-o):t}).onEnd(o=>{"worklet";const n=le.value;if(o.velocityY>1e3)return s?void runOnJS(Ye)(-1,t):void runOnJS(Ye)(0,e[0]);let r=0,a=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const o=Math.abs(n-e[t]);o<a&&(a=o,r=t)}const l=e[0];s&&n-l>80?runOnJS(Ye)(-1,t):runOnJS(Ye)(r,e[r])})},[re,ie,l,Ye,ze,Ke,I,le]),{height:We}=useReanimatedKeyboardAnimation(),Xe="shift"===p,Qe=useDerivedValue(()=>Xe?We.value:0),Ze=ne[de>=0?de:0]??ae,et=T.space.md,tt=useAnimatedStyle(()=>{if(N){const e=Qe.value,t=A+e-Ze-et,o=e<0&&le.value>t?t:le.value;return{top:o<J?J:o,opacity:ue.value}}const e=le.value+Qe.value,t=Qe.value<0?J:ze;return{top:e<t?t:e,opacity:ue.value}}),ot=useAnimatedStyle(()=>{const e=Qe.value;if(N){const t=A+e-Ze-et,o=e<0&&le.value>t?t:le.value,s=A+e-et-(o<J?J:o);return{height:s<0?0:s>Ze?Ze:s}}const t=e<0?J:ze,o=le.value+e,s=A+e-(o<t?t:o);return{height:s<0?0:s>ae?ae:s}}),st=de>=0,nt=useMemo(()=>buildStyles(T),[T]),rt=useCallback(()=>{i&&Ge(()=>{triggerHaptic("selection"),Ne()})},[i,Ne,Ge]),at=useMemo(()=>Gesture.Tap().withTestId(I?`${I}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&runOnJS(rt)()}),[rt,I]),lt=useMemo(()=>({snapIndex:de,snapPoints:ne,expand:Pe,collapse:He,close:Ne,requestClose:Le}),[de,ne,Pe,He,Ne,Le]);if("inline"===S&&!ge)return null;if("modal"===S&&!pe)return null;const it=_jsxs(View,{collapsable:!1,style:["modal"===S?nt.backdropModal:nt.backdropInline,{backgroundColor:T.colors.scrim}],onLayout:H,testID:I,accessibilityViewIsModal:E??st,children:[_jsx(GestureDetector,{gesture:at,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:"Close bottom sheet"})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:_,accessibilityViewIsModal:E??st,accessibilityActions:[{name:"escape",label:"Close bottom sheet"}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Fe()},onAccessibilityEscape:Fe,style:[nt.sheet,{height:ae,backgroundColor:T.colors.surface,borderTopLeftRadius:T.radius.xl,borderTopRightRadius:T.radius.xl,...smoothCorners,...T.shadow.modal},N?{height:Ze,left:(V-G)/2,right:void 0,width:G,borderBottomLeftRadius:T.radius.xl,borderBottomRightRadius:T.radius.xl}:null,w,tt],children:_jsxs(SheetBody,{style:[nt.body,ot],keyboardOffset:Qe,children:[N?_jsx(View,{style:{height:T.space.md}}):_jsx(GestureDetector,{gesture:qe,children:_jsx(View,{style:nt.handleRow,onLayout:K?Y:void 0,accessible:!0,accessibilityLabel:"Drag handle",accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:I?`${I}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[nt.handle,{backgroundColor:T.colors.border},g]})})}),null!=C&&_jsx(View,{style:[nt.header,M],onLayout:K?q:void 0,children:C}),c?_jsx(GestureDetector,{gesture:$e,children:_jsx(ScrollView,{ref:d,style:nt.scrollContent,onScroll:h,onContentSizeChange:se,onLayout:f,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:k})}):_jsx(View,{style:K?[nt.content,{overflow:"visible"}]:nt.content,children:K?_jsx(View,{onLayout:X,children:k}):k}),null!=x&&_jsx(View,{style:[nt.footer,R],onLayout:K?ee:void 0,children:x})]})})]}),ut=_jsx(BottomSheetContext.Provider,{value:lt,children:it});return"modal"===S?_jsx(Modal,{transparent:!0,visible:fe,onRequestClose:Fe,onDismiss:"ios"===Platform.OS?De:void 0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",supportedOrientations:["portrait","landscape"],children:_jsxs(ModalSafeArea,{onInsets:F,children:["android"===Platform.OS?_jsx(GestureHandlerRootView,{style:nt.modalRoot,children:ut}):ut,_jsx(ToastHost,{})]})}):ut}),SheetBody=({style:e,keyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,n=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:e>0?e:0}});return _jsx(Animated.View,{style:[e,n],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
@@ -1 +1 @@
1
- "use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,Gradient,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{squircleHostRadius}from"../../utils/squircle.js";import{themeStyles}from"../../utils/themeStyles.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse"],paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=React.memo(forwardRef((e,t)=>{const{children:o,variant:i="elevated",elevation:s="card",radius:r="lg",padding:l="md",interactive:a=!1,bg:n,header:d,title:c,titleFont:u="sans",lead:h,action:m,headerActions:p,collapsible:b=!1,collapsed:g,defaultCollapsed:y=!1,onCollapsedChange:x,collapsedSummary:f,onRemove:S,removeLabel:j="Remove",separatorHeight:v=StyleSheet.hairlineWidth,footer:C,imageSource:_,imageHeight:w=160,imageAspectRatio:R,imageOverlay:A,loading:k=!1,gradient:T,onPress:F,haptic:B,contextMenu:I,accessibilityLabel:H,accessibilityHint:L,accessibilityRole:P,style:V,containerStyle:z,headerStyle:M,bodyStyle:q,footerStyle:O,borderRadius:W,testID:D,onLayout:N,...E}=e,G=useTheme(),K=a||"function"==typeof F,U=useContextMenu(I,{haptic:B||!1,testID:D,accessibilityActions:E.accessibilityActions,onAccessibilityAction:E.onAccessibilityAction}),$=useMemo(()=>mergeRefs(t,U.hostRef),[t,U.hostRef]),J=K||U.enabled,{style:Q,pressIn:X,pressOut:Y}=usePressAnimation({enabled:J}),Z=stylesFor(G),ee=Boolean(_),te=G.space[paddingMap[l]],oe=useMemo(()=>T?"string"==typeof T?G.settings.gradients[T]??null:T:null,[T,G.settings.gradients]),ie="flat"===i,se=ie?G.radius.none:W??G.radius[r],re=resolveBackground(G,n),[le,ae]=useControllableState({value:g,defaultValue:y,onChange:x}),ne=b&&le,de=hasBuiltInHeaderContent(e),ce=Boolean(d)||de,ue=useSquircle(!ee&&!oe&&!ie,se,N),he=StyleSheet.flatten([V,z])??{},me=he.backgroundColor,pe=he.borderColor,be=me??re??("filled"===i?G.colors["bg-subtle"]:G.colors.surface),ge="outlined"===i?G.size.border:0,ye=pe??G.colors.border,xe="none"===s?void 0:G.shadow[s],fe="elevated"===i&&supportsBoxShadow()&&xe?toBoxShadow(xe):void 0,Se=ue.active&&"elevated"===i&&!fe,je=ue.active&&!Se?{backgroundColor:"transparent",borderColor:"transparent"}:null,ve=useMemo(()=>{const e={borderRadius:Se&&ue.size?squircleHostRadius(ue.size.width,ue.size.height,se):se,...smoothCorners,padding:ee?G.space.none:te,overflow:ue.active?"visible":"hidden"};switch(i){case"flat":return{...e,backgroundColor:re??G.colors.surface,borderBottomWidth:v,borderBottomColor:G.colors.border};case"outlined":return{...e,backgroundColor:ue.active?"transparent":re??G.colors.surface,borderWidth:G.size.border,borderColor:ue.active?"transparent":G.colors.border};case"filled":return{...e,backgroundColor:ue.active?"transparent":re??G.colors["bg-subtle"]};default:return{...e,backgroundColor:re??G.colors.surface,...fe?{boxShadow:fe}:xe}}},[G,i,xe,se,ee,te,ue.active,ue.size,fe,Se,re,v]),Ce=useMemo(()=>({..."number"==typeof R?{width:"100%",aspectRatio:R}:{width:"100%",height:w},borderTopLeftRadius:se,borderTopRightRadius:se,borderBottomLeftRadius:G.radius.none,borderBottomRightRadius:G.radius.none,...smoothCorners}),[G,se,R,w]),we="string"==typeof c?c:"",Re=_jsxs(_Fragment,{children:[_jsxs(View,{style:Z.titleColumn,children:["string"==typeof c?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(G,u),children:c}):c,h?_jsx(Text,{variant:"bodySmall",style:Z.lead,children:h}):null,ne&&f?_jsx(Text,{variant:"caption",style:Z.lead,children:f}):null]}),isCardTextAction(m)?_jsx(CardTextActionButton,{action:m,haptic:B}):m?_jsx(View,{style:Z.actionNode,children:m}):null,p,b?_jsx(CardIconAction,{icon:ne?"chevron-down":"chevron-up",label:`${ne?"Show":"Hide"} ${we}`.trim(),expanded:!ne,onPress:()=>ae(!ne),haptic:B}):null,S?_jsx(CardIconAction,{icon:"trash",label:j,onPress:S,color:G.colors["danger-text"],haptic:B}):null]}),Ae=_jsxs(_Fragment,{children:[ce?_jsx(View,{style:[Z.header,!d&&Z.headerRow,ne&&Z.headerFolded,M],children:d??Re}):null,ne?null:_jsx(View,{style:[ce||C?Z.body:null,q],children:o}),C&&!ne?_jsx(View,{style:[Z.footer,O],children:C}):null]}),ke=ee?_jsxs(_Fragment,{children:[_jsxs(View,{style:Z.imageWrapper,children:[_jsx(Image,{source:_,resizeMode:"cover",style:Ce,accessibilityLabel:"",accessible:!1}),A?_jsx(View,{pointerEvents:"box-none",style:Z.imageOverlay,children:A}):null]}),_jsx(View,{style:{padding:te},children:Ae})]}):Ae,Te=oe?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:oe,style:StyleSheet.absoluteFill}),ke]}):ue.active&&ue.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:ue.size.width,height:ue.size.height,radius:se,fill:be,stroke:ge?ye:void 0,strokeWidth:ge,outset:ge}),ke]}):ke;let Fe;if(J){const handlePress=e=>{K&&(B&&triggerHaptic(B),F?.(e))};Fe=_jsx(Animated.View,{style:Q,children:_jsx(Pressable,{ref:$,onPress:handlePress,onPressIn:X,onPressOut:Y,android_ripple:{color:G.colors["surface-pressed"],borderless:!1},accessibilityRole:P??(K?"button":void 0),accessibilityLabel:H,accessibilityHint:L,testID:D,onLayout:ue.onLayout,style:[ve,V,z,je],...E,...U.hostProps,children:Te})})}else Fe=_jsx(View,{ref:t,accessibilityLabel:H,accessibilityHint:L,accessibilityRole:P,testID:D,onLayout:ue.onLayout,style:[ve,V,z,je],...E,children:Te});return k?_jsx(CardSkeleton,{...e}):U.enabled?_jsxs(_Fragment,{children:[Fe,U.renderSurface(_jsx(View,{style:[ve,V,z,je,Z.preview],children:Te}))]}):Fe}));Card.displayName="Card";const CardSkeleton=({variant:e="elevated",elevation:t,radius:o="lg",padding:i="md",bg:s,header:r,footer:l,imageSource:a,imageHeight:n=160,imageAspectRatio:d,borderRadius:c,containerStyle:u,headerStyle:h,bodyStyle:m,footerStyle:p,style:b,...g})=>{const y=useTheme(),x=paddingMap[i],f=y.space[x],S="flat"===e?y.radius.none:c??y.radius[o],j=void 0!==r||hasBuiltInHeaderContent(g),v=resolveBackground(y,s)??y.colors.surface,C="outlined"===e?1:0,_="outlined"===e?y.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:v,borderRadius:S,...smoothCorners,borderWidth:C,borderColor:_,overflow:"hidden"},u,b],accessibilityRole:"progressbar",accessibilityLabel:"Loading",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==a?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,j?_jsx(View,{style:[{padding:f,paddingBottom:y.space.sm},h],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:f},m],children:_jsx(SkeletonText,{lines:3,fontSize:y.text.base.size,lastLineWidth:"55%"})}),void 0!==l?_jsx(View,{style:[{padding:f,paddingTop:y.space.sm,flexDirection:"row"},p],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:o,expanded:i,color:s,haptic:r})=>{const l=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===i?void 0:{expanded:i},"aria-expanded":i,onPress:()=>{r&&triggerHaptic(r),o()},style:iconActionStyle,children:_jsx(AppIcon,{name:e,size:20,color:s??l.colors["text-body"]})})},CardTextActionButton=({action:e,haptic:t})=>{const o=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&triggerHaptic(t),e.onPress()},style:textActionStyle,children:_jsx(Text,{variant:"label",weight:"semibold",color:o.colors.primary,children:e.label})})},iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?fontFor(e,"semibold","display"):{fontFamily:void 0,...fontFor(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=themeStyles(buildStyles);export{Card};export default Card;
1
+ "use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,Gradient,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{squircleHostRadius}from"../../utils/squircle.js";import{themeStyles}from"../../utils/themeStyles.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse"],paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=React.memo(forwardRef((e,t)=>{const{children:o,variant:i="elevated",elevation:s="card",radius:r="lg",padding:l="md",interactive:a=!1,bg:n,header:d,title:c,titleFont:u="sans",lead:h,action:m,headerActions:p,collapsible:b=!1,collapsed:g,defaultCollapsed:y=!1,onCollapsedChange:x,collapsedSummary:f,onRemove:S,removeLabel:j="Remove",separatorHeight:v=StyleSheet.hairlineWidth,footer:C,imageSource:_,imageHeight:w=160,imageAspectRatio:R,imageOverlay:A,loading:k=!1,gradient:T,onPress:F,haptic:B,contextMenu:I,accessibilityLabel:H,accessibilityHint:V,accessibilityRole:L,style:P,containerStyle:z,headerStyle:M,bodyStyle:q,footerStyle:O,borderRadius:W,testID:D,onLayout:N,...E}=e,G=useTheme(),K=a||"function"==typeof F,U=useContextMenu(I,{haptic:B||!1,testID:D,accessibilityActions:E.accessibilityActions,onAccessibilityAction:E.onAccessibilityAction}),$=useMemo(()=>mergeRefs(t,U.hostRef),[t,U.hostRef]),J=K||U.enabled,{style:Q,pressIn:X,pressOut:Y}=usePressAnimation({enabled:J}),Z=stylesFor(G),ee=Boolean(_),te=G.space[paddingMap[l]],oe=useMemo(()=>T?"string"==typeof T?G.settings.gradients[T]??null:T:null,[T,G.settings.gradients]),ie="flat"===i,se=ie?G.radius.none:W??G.radius[r],re=resolveBackground(G,n),[le,ae]=useControllableState({value:g,defaultValue:y,onChange:x}),ne=b&&le,de=hasBuiltInHeaderContent(e),ce=Boolean(d)||de,ue=useSquircle(!ee&&!oe&&!ie,se,N),he=StyleSheet.flatten([P,z])??{},me=he.backgroundColor,pe=he.borderColor,be=me??re??("filled"===i?G.colors["bg-subtle"]:G.colors.surface),ge="outlined"===i?G.size.border:0,ye=pe??G.colors.border,xe="none"===s?void 0:G.shadow[s],fe="elevated"===i&&supportsBoxShadow()&&xe?toBoxShadow(xe):void 0,Se=ue.active&&"elevated"===i&&!fe,je=ue.active&&!Se?{backgroundColor:"transparent",borderColor:"transparent"}:null,ve=useMemo(()=>{const e={borderRadius:Se&&ue.size?squircleHostRadius(ue.size.width,ue.size.height,se):se,...smoothCorners,padding:ee||ue.active?G.space.none:te,overflow:ue.active?"visible":"hidden"};switch(i){case"flat":return{...e,backgroundColor:re??G.colors.surface,borderBottomWidth:v,borderBottomColor:G.colors.border};case"outlined":return{...e,backgroundColor:ue.active?"transparent":re??G.colors.surface,borderWidth:G.size.border,borderColor:ue.active?"transparent":G.colors.border};case"filled":return{...e,backgroundColor:ue.active?"transparent":re??G.colors["bg-subtle"]};default:return{...e,backgroundColor:re??G.colors.surface,...fe?{boxShadow:fe}:xe}}},[G,i,xe,se,ee,te,ue.active,ue.size,fe,Se,re,v]),Ce=useMemo(()=>({..."number"==typeof R?{width:"100%",aspectRatio:R}:{width:"100%",height:w},borderTopLeftRadius:se,borderTopRightRadius:se,borderBottomLeftRadius:G.radius.none,borderBottomRightRadius:G.radius.none,...smoothCorners}),[G,se,R,w]),we="string"==typeof c?c:"",Re=_jsxs(_Fragment,{children:[_jsxs(View,{style:Z.titleColumn,children:["string"==typeof c?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(G,u),children:c}):c,h?_jsx(Text,{variant:"bodySmall",style:Z.lead,children:h}):null,ne&&f?_jsx(Text,{variant:"caption",style:Z.lead,children:f}):null]}),isCardTextAction(m)?_jsx(CardTextActionButton,{action:m,haptic:B}):m?_jsx(View,{style:Z.actionNode,children:m}):null,p,b?_jsx(CardIconAction,{icon:ne?"chevron-down":"chevron-up",label:`${ne?"Show":"Hide"} ${we}`.trim(),expanded:!ne,onPress:()=>ae(!ne),haptic:B}):null,S?_jsx(CardIconAction,{icon:"trash",label:j,onPress:S,color:G.colors["danger-text"],haptic:B}):null]}),Ae=_jsxs(_Fragment,{children:[ce?_jsx(View,{style:[Z.header,!d&&Z.headerRow,ne&&Z.headerFolded,M],children:d??Re}):null,ne?null:_jsx(View,{style:[ce||C?Z.body:null,q],children:o}),C&&!ne?_jsx(View,{style:[Z.footer,O],children:C}):null]}),ke=ee?_jsxs(_Fragment,{children:[_jsxs(View,{style:Z.imageWrapper,children:[_jsx(Image,{source:_,resizeMode:"cover",style:Ce,accessibilityLabel:"",accessible:!1}),A?_jsx(View,{pointerEvents:"box-none",style:Z.imageOverlay,children:A}):null]}),_jsx(View,{style:{padding:te},children:Ae})]}):Ae,Te=oe?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:oe,style:StyleSheet.absoluteFill}),ke]}):ue.active&&ue.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:ue.size.width,height:ue.size.height,radius:se,fill:be,stroke:ge?ye:void 0,strokeWidth:ge,outset:ge}),_jsx(View,{style:[Z.squircleClip,{padding:te,borderRadius:ue.size?squircleHostRadius(ue.size.width,ue.size.height,se):se}],children:ke})]}):ke;let Fe;if(J){const handlePress=e=>{K&&(B&&triggerHaptic(B),F?.(e))};Fe=_jsx(Animated.View,{style:Q,children:_jsx(Pressable,{ref:$,onPress:handlePress,onPressIn:X,onPressOut:Y,accessibilityRole:L??(K?"button":void 0),accessibilityLabel:H,accessibilityHint:V,testID:D,onLayout:ue.onLayout,style:[ve,P,z,je],...E,...U.hostProps,children:Te})})}else Fe=_jsx(View,{ref:t,accessibilityLabel:H,accessibilityHint:V,accessibilityRole:L,testID:D,onLayout:ue.onLayout,style:[ve,P,z,je],...E,children:Te});return k?_jsx(CardSkeleton,{...e}):U.enabled?_jsxs(_Fragment,{children:[Fe,U.renderSurface(_jsx(View,{style:[ve,P,z,je,Z.preview],children:Te}))]}):Fe}));Card.displayName="Card";const CardSkeleton=({variant:e="elevated",elevation:t,radius:o="lg",padding:i="md",bg:s,header:r,footer:l,imageSource:a,imageHeight:n=160,imageAspectRatio:d,borderRadius:c,containerStyle:u,headerStyle:h,bodyStyle:m,footerStyle:p,style:b,...g})=>{const y=useTheme(),x=paddingMap[i],f=y.space[x],S="flat"===e?y.radius.none:c??y.radius[o],j=void 0!==r||hasBuiltInHeaderContent(g),v=resolveBackground(y,s)??y.colors.surface,C="outlined"===e?1:0,_="outlined"===e?y.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:v,borderRadius:S,...smoothCorners,borderWidth:C,borderColor:_,overflow:"hidden"},u,b],accessibilityRole:"progressbar",accessibilityLabel:"Loading",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==a?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,j?_jsx(View,{style:[{padding:f,paddingBottom:y.space.sm},h],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:f},m],children:_jsx(SkeletonText,{lines:3,fontSize:y.text.base.size,lastLineWidth:"55%"})}),void 0!==l?_jsx(View,{style:[{padding:f,paddingTop:y.space.sm,flexDirection:"row"},p],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:o,expanded:i,color:s,haptic:r})=>{const l=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===i?void 0:{expanded:i},"aria-expanded":i,onPress:()=>{r&&triggerHaptic(r),o()},style:iconActionStyle,children:_jsx(AppIcon,{name:e,size:20,color:s??l.colors["text-body"]})})},CardTextActionButton=({action:e,haptic:t})=>{const o=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&triggerHaptic(t),e.onPress()},style:textActionStyle,children:_jsx(Text,{variant:"label",weight:"semibold",color:o.colors.primary,children:e.label})})},iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?fontFor(e,"semibold","display"):{fontFamily:void 0,...fontFor(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",...smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=themeStyles(buildStyles);export{Card};export default Card;
@@ -1 +1 @@
1
- "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Animated,Easing,Modal,Pressable,StyleSheet,Text,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{ModalSafeArea,useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{PickerTrigger}from"../PickerTrigger/index.js";import{ToastHost}from"../Toast/ToastProvider.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const NAV_BUTTON_SIZE=36,AnimatedGestureRoot=Animated.createAnimatedComponent(GestureHandlerRootView),GRID_SIZE=12,DECADE_SPAN=10,startOfDay=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),isSameDay=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),toIso=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,addMonths=(e,t)=>new Date(e.getFullYear(),e.getMonth()+t,1),buildMonthMatrix=(e,t)=>{const a=e.getFullYear(),r=e.getMonth(),s=(new Date(a,r,1).getDay()-t+7)%7,i=[];for(let e=0;e<42;e+=1){const t=new Date(a,r,1-s+e);i.push({date:t,inMonth:t.getMonth()===r,iso:toIso(t)})}return i},weekdayLabels=(e,t)=>{const a=new Intl.DateTimeFormat(e,{weekday:"short"}),r=[];for(let e=0;e<7;e+=1){const s=new Date(1970,0,4+(t+e)%7);r.push(a.format(s))}return r},formatMonthYear=(e,t)=>new Intl.DateTimeFormat(t,{month:"long",year:"numeric"}).format(e),decadeStartFor=e=>10*Math.floor(e/10),buildYearCells=e=>{const t=e-4;return Array.from({length:12},(e,a)=>t+a)},buildDecadeCells=e=>{const t=decadeStartFor(e)-40;return Array.from({length:12},(e,a)=>t+10*a)},DatePicker=e=>{const{value:t,onChange:a,onClose:r,minDate:s,maxDate:i,disabledDates:o,mode:n="modal",locale:l="en-IN",weekStartsOn:c=0,title:d="Select Date",confirmLabel:u="Confirm",cancelLabel:m="Cancel",style:g,containerStyle:y,headerLabelStyle:h,navButtonStyle:p,footerButtonStyle:b,haptic:f,testID:x,label:w,placeholder:D,helperText:v,error:C,required:j,disabled:S,size:A,variant:V,clearable:T,onClear:_,formatValue:M,triggerStyle:R}=e,k=void 0!==e.visible,[I,P]=useState(!1),F=k?e.visible:I,N=k?x:x?`${x}-calendar`:void 0,Y=useTheme(),L=usePresenceMotion(),[z,B]=useModalInsets(),$=useMemo(()=>buildStyles(Y),[Y]),[E,H]=useState(()=>startOfDay(new Date));useEffect(()=>{F&&H(startOfDay(new Date))},[F]);const O=t?startOfDay(t):E,[W,G]=useState(O),[q,X]=useState(t?startOfDay(t):null),[Z,U]=useState("days"),J=useRef(createAnimatedValue(0)).current,K=useRef(createAnimatedValue(0)).current,Q=useRef(createAnimatedValue(0)).current,ee=useRef(0),te=useRef(createAnimatedValue(0)).current,ae=useRef(createAnimatedValue(1)).current,re=useRef(createAnimatedValue(1)).current,se=useRef(createAnimatedValue(1)).current,ie=useRef(createAnimatedValue(1)).current,oe=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(t){const e=startOfDay(t);X(e),G(e)}else X(null)},[t]);const ne=useMemo(()=>{const e=new Set;return o?.forEach(t=>e.add(toIso(startOfDay(t)))),e},[o]),le=useMemo(()=>s?startOfDay(s):null,[s]),ce=useMemo(()=>i?startOfDay(i):null,[i]),de=useCallback(e=>!!(le&&e.getTime()<le.getTime())||(!!(ce&&e.getTime()>ce.getTime())||!!ne.has(toIso(e))),[le,ce,ne]),ue=useMemo(()=>buildMonthMatrix(W,c),[W,c]),me=useMemo(()=>buildYearCells(W.getFullYear()),[W]),ge=useMemo(()=>buildDecadeCells(W.getFullYear()),[W]),ye=useMemo(()=>weekdayLabels(l,c),[l,c]),he=useMemo(()=>new Intl.DateTimeFormat(l,{weekday:"long",year:"numeric",month:"long",day:"numeric"}),[l]),pe=useMemo(()=>{if("days"===Z)return formatMonthYear(W,l);if("years"===Z){return`${me[0]} - ${me[me.length-1]}`}return`${ge[0]} - ${ge[ge.length-1]+9}`},[W,ge,l,Z,me]),be=useCallback(e=>!!(le&&e<le.getFullYear())||!!(ce&&e>ce.getFullYear()),[le,ce]),fe=useCallback(e=>!!(le&&e+10-1<le.getFullYear())||!!(ce&&e>ce.getFullYear()),[le,ce]),xe=useCallback(e=>{!1!==f&&triggerHaptic("impactLight");const t=e>0?1:-1,a=Y.motion.duration.fast,r=Y.motion.duration.fast,[s]=L.range(32*-t,0),[i]=L.range(32*t,0),o=L.reduced?L.duration("fast"):a,n=L.reduced?L.duration("fast"):r;Animated.sequence([Animated.parallel([Animated.timing(te,{toValue:s,duration:a,easing:Easing.out(Easing.quad),useNativeDriver:!0}),Animated.timing(ae,{toValue:0,duration:o,useNativeDriver:!0})]),Animated.timing(te,{toValue:i,duration:0,useNativeDriver:!0}),Animated.parallel([Animated.timing(te,{toValue:0,duration:r,easing:Easing.out(Easing.cubic),useNativeDriver:!0}),Animated.timing(ae,{toValue:1,duration:n,useNativeDriver:!0})])]).start();const c=addMonths(W,e);G(c),AccessibilityInfo.announceForAccessibility(formatMonthYear(c,l))},[W,f,l,ae,te,L,Y.motion.duration.fast]),we=useCallback(()=>{"days"!==Z?(!1!==f&&triggerHaptic("impactLight"),G("years"===Z?e=>new Date(e.getFullYear()-12,e.getMonth(),1):e=>new Date(e.getFullYear()-120,e.getMonth(),1))):xe(-1)},[xe,Z,f]),De=useCallback(()=>{"days"!==Z?(!1!==f&&triggerHaptic("impactLight"),G("years"===Z?e=>new Date(e.getFullYear()+12,e.getMonth(),1):e=>new Date(e.getFullYear()+120,e.getMonth(),1))):xe(1)},[xe,Z,f]),ve=useCallback(()=>{const[e]=L.range(.9,1),t=L.reduced?L.duration("default"):Y.motion.duration.default;setNativeValue(se,0),setNativeValue(ie,e),Animated.parallel([Animated.timing(se,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:!0}),Animated.timing(ie,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:!0})]).start()},[se,ie,L,Y.motion.duration.default]),Ce=useCallback(()=>{const e=resolveHaptic(f,"selection");if(e&&triggerHaptic(e),!L.reduced){const e=80,t=100;Animated.sequence([Animated.timing(oe,{toValue:.96,duration:e,useNativeDriver:!0}),Animated.timing(oe,{toValue:1,duration:t,useNativeDriver:!0})]).start()}U(e=>"days"===e?"years":"years"===e?"decades":"years"),ve()},[ve,oe,f,L.reduced]),je=useCallback(e=>{const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),G(t=>new Date(e,t.getMonth(),1)),U("days"),ve()},[ve,f]),Se=useCallback(e=>{const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),G(t=>new Date(e+4,t.getMonth(),1)),U("years"),ve()},[ve,f]),Ae=useCallback(e=>{if(de(e.date))return;const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),X(e.date),e.inMonth||G(new Date(e.date.getFullYear(),e.date.getMonth(),1)),L.reduced||(setNativeValue(re,.7),Animated.spring(re,{toValue:1,damping:Y.motion.spring.bouncy.damping,stiffness:Y.motion.spring.bouncy.stiffness,mass:Y.motion.spring.bouncy.mass,useNativeDriver:!0}).start())},[de,L.reduced,re,Y.motion.spring.bouncy,f]),Ve=useCallback(()=>{k||P(!1),r?.()},[k,r]),Te=useCallback(()=>{"modal"===n?Animated.parallel([Animated.timing(J,{toValue:0,duration:L.duration("default"),easing:Easing.bezier(...Y.motion.ease.accelerate),useNativeDriver:!1}),Animated.timing(K,{toValue:0,duration:L.duration("fast"),easing:Easing.bezier(...Y.motion.ease.accelerate),useNativeDriver:!0})]).start(()=>{Ve()}):Ve()},[J,n,Ve,L,K,Y.motion.ease.accelerate]),{handleGesture:Me,opacity:Re}=useDragToDismiss({drag:Q,travel:()=>ee.current||320,onDismiss:Te}),ke=useMemo(()=>Animated.multiply(K,Re),[K,Re]),Ie=useMemo(()=>J.interpolate({inputRange:[0,1],outputRange:[transparentOf(Y.colors.scrim),Y.colors.scrim]}),[J,Y.colors.scrim]);useEffect(()=>{if("modal"===n&&F){J.setValue(0),setNativeValue(K,0),setNativeValue(Q,0),setNativeValue(Re,1);const e=L.reduced?Animated.timing(K,{toValue:1,duration:L.duration("default"),useNativeDriver:!0}):Animated.spring(K,{toValue:1,damping:Y.motion.spring.gentle.damping,stiffness:Y.motion.spring.gentle.stiffness,mass:Y.motion.spring.gentle.mass,useNativeDriver:!0}),t=Animated.parallel([Animated.timing(J,{toValue:1,duration:L.duration("default"),easing:Easing.out(Easing.cubic),useNativeDriver:!1}),e]);return t.start(),()=>t.stop()}},[F,n,J,L,K,Q,Re,Y.motion]);const Pe=useCallback(()=>{!1!==f&&triggerHaptic("selection"),Te()},[Te,f]),Fe=useCallback(()=>{q&&(!1!==f&&triggerHaptic("notificationSuccess"),a?.(q),Te())},[Te,a,q,f]),Ne=K.interpolate({inputRange:[0,1],outputRange:L.range(320,0)}),Ye=_jsx(View,{style:$.titleRow,children:_jsx(Text,{style:$.title,accessibilityRole:"header",children:d})}),Le=_jsxs(View,{style:[$.card,g,y],accessibilityRole:"modal"===n?void 0:"none",accessible:!1,testID:N,children:["modal"===n?_jsx(GestureDetector,{gesture:Me,children:_jsxs(View,{style:$.grabArea,children:[_jsx(View,{style:$.handle}),Ye]})}):Ye,_jsxs(View,{style:$.headerRow,children:[_jsx(Pressable,{onPress:we,style:({pressed:e})=>[$.navBtn,e&&$.navBtnPressed,p],accessibilityRole:"button",accessibilityLabel:"days"===Z?"Previous month":"years"===Z?"Previous years":"Previous decades",hitSlop:8,...hitSlopMarker(8),children:_jsx(Text,{style:$.navText,children:"‹"})}),_jsx(Pressable,{onPress:Ce,style:[$.headerLabelWrap,h],accessibilityRole:"button",accessibilityLabel:"days"===Z?`${pe}, switch to year selection`:"years"===Z?`${pe}, switch to decade selection`:`${pe}, switch to year selection`,hitSlop:8,...hitSlopMarker(8),children:_jsxs(Animated.View,{style:[$.headerLabelInner,{transform:[{scale:oe}],opacity:"days"===Z?ae:1}],children:[_jsx(Animated.Text,{style:[$.headerLabel,{transform:[{translateX:"days"===Z?te:0}]}],accessibilityLiveRegion:"polite",children:pe}),_jsx(View,{style:$.headerCaret,children:(Y.settings.icons.chevronDown??defaultIcons.chevronDown)({size:Y.text.sm.size,color:Y.colors["text-muted"]})})]})}),_jsx(Pressable,{onPress:De,style:({pressed:e})=>[$.navBtn,e&&$.navBtnPressed,p],accessibilityRole:"button",accessibilityLabel:"days"===Z?"Next month":"years"===Z?"Next years":"Next decades",hitSlop:8,...hitSlopMarker(8),children:_jsx(Text,{style:$.navText,children:"›"})})]}),"days"===Z?_jsxs(_Fragment,{children:[_jsx(View,{style:$.weekdayRow,children:ye.map((e,t)=>_jsx(View,{style:$.weekdayCell,children:_jsx(Text,{style:$.weekdayText,children:e})},`${e}-${t}`))}),_jsx(Animated.View,{style:[$.grid,{opacity:ae,transform:[{translateX:te}]}],children:Array.from({length:6}).map((e,t)=>_jsx(View,{style:$.gridRow,children:ue.slice(7*t,7*t+7).map(e=>{const t=de(e.date),a=!!q&&isSameDay(e.date,q),r=isSameDay(e.date,E),s=a?Y.colors.primary:"transparent",i=r&&!a?Y.colors.primary:"transparent",o=a?Y.colors["on-primary"]:e.inMonth?t?Y.colors["text-disabled"]:Y.colors["text-body"]:Y.colors["text-subtle"],n=t?.3:e.inMonth?1:.4;return _jsx(Pressable,{disabled:t,onPress:()=>Ae(e),accessibilityRole:"button",accessibilityLabel:he.format(e.date),accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:$.dayCell,children:_jsx(Animated.View,{style:[$.dayInner,{backgroundColor:s,borderColor:i,borderWidth:r&&!a?1.5:0,opacity:n},a?{transform:[{scale:re}]}:null],children:_jsx(Text,{style:[$.dayText,{color:o}],children:e.date.getDate()})})},e.iso)})},`r-${t}`))})]}):_jsx(Animated.View,"years"===Z?{style:[$.yearGrid,{opacity:se,transform:[{scale:ie}]}],children:Array.from({length:3}).map((e,t)=>_jsx(View,{style:$.gridRow,children:me.slice(4*t,4*t+4).map(e=>{const t=be(e),a=!!q&&q.getFullYear()===e,r=E.getFullYear()===e,s=a?Y.colors.primary:"transparent",i=r&&!a?Y.colors.primary:"transparent",o=a?Y.colors["on-primary"]:t?Y.colors["text-disabled"]:Y.colors["text-body"],n=t?.3:1;return _jsx(Pressable,{disabled:t,onPress:()=>je(e),accessibilityRole:"button",accessibilityLabel:`Year ${e}`,accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:$.yearCell,children:_jsx(View,{style:[$.yearInner,{backgroundColor:s,borderColor:i,borderWidth:r&&!a?1.5:0,opacity:n}],children:_jsx(Text,{style:[$.yearText,{color:o}],children:e})})},`year-${e}`)})},`yr-${t}`))}:{style:[$.yearGrid,{opacity:se,transform:[{scale:ie}]}],children:Array.from({length:3}).map((e,t)=>_jsx(View,{style:$.gridRow,children:ge.slice(4*t,4*t+4).map(e=>{const t=e+10-1,a=fe(e),r=!!q&&decadeStartFor(q.getFullYear())===e,s=decadeStartFor(E.getFullYear())===e,i=r?Y.colors.primary:"transparent",o=s&&!r?Y.colors.primary:"transparent",n=r?Y.colors["on-primary"]:a?Y.colors["text-disabled"]:Y.colors["text-body"],l=a?.3:1;return _jsx(Pressable,{disabled:a,onPress:()=>Se(e),accessibilityRole:"button",accessibilityLabel:`Decade ${e} to ${t}`,accessibilityState:{selected:r,disabled:a},"aria-selected":r,"aria-disabled":a,style:$.yearCell,children:_jsxs(View,{style:[$.yearInner,{backgroundColor:i,borderColor:o,borderWidth:s&&!r?1.5:0,opacity:l}],children:[_jsx(Text,{style:[$.yearText,{color:n}],children:`${e}s`}),_jsx(Text,{style:[$.decadeRangeText,{color:r?Y.colors["on-primary"]:Y.colors["text-subtle"]}],children:`${e}-${t}`})]})},`decade-${e}`)})},`dec-${t}`))}),_jsxs(View,{style:$.footer,children:[_jsx(Pressable,{onPress:Pe,style:({pressed:e})=>[$.footerBtn,$.footerCancel,e&&$.footerBtnPressed,b],accessibilityRole:"button",accessibilityLabel:m,children:_jsx(Text,{style:[$.footerBtnText,{color:Y.colors["text-muted"]}],children:m})}),_jsx(Pressable,{onPress:Fe,disabled:!q,style:({pressed:e})=>[$.footerBtn,$.footerConfirm,{backgroundColor:Y.colors.primary,opacity:q?1:.5},e&&{backgroundColor:Y.colors["primary-hover"]},b],accessibilityRole:"button",accessibilityLabel:u,accessibilityState:{disabled:!q},"aria-disabled":!q,children:_jsx(Text,{style:[$.footerBtnText,{color:Y.colors["on-primary"]}],children:u})})]})]}),ze=t?(M??(e=>e.toLocaleDateString()))(t):void 0,Be=!k;if("inline"===n)return F||Be?Be?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{label:w,value:ze,placeholder:D,helperText:v,error:C,required:j,disabled:S,size:A,variant:V,clearable:T,onClear:_,onPress:()=>P(!0),triggerStyle:R,testID:x}),F?Le:null]}):Le:null;const $e=_jsx(Modal,{visible:F,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:Te,children:_jsx(ModalSafeArea,{onInsets:B,children:_jsxs(AnimatedGestureRoot,{collapsable:!1,style:[$.backdrop,{backgroundColor:Ie}],children:[_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:Te,accessibilityLabel:"Dismiss"}),_jsx(Animated.View,{style:[$.sheetWrap,{paddingBottom:Math.max(z.bottom,Y.space.lg),opacity:ke,transform:[{translateY:Animated.add(Ne,Q)}]}],onLayout:e=>{ee.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:Le}),_jsx(ToastHost,{})]})})});return Be?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{label:w,value:ze,placeholder:D,helperText:v,error:C,required:j,disabled:S,size:A,variant:V,clearable:T,onClear:_,onPress:()=>P(!0),triggerStyle:R,testID:x}),$e]}):$e},buildStyles=e=>{const t=e.shadow.popover;return StyleSheet.create({backdrop:{...StyleSheet.absoluteFill},sheetWrap:{position:"absolute",left:0,right:0,bottom:0,paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,...smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,...smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:e.space.md},navBtn:{width:36,height:36,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"]},navBtnPressed:{backgroundColor:e.colors["surface-pressed"]},navText:{fontSize:e.text["2xl"].size,lineHeight:26,color:e.colors["text-body"],fontWeight:e.weight.semibold},headerLabelWrap:{flex:1,alignItems:"center"},headerLabelInner:{flexDirection:"row",alignItems:"center",justifyContent:"center"},headerLabel:{fontSize:e.text.base.size,fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerCaret:{marginLeft:e.space.xs,alignItems:"center",justifyContent:"center"},weekdayRow:{flexDirection:"row",marginBottom:e.space.xs},weekdayCell:{flex:1,alignItems:"center",paddingVertical:e.space.xs},weekdayText:{fontSize:e.text.xs.size,fontWeight:e.weight.medium,color:e.colors["text-subtle"],letterSpacing:e["letter-spacing"].wide},grid:{},gridRow:{flexDirection:"row"},dayCell:{flex:1,aspectRatio:1,alignItems:"center",justifyContent:"center",padding:e.space.xxs},dayInner:{width:"100%",height:"100%",borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center"},dayText:{fontSize:e.text.sm.size,fontWeight:e.weight.medium},yearGrid:{},yearCell:{flex:1,aspectRatio:1.6,alignItems:"center",justifyContent:"center",padding:e.space.xs},yearInner:{width:"100%",height:"100%",borderRadius:e.radius.lg,...smoothCorners,alignItems:"center",justifyContent:"center"},yearText:{fontSize:e.text.base.size,fontWeight:e.weight.semibold},decadeRangeText:{fontSize:e.text.xs.size,fontWeight:e.weight.medium,marginTop:e.space.xxs},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,...smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,fontWeight:e.weight.semibold}})};export{DatePicker};export default DatePicker;
1
+ "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Animated,Easing,Modal,Pressable,StyleSheet,Text,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{ModalSafeArea,useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{PickerTrigger}from"../PickerTrigger/index.js";import{ToastHost}from"../Toast/ToastProvider.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const NAV_BUTTON_SIZE=36,AnimatedGestureRoot=Animated.createAnimatedComponent(GestureHandlerRootView),GRID_SIZE=12,DECADE_SPAN=10,startOfDay=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),isSameDay=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),toIso=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,addMonths=(e,t)=>new Date(e.getFullYear(),e.getMonth()+t,1),buildMonthMatrix=(e,t)=>{const a=e.getFullYear(),r=e.getMonth(),s=(new Date(a,r,1).getDay()-t+7)%7,i=[];for(let e=0;e<42;e+=1){const t=new Date(a,r,1-s+e);i.push({date:t,inMonth:t.getMonth()===r,iso:toIso(t)})}return i},weekdayLabels=(e,t)=>{const a=new Intl.DateTimeFormat(e,{weekday:"short"}),r=[];for(let e=0;e<7;e+=1){const s=new Date(1970,0,4+(t+e)%7);r.push(a.format(s))}return r},formatMonthYear=(e,t)=>new Intl.DateTimeFormat(t,{month:"long",year:"numeric"}).format(e),decadeStartFor=e=>10*Math.floor(e/10),buildYearCells=e=>{const t=e-4;return Array.from({length:12},(e,a)=>t+a)},buildDecadeCells=e=>{const t=decadeStartFor(e)-40;return Array.from({length:12},(e,a)=>t+10*a)},DatePicker=e=>{const{value:t,onChange:a,onClose:r,minDate:s,maxDate:i,disabledDates:o,mode:n="modal",locale:l="en-IN",weekStartsOn:c=0,title:d="Select Date",confirmLabel:u="Confirm",cancelLabel:m="Cancel",style:g,containerStyle:y,headerLabelStyle:h,navButtonStyle:p,footerButtonStyle:b,haptic:f,testID:x,label:w,placeholder:D,helperText:v,error:C,required:j,disabled:S,size:A,variant:V,clearable:T,onClear:_,formatValue:M,triggerStyle:R}=e,k=void 0!==e.visible,[I,P]=useState(!1),F=k?e.visible:I,N=k?x:x?`${x}-calendar`:void 0,Y=useTheme(),L=usePresenceMotion(),[z,B]=useModalInsets(),$=useMemo(()=>buildStyles(Y),[Y]),[E,H]=useState(()=>startOfDay(new Date));useEffect(()=>{F&&H(startOfDay(new Date))},[F]);const O=t?startOfDay(t):E,[W,G]=useState(O),[q,X]=useState(t?startOfDay(t):null),[Z,U]=useState("days"),J=useRef(createAnimatedValue(0)).current,K=useRef(createAnimatedValue(0)).current,Q=useRef(createAnimatedValue(0)).current,ee=useRef(0),te=useRef(createAnimatedValue(0)).current,ae=useRef(createAnimatedValue(1)).current,re=useRef(createAnimatedValue(1)).current,se=useRef(createAnimatedValue(1)).current,ie=useRef(createAnimatedValue(1)).current,oe=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(t){const e=startOfDay(t);X(e),G(e)}else X(null)},[t]);const ne=useMemo(()=>{const e=new Set;return o?.forEach(t=>{e.add(toIso(startOfDay(t)))}),e},[o]),le=useMemo(()=>s?startOfDay(s):null,[s]),ce=useMemo(()=>i?startOfDay(i):null,[i]),de=useCallback(e=>!!(le&&e.getTime()<le.getTime())||(!!(ce&&e.getTime()>ce.getTime())||!!ne.has(toIso(e))),[le,ce,ne]),ue=useMemo(()=>buildMonthMatrix(W,c),[W,c]),me=useMemo(()=>buildYearCells(W.getFullYear()),[W]),ge=useMemo(()=>buildDecadeCells(W.getFullYear()),[W]),ye=useMemo(()=>weekdayLabels(l,c),[l,c]),he=useMemo(()=>new Intl.DateTimeFormat(l,{weekday:"long",year:"numeric",month:"long",day:"numeric"}),[l]),pe=useMemo(()=>{if("days"===Z)return formatMonthYear(W,l);if("years"===Z){return`${me[0]} - ${me[me.length-1]}`}return`${ge[0]} - ${ge[ge.length-1]+9}`},[W,ge,l,Z,me]),be=useCallback(e=>!!(le&&e<le.getFullYear())||!!(ce&&e>ce.getFullYear()),[le,ce]),fe=useCallback(e=>!!(le&&e+10-1<le.getFullYear())||!!(ce&&e>ce.getFullYear()),[le,ce]),xe=useCallback(e=>{!1!==f&&triggerHaptic("impactLight");const t=e>0?1:-1,a=Y.motion.duration.fast,r=Y.motion.duration.fast,[s]=L.range(32*-t,0),[i]=L.range(32*t,0),o=L.reduced?L.duration("fast"):a,n=L.reduced?L.duration("fast"):r;Animated.sequence([Animated.parallel([Animated.timing(te,{toValue:s,duration:a,easing:Easing.out(Easing.quad),useNativeDriver:!0}),Animated.timing(ae,{toValue:0,duration:o,useNativeDriver:!0})]),Animated.timing(te,{toValue:i,duration:0,useNativeDriver:!0}),Animated.parallel([Animated.timing(te,{toValue:0,duration:r,easing:Easing.out(Easing.cubic),useNativeDriver:!0}),Animated.timing(ae,{toValue:1,duration:n,useNativeDriver:!0})])]).start();const c=addMonths(W,e);G(c),AccessibilityInfo.announceForAccessibility(formatMonthYear(c,l))},[W,f,l,ae,te,L,Y.motion.duration.fast]),we=useCallback(()=>{"days"!==Z?(!1!==f&&triggerHaptic("impactLight"),G("years"===Z?e=>new Date(e.getFullYear()-12,e.getMonth(),1):e=>new Date(e.getFullYear()-120,e.getMonth(),1))):xe(-1)},[xe,Z,f]),De=useCallback(()=>{"days"!==Z?(!1!==f&&triggerHaptic("impactLight"),G("years"===Z?e=>new Date(e.getFullYear()+12,e.getMonth(),1):e=>new Date(e.getFullYear()+120,e.getMonth(),1))):xe(1)},[xe,Z,f]),ve=useCallback(()=>{const[e]=L.range(.9,1),t=L.reduced?L.duration("default"):Y.motion.duration.default;setNativeValue(se,0),setNativeValue(ie,e),Animated.parallel([Animated.timing(se,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:!0}),Animated.timing(ie,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:!0})]).start()},[se,ie,L,Y.motion.duration.default]),Ce=useCallback(()=>{const e=resolveHaptic(f,"selection");if(e&&triggerHaptic(e),!L.reduced){const e=80,t=100;Animated.sequence([Animated.timing(oe,{toValue:.96,duration:e,useNativeDriver:!0}),Animated.timing(oe,{toValue:1,duration:t,useNativeDriver:!0})]).start()}U(e=>"days"===e?"years":"years"===e?"decades":"years"),ve()},[ve,oe,f,L.reduced]),je=useCallback(e=>{const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),G(t=>new Date(e,t.getMonth(),1)),U("days"),ve()},[ve,f]),Se=useCallback(e=>{const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),G(t=>new Date(e+4,t.getMonth(),1)),U("years"),ve()},[ve,f]),Ae=useCallback(e=>{if(de(e.date))return;const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),X(e.date),e.inMonth||G(new Date(e.date.getFullYear(),e.date.getMonth(),1)),L.reduced||(setNativeValue(re,.7),Animated.spring(re,{toValue:1,damping:Y.motion.spring.bouncy.damping,stiffness:Y.motion.spring.bouncy.stiffness,mass:Y.motion.spring.bouncy.mass,useNativeDriver:!0}).start())},[de,L.reduced,re,Y.motion.spring.bouncy,f]),Ve=useCallback(()=>{k||P(!1),r?.()},[k,r]),Te=useCallback(()=>{"modal"===n?Animated.parallel([Animated.timing(J,{toValue:0,duration:L.duration("default"),easing:Easing.bezier(...Y.motion.ease.accelerate),useNativeDriver:!1}),Animated.timing(K,{toValue:0,duration:L.duration("fast"),easing:Easing.bezier(...Y.motion.ease.accelerate),useNativeDriver:!0})]).start(()=>{Ve()}):Ve()},[J,n,Ve,L,K,Y.motion.ease.accelerate]),{handleGesture:Me,opacity:Re}=useDragToDismiss({drag:Q,travel:()=>ee.current||320,onDismiss:Te}),ke=useMemo(()=>Animated.multiply(K,Re),[K,Re]),Ie=useMemo(()=>J.interpolate({inputRange:[0,1],outputRange:[transparentOf(Y.colors.scrim),Y.colors.scrim]}),[J,Y.colors.scrim]);useEffect(()=>{if("modal"===n&&F){J.setValue(0),setNativeValue(K,0),setNativeValue(Q,0),setNativeValue(Re,1);const e=L.reduced?Animated.timing(K,{toValue:1,duration:L.duration("default"),useNativeDriver:!0}):Animated.spring(K,{toValue:1,damping:Y.motion.spring.gentle.damping,stiffness:Y.motion.spring.gentle.stiffness,mass:Y.motion.spring.gentle.mass,useNativeDriver:!0}),t=Animated.parallel([Animated.timing(J,{toValue:1,duration:L.duration("default"),easing:Easing.out(Easing.cubic),useNativeDriver:!1}),e]);return t.start(),()=>t.stop()}},[F,n,J,L,K,Q,Re,Y.motion]);const Pe=useCallback(()=>{!1!==f&&triggerHaptic("selection"),Te()},[Te,f]),Fe=useCallback(()=>{q&&(!1!==f&&triggerHaptic("notificationSuccess"),a?.(q),Te())},[Te,a,q,f]),Ne=K.interpolate({inputRange:[0,1],outputRange:L.range(320,0)}),Ye=_jsx(View,{style:$.titleRow,children:_jsx(Text,{style:$.title,accessibilityRole:"header",children:d})}),Le=_jsxs(View,{style:[$.card,g,y],accessibilityRole:"modal"===n?void 0:"none",accessible:!1,testID:N,children:["modal"===n?_jsx(GestureDetector,{gesture:Me,children:_jsxs(View,{style:$.grabArea,children:[_jsx(View,{style:$.handle}),Ye]})}):Ye,_jsxs(View,{style:$.headerRow,children:[_jsx(Pressable,{onPress:we,style:({pressed:e})=>[$.navBtn,e&&$.navBtnPressed,p],accessibilityRole:"button",accessibilityLabel:"days"===Z?"Previous month":"years"===Z?"Previous years":"Previous decades",hitSlop:8,...hitSlopMarker(8),children:_jsx(Text,{style:$.navText,children:"‹"})}),_jsx(Pressable,{onPress:Ce,style:[$.headerLabelWrap,h],accessibilityRole:"button",accessibilityLabel:"days"===Z?`${pe}, switch to year selection`:"years"===Z?`${pe}, switch to decade selection`:`${pe}, switch to year selection`,hitSlop:8,...hitSlopMarker(8),children:_jsxs(Animated.View,{style:[$.headerLabelInner,{transform:[{scale:oe}],opacity:"days"===Z?ae:1}],children:[_jsx(Animated.Text,{style:[$.headerLabel,{transform:[{translateX:"days"===Z?te:0}]}],accessibilityLiveRegion:"polite",children:pe}),_jsx(View,{style:$.headerCaret,children:(Y.settings.icons.chevronDown??defaultIcons.chevronDown)({size:Y.text.sm.size,color:Y.colors["text-muted"]})})]})}),_jsx(Pressable,{onPress:De,style:({pressed:e})=>[$.navBtn,e&&$.navBtnPressed,p],accessibilityRole:"button",accessibilityLabel:"days"===Z?"Next month":"years"===Z?"Next years":"Next decades",hitSlop:8,...hitSlopMarker(8),children:_jsx(Text,{style:$.navText,children:"›"})})]}),"days"===Z?_jsxs(_Fragment,{children:[_jsx(View,{style:$.weekdayRow,children:ye.map((e,t)=>_jsx(View,{style:$.weekdayCell,children:_jsx(Text,{style:$.weekdayText,children:e})},`${e}-${t}`))}),_jsx(Animated.View,{style:[$.grid,{opacity:ae,transform:[{translateX:te}]}],children:Array.from({length:6}).map((e,t)=>_jsx(View,{style:$.gridRow,children:ue.slice(7*t,7*t+7).map(e=>{const t=de(e.date),a=!!q&&isSameDay(e.date,q),r=isSameDay(e.date,E),s=a?Y.colors.primary:"transparent",i=r&&!a?Y.colors.primary:"transparent",o=a?Y.colors["on-primary"]:e.inMonth?t?Y.colors["text-disabled"]:Y.colors["text-body"]:Y.colors["text-subtle"],n=t?.3:e.inMonth?1:.4;return _jsx(Pressable,{disabled:t,onPress:()=>Ae(e),accessibilityRole:"button",accessibilityLabel:he.format(e.date),accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:$.dayCell,children:_jsx(Animated.View,{style:[$.dayInner,{backgroundColor:s,borderColor:i,borderWidth:r&&!a?1.5:0,opacity:n},a?{transform:[{scale:re}]}:null],children:_jsx(Text,{style:[$.dayText,{color:o}],children:e.date.getDate()})})},e.iso)})},`r-${t}`))})]}):_jsx(Animated.View,"years"===Z?{style:[$.yearGrid,{opacity:se,transform:[{scale:ie}]}],children:Array.from({length:3}).map((e,t)=>_jsx(View,{style:$.gridRow,children:me.slice(4*t,4*t+4).map(e=>{const t=be(e),a=!!q&&q.getFullYear()===e,r=E.getFullYear()===e,s=a?Y.colors.primary:"transparent",i=r&&!a?Y.colors.primary:"transparent",o=a?Y.colors["on-primary"]:t?Y.colors["text-disabled"]:Y.colors["text-body"],n=t?.3:1;return _jsx(Pressable,{disabled:t,onPress:()=>je(e),accessibilityRole:"button",accessibilityLabel:`Year ${e}`,accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:$.yearCell,children:_jsx(View,{style:[$.yearInner,{backgroundColor:s,borderColor:i,borderWidth:r&&!a?1.5:0,opacity:n}],children:_jsx(Text,{style:[$.yearText,{color:o}],children:e})})},`year-${e}`)})},`yr-${t}`))}:{style:[$.yearGrid,{opacity:se,transform:[{scale:ie}]}],children:Array.from({length:3}).map((e,t)=>_jsx(View,{style:$.gridRow,children:ge.slice(4*t,4*t+4).map(e=>{const t=e+10-1,a=fe(e),r=!!q&&decadeStartFor(q.getFullYear())===e,s=decadeStartFor(E.getFullYear())===e,i=r?Y.colors.primary:"transparent",o=s&&!r?Y.colors.primary:"transparent",n=r?Y.colors["on-primary"]:a?Y.colors["text-disabled"]:Y.colors["text-body"],l=a?.3:1;return _jsx(Pressable,{disabled:a,onPress:()=>Se(e),accessibilityRole:"button",accessibilityLabel:`Decade ${e} to ${t}`,accessibilityState:{selected:r,disabled:a},"aria-selected":r,"aria-disabled":a,style:$.yearCell,children:_jsxs(View,{style:[$.yearInner,{backgroundColor:i,borderColor:o,borderWidth:s&&!r?1.5:0,opacity:l}],children:[_jsx(Text,{style:[$.yearText,{color:n}],children:`${e}s`}),_jsx(Text,{style:[$.decadeRangeText,{color:r?Y.colors["on-primary"]:Y.colors["text-subtle"]}],children:`${e}-${t}`})]})},`decade-${e}`)})},`dec-${t}`))}),_jsxs(View,{style:$.footer,children:[_jsx(Pressable,{onPress:Pe,style:({pressed:e})=>[$.footerBtn,$.footerCancel,e&&$.footerBtnPressed,b],accessibilityRole:"button",accessibilityLabel:m,children:_jsx(Text,{style:[$.footerBtnText,{color:Y.colors["text-muted"]}],children:m})}),_jsx(Pressable,{onPress:Fe,disabled:!q,style:({pressed:e})=>[$.footerBtn,$.footerConfirm,{backgroundColor:Y.colors.primary,opacity:q?1:.5},e&&{backgroundColor:Y.colors["primary-hover"]},b],accessibilityRole:"button",accessibilityLabel:u,accessibilityState:{disabled:!q},"aria-disabled":!q,children:_jsx(Text,{style:[$.footerBtnText,{color:Y.colors["on-primary"]}],children:u})})]})]}),ze=t?(M??(e=>e.toLocaleDateString()))(t):void 0,Be=!k;if("inline"===n)return F||Be?Be?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{label:w,value:ze,placeholder:D,helperText:v,error:C,required:j,disabled:S,size:A,variant:V,clearable:T,onClear:_,onPress:()=>P(!0),triggerStyle:R,testID:x}),F?Le:null]}):Le:null;const $e=_jsx(Modal,{visible:F,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:Te,children:_jsx(ModalSafeArea,{onInsets:B,children:_jsxs(AnimatedGestureRoot,{collapsable:!1,style:[$.backdrop,{backgroundColor:Ie}],children:[_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:Te,accessibilityLabel:"Dismiss"}),_jsx(Animated.View,{style:[$.sheetWrap,{paddingBottom:Math.max(z.bottom,Y.space.lg),opacity:ke,transform:[{translateY:Animated.add(Ne,Q)}]}],onLayout:e=>{ee.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:Le}),_jsx(ToastHost,{})]})})});return Be?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{label:w,value:ze,placeholder:D,helperText:v,error:C,required:j,disabled:S,size:A,variant:V,clearable:T,onClear:_,onPress:()=>P(!0),triggerStyle:R,testID:x}),$e]}):$e},buildStyles=e=>{const t=e.shadow.popover;return StyleSheet.create({backdrop:{...StyleSheet.absoluteFill},sheetWrap:{position:"absolute",left:0,right:0,bottom:0,paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,...smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,...smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:e.space.md},navBtn:{width:36,height:36,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"]},navBtnPressed:{backgroundColor:e.colors["surface-pressed"]},navText:{fontSize:e.text["2xl"].size,lineHeight:26,color:e.colors["text-body"],fontWeight:e.weight.semibold},headerLabelWrap:{flex:1,alignItems:"center"},headerLabelInner:{flexDirection:"row",alignItems:"center",justifyContent:"center"},headerLabel:{fontSize:e.text.base.size,fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerCaret:{marginLeft:e.space.xs,alignItems:"center",justifyContent:"center"},weekdayRow:{flexDirection:"row",marginBottom:e.space.xs},weekdayCell:{flex:1,alignItems:"center",paddingVertical:e.space.xs},weekdayText:{fontSize:e.text.xs.size,fontWeight:e.weight.medium,color:e.colors["text-subtle"],letterSpacing:e["letter-spacing"].wide},grid:{},gridRow:{flexDirection:"row"},dayCell:{flex:1,aspectRatio:1,alignItems:"center",justifyContent:"center",padding:e.space.xxs},dayInner:{width:"100%",height:"100%",borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center"},dayText:{fontSize:e.text.sm.size,fontWeight:e.weight.medium},yearGrid:{},yearCell:{flex:1,aspectRatio:1.6,alignItems:"center",justifyContent:"center",padding:e.space.xs},yearInner:{width:"100%",height:"100%",borderRadius:e.radius.lg,...smoothCorners,alignItems:"center",justifyContent:"center"},yearText:{fontSize:e.text.base.size,fontWeight:e.weight.semibold},decadeRangeText:{fontSize:e.text.xs.size,fontWeight:e.weight.medium,marginTop:e.space.xxs},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,...smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,fontWeight:e.weight.semibold}})};export{DatePicker};export default DatePicker;
@@ -1 +1 @@
1
- "use strict";import{useEffect,useMemo,useRef}from"react";import{Animated,Easing,Pressable,StyleSheet,Text,View}from"react-native";import{createAnimatedValue,fontFor,resolveFieldSize,useTheme}from"../../theme/index.js";import{ariaFromState}from"../../utils/ariaState.js";import{smoothCorners}from"../../utils/corners.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{NotationInkContext,useNotationInk}from"../Notation/Notation.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const expandColorSides=e=>"string"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??"transparent",right:e.right??"transparent",bottom:e.bottom??"transparent",left:e.left??"transparent"},expandWidthSides=e=>"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0};export const pickRepresentativeBorderColor=e=>{for(const t of["bottom","top","left","right"]){const o=e[t];if(o&&"transparent"!==o)return o}return e.bottom};export const resolveFieldTextStyle=(e,t={})=>{const{disabled:o=!1}=t;return{color:o?e.colors["field-text-disabled"]:e.colors["field-text"],placeholderColor:o?e.colors["field-placeholder-disabled"]:e.colors["field-placeholder"],weightStyle:fontFor(e,"normal")}};export const RequiredMark=()=>{const e=useTheme();return _jsx(Text,{style:{color:e.colors["danger-text"]},children:` ${e.settings.components.field?.requiredMarker??"*"}`})};export const RequiredPlaceholder=({text:e,color:t,fontSize:o,weightStyle:r,align:i="center",paddingTop:l,textAlign:s})=>_jsx(View,{pointerEvents:"none",style:[StyleSheet.absoluteFill,{justifyContent:"top"===i?"flex-start":"center",paddingTop:l}],children:_jsxs(Text,{accessible:!1,numberOfLines:1,style:{color:t,fontSize:o,...r,includeFontPadding:!1,textAlign:s},children:[e,_jsx(RequiredMark,{})]})});export const FieldErrorGlyph=({size:e,color:t})=>{const o=useTheme().settings.icons.error??defaultIcons.error;return _jsx(_Fragment,{children:o({size:e,color:t})})};export const hasFieldText=e=>null!=e&&!1!==e&&!0!==e&&""!==e;export const fieldTextAsString=e=>"string"==typeof e?e:void 0;export const FieldLabel=({children:e,size:t="md",required:o=!1,help:r,color:i,style:l})=>{const s=useTheme(),n=resolveFieldSize(s,t),d=hasFieldText(r),a=useNotationInk(l,n["label-text"],i??s.colors["field-label"]),c=_jsxs(Text,{style:[familyStyles.label,{color:i??s.colors["field-label"],fontSize:n["label-text"],...fontFor(s,"semibold"),marginBottom:d?s.space.none:n["label-gap"]},d?familyStyles.labelShrink:null,l],children:[_jsx(NotationInkContext.Provider,{value:a,children:e}),o?_jsx(RequiredMark,{}):null]});return d?_jsxs(View,{style:[familyStyles.labelRow,{marginBottom:n["label-gap"]}],children:[c,_jsx(View,{style:[familyStyles.help,{marginLeft:s.space.xs}],children:r})]}):c};export const FieldMessage=({text:e,error:t=!1,size:o="md",style:r})=>{const i=useTheme(),l=resolveFieldSize(i,o),s=t?i.colors["field-message"]:i.colors["text-muted"],n=useNotationInk(r,l["message-text"],s);return hasFieldText(e)?_jsxs(View,{style:[familyStyles.messageRow,{marginTop:l["message-gap"],columnGap:i.space.xs}],accessibilityLiveRegion:t?"polite":"none",children:[t?_jsx(FieldErrorGlyph,{size:l["message-text"],color:s}):null,_jsx(Text,{style:[familyStyles.messageText,{color:s,fontSize:l["message-text"],...fontFor(i,"normal")},r],children:_jsx(NotationInkContext.Provider,{value:n,children:e})})]}):null};const familyStyles=StyleSheet.create({label:{includeFontPadding:!1},labelShrink:{flexShrink:1},labelRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0,alignItems:"center",justifyContent:"center"},messageRow:{flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1}});export const resolveVariantColors=(e,t)=>{let o,r,i,l,s;"outlined"===t?(o=e.colors["field-bg"],r=e.colors["field-bg-focus"],i=e.colors["field-bg-disabled"],l=e.colors["field-border"],s=e.size.border):"underline"===t?(o="transparent",r=void 0,i="transparent",l={bottom:e.colors["field-border"]},s={bottom:e.size.border}):(o=e.colors["field-bg"],r=void 0,i=e.colors["field-bg-disabled"],l="transparent",s=0);const wrapToIdleShape=e=>"string"==typeof l?e:{bottom:e},n=expandColorSides(l),d=expandColorSides(wrapToIdleShape(e.colors["field-border-focus"]));return{backgroundIdleEmpty:o,backgroundIdleFilled:o,backgroundFocused:r,backgroundError:void 0,backgroundDisabled:i,borderIdle:n,borderFocused:d,borderError:expandColorSides(wrapToIdleShape(e.colors["field-border-error"])),borderDisabled:expandColorSides(l),borderWidth:expandWidthSides(s),borderFocusedRepresentative:pickRepresentativeBorderColor(d)}};export const FieldBase=e=>{const{size:t="md",variant:o,focused:r=!1,disabled:i=!1,error:l=!1,filled:s=!1,leading:n,leadingDivider:d=!1,trailing:a,slotAlign:c="center",slotLineHeight:b,topNotch:u,children:p,onPress:g,pressFeedback:m=!0,minHeight:h,maxHeight:f,width:x,height:y,paddingHorizontal:S,paddingLeft:F,paddingRight:R,paddingVertical:j,borderRadius:v,borderTopLeftRadius:C,borderTopRightRadius:k,borderBottomLeftRadius:T,borderBottomRightRadius:w,borderWidth:_,borderTopWidth:I,borderRightWidth:L,borderBottomWidth:z,borderLeftWidth:V,gap:B,style:W,testID:E,accessibilityRole:D,accessibilityLabel:q,accessibilityState:A,accessibilityHint:M}=e,P=useTheme(),N=useMemo(()=>buildStyles(),[]),H=o??P.settings.components.field?.defaultVariant??"outlined",G=resolveFieldSize(P,t),O=useMemo(()=>resolveVariantColors(P,H),[P,H]),$=l?2:r?1:0,J=useRef(createAnimatedValue($)).current;useEffect(()=>{const e=Animated.timing(J,{toValue:$,duration:P.motion.duration.fast,easing:Easing.bezier(...P.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[$,J,P.motion.duration.fast,P.motion.ease["in-out"]]);const K=[0,1,2],Q=s?O.backgroundIdleFilled:O.backgroundIdleEmpty,U=O.backgroundFocused??Q,X=O.backgroundError??Q,Y=i?O.backgroundDisabled:J.interpolate({inputRange:K,outputRange:[Q,U,X]}),Z=O.borderIdle,ee=O.borderFocused,te=O.borderError,oe={top:I,right:L,bottom:z,left:V},re={top:oe.top??_??O.borderWidth.top,right:oe.right??_??O.borderWidth.right,bottom:oe.bottom??_??O.borderWidth.bottom,left:oe.left??_??O.borderWidth.left},ie={minHeight:y??h??G["min-height"],maxHeight:f,paddingHorizontal:S??G["padding-x"],paddingVertical:j??G["padding-y"],paddingLeft:F??S??G["padding-x"],paddingRight:R??S??G["padding-x"],backgroundColor:Y,columnGap:B??P.space.md,alignItems:"top"===c?"flex-start":"center"},le="underline"===H,se=le?P.radius.none:v??G.radius,ne=le?{tl:P.radius.none,tr:P.radius.none,bl:P.radius.none,br:P.radius.none}:{tl:C??se,tr:k??se,bl:T??se,br:w??se};ie.borderTopLeftRadius=ne.tl,ie.borderTopRightRadius=ne.tr,ie.borderBottomLeftRadius=ne.bl,ie.borderBottomRightRadius=ne.br,ie.borderCurve=smoothCorners.borderCurve,ie.borderTopWidth=re.top,ie.borderRightWidth=re.right,ie.borderBottomWidth=re.bottom,ie.borderLeftWidth=re.left;const sideColor=e=>J.interpolate({inputRange:K,outputRange:[Z[e],ee[e],te[e]]}),sameOnEverySide=e=>e.top===e.right&&e.top===e.bottom&&e.top===e.left,de=!le&&ne.tl===ne.tr&&ne.tl===ne.bl&&ne.tl===ne.br&&sameOnEverySide(re)&&sameOnEverySide(Z)&&sameOnEverySide(ee)&&sameOnEverySide(te)&&sameOnEverySide(O.borderDisabled),ae=useSquircle(de,ne.tl);if(ae.active)ie.backgroundColor="transparent",ie.borderTopColor="transparent",ie.borderRightColor="transparent",ie.borderBottomColor="transparent",ie.borderLeftColor="transparent";else if(i){const e=O.borderDisabled;ie.borderTopColor=e.top,ie.borderRightColor=e.right,ie.borderBottomColor=e.bottom,ie.borderLeftColor=e.left}else ie.borderTopColor=sideColor("top"),ie.borderRightColor=sideColor("right"),ie.borderBottomColor=sideColor("bottom"),ie.borderLeftColor=sideColor("left");const ce=i?O.borderDisabled.top:sideColor("top"),be=useRef($);be.current=$,useEffect(()=>{J.setValue(be.current)},[O,J]),void 0!==x&&(ie.width=x),void 0!==y&&(ie.height=y);const ue={disabled:i,...A},pe="top"===c,ge=pe?{alignSelf:"flex-start",marginTop:Math.max(0,((b??G.icon)-G.icon)/2)}:null,me=y??h??G["min-height"],he=(()=>{if(!u)return 0;const e=Math.min(ne.tl,me/2),t=u.left;return e<=0||t>=e?0:Math.ceil(e-Math.sqrt(e*e-(e-t)*(e-t)))})(),fe=u&&re.top>0?_jsx(Animated.View,{pointerEvents:"none",style:{position:"absolute",top:-re.top,left:u.left-re.left,width:u.width,height:re.top+he,backgroundColor:Y}}):null,renderInner=e=>_jsxs(_Fragment,{children:[ae.active&&ae.size?_jsx(SquircleFill,{width:ae.size.width,height:ae.size.height,radius:ne.tl,fill:e&&!i?P.colors["surface-pressed"]:Y,stroke:ce,strokeWidth:re.top,outset:re.top}):null,fe,null!=n?_jsx(View,{style:[N.slot,ge],children:n}):null,null!=n&&d?_jsx(View,{pointerEvents:"none",style:[N.divider,ge,{height:G.icon,backgroundColor:P.colors["field-border"]}]}):null,_jsx(View,{style:[N.content,pe?N.contentTop:null],children:p}),null!=a?_jsx(View,{style:[N.slot,ge],children:a}):null]}),xe=_jsx(Animated.View,{onLayout:ae.onLayout,style:[N.box,ie,W],accessibilityRole:D,accessibilityLabel:q,accessibilityHint:M,accessibilityState:ue,...ariaFromState(ue),testID:E,children:renderInner(!1)});return g&&!m?_jsx(Pressable,{onPress:g,disabled:i,accessible:!1,children:xe}):g?_jsx(Pressable,{onPress:g,disabled:i,accessibilityRole:D??"button",accessibilityLabel:q,accessibilityHint:M,accessibilityState:ue,...ariaFromState(ue),testID:E,children:({pressed:e})=>_jsx(Animated.View,{onLayout:ae.onLayout,style:[N.box,ie,!e||i||ae.active?null:{backgroundColor:P.colors["surface-pressed"]},W],children:renderInner(e)})}):xe};FieldBase.displayName="FieldBase";const buildStyles=()=>StyleSheet.create({box:{flexDirection:"row",alignItems:"center",overflow:"visible"},slot:{alignItems:"center",justifyContent:"center"},divider:{width:1,alignSelf:"center"},content:{flex:1,flexDirection:"row",alignItems:"center"},contentTop:{alignItems:"flex-start"}});export default FieldBase;
1
+ "use strict";import{useEffect,useMemo,useRef}from"react";import{Animated,Easing,Pressable,StyleSheet,Text,View}from"react-native";import{createAnimatedValue,fontFor,resolveFieldSize,useTheme}from"../../theme/index.js";import{ariaFromState}from"../../utils/ariaState.js";import{smoothCorners}from"../../utils/corners.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{NotationInkContext,useNotationInk}from"../Notation/Notation.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const expandColorSides=e=>"string"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??"transparent",right:e.right??"transparent",bottom:e.bottom??"transparent",left:e.left??"transparent"},expandWidthSides=e=>"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0};export const pickRepresentativeBorderColor=e=>{for(const t of["bottom","top","left","right"]){const o=e[t];if(o&&"transparent"!==o)return o}return e.bottom};export const resolveFieldTextStyle=(e,t={})=>{const{disabled:o=!1}=t;return{color:o?e.colors["field-text-disabled"]:e.colors["field-text"],placeholderColor:o?e.colors["field-placeholder-disabled"]:e.colors["field-placeholder"],weightStyle:fontFor(e,"normal")}};export const RequiredMark=()=>{const e=useTheme();return _jsx(Text,{style:{color:e.colors["danger-text"]},children:` ${e.settings.components.field?.requiredMarker??"*"}`})};export const RequiredPlaceholder=({text:e,color:t,fontSize:o,weightStyle:r,align:i="center",paddingTop:l,textAlign:s})=>_jsx(View,{pointerEvents:"none",style:[StyleSheet.absoluteFill,{justifyContent:"top"===i?"flex-start":"center",paddingTop:l}],children:_jsxs(Text,{accessible:!1,numberOfLines:1,style:{color:t,fontSize:o,...r,includeFontPadding:!1,textAlign:s},children:[e,_jsx(RequiredMark,{})]})});export const FieldErrorGlyph=({size:e,color:t})=>{const o=useTheme().settings.icons.error??defaultIcons.error;return _jsx(_Fragment,{children:o({size:e,color:t})})};export const hasFieldText=e=>null!=e&&!1!==e&&!0!==e&&""!==e;export const fieldTextAsString=e=>"string"==typeof e?e:void 0;export const FieldLabel=({children:e,size:t="md",required:o=!1,help:r,color:i,style:l})=>{const s=useTheme(),n=resolveFieldSize(s,t),d=hasFieldText(r),a=useNotationInk(l,n["label-text"],i??s.colors["field-label"]),c=_jsxs(Text,{style:[familyStyles.label,{color:i??s.colors["field-label"],fontSize:n["label-text"],...fontFor(s,"semibold"),marginBottom:d?s.space.none:n["label-gap"]},d?familyStyles.labelShrink:null,l],children:[_jsx(NotationInkContext.Provider,{value:a,children:e}),o?_jsx(RequiredMark,{}):null]});return d?_jsxs(View,{style:[familyStyles.labelRow,{marginBottom:n["label-gap"]}],children:[c,_jsx(View,{style:[familyStyles.help,{marginLeft:s.space.xs}],children:r})]}):c};export const FieldMessage=({text:e,error:t=!1,size:o="md",style:r})=>{const i=useTheme(),l=resolveFieldSize(i,o),s=t?i.colors["field-message"]:i.colors["text-muted"],n=useNotationInk(r,l["message-text"],s);return hasFieldText(e)?_jsxs(View,{style:[familyStyles.messageRow,{marginTop:l["message-gap"],columnGap:i.space.xs}],accessibilityLiveRegion:t?"polite":"none",children:[t?_jsx(FieldErrorGlyph,{size:l["message-text"],color:s}):null,_jsx(Text,{style:[familyStyles.messageText,{color:s,fontSize:l["message-text"],...fontFor(i,"normal")},r],children:_jsx(NotationInkContext.Provider,{value:n,children:e})})]}):null};const familyStyles=StyleSheet.create({label:{includeFontPadding:!1},labelShrink:{flexShrink:1},labelRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0,alignItems:"center",justifyContent:"center"},messageRow:{flexDirection:"row",alignItems:"center"},messageText:{flexShrink:1,includeFontPadding:!1}});export const resolveVariantColors=(e,t)=>{let o,r,i,l,s;"outlined"===t?(o=e.colors["field-bg"],r=e.colors["field-bg-focus"],i=e.colors["field-bg-disabled"],l=e.colors["field-border"],s=e.size.border):"underline"===t?(o="transparent",r=void 0,i="transparent",l={bottom:e.colors["field-border"]},s={bottom:e.size.border}):(o=e.colors["field-bg"],r=void 0,i=e.colors["field-bg-disabled"],l="transparent",s=0);const wrapToIdleShape=e=>"string"==typeof l?e:{bottom:e},n=expandColorSides(l),d=expandColorSides(wrapToIdleShape(e.colors["field-border-focus"]));return{backgroundIdleEmpty:o,backgroundIdleFilled:o,backgroundFocused:r,backgroundError:void 0,backgroundDisabled:i,borderIdle:n,borderFocused:d,borderError:expandColorSides(wrapToIdleShape(e.colors["field-border-error"])),borderDisabled:expandColorSides(l),borderWidth:expandWidthSides(s),borderFocusedRepresentative:pickRepresentativeBorderColor(d)}};export const FieldBase=e=>{const{size:t="md",variant:o,focused:r=!1,disabled:i=!1,error:l=!1,filled:s=!1,leading:n,leadingDivider:d=!1,trailing:a,slotAlign:c="center",slotLineHeight:b,topNotch:u,children:p,onPress:g,pressFeedback:m=!0,minHeight:h,maxHeight:f,width:x,height:y,paddingHorizontal:S,paddingLeft:F,paddingRight:R,paddingVertical:j,borderRadius:v,borderTopLeftRadius:C,borderTopRightRadius:k,borderBottomLeftRadius:T,borderBottomRightRadius:w,borderWidth:_,borderTopWidth:I,borderRightWidth:L,borderBottomWidth:z,borderLeftWidth:V,gap:B,style:W,testID:E,accessibilityRole:D,accessibilityLabel:q,accessibilityState:A,accessibilityHint:M}=e,P=useTheme(),N=useMemo(()=>buildStyles(),[]),H=o??P.settings.components.field?.defaultVariant??"outlined",G=resolveFieldSize(P,t),O=useMemo(()=>resolveVariantColors(P,H),[P,H]),$=l?2:r?1:0,J=useRef(createAnimatedValue($)).current;useEffect(()=>{const e=Animated.timing(J,{toValue:$,duration:P.motion.duration.fast,easing:Easing.bezier(...P.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[$,J,P.motion.duration.fast,P.motion.ease["in-out"]]);const K=[0,1,2],Q=s?O.backgroundIdleFilled:O.backgroundIdleEmpty,U=O.backgroundFocused??Q,X=O.backgroundError??Q,Y=i?O.backgroundDisabled:J.interpolate({inputRange:K,outputRange:[Q,U,X]}),Z=O.borderIdle,ee=O.borderFocused,te=O.borderError,oe={top:I,right:L,bottom:z,left:V},re={top:oe.top??_??O.borderWidth.top,right:oe.right??_??O.borderWidth.right,bottom:oe.bottom??_??O.borderWidth.bottom,left:oe.left??_??O.borderWidth.left},ie={minHeight:y??h??G["min-height"],maxHeight:f,paddingHorizontal:S??G["padding-x"],paddingVertical:j??G["padding-y"],paddingLeft:F??S??G["padding-x"],paddingRight:R??S??G["padding-x"],backgroundColor:Y,columnGap:B??P.space.md,alignItems:"top"===c?"flex-start":"center"},le="underline"===H,se=le?P.radius.none:v??G.radius,ne=le?{tl:P.radius.none,tr:P.radius.none,bl:P.radius.none,br:P.radius.none}:{tl:C??se,tr:k??se,bl:T??se,br:w??se};ie.borderTopLeftRadius=ne.tl,ie.borderTopRightRadius=ne.tr,ie.borderBottomLeftRadius=ne.bl,ie.borderBottomRightRadius=ne.br,ie.borderCurve=smoothCorners.borderCurve,ie.borderTopWidth=re.top,ie.borderRightWidth=re.right,ie.borderBottomWidth=re.bottom,ie.borderLeftWidth=re.left;const sideColor=e=>J.interpolate({inputRange:K,outputRange:[Z[e],ee[e],te[e]]}),sameOnEverySide=e=>e.top===e.right&&e.top===e.bottom&&e.top===e.left,de=!le&&ne.tl===ne.tr&&ne.tl===ne.bl&&ne.tl===ne.br&&sameOnEverySide(re)&&sameOnEverySide(Z)&&sameOnEverySide(ee)&&sameOnEverySide(te)&&sameOnEverySide(O.borderDisabled),ae=useSquircle(de,ne.tl);if(ae.active)ie.backgroundColor="transparent",ie.borderTopColor="transparent",ie.borderRightColor="transparent",ie.borderBottomColor="transparent",ie.borderLeftColor="transparent";else if(i){const e=O.borderDisabled;ie.borderTopColor=e.top,ie.borderRightColor=e.right,ie.borderBottomColor=e.bottom,ie.borderLeftColor=e.left}else ie.borderTopColor=sideColor("top"),ie.borderRightColor=sideColor("right"),ie.borderBottomColor=sideColor("bottom"),ie.borderLeftColor=sideColor("left");const ce=i?O.borderDisabled.top:sideColor("top"),be=useRef($);be.current=$,useEffect(()=>{J.setValue(be.current)},[O,J]),void 0!==x&&(ie.width=x),void 0!==y&&(ie.height=y);const ue={disabled:i,...A},pe="top"===c,ge=pe?{alignSelf:"flex-start",marginTop:Math.max(0,((b??G.icon)-G.icon)/2)}:null,me=y??h??G["min-height"],he=(()=>{if(!u)return 0;const e=Math.min(ne.tl,me/2),t=u.left;return e<=0||t>=e?0:Math.ceil(e-Math.sqrt(e*e-(e-t)*(e-t)))})(),fe=u&&re.top>0?_jsx(Animated.View,{pointerEvents:"none",style:{position:"absolute",top:-re.top,left:u.left-re.left,width:u.width,height:re.top+he,backgroundColor:Y}}):null,renderInner=e=>_jsxs(_Fragment,{children:[ae.active&&ae.size?_jsx(SquircleFill,{width:ae.size.width,height:ae.size.height,radius:ne.tl,fill:e&&!i?P.colors["surface-pressed"]:Y,stroke:ce,strokeWidth:re.top,outset:re.top}):null,fe,null!=n?_jsx(View,{style:[N.slot,ge],children:n}):null,null!=n&&d?_jsx(View,{pointerEvents:"none",style:[N.divider,ge,{height:G.icon,backgroundColor:P.colors["field-border"]}]}):null,_jsx(View,{style:[N.content,pe?N.contentTop:null],children:p}),null!=a?_jsx(View,{style:[N.slot,ge],children:a}):null]}),xe=_jsx(Animated.View,{onLayout:ae.onLayout,style:[N.box,ie,W],accessibilityRole:D,accessibilityLabel:q,accessibilityHint:M,accessibilityState:ue,...ariaFromState(ue),testID:E,children:renderInner(!1)});return g&&!m?_jsx(Pressable,{onPress:g,disabled:i,accessible:!1,children:xe}):g?_jsx(Pressable,{onPress:g,disabled:i,accessibilityRole:D??"button",accessibilityLabel:q,accessibilityHint:M,accessibilityState:ue,...ariaFromState(ue),testID:E,children:({pressed:e})=>_jsx(Animated.View,{onLayout:ae.onLayout,style:[N.box,ie,!e||i||ae.active?null:{backgroundColor:P.colors["surface-pressed"]},W],children:renderInner(e)})}):xe};FieldBase.displayName="FieldBase";const buildStyles=()=>StyleSheet.create({box:{flexDirection:"row",alignItems:"center",overflow:"visible"},slot:{alignItems:"center",justifyContent:"center"},divider:{width:1,alignSelf:"center"},content:{flex:1,flexDirection:"row",alignItems:"center"},contentTop:{alignItems:"flex-start"}});export default FieldBase;