@webority/mobile-ui 0.130.3 → 0.131.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 (33) hide show
  1. package/README.md +6 -0
  2. package/dist/canvas-kit/kit.js +157 -70
  3. package/dist/canvas-kit/manifest.json +6 -1
  4. package/dist/canvas-kit/release.json +6 -6
  5. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  6. package/lib/commonjs/components/Confetti/Confetti.js +1 -1
  7. package/lib/commonjs/components/Drawer/Drawer.js +1 -1
  8. package/lib/commonjs/components/FileViewer/useFileViewerZoom.js +1 -1
  9. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  10. package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
  11. package/lib/commonjs/components/MessageList/MessageList.js +1 -1
  12. package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +1 -1
  13. package/lib/commonjs/components/Slider/Slider.js +1 -1
  14. package/lib/commonjs/components/SortableList/SortableList.js +1 -1
  15. package/lib/commonjs/components/Swipeable/Swipeable.js +1 -1
  16. package/lib/commonjs/components/TypingIndicator/TypingIndicator.js +1 -1
  17. package/lib/commonjs/components/ZoomableImage/ZoomableImage.js +1 -1
  18. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  19. package/lib/module/components/Confetti/Confetti.js +1 -1
  20. package/lib/module/components/Drawer/Drawer.js +1 -1
  21. package/lib/module/components/FileViewer/useFileViewerZoom.js +1 -1
  22. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
  23. package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
  24. package/lib/module/components/MessageList/MessageList.js +1 -1
  25. package/lib/module/components/SlideToConfirm/SlideToConfirm.js +1 -1
  26. package/lib/module/components/Slider/Slider.js +1 -1
  27. package/lib/module/components/SortableList/SortableList.js +1 -1
  28. package/lib/module/components/Swipeable/Swipeable.js +1 -1
  29. package/lib/module/components/TypingIndicator/TypingIndicator.js +1 -1
  30. package/lib/module/components/ZoomableImage/ZoomableImage.js +1 -1
  31. package/lib/typescript/commonjs/components/MessageList/MessageList.d.ts +1 -1
  32. package/lib/typescript/module/components/MessageList/MessageList.d.ts +1 -1
  33. package/package.json +7 -7
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFileViewerZoom=exports.ZOOM_REST=void 0;var _react=require("react"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=require("react-native-reanimated");const DOUBLE_TAP_ZOOM=2.5,ZOOM_REST=exports.ZOOM_REST=1.01,clamp=(e,a,t)=>{"worklet";return Math.min(Math.max(e,a),t)},panLimit=(e,a)=>{"worklet";return e*(a-1)/2},useFileViewerZoom=({zoomEnabled:e,maxZoom:a,viewportWidth:t,viewportHeight:i,maxScroll:l})=>{const[u,r]=(0,_react.useState)(1),v=(0,_reactNativeReanimated.useAnimatedRef)(),n=(0,_reactNativeReanimated.useScrollViewOffset)(v),m=(0,_reactNativeReanimated.useSharedValue)(0),c=(0,_reactNativeReanimated.useSharedValue)(0),s=(0,_reactNativeReanimated.useSharedValue)(0),o=(0,_reactNativeReanimated.useSharedValue)(0),d=(0,_reactNativeReanimated.useSharedValue)(1),_=(0,_reactNativeReanimated.useSharedValue)(1),R=(0,_reactNativeReanimated.useSharedValue)(0),N=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),w=(0,_reactNativeReanimated.useSharedValue)(0);(0,_react.useEffect)(()=>{s.value=t,o.value=i,c.value=l},[t,i,l,s,o,c]);const S=(0,_react.useCallback)(()=>{d.value=(0,_reactNativeReanimated.withTiming)(1),R.value=(0,_reactNativeReanimated.withTiming)(0),N.value=(0,_reactNativeReanimated.withTiming)(0),_.value=1,h.value=0,w.value=0,r(1)},[d,_,R,N,h,w]);(0,_react.useEffect)(()=>{e||S()},[e,S]);const p=(0,_react.useCallback)(e=>r(e),[]),O=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native(),[]),T=(0,_react.useMemo)(()=>{const t=Math.max(1,a),i=Math.min(2.5,t),l=_reactNativeGestureHandler.Gesture.Pinch().enabled(e).onStart(()=>{"worklet";_.value=d.value,h.value=R.value,w.value=N.value}).onUpdate(e=>{"worklet";const a=clamp(_.value*e.scale,1,t),i=e.focalX-s.value/2,l=e.focalY-o.value/2,u=a/_.value,r=panLimit(s.value,a),v=panLimit(o.value,a);R.value=clamp(i-(i-h.value)*u,-r,r),N.value=clamp(l-(l-w.value)*u,-v,v),d.value=a}).onEnd(()=>{"worklet";if(d.value<=ZOOM_REST)return d.value=(0,_reactNativeReanimated.withTiming)(1),R.value=(0,_reactNativeReanimated.withTiming)(0),N.value=(0,_reactNativeReanimated.withTiming)(0),_.value=1,h.value=0,w.value=0,void(0,_reactNativeReanimated.runOnJS)(p)(1);_.value=d.value,h.value=R.value,w.value=N.value,(0,_reactNativeReanimated.runOnJS)(p)(d.value)}),u=_reactNativeGestureHandler.Gesture.Pan().enabled(e).minPointers(1).maxPointers(1).manualActivation(!0).onTouchesMove((e,a)=>{"worklet";d.value>ZOOM_REST?a.activate():a.fail()}).onStart(()=>{"worklet";h.value=R.value,w.value=N.value,m.value=n.value}).onUpdate(e=>{"worklet";const a=d.value,t=panLimit(s.value,a),i=panLimit(o.value,a);R.value=clamp(h.value+e.translationX,-t,t);const l=w.value+e.translationY,u=clamp(l,-i,i),r=l-u;if(0!==r){const e=clamp(m.value-r/a,0,c.value);e!==m.value&&(m.value=e,(0,_reactNativeReanimated.scrollTo)(v,0,e,!1)),w.value-=r}N.value=u}).onEnd(()=>{"worklet";h.value=R.value,w.value=N.value}),r=_reactNativeGestureHandler.Gesture.Tap().enabled(e).numberOfTaps(2).maxDistance(10).onEnd(e=>{"worklet";if(d.value>ZOOM_REST)return d.value=(0,_reactNativeReanimated.withTiming)(1),R.value=(0,_reactNativeReanimated.withTiming)(0),N.value=(0,_reactNativeReanimated.withTiming)(0),_.value=1,h.value=0,w.value=0,void(0,_reactNativeReanimated.runOnJS)(p)(1);if(i<=ZOOM_REST)return;const a=e.x-s.value/2,t=e.y-o.value/2,l=panLimit(s.value,i),u=panLimit(o.value,i),r=clamp(-a*(i-1),-l,l),v=clamp(-t*(i-1),-u,u);d.value=(0,_reactNativeReanimated.withTiming)(i),R.value=(0,_reactNativeReanimated.withTiming)(r),N.value=(0,_reactNativeReanimated.withTiming)(v),_.value=i,h.value=r,w.value=v,(0,_reactNativeReanimated.runOnJS)(p)(i)});return l.simultaneousWithExternalGesture(O),u.simultaneousWithExternalGesture(O),r.simultaneousWithExternalGesture(O),_reactNativeGestureHandler.Gesture.Simultaneous(l,u,r)},[a,e,p,O,v,n,m,c,s,o,d,_,R,N,h,w]),f=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:R.value},{translateY:N.value},{scale:d.value}]}));return{scrollRef:v,scrollGesture:O,zoomGesture:T,zoomStyle:f,zoomLevel:u,resetZoom:S}};exports.useFileViewerZoom=useFileViewerZoom;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useFileViewerZoom=exports.ZOOM_REST=void 0;var _react=require("react"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=require("react-native-reanimated");const DOUBLE_TAP_ZOOM=2.5,ZOOM_REST=exports.ZOOM_REST=1.01,clamp=(e,a,t)=>{"worklet";return Math.min(Math.max(e,a),t)},panLimit=(e,a)=>{"worklet";return e*(a-1)/2},useFileViewerZoom=({zoomEnabled:e,maxZoom:a,viewportWidth:t,viewportHeight:i,maxScroll:l})=>{const[u,r]=(0,_react.useState)(1),v=(0,_reactNativeReanimated.useAnimatedRef)(),n=(0,_reactNativeReanimated.useScrollViewOffset)(v),m=(0,_reactNativeReanimated.useSharedValue)(0),c=(0,_reactNativeReanimated.useSharedValue)(0),s=(0,_reactNativeReanimated.useSharedValue)(0),o=(0,_reactNativeReanimated.useSharedValue)(0),d=(0,_reactNativeReanimated.useSharedValue)(1),_=(0,_reactNativeReanimated.useSharedValue)(1),R=(0,_reactNativeReanimated.useSharedValue)(0),N=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),w=(0,_reactNativeReanimated.useSharedValue)(0);(0,_react.useEffect)(()=>{s.value=t,o.value=i,c.value=l},[t,i,l,s,o,c]);const S=(0,_react.useCallback)(()=>{d.value=(0,_reactNativeReanimated.withTiming)(1),R.value=(0,_reactNativeReanimated.withTiming)(0),N.value=(0,_reactNativeReanimated.withTiming)(0),_.value=1,h.value=0,w.value=0,r(1)},[d,_,R,N,h,w]);(0,_react.useEffect)(()=>{e||S()},[e,S]);const p=(0,_react.useCallback)(e=>r(e),[]),O=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native(),[]),T=(0,_react.useMemo)(()=>{const t=Math.max(1,a),i=Math.min(2.5,t),l=_reactNativeGestureHandler.Gesture.Pinch().enabled(e).onStart(()=>{"worklet";_.value=d.value,h.value=R.value,w.value=N.value}).onUpdate(e=>{"worklet";const a=clamp(_.value*e.scale,1,t),i=e.focalX-s.value/2,l=e.focalY-o.value/2,u=a/_.value,r=panLimit(s.value,a),v=panLimit(o.value,a);R.value=clamp(i-(i-h.value)*u,-r,r),N.value=clamp(l-(l-w.value)*u,-v,v),d.value=a}).onEnd(()=>{"worklet";if(d.value<=ZOOM_REST)return d.value=(0,_reactNativeReanimated.withTiming)(1),R.value=(0,_reactNativeReanimated.withTiming)(0),N.value=(0,_reactNativeReanimated.withTiming)(0),_.value=1,h.value=0,w.value=0,void(0,_reactNativeReanimated.runOnJS)(p)(1);_.value=d.value,h.value=R.value,w.value=N.value,(0,_reactNativeReanimated.runOnJS)(p)(d.value)}),u=_reactNativeGestureHandler.Gesture.Pan().enabled(e).minPointers(1).maxPointers(1).manualActivation(!0).onTouchesMove((e,a)=>{"worklet";d.value>ZOOM_REST?a.activate():a.fail()}).onStart(()=>{"worklet";h.value=R.value,w.value=N.value,m.value=n.value}).onUpdate(e=>{"worklet";const a=d.value,t=panLimit(s.value,a),i=panLimit(o.value,a);R.value=clamp(h.value+e.translationX,-t,t);const l=w.value+e.translationY,u=clamp(l,-i,i),r=l-u;if(0!==r){const e=clamp(m.value-r/a,0,c.value);e!==m.value&&(m.value=e,(0,_reactNativeReanimated.scrollTo)(v,0,e,!1)),w.value-=r}N.value=u}).onEnd(()=>{"worklet";h.value=R.value,w.value=N.value}),r=_reactNativeGestureHandler.Gesture.Tap().enabled(e).numberOfTaps(2).maxDistance(10).onEnd(e=>{"worklet";if(d.value>ZOOM_REST)return d.value=(0,_reactNativeReanimated.withTiming)(1),R.value=(0,_reactNativeReanimated.withTiming)(0),N.value=(0,_reactNativeReanimated.withTiming)(0),_.value=1,h.value=0,w.value=0,void(0,_reactNativeReanimated.runOnJS)(p)(1);if(i<=ZOOM_REST)return;const a=e.x-s.value/2,t=e.y-o.value/2,l=panLimit(s.value,i),u=panLimit(o.value,i),r=clamp(-a*(i-1),-l,l),v=clamp(-t*(i-1),-u,u);d.value=(0,_reactNativeReanimated.withTiming)(i),R.value=(0,_reactNativeReanimated.withTiming)(r),N.value=(0,_reactNativeReanimated.withTiming)(v),_.value=i,h.value=r,w.value=v,(0,_reactNativeReanimated.runOnJS)(p)(i)});return l.simultaneousWithExternalGesture(O),u.simultaneousWithExternalGesture(O),r.simultaneousWithExternalGesture(O),_reactNativeGestureHandler.Gesture.Simultaneous(l,u,r)},[a,e,p,O,v,n,m,c,s,o,d,_,R,N,h,w]),f=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:R.value},{translateY:N.value},{scale:d.value}]}),[R,N,d]);return{scrollRef:v,scrollGesture:O,zoomGesture:T,zoomStyle:f,zoomLevel:u,resetZoom:S}};exports.useFileViewerZoom=useFileViewerZoom;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.FloatingActionButtonGroup=exports.FloatingActionButton=exports.DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS=void 0;var cache,_mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var n,i,o=Object.defineProperty,a={__proto__:null,default:e};if(Object(e)!==e)return a;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,a)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((n=o&&Object.getOwnPropertyDescriptor(e,i))&&(n.get||n.set)?o(a,i,n):a[i]=e[i]);return a}const FAB_SIZES=["sm","md","lg"],FAB_TONES=["primary","success","warning","danger","info","neutral"],FAB_POSITIONS=["bottomRight","bottomLeft","bottomCenter"],toneBackground=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["bg-muted"];default:return e.colors.primary}},pressedTintFor=(e,t)=>"neutral"===t?e.colors["surface-pressed"]:_color.ACCENT_PRESSED_TINT,toneForeground=(e,t)=>{if("neutral"===t)return e.colors["text-body"];switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-primary"]}},FloatingActionButton=exports.FloatingActionButton=(0,_react.forwardRef)((e,t)=>{const{icon:n,onPress:i,label:o,collapsed:a=!1,size:r="md",tone:s="primary",position:c,bottomOffset:l,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:_=!1,accessibilityLabel:p,accessibilityHint:b,haptic:g,style:f,containerStyle:v,labelStyle:h,testID:x}=e;(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButton","size",e.size,FAB_SIZES),(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButton","tone",e.tone,FAB_TONES),(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButton","position",e.position,FAB_POSITIONS);const y=!u&&!d,A=(0,_index.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),w=(0,_react.useMemo)(()=>(0,_index.resolveFloatingActionButtonSize)(A,r),[A,r]),N=(0,_react.useMemo)(()=>buildStyles(A),[A]),{scale:S,opacity:I,pressIn:j,pressOut:E}=(0,_usePressAnimation.usePressAnimation)({enabled:y}),F=(0,_usePresenceMotion.usePresenceMotion)(),C=A.space[A.components["floating-action-button"]["edge-offset"]],B=A.space[A.components["floating-action-button"]["bottom-offset"]],P=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,T=F.duration("default");(0,_react.useEffect)(()=>{if(!m)return void(0,_index.setNativeValue)(P,1);const e=_reactNative.Animated.timing(P,{toValue:_?0:1,duration:T,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[m,_,P,T,A.motion.ease["in-out"]]);const O=w.diameter+(l??B)+R.bottom+C,V=P.interpolate({inputRange:[0,1],outputRange:F.range(O,0)}),L=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(P,I),[P,I]),k="string"==typeof o&&o.length>0,D=k&&a,M=F.reduced,z=A.space.sm,G=w["label-padding-x"],U=A.motion.duration.fast,q=A.motion.ease["in-out"],$=(0,_reactNativeReanimated.useSharedValue)(D?1:0),[H,W]=(0,_react.useState)(null);(0,_react.useEffect)(()=>{const e=D?1:0;return $.value=M?e:(0,_reactNativeReanimated.withTiming)(e,{duration:U,easing:_reactNativeReanimated.Easing.bezier(...q)}),()=>(0,_reactNativeReanimated.cancelAnimation)($)},[D,M,$,U,q]);const Y=(0,_react.useCallback)(e=>{const t=Math.ceil(e);W(e=>e===t?e:t)},[]),Z=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({paddingHorizontal:G*(1-$.value)})),Q=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=Math.max(0,1-2*$.value);return null===H?$.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(H+z)*(1-$.value)}}),X=u?A.colors["surface-disabled"]:toneBackground(A,s),J=u?A.colors["text-disabled"]:toneForeground(A,s),K="lg"===r?"md":"sm",ee=d?(0,_jsxRuntime.jsx)(_index2.Spinner,{variant:"circular",size:K,color:J}):(0,_slotIcon.renderSlotIcon)(n,{color:J,size:w.icon,disabled:u}),te=(0,_react.useMemo)(()=>{if(!c)return null;const e=(l??B)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:C};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:C}}},[c,l,R.bottom,B,C]);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[te,{transform:[{translateY:V},{scale:S}],opacity:L},v,f],pointerEvents:m&&_?"none":"auto",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:e=>{if(!y)return;const t=(0,_hapticUtils.resolveHaptic)(g,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),i()},onPressIn:j,onPressOut:E,disabled:!y,accessibilityRole:"button",accessibilityLabel:p,accessibilityHint:b,accessibilityState:{disabled:!y,busy:d},"aria-disabled":!y,"aria-busy":d,testID:x,style:[N.base,k?{height:w.diameter,minWidth:w.diameter,borderRadius:w.diameter/2,..._corners.smoothCorners}:{width:w.diameter,height:w.diameter,borderRadius:w.diameter/2,..._corners.smoothCorners},A.shadow.popover,{backgroundColor:X,opacity:u||d?.55:1}],children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e&&y?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[N.pressedTint,{backgroundColor:pressedTintFor(A,s),borderRadius:w.diameter/2,..._corners.smoothCorners}]}):null,k?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[N.extendedRow,Z],children:[ee,(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[N.labelClip,Q],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{onLayout:e=>Y(e.nativeEvent.layout.width),style:[N.label,{color:J,fontSize:w.text,fontWeight:A.weight.semibold,marginLeft:z},h],numberOfLines:1,children:o})})]}):ee]})})})});FloatingActionButton.displayName="FloatingActionButton";const buildStyles=e=>_reactNative.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},extendedRow:{flexDirection:"row",alignItems:"center"},labelClip:{flexDirection:"row",overflow:"hidden"},label:{includeFontPadding:!1,flexShrink:0}}),FAB_GROUP_MIN_ACTIONS=2,FAB_GROUP_MAX_ACTIONS=6,FAB_GROUP_RANGE="2 to 6",describeActionProblem=e=>e.length<2?`was given ${e.length} action(s); a menu holds 2 to 6.`:e.length>6?`was given ${e.length} actions; a menu holds 2 to 6, so only the first 6 are drawn.`:e.some(e=>"string"!=typeof e.label||""===e.label.trim())?"has an action without a visible `label`; every menu action needs one.":"",DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS=exports.DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS={quickActions:"Quick actions",expanded:(e,t)=>`${e}, expanded, ${t} ${1===t?"action":"actions"}`,collapsed:e=>`${e}, collapsed`},FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:n,actions:i,expanded:o,defaultExpanded:a=!1,onExpandedChange:r,labels:s,position:c="bottomRight",bottomOffset:l,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:_=!1,isScrolling:p=!1,containerStyle:b,secondaryActionStyle:g,labelPillStyle:f,labelStyle:v,testID:h}=e;(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButtonGroup","size",e.size,FAB_SIZES),(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const x=(0,_react.useMemo)(()=>({...DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS,...s}),[s]),y=d??x.quickActions,A=(0,_index.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),w=(0,_react.useMemo)(()=>(0,_index.resolveFloatingActionButtonSize)(A,u),[A,u]),N=(0,_react.useMemo)(()=>buildGroupStyles(A),[A]),S=(0,_usePresenceMotion.usePresenceMotion)(),I=S.duration("default"),j=A.space[A.components["floating-action-button"]["edge-offset"]],E=A.space[A.components["floating-action-button"]["bottom-offset"]],F=A.space[A.components["floating-action-button"]["secondary-gap"]],C=A.components["floating-action-button"]["stagger-ms"],B=(0,_react.useMemo)(()=>i.slice(0,6),[i]),P=B.length,T=(0,_react.useMemo)(()=>B.map((e,t)=>({action:e,index:t})).reverse(),[B]);i.forEach(e=>{(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const O=__DEV__?describeActionProblem(i):"";(0,_react.useEffect)(()=>{__DEV__&&O&&_mobileCore.Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${O}`)},[O]);const V="boolean"==typeof o,[L,k]=(0,_react.useState)(a),D=V?o:L,M=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!_)return void(0,_index.setNativeValue)(M,1);const e=_reactNative.Animated.timing(M,{toValue:p?0:1,duration:I,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[_,p,M,I,A.motion.ease["in-out"]]);const z=_&&p;(0,_react.useEffect)(()=>{z&&D&&(V||k(!1),r?.(!1))},[z,D,V,r]);const G=w.diameter+(l??E)+R.bottom+j,U=M.interpolate({inputRange:[0,1],outputRange:S.range(G,0)}),q=M,$=(0,_react.useRef)((0,_index.createAnimatedValue)(D?1:0)).current,H=(0,_react.useRef)([]),[W,Y]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{const e=H.current;if(e.length!==P){if(e.length<P){const t=e.slice();for(let n=e.length;n<P;n+=1)t.push(new _reactNative.Animated.Value(D?1:0));H.current=t}else H.current=e.slice(0,P);Y(e=>e+1)}},[P]),(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing($,{toValue:D?1:0,duration:I,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0});e.start();const t=H.current.map(e=>_reactNative.Animated.timing(e,{toValue:D?1:0,duration:I,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0})),n=D?t:[...t].reverse(),i=_reactNative.Animated.stagger(C,n);return i.start(),()=>{e.stop(),i.stop()}},[D,$,I,A.motion.ease["in-out"],P,W,C]);const Z=(0,_react.useCallback)(e=>{const t=(0,_hapticUtils.resolveHaptic)(m,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),V||k(e),r?.(e)},[V,r,m]),Q=(0,_react.useRef)(null),X=(0,_react.useRef)(D),J=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(X.current===D)return;X.current=D;const e=J.current;if(J.current=!1,z||e)return;const t=Q.current;t&&("web"===_reactNative.Platform.OS?t.focus?.():_reactNative.AccessibilityInfo.sendAccessibilityEvent(t,"focus")),(0,_announce.announce)(D?x.expanded(y,P):x.collapsed(y))},[D,z,y,P,x]);const K=(0,_react.useCallback)(()=>{Z(!D)},[D,Z]),ee=(0,_react.useCallback)(e=>{!1!==m&&(0,_hapticUtils.triggerHaptic)("selection"),J.current=!0,e.onPress(),V||k(!1),r?.(!1)},[V,r,m]),te=(0,_react.useCallback)(()=>{D&&Z(!1)},[D,Z]);(0,_react.useEffect)(()=>{if(!D)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(Z(!1),!0));return()=>e.remove()},[D,Z]),(0,_react.useEffect)(()=>{if(!D||"web"!==_reactNative.Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&Z(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[D,Z]);const ne=(0,_react.useMemo)(()=>{const e=(l??E)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:j,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:j,alignItems:"flex-end"}}},[c,l,R.bottom,E,j]),slotOffset=e=>-(w.diameter+F)*(e+1),ie=(0,_react.useMemo)(()=>{switch(c){case"bottomLeft":return{left:0,right:0,justifyContent:"flex-start"};case"bottomCenter":return{left:0,right:0,justifyContent:"center"};default:return{left:0,right:0,justifyContent:"flex-end"}}},[c]),oe=.78*w.diameter,ae=(0,_react.useMemo)(()=>{const e=oe+A.space.sm;switch(c){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:w.diameter/2+oe/2+A.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[c,oe,w.diameter,A.space.sm]),re=$.interpolate({inputRange:[0,1],outputRange:[0,.4]}),se=$.interpolate(S.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[D?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:D?"auto":"none",style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:A.colors.scrim,opacity:re}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:te,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:h?`${h}-backdrop`:void 0})}):null,(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:z?"none":"box-none",style:[ne,{transform:[{translateY:U}],opacity:q},b],accessibilityRole:"menu",testID:h,children:[T.map(({action:e,index:t})=>{const n=H.current[t];if(!n)return null;const i=n.interpolate({inputRange:[0,1],outputRange:S.range(0,slotOffset(t))}),o=n.interpolate({inputRange:[0,1],outputRange:S.range(.6,1)}),a=toneBackground(A,e.tone??"primary"),r=toneForeground(A,e.tone??"primary"),s=e.label?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[N.labelSlot,ae],testID:h?`${h}-label-${e.key}`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[N.labelPill,A.shadow.card,{backgroundColor:A.colors.surface,paddingHorizontal:A.space.sm,paddingVertical:A.space.xs,borderRadius:A.radius.sm,..._corners.smoothCorners},f],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{color:A.colors["text-body"],fontSize:A.text.sm.size,fontWeight:A.weight.medium},v],numberOfLines:1,children:e.label})})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:D?"auto":"none",accessibilityElementsHidden:!D,importantForAccessibility:D?"auto":"no-hide-descendants","aria-hidden":!D,style:[N.secondaryRow,ie,{position:"absolute",bottom:0,opacity:n,transform:[{translateY:i},{scale:o}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>ee(e),focusable:D,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[N.fabBase,A.shadow.elevated,{width:oe,height:oe,borderRadius:oe/2,..._corners.smoothCorners,backgroundColor:a},g],testID:h?`${h}-action-${e.key}`:void 0,children:({pressed:t})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[t?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[N.pressedTint,{backgroundColor:pressedTintFor(A,e.tone??"primary"),borderRadius:oe/2,..._corners.smoothCorners}]}):null,(0,_slotIcon.renderSlotIcon)(e.icon,{color:r,size:w.icon,disabled:!1})]})}),s]},e.key)}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:Q,onPress:K,accessibilityRole:"button",accessibilityLabel:y,accessibilityState:{expanded:D},"aria-expanded":D,style:[N.fabBase,A.shadow.popover,{width:w.diameter,height:w.diameter,borderRadius:w.diameter/2,..._corners.smoothCorners,backgroundColor:A.colors.primary}],testID:h?`${h}-primary`:void 0,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[N.pressedTint,{backgroundColor:_color.ACCENT_PRESSED_TINT,borderRadius:w.diameter/2,..._corners.smoothCorners}]}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:n?void 0:{transform:[{rotate:se}]},children:(0,_slotIcon.renderSlotIcon)(D&&n?n:t,{color:A.colors["on-primary"],size:w.icon,disabled:!1})})]})})]})]})};exports.FloatingActionButtonGroup=FloatingActionButtonGroup;const buildGroupStyles=e=>_reactNative.StyleSheet.create({fabBase:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},secondaryRow:{flexDirection:"row",alignItems:"center"},labelSlot:{position:"absolute",top:0,bottom:0,justifyContent:"center"},labelPill:{alignSelf:"auto"}});var _default=exports.default=FloatingActionButton;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.FloatingActionButtonGroup=exports.FloatingActionButton=exports.DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS=void 0;var cache,_mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var n,i,o=Object.defineProperty,a={__proto__:null,default:e};if(Object(e)!==e)return a;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,a)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((n=o&&Object.getOwnPropertyDescriptor(e,i))&&(n.get||n.set)?o(a,i,n):a[i]=e[i]);return a}const FAB_SIZES=["sm","md","lg"],FAB_TONES=["primary","success","warning","danger","info","neutral"],FAB_POSITIONS=["bottomRight","bottomLeft","bottomCenter"],toneBackground=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["bg-muted"];default:return e.colors.primary}},pressedTintFor=(e,t)=>"neutral"===t?e.colors["surface-pressed"]:_color.ACCENT_PRESSED_TINT,toneForeground=(e,t)=>{if("neutral"===t)return e.colors["text-body"];switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-primary"]}},FloatingActionButton=exports.FloatingActionButton=(0,_react.forwardRef)((e,t)=>{const{icon:n,onPress:i,label:o,collapsed:a=!1,size:r="md",tone:s="primary",position:c,bottomOffset:l,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:_=!1,accessibilityLabel:p,accessibilityHint:b,haptic:g,style:f,containerStyle:v,labelStyle:h,testID:x}=e;(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButton","size",e.size,FAB_SIZES),(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButton","tone",e.tone,FAB_TONES),(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButton","position",e.position,FAB_POSITIONS);const y=!u&&!d,A=(0,_index.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),w=(0,_react.useMemo)(()=>(0,_index.resolveFloatingActionButtonSize)(A,r),[A,r]),N=(0,_react.useMemo)(()=>buildStyles(A),[A]),{scale:S,opacity:I,pressIn:j,pressOut:E}=(0,_usePressAnimation.usePressAnimation)({enabled:y}),F=(0,_usePresenceMotion.usePresenceMotion)(),C=A.space[A.components["floating-action-button"]["edge-offset"]],B=A.space[A.components["floating-action-button"]["bottom-offset"]],P=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,T=F.duration("default");(0,_react.useEffect)(()=>{if(!m)return void(0,_index.setNativeValue)(P,1);const e=_reactNative.Animated.timing(P,{toValue:_?0:1,duration:T,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[m,_,P,T,A.motion.ease["in-out"]]);const O=w.diameter+(l??B)+R.bottom+C,V=P.interpolate({inputRange:[0,1],outputRange:F.range(O,0)}),L=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(P,I),[P,I]),k="string"==typeof o&&o.length>0,D=k&&a,M=F.reduced,z=A.space.sm,G=w["label-padding-x"],U=A.motion.duration.fast,q=A.motion.ease["in-out"],$=(0,_reactNativeReanimated.useSharedValue)(D?1:0),[H,W]=(0,_react.useState)(null);(0,_react.useEffect)(()=>{const e=D?1:0;return $.value=M?e:(0,_reactNativeReanimated.withTiming)(e,{duration:U,easing:_reactNativeReanimated.Easing.bezier(...q)}),()=>(0,_reactNativeReanimated.cancelAnimation)($)},[D,M,$,U,q]);const Y=(0,_react.useCallback)(e=>{const t=Math.ceil(e);W(e=>e===t?e:t)},[]),Z=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({paddingHorizontal:G*(1-$.value)}),[G,$]),Q=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=Math.max(0,1-2*$.value);return null===H?$.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(H+z)*(1-$.value)}},[$,H,z]),X=u?A.colors["surface-disabled"]:toneBackground(A,s),J=u?A.colors["text-disabled"]:toneForeground(A,s),K="lg"===r?"md":"sm",ee=d?(0,_jsxRuntime.jsx)(_index2.Spinner,{variant:"circular",size:K,color:J}):(0,_slotIcon.renderSlotIcon)(n,{color:J,size:w.icon,disabled:u}),te=(0,_react.useMemo)(()=>{if(!c)return null;const e=(l??B)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:C};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:C}}},[c,l,R.bottom,B,C]);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[te,{transform:[{translateY:V},{scale:S}],opacity:L},v,f],pointerEvents:m&&_?"none":"auto",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:e=>{if(!y)return;const t=(0,_hapticUtils.resolveHaptic)(g,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),i()},onPressIn:j,onPressOut:E,disabled:!y,accessibilityRole:"button",accessibilityLabel:p,accessibilityHint:b,accessibilityState:{disabled:!y,busy:d},"aria-disabled":!y,"aria-busy":d,testID:x,style:[N.base,k?{height:w.diameter,minWidth:w.diameter,borderRadius:w.diameter/2,..._corners.smoothCorners}:{width:w.diameter,height:w.diameter,borderRadius:w.diameter/2,..._corners.smoothCorners},A.shadow.popover,{backgroundColor:X,opacity:u||d?.55:1}],children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e&&y?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[N.pressedTint,{backgroundColor:pressedTintFor(A,s),borderRadius:w.diameter/2,..._corners.smoothCorners}]}):null,k?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[N.extendedRow,Z],children:[ee,(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[N.labelClip,Q],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{onLayout:e=>Y(e.nativeEvent.layout.width),style:[N.label,{color:J,fontSize:w.text,fontWeight:A.weight.semibold,marginLeft:z},h],numberOfLines:1,children:o})})]}):ee]})})})});FloatingActionButton.displayName="FloatingActionButton";const buildStyles=e=>_reactNative.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},extendedRow:{flexDirection:"row",alignItems:"center"},labelClip:{flexDirection:"row",overflow:"hidden"},label:{includeFontPadding:!1,flexShrink:0}}),FAB_GROUP_MIN_ACTIONS=2,FAB_GROUP_MAX_ACTIONS=6,FAB_GROUP_RANGE="2 to 6",describeActionProblem=e=>e.length<2?`was given ${e.length} action(s); a menu holds 2 to 6.`:e.length>6?`was given ${e.length} actions; a menu holds 2 to 6, so only the first 6 are drawn.`:e.some(e=>"string"!=typeof e.label||""===e.label.trim())?"has an action without a visible `label`; every menu action needs one.":"",DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS=exports.DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS={quickActions:"Quick actions",expanded:(e,t)=>`${e}, expanded, ${t} ${1===t?"action":"actions"}`,collapsed:e=>`${e}, collapsed`},FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:n,actions:i,expanded:o,defaultExpanded:a=!1,onExpandedChange:r,labels:s,position:c="bottomRight",bottomOffset:l,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:_=!1,isScrolling:p=!1,containerStyle:b,secondaryActionStyle:g,labelPillStyle:f,labelStyle:v,testID:h}=e;(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButtonGroup","size",e.size,FAB_SIZES),(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const x=(0,_react.useMemo)(()=>({...DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS,...s}),[s]),y=d??x.quickActions,A=(0,_index.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),w=(0,_react.useMemo)(()=>(0,_index.resolveFloatingActionButtonSize)(A,u),[A,u]),N=(0,_react.useMemo)(()=>buildGroupStyles(A),[A]),S=(0,_usePresenceMotion.usePresenceMotion)(),I=S.duration("default"),j=A.space[A.components["floating-action-button"]["edge-offset"]],E=A.space[A.components["floating-action-button"]["bottom-offset"]],F=A.space[A.components["floating-action-button"]["secondary-gap"]],C=A.components["floating-action-button"]["stagger-ms"],B=(0,_react.useMemo)(()=>i.slice(0,6),[i]),P=B.length,T=(0,_react.useMemo)(()=>B.map((e,t)=>({action:e,index:t})).reverse(),[B]);i.forEach(e=>{(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const O=__DEV__?describeActionProblem(i):"";(0,_react.useEffect)(()=>{__DEV__&&O&&_mobileCore.Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${O}`)},[O]);const V="boolean"==typeof o,[L,k]=(0,_react.useState)(a),D=V?o:L,M=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!_)return void(0,_index.setNativeValue)(M,1);const e=_reactNative.Animated.timing(M,{toValue:p?0:1,duration:I,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[_,p,M,I,A.motion.ease["in-out"]]);const z=_&&p;(0,_react.useEffect)(()=>{z&&D&&(V||k(!1),r?.(!1))},[z,D,V,r]);const G=w.diameter+(l??E)+R.bottom+j,U=M.interpolate({inputRange:[0,1],outputRange:S.range(G,0)}),q=M,$=(0,_react.useRef)((0,_index.createAnimatedValue)(D?1:0)).current,H=(0,_react.useRef)([]),[W,Y]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{const e=H.current;if(e.length!==P){if(e.length<P){const t=e.slice();for(let n=e.length;n<P;n+=1)t.push(new _reactNative.Animated.Value(D?1:0));H.current=t}else H.current=e.slice(0,P);Y(e=>e+1)}},[P]),(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing($,{toValue:D?1:0,duration:I,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0});e.start();const t=H.current.map(e=>_reactNative.Animated.timing(e,{toValue:D?1:0,duration:I,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0})),n=D?t:[...t].reverse(),i=_reactNative.Animated.stagger(C,n);return i.start(),()=>{e.stop(),i.stop()}},[D,$,I,A.motion.ease["in-out"],P,W,C]);const Z=(0,_react.useCallback)(e=>{const t=(0,_hapticUtils.resolveHaptic)(m,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),V||k(e),r?.(e)},[V,r,m]),Q=(0,_react.useRef)(null),X=(0,_react.useRef)(D),J=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(X.current===D)return;X.current=D;const e=J.current;if(J.current=!1,z||e)return;const t=Q.current;t&&("web"===_reactNative.Platform.OS?t.focus?.():_reactNative.AccessibilityInfo.sendAccessibilityEvent(t,"focus")),(0,_announce.announce)(D?x.expanded(y,P):x.collapsed(y))},[D,z,y,P,x]);const K=(0,_react.useCallback)(()=>{Z(!D)},[D,Z]),ee=(0,_react.useCallback)(e=>{!1!==m&&(0,_hapticUtils.triggerHaptic)("selection"),J.current=!0,e.onPress(),V||k(!1),r?.(!1)},[V,r,m]),te=(0,_react.useCallback)(()=>{D&&Z(!1)},[D,Z]);(0,_react.useEffect)(()=>{if(!D)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(Z(!1),!0));return()=>e.remove()},[D,Z]),(0,_react.useEffect)(()=>{if(!D||"web"!==_reactNative.Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&Z(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[D,Z]);const ne=(0,_react.useMemo)(()=>{const e=(l??E)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:j,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:j,alignItems:"flex-end"}}},[c,l,R.bottom,E,j]),slotOffset=e=>-(w.diameter+F)*(e+1),ie=(0,_react.useMemo)(()=>{switch(c){case"bottomLeft":return{left:0,right:0,justifyContent:"flex-start"};case"bottomCenter":return{left:0,right:0,justifyContent:"center"};default:return{left:0,right:0,justifyContent:"flex-end"}}},[c]),oe=.78*w.diameter,ae=(0,_react.useMemo)(()=>{const e=oe+A.space.sm;switch(c){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:w.diameter/2+oe/2+A.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[c,oe,w.diameter,A.space.sm]),re=$.interpolate({inputRange:[0,1],outputRange:[0,.4]}),se=$.interpolate(S.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[D?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:D?"auto":"none",style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:A.colors.scrim,opacity:re}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:te,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:h?`${h}-backdrop`:void 0})}):null,(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:z?"none":"box-none",style:[ne,{transform:[{translateY:U}],opacity:q},b],accessibilityRole:"menu",testID:h,children:[T.map(({action:e,index:t})=>{const n=H.current[t];if(!n)return null;const i=n.interpolate({inputRange:[0,1],outputRange:S.range(0,slotOffset(t))}),o=n.interpolate({inputRange:[0,1],outputRange:S.range(.6,1)}),a=toneBackground(A,e.tone??"primary"),r=toneForeground(A,e.tone??"primary"),s=e.label?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[N.labelSlot,ae],testID:h?`${h}-label-${e.key}`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[N.labelPill,A.shadow.card,{backgroundColor:A.colors.surface,paddingHorizontal:A.space.sm,paddingVertical:A.space.xs,borderRadius:A.radius.sm,..._corners.smoothCorners},f],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{color:A.colors["text-body"],fontSize:A.text.sm.size,fontWeight:A.weight.medium},v],numberOfLines:1,children:e.label})})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:D?"auto":"none",accessibilityElementsHidden:!D,importantForAccessibility:D?"auto":"no-hide-descendants","aria-hidden":!D,style:[N.secondaryRow,ie,{position:"absolute",bottom:0,opacity:n,transform:[{translateY:i},{scale:o}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>ee(e),focusable:D,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[N.fabBase,A.shadow.elevated,{width:oe,height:oe,borderRadius:oe/2,..._corners.smoothCorners,backgroundColor:a},g],testID:h?`${h}-action-${e.key}`:void 0,children:({pressed:t})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[t?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[N.pressedTint,{backgroundColor:pressedTintFor(A,e.tone??"primary"),borderRadius:oe/2,..._corners.smoothCorners}]}):null,(0,_slotIcon.renderSlotIcon)(e.icon,{color:r,size:w.icon,disabled:!1})]})}),s]},e.key)}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:Q,onPress:K,accessibilityRole:"button",accessibilityLabel:y,accessibilityState:{expanded:D},"aria-expanded":D,style:[N.fabBase,A.shadow.popover,{width:w.diameter,height:w.diameter,borderRadius:w.diameter/2,..._corners.smoothCorners,backgroundColor:A.colors.primary}],testID:h?`${h}-primary`:void 0,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[N.pressedTint,{backgroundColor:_color.ACCENT_PRESSED_TINT,borderRadius:w.diameter/2,..._corners.smoothCorners}]}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:n?void 0:{transform:[{rotate:se}]},children:(0,_slotIcon.renderSlotIcon)(D&&n?n:t,{color:A.colors["on-primary"],size:w.icon,disabled:!1})})]})})]})]})};exports.FloatingActionButtonGroup=FloatingActionButtonGroup;const buildGroupStyles=e=>_reactNative.StyleSheet.create({fabBase:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},secondaryRow:{flexDirection:"row",alignItems:"center"},labelSlot:{position:"absolute",top:0,bottom:0,justifyContent:"center"},labelPill:{alignSelf:"auto"}});var _default=exports.default=FloatingActionButton;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ImageGallery=exports.DEFAULT_IMAGE_GALLERY_LABELS=void 0;var cache,_react=_interopRequireWildcard(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"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index3=require("../Carousel/index.js"),_Modal=require("../Modal/Modal.js"),_index4=require("../Skeleton/index.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,i,l=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)&&((t=l&&Object.getOwnPropertyDescriptor(e,i))&&(t.get||t.set)?l(r,i,t):r[i]=e[i]);return r}const DEFAULT_IMAGE_GALLERY_LABELS=exports.DEFAULT_IMAGE_GALLERY_LABELS={gallery:"Image gallery",imageOf:(e,a)=>`Image ${e} of ${a}`,openFullscreen:"Tap to open fullscreen",closeGallery:"Close gallery"},MAX_SCALE_FALLBACK=4,MIN_SCALE_FALLBACK=1,DOUBLE_TAP_SCALE_FALLBACK=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ImageGallery=({images:e,initialIndex:a=0,showThumbnails:t=!0,showCounter:i=!0,enableLightbox:l=!0,enablePinchZoom:r=!0,onIndexChange:n,haptic:s,loading:o=!1,accessibilityLabel:c,containerStyle:u,testID:d,labels:m})=>{const _=(0,_index.useTheme)(),h=(0,_react.useMemo)(()=>buildStyles(_),[_]),g=(0,_react.useMemo)(()=>({...DEFAULT_IMAGE_GALLERY_LABELS,...m}),[m]),[x,v]=(0,_react.useState)(clamp(a,0,Math.max(0,e.length-1))),[p,b]=(0,_react.useState)(!1),R=(0,_react.useCallback)(e=>{v(e),n?.(e)},[n]),S=(0,_react.useCallback)(()=>{if(!l)return;const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),b(!0)},[l,s]),y=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),b(!1)},[s]),I=(0,_react.useCallback)((a,t)=>{const i=a.alt??g.imageOf(t+1,e.length);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:S,accessibilityRole:"image",accessibilityLabel:i,accessibilityHint:l?g.openFullscreen:void 0,style:h.imageWrap,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:a.source,style:h.image,resizeMode:"cover"})})},[l,e.length,S,h,g]),N=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNative.Image,{source:e.source,style:h.thumbnailImage,resizeMode:"cover"}),[h]),j=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[h.container,u],testID:d,accessibilityLabel:c??g.gallery,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:h.carouselWrap,accessibilityElementsHidden:p,importantForAccessibility:p?"no-hide-descendants":"auto",children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{data:e,defaultIndex:a,onIndexChange:R,renderItem:I,showPagination:!1,showThumbnails:t,renderThumbnail:N,haptic:s}),i&&e.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:h.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:"semibold",style:{color:_.colors["on-scrim"]},accessibilityLabel:g.imageOf(x+1,e.length),children:`${x+1} / ${e.length}`})}):null]}),l?(0,_jsxRuntime.jsx)(Lightbox,{open:p,images:e,initialIndex:x,enablePinchZoom:r,showCounter:i,onClose:y,onIndexChange:R,haptic:s,labels:g}):null]});return o?(0,_jsxRuntime.jsx)(ImageGallerySkeleton,{images:e,showThumbnails:t,showCounter:i,containerStyle:u,testID:d}):j};exports.ImageGallery=ImageGallery,ImageGallery.displayName="ImageGallery";const ImageGallerySkeleton=({images:e,showThumbnails:a=!0,showCounter:t=!0,containerStyle:i,testID:l})=>{const r=(0,_index.useTheme)(),n=Math.min(e?.length||4,6);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{width:"100%"},i],testID:l,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{position:"relative"},children:[(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:"100%",height:280,radius:"lg"}),t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",top:12,right:12},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:44,height:22,radius:"pill"})}):null]}),a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:r.space.md},children:Array.from({length:n}).map((e,a)=>(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:64,height:64,radius:"md",style:{marginRight:r.space.sm}},`sk-thumb-${a}`))}):null]})};ImageGallerySkeleton.displayName="ImageGallerySkeleton",ImageGallery.Skeleton=ImageGallerySkeleton;const Lightbox=({open:e,images:a,initialIndex:t,enablePinchZoom:i,showCounter:l,onClose:r,onIndexChange:n,haptic:s,labels:o})=>{const c=(0,_index.useTheme)(),u=(0,_react.useMemo)(()=>buildLightboxStyles(c),[c]),d=(0,_react.useRef)(null),[m,_]=(0,_react.useState)(t),h=(0,_react.useCallback)(e=>{if(e!==m){const a=(0,_index2.resolveHaptic)(s,"selection");a&&(0,_index2.triggerHaptic)(a),_(e),n(e)}},[m,n,s]),g=(0,_react.useCallback)((e,t)=>(0,_jsxRuntime.jsx)(ZoomableImage,{image:e,index:t,total:a.length,active:t===m,enabled:i,maxScale:4,minScale:1,doubleTapScale:2,haptic:s,imageLabel:o.imageOf}),[m,i,a.length,s,o]),x=a[m]?.caption;return(0,_jsxRuntime.jsx)(_Modal.Modal,{open:e,onClose:r,presentation:"fullScreen",backdropPressClose:!1,animateMount:!1,contentStyle:{backgroundColor:"transparent"},children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:u.backdrop,children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{ref:d,data:a,defaultIndex:t,onIndexChange:h,renderItem:g,showPagination:!1,haptic:s}),l&&a.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:"semibold",style:{color:c.colors["on-scrim"]},accessibilityLabel:o.imageOf(m+1,a.length),children:`${m+1} / ${a.length}`})}):null,(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:o.closeGallery,style:u.closeButton,hitSlop:12,...(0,_hitSlop.hitSlopMarker)(12),children:(c.settings.icons.close??_defaultIcons.defaultIcons.close)({size:24,color:c.colors["on-scrim"]})}),x?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:u.captionWrap,entering:void 0,accessibilityElementsHidden:!1,children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",align:"center",numberOfLines:3,style:u.captionText,children:x})}):null]})})},ZoomableImage=({image:e,index:a,total:t,active:i,enabled:l,maxScale:r,minScale:n,doubleTapScale:s,haptic:o,imageLabel:c})=>{const u=_reactNative.Dimensions.get("window"),d=(0,_reactNativeReanimated.useSharedValue)(1),m=(0,_reactNativeReanimated.useSharedValue)(1),_=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),g=(0,_reactNativeReanimated.useSharedValue)(0),x=(0,_reactNativeReanimated.useSharedValue)(0),v=(0,_react.useCallback)(()=>{d.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),m.value=1,_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),g.value=0,x.value=0},[d,m,_,h,g,x]);_react.default.useEffect(()=>{i||(d.value=(0,_reactNativeReanimated.withTiming)(1,{duration:150}),_.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),h.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),m.value=1,g.value=0,x.value=0)},[i,d,_,h,m,g,x]);const p=(0,_react.useCallback)(()=>{!1!==o&&(0,_index2.triggerHaptic)("impactLight")},[o]),b=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pinch().enabled(l).onStart(()=>{"worklet";m.value=d.value}).onUpdate(e=>{"worklet";const a=m.value*e.scale;d.value=a<n?n+.3*(a-n):a>r?r+.2*(a-r):a}).onEnd(()=>{"worklet";return d.value<n?(d.value=(0,_reactNativeReanimated.withSpring)(n,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),m.value=n,g.value=0,void(x.value=0)):d.value>r?(d.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(m.value=r)):void(m.value=d.value)}),[l,d,m,_,h,g,x,n,r]),R=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pan().minPointers(1).maxPointers(1).onStart(()=>{"worklet";g.value=_.value,x.value=h.value}).onUpdate(e=>{"worklet";d.value<=1||(_.value=g.value+e.translationX,h.value=x.value+e.translationY)}).onEnd(()=>{"worklet";g.value=_.value,x.value=h.value}),[d,_,h,g,x]),S=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().numberOfTaps(2).onEnd(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(p)(),d.value>1?(d.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),m.value=1,g.value=0,x.value=0):(d.value=(0,_reactNativeReanimated.withSpring)(s,SPRING_CONFIG),m.value=s)}),[d,m,_,h,g,x,p,s]),y=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Race(b,R,S),[b,R,S]),I=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:_.value},{translateY:h.value},{scale:d.value}]}));_react.default.useEffect(()=>{i||v()},[i,v]);const N=e.alt??c(a+1,t);return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:y,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[lightboxImageStyles.container,{width:u.width}],children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.Image,{source:e.source,resizeMode:"contain",style:[lightboxImageStyles.image,I],accessibilityLabel:N,accessible:!0})})})},clamp=(e,a,t)=>Math.min(Math.max(e,a),t),buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},carouselWrap:{width:"100%",position:"relative"},imageWrap:{width:"100%",aspectRatio:16/9,backgroundColor:e.colors["bg-subtle"],overflow:"hidden",borderRadius:e.radius.md,..._corners.smoothCorners},image:{width:"100%",height:"100%"},thumbnailImage:{width:"100%",height:"100%"},counterPill:{position:"absolute",top:12,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.55)"}}),buildLightboxStyles=e=>_reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:"#000",justifyContent:"center"},counterPill:{position:"absolute",top:48,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.6)"},closeButton:{position:"absolute",top:44,right:16,width:40,height:40,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)"},captionWrap:{position:"absolute",left:0,right:0,bottom:32,paddingHorizontal:e.space.xl},captionText:{color:e.colors["on-scrim"],lineHeight:21}}),lightboxImageStyles=_reactNative.StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"}});var _default=exports.default=ImageGallery;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ImageGallery=exports.DEFAULT_IMAGE_GALLERY_LABELS=void 0;var cache,_react=_interopRequireWildcard(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"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index3=require("../Carousel/index.js"),_Modal=require("../Modal/Modal.js"),_index4=require("../Skeleton/index.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,i,l=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)&&((t=l&&Object.getOwnPropertyDescriptor(e,i))&&(t.get||t.set)?l(r,i,t):r[i]=e[i]);return r}const DEFAULT_IMAGE_GALLERY_LABELS=exports.DEFAULT_IMAGE_GALLERY_LABELS={gallery:"Image gallery",imageOf:(e,a)=>`Image ${e} of ${a}`,openFullscreen:"Tap to open fullscreen",closeGallery:"Close gallery"},MAX_SCALE_FALLBACK=4,MIN_SCALE_FALLBACK=1,DOUBLE_TAP_SCALE_FALLBACK=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ImageGallery=({images:e,initialIndex:a=0,showThumbnails:t=!0,showCounter:i=!0,enableLightbox:l=!0,enablePinchZoom:r=!0,onIndexChange:n,haptic:s,loading:o=!1,accessibilityLabel:c,containerStyle:u,testID:d,labels:m})=>{const _=(0,_index.useTheme)(),h=(0,_react.useMemo)(()=>buildStyles(_),[_]),g=(0,_react.useMemo)(()=>({...DEFAULT_IMAGE_GALLERY_LABELS,...m}),[m]),[x,v]=(0,_react.useState)(clamp(a,0,Math.max(0,e.length-1))),[p,b]=(0,_react.useState)(!1),R=(0,_react.useCallback)(e=>{v(e),n?.(e)},[n]),S=(0,_react.useCallback)(()=>{if(!l)return;const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),b(!0)},[l,s]),y=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),b(!1)},[s]),I=(0,_react.useCallback)((a,t)=>{const i=a.alt??g.imageOf(t+1,e.length);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:S,accessibilityRole:"image",accessibilityLabel:i,accessibilityHint:l?g.openFullscreen:void 0,style:h.imageWrap,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:a.source,style:h.image,resizeMode:"cover"})})},[l,e.length,S,h,g]),N=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNative.Image,{source:e.source,style:h.thumbnailImage,resizeMode:"cover"}),[h]),j=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[h.container,u],testID:d,accessibilityLabel:c??g.gallery,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:h.carouselWrap,accessibilityElementsHidden:p,importantForAccessibility:p?"no-hide-descendants":"auto",children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{data:e,defaultIndex:a,onIndexChange:R,renderItem:I,showPagination:!1,showThumbnails:t,renderThumbnail:N,haptic:s}),i&&e.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:h.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:"semibold",style:{color:_.colors["on-scrim"]},accessibilityLabel:g.imageOf(x+1,e.length),children:`${x+1} / ${e.length}`})}):null]}),l?(0,_jsxRuntime.jsx)(Lightbox,{open:p,images:e,initialIndex:x,enablePinchZoom:r,showCounter:i,onClose:y,onIndexChange:R,haptic:s,labels:g}):null]});return o?(0,_jsxRuntime.jsx)(ImageGallerySkeleton,{images:e,showThumbnails:t,showCounter:i,containerStyle:u,testID:d}):j};exports.ImageGallery=ImageGallery,ImageGallery.displayName="ImageGallery";const ImageGallerySkeleton=({images:e,showThumbnails:a=!0,showCounter:t=!0,containerStyle:i,testID:l})=>{const r=(0,_index.useTheme)(),n=Math.min(e?.length||4,6);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{width:"100%"},i],testID:l,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{position:"relative"},children:[(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:"100%",height:280,radius:"lg"}),t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",top:12,right:12},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:44,height:22,radius:"pill"})}):null]}),a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:r.space.md},children:Array.from({length:n}).map((e,a)=>(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:64,height:64,radius:"md",style:{marginRight:r.space.sm}},`sk-thumb-${a}`))}):null]})};ImageGallerySkeleton.displayName="ImageGallerySkeleton",ImageGallery.Skeleton=ImageGallerySkeleton;const Lightbox=({open:e,images:a,initialIndex:t,enablePinchZoom:i,showCounter:l,onClose:r,onIndexChange:n,haptic:s,labels:o})=>{const c=(0,_index.useTheme)(),u=(0,_react.useMemo)(()=>buildLightboxStyles(c),[c]),d=(0,_react.useRef)(null),[m,_]=(0,_react.useState)(t),h=(0,_react.useCallback)(e=>{if(e!==m){const a=(0,_index2.resolveHaptic)(s,"selection");a&&(0,_index2.triggerHaptic)(a),_(e),n(e)}},[m,n,s]),g=(0,_react.useCallback)((e,t)=>(0,_jsxRuntime.jsx)(ZoomableImage,{image:e,index:t,total:a.length,active:t===m,enabled:i,maxScale:4,minScale:1,doubleTapScale:2,haptic:s,imageLabel:o.imageOf}),[m,i,a.length,s,o]),x=a[m]?.caption;return(0,_jsxRuntime.jsx)(_Modal.Modal,{open:e,onClose:r,presentation:"fullScreen",backdropPressClose:!1,animateMount:!1,contentStyle:{backgroundColor:"transparent"},children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:u.backdrop,children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{ref:d,data:a,defaultIndex:t,onIndexChange:h,renderItem:g,showPagination:!1,haptic:s}),l&&a.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:"semibold",style:{color:c.colors["on-scrim"]},accessibilityLabel:o.imageOf(m+1,a.length),children:`${m+1} / ${a.length}`})}):null,(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:o.closeGallery,style:u.closeButton,hitSlop:12,...(0,_hitSlop.hitSlopMarker)(12),children:(c.settings.icons.close??_defaultIcons.defaultIcons.close)({size:24,color:c.colors["on-scrim"]})}),x?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:u.captionWrap,entering:void 0,accessibilityElementsHidden:!1,children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",align:"center",numberOfLines:3,style:u.captionText,children:x})}):null]})})},ZoomableImage=({image:e,index:a,total:t,active:i,enabled:l,maxScale:r,minScale:n,doubleTapScale:s,haptic:o,imageLabel:c})=>{const u=_reactNative.Dimensions.get("window"),d=(0,_reactNativeReanimated.useSharedValue)(1),m=(0,_reactNativeReanimated.useSharedValue)(1),_=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),g=(0,_reactNativeReanimated.useSharedValue)(0),x=(0,_reactNativeReanimated.useSharedValue)(0),v=(0,_react.useCallback)(()=>{d.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),m.value=1,_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),g.value=0,x.value=0},[d,m,_,h,g,x]);_react.default.useEffect(()=>{i||(d.value=(0,_reactNativeReanimated.withTiming)(1,{duration:150}),_.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),h.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),m.value=1,g.value=0,x.value=0)},[i,d,_,h,m,g,x]);const p=(0,_react.useCallback)(()=>{!1!==o&&(0,_index2.triggerHaptic)("impactLight")},[o]),b=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pinch().enabled(l).onStart(()=>{"worklet";m.value=d.value}).onUpdate(e=>{"worklet";const a=m.value*e.scale;d.value=a<n?n+.3*(a-n):a>r?r+.2*(a-r):a}).onEnd(()=>{"worklet";return d.value<n?(d.value=(0,_reactNativeReanimated.withSpring)(n,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),m.value=n,g.value=0,void(x.value=0)):d.value>r?(d.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(m.value=r)):void(m.value=d.value)}),[l,d,m,_,h,g,x,n,r]),R=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pan().minPointers(1).maxPointers(1).onStart(()=>{"worklet";g.value=_.value,x.value=h.value}).onUpdate(e=>{"worklet";d.value<=1||(_.value=g.value+e.translationX,h.value=x.value+e.translationY)}).onEnd(()=>{"worklet";g.value=_.value,x.value=h.value}),[d,_,h,g,x]),S=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().numberOfTaps(2).onEnd(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(p)(),d.value>1?(d.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),m.value=1,g.value=0,x.value=0):(d.value=(0,_reactNativeReanimated.withSpring)(s,SPRING_CONFIG),m.value=s)}),[d,m,_,h,g,x,p,s]),y=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Race(b,R,S),[b,R,S]),I=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:_.value},{translateY:h.value},{scale:d.value}]}),[_,h,d]);_react.default.useEffect(()=>{i||v()},[i,v]);const N=e.alt??c(a+1,t);return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:y,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[lightboxImageStyles.container,{width:u.width}],children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.Image,{source:e.source,resizeMode:"contain",style:[lightboxImageStyles.image,I],accessibilityLabel:N,accessible:!0})})})},clamp=(e,a,t)=>Math.min(Math.max(e,a),t),buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},carouselWrap:{width:"100%",position:"relative"},imageWrap:{width:"100%",aspectRatio:16/9,backgroundColor:e.colors["bg-subtle"],overflow:"hidden",borderRadius:e.radius.md,..._corners.smoothCorners},image:{width:"100%",height:"100%"},thumbnailImage:{width:"100%",height:"100%"},counterPill:{position:"absolute",top:12,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.55)"}}),buildLightboxStyles=e=>_reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:"#000",justifyContent:"center"},counterPill:{position:"absolute",top:48,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.6)"},closeButton:{position:"absolute",top:44,right:16,width:40,height:40,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)"},captionWrap:{position:"absolute",left:0,right:0,bottom:32,paddingHorizontal:e.space.xl},captionText:{color:e.colors["on-scrim"],lineHeight:21}}),lightboxImageStyles=_reactNative.StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"}});var _default=exports.default=ImageGallery;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_MESSAGE_LIST_LABELS=void 0,exports.MessageList=MessageList,exports.default=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_index2=require("../Badge/index.js"),_index3=require("../DateSeparator/index.js"),_index4=require("../IconButton/index.js"),_index5=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_MESSAGE_LIST_LABELS=exports.DEFAULT_MESSAGE_LIST_LABELS=Object.freeze({today:"Today",yesterday:"Yesterday",jumpToLatest:"Jump to the latest message",newMessages:e=>1===e?"1 new message":`${e} new messages`,unread:"New messages",loadingOlder:"Loading earlier messages"}),JUMP_AT=160,KEEP_POSITION={minIndexForVisible:0,autoscrollToTopThreshold:JUMP_AT},positionOf=(e,t)=>e?t?"middle":"last":t?"first":"single";function MessageList({messages:e,keyExtractor:t,renderMessage:n,getAuthorKey:r,getDate:s,firstUnreadKey:a,onLoadOlder:o,loadingOlder:i=!1,hasOlder:l=!0,typing:u,empty:c,getAnnouncement:d,followNew:_,keyboardAware:m=!0,keyboardOffset:x,labels:p,now:j,onScroll:f,contentContainerStyle:y,style:g,testID:b,...S}){const v=(0,_index.useTheme)(),L=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),h=(0,_useReducedMotion.useReducedMotion)(),E=(0,_react.useMemo)(()=>buildStyles(v),[v]),R=(0,_react.useMemo)(()=>({...DEFAULT_MESSAGE_LIST_LABELS,...p}),[p]),w=x??L.bottom,T=(0,_react.useRef)(null),A=(0,_react.useRef)(!1),[C,M]=(0,_react.useState)(!1),[I,N]=(0,_react.useState)(0),O=(0,_react.useMemo)(()=>{const n=s?e.map(e=>(0,_mobileCore.formatDate)(s(e))):null,o=r?e.map(r):null,i=void 0===a?-1:e.findIndex(e=>t(e)===a);return e.map((t,r)=>{const a=r===e.length-1,l=null!==n&&(a||n[r]!==n[r+1]),u=null!==o&&!a&&o[r+1]===o[r]&&!l&&r!==i,c=null!==o&&r>0&&o[r-1]===o[r]&&(null===n||n[r-1]===n[r])&&r-1!==i;return{groupPosition:positionOf(u,c),day:l&&s?(0,_index3.dayLabel)(s(t),{now:j,labels:R}):null,unread:r===i}})},[e,s,r,a,t,j,R]),k=(0,_react.useCallback)(()=>{T.current?.scrollToOffset({offset:0,animated:!h}),N(0)},[h]),q=e.length>0?t(e[0]):null,D=(0,_react.useRef)(q);(0,_react.useEffect)(()=>{const n=D.current;if(D.current=q,null===n||null===q||n===q)return;const r=e.findIndex(e=>t(e)===n);if(-1===r)return void N(0);const s=e.slice(0,r).reverse();for(const e of s){const t=d?.(e);t&&(0,_announce.announce)(t)}_&&s.some(_)?k():A.current&&N(e=>e+s.length)},[q]);const P=(0,_react.useCallback)(e=>{const t=e.nativeEvent.contentOffset.y>JUMP_AT;t!==A.current&&(A.current=t,M(t),t||N(0)),f?.(e)},[f]),V=(0,_react.useCallback)(()=>{l&&!i&&o?.()},[l,i,o]),F=(0,_react.useCallback)(({item:e,index:t})=>{const r=O[t];return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[r?.day?(0,_jsxRuntime.jsx)(_index3.DateSeparator,{label:r.day}):null,r?.unread?(0,_jsxRuntime.jsx)(_index3.DateSeparator,{label:R.unread,emphasis:!0}):null,n({item:e,index:t,groupPosition:r?.groupPosition??"single"})]})},[O,R.unread,n]),B=(0,_react.useCallback)(e=>t(e),[t]),U=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardChatScrollView,{...e,inverted:!0,offset:w}),[w]),K=I>0?`${R.newMessages(I)}. ${R.jumpToLatest}`:R.jumpToLatest;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[E.root,g],children:[(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",maintainVisibleContentPosition:KEEP_POSITION,...S,ref:T,data:e,renderItem:F,keyExtractor:B,inverted:!0,onScroll:P,onEndReached:o?V:void 0,ListHeaderComponent:u?(0,_jsxRuntime.jsx)(_reactNative.View,{children:u}):null,ListFooterComponent:i?(0,_jsxRuntime.jsx)(_index5.Spinner,{size:"sm",accessibilityLabel:R.loadingOlder,style:E.older}):null,ListEmptyComponent:c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:E.fill,children:c}):null,renderScrollComponent:m?U:void 0,contentContainerStyle:[E.content,0===e.length?E.grow:null,y],testID:b}),C?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E.jump,pointerEvents:"box-none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:E.jumpDisc,children:(0,_jsxRuntime.jsx)(_index4.IconButton,{icon:"arrow-down",accessibilityLabel:K,variant:"ghost",tone:"neutral",onPress:k,testID:b?`${b}-jump`:void 0})}),I>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:E.count,pointerEvents:"none",importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,children:(0,_jsxRuntime.jsx)(_index2.Badge,{value:I,max:99,tone:"primary",size:"sm"})}):null]}):null]})}const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1},content:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm},grow:{flexGrow:1},fill:{flex:1},older:{paddingVertical:e.space.md},jump:{position:"absolute",right:e.space.md,bottom:e.space.md},jumpDisc:{borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors.surface,...e.shadow.elevated},count:{position:"absolute",top:-e.space.xs,right:-e.space.xs}});var _default=exports.default=MessageList;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_MESSAGE_LIST_LABELS=void 0,exports.MessageList=MessageList,exports.default=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_index2=require("../Badge/index.js"),_index3=require("../DateSeparator/index.js"),_index4=require("../IconButton/index.js"),_index5=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_MESSAGE_LIST_LABELS=exports.DEFAULT_MESSAGE_LIST_LABELS=Object.freeze({today:"Today",yesterday:"Yesterday",jumpToLatest:"Jump to the latest message",newMessages:e=>1===e?"1 new message":`${e} new messages`,unread:"New messages",loadingOlder:"Loading earlier messages"}),JUMP_AT=160,FOLLOW_AT=48,KEEP_POSITION={minIndexForVisible:0,autoscrollToTopThreshold:JUMP_AT},positionOf=(e,t)=>e?t?"middle":"last":t?"first":"single";function MessageList({messages:e,keyExtractor:t,renderMessage:n,getAuthorKey:r,getDate:s,firstUnreadKey:a,onLoadOlder:o,loadingOlder:i=!1,hasOlder:l=!0,typing:c,empty:u,getAnnouncement:d,followNew:_,keyboardAware:m=!0,keyboardOffset:x,labels:p,now:f,onScroll:j,onContentSizeChange:y,contentContainerStyle:g,style:b,testID:S,...v}){const L=(0,_index.useTheme)(),h=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),E=(0,_useReducedMotion.useReducedMotion)(),C=(0,_react.useMemo)(()=>buildStyles(L),[L]),R=(0,_react.useMemo)(()=>({...DEFAULT_MESSAGE_LIST_LABELS,...p}),[p]),T=x??h.bottom,w=(0,_react.useRef)(null),A=(0,_react.useRef)(!1),M=(0,_react.useRef)(!0),O=(0,_react.useRef)(0),[I,N]=(0,_react.useState)(!1),[k,q]=(0,_react.useState)(0),D=(0,_react.useMemo)(()=>{const n=s?e.map(e=>(0,_mobileCore.formatDate)(s(e))):null,o=r?e.map(r):null,i=void 0===a?-1:e.findIndex(e=>t(e)===a);return e.map((t,r)=>{const a=r===e.length-1,l=null!==n&&(a||n[r]!==n[r+1]),c=null!==o&&!a&&o[r+1]===o[r]&&!l&&r!==i,u=null!==o&&r>0&&o[r-1]===o[r]&&(null===n||n[r-1]===n[r])&&r-1!==i;return{groupPosition:positionOf(c,u),day:l&&s?(0,_index3.dayLabel)(s(t),{now:f,labels:R}):null,unread:r===i}})},[e,s,r,a,t,f,R]),P=(0,_react.useCallback)(()=>{M.current=!0,w.current?.scrollToOffset({offset:0,animated:!E}),q(0)},[E]),V=e.length>0?t(e[0]):null,F=(0,_react.useRef)(V);(0,_react.useEffect)(()=>{const n=F.current;if(F.current=V,null===n||null===V||n===V)return;const r=e.findIndex(e=>t(e)===n);if(-1===r)return void q(0);const s=e.slice(0,r).reverse();for(const e of s){const t=d?.(e);t&&(0,_announce.announce)(t)}_&&s.some(_)?P():A.current&&q(e=>e+s.length)},[V]);const B=(0,_react.useCallback)(e=>{M.current=e.nativeEvent.contentOffset.y<=FOLLOW_AT;const t=e.nativeEvent.contentOffset.y>JUMP_AT;t!==A.current&&(A.current=t,N(t),t||q(0)),j?.(e)},[j]),U=(0,_react.useCallback)((e,t)=>{const n=t>O.current;O.current=t,n&&M.current&&w.current?.scrollToOffset({offset:0,animated:!1}),y?.(e,t)},[y]),K=(0,_react.useCallback)(()=>{l&&!i&&o?.()},[l,i,o]),z=(0,_react.useCallback)(({item:e,index:t})=>{const r=D[t];return(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[r?.day?(0,_jsxRuntime.jsx)(_index3.DateSeparator,{label:r.day}):null,r?.unread?(0,_jsxRuntime.jsx)(_index3.DateSeparator,{label:R.unread,emphasis:!0}):null,n({item:e,index:t,groupPosition:r?.groupPosition??"single"})]})},[D,R.unread,n]),G=(0,_react.useCallback)(e=>t(e),[t]),J=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardChatScrollView,{...e,inverted:!0,offset:T}),[T]),$=k>0?`${R.newMessages(k)}. ${R.jumpToLatest}`:R.jumpToLatest;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[C.root,b],children:[(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",maintainVisibleContentPosition:KEEP_POSITION,...v,ref:w,data:e,renderItem:z,keyExtractor:G,inverted:!0,onScroll:B,onContentSizeChange:U,onEndReached:o?K:void 0,ListHeaderComponent:c?(0,_jsxRuntime.jsx)(_reactNative.View,{children:c}):null,ListFooterComponent:i?(0,_jsxRuntime.jsx)(_index5.Spinner,{size:"sm",accessibilityLabel:R.loadingOlder,style:C.older}):null,ListEmptyComponent:u?(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.fill,children:u}):null,renderScrollComponent:m?J:void 0,contentContainerStyle:[C.content,0===e.length?C.grow:null,g],testID:S}),I?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:C.jump,pointerEvents:"box-none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.jumpDisc,children:(0,_jsxRuntime.jsx)(_index4.IconButton,{icon:"arrow-down",accessibilityLabel:$,variant:"ghost",tone:"neutral",onPress:P,testID:S?`${S}-jump`:void 0})}),k>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.count,pointerEvents:"none",importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,children:(0,_jsxRuntime.jsx)(_index2.Badge,{value:k,max:99,tone:"primary",size:"sm"})}):null]}):null]})}const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1},content:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm},grow:{flexGrow:1},fill:{flex:1},older:{paddingVertical:e.space.md},jump:{position:"absolute",right:e.space.md,bottom:e.space.md},jumpDisc:{borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors.surface,...e.shadow.elevated},count:{position:"absolute",top:-e.space.xs,right:-e.space.xs}});var _default=exports.default=MessageList;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SlideToConfirm=exports.DEFAULT_SLIDE_TO_CONFIRM_LABELS=void 0;var cache,_react=_interopRequireWildcard(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"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,i=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=i&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?i(n,r,a):n[r]=e[r]);return n}const DEFAULT_SLIDE_TO_CONFIRM_LABELS=exports.DEFAULT_SLIDE_TO_CONFIRM_LABELS=Object.freeze({slide:"Slide to confirm",confirmed:"Confirmed",confirmAction:"Confirm"}),SIZE_MAP={sm:{height:44,pad:"xxs"},md:{height:56,pad:"xs"},lg:{height:64,pad:"sm"}},Chevron=({color:e,size:t})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:0,height:0,borderTopWidth:.4*t,borderBottomWidth:.4*t,borderLeftWidth:.55*t,borderTopColor:"transparent",borderBottomColor:"transparent",borderLeftColor:e,marginLeft:.2*t}}),SlideToConfirm=exports.SlideToConfirm=(0,_react.forwardRef)((e,t)=>{const{onConfirm:a,label:r,tone:i="primary",size:n="md",disabled:o=!1,threshold:l=.9,resetAfter:s=!1,haptic:c,icon:d,labels:u,style:m,trackStyle:_,handleStyle:h,labelStyle:v,testID:f}=e;(0,_warnInvalidValue.warnInvalidValue)("SlideToConfirm","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("SlideToConfirm","size",e.size,["sm","md","lg"]);const p=(0,_react.useMemo)(()=>({...DEFAULT_SLIDE_TO_CONFIRM_LABELS,...u}),[u]),b=(0,_react.useMemo)(()=>[{name:"activate",label:p.confirmAction},{name:"increment",label:p.confirmAction}],[p.confirmAction]),x=(0,_index.useTheme)(),g=SIZE_MAP[n],R=x.space[g.pad],S=g.height-2*R,y=(0,_react.useMemo)(()=>buildStyles(x,g),[x,g]),C=x.colors[i],[j,N]=(0,_react.useState)(!1),w=(0,_reactNativeReanimated.useSharedValue)(0),T=(0,_reactNativeReanimated.useSharedValue)(0),A=(0,_reactNativeReanimated.useSharedValue)(0),E=(0,_react.useRef)(null),L=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(c,"notificationSuccess");e&&(0,_index2.triggerHaptic)(e)},[c]),I=(0,_react.useCallback)(()=>{N(!1),w.value=(0,_reactNativeReanimated.withSpring)(0,{damping:18,stiffness:160,mass:1})},[w]),M=(0,_react.useCallback)(()=>{N(!0),L(),a(),!1!==s&&(E.current&&clearTimeout(E.current),E.current=setTimeout(I,s))},[L,a,s,I]),O=(0,_react.useCallback)(e=>{if(o||j)return;const{actionName:t}=e.nativeEvent;"activate"!==t&&"increment"!==t||M()},[o,j,M]);_react.default.useEffect(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(w),E.current&&clearTimeout(E.current)},[w]);const k=(0,_react.useCallback)(e=>{T.value=Math.max(0,e.nativeEvent.layout.width-S-2*R)},[T,S,R]),V=(0,_react.useMemo)(()=>{const e=l,t={damping:18,stiffness:160,mass:1},a={duration:x.motion.duration.fast,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)};return _reactNativeGestureHandler.Gesture.Pan().enabled(!o&&!j).minDistance(0).onStart(()=>{"worklet";A.value=w.value}).onUpdate(e=>{"worklet";w.value=Math.min(Math.max(A.value+e.translationX,0),T.value)}).onEnd(()=>{"worklet";T.value>0&&w.value>=T.value*e?(w.value=(0,_reactNativeReanimated.withTiming)(T.value,a),(0,_reactNativeReanimated.runOnJS)(M)()):w.value=(0,_reactNativeReanimated.withSpring)(0,t)})},[o,j,l,w,T,A,M,x.motion.duration.fast]),q=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:w.value}]})),D=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({width:w.value+S+R})),W=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=T.value>0?T.value:1;return{opacity:Math.max(0,1-w.value/(.6*e))}});return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[y.track,{backgroundColor:x.colors["bg-subtle"]},_,m],onLayout:k,testID:f,accessibilityRole:"adjustable",accessibilityLabel:j?p.confirmed:r??p.slide,accessibilityState:{disabled:o},"aria-disabled":o,accessibilityActions:b,onAccessibilityAction:O,children:[(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[y.fill,{backgroundColor:C,opacity:o?.5:1},D],pointerEvents:"none"}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[y.labelWrap,W],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",style:[y.label,{color:x.colors["text-muted"]},v],numberOfLines:1,children:j?p.confirmed:r??p.slide})}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:V,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[y.handle,{width:S,height:S,borderRadius:x.radius.pill,..._corners.smoothCorners,backgroundColor:x.colors.surface,opacity:o?.5:1,...x.shadow.card},h,q],children:d??(0,_jsxRuntime.jsx)(Chevron,{color:C,size:.5*S})})})]})});SlideToConfirm.displayName="SlideToConfirm";const buildStyles=(e,t)=>_reactNative.StyleSheet.create({track:{height:t.height,borderRadius:e.radius.pill,..._corners.smoothCorners,justifyContent:"center",overflow:"hidden",padding:e.space[t.pad]},fill:{position:"absolute",left:0,top:0,bottom:0,borderRadius:e.radius.pill,..._corners.smoothCorners},labelWrap:{position:"absolute",left:t.height,right:t.height},label:{textAlign:"center",includeFontPadding:!1},handle:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=SlideToConfirm;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SlideToConfirm=exports.DEFAULT_SLIDE_TO_CONFIRM_LABELS=void 0;var cache,_react=_interopRequireWildcard(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"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,i=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=i&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?i(n,r,a):n[r]=e[r]);return n}const DEFAULT_SLIDE_TO_CONFIRM_LABELS=exports.DEFAULT_SLIDE_TO_CONFIRM_LABELS=Object.freeze({slide:"Slide to confirm",confirmed:"Confirmed",confirmAction:"Confirm"}),SIZE_MAP={sm:{height:44,pad:"xxs"},md:{height:56,pad:"xs"},lg:{height:64,pad:"sm"}},Chevron=({color:e,size:t})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:0,height:0,borderTopWidth:.4*t,borderBottomWidth:.4*t,borderLeftWidth:.55*t,borderTopColor:"transparent",borderBottomColor:"transparent",borderLeftColor:e,marginLeft:.2*t}}),SlideToConfirm=exports.SlideToConfirm=(0,_react.forwardRef)((e,t)=>{const{onConfirm:a,label:r,tone:i="primary",size:n="md",disabled:o=!1,threshold:l=.9,resetAfter:s=!1,haptic:c,icon:d,labels:u,style:m,trackStyle:_,handleStyle:h,labelStyle:v,testID:f}=e;(0,_warnInvalidValue.warnInvalidValue)("SlideToConfirm","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("SlideToConfirm","size",e.size,["sm","md","lg"]);const p=(0,_react.useMemo)(()=>({...DEFAULT_SLIDE_TO_CONFIRM_LABELS,...u}),[u]),b=(0,_react.useMemo)(()=>[{name:"activate",label:p.confirmAction},{name:"increment",label:p.confirmAction}],[p.confirmAction]),x=(0,_index.useTheme)(),g=SIZE_MAP[n],R=x.space[g.pad],S=g.height-2*R,y=(0,_react.useMemo)(()=>buildStyles(x,g),[x,g]),C=x.colors[i],[j,N]=(0,_react.useState)(!1),w=(0,_reactNativeReanimated.useSharedValue)(0),T=(0,_reactNativeReanimated.useSharedValue)(0),A=(0,_reactNativeReanimated.useSharedValue)(0),E=(0,_react.useRef)(null),L=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(c,"notificationSuccess");e&&(0,_index2.triggerHaptic)(e)},[c]),I=(0,_react.useCallback)(()=>{N(!1),w.value=(0,_reactNativeReanimated.withSpring)(0,{damping:18,stiffness:160,mass:1})},[w]),M=(0,_react.useCallback)(()=>{N(!0),L(),a(),!1!==s&&(E.current&&clearTimeout(E.current),E.current=setTimeout(I,s))},[L,a,s,I]),O=(0,_react.useCallback)(e=>{if(o||j)return;const{actionName:t}=e.nativeEvent;"activate"!==t&&"increment"!==t||M()},[o,j,M]);_react.default.useEffect(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(w),E.current&&clearTimeout(E.current)},[w]);const k=(0,_react.useCallback)(e=>{T.value=Math.max(0,e.nativeEvent.layout.width-S-2*R)},[T,S,R]),V=(0,_react.useMemo)(()=>{const e=l,t={damping:18,stiffness:160,mass:1},a={duration:x.motion.duration.fast,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)};return _reactNativeGestureHandler.Gesture.Pan().enabled(!o&&!j).minDistance(0).onStart(()=>{"worklet";A.value=w.value}).onUpdate(e=>{"worklet";w.value=Math.min(Math.max(A.value+e.translationX,0),T.value)}).onEnd(()=>{"worklet";T.value>0&&w.value>=T.value*e?(w.value=(0,_reactNativeReanimated.withTiming)(T.value,a),(0,_reactNativeReanimated.runOnJS)(M)()):w.value=(0,_reactNativeReanimated.withSpring)(0,t)})},[o,j,l,w,T,A,M,x.motion.duration.fast]),q=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:w.value}]}),[w]),D=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({width:w.value+S+R}),[w,S,R]),W=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=T.value>0?T.value:1;return{opacity:Math.max(0,1-w.value/(.6*e))}},[T,w]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[y.track,{backgroundColor:x.colors["bg-subtle"]},_,m],onLayout:k,testID:f,accessibilityRole:"adjustable",accessibilityLabel:j?p.confirmed:r??p.slide,accessibilityState:{disabled:o},"aria-disabled":o,accessibilityActions:b,onAccessibilityAction:O,children:[(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[y.fill,{backgroundColor:C,opacity:o?.5:1},D],pointerEvents:"none"}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[y.labelWrap,W],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",style:[y.label,{color:x.colors["text-muted"]},v],numberOfLines:1,children:j?p.confirmed:r??p.slide})}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:V,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[y.handle,{width:S,height:S,borderRadius:x.radius.pill,..._corners.smoothCorners,backgroundColor:x.colors.surface,opacity:o?.5:1,...x.shadow.card},h,q],children:d??(0,_jsxRuntime.jsx)(Chevron,{color:C,size:.5*S})})})]})});SlideToConfirm.displayName="SlideToConfirm";const buildStyles=(e,t)=>_reactNative.StyleSheet.create({track:{height:t.height,borderRadius:e.radius.pill,..._corners.smoothCorners,justifyContent:"center",overflow:"hidden",padding:e.space[t.pad]},fill:{position:"absolute",left:0,top:0,bottom:0,borderRadius:e.radius.pill,..._corners.smoothCorners},labelWrap:{position:"absolute",left:t.height,right:t.height},label:{textAlign:"center",includeFontPadding:!1},handle:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=SlideToConfirm;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Slider=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("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index4=require("../Text/index.js"),_valueText=require("./valueText.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,i,r=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((a=r&&Object.getOwnPropertyDescriptor(e,i))&&(a.get||a.set)?r(n,i,a):n[i]=e[i]);return n}const VARIANT_SIZE_MAP={inset:{sm:{trackHeight:14,thumbDiameter:10},md:{trackHeight:20,thumbDiameter:14},lg:{trackHeight:26,thumbDiameter:18}},minimal:{sm:{trackHeight:2,thumbDiameter:14},md:{trackHeight:3,thumbDiameter:18},lg:{trackHeight:4,thumbDiameter:22}},bar:{sm:{trackHeight:20,thumbDiameter:20},md:{trackHeight:28,thumbDiameter:28},lg:{trackHeight:36,thumbDiameter:36}}},INSET_RING_RATIO=.3,MIN_THUMB_TOUCH=44,clamp=(e,t,a)=>Math.min(Math.max(e,t),a),snapToStep=(e,t,a,i)=>{if(i<=0)return clamp(e,t,a);const r=Math.round((e-t)/i)*i+t,n=String(i).split(".")[1]?.length??0,s=n>0?Number(r.toFixed(n)):r;return clamp(s,t,a)},BUBBLE_GAP=2,BUBBLE_CARET=8,BUBBLE_WRAP_WIDTH=160,NO_SHADOW={shadowOpacity:0,elevation:0},defaultFormatLabel=e=>String(e),Slider=exports.Slider=(0,_react.forwardRef)((e,t)=>{const{min:a=0,max:i=100,step:r=1,disabled:n=!1,tone:s="primary",size:l="md",variant:c="default",showLabel:o=!1,snapThumb:u=!1,formatLabel:d=defaultFormatLabel,renderLabel:m,accessibilityLabel:h,haptic:_,style:v,containerStyle:b,trackStyle:p,fillStyle:f,thumbStyle:g,labelStyle:R,thumbPressScale:w,labelShowDuration:x,labelOpacity:y,testID:N}=e;(0,_warnInvalidValue.warnInvalidValue)("Slider","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("Slider","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Slider","variant",e.variant,["default","inset","minimal","bar"]);const S=(0,_index2.useTheme)(),k=(0,_react.useMemo)(()=>{const e=(0,_index2.resolveSliderSize)(S,l);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[S,l]),j=(0,_react.useMemo)(()=>"default"===c?k:VARIANT_SIZE_MAP[c][l],[k,l,c]),C="inset"===c?j.trackHeight/2:0,M=S.settings.components.slider?.thumbPressAnimation??!1,V=w??1.1,H=x??S.motion.duration.fast,O=y??1,D=(0,_react.useMemo)(()=>buildStyles(S,j),[S,j]),A=(0,_react.useMemo)(()=>({damping:S.motion.spring.snappy.damping,stiffness:S.motion.spring.snappy.stiffness,mass:S.motion.spring.snappy.mass}),[S.motion.spring.snappy]),[E,T]=(0,_react.useState)(0),I=S.colors[s],W=(0,_valueText.sliderToneInk)(S,s),q=!0===e.range,[P,L]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??(q?[a,i]:a),onChange:e.onChange}),X=(0,_reactNativeReanimated.useSharedValue)(0),B=(0,_reactNativeReanimated.useSharedValue)(0),G=(0,_reactNativeReanimated.useSharedValue)(q?P[0]:P),F=(0,_reactNativeReanimated.useSharedValue)(q?P[1]:P),z=(0,_reactNativeReanimated.useSharedValue)(0),J=(0,_reactNativeReanimated.useSharedValue)(0),U=(0,_reactNativeReanimated.useSharedValue)(1),Z=(0,_reactNativeReanimated.useSharedValue)(1),$="always"===o,K=(0,_reactNativeReanimated.useSharedValue)($?1:0),Q=(0,_reactNativeReanimated.useSharedValue)($?1:0),Y=(0,_react.useMemo)(()=>10**(String(r).split(".")[1]?.length??0),[r]);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(X),(0,_reactNativeReanimated.cancelAnimation)(B),(0,_reactNativeReanimated.cancelAnimation)(U),(0,_reactNativeReanimated.cancelAnimation)(Z),(0,_reactNativeReanimated.cancelAnimation)(K),(0,_reactNativeReanimated.cancelAnimation)(Q)},[X,B,U,Z,K,Q]);const ee=(0,_react.useCallback)((e,t)=>{const r=t-2*C;return i===a||r<=0?C:C+(e-a)/(i-a)*r},[a,i,C]),te=(0,_react.useCallback)((e,t)=>{const n=t-2*C;if(n<=0)return a;const s=clamp((e-C)/n,0,1);return snapToStep(a+s*(i-a),a,i,r)},[a,i,r,C]),ae=(0,_react.useRef)(!1),ie=S.motion.duration.fast,re=(0,_react.useRef)(P);re.current=P;const ne=(0,_react.useRef)(E);ne.current=E;const se=(0,_react.useCallback)((e=!1)=>{const t=ne.current;if(t<=0)return;const place=t=>e?(0,_reactNativeReanimated.withTiming)(t,{duration:ie,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}):t,a=re.current;if(q){const[e,i]=a,r=Math.min(e,i),n=Math.max(e,i);G.value=r,F.value=n,X.value=place(ee(r,t)),B.value=place(ee(n,t))}else{const e=a;G.value=e,F.value=e,X.value=place(ee(e,t))}},[q,ee,G,F,X,B,ie]),[le,ce]=(0,_react.useState)(0),oe=(0,_react.useRef)(!1),ue=(0,_react.useCallback)(e=>{ae.current=e,e||(oe.current=!0,ce(e=>e+1))},[]);(0,_react.useEffect)(()=>{if(ae.current)return;const e=oe.current;oe.current=!1,se(e)},[JSON.stringify(P),E,le,se]);const de=(0,_react.useCallback)(e=>{const t=e.nativeEvent.layout.width;J.value=t,T(t)},[J]),me=(0,_react.useCallback)((e,t)=>{L(q?[e,t]:e)},[q,L]),he=(0,_react.useCallback)(()=>{const e=(0,_index3.resolveHaptic)(_,"selection");e&&(0,_index3.triggerHaptic)(e)},[_]),ve=(0,_react.useRef)(me);ve.current=me;const be=(0,_react.useRef)(he);be.current=he;const pe=(0,_react.useCallback)((e,t)=>ve.current(e,t),[]),fe=(0,_react.useCallback)(()=>be.current(),[]),ge=Math.max(0,(44-j.thumbDiameter)/2),Re=ge>0?ge:void 0,we=(0,_react.useCallback)(e=>{const t="low"===e?X:B,s="low"===e?G:F,l="low"===e?F:G,c="low"===e?U:Z,d="low"===e?K:Q,m="low"===e,h=a,_=i,v=r,b=Y,p=q,f=V,g=M,R=!0===o,w=u,x=O,y=H,N=A,S=C,follow=e=>{"worklet";const a=J.value-2*S;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(z.value+e,S),J.value-S);let r=h+(i-S)/a*(_-h);v>0&&(r=Math.round((r-h)/v)*v+h,r=Math.round(r*b)/b),r=Math.min(Math.max(r,h),_),p&&(m&&r>l.value&&(r=l.value),!m&&r<l.value&&(r=l.value)),t.value=w||_===h?_===h?S:S+(r-h)/(_-h)*a:p?m?Math.min(i,B.value):Math.max(i,X.value):i,r!==s.value&&(s.value=r,r!==h&&r!==_||(0,_reactNativeReanimated.runOnJS)(fe)(),(0,_reactNativeReanimated.runOnJS)(pe)(G.value,F.value))},k=_reactNativeGestureHandler.Gesture.Pan().enabled(!n).minDistance(0);return(void 0===Re?k:k.hitSlop(Re)).onStart(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(ue)(!0),z.value=t.value,g&&(c.value=(0,_reactNativeReanimated.withSpring)(f,N)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(x,{duration:y,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)})),(0,_reactNativeReanimated.runOnJS)(fe)()}).onUpdate(e=>{"worklet";follow(e.translationX)}).onEnd(e=>{"worklet";follow(e.translationX),g&&(c.value=(0,_reactNativeReanimated.withSpring)(1,N)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(0,{duration:y,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}))}).onFinalize(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(ue)(!1)})},[n,a,i,r,Y,q,V,M,o,u,O,H,A,C,Re,pe,fe,ue,X,B,G,F,U,Z,K,Q,z,J]),xe=(0,_react.useMemo)(()=>we("low"),[we]),ye=(0,_react.useMemo)(()=>we("high"),[we]),Ne=(0,_react.useCallback)(e=>{if(n||q||E<=0)return;const t=clamp(e.nativeEvent.locationX,0,E),a=te(t,E);a!==G.value&&(he(),G.value=a,X.value=(0,_reactNativeReanimated.withTiming)(ee(a,E),{duration:S.motion.duration.fast,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}),me(a,a))},[n,q,E,te,ee,me,he,X,G,S.motion.duration.fast]),Se=(0,_react.useCallback)(e=>{if(n)return;const t="increment"===e.nativeEvent.actionName?r:-r,s=r>0?Math.round(t*Y)/Y:t;if(q){const e=Math.round((G.value+s)*Y)/Y,t=clamp(e,a,F.value);t!==G.value&&(G.value=t,X.value=ee(t,E),he(),me(t,F.value))}else{const e=Math.round((G.value+s)*Y)/Y,t=clamp(e,a,i);t!==G.value&&(G.value=t,X.value=ee(t,E),he(),me(t,t))}},[n,r,Y,q,a,i,ee,E,X,G,F,me,he]),ke=j.thumbDiameter/2,je=n?S.colors["surface-disabled"]:I,Ce="inset"===c?{backgroundColor:je,borderColor:S.colors.surface,borderWidth:Math.max(2,Math.round(.3*j.thumbDiameter)),...NO_SHADOW}:"minimal"===c?{backgroundColor:je,borderWidth:0}:"bar"===c?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:S.colors.surface,borderColor:je},Me=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=J.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=n?.55:1;if(q){const a=Math.max(0,B.value-X.value+2*C);return{opacity:t,transform:[{translateX:X.value-C},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:X.value+C-e},{scaleX:1}]}}),Ve=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:X.value-ke},{scale:U.value}]})),He=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:B.value-ke},{scale:Z.value}]})),Oe=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:K.value})),De=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:Q.value})),clampDisplay=e=>clamp(e,a,i),Ae=clampDisplay(q?Math.min(...P):P),Ee=clampDisplay(q?Math.max(...P):P);return(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:[D.container,b,v],testID:N,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:n},"aria-disabled":n,accessibilityValue:q?{min:a,max:i,now:Ae,text:`${Ae} to ${Ee}`}:{min:a,max:i,now:Ae},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Se,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Ne,disabled:n||q,style:D.trackTouch,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:D.trackWrap,onLayout:de,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:D.trackClip,pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.track,{backgroundColor:n?S.colors["surface-disabled"]:S.colors.border},p]}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[D.fill,{backgroundColor:n?S.colors["surface-disabled"]:I},f,Me]})]}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:xe,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[D.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:ke,..._corners.smoothCorners,opacity:n?.55:1},Ce,g,Ve],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[D.bubbleWrap,Oe],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubble,{backgroundColor:I}],children:m?m(Ae):(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",style:[{color:W},R],numberOfLines:1,children:d(Ae)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubbleCaret,{backgroundColor:I}]})]}):null})}),q?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ye,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[D.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:ke,..._corners.smoothCorners,opacity:n?.55:1},Ce,g,He],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[D.bubbleWrap,De],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubble,{backgroundColor:I}],children:m?m(Ee):(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",style:[{color:W},R],numberOfLines:1,children:d(Ee)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubbleCaret,{backgroundColor:I}]})]}):null})}):null]})})})});Slider.displayName="Slider";const buildStyles=(e,t)=>{const a=e.shadow.elevated,i=Math.max(t.thumbDiameter,t.trackHeight),r=i/2+e.space.xs;return _reactNative.StyleSheet.create({container:{width:"100%",paddingVertical:r,justifyContent:"center"},trackTouch:{width:"100%",justifyContent:"center"},trackWrap:{width:"100%",height:i,justifyContent:"center"},trackClip:{position:"absolute",left:0,right:0,height:t.trackHeight,top:(i-t.trackHeight)/2,borderRadius:t.trackHeight/2,..._corners.smoothCorners,overflow:"hidden"},track:{position:"absolute",top:0,right:0,bottom:0,left:0,borderRadius:t.trackHeight/2,..._corners.smoothCorners},fill:{position:"absolute",top:0,left:0,width:"100%",height:t.trackHeight,borderRadius:t.trackHeight/2,..._corners.smoothCorners,transformOrigin:"left"},thumb:{position:"absolute",top:(i-t.thumbDiameter)/2,left:0,borderWidth:2,shadowColor:a.shadowColor,shadowOffset:a.shadowOffset,shadowOpacity:a.shadowOpacity,shadowRadius:a.shadowRadius,elevation:a.elevation,alignItems:"center",justifyContent:"center"},bubbleWrap:{position:"absolute",bottom:t.thumbDiameter+2,left:t.thumbDiameter/2-80,width:160,alignItems:"center"},bubbleCaret:{width:8,height:8,marginTop:-5,borderRadius:e.radius.none,..._corners.smoothCorners,transform:[{rotate:"45deg"}]},bubble:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xxs,borderRadius:e.radius.md,..._corners.smoothCorners,minWidth:36,alignItems:"center",justifyContent:"center",..._reactNative.Platform.select({ios:{shadowColor:e.shadow.card.shadowColor,shadowOffset:e.shadow.card.shadowOffset,shadowOpacity:e.shadow.card.shadowOpacity,shadowRadius:e.shadow.card.shadowRadius},android:{elevation:e.shadow.card.elevation},default:{}})}})};var _default=exports.default=Slider;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Slider=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("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index4=require("../Text/index.js"),_valueText=require("./valueText.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,i,r=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((a=r&&Object.getOwnPropertyDescriptor(e,i))&&(a.get||a.set)?r(n,i,a):n[i]=e[i]);return n}const VARIANT_SIZE_MAP={inset:{sm:{trackHeight:14,thumbDiameter:10},md:{trackHeight:20,thumbDiameter:14},lg:{trackHeight:26,thumbDiameter:18}},minimal:{sm:{trackHeight:2,thumbDiameter:14},md:{trackHeight:3,thumbDiameter:18},lg:{trackHeight:4,thumbDiameter:22}},bar:{sm:{trackHeight:20,thumbDiameter:20},md:{trackHeight:28,thumbDiameter:28},lg:{trackHeight:36,thumbDiameter:36}}},INSET_RING_RATIO=.3,MIN_THUMB_TOUCH=44,clamp=(e,t,a)=>Math.min(Math.max(e,t),a),snapToStep=(e,t,a,i)=>{if(i<=0)return clamp(e,t,a);const r=Math.round((e-t)/i)*i+t,n=String(i).split(".")[1]?.length??0,s=n>0?Number(r.toFixed(n)):r;return clamp(s,t,a)},BUBBLE_GAP=2,BUBBLE_CARET=8,BUBBLE_WRAP_WIDTH=160,NO_SHADOW={shadowOpacity:0,elevation:0},defaultFormatLabel=e=>String(e),Slider=exports.Slider=(0,_react.forwardRef)((e,t)=>{const{min:a=0,max:i=100,step:r=1,disabled:n=!1,tone:s="primary",size:l="md",variant:c="default",showLabel:o=!1,snapThumb:u=!1,formatLabel:d=defaultFormatLabel,renderLabel:m,accessibilityLabel:h,haptic:_,style:v,containerStyle:b,trackStyle:p,fillStyle:f,thumbStyle:g,labelStyle:R,thumbPressScale:w,labelShowDuration:x,labelOpacity:y,testID:N}=e;(0,_warnInvalidValue.warnInvalidValue)("Slider","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("Slider","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Slider","variant",e.variant,["default","inset","minimal","bar"]);const S=(0,_index2.useTheme)(),k=(0,_react.useMemo)(()=>{const e=(0,_index2.resolveSliderSize)(S,l);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[S,l]),j=(0,_react.useMemo)(()=>"default"===c?k:VARIANT_SIZE_MAP[c][l],[k,l,c]),C="inset"===c?j.trackHeight/2:0,M=S.settings.components.slider?.thumbPressAnimation??!1,V=w??1.1,H=x??S.motion.duration.fast,O=y??1,D=(0,_react.useMemo)(()=>buildStyles(S,j),[S,j]),A=(0,_react.useMemo)(()=>({damping:S.motion.spring.snappy.damping,stiffness:S.motion.spring.snappy.stiffness,mass:S.motion.spring.snappy.mass}),[S.motion.spring.snappy]),[E,T]=(0,_react.useState)(0),I=S.colors[s],W=(0,_valueText.sliderToneInk)(S,s),q=!0===e.range,[P,L]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??(q?[a,i]:a),onChange:e.onChange}),X=(0,_reactNativeReanimated.useSharedValue)(0),B=(0,_reactNativeReanimated.useSharedValue)(0),G=(0,_reactNativeReanimated.useSharedValue)(q?P[0]:P),F=(0,_reactNativeReanimated.useSharedValue)(q?P[1]:P),z=(0,_reactNativeReanimated.useSharedValue)(0),J=(0,_reactNativeReanimated.useSharedValue)(0),U=(0,_reactNativeReanimated.useSharedValue)(1),Z=(0,_reactNativeReanimated.useSharedValue)(1),$="always"===o,K=(0,_reactNativeReanimated.useSharedValue)($?1:0),Q=(0,_reactNativeReanimated.useSharedValue)($?1:0),Y=(0,_react.useMemo)(()=>10**(String(r).split(".")[1]?.length??0),[r]);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(X),(0,_reactNativeReanimated.cancelAnimation)(B),(0,_reactNativeReanimated.cancelAnimation)(U),(0,_reactNativeReanimated.cancelAnimation)(Z),(0,_reactNativeReanimated.cancelAnimation)(K),(0,_reactNativeReanimated.cancelAnimation)(Q)},[X,B,U,Z,K,Q]);const ee=(0,_react.useCallback)((e,t)=>{const r=t-2*C;return i===a||r<=0?C:C+(e-a)/(i-a)*r},[a,i,C]),te=(0,_react.useCallback)((e,t)=>{const n=t-2*C;if(n<=0)return a;const s=clamp((e-C)/n,0,1);return snapToStep(a+s*(i-a),a,i,r)},[a,i,r,C]),ae=(0,_react.useRef)(!1),ie=S.motion.duration.fast,re=(0,_react.useRef)(P);re.current=P;const ne=(0,_react.useRef)(E);ne.current=E;const se=(0,_react.useCallback)((e=!1)=>{const t=ne.current;if(t<=0)return;const place=t=>e?(0,_reactNativeReanimated.withTiming)(t,{duration:ie,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}):t,a=re.current;if(q){const[e,i]=a,r=Math.min(e,i),n=Math.max(e,i);G.value=r,F.value=n,X.value=place(ee(r,t)),B.value=place(ee(n,t))}else{const e=a;G.value=e,F.value=e,X.value=place(ee(e,t))}},[q,ee,G,F,X,B,ie]),[le,ce]=(0,_react.useState)(0),oe=(0,_react.useRef)(!1),ue=(0,_react.useCallback)(e=>{ae.current=e,e||(oe.current=!0,ce(e=>e+1))},[]);(0,_react.useEffect)(()=>{if(ae.current)return;const e=oe.current;oe.current=!1,se(e)},[JSON.stringify(P),E,le,se]);const de=(0,_react.useCallback)(e=>{const t=e.nativeEvent.layout.width;J.value=t,T(t)},[J]),me=(0,_react.useCallback)((e,t)=>{L(q?[e,t]:e)},[q,L]),he=(0,_react.useCallback)(()=>{const e=(0,_index3.resolveHaptic)(_,"selection");e&&(0,_index3.triggerHaptic)(e)},[_]),ve=(0,_react.useRef)(me);ve.current=me;const be=(0,_react.useRef)(he);be.current=he;const pe=(0,_react.useCallback)((e,t)=>ve.current(e,t),[]),fe=(0,_react.useCallback)(()=>be.current(),[]),ge=Math.max(0,(44-j.thumbDiameter)/2),Re=ge>0?ge:void 0,we=(0,_react.useCallback)(e=>{const t="low"===e?X:B,s="low"===e?G:F,l="low"===e?F:G,c="low"===e?U:Z,d="low"===e?K:Q,m="low"===e,h=a,_=i,v=r,b=Y,p=q,f=V,g=M,R=!0===o,w=u,x=O,y=H,N=A,S=C,follow=e=>{"worklet";const a=J.value-2*S;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(z.value+e,S),J.value-S);let r=h+(i-S)/a*(_-h);v>0&&(r=Math.round((r-h)/v)*v+h,r=Math.round(r*b)/b),r=Math.min(Math.max(r,h),_),p&&(m&&r>l.value&&(r=l.value),!m&&r<l.value&&(r=l.value)),t.value=w||_===h?_===h?S:S+(r-h)/(_-h)*a:p?m?Math.min(i,B.value):Math.max(i,X.value):i,r!==s.value&&(s.value=r,r!==h&&r!==_||(0,_reactNativeReanimated.runOnJS)(fe)(),(0,_reactNativeReanimated.runOnJS)(pe)(G.value,F.value))},k=_reactNativeGestureHandler.Gesture.Pan().enabled(!n).minDistance(0);return(void 0===Re?k:k.hitSlop(Re)).onStart(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(ue)(!0),z.value=t.value,g&&(c.value=(0,_reactNativeReanimated.withSpring)(f,N)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(x,{duration:y,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)})),(0,_reactNativeReanimated.runOnJS)(fe)()}).onUpdate(e=>{"worklet";follow(e.translationX)}).onEnd(e=>{"worklet";follow(e.translationX),g&&(c.value=(0,_reactNativeReanimated.withSpring)(1,N)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(0,{duration:y,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}))}).onFinalize(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(ue)(!1)})},[n,a,i,r,Y,q,V,M,o,u,O,H,A,C,Re,pe,fe,ue,X,B,G,F,U,Z,K,Q,z,J]),xe=(0,_react.useMemo)(()=>we("low"),[we]),ye=(0,_react.useMemo)(()=>we("high"),[we]),Ne=(0,_react.useCallback)(e=>{if(n||q||E<=0)return;const t=clamp(e.nativeEvent.locationX,0,E),a=te(t,E);a!==G.value&&(he(),G.value=a,X.value=(0,_reactNativeReanimated.withTiming)(ee(a,E),{duration:S.motion.duration.fast,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}),me(a,a))},[n,q,E,te,ee,me,he,X,G,S.motion.duration.fast]),Se=(0,_react.useCallback)(e=>{if(n)return;const t="increment"===e.nativeEvent.actionName?r:-r,s=r>0?Math.round(t*Y)/Y:t;if(q){const e=Math.round((G.value+s)*Y)/Y,t=clamp(e,a,F.value);t!==G.value&&(G.value=t,X.value=ee(t,E),he(),me(t,F.value))}else{const e=Math.round((G.value+s)*Y)/Y,t=clamp(e,a,i);t!==G.value&&(G.value=t,X.value=ee(t,E),he(),me(t,t))}},[n,r,Y,q,a,i,ee,E,X,G,F,me,he]),ke=j.thumbDiameter/2,je=n?S.colors["surface-disabled"]:I,Ce="inset"===c?{backgroundColor:je,borderColor:S.colors.surface,borderWidth:Math.max(2,Math.round(.3*j.thumbDiameter)),...NO_SHADOW}:"minimal"===c?{backgroundColor:je,borderWidth:0}:"bar"===c?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:S.colors.surface,borderColor:je},Me=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=J.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=n?.55:1;if(q){const a=Math.max(0,B.value-X.value+2*C);return{opacity:t,transform:[{translateX:X.value-C},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:X.value+C-e},{scaleX:1}]}},[J,n,q,B,X,C]),Ve=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:X.value-ke},{scale:U.value}]}),[X,ke,U]),He=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:B.value-ke},{scale:Z.value}]}),[B,ke,Z]),Oe=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:K.value}),[K]),De=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:Q.value}),[Q]),clampDisplay=e=>clamp(e,a,i),Ae=clampDisplay(q?Math.min(...P):P),Ee=clampDisplay(q?Math.max(...P):P);return(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:[D.container,b,v],testID:N,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:n},"aria-disabled":n,accessibilityValue:q?{min:a,max:i,now:Ae,text:`${Ae} to ${Ee}`}:{min:a,max:i,now:Ae},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Se,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Ne,disabled:n||q,style:D.trackTouch,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:D.trackWrap,onLayout:de,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:D.trackClip,pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.track,{backgroundColor:n?S.colors["surface-disabled"]:S.colors.border},p]}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[D.fill,{backgroundColor:n?S.colors["surface-disabled"]:I},f,Me]})]}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:xe,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[D.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:ke,..._corners.smoothCorners,opacity:n?.55:1},Ce,g,Ve],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[D.bubbleWrap,Oe],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubble,{backgroundColor:I}],children:m?m(Ae):(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",style:[{color:W},R],numberOfLines:1,children:d(Ae)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubbleCaret,{backgroundColor:I}]})]}):null})}),q?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ye,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[D.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:ke,..._corners.smoothCorners,opacity:n?.55:1},Ce,g,He],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[D.bubbleWrap,De],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubble,{backgroundColor:I}],children:m?m(Ee):(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",style:[{color:W},R],numberOfLines:1,children:d(Ee)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubbleCaret,{backgroundColor:I}]})]}):null})}):null]})})})});Slider.displayName="Slider";const buildStyles=(e,t)=>{const a=e.shadow.elevated,i=Math.max(t.thumbDiameter,t.trackHeight),r=i/2+e.space.xs;return _reactNative.StyleSheet.create({container:{width:"100%",paddingVertical:r,justifyContent:"center"},trackTouch:{width:"100%",justifyContent:"center"},trackWrap:{width:"100%",height:i,justifyContent:"center"},trackClip:{position:"absolute",left:0,right:0,height:t.trackHeight,top:(i-t.trackHeight)/2,borderRadius:t.trackHeight/2,..._corners.smoothCorners,overflow:"hidden"},track:{position:"absolute",top:0,right:0,bottom:0,left:0,borderRadius:t.trackHeight/2,..._corners.smoothCorners},fill:{position:"absolute",top:0,left:0,width:"100%",height:t.trackHeight,borderRadius:t.trackHeight/2,..._corners.smoothCorners,transformOrigin:"left"},thumb:{position:"absolute",top:(i-t.thumbDiameter)/2,left:0,borderWidth:2,shadowColor:a.shadowColor,shadowOffset:a.shadowOffset,shadowOpacity:a.shadowOpacity,shadowRadius:a.shadowRadius,elevation:a.elevation,alignItems:"center",justifyContent:"center"},bubbleWrap:{position:"absolute",bottom:t.thumbDiameter+2,left:t.thumbDiameter/2-80,width:160,alignItems:"center"},bubbleCaret:{width:8,height:8,marginTop:-5,borderRadius:e.radius.none,..._corners.smoothCorners,transform:[{rotate:"45deg"}]},bubble:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xxs,borderRadius:e.radius.md,..._corners.smoothCorners,minWidth:36,alignItems:"center",justifyContent:"center",..._reactNative.Platform.select({ios:{shadowColor:e.shadow.card.shadowColor,shadowOffset:e.shadow.card.shadowOffset,shadowOpacity:e.shadow.card.shadowOpacity,shadowRadius:e.shadow.card.shadowRadius},android:{elevation:e.shadow.card.elevation},default:{}})}})};var _default=exports.default=Slider;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_SORTABLE_LIST_LABELS=void 0,exports.SortableList=SortableList,exports.default=void 0,exports.dropIndex=dropIndex,exports.moveItem=moveItem,exports.rowShifts=rowShifts,exports.slotTop=slotTop,exports.topOf=topOf;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"),_ScrollHost=require("../Screen/ScrollHost.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,l=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=l&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?l(n,r,a):n[r]=e[r]);return n}const DEFAULT_SORTABLE_LIST_LABELS=exports.DEFAULT_SORTABLE_LIST_LABELS=Object.freeze({moveUp:"Move up",moveDown:"Move down"}),LONG_PRESS_MS=350,EDGE_PX=48,SCROLL_STEP_PX=12,SCROLL_SLACK_PX=1,SPRING_CONFIG={damping:22,stiffness:260,mass:1},ACTION_STEP={moveUp:-1,moveDown:1},noop=e=>{};function moveItem(e,t,a){const r=e.slice();if(t<0||t>=r.length)return r;const[l]=r.splice(t,1);return r.splice(a,0,l),r}function topOf(e,t){"worklet";let a=0;for(let r=0;r<t;r++)a+=e[r]??0;return a}function slotTop(e,t,a){"worklet";let r=0,l=0;for(let n=0;n<e.length&&l<a;n++)n!==t&&(r+=e[n]??0,l++);return r}function dropIndex(e,t,a){"worklet";const r=topOf(e,t)+(e[t]??0)/2+a;let l=0,n=0;for(let a=0;a<e.length;a++){const i=e[a]??0;a!==t&&n+i/2<r&&l++,n+=i}return l}function rowShifts(e,t,a){const r=[];let l=0;for(const t of e)r.push(l),l+=t;const n=e.map(()=>0),i=moveItem(e.map((e,t)=>t),t,a);let o=0;for(const t of i)n[t]=o-(r[t]??0),o+=e[t]??0;return n}const buildStyles=e=>_reactNative.StyleSheet.create({handleRow:{flexDirection:"row",alignItems:"center"},handle:{paddingHorizontal:e.space.sm,paddingVertical:e.space.md,gap:e.space.xxs},bar:{width:e.space.md,height:e.space.xxs,backgroundColor:e.colors["text-muted"]},body:{flex:1}});function SortableRow({rowKey:e,index:t,count:a,shift:r,isActive:l,dragging:n,handle:i,disabled:o,shared:s,callbacks:c,labels:u,children:d}){const v=(0,_index.useTheme)(),_=(0,_react.useMemo)(()=>buildStyles(v),[v]),m=(0,_reactNativeReanimated.useSharedValue)(0);(0,_react.useEffect)(()=>{m.value=n&&!l?(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG):r},[n,l,r,m]),(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(m)},[m]);const S=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateY:l?s.dragY.value:m.value}],zIndex:l?1:0})),h=(0,_react.useMemo)(()=>{const{dragIndex:e,dropTo:a,dragY:r,translation:l,absoluteY:n,scrollY:u,scrollStart:d,hostOffset:v,hostStart:_,hostTarget:m,heights:S}=s,{onLift:h,onDrop:f,onSettled:p}=c,R=_reactNativeGestureHandler.Gesture.Pan().enabled(!o).onStart(i=>{"worklet";n.value=i.absoluteY,e.value=t,a.value=t,d.value=u.value,_.value=v.value,m.value=v.value,l.value=0,r.value=0,(0,_reactNativeReanimated.runOnJS)(h)(t)}).onUpdate(a=>{"worklet";e.value===t&&(l.value=a.translationY,n.value=a.absoluteY)}).onFinalize(()=>{"worklet";if(e.value!==t)return;const l=a.value,n=S.value;e.value=-1,r.value=topOf(n,t)+r.value-slotTop(n,t,l),r.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(p)()}),(0,_reactNativeReanimated.runOnJS)(f)(t,l)});return i?R:R.activateAfterLongPress(350)},[o,i,t,c,s]),f=o?[]:[...t>0?[{name:"moveUp",label:u.moveUp}]:[],...t<a-1?[{name:"moveDown",label:u.moveDown}]:[]];return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:S,onLayout:t=>c.onHeight(e,t.nativeEvent.layout.height),accessibilityActions:f,onAccessibilityAction:e=>{if(o)return;const r=t+(ACTION_STEP[e.nativeEvent.actionName]??0);r!==t&&r>=0&&r<a&&c.onMove(t,r)},testID:`sortable-row-${e}`,children:i?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.handleRow,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:h,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.handle,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.body,children:d})]}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:h,children:(0,_jsxRuntime.jsx)(_reactNative.View,{children:d})})})}function SortableList(e){const{data:t,keyExtractor:a,renderItem:r,onReorder:l,handle:n=!1,disabled:i=!1,accessibilityLabel:o,labels:s,testID:c}=e,u=(0,_react.useMemo)(()=>({...DEFAULT_SORTABLE_LIST_LABELS,...s}),[s]),d=(0,_react.useMemo)(()=>t.map((e,t)=>({key:a(e,t),item:e})),[t,a]),v=(0,_react.useMemo)(()=>d.map(e=>e.key),[d]),_=(0,_reactNativeReanimated.useAnimatedRef)(),m=(0,_reactNativeReanimated.useSharedValue)(0),S=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),f=(0,_ScrollHost.useScrollHost)(),p=(0,_reactNativeReanimated.useSharedValue)(0),R=null!==f,g=f?.top??p,x=f?.bottom??p,N=f?.offset??p,b=f?.maxOffset??p,L=f?.scrollTo??noop,w=(0,_reactNativeReanimated.useSharedValue)(0),O=(0,_reactNativeReanimated.useSharedValue)(0),y=(0,_reactNativeReanimated.useSharedValue)(0),E=(0,_reactNativeReanimated.useSharedValue)(0),j=(0,_reactNativeReanimated.useSharedValue)(-1),T=(0,_reactNativeReanimated.useSharedValue)(-1),k=(0,_reactNativeReanimated.useSharedValue)(0),A=(0,_reactNativeReanimated.useSharedValue)([]),I=(0,_react.useRef)(new Map),P=(0,_react.useRef)(v),[C,M]=(0,_react.useState)(null),V=(0,_react.useCallback)(()=>{A.value=P.current.map(e=>I.current.get(e)??0)},[A]);(0,_react.useEffect)(()=>{P.current=v,V()},[v,V]),(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(k)},[k]);const D=(0,_react.useCallback)(e=>{M(t=>t?.dragging?{...t,to:e}:t)},[]),G=(0,_reactNativeReanimated.useFrameCallback)(()=>{"worklet";const e=j.value;if(e<0)return;const t=(0,_reactNativeReanimated.measure)(_);if(t){const e=R?Math.max(t.pageY,g.value):t.pageY,a=R?Math.min(t.pageY+t.height,x.value):t.pageY+t.height,r=Math.max(0,h.value-t.height-SCROLL_SLACK_PX);E.value<e+EDGE_PX?m.value>SCROLL_SLACK_PX?(0,_reactNativeReanimated.scrollTo)(_,0,Math.max(0,m.value-SCROLL_STEP_PX),!1):R&&O.value>0&&(O.value=Math.max(0,O.value-SCROLL_STEP_PX),(0,_reactNativeReanimated.runOnJS)(L)(O.value)):E.value>a-EDGE_PX&&(m.value<r?(0,_reactNativeReanimated.scrollTo)(_,0,Math.min(r,m.value+SCROLL_STEP_PX),!1):R&&O.value<b.value&&(O.value=Math.min(b.value,O.value+SCROLL_STEP_PX),(0,_reactNativeReanimated.runOnJS)(L)(O.value)))}k.value=y.value+m.value-S.value+N.value-w.value;const a=dropIndex(A.value,e,k.value);a!==T.value&&(T.value=a,(0,_reactNativeReanimated.runOnJS)(D)(a))},!1),Y=(0,_react.useCallback)(e=>{(0,_index2.triggerHaptic)("longPress"),G.setActive(!0),M({key:v[e]??"",from:e,to:e,dragging:!0})},[G,v]),H=(0,_react.useCallback)((e,t)=>{G.setActive(!1),M(e=>e?{...e,to:t,dragging:!1}:e),t!==e&&l(moveItem(v,e,t))},[G,v,l]),X=(0,_react.useCallback)(()=>{M(e=>e&&!e.dragging?null:e)},[]),q=(0,_react.useCallback)((e,t)=>{l(moveItem(v,e,t))},[v,l]),F=(0,_react.useCallback)((e,t)=>{I.current.set(e,t),V()},[V]),U=(0,_reactNativeReanimated.useAnimatedScrollHandler)({onScroll:e=>{"worklet";m.value=e.contentOffset.y}}),B=(0,_react.useCallback)((e,t)=>{h.value=t},[h]),J=(0,_react.useMemo)(()=>({scrollRef:_,scrollY:m,scrollStart:S,hostOffset:N,hostStart:w,hostTarget:O,translation:y,absoluteY:E,dragIndex:j,dropTo:T,dragY:k,heights:A}),[_,m,S,N,w,O,y,E,j,T,k,A]),z=(0,_react.useMemo)(()=>({onLift:Y,onDrop:H,onSettled:X,onMove:q,onHeight:F}),[Y,H,X,q,F]),K=!0===C?.dragging,W=K&&C?rowShifts(v.map(e=>I.current.get(e)??0),C.from,C.to):null;return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.ScrollView,{ref:_,onScroll:U,onContentSizeChange:B,scrollEventThrottle:16,scrollEnabled:!K,accessibilityLabel:o,testID:c,children:d.map((e,t)=>{const a=C?.key===e.key;return(0,_jsxRuntime.jsx)(SortableRow,{rowKey:e.key,index:t,count:d.length,shift:W?.[t]??0,isActive:a,dragging:K,handle:n,disabled:i,shared:J,callbacks:z,labels:u,children:r({item:e.item,index:t,isActive:a})},e.key)})})}SortableList.displayName="SortableList";var _default=exports.default=SortableList;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_SORTABLE_LIST_LABELS=void 0,exports.SortableList=SortableList,exports.default=void 0,exports.dropIndex=dropIndex,exports.moveItem=moveItem,exports.rowShifts=rowShifts,exports.slotTop=slotTop,exports.topOf=topOf;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"),_ScrollHost=require("../Screen/ScrollHost.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,l=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=l&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?l(n,r,a):n[r]=e[r]);return n}const DEFAULT_SORTABLE_LIST_LABELS=exports.DEFAULT_SORTABLE_LIST_LABELS=Object.freeze({moveUp:"Move up",moveDown:"Move down"}),LONG_PRESS_MS=350,EDGE_PX=48,SCROLL_STEP_PX=12,SCROLL_SLACK_PX=1,SPRING_CONFIG={damping:22,stiffness:260,mass:1},ACTION_STEP={moveUp:-1,moveDown:1},noop=e=>{};function moveItem(e,t,a){const r=e.slice();if(t<0||t>=r.length)return r;const[l]=r.splice(t,1);return r.splice(a,0,l),r}function topOf(e,t){"worklet";let a=0;for(let r=0;r<t;r++)a+=e[r]??0;return a}function slotTop(e,t,a){"worklet";let r=0,l=0;for(let n=0;n<e.length&&l<a;n++)n!==t&&(r+=e[n]??0,l++);return r}function dropIndex(e,t,a){"worklet";const r=topOf(e,t)+(e[t]??0)/2+a;let l=0,n=0;for(let a=0;a<e.length;a++){const i=e[a]??0;a!==t&&n+i/2<r&&l++,n+=i}return l}function rowShifts(e,t,a){const r=[];let l=0;for(const t of e)r.push(l),l+=t;const n=e.map(()=>0),i=moveItem(e.map((e,t)=>t),t,a);let o=0;for(const t of i)n[t]=o-(r[t]??0),o+=e[t]??0;return n}const buildStyles=e=>_reactNative.StyleSheet.create({handleRow:{flexDirection:"row",alignItems:"center"},handle:{paddingHorizontal:e.space.sm,paddingVertical:e.space.md,gap:e.space.xxs},bar:{width:e.space.md,height:e.space.xxs,backgroundColor:e.colors["text-muted"]},body:{flex:1}});function SortableRow({rowKey:e,index:t,count:a,shift:r,isActive:l,dragging:n,handle:i,disabled:o,shared:s,callbacks:c,labels:u,children:d}){const v=(0,_index.useTheme)(),_=(0,_react.useMemo)(()=>buildStyles(v),[v]),m=(0,_reactNativeReanimated.useSharedValue)(0);(0,_react.useEffect)(()=>{m.value=n&&!l?(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG):r},[n,l,r,m]),(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(m)},[m]);const S=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateY:l?s.dragY.value:m.value}],zIndex:l?1:0}),[l,s,m]),h=(0,_react.useMemo)(()=>{const{dragIndex:e,dropTo:a,dragY:r,translation:l,absoluteY:n,scrollY:u,scrollStart:d,hostOffset:v,hostStart:_,hostTarget:m,heights:S}=s,{onLift:h,onDrop:f,onSettled:p}=c,R=_reactNativeGestureHandler.Gesture.Pan().enabled(!o).onStart(i=>{"worklet";n.value=i.absoluteY,e.value=t,a.value=t,d.value=u.value,_.value=v.value,m.value=v.value,l.value=0,r.value=0,(0,_reactNativeReanimated.runOnJS)(h)(t)}).onUpdate(a=>{"worklet";e.value===t&&(l.value=a.translationY,n.value=a.absoluteY)}).onFinalize(()=>{"worklet";if(e.value!==t)return;const l=a.value,n=S.value;e.value=-1,r.value=topOf(n,t)+r.value-slotTop(n,t,l),r.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(p)()}),(0,_reactNativeReanimated.runOnJS)(f)(t,l)});return i?R:R.activateAfterLongPress(350)},[o,i,t,c,s]),f=o?[]:[...t>0?[{name:"moveUp",label:u.moveUp}]:[],...t<a-1?[{name:"moveDown",label:u.moveDown}]:[]];return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:S,onLayout:t=>c.onHeight(e,t.nativeEvent.layout.height),accessibilityActions:f,onAccessibilityAction:e=>{if(o)return;const r=t+(ACTION_STEP[e.nativeEvent.actionName]??0);r!==t&&r>=0&&r<a&&c.onMove(t,r)},testID:`sortable-row-${e}`,children:i?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.handleRow,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:h,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.handle,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.body,children:d})]}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:h,children:(0,_jsxRuntime.jsx)(_reactNative.View,{children:d})})})}function SortableList(e){const{data:t,keyExtractor:a,renderItem:r,onReorder:l,handle:n=!1,disabled:i=!1,accessibilityLabel:o,labels:s,testID:c}=e,u=(0,_react.useMemo)(()=>({...DEFAULT_SORTABLE_LIST_LABELS,...s}),[s]),d=(0,_react.useMemo)(()=>t.map((e,t)=>({key:a(e,t),item:e})),[t,a]),v=(0,_react.useMemo)(()=>d.map(e=>e.key),[d]),_=(0,_reactNativeReanimated.useAnimatedRef)(),m=(0,_reactNativeReanimated.useSharedValue)(0),S=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),f=(0,_ScrollHost.useScrollHost)(),p=(0,_reactNativeReanimated.useSharedValue)(0),R=null!==f,g=f?.top??p,x=f?.bottom??p,N=f?.offset??p,b=f?.maxOffset??p,L=f?.scrollTo??noop,w=(0,_reactNativeReanimated.useSharedValue)(0),O=(0,_reactNativeReanimated.useSharedValue)(0),y=(0,_reactNativeReanimated.useSharedValue)(0),E=(0,_reactNativeReanimated.useSharedValue)(0),j=(0,_reactNativeReanimated.useSharedValue)(-1),T=(0,_reactNativeReanimated.useSharedValue)(-1),k=(0,_reactNativeReanimated.useSharedValue)(0),A=(0,_reactNativeReanimated.useSharedValue)([]),I=(0,_react.useRef)(new Map),P=(0,_react.useRef)(v),[C,M]=(0,_react.useState)(null),V=(0,_react.useCallback)(()=>{A.value=P.current.map(e=>I.current.get(e)??0)},[A]);(0,_react.useEffect)(()=>{P.current=v,V()},[v,V]),(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(k)},[k]);const D=(0,_react.useCallback)(e=>{M(t=>t?.dragging?{...t,to:e}:t)},[]),G=(0,_reactNativeReanimated.useFrameCallback)(()=>{"worklet";const e=j.value;if(e<0)return;const t=(0,_reactNativeReanimated.measure)(_);if(t){const e=R?Math.max(t.pageY,g.value):t.pageY,a=R?Math.min(t.pageY+t.height,x.value):t.pageY+t.height,r=Math.max(0,h.value-t.height-SCROLL_SLACK_PX);E.value<e+EDGE_PX?m.value>SCROLL_SLACK_PX?(0,_reactNativeReanimated.scrollTo)(_,0,Math.max(0,m.value-SCROLL_STEP_PX),!1):R&&O.value>0&&(O.value=Math.max(0,O.value-SCROLL_STEP_PX),(0,_reactNativeReanimated.runOnJS)(L)(O.value)):E.value>a-EDGE_PX&&(m.value<r?(0,_reactNativeReanimated.scrollTo)(_,0,Math.min(r,m.value+SCROLL_STEP_PX),!1):R&&O.value<b.value&&(O.value=Math.min(b.value,O.value+SCROLL_STEP_PX),(0,_reactNativeReanimated.runOnJS)(L)(O.value)))}k.value=y.value+m.value-S.value+N.value-w.value;const a=dropIndex(A.value,e,k.value);a!==T.value&&(T.value=a,(0,_reactNativeReanimated.runOnJS)(D)(a))},!1),Y=(0,_react.useCallback)(e=>{(0,_index2.triggerHaptic)("longPress"),G.setActive(!0),M({key:v[e]??"",from:e,to:e,dragging:!0})},[G,v]),H=(0,_react.useCallback)((e,t)=>{G.setActive(!1),M(e=>e?{...e,to:t,dragging:!1}:e),t!==e&&l(moveItem(v,e,t))},[G,v,l]),X=(0,_react.useCallback)(()=>{M(e=>e&&!e.dragging?null:e)},[]),q=(0,_react.useCallback)((e,t)=>{l(moveItem(v,e,t))},[v,l]),F=(0,_react.useCallback)((e,t)=>{I.current.set(e,t),V()},[V]),U=(0,_reactNativeReanimated.useAnimatedScrollHandler)({onScroll:e=>{"worklet";m.value=e.contentOffset.y}}),B=(0,_react.useCallback)((e,t)=>{h.value=t},[h]),J=(0,_react.useMemo)(()=>({scrollRef:_,scrollY:m,scrollStart:S,hostOffset:N,hostStart:w,hostTarget:O,translation:y,absoluteY:E,dragIndex:j,dropTo:T,dragY:k,heights:A}),[_,m,S,N,w,O,y,E,j,T,k,A]),z=(0,_react.useMemo)(()=>({onLift:Y,onDrop:H,onSettled:X,onMove:q,onHeight:F}),[Y,H,X,q,F]),K=!0===C?.dragging,W=K&&C?rowShifts(v.map(e=>I.current.get(e)??0),C.from,C.to):null;return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.ScrollView,{ref:_,onScroll:U,onContentSizeChange:B,scrollEventThrottle:16,scrollEnabled:!K,accessibilityLabel:o,testID:c,children:d.map((e,t)=>{const a=C?.key===e.key;return(0,_jsxRuntime.jsx)(SortableRow,{rowKey:e.key,index:t,count:d.length,shift:W?.[t]??0,isActive:a,dragging:K,handle:n,disabled:i,shared:J,callbacks:z,labels:u,children:r({item:e.item,index:t,isActive:a})},e.key)})})}SortableList.displayName="SortableList";var _default=exports.default=SortableList;
@@ -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"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,n,i=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(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((a=i&&Object.getOwnPropertyDescriptor(e,n))&&(a.get||a.set)?i(r,n,a):r[n]=e[n]);return r}const SPRING_CONFIG={damping:22,stiffness:260,mass:1},DRAG_ACTIVATION_OFFSET=10,RUBBER_BAND_FACTOR=.35,FAIL_OFFSET_Y=15,ACTION_ICON_SIZE=20,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;case"info":return e.colors.info;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"];case"info":return e.colors["on-info"];default:return e.colors["on-neutral"]}},Swipeable=e=>{const{children:t,leftActions:a,rightActions:n,threshold:i,fullSwipeThreshold:r,onSwipeOpen:s,onSwipeClose:c,disabled:o=!1,haptic:l,containerStyle:u,contentStyle:d,actionStyle:_,accessibilityLabel:m,testID:v}=e,h=(0,_index.useTheme)(),p=i??80,w=r??200,S=(0,_react.useMemo)(()=>buildStyles(h),[h]),b=(0,_react.useMemo)(()=>buildActionStyles(h),[h]),f=!!a&&a.length>0,N=!!n&&n.length>0,R=_reactNative.Dimensions.get("window").width,x=f?p*(a?.length??0):0,g=N?p*(n?.length??0):0,y=(0,_reactNativeReanimated.useSharedValue)(0),I=(0,_reactNativeReanimated.useSharedValue)(0),j=(0,_react.useRef)(null);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(y),(0,_reactNativeReanimated.cancelAnimation)(I)},[y,I]);const O=(0,_react.useCallback)(e=>{j.current!==e&&(j.current=e,s?.(e))},[s]),C=(0,_react.useCallback)(()=>{null!==j.current&&(j.current=null,c?.())},[c]),A=(0,_react.useCallback)(e=>{const t="left"===e?a:n,i=t?.[0];i&&(!1!==l&&(0,_index2.triggerHaptic)("notificationSuccess"),i.onPress(),y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),j.current=null,c?.())},[a,n,y,c,l]),G=(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(),G()},[G,l]),k=(0,_react.useMemo)(()=>{const e=x,t=g,a=w,n=-w,i=R,r=-R,s=p,c=f,l=N;return _reactNativeGestureHandler.Gesture.Pan().enabled(!o).withTestId(v?`${v}-gesture`:"swipeable-gesture").activeOffsetX([-10,10]).failOffsetY([-15,15]).onStart(()=>{"worklet";I.value=y.value}).onUpdate(a=>{"worklet";const n=I.value+a.translationX;y.value=n>0&&!c||n<0&&!l?0:n>e&&c?e+.35*(n-e):n<-t&&l?.35*(n+t)-t:n}).onEnd(()=>{"worklet";const o=y.value;return c&&o>=a?(y.value=(0,_reactNativeReanimated.withSpring)(i,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(A)("left")):l&&o<=n?(y.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(A)("right")):c&&o>=s?(y.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(O)("left")):l&&o<=-s?(y.value=(0,_reactNativeReanimated.withSpring)(-t,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(O)("right")):(y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(C)())})},[o,I,A,w,f,N,x,C,O,g,R,p,y,v]),T=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:y.value}]})),F=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:x>0?Math.min(1,Math.max(0,y.value/x)):0})),V=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:g>0?Math.min(1,Math.max(0,-y.value/g)):0})),q=(0,_react.useMemo)(()=>{const e=[];return a?.forEach(t=>{e.push({name:t.key,label:t.label})}),n?.forEach(t=>{e.push({name:t.key,label:t.label})}),e},[a,n]),M=(0,_react.useCallback)(e=>{const t=e.nativeEvent.actionName,i=[...a??[],...n??[]].find(e=>e.key===t);i&&(!1!==l&&(0,_index2.triggerHaptic)("selection"),i.onPress())},[a,n,l]);return f||N?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[S.root,u],testID:v,accessibilityLabel:m,accessibilityActions:q,onAccessibilityAction:M,children:[f?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.actionsRow,S.actionsLeft,{width:x},_,F],pointerEvents:"box-none",children:a?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:h,actionStyles:b,width:p,onPress:P},e.key))}):null,N?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.actionsRow,S.actionsRight,{width:g},_,V],pointerEvents:"box-none",children:n?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:h,actionStyles:b,width:p,onPress:P},e.key))}):null,(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:k,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.content,d,T],children:t})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u,testID:v,children:t})};exports.Swipeable=Swipeable,Swipeable.displayName="Swipeable";const ActionButton=({action:e,theme:t,actionStyles:a,width:n,onPress:i})=>{(0,_warnInvalidValue.warnInvalidValue)("Swipeable","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const r=e.tone??"neutral",s=toneToBg(t,r),c=(0,_slotIcon.renderSlotIcon)(e.icon,{color:toneToOnColor(t,r),size:20,disabled:!1});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>i(e),accessibilityRole:"button",accessibilityLabel:e.label,style:[a.button,{width:n,backgroundColor:s,paddingHorizontal:t.space.sm}],children:[c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:a.icon,children:c}):null,(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",weight:"semibold",style:[a.label,{color:toneToOnColor(t,r)}],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"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,n,i=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(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((a=i&&Object.getOwnPropertyDescriptor(e,n))&&(a.get||a.set)?i(r,n,a):r[n]=e[n]);return r}const SPRING_CONFIG={damping:22,stiffness:260,mass:1},DRAG_ACTIVATION_OFFSET=10,RUBBER_BAND_FACTOR=.35,FAIL_OFFSET_Y=15,ACTION_ICON_SIZE=20,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;case"info":return e.colors.info;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"];case"info":return e.colors["on-info"];default:return e.colors["on-neutral"]}},Swipeable=e=>{const{children:t,leftActions:a,rightActions:n,threshold:i,fullSwipeThreshold:r,onSwipeOpen:s,onSwipeClose:c,disabled:o=!1,haptic:l,containerStyle:u,contentStyle:d,actionStyle:_,accessibilityLabel:m,testID:v}=e,h=(0,_index.useTheme)(),p=i??80,w=r??200,S=(0,_react.useMemo)(()=>buildStyles(h),[h]),b=(0,_react.useMemo)(()=>buildActionStyles(h),[h]),f=!!a&&a.length>0,N=!!n&&n.length>0,R=_reactNative.Dimensions.get("window").width,x=f?p*(a?.length??0):0,g=N?p*(n?.length??0):0,y=(0,_reactNativeReanimated.useSharedValue)(0),I=(0,_reactNativeReanimated.useSharedValue)(0),j=(0,_react.useRef)(null);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(y),(0,_reactNativeReanimated.cancelAnimation)(I)},[y,I]);const O=(0,_react.useCallback)(e=>{j.current!==e&&(j.current=e,s?.(e))},[s]),C=(0,_react.useCallback)(()=>{null!==j.current&&(j.current=null,c?.())},[c]),A=(0,_react.useCallback)(e=>{const t="left"===e?a:n,i=t?.[0];i&&(!1!==l&&(0,_index2.triggerHaptic)("notificationSuccess"),i.onPress(),y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),j.current=null,c?.())},[a,n,y,c,l]),G=(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(),G()},[G,l]),k=(0,_react.useMemo)(()=>{const e=x,t=g,a=w,n=-w,i=R,r=-R,s=p,c=f,l=N;return _reactNativeGestureHandler.Gesture.Pan().enabled(!o).withTestId(v?`${v}-gesture`:"swipeable-gesture").activeOffsetX([-10,10]).failOffsetY([-15,15]).onStart(()=>{"worklet";I.value=y.value}).onUpdate(a=>{"worklet";const n=I.value+a.translationX;y.value=n>0&&!c||n<0&&!l?0:n>e&&c?e+.35*(n-e):n<-t&&l?.35*(n+t)-t:n}).onEnd(()=>{"worklet";const o=y.value;return c&&o>=a?(y.value=(0,_reactNativeReanimated.withSpring)(i,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(A)("left")):l&&o<=n?(y.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(A)("right")):c&&o>=s?(y.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(O)("left")):l&&o<=-s?(y.value=(0,_reactNativeReanimated.withSpring)(-t,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(O)("right")):(y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(C)())})},[o,I,A,w,f,N,x,C,O,g,R,p,y,v]),T=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:y.value}]}),[y]),F=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:x>0?Math.min(1,Math.max(0,y.value/x)):0}),[x,y]),V=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:g>0?Math.min(1,Math.max(0,-y.value/g)):0}),[g,y]),q=(0,_react.useMemo)(()=>{const e=[];return a?.forEach(t=>{e.push({name:t.key,label:t.label})}),n?.forEach(t=>{e.push({name:t.key,label:t.label})}),e},[a,n]),M=(0,_react.useCallback)(e=>{const t=e.nativeEvent.actionName,i=[...a??[],...n??[]].find(e=>e.key===t);i&&(!1!==l&&(0,_index2.triggerHaptic)("selection"),i.onPress())},[a,n,l]);return f||N?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[S.root,u],testID:v,accessibilityLabel:m,accessibilityActions:q,onAccessibilityAction:M,children:[f?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.actionsRow,S.actionsLeft,{width:x},_,F],pointerEvents:"box-none",children:a?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:h,actionStyles:b,width:p,onPress:P},e.key))}):null,N?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.actionsRow,S.actionsRight,{width:g},_,V],pointerEvents:"box-none",children:n?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:h,actionStyles:b,width:p,onPress:P},e.key))}):null,(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:k,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.content,d,T],children:t})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u,testID:v,children:t})};exports.Swipeable=Swipeable,Swipeable.displayName="Swipeable";const ActionButton=({action:e,theme:t,actionStyles:a,width:n,onPress:i})=>{(0,_warnInvalidValue.warnInvalidValue)("Swipeable","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const r=e.tone??"neutral",s=toneToBg(t,r),c=(0,_slotIcon.renderSlotIcon)(e.icon,{color:toneToOnColor(t,r),size:20,disabled:!1});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>i(e),accessibilityRole:"button",accessibilityLabel:e.label,style:[a.button,{width:n,backgroundColor:s,paddingHorizontal:t.space.sm}],children:[c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:a.icon,children:c}):null,(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",weight:"semibold",style:[a.label,{color:toneToOnColor(t,r)}],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.TypingIndicator=exports.DEFAULT_TYPING_INDICATOR_LABELS=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_index2=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,a,r=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((i=r&&Object.getOwnPropertyDescriptor(e,a))&&(i.get||i.set)?r(s,a,i):s[a]=e[a]);return s}const DEFAULT_TYPING_INDICATOR_LABELS=exports.DEFAULT_TYPING_INDICATOR_LABELS=Object.freeze({typing:"Typing"}),DOT=6,DIM=.3,PULSE_MS=400,STAGGER_MS=160,STILL_OPACITY=[1,.65,.3],DOT_NAMES=["first","second","third"],Dot=({index:e,still:t,colour:i,dotStyle:a})=>{const r=(0,_reactNativeReanimated.useSharedValue)(.3);(0,_react.useEffect)(()=>{if(!t)return r.value=(0,_reactNativeReanimated.withDelay)(160*e,(0,_reactNativeReanimated.withRepeat)((0,_reactNativeReanimated.withSequence)((0,_reactNativeReanimated.withTiming)(1,{duration:400}),(0,_reactNativeReanimated.withTiming)(.3,{duration:400})),-1)),()=>(0,_reactNativeReanimated.cancelAnimation)(r)},[t,e,r]);const s=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:r.value}));return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[a,{backgroundColor:i},t?{opacity:STILL_OPACITY[e]}:s]})},TypingIndicator=({label:e,accessibilityLabel:t,labels:i,bubble:a=!0,style:r,testID:s})=>{const c=(0,_index.useTheme)(),n=(0,_react.useMemo)(()=>buildStyles(c),[c]),o=(0,_useReducedMotion.useReducedMotion)(),l=c.colors["text-subtle"],d=(0,_react.useMemo)(()=>({...DEFAULT_TYPING_INDICATOR_LABELS,...i}),[i]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[n.root,a?n.bubble:null,r],accessible:!0,accessibilityRole:"progressbar",accessibilityLabel:e??t??d.typing,accessibilityState:{busy:!0},"aria-busy":!0,testID:s,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:n.dots,children:DOT_NAMES.map((e,t)=>(0,_jsxRuntime.jsx)(Dot,{index:t,still:o,colour:l,dotStyle:n.dot},e))}),e?(0,_jsxRuntime.jsx)(_index2.Text,{variant:"bodySmall",color:"secondary",children:e}):null]})};exports.TypingIndicator=TypingIndicator;const buildStyles=e=>_reactNative.StyleSheet.create({dot:{width:6,height:6,borderRadius:e.radius.pill,..._corners.smoothCorners},root:{flexDirection:"row",alignItems:"center",alignSelf:"flex-start",gap:e.space.sm,marginTop:e.space.sm},bubble:{backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.xl,..._corners.smoothCorners,paddingHorizontal:e.space.md,paddingVertical:e.space.sm+e.space.xs},dots:{flexDirection:"row",alignItems:"center",gap:e.space.xs}});var _default=exports.default=TypingIndicator;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.TypingIndicator=exports.DEFAULT_TYPING_INDICATOR_LABELS=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_corners=require("../../utils/corners.js"),_index2=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,a,r=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((i=r&&Object.getOwnPropertyDescriptor(e,a))&&(i.get||i.set)?r(s,a,i):s[a]=e[a]);return s}const DEFAULT_TYPING_INDICATOR_LABELS=exports.DEFAULT_TYPING_INDICATOR_LABELS=Object.freeze({typing:"Typing"}),DOT=6,DIM=.3,PULSE_MS=400,STAGGER_MS=160,STILL_OPACITY=[1,.65,.3],DOT_NAMES=["first","second","third"],Dot=({index:e,still:t,colour:i,dotStyle:a})=>{const r=(0,_reactNativeReanimated.useSharedValue)(.3);(0,_react.useEffect)(()=>{if(!t)return r.value=(0,_reactNativeReanimated.withDelay)(160*e,(0,_reactNativeReanimated.withRepeat)((0,_reactNativeReanimated.withSequence)((0,_reactNativeReanimated.withTiming)(1,{duration:400}),(0,_reactNativeReanimated.withTiming)(.3,{duration:400})),-1)),()=>(0,_reactNativeReanimated.cancelAnimation)(r)},[t,e,r]);const s=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:r.value}),[r]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[a,{backgroundColor:i},t?{opacity:STILL_OPACITY[e]}:s]})},TypingIndicator=({label:e,accessibilityLabel:t,labels:i,bubble:a=!0,style:r,testID:s})=>{const c=(0,_index.useTheme)(),n=(0,_react.useMemo)(()=>buildStyles(c),[c]),o=(0,_useReducedMotion.useReducedMotion)(),l=c.colors["text-subtle"],d=(0,_react.useMemo)(()=>({...DEFAULT_TYPING_INDICATOR_LABELS,...i}),[i]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[n.root,a?n.bubble:null,r],accessible:!0,accessibilityRole:"progressbar",accessibilityLabel:e??t??d.typing,accessibilityState:{busy:!0},"aria-busy":!0,testID:s,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:n.dots,children:DOT_NAMES.map((e,t)=>(0,_jsxRuntime.jsx)(Dot,{index:t,still:o,colour:l,dotStyle:n.dot},e))}),e?(0,_jsxRuntime.jsx)(_index2.Text,{variant:"bodySmall",color:"secondary",children:e}):null]})};exports.TypingIndicator=TypingIndicator;const buildStyles=e=>_reactNative.StyleSheet.create({dot:{width:6,height:6,borderRadius:e.radius.pill,..._corners.smoothCorners},root:{flexDirection:"row",alignItems:"center",alignSelf:"flex-start",gap:e.space.sm,marginTop:e.space.sm},bubble:{backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.xl,..._corners.smoothCorners,paddingHorizontal:e.space.md,paddingVertical:e.space.sm+e.space.xs},dots:{flexDirection:"row",alignItems:"center",gap:e.space.xs}});var _default=exports.default=TypingIndicator;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ZoomableImage=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("../../utils/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,r,i=Object.defineProperty,l={__proto__:null,default:e};if(Object(e)!==e)return l;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,l)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((t=i&&Object.getOwnPropertyDescriptor(e,r))&&(t.get||t.set)?i(l,r,t):l[r]=e[r]);return l}const DEFAULT_MAX_SCALE=4,DEFAULT_MIN_SCALE=1,DEFAULT_DOUBLE_TAP_SCALE=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ZoomableImage=({children:e,maxScale:a=4,minScale:t=1,doubleTapScale:r=2,disabled:i=!1,haptic:l,style:n,accessibilityLabel:u,testID:c})=>{const s=(0,_reactNativeReanimated.useSharedValue)(1),v=(0,_reactNativeReanimated.useSharedValue)(1),d=(0,_reactNativeReanimated.useSharedValue)(0),o=(0,_reactNativeReanimated.useSharedValue)(0),_=(0,_reactNativeReanimated.useSharedValue)(0),m=(0,_reactNativeReanimated.useSharedValue)(0),N=(0,_react.useCallback)(()=>{s.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),v.value=1,d.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),o.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),_.value=0,m.value=0},[s,v,d,o,_,m]);(0,_react.useEffect)(()=>{i&&N()},[i,N]);const S=(0,_react.useCallback)(()=>{const e=(0,_index.resolveHaptic)(l,"impactLight");e&&(0,_index.triggerHaptic)(e)},[l]),R=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pinch().enabled(!i).onStart(()=>{"worklet";v.value=s.value}).onUpdate(e=>{"worklet";const r=v.value*e.scale;s.value=r<t?t+.3*(r-t):r>a?a+.2*(r-a):r}).onEnd(()=>{"worklet";return s.value<t?(s.value=(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG),d.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),o.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),v.value=t,_.value=0,void(m.value=0)):s.value>a?(s.value=(0,_reactNativeReanimated.withSpring)(a,SPRING_CONFIG),void(v.value=a)):void(v.value=s.value)}),[i,s,v,d,o,_,m,t,a]),h=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pan().enabled(!i).minPointers(1).maxPointers(1).onStart(()=>{"worklet";_.value=d.value,m.value=o.value}).onUpdate(e=>{"worklet";s.value<=1||(d.value=_.value+e.translationX,o.value=m.value+e.translationY)}).onEnd(()=>{"worklet";_.value=d.value,m.value=o.value}),[i,s,d,o,_,m]),p=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().enabled(!i).numberOfTaps(2).onEnd(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(S)(),s.value>1?(s.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),d.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),o.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),v.value=1,_.value=0,m.value=0):(s.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),v.value=r)}),[i,s,v,d,o,_,m,S,r]),I=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Race(R,h,p),[R,h,p]),G=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:d.value},{translateY:o.value},{scale:s.value}]}));return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:I,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[styles.container,n],testID:c,accessibilityLabel:u,accessibilityState:{disabled:i},"aria-disabled":i,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[styles.content,G],children:e})})})};exports.ZoomableImage=ZoomableImage,ZoomableImage.displayName="ZoomableImage";const styles=_reactNative.StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center",overflow:"hidden"},content:{width:"100%",height:"100%",alignItems:"center",justifyContent:"center"}});var _default=exports.default=ZoomableImage;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ZoomableImage=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("../../utils/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,r,i=Object.defineProperty,l={__proto__:null,default:e};if(Object(e)!==e)return l;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,l)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((t=i&&Object.getOwnPropertyDescriptor(e,r))&&(t.get||t.set)?i(l,r,t):l[r]=e[r]);return l}const DEFAULT_MAX_SCALE=4,DEFAULT_MIN_SCALE=1,DEFAULT_DOUBLE_TAP_SCALE=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ZoomableImage=({children:e,maxScale:a=4,minScale:t=1,doubleTapScale:r=2,disabled:i=!1,haptic:l,style:n,accessibilityLabel:u,testID:c})=>{const s=(0,_reactNativeReanimated.useSharedValue)(1),v=(0,_reactNativeReanimated.useSharedValue)(1),d=(0,_reactNativeReanimated.useSharedValue)(0),o=(0,_reactNativeReanimated.useSharedValue)(0),_=(0,_reactNativeReanimated.useSharedValue)(0),m=(0,_reactNativeReanimated.useSharedValue)(0),N=(0,_react.useCallback)(()=>{s.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),v.value=1,d.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),o.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),_.value=0,m.value=0},[s,v,d,o,_,m]);(0,_react.useEffect)(()=>{i&&N()},[i,N]);const S=(0,_react.useCallback)(()=>{const e=(0,_index.resolveHaptic)(l,"impactLight");e&&(0,_index.triggerHaptic)(e)},[l]),R=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pinch().enabled(!i).onStart(()=>{"worklet";v.value=s.value}).onUpdate(e=>{"worklet";const r=v.value*e.scale;s.value=r<t?t+.3*(r-t):r>a?a+.2*(r-a):r}).onEnd(()=>{"worklet";return s.value<t?(s.value=(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG),d.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),o.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),v.value=t,_.value=0,void(m.value=0)):s.value>a?(s.value=(0,_reactNativeReanimated.withSpring)(a,SPRING_CONFIG),void(v.value=a)):void(v.value=s.value)}),[i,s,v,d,o,_,m,t,a]),h=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pan().enabled(!i).minPointers(1).maxPointers(1).onStart(()=>{"worklet";_.value=d.value,m.value=o.value}).onUpdate(e=>{"worklet";s.value<=1||(d.value=_.value+e.translationX,o.value=m.value+e.translationY)}).onEnd(()=>{"worklet";_.value=d.value,m.value=o.value}),[i,s,d,o,_,m]),p=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().enabled(!i).numberOfTaps(2).onEnd(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(S)(),s.value>1?(s.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),d.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),o.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),v.value=1,_.value=0,m.value=0):(s.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),v.value=r)}),[i,s,v,d,o,_,m,S,r]),I=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Race(R,h,p),[R,h,p]),G=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:d.value},{translateY:o.value},{scale:s.value}]}),[d,o,s]);return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:I,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[styles.container,n],testID:c,accessibilityLabel:u,accessibilityState:{disabled:i},"aria-disabled":i,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[styles.content,G],children:e})})})};exports.ZoomableImage=ZoomableImage,ZoomableImage.displayName="ZoomableImage";const styles=_reactNative.StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center",overflow:"hidden"},content:{width:"100%",height:"100%",alignItems:"center",justifyContent:"center"}});var _default=exports.default=ZoomableImage;
@@ -1 +1 @@
1
- "use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,runOnJS,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"});const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:n,onSnapChange:r,onAnimate:a,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:S,onContentSizeChange:b,onScrollLayout:p,scrollEventThrottle:v,keyboardBehavior:y="shift",inline:g=!1,presentation:w="sheet",animateMount:C=!0,handleIndicatorStyle:x,containerStyle:_,header:M,actions:E,actionsLayout:O="auto",footer:T,headerStyle:k,footerStyle:I,children:R,accessibilityLabel:A,accessibilityViewIsModal:j,testID:V}=e;warnInvalidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),warnInvalidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),warnInvalidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const D=useMemo(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,...h}),[h]),B=null!=M||null!=d,L=null!=E&&E.length>0,P=null!=T||L,N=g?"inline":"modal",H=useTheme(),G=usePresenceMotion(),F=useSafeAreaInsets(),[U,J]=useState(()=>Dimensions.get("window").height),[z,Y]=useState(()=>Dimensions.get("window").width),K=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&J(e=>e===t?e:t),o>0&&Y(e=>e===o?e:o)},[]),$=useWindowDimensions(),W="dialog"===w||"auto"===w&&Math.min($.width,$.height)>=600,X=Math.min(560,z-2*H.space.xl),[q,Q]=useModalInsets(),Z="modal"===N?q.top:F.top,ee="modal"===N?q.bottom:F.bottom,te=t.includes("content"),[oe,se]=useMeasuredHeight(),[ne,re]=useMeasuredHeight(),[ae,le,ie]=useMeasuredHeight(),[ue,ce]=useMeasuredHeight(),de=W?H.space.md:oe,he=te?Math.min(de+(B?ne:0)+ae+(P?ue:0)+ee,U-Z):0,me=useCallback((e,t)=>{te&&ie(t),b?.(e,t)},[te,b,ie]),fe=useMemo(()=>resolveSnapPoints(t,U,he),[t,U,he]),Se=U,be=fe[fe.length-1]??0,pe=useSharedValue(Se),ve=useSharedValue(Se),ye=useSharedValue(1),ge=useSharedValue(-1),[we,Ce]=useState(-1),xe=useRef(!1),[Me,Ee]=useState(!1),[Oe,Te]=useState(!1),ke=useRef(!1),Ie=useRef(l);Ie.current=l;const[Re,Ae]=useState(!1),je=useRef(!C&&o),Ve=useRef(-1),De=useRef(!1);De.current="modal"===N?Oe:Re;const Be=useRef(c);Be.current=c;const Le=useRef(s);Le.current=s;const Pe=useRef(!1),Ne=useRef(!0),He=useRef([]),Ge=useCallback(e=>{const t=He.current;He.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Ne.current=!0,()=>{Ne.current=!1,Ge(!1)}),[Ge]);const Fe=useCallback(e=>{if(e<0||e>=fe.length)return Se;const t=fe[e];return W?(U-t)/2:U-t},[fe,U,Se,W]),Ue=useCallback(e=>{Ve.current=e;we!==e&&(Ce(e),ge.value=e,e>=0&&r?.(e))},[we,ge,r]),Je=useCallback(()=>{xe.current=!1,ge.value<0&&(ke.current=!0,"modal"===N?(Ee(!1),"ios"!==Platform.OS&&Te(!1)):Ae(!1))},[N,ge]),ze=useCallback(()=>{ke.current&&Te(!1)},[]);useEffect(()=>{("modal"===N?!Oe:!Re)&&ke.current&&(ke.current=!1,Ie.current?.(),Ge(!0))},[N,Oe,Re,Ge]);const Ye=useCallback((e,t,o)=>{xe.current=!0,a?.(t,o),pe.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(Je)()})},[a,pe,Je]),Ke=useCallback(e=>{const t="number"==typeof e?clamp(e,0,fe.length-1):we>=0?we:0,o=ge.value,s=Fe(t);return ke.current=!1,Ge(!1),"modal"===N?(Te(!0),Ee(!0)):Ae(!0),o<0&&je.current?(pe.value=s,ye.value=1,Ue(t),void a?.(o,t)):o<0&&G.reduced?(pe.value=s,ye.value=0,ye.value=withTiming(1,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ue(t),void a?.(o,t)):(o<0&&(pe.value=Se,ye.value=1),Ue(t),void Ye(s,o,t))},[Ye,Se,we,ge,N,a,G,ye,fe.length,Ue,Ge,H.motion.ease.decelerate,pe,Fe]),$e=useCallback(()=>new Promise(e=>{if(Ve.current<0)return void(De.current?He.current.push(e):e(!0));He.current.push(e),je.current=!1;const t=ge.value;Ue(-1),xe.current=!0,a?.(t,-1);const o=G.reduced?ye:pe,s=G.reduced?0:Se;o.value=withTiming(s,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&runOnJS(Je)()})}),[Se,ge,Je,a,G,ye,Ue,pe,H.motion.ease.accelerate]),We=useCallback((e,t,o)=>{const s=Be.current;if(!s)return void e();if(Pe.current)return void t?.();const n=s();"boolean"!=typeof n?(Pe.current=!0,o?.(),n.then(o=>{Pe.current=!1,o&&Ne.current&&Ve.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(n?e:t)?.()},[]),Xe=useCallback(()=>new Promise(e=>{Ve.current<0?e(!0):We(()=>{Le.current(),$e(),e(!0)},()=>e(!1))}),[$e,We]),qe=useCallback(()=>{Le.current()},[]),Qe=useCallback(()=>{u&&Xe()},[u,Xe]),Ze=useRef(null);useEffect(()=>{const e=Ze.current!==o;Ze.current=o,e?o?Ke(n??0):$e():o&&"number"==typeof n&&n!==ge.value&&Ke(n)},[o,n]);const et=useRef({hostHeight:U,contentSnap:he});useEffect(()=>{const e=et.current;if(e.hostHeight===U&&e.contentSnap===he)return;if(et.current={hostHeight:U,contentSnap:he},e.hostHeight===U&&ge.value<0)return;const t=Fe(ge.value);pe.value=je.current?t:withSpring(t,SPRING_CONFIG)},[U,he]);const tt=U-be,ot=useMemo(()=>fe.map(e=>U-e),[fe,U]),st=useCallback(()=>{const e=Ve.current;e<0||Ye(Fe(e),e,e)},[Ye,Fe]),nt=useCallback((e,t)=>{const o=ge.value;-1!==e?(Ue(e),Ye(t,o,e)):We(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Le.current(),$e()},st,st)},[Ye,$e,ge,We,Ue,st]),rt=useMemo(()=>Gesture.Native().withTestId(V?`${V}-content-gesture`:"bottom-sheet-content-gesture"),[V]),at=useMemo(()=>{const e=ot,t=Se,o=tt,s=i;return Gesture.Pan().withTestId(V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";ve.value=pe.value}).onUpdate(e=>{"worklet";const t=ve.value+e.translationY;pe.value=t<o?o+.25*(t-o):t}).onEnd(o=>{"worklet";const n=pe.value;if(o.velocityY>1e3)return s?void runOnJS(nt)(-1,t):void runOnJS(nt)(0,e[0]);let r=0,a=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const o=Math.abs(n-e[t]);o<a&&(a=o,r=t)}const l=e[0];s&&n-l>80?runOnJS(nt)(-1,t):runOnJS(nt)(r,e[r])})},[Se,ve,i,nt,tt,ot,V,pe]),{height:lt}=useReanimatedKeyboardAnimation(),it="shift"===y,ut=useDerivedValue(()=>it?lt.value:0),ct=fe[we>=0?we:0]??be,dt=H.space.md,ht=useAnimatedStyle(()=>{if(W){const e=ut.value,t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value;return{top:o<Z?Z:o,opacity:ye.value}}const e=pe.value+ut.value,t=ut.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}}),mt=useAnimatedStyle(()=>{const e=ut.value;if(W){const t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value,s=U+e-dt-(o<Z?Z:o);return{height:s<0?0:s>ct?ct:s}}const t=e<0?Z:tt,o=pe.value+e,s=U+e-(o<t?t:o);return{height:s<0?0:s>be?be:s}}),ft=we>=0,St=useMemo(()=>buildStyles(H),[H]),bt=useCallback(()=>{u&&We(()=>{triggerHaptic("selection"),Le.current(),$e()})},[u,$e,We]),pt=useMemo(()=>Gesture.Tap().withTestId(V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&runOnJS(bt)()}),[bt,V]),vt=useMemo(()=>({snapIndex:we,snapPoints:fe,close:qe,requestClose:Xe}),[we,fe,qe,Xe]);if("inline"===N&&!Re)return null;if("modal"===N&&!Oe)return null;const yt=_jsxs(View,{collapsable:!1,style:["modal"===N?St.backdropModal:St.backdropInline,{backgroundColor:"modal"===N?transparentOf(H.colors.scrim):H.colors.scrim}],onLayout:K,testID:V,accessibilityViewIsModal:j??ft,children:[_jsx(GestureDetector,{gesture:pt,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:D.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:A,accessibilityViewIsModal:j??ft,accessibilityActions:[{name:"escape",label:D.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[St.sheet,{height:be,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,...smoothCorners,...H.shadow.modal},W?{height:ct,left:(z-X)/2,right:void 0,width:X,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,_,ht],children:_jsxs(SheetBody,{style:[St.body,mt],keyboardOffset:ut,children:[W?_jsx(View,{style:{height:H.space.md}}):_jsx(GestureDetector,{gesture:at,children:_jsx(View,{style:St.handleRow,onLayout:te?se:void 0,accessible:!0,accessibilityLabel:D.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[St.handle,{backgroundColor:H.colors.border},x]})})}),B&&_jsxs(View,{style:[St.header,k],onLayout:te?re:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,M]}),m?_jsx(GestureDetector,{gesture:rt,children:_jsx(ScrollView,{ref:f,style:St.scrollContent,onScroll:S,onContentSizeChange:me,onLayout:p,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:R})}):_jsx(View,{style:te?[St.content,{overflow:"visible"}]:St.content,children:te?_jsx(View,{onLayout:le,children:R}):R}),P&&_jsxs(View,{style:[St.footer,I],onLayout:te?ce:void 0,children:[L?_jsx(View,{style:St.actions,children:_jsx(OverlayActions,{actions:E??[],layout:O})}):null,T]})]})})]}),gt=_jsx(BottomSheetContext.Provider,{value:vt,children:yt});return"modal"===N?_jsx(Modal,{open:Me,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===Platform.OS?ze:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:St.modalRoot,children:gt}):gt}):gt},SheetBody=({style:e,keyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,n=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:e>0?e:0}});return _jsx(Animated.View,{style:[e,n],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
1
+ "use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,runOnJS,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"});const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:n,onSnapChange:r,onAnimate:a,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:S,onContentSizeChange:b,onScrollLayout:p,scrollEventThrottle:v,keyboardBehavior:y="shift",inline:g=!1,presentation:w="sheet",animateMount:C=!0,handleIndicatorStyle:x,containerStyle:_,header:M,actions:E,actionsLayout:O="auto",footer:T,headerStyle:k,footerStyle:I,children:R,accessibilityLabel:A,accessibilityViewIsModal:j,testID:V}=e;warnInvalidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),warnInvalidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),warnInvalidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const D=useMemo(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,...h}),[h]),B=null!=M||null!=d,L=null!=E&&E.length>0,P=null!=T||L,N=g?"inline":"modal",H=useTheme(),G=usePresenceMotion(),F=useSafeAreaInsets(),[U,J]=useState(()=>Dimensions.get("window").height),[z,Y]=useState(()=>Dimensions.get("window").width),K=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&J(e=>e===t?e:t),o>0&&Y(e=>e===o?e:o)},[]),$=useWindowDimensions(),W="dialog"===w||"auto"===w&&Math.min($.width,$.height)>=600,X=Math.min(560,z-2*H.space.xl),[q,Q]=useModalInsets(),Z="modal"===N?q.top:F.top,ee="modal"===N?q.bottom:F.bottom,te=t.includes("content"),[oe,se]=useMeasuredHeight(),[ne,re]=useMeasuredHeight(),[ae,le,ie]=useMeasuredHeight(),[ue,ce]=useMeasuredHeight(),de=W?H.space.md:oe,he=te?Math.min(de+(B?ne:0)+ae+(P?ue:0)+ee,U-Z):0,me=useCallback((e,t)=>{te&&ie(t),b?.(e,t)},[te,b,ie]),fe=useMemo(()=>resolveSnapPoints(t,U,he),[t,U,he]),Se=U,be=fe[fe.length-1]??0,pe=useSharedValue(Se),ve=useSharedValue(Se),ye=useSharedValue(1),ge=useSharedValue(-1),[we,Ce]=useState(-1),xe=useRef(!1),[Me,Ee]=useState(!1),[Oe,Te]=useState(!1),ke=useRef(!1),Ie=useRef(l);Ie.current=l;const[Re,Ae]=useState(!1),je=useRef(!C&&o),Ve=useRef(-1),De=useRef(!1);De.current="modal"===N?Oe:Re;const Be=useRef(c);Be.current=c;const Le=useRef(s);Le.current=s;const Pe=useRef(!1),Ne=useRef(!0),He=useRef([]),Ge=useCallback(e=>{const t=He.current;He.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Ne.current=!0,()=>{Ne.current=!1,Ge(!1)}),[Ge]);const Fe=useCallback(e=>{if(e<0||e>=fe.length)return Se;const t=fe[e];return W?(U-t)/2:U-t},[fe,U,Se,W]),Ue=useCallback(e=>{Ve.current=e;we!==e&&(Ce(e),ge.value=e,e>=0&&r?.(e))},[we,ge,r]),Je=useCallback(()=>{xe.current=!1,ge.value<0&&(ke.current=!0,"modal"===N?(Ee(!1),"ios"!==Platform.OS&&Te(!1)):Ae(!1))},[N,ge]),ze=useCallback(()=>{ke.current&&Te(!1)},[]);useEffect(()=>{("modal"===N?!Oe:!Re)&&ke.current&&(ke.current=!1,Ie.current?.(),Ge(!0))},[N,Oe,Re,Ge]);const Ye=useCallback((e,t,o)=>{xe.current=!0,a?.(t,o),pe.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(Je)()})},[a,pe,Je]),Ke=useCallback(e=>{const t="number"==typeof e?clamp(e,0,fe.length-1):we>=0?we:0,o=ge.value,s=Fe(t);return ke.current=!1,Ge(!1),"modal"===N?(Te(!0),Ee(!0)):Ae(!0),o<0&&je.current?(pe.value=s,ye.value=1,Ue(t),void a?.(o,t)):o<0&&G.reduced?(pe.value=s,ye.value=0,ye.value=withTiming(1,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ue(t),void a?.(o,t)):(o<0&&(pe.value=Se,ye.value=1),Ue(t),void Ye(s,o,t))},[Ye,Se,we,ge,N,a,G,ye,fe.length,Ue,Ge,H.motion.ease.decelerate,pe,Fe]),$e=useCallback(()=>new Promise(e=>{if(Ve.current<0)return void(De.current?He.current.push(e):e(!0));He.current.push(e),je.current=!1;const t=ge.value;Ue(-1),xe.current=!0,a?.(t,-1);const o=G.reduced?ye:pe,s=G.reduced?0:Se;o.value=withTiming(s,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&runOnJS(Je)()})}),[Se,ge,Je,a,G,ye,Ue,pe,H.motion.ease.accelerate]),We=useCallback((e,t,o)=>{const s=Be.current;if(!s)return void e();if(Pe.current)return void t?.();const n=s();"boolean"!=typeof n?(Pe.current=!0,o?.(),n.then(o=>{Pe.current=!1,o&&Ne.current&&Ve.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(n?e:t)?.()},[]),Xe=useCallback(()=>new Promise(e=>{Ve.current<0?e(!0):We(()=>{Le.current(),$e(),e(!0)},()=>e(!1))}),[$e,We]),qe=useCallback(()=>{Le.current()},[]),Qe=useCallback(()=>{u&&Xe()},[u,Xe]),Ze=useRef(null);useEffect(()=>{const e=Ze.current!==o;Ze.current=o,e?o?Ke(n??0):$e():o&&"number"==typeof n&&n!==ge.value&&Ke(n)},[o,n]);const et=useRef({hostHeight:U,contentSnap:he});useEffect(()=>{const e=et.current;if(e.hostHeight===U&&e.contentSnap===he)return;if(et.current={hostHeight:U,contentSnap:he},e.hostHeight===U&&ge.value<0)return;const t=Fe(ge.value);pe.value=je.current?t:withSpring(t,SPRING_CONFIG)},[U,he]);const tt=U-be,ot=useMemo(()=>fe.map(e=>U-e),[fe,U]),st=useCallback(()=>{const e=Ve.current;e<0||Ye(Fe(e),e,e)},[Ye,Fe]),nt=useCallback((e,t)=>{const o=ge.value;-1!==e?(Ue(e),Ye(t,o,e)):We(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Le.current(),$e()},st,st)},[Ye,$e,ge,We,Ue,st]),rt=useMemo(()=>Gesture.Native().withTestId(V?`${V}-content-gesture`:"bottom-sheet-content-gesture"),[V]),at=useMemo(()=>{const e=ot,t=Se,o=tt,s=i;return Gesture.Pan().withTestId(V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";ve.value=pe.value}).onUpdate(e=>{"worklet";const t=ve.value+e.translationY;pe.value=t<o?o+.25*(t-o):t}).onEnd(o=>{"worklet";const n=pe.value;if(o.velocityY>1e3)return s?void runOnJS(nt)(-1,t):void runOnJS(nt)(0,e[0]);let r=0,a=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const o=Math.abs(n-e[t]);o<a&&(a=o,r=t)}const l=e[0];s&&n-l>80?runOnJS(nt)(-1,t):runOnJS(nt)(r,e[r])})},[Se,ve,i,nt,tt,ot,V,pe]),{height:lt}=useReanimatedKeyboardAnimation(),it="shift"===y,ut=useDerivedValue(()=>it?lt.value:0,[it,lt]),ct=fe[we>=0?we:0]??be,dt=H.space.md,ht=useAnimatedStyle(()=>{if(W){const e=ut.value,t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value;return{top:o<Z?Z:o,opacity:ye.value}}const e=pe.value+ut.value,t=ut.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}},[W,ut,U,ct,dt,pe,Z,ye,tt]),mt=useAnimatedStyle(()=>{const e=ut.value;if(W){const t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value,s=U+e-dt-(o<Z?Z:o);return{height:s<0?0:s>ct?ct:s}}const t=e<0?Z:tt,o=pe.value+e,s=U+e-(o<t?t:o);return{height:s<0?0:s>be?be:s}},[ut,W,U,ct,dt,pe,Z,tt,be]),ft=we>=0,St=useMemo(()=>buildStyles(H),[H]),bt=useCallback(()=>{u&&We(()=>{triggerHaptic("selection"),Le.current(),$e()})},[u,$e,We]),pt=useMemo(()=>Gesture.Tap().withTestId(V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&runOnJS(bt)()}),[bt,V]),vt=useMemo(()=>({snapIndex:we,snapPoints:fe,close:qe,requestClose:Xe}),[we,fe,qe,Xe]);if("inline"===N&&!Re)return null;if("modal"===N&&!Oe)return null;const yt=_jsxs(View,{collapsable:!1,style:["modal"===N?St.backdropModal:St.backdropInline,{backgroundColor:"modal"===N?transparentOf(H.colors.scrim):H.colors.scrim}],onLayout:K,testID:V,accessibilityViewIsModal:j??ft,children:[_jsx(GestureDetector,{gesture:pt,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:D.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:A,accessibilityViewIsModal:j??ft,accessibilityActions:[{name:"escape",label:D.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[St.sheet,{height:be,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,...smoothCorners,...H.shadow.modal},W?{height:ct,left:(z-X)/2,right:void 0,width:X,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,_,ht],children:_jsxs(SheetBody,{style:[St.body,mt],keyboardOffset:ut,children:[W?_jsx(View,{style:{height:H.space.md}}):_jsx(GestureDetector,{gesture:at,children:_jsx(View,{style:St.handleRow,onLayout:te?se:void 0,accessible:!0,accessibilityLabel:D.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[St.handle,{backgroundColor:H.colors.border},x]})})}),B&&_jsxs(View,{style:[St.header,k],onLayout:te?re:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,M]}),m?_jsx(GestureDetector,{gesture:rt,children:_jsx(ScrollView,{ref:f,style:St.scrollContent,onScroll:S,onContentSizeChange:me,onLayout:p,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:R})}):_jsx(View,{style:te?[St.content,{overflow:"visible"}]:St.content,children:te?_jsx(View,{onLayout:le,children:R}):R}),P&&_jsxs(View,{style:[St.footer,I],onLayout:te?ce:void 0,children:[L?_jsx(View,{style:St.actions,children:_jsx(OverlayActions,{actions:E??[],layout:O})}):null,T]})]})})]}),gt=_jsx(BottomSheetContext.Provider,{value:vt,children:yt});return"modal"===N?_jsx(Modal,{open:Me,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===Platform.OS?ze:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:St.modalRoot,children:gt}):gt}):gt},SheetBody=({style:e,keyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,n=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:e>0?e:0}},[s,t]);return _jsx(Animated.View,{style:[e,n],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useState}from"react";import{StyleSheet,useWindowDimensions,View}from"react-native";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withRepeat,withTiming}from"react-native-reanimated";import Svg,{Path,Polygon}from"react-native-svg";import{useReducedMotion}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{jsx as _jsx}from"react/jsx-runtime";const TAU=2*Math.PI,DEG=Math.PI/180,SPEED_FACTOR={slow:1.6,normal:1,fast:.6};export const DEFAULT_PHYSICS={velocity:1,drag:1,fallSpeed:1,spread:0};const PRESET_SHAPES={pop:["strip","strip","strip","square","circle","triangle","star","streamer"],rain:["strip","strip","strip","circle","square"],fireworks:["circle","circle","star","star","triangle","strip"]},rand=(e,a)=>e+Math.random()*(a-e),pick=e=>e[Math.floor(Math.random()*e.length)]??e[0],commonPiece=(e,a)=>({color:e.colors[a%e.colors.length]??e.colors[0],size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:Math.random()<.5?1:-1,flutterFreq:rand(2,5)}),popPiece=(e,a)=>{const r=e.physics.spread>0?e.physics.spread/2:100,t=(-90+rand(-r,r))*DEG,s=rand(1.8,4.2)*e.physics.velocity;return{...commonPiece(e,a),x0Frac:e.originXFrac,y0Frac:e.originYFrac,vxFrac:Math.cos(t)*s*.7,vyFrac:Math.sin(t)*s,drag:rand(5.5,7.5)*e.physics.drag,terminalFrac:rand(.22,.44)*e.physics.fallSpeed,delay:rand(0,.05),swayAmp:rand(4,16),swayFreq:rand(1,3)}},rainPiece=(e,a)=>({...commonPiece(e,a),x0Frac:Math.random(),y0Frac:-.05,vxFrac:rand(-.12,.12)*e.physics.velocity,vyFrac:rand(.05,.25)*e.physics.velocity,drag:rand(2.5,4)*e.physics.drag,terminalFrac:rand(.95,1.35)*e.physics.fallSpeed,delay:rand(0,.35),swayAmp:rand(10,30),swayFreq:rand(1,3)}),FIREWORK_BURSTS=4,buildFireworks=(e,a)=>{const r=Math.max(1,Math.round(e/4)),t=a.physics.spread>0?a.physics.spread/2:180,s=[];for(let i=0;i<4&&s.length<e;i+=1){const n=rand(.18,.82),o=rand(.18,.52),c=i/4*.5+rand(0,.06);for(let i=0;i<r&&s.length<e;i+=1){const e=rand(-t,t)*DEG,r=rand(1.4,3.4)*a.physics.velocity;s.push({...commonPiece(a,s.length),x0Frac:n,y0Frac:o,vxFrac:Math.cos(e)*r*.7,vyFrac:Math.sin(e)*r,drag:rand(6.5,8.5)*a.physics.drag,terminalFrac:rand(.18,.38)*a.physics.fallSpeed,delay:c,swayAmp:rand(3,12),swayFreq:rand(1,3)})}}return s};export const buildPieces=(e,a,r)=>{if("fireworks"===a)return buildFireworks(e,r);const t="rain"===a?rainPiece:popPiece;return Array.from({length:e},(e,a)=>t(r,a))};const SHAPE_BOX={strip:{w:1,h:.45},square:{w:1,h:1},circle:{w:1,h:1},triangle:{w:1,h:1},star:{w:1.2,h:1.2},streamer:{w:3,h:1.2}},TRIANGLE_POINTS="50,4 96,96 4,96",STAR_POINTS="50,2 61,36 97,36 68,58 79,94 50,72 21,94 32,58 3,36 39,36",STREAMER_PATH="M2,50 C20,6 44,94 62,50 S92,6 98,50",ShapeBody=({shape:e,color:a})=>"triangle"===e||"star"===e?_jsx(Svg,{width:"100%",height:"100%",viewBox:"0 0 100 100",children:_jsx(Polygon,{points:"star"===e?STAR_POINTS:TRIANGLE_POINTS,fill:a})}):"streamer"===e?_jsx(Svg,{width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:_jsx(Path,{d:STREAMER_PATH,stroke:a,strokeWidth:22,strokeLinecap:"round",fill:"none"})}):null,ConfettiPiece=({piece:e,progress:a,width:r,height:t,fadeOut:s})=>{const i=useAnimatedStyle(()=>{const i=1-e.delay,n=i<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/i)),o=(1-Math.exp(-e.drag*n))/e.drag,c=e.x0Frac*r+e.vxFrac*r*o,l=e.y0Frac*t+e.terminalFrac*t*n+(e.vyFrac-e.terminalFrac)*t*o,h=Math.sin(n*e.swayFreq*TAU)*e.swayAmp,d=e.rotateDir*e.rotations*360*n,p=.35+.65*Math.abs(Math.cos(n*e.flutterFreq*TAU));return{opacity:s?Math.max(0,1-Math.max(0,n-.75)/.25):1,transform:[{translateX:c+h},{translateY:l},{rotate:`${d}deg`},{scaleY:p}]}}),n=SHAPE_BOX[e.shape],o="triangle"===e.shape||"star"===e.shape||"streamer"===e.shape;return _jsx(Animated.View,{style:[{position:"absolute",width:e.size*n.w,height:e.size*n.h,borderRadius:"circle"===e.shape?e.size*n.h/2:1,backgroundColor:o?"transparent":e.color},i],children:_jsx(ShapeBody,{shape:e.shape,color:e.color})})},Confetti=forwardRef(({count:e=80,colors:a,preset:r="pop",shapes:t,speed:s="normal",physics:i,origin:n,duration:o=2800,fadeOut:c=!0,autoStart:l=!1,recycle:h=!1,size:d=10,onComplete:p,style:u,testID:m},y)=>{warnInvalidValue("Confetti","preset",r,["pop","rain","fireworks"]),warnInvalidValue("Confetti","speed",s,["slow","normal","fast"]);for(const e of t??[])warnInvalidValue("Confetti","shapes",e,["strip","square","circle","triangle","star","streamer"]);const g=useTheme(),w=useReducedMotion(),f=useWindowDimensions(),[S,F]=useState({width:f.width,height:f.height}),[v,x]=useState(!1),[P,A]=useState([]),E=useMemo(()=>a??[g.colors.primary,g.colors.neutral,g.colors.success,g.colors.warning,g.colors.danger,g.colors.info],[a,g.colors]),M=useSharedValue(0),T=o*SPEED_FACTOR[s],_=useCallback(()=>{x(!1),p?.()},[p]),R=useCallback(()=>{if(w)return void p?.();cancelAnimation(M),M.value=0,A(buildPieces(e,r,{colors:E,baseSize:d,originXFrac:n?n.x/Math.max(1,S.width):.5,originYFrac:n?n.y/Math.max(1,S.height):.5,physics:{...DEFAULT_PHYSICS,...i},shapes:t??PRESET_SHAPES[r]})),x(!0);const a=withTiming(1,{duration:T,easing:Easing.linear},e=>{"worklet";e&&!h&&runOnJS(_)()});M.value=h?withRepeat(a,-1,!1):a},[w,M,T,h,_,p,e,E,r,t,i,d,n,S.width,S.height]),C=useCallback(()=>{cancelAnimation(M),x(!1)},[M]);useImperativeHandle(y,()=>({start:R,stop:C}),[R,C]),useEffect(()=>(l&&R(),()=>cancelAnimation(M)),[]);const I=useCallback(e=>{const{width:a,height:r}=e.nativeEvent.layout;a>0&&r>0&&F({width:a,height:r})},[]);return _jsx(View,{style:[StyleSheet.absoluteFill,u],pointerEvents:"none",onLayout:I,testID:m,children:v?P.map((e,a)=>_jsx(ConfettiPiece,{piece:e,progress:M,width:S.width,height:S.height,fadeOut:c},a)):null})});Confetti.displayName="Confetti";export{Confetti};export default Confetti;
1
+ "use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useState}from"react";import{StyleSheet,useWindowDimensions,View}from"react-native";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withRepeat,withTiming}from"react-native-reanimated";import Svg,{Path,Polygon}from"react-native-svg";import{useReducedMotion}from"../../hooks/index.js";import{useTheme}from"../../theme/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{jsx as _jsx}from"react/jsx-runtime";const TAU=2*Math.PI,DEG=Math.PI/180,SPEED_FACTOR={slow:1.6,normal:1,fast:.6};export const DEFAULT_PHYSICS={velocity:1,drag:1,fallSpeed:1,spread:0};const PRESET_SHAPES={pop:["strip","strip","strip","square","circle","triangle","star","streamer"],rain:["strip","strip","strip","circle","square"],fireworks:["circle","circle","star","star","triangle","strip"]},rand=(e,a)=>e+Math.random()*(a-e),pick=e=>e[Math.floor(Math.random()*e.length)]??e[0],commonPiece=(e,a)=>({color:e.colors[a%e.colors.length]??e.colors[0],size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:Math.random()<.5?1:-1,flutterFreq:rand(2,5)}),popPiece=(e,a)=>{const r=e.physics.spread>0?e.physics.spread/2:100,t=(-90+rand(-r,r))*DEG,s=rand(1.8,4.2)*e.physics.velocity;return{...commonPiece(e,a),x0Frac:e.originXFrac,y0Frac:e.originYFrac,vxFrac:Math.cos(t)*s*.7,vyFrac:Math.sin(t)*s,drag:rand(5.5,7.5)*e.physics.drag,terminalFrac:rand(.22,.44)*e.physics.fallSpeed,delay:rand(0,.05),swayAmp:rand(4,16),swayFreq:rand(1,3)}},rainPiece=(e,a)=>({...commonPiece(e,a),x0Frac:Math.random(),y0Frac:-.05,vxFrac:rand(-.12,.12)*e.physics.velocity,vyFrac:rand(.05,.25)*e.physics.velocity,drag:rand(2.5,4)*e.physics.drag,terminalFrac:rand(.95,1.35)*e.physics.fallSpeed,delay:rand(0,.35),swayAmp:rand(10,30),swayFreq:rand(1,3)}),FIREWORK_BURSTS=4,buildFireworks=(e,a)=>{const r=Math.max(1,Math.round(e/4)),t=a.physics.spread>0?a.physics.spread/2:180,s=[];for(let i=0;i<4&&s.length<e;i+=1){const n=rand(.18,.82),o=rand(.18,.52),c=i/4*.5+rand(0,.06);for(let i=0;i<r&&s.length<e;i+=1){const e=rand(-t,t)*DEG,r=rand(1.4,3.4)*a.physics.velocity;s.push({...commonPiece(a,s.length),x0Frac:n,y0Frac:o,vxFrac:Math.cos(e)*r*.7,vyFrac:Math.sin(e)*r,drag:rand(6.5,8.5)*a.physics.drag,terminalFrac:rand(.18,.38)*a.physics.fallSpeed,delay:c,swayAmp:rand(3,12),swayFreq:rand(1,3)})}}return s};export const buildPieces=(e,a,r)=>{if("fireworks"===a)return buildFireworks(e,r);const t="rain"===a?rainPiece:popPiece;return Array.from({length:e},(e,a)=>t(r,a))};const SHAPE_BOX={strip:{w:1,h:.45},square:{w:1,h:1},circle:{w:1,h:1},triangle:{w:1,h:1},star:{w:1.2,h:1.2},streamer:{w:3,h:1.2}},TRIANGLE_POINTS="50,4 96,96 4,96",STAR_POINTS="50,2 61,36 97,36 68,58 79,94 50,72 21,94 32,58 3,36 39,36",STREAMER_PATH="M2,50 C20,6 44,94 62,50 S92,6 98,50",ShapeBody=({shape:e,color:a})=>"triangle"===e||"star"===e?_jsx(Svg,{width:"100%",height:"100%",viewBox:"0 0 100 100",children:_jsx(Polygon,{points:"star"===e?STAR_POINTS:TRIANGLE_POINTS,fill:a})}):"streamer"===e?_jsx(Svg,{width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:_jsx(Path,{d:STREAMER_PATH,stroke:a,strokeWidth:22,strokeLinecap:"round",fill:"none"})}):null,ConfettiPiece=({piece:e,progress:a,width:r,height:t,fadeOut:s})=>{const i=useAnimatedStyle(()=>{const i=1-e.delay,n=i<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/i)),o=(1-Math.exp(-e.drag*n))/e.drag,c=e.x0Frac*r+e.vxFrac*r*o,l=e.y0Frac*t+e.terminalFrac*t*n+(e.vyFrac-e.terminalFrac)*t*o,h=Math.sin(n*e.swayFreq*TAU)*e.swayAmp,d=e.rotateDir*e.rotations*360*n,p=.35+.65*Math.abs(Math.cos(n*e.flutterFreq*TAU));return{opacity:s?Math.max(0,1-Math.max(0,n-.75)/.25):1,transform:[{translateX:c+h},{translateY:l},{rotate:`${d}deg`},{scaleY:p}]}},[e,a,r,t,s]),n=SHAPE_BOX[e.shape],o="triangle"===e.shape||"star"===e.shape||"streamer"===e.shape;return _jsx(Animated.View,{style:[{position:"absolute",width:e.size*n.w,height:e.size*n.h,borderRadius:"circle"===e.shape?e.size*n.h/2:1,backgroundColor:o?"transparent":e.color},i],children:_jsx(ShapeBody,{shape:e.shape,color:e.color})})},Confetti=forwardRef(({count:e=80,colors:a,preset:r="pop",shapes:t,speed:s="normal",physics:i,origin:n,duration:o=2800,fadeOut:c=!0,autoStart:l=!1,recycle:h=!1,size:d=10,onComplete:p,style:u,testID:m},y)=>{warnInvalidValue("Confetti","preset",r,["pop","rain","fireworks"]),warnInvalidValue("Confetti","speed",s,["slow","normal","fast"]);for(const e of t??[])warnInvalidValue("Confetti","shapes",e,["strip","square","circle","triangle","star","streamer"]);const g=useTheme(),w=useReducedMotion(),f=useWindowDimensions(),[S,F]=useState({width:f.width,height:f.height}),[v,x]=useState(!1),[P,A]=useState([]),E=useMemo(()=>a??[g.colors.primary,g.colors.neutral,g.colors.success,g.colors.warning,g.colors.danger,g.colors.info],[a,g.colors]),M=useSharedValue(0),T=o*SPEED_FACTOR[s],_=useCallback(()=>{x(!1),p?.()},[p]),R=useCallback(()=>{if(w)return void p?.();cancelAnimation(M),M.value=0,A(buildPieces(e,r,{colors:E,baseSize:d,originXFrac:n?n.x/Math.max(1,S.width):.5,originYFrac:n?n.y/Math.max(1,S.height):.5,physics:{...DEFAULT_PHYSICS,...i},shapes:t??PRESET_SHAPES[r]})),x(!0);const a=withTiming(1,{duration:T,easing:Easing.linear},e=>{"worklet";e&&!h&&runOnJS(_)()});M.value=h?withRepeat(a,-1,!1):a},[w,M,T,h,_,p,e,E,r,t,i,d,n,S.width,S.height]),C=useCallback(()=>{cancelAnimation(M),x(!1)},[M]);useImperativeHandle(y,()=>({start:R,stop:C}),[R,C]),useEffect(()=>(l&&R(),()=>cancelAnimation(M)),[]);const I=useCallback(e=>{const{width:a,height:r}=e.nativeEvent.layout;a>0&&r>0&&F({width:a,height:r})},[]);return _jsx(View,{style:[StyleSheet.absoluteFill,u],pointerEvents:"none",onLayout:I,testID:m,children:v?P.map((e,a)=>_jsx(ConfettiPiece,{piece:e,progress:M,width:S.width,height:S.height,fadeOut:c},a)):null})});Confetti.displayName="Confetti";export{Confetti};export default Confetti;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Dimensions,Pressable,StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{Extrapolation,interpolate,runOnJS,useAnimatedStyle,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{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_DRAWER_LABELS={close:"Close drawer",drawer:"Drawer"};const DEFAULT_CLOSE_VELOCITY_THRESHOLD=1e3,DEFAULT_DRAG_ACTIVATION_OFFSET=10,Drawer=forwardRef((e,t)=>{const{open:a,defaultOpen:r=!1,onOpenChange:i,side:o="left",width:s,enableSwipe:n=!0,enableBackdropPress:l=!0,backdropOpacity:u=.5,haptic:c,containerStyle:d,children:p,accessibilityLabel:h,labels:m,testID:f}=e,g=useTheme();warnInvalidValue("Drawer","side",e.side,["left","right","top","bottom"]);const b=useMemo(()=>({...DEFAULT_DRAWER_LABELS,...m}),[m]),v=usePresenceMotion(),w=v.reduced,S=v.duration("default"),E=v.duration("fast"),y=useSafeAreaInsets(),M="boolean"==typeof a,[_,D]=useState(()=>Dimensions.get("window"));useEffect(()=>{const e=Dimensions.addEventListener("change",({window:e})=>D(e));return()=>e.remove()},[]);const C="left"===o||"right"===o,O=useMemo(()=>resolveSize(s,C,_),[s,C,_]),R=useMemo(()=>{switch(o){case"left":case"top":return-O;case"right":case"bottom":return O}},[o,O]),T=useSharedValue(r?0:R),x=useSharedValue(r?0:R),k=useSharedValue(r?1:0),[A,L]=useState(r),I=useSharedValue(r);useEffect(()=>{A||w||(T.value=R,x.value=R)},[R,A,T,x,w]);const V=g.motion.spring.snappy,j=useCallback(()=>{if(w)return T.value=0,void(k.value=withTiming(1,{duration:S,reduceMotion:PRESENCE_REDUCE_MOTION}));k.value=1,T.value=withSpring(0,V)},[T,k,V,w,S]),N=useCallback(()=>{w?k.value=withTiming(0,{duration:E,reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(T.value=R)}):T.value=withSpring(R,V)},[T,k,R,V,w,E]),P=useCallback(e=>{L(t=>t===e?t:(i?.(e),e)),I.value=e},[i,I]),F=useCallback(()=>{P(!0),j()},[P,j]),U=useCallback(()=>{P(!1),N()},[P,N]),H=useCallback(()=>{A?U():F()},[A,F,U]);useImperativeHandle(t,()=>({open:F,close:U,toggle:H}),[F,U,H]),useEffect(()=>{M&&a!==A&&(a?F():U())},[a]);const B=useMemo(()=>{const e=R,t=o,a=n;let r=Gesture.Pan();return r=C?r.activeOffsetX([-10,10]).failOffsetY([-15,15]):r.activeOffsetY([-10,10]).failOffsetX([-15,15]),r.onStart(()=>{"worklet";a&&(x.value=T.value)}).onUpdate(t=>{"worklet";if(!a)return;const r=C?t.translationX:t.translationY,i=x.value+r,o=Math.min(0,e),s=Math.max(0,e);T.value=i<o?o+.25*(i-o):i>s?s+.25*(i-s):i}).onEnd(r=>{"worklet";if(!a)return;const i=C?r.velocityX:r.velocityY,o=T.value;let s=!1;s="left"===t||"top"===t?i<-1e3:i>1e3;const n=Math.abs(e),l=Math.abs(o)/n;s||l>.5?(runOnJS(P)(!1),w?k.value=withTiming(0,{duration:E,reduceMotion:PRESENCE_REDUCE_MOTION},t=>{"worklet";t&&(T.value=e)}):T.value=withSpring(e,V)):(runOnJS(P)(!0),w?(T.value=0,k.value=withTiming(1,{duration:S,reduceMotion:PRESENCE_REDUCE_MOTION})):T.value=withSpring(0,V))})},[R,x,n,C,T,k,P,o,V,w,S,E]),Y=useAnimatedStyle(()=>C?{opacity:k.value,transform:[{translateX:T.value}]}:{opacity:k.value,transform:[{translateY:T.value}]}),G=useAnimatedStyle(()=>({opacity:interpolate(T.value,[R,0],[0,u],Extrapolation.CLAMP)*k.value,pointerEvents:Math.abs(T.value-R)<.5?"none":"auto"}),[R,u]),X=useMemo(()=>buildStyles(g),[g]),J=useCallback(()=>{if(!l)return;const e=resolveHaptic(c,"selection");e&&triggerHaptic(e),U()},[l,U,c]),z=useMemo(()=>{switch(o){case"left":return{position:"absolute",top:0,bottom:0,left:0,width:O,paddingTop:y.top,paddingBottom:y.bottom,paddingLeft:y.left};case"right":return{position:"absolute",top:0,bottom:0,right:0,width:O,paddingTop:y.top,paddingBottom:y.bottom,paddingRight:y.right};case"top":return{position:"absolute",top:0,left:0,right:0,height:O,paddingTop:y.top,paddingLeft:y.left,paddingRight:y.right};case"bottom":return{position:"absolute",bottom:0,left:0,right:0,height:O,paddingBottom:y.bottom,paddingLeft:y.left,paddingRight:y.right}}},[o,O,y]),W=useRef(r);return A&&(W.current=!0),W.current?_jsxs(View,{style:StyleSheet.absoluteFill,pointerEvents:"box-none",testID:f,accessibilityViewIsModal:A,children:[_jsx(Animated.View,{style:[X.backdrop,{backgroundColor:g.colors.scrim},G],children:_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:J,accessibilityRole:"button",accessibilityLabel:b.close,disabled:!l||!A})}),_jsx(GestureDetector,{gesture:B,children:_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:h??b.drawer,style:[z,{backgroundColor:g.colors.surface,...g.shadow.modal},d,Y],children:_jsx(View,{style:X.content,children:p})})})]}):null});Drawer.displayName="Drawer";const resolveSize=(e,t,a)=>{if("number"==typeof e)return e;if("string"==typeof e){const r=parseFloat(e);if(Number.isNaN(r))return t?280:Math.round(.4*a.height);return r/100*(t?a.width:a.height)}return t?280:Math.round(.4*a.height)},buildStyles=e=>StyleSheet.create({backdrop:{...StyleSheet.absoluteFill},content:{flex:1}});export{Drawer};export default Drawer;
1
+ "use strict";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Dimensions,Pressable,StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{Extrapolation,interpolate,runOnJS,useAnimatedStyle,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{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_DRAWER_LABELS={close:"Close drawer",drawer:"Drawer"};const DEFAULT_CLOSE_VELOCITY_THRESHOLD=1e3,DEFAULT_DRAG_ACTIVATION_OFFSET=10,Drawer=forwardRef((e,t)=>{const{open:a,defaultOpen:r=!1,onOpenChange:i,side:o="left",width:s,enableSwipe:n=!0,enableBackdropPress:l=!0,backdropOpacity:u=.5,haptic:c,containerStyle:d,children:p,accessibilityLabel:h,labels:m,testID:f}=e,g=useTheme();warnInvalidValue("Drawer","side",e.side,["left","right","top","bottom"]);const b=useMemo(()=>({...DEFAULT_DRAWER_LABELS,...m}),[m]),v=usePresenceMotion(),w=v.reduced,S=v.duration("default"),E=v.duration("fast"),y=useSafeAreaInsets(),M="boolean"==typeof a,[_,D]=useState(()=>Dimensions.get("window"));useEffect(()=>{const e=Dimensions.addEventListener("change",({window:e})=>D(e));return()=>e.remove()},[]);const C="left"===o||"right"===o,O=useMemo(()=>resolveSize(s,C,_),[s,C,_]),R=useMemo(()=>{switch(o){case"left":case"top":return-O;case"right":case"bottom":return O}},[o,O]),T=useSharedValue(r?0:R),x=useSharedValue(r?0:R),k=useSharedValue(r?1:0),[A,L]=useState(r),I=useSharedValue(r);useEffect(()=>{A||w||(T.value=R,x.value=R)},[R,A,T,x,w]);const V=g.motion.spring.snappy,j=useCallback(()=>{if(w)return T.value=0,void(k.value=withTiming(1,{duration:S,reduceMotion:PRESENCE_REDUCE_MOTION}));k.value=1,T.value=withSpring(0,V)},[T,k,V,w,S]),N=useCallback(()=>{w?k.value=withTiming(0,{duration:E,reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(T.value=R)}):T.value=withSpring(R,V)},[T,k,R,V,w,E]),P=useCallback(e=>{L(t=>t===e?t:(i?.(e),e)),I.value=e},[i,I]),F=useCallback(()=>{P(!0),j()},[P,j]),U=useCallback(()=>{P(!1),N()},[P,N]),H=useCallback(()=>{A?U():F()},[A,F,U]);useImperativeHandle(t,()=>({open:F,close:U,toggle:H}),[F,U,H]),useEffect(()=>{M&&a!==A&&(a?F():U())},[a]);const B=useMemo(()=>{const e=R,t=o,a=n;let r=Gesture.Pan();return r=C?r.activeOffsetX([-10,10]).failOffsetY([-15,15]):r.activeOffsetY([-10,10]).failOffsetX([-15,15]),r.onStart(()=>{"worklet";a&&(x.value=T.value)}).onUpdate(t=>{"worklet";if(!a)return;const r=C?t.translationX:t.translationY,i=x.value+r,o=Math.min(0,e),s=Math.max(0,e);T.value=i<o?o+.25*(i-o):i>s?s+.25*(i-s):i}).onEnd(r=>{"worklet";if(!a)return;const i=C?r.velocityX:r.velocityY,o=T.value;let s=!1;s="left"===t||"top"===t?i<-1e3:i>1e3;const n=Math.abs(e),l=Math.abs(o)/n;s||l>.5?(runOnJS(P)(!1),w?k.value=withTiming(0,{duration:E,reduceMotion:PRESENCE_REDUCE_MOTION},t=>{"worklet";t&&(T.value=e)}):T.value=withSpring(e,V)):(runOnJS(P)(!0),w?(T.value=0,k.value=withTiming(1,{duration:S,reduceMotion:PRESENCE_REDUCE_MOTION})):T.value=withSpring(0,V))})},[R,x,n,C,T,k,P,o,V,w,S,E]),Y=useAnimatedStyle(()=>C?{opacity:k.value,transform:[{translateX:T.value}]}:{opacity:k.value,transform:[{translateY:T.value}]},[C,T,k]),G=useAnimatedStyle(()=>({opacity:interpolate(T.value,[R,0],[0,u],Extrapolation.CLAMP)*k.value,pointerEvents:Math.abs(T.value-R)<.5?"none":"auto"}),[T,R,u,k]),X=useMemo(()=>buildStyles(g),[g]),J=useCallback(()=>{if(!l)return;const e=resolveHaptic(c,"selection");e&&triggerHaptic(e),U()},[l,U,c]),z=useMemo(()=>{switch(o){case"left":return{position:"absolute",top:0,bottom:0,left:0,width:O,paddingTop:y.top,paddingBottom:y.bottom,paddingLeft:y.left};case"right":return{position:"absolute",top:0,bottom:0,right:0,width:O,paddingTop:y.top,paddingBottom:y.bottom,paddingRight:y.right};case"top":return{position:"absolute",top:0,left:0,right:0,height:O,paddingTop:y.top,paddingLeft:y.left,paddingRight:y.right};case"bottom":return{position:"absolute",bottom:0,left:0,right:0,height:O,paddingBottom:y.bottom,paddingLeft:y.left,paddingRight:y.right}}},[o,O,y]),W=useRef(r);return A&&(W.current=!0),W.current?_jsxs(View,{style:StyleSheet.absoluteFill,pointerEvents:"box-none",testID:f,accessibilityViewIsModal:A,children:[_jsx(Animated.View,{style:[X.backdrop,{backgroundColor:g.colors.scrim},G],children:_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:J,accessibilityRole:"button",accessibilityLabel:b.close,disabled:!l||!A})}),_jsx(GestureDetector,{gesture:B,children:_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:h??b.drawer,style:[z,{backgroundColor:g.colors.surface,...g.shadow.modal},d,Y],children:_jsx(View,{style:X.content,children:p})})})]}):null});Drawer.displayName="Drawer";const resolveSize=(e,t,a)=>{if("number"==typeof e)return e;if("string"==typeof e){const r=parseFloat(e);if(Number.isNaN(r))return t?280:Math.round(.4*a.height);return r/100*(t?a.width:a.height)}return t?280:Math.round(.4*a.height)},buildStyles=e=>StyleSheet.create({backdrop:{...StyleSheet.absoluteFill},content:{flex:1}});export{Drawer};export default Drawer;