@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";import{useCallback,useEffect,useMemo,useState}from"react";import{Gesture}from"react-native-gesture-handler";import{runOnJS,scrollTo,useAnimatedRef,useAnimatedStyle,useScrollViewOffset,useSharedValue,withTiming}from"react-native-reanimated";const DOUBLE_TAP_ZOOM=2.5;export const ZOOM_REST=1.01;const clamp=(e,a,l)=>{"worklet";return Math.min(Math.max(e,a),l)},panLimit=(e,a)=>{"worklet";return e*(a-1)/2};export const useFileViewerZoom=({zoomEnabled:e,maxZoom:a,viewportWidth:l,viewportHeight:u,maxScroll:t})=>{const[i,n]=useState(1),v=useAnimatedRef(),r=useScrollViewOffset(v),o=useSharedValue(0),s=useSharedValue(0),m=useSharedValue(0),c=useSharedValue(0),h=useSharedValue(1),d=useSharedValue(1),w=useSharedValue(0),S=useSharedValue(0),p=useSharedValue(0),f=useSharedValue(0);useEffect(()=>{m.value=l,c.value=u,s.value=t},[l,u,t,m,c,s]);const T=useCallback(()=>{h.value=withTiming(1),w.value=withTiming(0),S.value=withTiming(0),d.value=1,p.value=0,f.value=0,n(1)},[h,d,w,S,p,f]);useEffect(()=>{e||T()},[e,T]);const g=useCallback(e=>n(e),[]),V=useMemo(()=>Gesture.Native(),[]),k=useMemo(()=>{const l=Math.max(1,a),u=Math.min(2.5,l),t=Gesture.Pinch().enabled(e).onStart(()=>{"worklet";d.value=h.value,p.value=w.value,f.value=S.value}).onUpdate(e=>{"worklet";const a=clamp(d.value*e.scale,1,l),u=e.focalX-m.value/2,t=e.focalY-c.value/2,i=a/d.value,n=panLimit(m.value,a),v=panLimit(c.value,a);w.value=clamp(u-(u-p.value)*i,-n,n),S.value=clamp(t-(t-f.value)*i,-v,v),h.value=a}).onEnd(()=>{"worklet";if(h.value<=1.01)return h.value=withTiming(1),w.value=withTiming(0),S.value=withTiming(0),d.value=1,p.value=0,f.value=0,void runOnJS(g)(1);d.value=h.value,p.value=w.value,f.value=S.value,runOnJS(g)(h.value)}),i=Gesture.Pan().enabled(e).minPointers(1).maxPointers(1).manualActivation(!0).onTouchesMove((e,a)=>{"worklet";h.value>1.01?a.activate():a.fail()}).onStart(()=>{"worklet";p.value=w.value,f.value=S.value,o.value=r.value}).onUpdate(e=>{"worklet";const a=h.value,l=panLimit(m.value,a),u=panLimit(c.value,a);w.value=clamp(p.value+e.translationX,-l,l);const t=f.value+e.translationY,i=clamp(t,-u,u),n=t-i;if(0!==n){const e=clamp(o.value-n/a,0,s.value);e!==o.value&&(o.value=e,scrollTo(v,0,e,!1)),f.value-=n}S.value=i}).onEnd(()=>{"worklet";p.value=w.value,f.value=S.value}),n=Gesture.Tap().enabled(e).numberOfTaps(2).maxDistance(10).onEnd(e=>{"worklet";if(h.value>1.01)return h.value=withTiming(1),w.value=withTiming(0),S.value=withTiming(0),d.value=1,p.value=0,f.value=0,void runOnJS(g)(1);if(u<=1.01)return;const a=e.x-m.value/2,l=e.y-c.value/2,t=panLimit(m.value,u),i=panLimit(c.value,u),n=clamp(-a*(u-1),-t,t),v=clamp(-l*(u-1),-i,i);h.value=withTiming(u),w.value=withTiming(n),S.value=withTiming(v),d.value=u,p.value=n,f.value=v,runOnJS(g)(u)});return t.simultaneousWithExternalGesture(V),i.simultaneousWithExternalGesture(V),n.simultaneousWithExternalGesture(V),Gesture.Simultaneous(t,i,n)},[a,e,g,V,v,r,o,s,m,c,h,d,w,S,p,f]),O=useAnimatedStyle(()=>({transform:[{translateX:w.value},{translateY:S.value},{scale:h.value}]}));return{scrollRef:v,scrollGesture:V,zoomGesture:k,zoomStyle:O,zoomLevel:i,resetZoom:T}};
1
+ "use strict";import{useCallback,useEffect,useMemo,useState}from"react";import{Gesture}from"react-native-gesture-handler";import{runOnJS,scrollTo,useAnimatedRef,useAnimatedStyle,useScrollViewOffset,useSharedValue,withTiming}from"react-native-reanimated";const DOUBLE_TAP_ZOOM=2.5;export const ZOOM_REST=1.01;const clamp=(e,a,l)=>{"worklet";return Math.min(Math.max(e,a),l)},panLimit=(e,a)=>{"worklet";return e*(a-1)/2};export const useFileViewerZoom=({zoomEnabled:e,maxZoom:a,viewportWidth:l,viewportHeight:u,maxScroll:t})=>{const[i,n]=useState(1),v=useAnimatedRef(),r=useScrollViewOffset(v),o=useSharedValue(0),s=useSharedValue(0),m=useSharedValue(0),c=useSharedValue(0),h=useSharedValue(1),d=useSharedValue(1),w=useSharedValue(0),S=useSharedValue(0),p=useSharedValue(0),f=useSharedValue(0);useEffect(()=>{m.value=l,c.value=u,s.value=t},[l,u,t,m,c,s]);const T=useCallback(()=>{h.value=withTiming(1),w.value=withTiming(0),S.value=withTiming(0),d.value=1,p.value=0,f.value=0,n(1)},[h,d,w,S,p,f]);useEffect(()=>{e||T()},[e,T]);const g=useCallback(e=>n(e),[]),V=useMemo(()=>Gesture.Native(),[]),k=useMemo(()=>{const l=Math.max(1,a),u=Math.min(2.5,l),t=Gesture.Pinch().enabled(e).onStart(()=>{"worklet";d.value=h.value,p.value=w.value,f.value=S.value}).onUpdate(e=>{"worklet";const a=clamp(d.value*e.scale,1,l),u=e.focalX-m.value/2,t=e.focalY-c.value/2,i=a/d.value,n=panLimit(m.value,a),v=panLimit(c.value,a);w.value=clamp(u-(u-p.value)*i,-n,n),S.value=clamp(t-(t-f.value)*i,-v,v),h.value=a}).onEnd(()=>{"worklet";if(h.value<=1.01)return h.value=withTiming(1),w.value=withTiming(0),S.value=withTiming(0),d.value=1,p.value=0,f.value=0,void runOnJS(g)(1);d.value=h.value,p.value=w.value,f.value=S.value,runOnJS(g)(h.value)}),i=Gesture.Pan().enabled(e).minPointers(1).maxPointers(1).manualActivation(!0).onTouchesMove((e,a)=>{"worklet";h.value>1.01?a.activate():a.fail()}).onStart(()=>{"worklet";p.value=w.value,f.value=S.value,o.value=r.value}).onUpdate(e=>{"worklet";const a=h.value,l=panLimit(m.value,a),u=panLimit(c.value,a);w.value=clamp(p.value+e.translationX,-l,l);const t=f.value+e.translationY,i=clamp(t,-u,u),n=t-i;if(0!==n){const e=clamp(o.value-n/a,0,s.value);e!==o.value&&(o.value=e,scrollTo(v,0,e,!1)),f.value-=n}S.value=i}).onEnd(()=>{"worklet";p.value=w.value,f.value=S.value}),n=Gesture.Tap().enabled(e).numberOfTaps(2).maxDistance(10).onEnd(e=>{"worklet";if(h.value>1.01)return h.value=withTiming(1),w.value=withTiming(0),S.value=withTiming(0),d.value=1,p.value=0,f.value=0,void runOnJS(g)(1);if(u<=1.01)return;const a=e.x-m.value/2,l=e.y-c.value/2,t=panLimit(m.value,u),i=panLimit(c.value,u),n=clamp(-a*(u-1),-t,t),v=clamp(-l*(u-1),-i,i);h.value=withTiming(u),w.value=withTiming(n),S.value=withTiming(v),d.value=u,p.value=n,f.value=v,runOnJS(g)(u)});return t.simultaneousWithExternalGesture(V),i.simultaneousWithExternalGesture(V),n.simultaneousWithExternalGesture(V),Gesture.Simultaneous(t,i,n)},[a,e,g,V,v,r,o,s,m,c,h,d,w,S,p,f]),O=useAnimatedStyle(()=>({transform:[{translateX:w.value},{translateY:S.value},{scale:h.value}]}),[w,S,h]);return{scrollRef:v,scrollGesture:V,zoomGesture:k,zoomStyle:O,zoomLevel:i,resetZoom:T}};
@@ -1 +1 @@
1
- "use strict";import{Logger}from"@webority/mobile-core";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Animated,BackHandler,Easing,Platform,Pressable,StyleSheet,Text,View}from"react-native";import Reanimated,{cancelAnimation,Easing as ReanimatedEasing,useAnimatedStyle,useSharedValue,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{createAnimatedValue,resolveFloatingActionButtonSize,setNativeValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{ACCENT_PRESSED_TINT}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";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"]: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=forwardRef((e,t)=>{const{icon:o,onPress:n,label:i,collapsed:s=!1,size:r="md",tone:a="primary",position:l,bottomOffset:c,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:p=!1,accessibilityLabel:b,accessibilityHint:g,haptic:f,style:h,containerStyle:y,labelStyle:A,testID:S}=e;warnInvalidValue("FloatingActionButton","size",e.size,FAB_SIZES),warnInvalidValue("FloatingActionButton","tone",e.tone,FAB_TONES),warnInvalidValue("FloatingActionButton","position",e.position,FAB_POSITIONS);const w=!u&&!d,x=useTheme(),_=useSafeAreaInsets(),v=useMemo(()=>resolveFloatingActionButtonSize(x,r),[x,r]),I=useMemo(()=>buildStyles(x),[x]),{scale:E,opacity:R,pressIn:F,pressOut:C}=usePressAnimation({enabled:w}),j=usePresenceMotion(),T=x.space[x.components["floating-action-button"]["edge-offset"]],B=x.space[x.components["floating-action-button"]["bottom-offset"]],P=useRef(createAnimatedValue(1)).current,V=j.duration("default");useEffect(()=>{if(!m)return void setNativeValue(P,1);const e=Animated.timing(P,{toValue:p?0:1,duration:V,easing:Easing.bezier(...x.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[m,p,P,V,x.motion.ease["in-out"]]);const k=v.diameter+(c??B)+_.bottom+T,O=P.interpolate({inputRange:[0,1],outputRange:j.range(k,0)}),L=useMemo(()=>Animated.multiply(P,R),[P,R]),N="string"==typeof i&&i.length>0,D=N&&s,z=j.reduced,M=x.space.sm,G=v["label-padding-x"],H=x.motion.duration.fast,$=x.motion.ease["in-out"],U=useSharedValue(D?1:0),[W,Y]=useState(null);useEffect(()=>{const e=D?1:0;return U.value=z?e:withTiming(e,{duration:H,easing:ReanimatedEasing.bezier(...$)}),()=>cancelAnimation(U)},[D,z,U,H,$]);const Z=useCallback(e=>{const t=Math.ceil(e);Y(e=>e===t?e:t)},[]),q=useAnimatedStyle(()=>({paddingHorizontal:G*(1-U.value)})),Q=useAnimatedStyle(()=>{const e=Math.max(0,1-2*U.value);return null===W?U.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(W+M)*(1-U.value)}}),X=u?x.colors["surface-disabled"]:toneBackground(x,a),J=u?x.colors["text-disabled"]:toneForeground(x,a),K=d?_jsx(Spinner,{variant:"circular",size:"lg"===r?"md":"sm",color:J}):renderSlotIcon(o,{color:J,size:v.icon,disabled:u}),ee=useMemo(()=>{if(!l)return null;const e=(c??B)+_.bottom;switch(l){case"bottomLeft":return{position:"absolute",bottom:e,left:T};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:T}}},[l,c,_.bottom,B,T]);return _jsx(Animated.View,{style:[ee,{transform:[{translateY:O},{scale:E}],opacity:L},y,h],pointerEvents:m&&p?"none":"auto",children:_jsx(Pressable,{ref:t,onPress:e=>{if(!w)return;const t=resolveHaptic(f,"impactLight");t&&triggerHaptic(t),n()},onPressIn:F,onPressOut:C,disabled:!w,accessibilityRole:"button",accessibilityLabel:b,accessibilityHint:g,accessibilityState:{disabled:!w,busy:d},"aria-disabled":!w,"aria-busy":d,testID:S,style:[I.base,N?{height:v.diameter,minWidth:v.diameter,borderRadius:v.diameter/2,...smoothCorners}:{width:v.diameter,height:v.diameter,borderRadius:v.diameter/2,...smoothCorners},x.shadow.popover,{backgroundColor:X,opacity:u||d?.55:1}],children:({pressed:e})=>_jsxs(_Fragment,{children:[e&&w?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[I.pressedTint,{backgroundColor:pressedTintFor(x,a),borderRadius:v.diameter/2,...smoothCorners}]}):null,N?_jsxs(Reanimated.View,{style:[I.extendedRow,q],children:[K,_jsx(Reanimated.View,{style:[I.labelClip,Q],children:_jsx(Text,{onLayout:e=>Z(e.nativeEvent.layout.width),style:[I.label,{color:J,fontSize:v.text,fontWeight:x.weight.semibold,marginLeft:M},A],numberOfLines:1,children:i})})]}):K]})})})});FloatingActionButton.displayName="FloatingActionButton";const buildStyles=e=>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.":"";export const DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS={quickActions:"Quick actions",expanded:(e,t)=>`${e}, expanded, ${t} ${1===t?"action":"actions"}`,collapsed:e=>`${e}, collapsed`};const FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:o,actions:n,expanded:i,defaultExpanded:s=!1,onExpandedChange:r,labels:a,position:l="bottomRight",bottomOffset:c,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:p=!1,isScrolling:b=!1,containerStyle:g,secondaryActionStyle:f,labelPillStyle:h,labelStyle:y,testID:A}=e;warnInvalidValue("FloatingActionButtonGroup","size",e.size,FAB_SIZES),warnInvalidValue("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const S=useMemo(()=>({...DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS,...a}),[a]),w=d??S.quickActions,x=useTheme(),_=useSafeAreaInsets(),v=useMemo(()=>resolveFloatingActionButtonSize(x,u),[x,u]),I=useMemo(()=>buildGroupStyles(x),[x]),E=usePresenceMotion(),R=E.duration("default"),F=x.space[x.components["floating-action-button"]["edge-offset"]],C=x.space[x.components["floating-action-button"]["bottom-offset"]],j=x.space[x.components["floating-action-button"]["secondary-gap"]],T=x.components["floating-action-button"]["stagger-ms"],B=useMemo(()=>n.slice(0,6),[n]),P=B.length,V=useMemo(()=>B.map((e,t)=>({action:e,index:t})).reverse(),[B]);n.forEach(e=>{warnInvalidValue("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const k=__DEV__?describeActionProblem(n):"";useEffect(()=>{__DEV__&&k&&Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${k}`)},[k]);const O="boolean"==typeof i,[L,N]=useState(s),D=O?i:L,z=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(!p)return void setNativeValue(z,1);const e=Animated.timing(z,{toValue:b?0:1,duration:R,easing:Easing.bezier(...x.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[p,b,z,R,x.motion.ease["in-out"]]);const M=p&&b;useEffect(()=>{M&&D&&(O||N(!1),r?.(!1))},[M,D,O,r]);const G=v.diameter+(c??C)+_.bottom+F,H=z.interpolate({inputRange:[0,1],outputRange:E.range(G,0)}),$=z,U=useRef(createAnimatedValue(D?1:0)).current,W=useRef([]),[Y,Z]=useState(0);useEffect(()=>{const e=W.current;if(e.length!==P){if(e.length<P){const t=e.slice();for(let o=e.length;o<P;o+=1)t.push(new Animated.Value(D?1:0));W.current=t}else W.current=e.slice(0,P);Z(e=>e+1)}},[P]),useEffect(()=>{const e=Animated.timing(U,{toValue:D?1:0,duration:R,easing:Easing.bezier(...x.motion.ease["in-out"]),useNativeDriver:!0});e.start();const t=W.current.map(e=>Animated.timing(e,{toValue:D?1:0,duration:R,easing:Easing.bezier(...x.motion.ease["in-out"]),useNativeDriver:!0})),o=D?t:[...t].reverse(),n=Animated.stagger(T,o);return n.start(),()=>{e.stop(),n.stop()}},[D,U,R,x.motion.ease["in-out"],P,Y,T]);const q=useCallback(e=>{const t=resolveHaptic(m,"impactLight");t&&triggerHaptic(t),O||N(e),r?.(e)},[O,r,m]),Q=useRef(null),X=useRef(D),J=useRef(!1);useEffect(()=>{if(X.current===D)return;X.current=D;const e=J.current;if(J.current=!1,M||e)return;const t=Q.current;t&&("web"===Platform.OS?t.focus?.():AccessibilityInfo.sendAccessibilityEvent(t,"focus")),announce(D?S.expanded(w,P):S.collapsed(w))},[D,M,w,P,S]);const K=useCallback(()=>{q(!D)},[D,q]),ee=useCallback(e=>{!1!==m&&triggerHaptic("selection"),J.current=!0,e.onPress(),O||N(!1),r?.(!1)},[O,r,m]),te=useCallback(()=>{D&&q(!1)},[D,q]);useEffect(()=>{if(!D)return;const e=BackHandler.addEventListener("hardwareBackPress",()=>(q(!1),!0));return()=>e.remove()},[D,q]),useEffect(()=>{if(!D||"web"!==Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&q(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[D,q]);const oe=useMemo(()=>{const e=(c??C)+_.bottom;switch(l){case"bottomLeft":return{position:"absolute",bottom:e,left:F,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:F,alignItems:"flex-end"}}},[l,c,_.bottom,C,F]),slotOffset=e=>-(v.diameter+j)*(e+1),ne=useMemo(()=>{switch(l){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"}}},[l]),ie=.78*v.diameter,se=useMemo(()=>{const e=ie+x.space.sm;switch(l){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:v.diameter/2+ie/2+x.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[l,ie,v.diameter,x.space.sm]),re=U.interpolate({inputRange:[0,1],outputRange:[0,.4]}),ae=U.interpolate(E.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return _jsxs(_Fragment,{children:[D?_jsx(Animated.View,{pointerEvents:D?"auto":"none",style:[StyleSheet.absoluteFill,{backgroundColor:x.colors.scrim,opacity:re}],children:_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:te,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:A?`${A}-backdrop`:void 0})}):null,_jsxs(Animated.View,{pointerEvents:M?"none":"box-none",style:[oe,{transform:[{translateY:H}],opacity:$},g],accessibilityRole:"menu",testID:A,children:[V.map(({action:e,index:t})=>{const o=W.current[t];if(!o)return null;const n=o.interpolate({inputRange:[0,1],outputRange:E.range(0,slotOffset(t))}),i=o.interpolate({inputRange:[0,1],outputRange:E.range(.6,1)}),s=toneBackground(x,e.tone??"primary"),r=toneForeground(x,e.tone??"primary"),a=e.label?_jsx(View,{pointerEvents:"none",style:[I.labelSlot,se],testID:A?`${A}-label-${e.key}`:void 0,children:_jsx(View,{style:[I.labelPill,x.shadow.card,{backgroundColor:x.colors.surface,paddingHorizontal:x.space.sm,paddingVertical:x.space.xs,borderRadius:x.radius.sm,...smoothCorners},h],children:_jsx(Text,{style:[{color:x.colors["text-body"],fontSize:x.text.sm.size,fontWeight:x.weight.medium},y],numberOfLines:1,children:e.label})})}):null;return _jsxs(Animated.View,{pointerEvents:D?"auto":"none",accessibilityElementsHidden:!D,importantForAccessibility:D?"auto":"no-hide-descendants","aria-hidden":!D,style:[I.secondaryRow,ne,{position:"absolute",bottom:0,opacity:o,transform:[{translateY:n},{scale:i}]}],children:[_jsx(Pressable,{onPress:()=>ee(e),focusable:D,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[I.fabBase,x.shadow.elevated,{width:ie,height:ie,borderRadius:ie/2,...smoothCorners,backgroundColor:s},f],testID:A?`${A}-action-${e.key}`:void 0,children:({pressed:t})=>_jsxs(_Fragment,{children:[t?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[I.pressedTint,{backgroundColor:pressedTintFor(x,e.tone??"primary"),borderRadius:ie/2,...smoothCorners}]}):null,renderSlotIcon(e.icon,{color:r,size:v.icon,disabled:!1})]})}),a]},e.key)}),_jsx(Pressable,{ref:Q,onPress:K,accessibilityRole:"button",accessibilityLabel:w,accessibilityState:{expanded:D},"aria-expanded":D,style:[I.fabBase,x.shadow.popover,{width:v.diameter,height:v.diameter,borderRadius:v.diameter/2,...smoothCorners,backgroundColor:x.colors.primary}],testID:A?`${A}-primary`:void 0,children:({pressed:e})=>_jsxs(_Fragment,{children:[e?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[I.pressedTint,{backgroundColor:ACCENT_PRESSED_TINT,borderRadius:v.diameter/2,...smoothCorners}]}):null,_jsx(Animated.View,{style:o?void 0:{transform:[{rotate:ae}]},children:renderSlotIcon(D&&o?o:t,{color:x.colors["on-primary"],size:v.icon,disabled:!1})})]})})]})]})},buildGroupStyles=e=>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"}});export{FloatingActionButton,FloatingActionButtonGroup};export default FloatingActionButton;
1
+ "use strict";import{Logger}from"@webority/mobile-core";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Animated,BackHandler,Easing,Platform,Pressable,StyleSheet,Text,View}from"react-native";import Reanimated,{cancelAnimation,Easing as ReanimatedEasing,useAnimatedStyle,useSharedValue,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{createAnimatedValue,resolveFloatingActionButtonSize,setNativeValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{ACCENT_PRESSED_TINT}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";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"]: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=forwardRef((e,t)=>{const{icon:o,onPress:n,label:i,collapsed:s=!1,size:r="md",tone:a="primary",position:l,bottomOffset:c,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:p=!1,accessibilityLabel:b,accessibilityHint:g,haptic:f,style:h,containerStyle:y,labelStyle:A,testID:S}=e;warnInvalidValue("FloatingActionButton","size",e.size,FAB_SIZES),warnInvalidValue("FloatingActionButton","tone",e.tone,FAB_TONES),warnInvalidValue("FloatingActionButton","position",e.position,FAB_POSITIONS);const w=!u&&!d,x=useTheme(),_=useSafeAreaInsets(),v=useMemo(()=>resolveFloatingActionButtonSize(x,r),[x,r]),I=useMemo(()=>buildStyles(x),[x]),{scale:E,opacity:R,pressIn:F,pressOut:C}=usePressAnimation({enabled:w}),j=usePresenceMotion(),T=x.space[x.components["floating-action-button"]["edge-offset"]],B=x.space[x.components["floating-action-button"]["bottom-offset"]],P=useRef(createAnimatedValue(1)).current,V=j.duration("default");useEffect(()=>{if(!m)return void setNativeValue(P,1);const e=Animated.timing(P,{toValue:p?0:1,duration:V,easing:Easing.bezier(...x.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[m,p,P,V,x.motion.ease["in-out"]]);const k=v.diameter+(c??B)+_.bottom+T,O=P.interpolate({inputRange:[0,1],outputRange:j.range(k,0)}),L=useMemo(()=>Animated.multiply(P,R),[P,R]),N="string"==typeof i&&i.length>0,D=N&&s,z=j.reduced,M=x.space.sm,G=v["label-padding-x"],H=x.motion.duration.fast,$=x.motion.ease["in-out"],U=useSharedValue(D?1:0),[W,Y]=useState(null);useEffect(()=>{const e=D?1:0;return U.value=z?e:withTiming(e,{duration:H,easing:ReanimatedEasing.bezier(...$)}),()=>cancelAnimation(U)},[D,z,U,H,$]);const Z=useCallback(e=>{const t=Math.ceil(e);Y(e=>e===t?e:t)},[]),q=useAnimatedStyle(()=>({paddingHorizontal:G*(1-U.value)}),[G,U]),Q=useAnimatedStyle(()=>{const e=Math.max(0,1-2*U.value);return null===W?U.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(W+M)*(1-U.value)}},[U,W,M]),X=u?x.colors["surface-disabled"]:toneBackground(x,a),J=u?x.colors["text-disabled"]:toneForeground(x,a),K=d?_jsx(Spinner,{variant:"circular",size:"lg"===r?"md":"sm",color:J}):renderSlotIcon(o,{color:J,size:v.icon,disabled:u}),ee=useMemo(()=>{if(!l)return null;const e=(c??B)+_.bottom;switch(l){case"bottomLeft":return{position:"absolute",bottom:e,left:T};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:T}}},[l,c,_.bottom,B,T]);return _jsx(Animated.View,{style:[ee,{transform:[{translateY:O},{scale:E}],opacity:L},y,h],pointerEvents:m&&p?"none":"auto",children:_jsx(Pressable,{ref:t,onPress:e=>{if(!w)return;const t=resolveHaptic(f,"impactLight");t&&triggerHaptic(t),n()},onPressIn:F,onPressOut:C,disabled:!w,accessibilityRole:"button",accessibilityLabel:b,accessibilityHint:g,accessibilityState:{disabled:!w,busy:d},"aria-disabled":!w,"aria-busy":d,testID:S,style:[I.base,N?{height:v.diameter,minWidth:v.diameter,borderRadius:v.diameter/2,...smoothCorners}:{width:v.diameter,height:v.diameter,borderRadius:v.diameter/2,...smoothCorners},x.shadow.popover,{backgroundColor:X,opacity:u||d?.55:1}],children:({pressed:e})=>_jsxs(_Fragment,{children:[e&&w?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[I.pressedTint,{backgroundColor:pressedTintFor(x,a),borderRadius:v.diameter/2,...smoothCorners}]}):null,N?_jsxs(Reanimated.View,{style:[I.extendedRow,q],children:[K,_jsx(Reanimated.View,{style:[I.labelClip,Q],children:_jsx(Text,{onLayout:e=>Z(e.nativeEvent.layout.width),style:[I.label,{color:J,fontSize:v.text,fontWeight:x.weight.semibold,marginLeft:M},A],numberOfLines:1,children:i})})]}):K]})})})});FloatingActionButton.displayName="FloatingActionButton";const buildStyles=e=>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.":"";export const DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS={quickActions:"Quick actions",expanded:(e,t)=>`${e}, expanded, ${t} ${1===t?"action":"actions"}`,collapsed:e=>`${e}, collapsed`};const FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:o,actions:n,expanded:i,defaultExpanded:s=!1,onExpandedChange:r,labels:a,position:l="bottomRight",bottomOffset:c,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:p=!1,isScrolling:b=!1,containerStyle:g,secondaryActionStyle:f,labelPillStyle:h,labelStyle:y,testID:A}=e;warnInvalidValue("FloatingActionButtonGroup","size",e.size,FAB_SIZES),warnInvalidValue("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const S=useMemo(()=>({...DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS,...a}),[a]),w=d??S.quickActions,x=useTheme(),_=useSafeAreaInsets(),v=useMemo(()=>resolveFloatingActionButtonSize(x,u),[x,u]),I=useMemo(()=>buildGroupStyles(x),[x]),E=usePresenceMotion(),R=E.duration("default"),F=x.space[x.components["floating-action-button"]["edge-offset"]],C=x.space[x.components["floating-action-button"]["bottom-offset"]],j=x.space[x.components["floating-action-button"]["secondary-gap"]],T=x.components["floating-action-button"]["stagger-ms"],B=useMemo(()=>n.slice(0,6),[n]),P=B.length,V=useMemo(()=>B.map((e,t)=>({action:e,index:t})).reverse(),[B]);n.forEach(e=>{warnInvalidValue("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const k=__DEV__?describeActionProblem(n):"";useEffect(()=>{__DEV__&&k&&Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${k}`)},[k]);const O="boolean"==typeof i,[L,N]=useState(s),D=O?i:L,z=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(!p)return void setNativeValue(z,1);const e=Animated.timing(z,{toValue:b?0:1,duration:R,easing:Easing.bezier(...x.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[p,b,z,R,x.motion.ease["in-out"]]);const M=p&&b;useEffect(()=>{M&&D&&(O||N(!1),r?.(!1))},[M,D,O,r]);const G=v.diameter+(c??C)+_.bottom+F,H=z.interpolate({inputRange:[0,1],outputRange:E.range(G,0)}),$=z,U=useRef(createAnimatedValue(D?1:0)).current,W=useRef([]),[Y,Z]=useState(0);useEffect(()=>{const e=W.current;if(e.length!==P){if(e.length<P){const t=e.slice();for(let o=e.length;o<P;o+=1)t.push(new Animated.Value(D?1:0));W.current=t}else W.current=e.slice(0,P);Z(e=>e+1)}},[P]),useEffect(()=>{const e=Animated.timing(U,{toValue:D?1:0,duration:R,easing:Easing.bezier(...x.motion.ease["in-out"]),useNativeDriver:!0});e.start();const t=W.current.map(e=>Animated.timing(e,{toValue:D?1:0,duration:R,easing:Easing.bezier(...x.motion.ease["in-out"]),useNativeDriver:!0})),o=D?t:[...t].reverse(),n=Animated.stagger(T,o);return n.start(),()=>{e.stop(),n.stop()}},[D,U,R,x.motion.ease["in-out"],P,Y,T]);const q=useCallback(e=>{const t=resolveHaptic(m,"impactLight");t&&triggerHaptic(t),O||N(e),r?.(e)},[O,r,m]),Q=useRef(null),X=useRef(D),J=useRef(!1);useEffect(()=>{if(X.current===D)return;X.current=D;const e=J.current;if(J.current=!1,M||e)return;const t=Q.current;t&&("web"===Platform.OS?t.focus?.():AccessibilityInfo.sendAccessibilityEvent(t,"focus")),announce(D?S.expanded(w,P):S.collapsed(w))},[D,M,w,P,S]);const K=useCallback(()=>{q(!D)},[D,q]),ee=useCallback(e=>{!1!==m&&triggerHaptic("selection"),J.current=!0,e.onPress(),O||N(!1),r?.(!1)},[O,r,m]),te=useCallback(()=>{D&&q(!1)},[D,q]);useEffect(()=>{if(!D)return;const e=BackHandler.addEventListener("hardwareBackPress",()=>(q(!1),!0));return()=>e.remove()},[D,q]),useEffect(()=>{if(!D||"web"!==Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&q(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[D,q]);const oe=useMemo(()=>{const e=(c??C)+_.bottom;switch(l){case"bottomLeft":return{position:"absolute",bottom:e,left:F,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:F,alignItems:"flex-end"}}},[l,c,_.bottom,C,F]),slotOffset=e=>-(v.diameter+j)*(e+1),ne=useMemo(()=>{switch(l){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"}}},[l]),ie=.78*v.diameter,se=useMemo(()=>{const e=ie+x.space.sm;switch(l){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:v.diameter/2+ie/2+x.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[l,ie,v.diameter,x.space.sm]),re=U.interpolate({inputRange:[0,1],outputRange:[0,.4]}),ae=U.interpolate(E.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return _jsxs(_Fragment,{children:[D?_jsx(Animated.View,{pointerEvents:D?"auto":"none",style:[StyleSheet.absoluteFill,{backgroundColor:x.colors.scrim,opacity:re}],children:_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:te,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:A?`${A}-backdrop`:void 0})}):null,_jsxs(Animated.View,{pointerEvents:M?"none":"box-none",style:[oe,{transform:[{translateY:H}],opacity:$},g],accessibilityRole:"menu",testID:A,children:[V.map(({action:e,index:t})=>{const o=W.current[t];if(!o)return null;const n=o.interpolate({inputRange:[0,1],outputRange:E.range(0,slotOffset(t))}),i=o.interpolate({inputRange:[0,1],outputRange:E.range(.6,1)}),s=toneBackground(x,e.tone??"primary"),r=toneForeground(x,e.tone??"primary"),a=e.label?_jsx(View,{pointerEvents:"none",style:[I.labelSlot,se],testID:A?`${A}-label-${e.key}`:void 0,children:_jsx(View,{style:[I.labelPill,x.shadow.card,{backgroundColor:x.colors.surface,paddingHorizontal:x.space.sm,paddingVertical:x.space.xs,borderRadius:x.radius.sm,...smoothCorners},h],children:_jsx(Text,{style:[{color:x.colors["text-body"],fontSize:x.text.sm.size,fontWeight:x.weight.medium},y],numberOfLines:1,children:e.label})})}):null;return _jsxs(Animated.View,{pointerEvents:D?"auto":"none",accessibilityElementsHidden:!D,importantForAccessibility:D?"auto":"no-hide-descendants","aria-hidden":!D,style:[I.secondaryRow,ne,{position:"absolute",bottom:0,opacity:o,transform:[{translateY:n},{scale:i}]}],children:[_jsx(Pressable,{onPress:()=>ee(e),focusable:D,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[I.fabBase,x.shadow.elevated,{width:ie,height:ie,borderRadius:ie/2,...smoothCorners,backgroundColor:s},f],testID:A?`${A}-action-${e.key}`:void 0,children:({pressed:t})=>_jsxs(_Fragment,{children:[t?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[I.pressedTint,{backgroundColor:pressedTintFor(x,e.tone??"primary"),borderRadius:ie/2,...smoothCorners}]}):null,renderSlotIcon(e.icon,{color:r,size:v.icon,disabled:!1})]})}),a]},e.key)}),_jsx(Pressable,{ref:Q,onPress:K,accessibilityRole:"button",accessibilityLabel:w,accessibilityState:{expanded:D},"aria-expanded":D,style:[I.fabBase,x.shadow.popover,{width:v.diameter,height:v.diameter,borderRadius:v.diameter/2,...smoothCorners,backgroundColor:x.colors.primary}],testID:A?`${A}-primary`:void 0,children:({pressed:e})=>_jsxs(_Fragment,{children:[e?_jsx(View,{pointerEvents:"none",testID:"fab-pressed",style:[I.pressedTint,{backgroundColor:ACCENT_PRESSED_TINT,borderRadius:v.diameter/2,...smoothCorners}]}):null,_jsx(Animated.View,{style:o?void 0:{transform:[{rotate:ae}]},children:renderSlotIcon(D&&o?o:t,{color:x.colors["on-primary"],size:v.icon,disabled:!1})})]})})]})]})},buildGroupStyles=e=>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"}});export{FloatingActionButton,FloatingActionButtonGroup};export default FloatingActionButton;
@@ -1 +1 @@
1
- "use strict";import React,{useCallback,useMemo,useRef,useState}from"react";import{Dimensions,Image,Pressable,StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{runOnJS,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Carousel}from"../Carousel/index.js";import{Modal}from"../Modal/Modal.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_IMAGE_GALLERY_LABELS={gallery:"Image gallery",imageOf:(e,t)=>`Image ${e} of ${t}`,openFullscreen:"Tap to open fullscreen",closeGallery:"Close gallery"};const 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:t=0,showThumbnails:a=!0,showCounter:l=!0,enableLightbox:i=!0,enablePinchZoom:s=!0,onIndexChange:o,haptic:n,loading:r=!1,accessibilityLabel:c,containerStyle:u,testID:m,labels:d})=>{const h=useTheme(),g=useMemo(()=>buildStyles(h),[h]),p=useMemo(()=>({...DEFAULT_IMAGE_GALLERY_LABELS,...d}),[d]),[b,S]=useState(clamp(t,0,Math.max(0,e.length-1))),[x,y]=useState(!1),v=useCallback(e=>{S(e),o?.(e)},[o]),I=useCallback(()=>{if(!i)return;const e=resolveHaptic(n,"selection");e&&triggerHaptic(e),y(!0)},[i,n]),w=useCallback(()=>{const e=resolveHaptic(n,"selection");e&&triggerHaptic(e),y(!1)},[n]),C=useCallback((t,a)=>{const l=t.alt??p.imageOf(a+1,e.length);return _jsx(Pressable,{onPress:I,accessibilityRole:"image",accessibilityLabel:l,accessibilityHint:i?p.openFullscreen:void 0,style:g.imageWrap,children:_jsx(Image,{source:t.source,style:g.image,resizeMode:"cover"})})},[i,e.length,I,g,p]),_=useCallback(e=>_jsx(Image,{source:e.source,style:g.thumbnailImage,resizeMode:"cover"}),[g]),f=_jsxs(View,{style:[g.container,u],testID:m,accessibilityLabel:c??p.gallery,children:[_jsxs(View,{style:g.carouselWrap,accessibilityElementsHidden:x,importantForAccessibility:x?"no-hide-descendants":"auto",children:[_jsx(Carousel,{data:e,defaultIndex:t,onIndexChange:v,renderItem:C,showPagination:!1,showThumbnails:a,renderThumbnail:_,haptic:n}),l&&e.length>0?_jsx(View,{style:g.counterPill,pointerEvents:"none",children:_jsx(Text,{variant:"label",weight:"semibold",style:{color:h.colors["on-scrim"]},accessibilityLabel:p.imageOf(b+1,e.length),children:`${b+1} / ${e.length}`})}):null]}),i?_jsx(Lightbox,{open:x,images:e,initialIndex:b,enablePinchZoom:s,showCounter:l,onClose:w,onIndexChange:v,haptic:n,labels:p}):null]});return r?_jsx(ImageGallerySkeleton,{images:e,showThumbnails:a,showCounter:l,containerStyle:u,testID:m}):f};ImageGallery.displayName="ImageGallery";const ImageGallerySkeleton=({images:e,showThumbnails:t=!0,showCounter:a=!0,containerStyle:l,testID:i})=>{const s=useTheme(),o=Math.min(e?.length||4,6);return _jsxs(View,{style:[{width:"100%"},l],testID:i,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[_jsxs(View,{style:{position:"relative"},children:[_jsx(Skeleton,{width:"100%",height:280,radius:"lg"}),a?_jsx(View,{style:{position:"absolute",top:12,right:12},children:_jsx(Skeleton,{width:44,height:22,radius:"pill"})}):null]}),t?_jsx(View,{style:{flexDirection:"row",marginTop:s.space.md},children:Array.from({length:o}).map((e,t)=>_jsx(Skeleton,{width:64,height:64,radius:"md",style:{marginRight:s.space.sm}},`sk-thumb-${t}`))}):null]})};ImageGallerySkeleton.displayName="ImageGallerySkeleton",ImageGallery.Skeleton=ImageGallerySkeleton;const Lightbox=({open:e,images:t,initialIndex:a,enablePinchZoom:l,showCounter:i,onClose:s,onIndexChange:o,haptic:n,labels:r})=>{const c=useTheme(),u=useMemo(()=>buildLightboxStyles(c),[c]),m=useRef(null),[d,h]=useState(a),g=useCallback(e=>{if(e!==d){const t=resolveHaptic(n,"selection");t&&triggerHaptic(t),h(e),o(e)}},[d,o,n]),p=useCallback((e,a)=>_jsx(ZoomableImage,{image:e,index:a,total:t.length,active:a===d,enabled:l,maxScale:4,minScale:1,doubleTapScale:2,haptic:n,imageLabel:r.imageOf}),[d,l,t.length,n,r]),b=t[d]?.caption;return _jsx(Modal,{open:e,onClose:s,presentation:"fullScreen",backdropPressClose:!1,animateMount:!1,contentStyle:{backgroundColor:"transparent"},children:_jsxs(View,{style:u.backdrop,children:[_jsx(Carousel,{ref:m,data:t,defaultIndex:a,onIndexChange:g,renderItem:p,showPagination:!1,haptic:n}),i&&t.length>0?_jsx(View,{style:u.counterPill,pointerEvents:"none",children:_jsx(Text,{variant:"label",weight:"semibold",style:{color:c.colors["on-scrim"]},accessibilityLabel:r.imageOf(d+1,t.length),children:`${d+1} / ${t.length}`})}):null,_jsx(Pressable,{onPress:s,accessibilityRole:"button",accessibilityLabel:r.closeGallery,style:u.closeButton,hitSlop:12,...hitSlopMarker(12),children:(c.settings.icons.close??defaultIcons.close)({size:24,color:c.colors["on-scrim"]})}),b?_jsx(Animated.View,{style:u.captionWrap,entering:void 0,accessibilityElementsHidden:!1,children:_jsx(Text,{variant:"body",align:"center",numberOfLines:3,style:u.captionText,children:b})}):null]})})},ZoomableImage=({image:e,index:t,total:a,active:l,enabled:i,maxScale:s,minScale:o,doubleTapScale:n,haptic:r,imageLabel:c})=>{const u=Dimensions.get("window"),m=useSharedValue(1),d=useSharedValue(1),h=useSharedValue(0),g=useSharedValue(0),p=useSharedValue(0),b=useSharedValue(0),S=useCallback(()=>{m.value=withSpring(1,SPRING_CONFIG),d.value=1,h.value=withSpring(0,SPRING_CONFIG),g.value=withSpring(0,SPRING_CONFIG),p.value=0,b.value=0},[m,d,h,g,p,b]);React.useEffect(()=>{l||(m.value=withTiming(1,{duration:150}),h.value=withTiming(0,{duration:150}),g.value=withTiming(0,{duration:150}),d.value=1,p.value=0,b.value=0)},[l,m,h,g,d,p,b]);const x=useCallback(()=>{!1!==r&&triggerHaptic("impactLight")},[r]),y=useMemo(()=>Gesture.Pinch().enabled(i).onStart(()=>{"worklet";d.value=m.value}).onUpdate(e=>{"worklet";const t=d.value*e.scale;m.value=t<o?o+.3*(t-o):t>s?s+.2*(t-s):t}).onEnd(()=>{"worklet";return m.value<o?(m.value=withSpring(o,SPRING_CONFIG),h.value=withSpring(0,SPRING_CONFIG),g.value=withSpring(0,SPRING_CONFIG),d.value=o,p.value=0,void(b.value=0)):m.value>s?(m.value=withSpring(s,SPRING_CONFIG),void(d.value=s)):void(d.value=m.value)}),[i,m,d,h,g,p,b,o,s]),v=useMemo(()=>Gesture.Pan().minPointers(1).maxPointers(1).onStart(()=>{"worklet";p.value=h.value,b.value=g.value}).onUpdate(e=>{"worklet";m.value<=1||(h.value=p.value+e.translationX,g.value=b.value+e.translationY)}).onEnd(()=>{"worklet";p.value=h.value,b.value=g.value}),[m,h,g,p,b]),I=useMemo(()=>Gesture.Tap().numberOfTaps(2).onEnd(()=>{"worklet";runOnJS(x)(),m.value>1?(m.value=withSpring(1,SPRING_CONFIG),h.value=withSpring(0,SPRING_CONFIG),g.value=withSpring(0,SPRING_CONFIG),d.value=1,p.value=0,b.value=0):(m.value=withSpring(n,SPRING_CONFIG),d.value=n)}),[m,d,h,g,p,b,x,n]),w=useMemo(()=>Gesture.Race(y,v,I),[y,v,I]),C=useAnimatedStyle(()=>({transform:[{translateX:h.value},{translateY:g.value},{scale:m.value}]}));React.useEffect(()=>{l||S()},[l,S]);const _=e.alt??c(t+1,a);return _jsx(GestureDetector,{gesture:w,children:_jsx(Animated.View,{style:[lightboxImageStyles.container,{width:u.width}],children:_jsx(Animated.Image,{source:e.source,resizeMode:"contain",style:[lightboxImageStyles.image,C],accessibilityLabel:_,accessible:!0})})})},clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>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,...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,...smoothCorners,backgroundColor:"rgba(0,0,0,0.55)"}}),buildLightboxStyles=e=>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,...smoothCorners,backgroundColor:"rgba(0,0,0,0.6)"},closeButton:{position:"absolute",top:44,right:16,width:40,height:40,borderRadius:e.radius.pill,...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=StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"}});export{ImageGallery};export default ImageGallery;
1
+ "use strict";import React,{useCallback,useMemo,useRef,useState}from"react";import{Dimensions,Image,Pressable,StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{runOnJS,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Carousel}from"../Carousel/index.js";import{Modal}from"../Modal/Modal.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_IMAGE_GALLERY_LABELS={gallery:"Image gallery",imageOf:(e,t)=>`Image ${e} of ${t}`,openFullscreen:"Tap to open fullscreen",closeGallery:"Close gallery"};const 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:t=0,showThumbnails:a=!0,showCounter:l=!0,enableLightbox:i=!0,enablePinchZoom:s=!0,onIndexChange:o,haptic:n,loading:r=!1,accessibilityLabel:c,containerStyle:u,testID:m,labels:d})=>{const h=useTheme(),g=useMemo(()=>buildStyles(h),[h]),p=useMemo(()=>({...DEFAULT_IMAGE_GALLERY_LABELS,...d}),[d]),[b,S]=useState(clamp(t,0,Math.max(0,e.length-1))),[x,y]=useState(!1),v=useCallback(e=>{S(e),o?.(e)},[o]),I=useCallback(()=>{if(!i)return;const e=resolveHaptic(n,"selection");e&&triggerHaptic(e),y(!0)},[i,n]),w=useCallback(()=>{const e=resolveHaptic(n,"selection");e&&triggerHaptic(e),y(!1)},[n]),C=useCallback((t,a)=>{const l=t.alt??p.imageOf(a+1,e.length);return _jsx(Pressable,{onPress:I,accessibilityRole:"image",accessibilityLabel:l,accessibilityHint:i?p.openFullscreen:void 0,style:g.imageWrap,children:_jsx(Image,{source:t.source,style:g.image,resizeMode:"cover"})})},[i,e.length,I,g,p]),_=useCallback(e=>_jsx(Image,{source:e.source,style:g.thumbnailImage,resizeMode:"cover"}),[g]),f=_jsxs(View,{style:[g.container,u],testID:m,accessibilityLabel:c??p.gallery,children:[_jsxs(View,{style:g.carouselWrap,accessibilityElementsHidden:x,importantForAccessibility:x?"no-hide-descendants":"auto",children:[_jsx(Carousel,{data:e,defaultIndex:t,onIndexChange:v,renderItem:C,showPagination:!1,showThumbnails:a,renderThumbnail:_,haptic:n}),l&&e.length>0?_jsx(View,{style:g.counterPill,pointerEvents:"none",children:_jsx(Text,{variant:"label",weight:"semibold",style:{color:h.colors["on-scrim"]},accessibilityLabel:p.imageOf(b+1,e.length),children:`${b+1} / ${e.length}`})}):null]}),i?_jsx(Lightbox,{open:x,images:e,initialIndex:b,enablePinchZoom:s,showCounter:l,onClose:w,onIndexChange:v,haptic:n,labels:p}):null]});return r?_jsx(ImageGallerySkeleton,{images:e,showThumbnails:a,showCounter:l,containerStyle:u,testID:m}):f};ImageGallery.displayName="ImageGallery";const ImageGallerySkeleton=({images:e,showThumbnails:t=!0,showCounter:a=!0,containerStyle:l,testID:i})=>{const s=useTheme(),o=Math.min(e?.length||4,6);return _jsxs(View,{style:[{width:"100%"},l],testID:i,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[_jsxs(View,{style:{position:"relative"},children:[_jsx(Skeleton,{width:"100%",height:280,radius:"lg"}),a?_jsx(View,{style:{position:"absolute",top:12,right:12},children:_jsx(Skeleton,{width:44,height:22,radius:"pill"})}):null]}),t?_jsx(View,{style:{flexDirection:"row",marginTop:s.space.md},children:Array.from({length:o}).map((e,t)=>_jsx(Skeleton,{width:64,height:64,radius:"md",style:{marginRight:s.space.sm}},`sk-thumb-${t}`))}):null]})};ImageGallerySkeleton.displayName="ImageGallerySkeleton",ImageGallery.Skeleton=ImageGallerySkeleton;const Lightbox=({open:e,images:t,initialIndex:a,enablePinchZoom:l,showCounter:i,onClose:s,onIndexChange:o,haptic:n,labels:r})=>{const c=useTheme(),u=useMemo(()=>buildLightboxStyles(c),[c]),m=useRef(null),[d,h]=useState(a),g=useCallback(e=>{if(e!==d){const t=resolveHaptic(n,"selection");t&&triggerHaptic(t),h(e),o(e)}},[d,o,n]),p=useCallback((e,a)=>_jsx(ZoomableImage,{image:e,index:a,total:t.length,active:a===d,enabled:l,maxScale:4,minScale:1,doubleTapScale:2,haptic:n,imageLabel:r.imageOf}),[d,l,t.length,n,r]),b=t[d]?.caption;return _jsx(Modal,{open:e,onClose:s,presentation:"fullScreen",backdropPressClose:!1,animateMount:!1,contentStyle:{backgroundColor:"transparent"},children:_jsxs(View,{style:u.backdrop,children:[_jsx(Carousel,{ref:m,data:t,defaultIndex:a,onIndexChange:g,renderItem:p,showPagination:!1,haptic:n}),i&&t.length>0?_jsx(View,{style:u.counterPill,pointerEvents:"none",children:_jsx(Text,{variant:"label",weight:"semibold",style:{color:c.colors["on-scrim"]},accessibilityLabel:r.imageOf(d+1,t.length),children:`${d+1} / ${t.length}`})}):null,_jsx(Pressable,{onPress:s,accessibilityRole:"button",accessibilityLabel:r.closeGallery,style:u.closeButton,hitSlop:12,...hitSlopMarker(12),children:(c.settings.icons.close??defaultIcons.close)({size:24,color:c.colors["on-scrim"]})}),b?_jsx(Animated.View,{style:u.captionWrap,entering:void 0,accessibilityElementsHidden:!1,children:_jsx(Text,{variant:"body",align:"center",numberOfLines:3,style:u.captionText,children:b})}):null]})})},ZoomableImage=({image:e,index:t,total:a,active:l,enabled:i,maxScale:s,minScale:o,doubleTapScale:n,haptic:r,imageLabel:c})=>{const u=Dimensions.get("window"),m=useSharedValue(1),d=useSharedValue(1),h=useSharedValue(0),g=useSharedValue(0),p=useSharedValue(0),b=useSharedValue(0),S=useCallback(()=>{m.value=withSpring(1,SPRING_CONFIG),d.value=1,h.value=withSpring(0,SPRING_CONFIG),g.value=withSpring(0,SPRING_CONFIG),p.value=0,b.value=0},[m,d,h,g,p,b]);React.useEffect(()=>{l||(m.value=withTiming(1,{duration:150}),h.value=withTiming(0,{duration:150}),g.value=withTiming(0,{duration:150}),d.value=1,p.value=0,b.value=0)},[l,m,h,g,d,p,b]);const x=useCallback(()=>{!1!==r&&triggerHaptic("impactLight")},[r]),y=useMemo(()=>Gesture.Pinch().enabled(i).onStart(()=>{"worklet";d.value=m.value}).onUpdate(e=>{"worklet";const t=d.value*e.scale;m.value=t<o?o+.3*(t-o):t>s?s+.2*(t-s):t}).onEnd(()=>{"worklet";return m.value<o?(m.value=withSpring(o,SPRING_CONFIG),h.value=withSpring(0,SPRING_CONFIG),g.value=withSpring(0,SPRING_CONFIG),d.value=o,p.value=0,void(b.value=0)):m.value>s?(m.value=withSpring(s,SPRING_CONFIG),void(d.value=s)):void(d.value=m.value)}),[i,m,d,h,g,p,b,o,s]),v=useMemo(()=>Gesture.Pan().minPointers(1).maxPointers(1).onStart(()=>{"worklet";p.value=h.value,b.value=g.value}).onUpdate(e=>{"worklet";m.value<=1||(h.value=p.value+e.translationX,g.value=b.value+e.translationY)}).onEnd(()=>{"worklet";p.value=h.value,b.value=g.value}),[m,h,g,p,b]),I=useMemo(()=>Gesture.Tap().numberOfTaps(2).onEnd(()=>{"worklet";runOnJS(x)(),m.value>1?(m.value=withSpring(1,SPRING_CONFIG),h.value=withSpring(0,SPRING_CONFIG),g.value=withSpring(0,SPRING_CONFIG),d.value=1,p.value=0,b.value=0):(m.value=withSpring(n,SPRING_CONFIG),d.value=n)}),[m,d,h,g,p,b,x,n]),w=useMemo(()=>Gesture.Race(y,v,I),[y,v,I]),C=useAnimatedStyle(()=>({transform:[{translateX:h.value},{translateY:g.value},{scale:m.value}]}),[h,g,m]);React.useEffect(()=>{l||S()},[l,S]);const _=e.alt??c(t+1,a);return _jsx(GestureDetector,{gesture:w,children:_jsx(Animated.View,{style:[lightboxImageStyles.container,{width:u.width}],children:_jsx(Animated.Image,{source:e.source,resizeMode:"contain",style:[lightboxImageStyles.image,C],accessibilityLabel:_,accessible:!0})})})},clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>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,...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,...smoothCorners,backgroundColor:"rgba(0,0,0,0.55)"}}),buildLightboxStyles=e=>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,...smoothCorners,backgroundColor:"rgba(0,0,0,0.6)"},closeButton:{position:"absolute",top:44,right:16,width:40,height:40,borderRadius:e.radius.pill,...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=StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"}});export{ImageGallery};export default ImageGallery;
@@ -1 +1 @@
1
- "use strict";import{formatDate}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{FlatList,StyleSheet,View}from"react-native";import{KeyboardChatScrollView}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{smoothCorners}from"../../utils/corners.js";import{Badge}from"../Badge/index.js";import{DateSeparator,dayLabel}from"../DateSeparator/index.js";import{IconButton}from"../IconButton/index.js";import{Spinner}from"../Spinner/index.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";export const 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"});const JUMP_AT=160,KEEP_POSITION={minIndexForVisible:0,autoscrollToTopThreshold:160},positionOf=(e,t)=>e?t?"middle":"last":t?"first":"single";export function MessageList({messages:e,keyExtractor:t,renderMessage:o,getAuthorKey:s,getDate:n,firstUnreadKey:r,onLoadOlder:a,loadingOlder:l=!1,hasOlder:i=!0,typing:d,empty:u,getAnnouncement:c,followNew:m,keyboardAware:p=!0,keyboardOffset:f,labels:g,now:y,onScroll:x,contentContainerStyle:b,style:j,testID:S,...h}){const _=useTheme(),w=useSafeAreaInsets(),L=useReducedMotion(),E=useMemo(()=>buildStyles(_),[_]),C=useMemo(()=>({...DEFAULT_MESSAGE_LIST_LABELS,...g}),[g]),v=f??w.bottom,I=useRef(null),T=useRef(!1),[k,M]=useState(!1),[O,D]=useState(0),A=useMemo(()=>{const o=n?e.map(e=>formatDate(n(e))):null,a=s?e.map(s):null,l=void 0===r?-1:e.findIndex(e=>t(e)===r);return e.map((t,s)=>{const r=s===e.length-1,i=null!==o&&(r||o[s]!==o[s+1]),d=null!==a&&!r&&a[s+1]===a[s]&&!i&&s!==l,u=null!==a&&s>0&&a[s-1]===a[s]&&(null===o||o[s-1]===o[s])&&s-1!==l;return{groupPosition:positionOf(d,u),day:i&&n?dayLabel(n(t),{now:y,labels:C}):null,unread:s===l}})},[e,n,s,r,t,y,C]),V=useCallback(()=>{I.current?.scrollToOffset({offset:0,animated:!L}),D(0)},[L]),P=e.length>0?t(e[0]):null,F=useRef(P);useEffect(()=>{const o=F.current;if(F.current=P,null===o||null===P||o===P)return;const s=e.findIndex(e=>t(e)===o);if(-1===s)return void D(0);const n=e.slice(0,s).reverse();for(const e of n){const t=c?.(e);t&&announce(t)}m&&n.some(m)?V():T.current&&D(e=>e+n.length)},[P]);const R=useCallback(e=>{const t=e.nativeEvent.contentOffset.y>160;t!==T.current&&(T.current=t,M(t),t||D(0)),x?.(e)},[x]),B=useCallback(()=>{i&&!l&&a?.()},[i,l,a]),K=useCallback(({item:e,index:t})=>{const s=A[t];return _jsxs(_Fragment,{children:[s?.day?_jsx(DateSeparator,{label:s.day}):null,s?.unread?_jsx(DateSeparator,{label:C.unread,emphasis:!0}):null,o({item:e,index:t,groupPosition:s?.groupPosition??"single"})]})},[A,C.unread,o]),z=useCallback(e=>t(e),[t]),N=useCallback(e=>_jsx(KeyboardChatScrollView,{...e,inverted:!0,offset:v}),[v]),U=O>0?`${C.newMessages(O)}. ${C.jumpToLatest}`:C.jumpToLatest;return _jsxs(View,{style:[E.root,j],children:[_jsx(FlatList,{keyboardShouldPersistTaps:"handled",maintainVisibleContentPosition:KEEP_POSITION,...h,ref:I,data:e,renderItem:K,keyExtractor:z,inverted:!0,onScroll:R,onEndReached:a?B:void 0,ListHeaderComponent:d?_jsx(View,{children:d}):null,ListFooterComponent:l?_jsx(Spinner,{size:"sm",accessibilityLabel:C.loadingOlder,style:E.older}):null,ListEmptyComponent:u?_jsx(View,{style:E.fill,children:u}):null,renderScrollComponent:p?N:void 0,contentContainerStyle:[E.content,0===e.length?E.grow:null,b],testID:S}),k?_jsxs(View,{style:E.jump,pointerEvents:"box-none",children:[_jsx(View,{style:E.jumpDisc,children:_jsx(IconButton,{icon:"arrow-down",accessibilityLabel:U,variant:"ghost",tone:"neutral",onPress:V,testID:S?`${S}-jump`:void 0})}),O>0?_jsx(View,{style:E.count,pointerEvents:"none",importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,children:_jsx(Badge,{value:O,max:99,tone:"primary",size:"sm"})}):null]}):null]})}const buildStyles=e=>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,...smoothCorners,backgroundColor:e.colors.surface,...e.shadow.elevated},count:{position:"absolute",top:-e.space.xs,right:-e.space.xs}});export default MessageList;
1
+ "use strict";import{formatDate}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{FlatList,StyleSheet,View}from"react-native";import{KeyboardChatScrollView}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{smoothCorners}from"../../utils/corners.js";import{Badge}from"../Badge/index.js";import{DateSeparator,dayLabel}from"../DateSeparator/index.js";import{IconButton}from"../IconButton/index.js";import{Spinner}from"../Spinner/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const 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"});const JUMP_AT=160,FOLLOW_AT=48,KEEP_POSITION={minIndexForVisible:0,autoscrollToTopThreshold:160},positionOf=(e,t)=>e?t?"middle":"last":t?"first":"single";export function MessageList({messages:e,keyExtractor:t,renderMessage:o,getAuthorKey:n,getDate:s,firstUnreadKey:r,onLoadOlder:a,loadingOlder:l=!1,hasOlder:i=!0,typing:u,empty:c,getAnnouncement:d,followNew:m,keyboardAware:p=!0,keyboardOffset:f,labels:y,now:g,onScroll:x,onContentSizeChange:b,contentContainerStyle:S,style:h,testID:j,...w}){const L=useTheme(),_=useSafeAreaInsets(),C=useReducedMotion(),E=useMemo(()=>buildStyles(L),[L]),v=useMemo(()=>({...DEFAULT_MESSAGE_LIST_LABELS,...y}),[y]),T=f??_.bottom,O=useRef(null),I=useRef(!1),k=useRef(!0),M=useRef(0),[A,D]=useState(!1),[V,P]=useState(0),R=useMemo(()=>{const o=s?e.map(e=>formatDate(s(e))):null,a=n?e.map(n):null,l=void 0===r?-1:e.findIndex(e=>t(e)===r);return e.map((t,n)=>{const r=n===e.length-1,i=null!==o&&(r||o[n]!==o[n+1]),u=null!==a&&!r&&a[n+1]===a[n]&&!i&&n!==l,c=null!==a&&n>0&&a[n-1]===a[n]&&(null===o||o[n-1]===o[n])&&n-1!==l;return{groupPosition:positionOf(u,c),day:i&&s?dayLabel(s(t),{now:g,labels:v}):null,unread:n===l}})},[e,s,n,r,t,g,v]),B=useCallback(()=>{k.current=!0,O.current?.scrollToOffset({offset:0,animated:!C}),P(0)},[C]),F=e.length>0?t(e[0]):null,z=useRef(F);useEffect(()=>{const o=z.current;if(z.current=F,null===o||null===F||o===F)return;const n=e.findIndex(e=>t(e)===o);if(-1===n)return void P(0);const s=e.slice(0,n).reverse();for(const e of s){const t=d?.(e);t&&announce(t)}m&&s.some(m)?B():I.current&&P(e=>e+s.length)},[F]);const K=useCallback(e=>{k.current=e.nativeEvent.contentOffset.y<=48;const t=e.nativeEvent.contentOffset.y>160;t!==I.current&&(I.current=t,D(t),t||P(0)),x?.(e)},[x]),N=useCallback((e,t)=>{const o=t>M.current;M.current=t,o&&k.current&&O.current?.scrollToOffset({offset:0,animated:!1}),b?.(e,t)},[b]),U=useCallback(()=>{i&&!l&&a?.()},[i,l,a]),$=useCallback(({item:e,index:t})=>{const n=R[t];return _jsxs(View,{children:[n?.day?_jsx(DateSeparator,{label:n.day}):null,n?.unread?_jsx(DateSeparator,{label:v.unread,emphasis:!0}):null,o({item:e,index:t,groupPosition:n?.groupPosition??"single"})]})},[R,v.unread,o]),G=useCallback(e=>t(e),[t]),H=useCallback(e=>_jsx(KeyboardChatScrollView,{...e,inverted:!0,offset:T}),[T]),J=V>0?`${v.newMessages(V)}. ${v.jumpToLatest}`:v.jumpToLatest;return _jsxs(View,{style:[E.root,h],children:[_jsx(FlatList,{keyboardShouldPersistTaps:"handled",maintainVisibleContentPosition:KEEP_POSITION,...w,ref:O,data:e,renderItem:$,keyExtractor:G,inverted:!0,onScroll:K,onContentSizeChange:N,onEndReached:a?U:void 0,ListHeaderComponent:u?_jsx(View,{children:u}):null,ListFooterComponent:l?_jsx(Spinner,{size:"sm",accessibilityLabel:v.loadingOlder,style:E.older}):null,ListEmptyComponent:c?_jsx(View,{style:E.fill,children:c}):null,renderScrollComponent:p?H:void 0,contentContainerStyle:[E.content,0===e.length?E.grow:null,S],testID:j}),A?_jsxs(View,{style:E.jump,pointerEvents:"box-none",children:[_jsx(View,{style:E.jumpDisc,children:_jsx(IconButton,{icon:"arrow-down",accessibilityLabel:J,variant:"ghost",tone:"neutral",onPress:B,testID:j?`${j}-jump`:void 0})}),V>0?_jsx(View,{style:E.count,pointerEvents:"none",importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,children:_jsx(Badge,{value:V,max:99,tone:"primary",size:"sm"})}):null]}):null]})}const buildStyles=e=>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,...smoothCorners,backgroundColor:e.colors.surface,...e.shadow.elevated},count:{position:"absolute",top:-e.space.xs,right:-e.space.xs}});export default MessageList;
@@ -1 +1 @@
1
- "use strict";import React,{forwardRef,useCallback,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SLIDE_TO_CONFIRM_LABELS=Object.freeze({slide:"Slide to confirm",confirmed:"Confirmed",confirmAction:"Confirm"});const SIZE_MAP={sm:{height:44,pad:"xxs"},md:{height:56,pad:"xs"},lg:{height:64,pad:"sm"}},Chevron=({color:e,size:t})=>_jsx(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=forwardRef((e,t)=>{const{onConfirm:i,label:a,tone:r="primary",size:o="md",disabled:n=!1,threshold:s=.9,resetAfter:l=!1,haptic:c,icon:d,labels:u,style:m,trackStyle:h,handleStyle:f,labelStyle:p,testID:b}=e;warnInvalidValue("SlideToConfirm","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("SlideToConfirm","size",e.size,["sm","md","lg"]);const g=useMemo(()=>({...DEFAULT_SLIDE_TO_CONFIRM_LABELS,...u}),[u]),S=useMemo(()=>[{name:"activate",label:g.confirmAction},{name:"increment",label:g.confirmAction}],[g.confirmAction]),v=useTheme(),y=SIZE_MAP[o],C=v.space[y.pad],x=y.height-2*C,w=useMemo(()=>buildStyles(v,y),[v,y]),A=v.colors[r],[T,j]=useState(!1),_=useSharedValue(0),E=useSharedValue(0),k=useSharedValue(0),L=useRef(null),V=useCallback(()=>{const e=resolveHaptic(c,"notificationSuccess");e&&triggerHaptic(e)},[c]),I=useCallback(()=>{j(!1),_.value=withSpring(0,{damping:18,stiffness:160,mass:1})},[_]),M=useCallback(()=>{j(!0),V(),i(),!1!==l&&(L.current&&clearTimeout(L.current),L.current=setTimeout(I,l))},[V,i,l,I]),R=useCallback(e=>{if(n||T)return;const{actionName:t}=e.nativeEvent;"activate"!==t&&"increment"!==t||M()},[n,T,M]);React.useEffect(()=>()=>{cancelAnimation(_),L.current&&clearTimeout(L.current)},[_]);const D=useCallback(e=>{E.value=Math.max(0,e.nativeEvent.layout.width-x-2*C)},[E,x,C]),O=useMemo(()=>{const e=s,t={damping:18,stiffness:160,mass:1},i={duration:v.motion.duration.fast,easing:Easing.out(Easing.cubic)};return Gesture.Pan().enabled(!n&&!T).minDistance(0).onStart(()=>{"worklet";k.value=_.value}).onUpdate(e=>{"worklet";_.value=Math.min(Math.max(k.value+e.translationX,0),E.value)}).onEnd(()=>{"worklet";E.value>0&&_.value>=E.value*e?(_.value=withTiming(E.value,i),runOnJS(M)()):_.value=withSpring(0,t)})},[n,T,s,_,E,k,M,v.motion.duration.fast]),z=useAnimatedStyle(()=>({transform:[{translateX:_.value}]})),F=useAnimatedStyle(()=>({width:_.value+x+C})),W=useAnimatedStyle(()=>{const e=E.value>0?E.value:1;return{opacity:Math.max(0,1-_.value/(.6*e))}});return _jsxs(View,{ref:t,style:[w.track,{backgroundColor:v.colors["bg-subtle"]},h,m],onLayout:D,testID:b,accessibilityRole:"adjustable",accessibilityLabel:T?g.confirmed:a??g.slide,accessibilityState:{disabled:n},"aria-disabled":n,accessibilityActions:S,onAccessibilityAction:R,children:[_jsx(Animated.View,{style:[w.fill,{backgroundColor:A,opacity:n?.5:1},F],pointerEvents:"none"}),_jsx(Animated.View,{style:[w.labelWrap,W],pointerEvents:"none",children:_jsx(Text,{variant:"body",style:[w.label,{color:v.colors["text-muted"]},p],numberOfLines:1,children:T?g.confirmed:a??g.slide})}),_jsx(GestureDetector,{gesture:O,children:_jsx(Animated.View,{style:[w.handle,{width:x,height:x,borderRadius:v.radius.pill,...smoothCorners,backgroundColor:v.colors.surface,opacity:n?.5:1,...v.shadow.card},f,z],children:d??_jsx(Chevron,{color:A,size:.5*x})})})]})});SlideToConfirm.displayName="SlideToConfirm";const buildStyles=(e,t)=>StyleSheet.create({track:{height:t.height,borderRadius:e.radius.pill,...smoothCorners,justifyContent:"center",overflow:"hidden",padding:e.space[t.pad]},fill:{position:"absolute",left:0,top:0,bottom:0,borderRadius:e.radius.pill,...smoothCorners},labelWrap:{position:"absolute",left:t.height,right:t.height},label:{textAlign:"center",includeFontPadding:!1},handle:{alignItems:"center",justifyContent:"center"}});export{SlideToConfirm};export default SlideToConfirm;
1
+ "use strict";import React,{forwardRef,useCallback,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SLIDE_TO_CONFIRM_LABELS=Object.freeze({slide:"Slide to confirm",confirmed:"Confirmed",confirmAction:"Confirm"});const SIZE_MAP={sm:{height:44,pad:"xxs"},md:{height:56,pad:"xs"},lg:{height:64,pad:"sm"}},Chevron=({color:e,size:t})=>_jsx(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=forwardRef((e,t)=>{const{onConfirm:i,label:a,tone:r="primary",size:o="md",disabled:n=!1,threshold:s=.9,resetAfter:l=!1,haptic:c,icon:d,labels:u,style:m,trackStyle:h,handleStyle:f,labelStyle:p,testID:b}=e;warnInvalidValue("SlideToConfirm","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("SlideToConfirm","size",e.size,["sm","md","lg"]);const g=useMemo(()=>({...DEFAULT_SLIDE_TO_CONFIRM_LABELS,...u}),[u]),S=useMemo(()=>[{name:"activate",label:g.confirmAction},{name:"increment",label:g.confirmAction}],[g.confirmAction]),v=useTheme(),y=SIZE_MAP[o],C=v.space[y.pad],x=y.height-2*C,w=useMemo(()=>buildStyles(v,y),[v,y]),A=v.colors[r],[T,j]=useState(!1),_=useSharedValue(0),E=useSharedValue(0),k=useSharedValue(0),L=useRef(null),V=useCallback(()=>{const e=resolveHaptic(c,"notificationSuccess");e&&triggerHaptic(e)},[c]),I=useCallback(()=>{j(!1),_.value=withSpring(0,{damping:18,stiffness:160,mass:1})},[_]),M=useCallback(()=>{j(!0),V(),i(),!1!==l&&(L.current&&clearTimeout(L.current),L.current=setTimeout(I,l))},[V,i,l,I]),R=useCallback(e=>{if(n||T)return;const{actionName:t}=e.nativeEvent;"activate"!==t&&"increment"!==t||M()},[n,T,M]);React.useEffect(()=>()=>{cancelAnimation(_),L.current&&clearTimeout(L.current)},[_]);const D=useCallback(e=>{E.value=Math.max(0,e.nativeEvent.layout.width-x-2*C)},[E,x,C]),O=useMemo(()=>{const e=s,t={damping:18,stiffness:160,mass:1},i={duration:v.motion.duration.fast,easing:Easing.out(Easing.cubic)};return Gesture.Pan().enabled(!n&&!T).minDistance(0).onStart(()=>{"worklet";k.value=_.value}).onUpdate(e=>{"worklet";_.value=Math.min(Math.max(k.value+e.translationX,0),E.value)}).onEnd(()=>{"worklet";E.value>0&&_.value>=E.value*e?(_.value=withTiming(E.value,i),runOnJS(M)()):_.value=withSpring(0,t)})},[n,T,s,_,E,k,M,v.motion.duration.fast]),z=useAnimatedStyle(()=>({transform:[{translateX:_.value}]}),[_]),F=useAnimatedStyle(()=>({width:_.value+x+C}),[_,x,C]),W=useAnimatedStyle(()=>{const e=E.value>0?E.value:1;return{opacity:Math.max(0,1-_.value/(.6*e))}},[E,_]);return _jsxs(View,{ref:t,style:[w.track,{backgroundColor:v.colors["bg-subtle"]},h,m],onLayout:D,testID:b,accessibilityRole:"adjustable",accessibilityLabel:T?g.confirmed:a??g.slide,accessibilityState:{disabled:n},"aria-disabled":n,accessibilityActions:S,onAccessibilityAction:R,children:[_jsx(Animated.View,{style:[w.fill,{backgroundColor:A,opacity:n?.5:1},F],pointerEvents:"none"}),_jsx(Animated.View,{style:[w.labelWrap,W],pointerEvents:"none",children:_jsx(Text,{variant:"body",style:[w.label,{color:v.colors["text-muted"]},p],numberOfLines:1,children:T?g.confirmed:a??g.slide})}),_jsx(GestureDetector,{gesture:O,children:_jsx(Animated.View,{style:[w.handle,{width:x,height:x,borderRadius:v.radius.pill,...smoothCorners,backgroundColor:v.colors.surface,opacity:n?.5:1,...v.shadow.card},f,z],children:d??_jsx(Chevron,{color:A,size:.5*x})})})]})});SlideToConfirm.displayName="SlideToConfirm";const buildStyles=(e,t)=>StyleSheet.create({track:{height:t.height,borderRadius:e.radius.pill,...smoothCorners,justifyContent:"center",overflow:"hidden",padding:e.space[t.pad]},fill:{position:"absolute",left:0,top:0,bottom:0,borderRadius:e.radius.pill,...smoothCorners},labelWrap:{position:"absolute",left:t.height,right:t.height},label:{textAlign:"center",includeFontPadding:!1},handle:{alignItems:"center",justifyContent:"center"}});export{SlideToConfirm};export default SlideToConfirm;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Platform,Pressable,StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useControllableState}from"../../hooks/index.js";import{resolveSliderSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Text}from"../Text/index.js";import{sliderToneInk}from"./valueText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";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=forwardRef((e,t)=>{const{min:a=0,max:i=100,step:r=1,disabled:n=!1,tone:s="primary",size:o="md",variant:l="default",showLabel:u=!1,snapThumb:c=!1,formatLabel:d=defaultFormatLabel,renderLabel:m,accessibilityLabel:h,haptic:b,style:p,containerStyle:f,trackStyle:g,fillStyle:v,thumbStyle:w,labelStyle:y,thumbPressScale:S,labelShowDuration:k,labelOpacity:C,testID:x}=e;warnInvalidValue("Slider","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Slider","size",e.size,["sm","md","lg"]),warnInvalidValue("Slider","variant",e.variant,["default","inset","minimal","bar"]);const A=useTheme(),V=useMemo(()=>{const e=resolveSliderSize(A,o);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[A,o]),j=useMemo(()=>"default"===l?V:VARIANT_SIZE_MAP[l][o],[V,o,l]),M="inset"===l?j.trackHeight/2:0,_=A.settings.components.slider?.thumbPressAnimation??!1,D=S??1.1,H=k??A.motion.duration.fast,E=C??1,O=useMemo(()=>buildStyles(A,j),[A,j]),T=useMemo(()=>({damping:A.motion.spring.snappy.damping,stiffness:A.motion.spring.snappy.stiffness,mass:A.motion.spring.snappy.mass}),[A.motion.spring.snappy]),[R,I]=useState(0),W=A.colors[s],L=sliderToneInk(A,s),N=!0===e.range,[P,X]=useControllableState({value:e.value,defaultValue:e.defaultValue??(N?[a,i]:a),onChange:e.onChange}),B=useSharedValue(0),F=useSharedValue(0),z=useSharedValue(N?P[0]:P),G=useSharedValue(N?P[1]:P),J=useSharedValue(0),U=useSharedValue(0),Z=useSharedValue(1),$=useSharedValue(1),q="always"===u,K=useSharedValue(q?1:0),Q=useSharedValue(q?1:0),Y=useMemo(()=>10**(String(r).split(".")[1]?.length??0),[r]);useEffect(()=>()=>{cancelAnimation(B),cancelAnimation(F),cancelAnimation(Z),cancelAnimation($),cancelAnimation(K),cancelAnimation(Q)},[B,F,Z,$,K,Q]);const ee=useCallback((e,t)=>{const r=t-2*M;return i===a||r<=0?M:M+(e-a)/(i-a)*r},[a,i,M]),te=useCallback((e,t)=>{const n=t-2*M;if(n<=0)return a;const s=clamp((e-M)/n,0,1);return snapToStep(a+s*(i-a),a,i,r)},[a,i,r,M]),ae=useRef(!1),ie=A.motion.duration.fast,re=useRef(P);re.current=P;const ne=useRef(R);ne.current=R;const se=useCallback((e=!1)=>{const t=ne.current;if(t<=0)return;const place=t=>e?withTiming(t,{duration:ie,easing:Easing.out(Easing.cubic)}):t,a=re.current;if(N){const[e,i]=a,r=Math.min(e,i),n=Math.max(e,i);z.value=r,G.value=n,B.value=place(ee(r,t)),F.value=place(ee(n,t))}else{const e=a;z.value=e,G.value=e,B.value=place(ee(e,t))}},[N,ee,z,G,B,F,ie]),[oe,le]=useState(0),ue=useRef(!1),ce=useCallback(e=>{ae.current=e,e||(ue.current=!0,le(e=>e+1))},[]);useEffect(()=>{if(ae.current)return;const e=ue.current;ue.current=!1,se(e)},[JSON.stringify(P),R,oe,se]);const de=useCallback(e=>{const t=e.nativeEvent.layout.width;U.value=t,I(t)},[U]),me=useCallback((e,t)=>{X(N?[e,t]:e)},[N,X]),he=useCallback(()=>{const e=resolveHaptic(b,"selection");e&&triggerHaptic(e)},[b]),be=useRef(me);be.current=me;const pe=useRef(he);pe.current=he;const fe=useCallback((e,t)=>be.current(e,t),[]),ge=useCallback(()=>pe.current(),[]),ve=Math.max(0,(44-j.thumbDiameter)/2),we=ve>0?ve:void 0,ye=useCallback(e=>{const t="low"===e?B:F,s="low"===e?z:G,o="low"===e?G:z,l="low"===e?Z:$,d="low"===e?K:Q,m="low"===e,h=a,b=i,p=r,f=Y,g=N,v=D,w=_,y=!0===u,S=c,k=E,C=H,x=T,A=M,follow=e=>{"worklet";const a=U.value-2*A;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(J.value+e,A),U.value-A);let r=h+(i-A)/a*(b-h);p>0&&(r=Math.round((r-h)/p)*p+h,r=Math.round(r*f)/f),r=Math.min(Math.max(r,h),b),g&&(m&&r>o.value&&(r=o.value),!m&&r<o.value&&(r=o.value)),t.value=S||b===h?b===h?A:A+(r-h)/(b-h)*a:g?m?Math.min(i,F.value):Math.max(i,B.value):i,r!==s.value&&(s.value=r,r!==h&&r!==b||runOnJS(ge)(),runOnJS(fe)(z.value,G.value))},V=Gesture.Pan().enabled(!n).minDistance(0);return(void 0===we?V:V.hitSlop(we)).onStart(()=>{"worklet";runOnJS(ce)(!0),J.value=t.value,w&&(l.value=withSpring(v,x)),y&&(d.value=withTiming(k,{duration:C,easing:Easing.out(Easing.cubic)})),runOnJS(ge)()}).onUpdate(e=>{"worklet";follow(e.translationX)}).onEnd(e=>{"worklet";follow(e.translationX),w&&(l.value=withSpring(1,x)),y&&(d.value=withTiming(0,{duration:C,easing:Easing.out(Easing.cubic)}))}).onFinalize(()=>{"worklet";runOnJS(ce)(!1)})},[n,a,i,r,Y,N,D,_,u,c,E,H,T,M,we,fe,ge,ce,B,F,z,G,Z,$,K,Q,J,U]),Se=useMemo(()=>ye("low"),[ye]),ke=useMemo(()=>ye("high"),[ye]),Ce=useCallback(e=>{if(n||N||R<=0)return;const t=clamp(e.nativeEvent.locationX,0,R),a=te(t,R);a!==z.value&&(he(),z.value=a,B.value=withTiming(ee(a,R),{duration:A.motion.duration.fast,easing:Easing.out(Easing.cubic)}),me(a,a))},[n,N,R,te,ee,me,he,B,z,A.motion.duration.fast]),xe=useCallback(e=>{if(n)return;const t="increment"===e.nativeEvent.actionName?r:-r,s=r>0?Math.round(t*Y)/Y:t;if(N){const e=Math.round((z.value+s)*Y)/Y,t=clamp(e,a,G.value);t!==z.value&&(z.value=t,B.value=ee(t,R),he(),me(t,G.value))}else{const e=Math.round((z.value+s)*Y)/Y,t=clamp(e,a,i);t!==z.value&&(z.value=t,B.value=ee(t,R),he(),me(t,t))}},[n,r,Y,N,a,i,ee,R,B,z,G,me,he]),Ae=j.thumbDiameter/2,Ve=n?A.colors["surface-disabled"]:W,je="inset"===l?{backgroundColor:Ve,borderColor:A.colors.surface,borderWidth:Math.max(2,Math.round(.3*j.thumbDiameter)),...NO_SHADOW}:"minimal"===l?{backgroundColor:Ve,borderWidth:0}:"bar"===l?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:A.colors.surface,borderColor:Ve},Me=useAnimatedStyle(()=>{const e=U.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=n?.55:1;if(N){const a=Math.max(0,F.value-B.value+2*M);return{opacity:t,transform:[{translateX:B.value-M},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:B.value+M-e},{scaleX:1}]}}),De=useAnimatedStyle(()=>({transform:[{translateX:B.value-Ae},{scale:Z.value}]})),He=useAnimatedStyle(()=>({transform:[{translateX:F.value-Ae},{scale:$.value}]})),Ee=useAnimatedStyle(()=>({opacity:K.value})),Oe=useAnimatedStyle(()=>({opacity:Q.value})),clampDisplay=e=>clamp(e,a,i),Te=clampDisplay(N?Math.min(...P):P),Re=clampDisplay(N?Math.max(...P):P);return _jsx(View,{ref:t,style:[O.container,f,p],testID:x,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:n},"aria-disabled":n,accessibilityValue:N?{min:a,max:i,now:Te,text:`${Te} to ${Re}`}:{min:a,max:i,now:Te},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:xe,children:_jsx(Pressable,{onPress:Ce,disabled:n||N,style:O.trackTouch,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:_jsxs(View,{style:O.trackWrap,onLayout:de,children:[_jsxs(View,{style:O.trackClip,pointerEvents:"none",children:[_jsx(View,{style:[O.track,{backgroundColor:n?A.colors["surface-disabled"]:A.colors.border},g]}),_jsx(Animated.View,{style:[O.fill,{backgroundColor:n?A.colors["surface-disabled"]:W},v,Me]})]}),_jsx(GestureDetector,{gesture:Se,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:Ae,...smoothCorners,opacity:n?.55:1},je,w,De],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[O.bubbleWrap,Ee],pointerEvents:"none",children:[_jsx(View,{style:[O.bubble,{backgroundColor:W}],children:m?m(Te):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:L},y],numberOfLines:1,children:d(Te)})}),_jsx(View,{style:[O.bubbleCaret,{backgroundColor:W}]})]}):null})}),N?_jsx(GestureDetector,{gesture:ke,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:Ae,...smoothCorners,opacity:n?.55:1},je,w,He],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[O.bubbleWrap,Oe],pointerEvents:"none",children:[_jsx(View,{style:[O.bubble,{backgroundColor:W}],children:m?m(Re):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:L},y],numberOfLines:1,children:d(Re)})}),_jsx(View,{style:[O.bubbleCaret,{backgroundColor:W}]})]}):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 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,...smoothCorners,overflow:"hidden"},track:{position:"absolute",top:0,right:0,bottom:0,left:0,borderRadius:t.trackHeight/2,...smoothCorners},fill:{position:"absolute",top:0,left:0,width:"100%",height:t.trackHeight,borderRadius:t.trackHeight/2,...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,...smoothCorners,transform:[{rotate:"45deg"}]},bubble:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xxs,borderRadius:e.radius.md,...smoothCorners,minWidth:36,alignItems:"center",justifyContent:"center",...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:{}})}})};export{Slider};export default Slider;
1
+ "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Platform,Pressable,StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useControllableState}from"../../hooks/index.js";import{resolveSliderSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Text}from"../Text/index.js";import{sliderToneInk}from"./valueText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";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=forwardRef((e,t)=>{const{min:a=0,max:i=100,step:r=1,disabled:n=!1,tone:s="primary",size:o="md",variant:l="default",showLabel:u=!1,snapThumb:c=!1,formatLabel:d=defaultFormatLabel,renderLabel:m,accessibilityLabel:h,haptic:b,style:p,containerStyle:f,trackStyle:g,fillStyle:v,thumbStyle:w,labelStyle:y,thumbPressScale:S,labelShowDuration:k,labelOpacity:C,testID:x}=e;warnInvalidValue("Slider","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Slider","size",e.size,["sm","md","lg"]),warnInvalidValue("Slider","variant",e.variant,["default","inset","minimal","bar"]);const A=useTheme(),V=useMemo(()=>{const e=resolveSliderSize(A,o);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[A,o]),j=useMemo(()=>"default"===l?V:VARIANT_SIZE_MAP[l][o],[V,o,l]),M="inset"===l?j.trackHeight/2:0,_=A.settings.components.slider?.thumbPressAnimation??!1,D=S??1.1,H=k??A.motion.duration.fast,E=C??1,O=useMemo(()=>buildStyles(A,j),[A,j]),T=useMemo(()=>({damping:A.motion.spring.snappy.damping,stiffness:A.motion.spring.snappy.stiffness,mass:A.motion.spring.snappy.mass}),[A.motion.spring.snappy]),[R,I]=useState(0),W=A.colors[s],L=sliderToneInk(A,s),N=!0===e.range,[P,X]=useControllableState({value:e.value,defaultValue:e.defaultValue??(N?[a,i]:a),onChange:e.onChange}),B=useSharedValue(0),F=useSharedValue(0),z=useSharedValue(N?P[0]:P),G=useSharedValue(N?P[1]:P),J=useSharedValue(0),U=useSharedValue(0),Z=useSharedValue(1),$=useSharedValue(1),q="always"===u,K=useSharedValue(q?1:0),Q=useSharedValue(q?1:0),Y=useMemo(()=>10**(String(r).split(".")[1]?.length??0),[r]);useEffect(()=>()=>{cancelAnimation(B),cancelAnimation(F),cancelAnimation(Z),cancelAnimation($),cancelAnimation(K),cancelAnimation(Q)},[B,F,Z,$,K,Q]);const ee=useCallback((e,t)=>{const r=t-2*M;return i===a||r<=0?M:M+(e-a)/(i-a)*r},[a,i,M]),te=useCallback((e,t)=>{const n=t-2*M;if(n<=0)return a;const s=clamp((e-M)/n,0,1);return snapToStep(a+s*(i-a),a,i,r)},[a,i,r,M]),ae=useRef(!1),ie=A.motion.duration.fast,re=useRef(P);re.current=P;const ne=useRef(R);ne.current=R;const se=useCallback((e=!1)=>{const t=ne.current;if(t<=0)return;const place=t=>e?withTiming(t,{duration:ie,easing:Easing.out(Easing.cubic)}):t,a=re.current;if(N){const[e,i]=a,r=Math.min(e,i),n=Math.max(e,i);z.value=r,G.value=n,B.value=place(ee(r,t)),F.value=place(ee(n,t))}else{const e=a;z.value=e,G.value=e,B.value=place(ee(e,t))}},[N,ee,z,G,B,F,ie]),[oe,le]=useState(0),ue=useRef(!1),ce=useCallback(e=>{ae.current=e,e||(ue.current=!0,le(e=>e+1))},[]);useEffect(()=>{if(ae.current)return;const e=ue.current;ue.current=!1,se(e)},[JSON.stringify(P),R,oe,se]);const de=useCallback(e=>{const t=e.nativeEvent.layout.width;U.value=t,I(t)},[U]),me=useCallback((e,t)=>{X(N?[e,t]:e)},[N,X]),he=useCallback(()=>{const e=resolveHaptic(b,"selection");e&&triggerHaptic(e)},[b]),be=useRef(me);be.current=me;const pe=useRef(he);pe.current=he;const fe=useCallback((e,t)=>be.current(e,t),[]),ge=useCallback(()=>pe.current(),[]),ve=Math.max(0,(44-j.thumbDiameter)/2),we=ve>0?ve:void 0,ye=useCallback(e=>{const t="low"===e?B:F,s="low"===e?z:G,o="low"===e?G:z,l="low"===e?Z:$,d="low"===e?K:Q,m="low"===e,h=a,b=i,p=r,f=Y,g=N,v=D,w=_,y=!0===u,S=c,k=E,C=H,x=T,A=M,follow=e=>{"worklet";const a=U.value-2*A;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(J.value+e,A),U.value-A);let r=h+(i-A)/a*(b-h);p>0&&(r=Math.round((r-h)/p)*p+h,r=Math.round(r*f)/f),r=Math.min(Math.max(r,h),b),g&&(m&&r>o.value&&(r=o.value),!m&&r<o.value&&(r=o.value)),t.value=S||b===h?b===h?A:A+(r-h)/(b-h)*a:g?m?Math.min(i,F.value):Math.max(i,B.value):i,r!==s.value&&(s.value=r,r!==h&&r!==b||runOnJS(ge)(),runOnJS(fe)(z.value,G.value))},V=Gesture.Pan().enabled(!n).minDistance(0);return(void 0===we?V:V.hitSlop(we)).onStart(()=>{"worklet";runOnJS(ce)(!0),J.value=t.value,w&&(l.value=withSpring(v,x)),y&&(d.value=withTiming(k,{duration:C,easing:Easing.out(Easing.cubic)})),runOnJS(ge)()}).onUpdate(e=>{"worklet";follow(e.translationX)}).onEnd(e=>{"worklet";follow(e.translationX),w&&(l.value=withSpring(1,x)),y&&(d.value=withTiming(0,{duration:C,easing:Easing.out(Easing.cubic)}))}).onFinalize(()=>{"worklet";runOnJS(ce)(!1)})},[n,a,i,r,Y,N,D,_,u,c,E,H,T,M,we,fe,ge,ce,B,F,z,G,Z,$,K,Q,J,U]),Se=useMemo(()=>ye("low"),[ye]),ke=useMemo(()=>ye("high"),[ye]),Ce=useCallback(e=>{if(n||N||R<=0)return;const t=clamp(e.nativeEvent.locationX,0,R),a=te(t,R);a!==z.value&&(he(),z.value=a,B.value=withTiming(ee(a,R),{duration:A.motion.duration.fast,easing:Easing.out(Easing.cubic)}),me(a,a))},[n,N,R,te,ee,me,he,B,z,A.motion.duration.fast]),xe=useCallback(e=>{if(n)return;const t="increment"===e.nativeEvent.actionName?r:-r,s=r>0?Math.round(t*Y)/Y:t;if(N){const e=Math.round((z.value+s)*Y)/Y,t=clamp(e,a,G.value);t!==z.value&&(z.value=t,B.value=ee(t,R),he(),me(t,G.value))}else{const e=Math.round((z.value+s)*Y)/Y,t=clamp(e,a,i);t!==z.value&&(z.value=t,B.value=ee(t,R),he(),me(t,t))}},[n,r,Y,N,a,i,ee,R,B,z,G,me,he]),Ae=j.thumbDiameter/2,Ve=n?A.colors["surface-disabled"]:W,je="inset"===l?{backgroundColor:Ve,borderColor:A.colors.surface,borderWidth:Math.max(2,Math.round(.3*j.thumbDiameter)),...NO_SHADOW}:"minimal"===l?{backgroundColor:Ve,borderWidth:0}:"bar"===l?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:A.colors.surface,borderColor:Ve},Me=useAnimatedStyle(()=>{const e=U.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=n?.55:1;if(N){const a=Math.max(0,F.value-B.value+2*M);return{opacity:t,transform:[{translateX:B.value-M},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:B.value+M-e},{scaleX:1}]}},[U,n,N,F,B,M]),De=useAnimatedStyle(()=>({transform:[{translateX:B.value-Ae},{scale:Z.value}]}),[B,Ae,Z]),He=useAnimatedStyle(()=>({transform:[{translateX:F.value-Ae},{scale:$.value}]}),[F,Ae,$]),Ee=useAnimatedStyle(()=>({opacity:K.value}),[K]),Oe=useAnimatedStyle(()=>({opacity:Q.value}),[Q]),clampDisplay=e=>clamp(e,a,i),Te=clampDisplay(N?Math.min(...P):P),Re=clampDisplay(N?Math.max(...P):P);return _jsx(View,{ref:t,style:[O.container,f,p],testID:x,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:n},"aria-disabled":n,accessibilityValue:N?{min:a,max:i,now:Te,text:`${Te} to ${Re}`}:{min:a,max:i,now:Te},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:xe,children:_jsx(Pressable,{onPress:Ce,disabled:n||N,style:O.trackTouch,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:_jsxs(View,{style:O.trackWrap,onLayout:de,children:[_jsxs(View,{style:O.trackClip,pointerEvents:"none",children:[_jsx(View,{style:[O.track,{backgroundColor:n?A.colors["surface-disabled"]:A.colors.border},g]}),_jsx(Animated.View,{style:[O.fill,{backgroundColor:n?A.colors["surface-disabled"]:W},v,Me]})]}),_jsx(GestureDetector,{gesture:Se,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:Ae,...smoothCorners,opacity:n?.55:1},je,w,De],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[O.bubbleWrap,Ee],pointerEvents:"none",children:[_jsx(View,{style:[O.bubble,{backgroundColor:W}],children:m?m(Te):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:L},y],numberOfLines:1,children:d(Te)})}),_jsx(View,{style:[O.bubbleCaret,{backgroundColor:W}]})]}):null})}),N?_jsx(GestureDetector,{gesture:ke,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:Ae,...smoothCorners,opacity:n?.55:1},je,w,He],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[O.bubbleWrap,Oe],pointerEvents:"none",children:[_jsx(View,{style:[O.bubble,{backgroundColor:W}],children:m?m(Re):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:L},y],numberOfLines:1,children:d(Re)})}),_jsx(View,{style:[O.bubbleCaret,{backgroundColor:W}]})]}):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 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,...smoothCorners,overflow:"hidden"},track:{position:"absolute",top:0,right:0,bottom:0,left:0,borderRadius:t.trackHeight/2,...smoothCorners},fill:{position:"absolute",top:0,left:0,width:"100%",height:t.trackHeight,borderRadius:t.trackHeight/2,...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,...smoothCorners,transform:[{rotate:"45deg"}]},bubble:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xxs,borderRadius:e.radius.md,...smoothCorners,minWidth:36,alignItems:"center",justifyContent:"center",...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:{}})}})};export{Slider};export default Slider;
@@ -1 +1 @@
1
- "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{cancelAnimation,measure,runOnJS,scrollTo,useAnimatedRef,useAnimatedScrollHandler,useAnimatedStyle,useFrameCallback,useSharedValue,withSpring}from"react-native-reanimated";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{useScrollHost}from"../Screen/ScrollHost.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SORTABLE_LIST_LABELS=Object.freeze({moveUp:"Move up",moveDown:"Move down"});const 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=>{};export function moveItem(e,t,a){const l=e.slice();if(t<0||t>=l.length)return l;const[o]=l.splice(t,1);return l.splice(a,0,o),l}export function topOf(e,t){"worklet";let a=0;for(let l=0;l<t;l++)a+=e[l]??0;return a}export function slotTop(e,t,a){"worklet";let l=0,o=0;for(let r=0;r<e.length&&o<a;r++)r!==t&&(l+=e[r]??0,o++);return l}export function dropIndex(e,t,a){"worklet";const l=topOf(e,t)+(e[t]??0)/2+a;let o=0,r=0;for(let a=0;a<e.length;a++){const s=e[a]??0;a!==t&&r+s/2<l&&o++,r+=s}return o}export function rowShifts(e,t,a){const l=[];let o=0;for(const t of e)l.push(o),o+=t;const r=e.map(()=>0),s=moveItem(e.map((e,t)=>t),t,a);let n=0;for(const t of s)r[t]=n-(l[t]??0),n+=e[t]??0;return r}const buildStyles=e=>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:l,isActive:o,dragging:r,handle:s,disabled:n,shared:u,callbacks:i,labels:c,children:d}){const m=useTheme(),v=useMemo(()=>buildStyles(m),[m]),h=useSharedValue(0);useEffect(()=>{h.value=r&&!o?withSpring(l,SPRING_CONFIG):l},[r,o,l,h]),useEffect(()=>()=>{cancelAnimation(h)},[h]);const S=useAnimatedStyle(()=>({transform:[{translateY:o?u.dragY.value:h.value}],zIndex:o?1:0})),f=useMemo(()=>{const{dragIndex:e,dropTo:a,dragY:l,translation:o,absoluteY:r,scrollY:c,scrollStart:d,hostOffset:m,hostStart:v,hostTarget:h,heights:S}=u,{onLift:f,onDrop:g,onSettled:p}=i,b=Gesture.Pan().enabled(!n).onStart(s=>{"worklet";r.value=s.absoluteY,e.value=t,a.value=t,d.value=c.value,v.value=m.value,h.value=m.value,o.value=0,l.value=0,runOnJS(f)(t)}).onUpdate(a=>{"worklet";e.value===t&&(o.value=a.translationY,r.value=a.absoluteY)}).onFinalize(()=>{"worklet";if(e.value!==t)return;const o=a.value,r=S.value;e.value=-1,l.value=topOf(r,t)+l.value-slotTop(r,t,o),l.value=withSpring(0,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(p)()}),runOnJS(g)(t,o)});return s?b:b.activateAfterLongPress(350)},[n,s,t,i,u]),g=n?[]:[...t>0?[{name:"moveUp",label:c.moveUp}]:[],...t<a-1?[{name:"moveDown",label:c.moveDown}]:[]];return _jsx(Animated.View,{style:S,onLayout:t=>i.onHeight(e,t.nativeEvent.layout.height),accessibilityActions:g,onAccessibilityAction:e=>{if(n)return;const l=t+(ACTION_STEP[e.nativeEvent.actionName]??0);l!==t&&l>=0&&l<a&&i.onMove(t,l)},testID:`sortable-row-${e}`,children:s?_jsxs(View,{style:v.handleRow,children:[_jsx(GestureDetector,{gesture:f,children:_jsxs(View,{style:v.handle,children:[_jsx(View,{style:v.bar}),_jsx(View,{style:v.bar}),_jsx(View,{style:v.bar})]})}),_jsx(View,{style:v.body,children:d})]}):_jsx(GestureDetector,{gesture:f,children:_jsx(View,{children:d})})})}export function SortableList(e){const{data:t,keyExtractor:a,renderItem:l,onReorder:o,handle:r=!1,disabled:s=!1,accessibilityLabel:n,labels:u,testID:i}=e,c=useMemo(()=>({...DEFAULT_SORTABLE_LIST_LABELS,...u}),[u]),d=useMemo(()=>t.map((e,t)=>({key:a(e,t),item:e})),[t,a]),m=useMemo(()=>d.map(e=>e.key),[d]),v=useAnimatedRef(),h=useSharedValue(0),S=useSharedValue(0),f=useSharedValue(0),g=useScrollHost(),p=useSharedValue(0),b=null!==g,x=g?.top??p,w=g?.bottom??p,y=g?.offset??p,_=g?.maxOffset??p,k=g?.scrollTo??noop,A=useSharedValue(0),L=useSharedValue(0),O=useSharedValue(0),V=useSharedValue(0),I=useSharedValue(-1),T=useSharedValue(-1),C=useSharedValue(0),E=useSharedValue([]),j=useRef(new Map),M=useRef(m),[R,D]=useState(null),Y=useCallback(()=>{E.value=M.current.map(e=>j.current.get(e)??0)},[E]);useEffect(()=>{M.current=m,Y()},[m,Y]),useEffect(()=>()=>{cancelAnimation(C)},[C]);const G=useCallback(e=>{D(t=>t?.dragging?{...t,to:e}:t)},[]),P=useFrameCallback(()=>{"worklet";const e=I.value;if(e<0)return;const t=measure(v);if(t){const e=b?Math.max(t.pageY,x.value):t.pageY,a=b?Math.min(t.pageY+t.height,w.value):t.pageY+t.height,l=Math.max(0,f.value-t.height-1);V.value<e+48?h.value>1?scrollTo(v,0,Math.max(0,h.value-12),!1):b&&L.value>0&&(L.value=Math.max(0,L.value-12),runOnJS(k)(L.value)):V.value>a-48&&(h.value<l?scrollTo(v,0,Math.min(l,h.value+12),!1):b&&L.value<_.value&&(L.value=Math.min(_.value,L.value+12),runOnJS(k)(L.value)))}C.value=O.value+h.value-S.value+y.value-A.value;const a=dropIndex(E.value,e,C.value);a!==T.value&&(T.value=a,runOnJS(G)(a))},!1),N=useCallback(e=>{triggerHaptic("longPress"),P.setActive(!0),D({key:m[e]??"",from:e,to:e,dragging:!0})},[P,m]),H=useCallback((e,t)=>{P.setActive(!1),D(e=>e?{...e,to:t,dragging:!1}:e),t!==e&&o(moveItem(m,e,t))},[P,m,o]),F=useCallback(()=>{D(e=>e&&!e.dragging?null:e)},[]),J=useCallback((e,t)=>{o(moveItem(m,e,t))},[m,o]),U=useCallback((e,t)=>{j.current.set(e,t),Y()},[Y]),z=useAnimatedScrollHandler({onScroll:e=>{"worklet";h.value=e.contentOffset.y}}),B=useCallback((e,t)=>{f.value=t},[f]),K=useMemo(()=>({scrollRef:v,scrollY:h,scrollStart:S,hostOffset:y,hostStart:A,hostTarget:L,translation:O,absoluteY:V,dragIndex:I,dropTo:T,dragY:C,heights:E}),[v,h,S,y,A,L,O,V,I,T,C,E]),X=useMemo(()=>({onLift:N,onDrop:H,onSettled:F,onMove:J,onHeight:U}),[N,H,F,J,U]),$=!0===R?.dragging,q=$&&R?rowShifts(m.map(e=>j.current.get(e)??0),R.from,R.to):null;return _jsx(Animated.ScrollView,{ref:v,onScroll:z,onContentSizeChange:B,scrollEventThrottle:16,scrollEnabled:!$,accessibilityLabel:n,testID:i,children:d.map((e,t)=>{const a=R?.key===e.key;return _jsx(SortableRow,{rowKey:e.key,index:t,count:d.length,shift:q?.[t]??0,isActive:a,dragging:$,handle:r,disabled:s,shared:K,callbacks:X,labels:c,children:l({item:e.item,index:t,isActive:a})},e.key)})})}SortableList.displayName="SortableList";export default SortableList;
1
+ "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{cancelAnimation,measure,runOnJS,scrollTo,useAnimatedRef,useAnimatedScrollHandler,useAnimatedStyle,useFrameCallback,useSharedValue,withSpring}from"react-native-reanimated";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{useScrollHost}from"../Screen/ScrollHost.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SORTABLE_LIST_LABELS=Object.freeze({moveUp:"Move up",moveDown:"Move down"});const 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=>{};export function moveItem(e,t,a){const l=e.slice();if(t<0||t>=l.length)return l;const[o]=l.splice(t,1);return l.splice(a,0,o),l}export function topOf(e,t){"worklet";let a=0;for(let l=0;l<t;l++)a+=e[l]??0;return a}export function slotTop(e,t,a){"worklet";let l=0,o=0;for(let r=0;r<e.length&&o<a;r++)r!==t&&(l+=e[r]??0,o++);return l}export function dropIndex(e,t,a){"worklet";const l=topOf(e,t)+(e[t]??0)/2+a;let o=0,r=0;for(let a=0;a<e.length;a++){const s=e[a]??0;a!==t&&r+s/2<l&&o++,r+=s}return o}export function rowShifts(e,t,a){const l=[];let o=0;for(const t of e)l.push(o),o+=t;const r=e.map(()=>0),s=moveItem(e.map((e,t)=>t),t,a);let n=0;for(const t of s)r[t]=n-(l[t]??0),n+=e[t]??0;return r}const buildStyles=e=>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:l,isActive:o,dragging:r,handle:s,disabled:n,shared:u,callbacks:i,labels:c,children:d}){const m=useTheme(),v=useMemo(()=>buildStyles(m),[m]),h=useSharedValue(0);useEffect(()=>{h.value=r&&!o?withSpring(l,SPRING_CONFIG):l},[r,o,l,h]),useEffect(()=>()=>{cancelAnimation(h)},[h]);const S=useAnimatedStyle(()=>({transform:[{translateY:o?u.dragY.value:h.value}],zIndex:o?1:0}),[o,u,h]),f=useMemo(()=>{const{dragIndex:e,dropTo:a,dragY:l,translation:o,absoluteY:r,scrollY:c,scrollStart:d,hostOffset:m,hostStart:v,hostTarget:h,heights:S}=u,{onLift:f,onDrop:g,onSettled:p}=i,b=Gesture.Pan().enabled(!n).onStart(s=>{"worklet";r.value=s.absoluteY,e.value=t,a.value=t,d.value=c.value,v.value=m.value,h.value=m.value,o.value=0,l.value=0,runOnJS(f)(t)}).onUpdate(a=>{"worklet";e.value===t&&(o.value=a.translationY,r.value=a.absoluteY)}).onFinalize(()=>{"worklet";if(e.value!==t)return;const o=a.value,r=S.value;e.value=-1,l.value=topOf(r,t)+l.value-slotTop(r,t,o),l.value=withSpring(0,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(p)()}),runOnJS(g)(t,o)});return s?b:b.activateAfterLongPress(350)},[n,s,t,i,u]),g=n?[]:[...t>0?[{name:"moveUp",label:c.moveUp}]:[],...t<a-1?[{name:"moveDown",label:c.moveDown}]:[]];return _jsx(Animated.View,{style:S,onLayout:t=>i.onHeight(e,t.nativeEvent.layout.height),accessibilityActions:g,onAccessibilityAction:e=>{if(n)return;const l=t+(ACTION_STEP[e.nativeEvent.actionName]??0);l!==t&&l>=0&&l<a&&i.onMove(t,l)},testID:`sortable-row-${e}`,children:s?_jsxs(View,{style:v.handleRow,children:[_jsx(GestureDetector,{gesture:f,children:_jsxs(View,{style:v.handle,children:[_jsx(View,{style:v.bar}),_jsx(View,{style:v.bar}),_jsx(View,{style:v.bar})]})}),_jsx(View,{style:v.body,children:d})]}):_jsx(GestureDetector,{gesture:f,children:_jsx(View,{children:d})})})}export function SortableList(e){const{data:t,keyExtractor:a,renderItem:l,onReorder:o,handle:r=!1,disabled:s=!1,accessibilityLabel:n,labels:u,testID:i}=e,c=useMemo(()=>({...DEFAULT_SORTABLE_LIST_LABELS,...u}),[u]),d=useMemo(()=>t.map((e,t)=>({key:a(e,t),item:e})),[t,a]),m=useMemo(()=>d.map(e=>e.key),[d]),v=useAnimatedRef(),h=useSharedValue(0),S=useSharedValue(0),f=useSharedValue(0),g=useScrollHost(),p=useSharedValue(0),b=null!==g,x=g?.top??p,w=g?.bottom??p,y=g?.offset??p,_=g?.maxOffset??p,k=g?.scrollTo??noop,A=useSharedValue(0),L=useSharedValue(0),O=useSharedValue(0),V=useSharedValue(0),I=useSharedValue(-1),T=useSharedValue(-1),C=useSharedValue(0),E=useSharedValue([]),j=useRef(new Map),M=useRef(m),[R,D]=useState(null),Y=useCallback(()=>{E.value=M.current.map(e=>j.current.get(e)??0)},[E]);useEffect(()=>{M.current=m,Y()},[m,Y]),useEffect(()=>()=>{cancelAnimation(C)},[C]);const G=useCallback(e=>{D(t=>t?.dragging?{...t,to:e}:t)},[]),P=useFrameCallback(()=>{"worklet";const e=I.value;if(e<0)return;const t=measure(v);if(t){const e=b?Math.max(t.pageY,x.value):t.pageY,a=b?Math.min(t.pageY+t.height,w.value):t.pageY+t.height,l=Math.max(0,f.value-t.height-1);V.value<e+48?h.value>1?scrollTo(v,0,Math.max(0,h.value-12),!1):b&&L.value>0&&(L.value=Math.max(0,L.value-12),runOnJS(k)(L.value)):V.value>a-48&&(h.value<l?scrollTo(v,0,Math.min(l,h.value+12),!1):b&&L.value<_.value&&(L.value=Math.min(_.value,L.value+12),runOnJS(k)(L.value)))}C.value=O.value+h.value-S.value+y.value-A.value;const a=dropIndex(E.value,e,C.value);a!==T.value&&(T.value=a,runOnJS(G)(a))},!1),N=useCallback(e=>{triggerHaptic("longPress"),P.setActive(!0),D({key:m[e]??"",from:e,to:e,dragging:!0})},[P,m]),H=useCallback((e,t)=>{P.setActive(!1),D(e=>e?{...e,to:t,dragging:!1}:e),t!==e&&o(moveItem(m,e,t))},[P,m,o]),F=useCallback(()=>{D(e=>e&&!e.dragging?null:e)},[]),J=useCallback((e,t)=>{o(moveItem(m,e,t))},[m,o]),U=useCallback((e,t)=>{j.current.set(e,t),Y()},[Y]),z=useAnimatedScrollHandler({onScroll:e=>{"worklet";h.value=e.contentOffset.y}}),B=useCallback((e,t)=>{f.value=t},[f]),K=useMemo(()=>({scrollRef:v,scrollY:h,scrollStart:S,hostOffset:y,hostStart:A,hostTarget:L,translation:O,absoluteY:V,dragIndex:I,dropTo:T,dragY:C,heights:E}),[v,h,S,y,A,L,O,V,I,T,C,E]),X=useMemo(()=>({onLift:N,onDrop:H,onSettled:F,onMove:J,onHeight:U}),[N,H,F,J,U]),$=!0===R?.dragging,q=$&&R?rowShifts(m.map(e=>j.current.get(e)??0),R.from,R.to):null;return _jsx(Animated.ScrollView,{ref:v,onScroll:z,onContentSizeChange:B,scrollEventThrottle:16,scrollEnabled:!$,accessibilityLabel:n,testID:i,children:d.map((e,t)=>{const a=R?.key===e.key;return _jsx(SortableRow,{rowKey:e.key,index:t,count:d.length,shift:q?.[t]??0,isActive:a,dragging:$,handle:r,disabled:s,shared:K,callbacks:X,labels:c,children:l({item:e.item,index:t,isActive:a})},e.key)})})}SortableList.displayName="SortableList";export default SortableList;
@@ -1 +1 @@
1
- "use strict";import{useCallback,useEffect,useMemo,useRef}from"react";import{Dimensions,Pressable,StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{cancelAnimation,runOnJS,useAnimatedStyle,useSharedValue,withSpring}from"react-native-reanimated";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";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:n,rightActions:o,threshold:i,fullSwipeThreshold:r,onSwipeOpen:s,onSwipeClose:a,disabled:l=!1,haptic:c,containerStyle:u,contentStyle:d,actionStyle:m,accessibilityLabel:h,testID:p}=e,S=useTheme(),w=i??80,b=r??200,f=useMemo(()=>buildStyles(S),[S]),g=useMemo(()=>buildActionStyles(S),[S]),y=!!n&&n.length>0,v=!!o&&o.length>0,x=Dimensions.get("window").width,I=y?w*(n?.length??0):0,A=v?w*(o?.length??0):0,_=useSharedValue(0),C=useSharedValue(0),O=useRef(null);useEffect(()=>()=>{cancelAnimation(_),cancelAnimation(C)},[_,C]);const j=useCallback(e=>{O.current!==e&&(O.current=e,s?.(e))},[s]),G=useCallback(()=>{null!==O.current&&(O.current=null,a?.())},[a]),N=useCallback(e=>{const t="left"===e?n:o,i=t?.[0];i&&(!1!==c&&triggerHaptic("notificationSuccess"),i.onPress(),_.value=withSpring(0,SPRING_CONFIG),O.current=null,a?.())},[n,o,_,a,c]),R=useCallback(()=>{_.value=withSpring(0,SPRING_CONFIG),G()},[_,G]),k=useCallback(e=>{const t=resolveHaptic(c,"selection");t&&triggerHaptic(t),e.onPress(),R()},[R,c]),P=useMemo(()=>{const e=I,t=A,n=b,o=-b,i=x,r=-x,s=w,a=y,c=v;return Gesture.Pan().enabled(!l).withTestId(p?`${p}-gesture`:"swipeable-gesture").activeOffsetX([-10,10]).failOffsetY([-15,15]).onStart(()=>{"worklet";C.value=_.value}).onUpdate(n=>{"worklet";const o=C.value+n.translationX;_.value=o>0&&!a||o<0&&!c?0:o>e&&a?e+.35*(o-e):o<-t&&c?.35*(o+t)-t:o}).onEnd(()=>{"worklet";const l=_.value;return a&&l>=n?(_.value=withSpring(i,SPRING_CONFIG),void runOnJS(N)("left")):c&&l<=o?(_.value=withSpring(r,SPRING_CONFIG),void runOnJS(N)("right")):a&&l>=s?(_.value=withSpring(e,SPRING_CONFIG),void runOnJS(j)("left")):c&&l<=-s?(_.value=withSpring(-t,SPRING_CONFIG),void runOnJS(j)("right")):(_.value=withSpring(0,SPRING_CONFIG),void runOnJS(G)())})},[l,C,N,b,y,v,I,G,j,A,x,w,_,p]),T=useAnimatedStyle(()=>({transform:[{translateX:_.value}]})),F=useAnimatedStyle(()=>({opacity:I>0?Math.min(1,Math.max(0,_.value/I)):0})),V=useAnimatedStyle(()=>({opacity:A>0?Math.min(1,Math.max(0,-_.value/A)):0})),E=useMemo(()=>{const e=[];return n?.forEach(t=>{e.push({name:t.key,label:t.label})}),o?.forEach(t=>{e.push({name:t.key,label:t.label})}),e},[n,o]),D=useCallback(e=>{const t=e.nativeEvent.actionName,i=[...n??[],...o??[]].find(e=>e.key===t);i&&(!1!==c&&triggerHaptic("selection"),i.onPress())},[n,o,c]);return y||v?_jsxs(View,{style:[f.root,u],testID:p,accessibilityLabel:h,accessibilityActions:E,onAccessibilityAction:D,children:[y?_jsx(Animated.View,{style:[f.actionsRow,f.actionsLeft,{width:I},m,F],pointerEvents:"box-none",children:n?.map(e=>_jsx(ActionButton,{action:e,theme:S,actionStyles:g,width:w,onPress:k},e.key))}):null,v?_jsx(Animated.View,{style:[f.actionsRow,f.actionsRight,{width:A},m,V],pointerEvents:"box-none",children:o?.map(e=>_jsx(ActionButton,{action:e,theme:S,actionStyles:g,width:w,onPress:k},e.key))}):null,_jsx(GestureDetector,{gesture:P,children:_jsx(Animated.View,{style:[f.content,d,T],children:t})})]}):_jsx(View,{style:u,testID:p,children:t})};Swipeable.displayName="Swipeable";const ActionButton=({action:e,theme:t,actionStyles:n,width:o,onPress:i})=>{warnInvalidValue("Swipeable","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const r=e.tone??"neutral",s=toneToBg(t,r),a=renderSlotIcon(e.icon,{color:toneToOnColor(t,r),size:20,disabled:!1});return _jsxs(Pressable,{onPress:()=>i(e),accessibilityRole:"button",accessibilityLabel:e.label,style:[n.button,{width:o,backgroundColor:s,paddingHorizontal:t.space.sm}],children:[a?_jsx(View,{style:n.icon,children:a}):null,_jsx(Text,{variant:"bodySmall",weight:"semibold",style:[n.label,{color:toneToOnColor(t,r)}],numberOfLines:1,children:e.label})]})},buildActionStyles=e=>StyleSheet.create({button:{flexGrow:0,flexShrink:0,alignItems:"center",justifyContent:"center"},icon:{marginBottom:e.space.xxs},label:{textAlign:"center"}}),buildStyles=e=>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"}});export{Swipeable};export default Swipeable;
1
+ "use strict";import{useCallback,useEffect,useMemo,useRef}from"react";import{Dimensions,Pressable,StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{cancelAnimation,runOnJS,useAnimatedStyle,useSharedValue,withSpring}from"react-native-reanimated";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";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:n,rightActions:o,threshold:i,fullSwipeThreshold:r,onSwipeOpen:s,onSwipeClose:a,disabled:l=!1,haptic:c,containerStyle:u,contentStyle:d,actionStyle:m,accessibilityLabel:h,testID:p}=e,S=useTheme(),w=i??80,b=r??200,f=useMemo(()=>buildStyles(S),[S]),g=useMemo(()=>buildActionStyles(S),[S]),y=!!n&&n.length>0,v=!!o&&o.length>0,x=Dimensions.get("window").width,I=y?w*(n?.length??0):0,A=v?w*(o?.length??0):0,_=useSharedValue(0),C=useSharedValue(0),O=useRef(null);useEffect(()=>()=>{cancelAnimation(_),cancelAnimation(C)},[_,C]);const j=useCallback(e=>{O.current!==e&&(O.current=e,s?.(e))},[s]),G=useCallback(()=>{null!==O.current&&(O.current=null,a?.())},[a]),N=useCallback(e=>{const t="left"===e?n:o,i=t?.[0];i&&(!1!==c&&triggerHaptic("notificationSuccess"),i.onPress(),_.value=withSpring(0,SPRING_CONFIG),O.current=null,a?.())},[n,o,_,a,c]),R=useCallback(()=>{_.value=withSpring(0,SPRING_CONFIG),G()},[_,G]),k=useCallback(e=>{const t=resolveHaptic(c,"selection");t&&triggerHaptic(t),e.onPress(),R()},[R,c]),P=useMemo(()=>{const e=I,t=A,n=b,o=-b,i=x,r=-x,s=w,a=y,c=v;return Gesture.Pan().enabled(!l).withTestId(p?`${p}-gesture`:"swipeable-gesture").activeOffsetX([-10,10]).failOffsetY([-15,15]).onStart(()=>{"worklet";C.value=_.value}).onUpdate(n=>{"worklet";const o=C.value+n.translationX;_.value=o>0&&!a||o<0&&!c?0:o>e&&a?e+.35*(o-e):o<-t&&c?.35*(o+t)-t:o}).onEnd(()=>{"worklet";const l=_.value;return a&&l>=n?(_.value=withSpring(i,SPRING_CONFIG),void runOnJS(N)("left")):c&&l<=o?(_.value=withSpring(r,SPRING_CONFIG),void runOnJS(N)("right")):a&&l>=s?(_.value=withSpring(e,SPRING_CONFIG),void runOnJS(j)("left")):c&&l<=-s?(_.value=withSpring(-t,SPRING_CONFIG),void runOnJS(j)("right")):(_.value=withSpring(0,SPRING_CONFIG),void runOnJS(G)())})},[l,C,N,b,y,v,I,G,j,A,x,w,_,p]),T=useAnimatedStyle(()=>({transform:[{translateX:_.value}]}),[_]),F=useAnimatedStyle(()=>({opacity:I>0?Math.min(1,Math.max(0,_.value/I)):0}),[I,_]),V=useAnimatedStyle(()=>({opacity:A>0?Math.min(1,Math.max(0,-_.value/A)):0}),[A,_]),E=useMemo(()=>{const e=[];return n?.forEach(t=>{e.push({name:t.key,label:t.label})}),o?.forEach(t=>{e.push({name:t.key,label:t.label})}),e},[n,o]),D=useCallback(e=>{const t=e.nativeEvent.actionName,i=[...n??[],...o??[]].find(e=>e.key===t);i&&(!1!==c&&triggerHaptic("selection"),i.onPress())},[n,o,c]);return y||v?_jsxs(View,{style:[f.root,u],testID:p,accessibilityLabel:h,accessibilityActions:E,onAccessibilityAction:D,children:[y?_jsx(Animated.View,{style:[f.actionsRow,f.actionsLeft,{width:I},m,F],pointerEvents:"box-none",children:n?.map(e=>_jsx(ActionButton,{action:e,theme:S,actionStyles:g,width:w,onPress:k},e.key))}):null,v?_jsx(Animated.View,{style:[f.actionsRow,f.actionsRight,{width:A},m,V],pointerEvents:"box-none",children:o?.map(e=>_jsx(ActionButton,{action:e,theme:S,actionStyles:g,width:w,onPress:k},e.key))}):null,_jsx(GestureDetector,{gesture:P,children:_jsx(Animated.View,{style:[f.content,d,T],children:t})})]}):_jsx(View,{style:u,testID:p,children:t})};Swipeable.displayName="Swipeable";const ActionButton=({action:e,theme:t,actionStyles:n,width:o,onPress:i})=>{warnInvalidValue("Swipeable","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const r=e.tone??"neutral",s=toneToBg(t,r),a=renderSlotIcon(e.icon,{color:toneToOnColor(t,r),size:20,disabled:!1});return _jsxs(Pressable,{onPress:()=>i(e),accessibilityRole:"button",accessibilityLabel:e.label,style:[n.button,{width:o,backgroundColor:s,paddingHorizontal:t.space.sm}],children:[a?_jsx(View,{style:n.icon,children:a}):null,_jsx(Text,{variant:"bodySmall",weight:"semibold",style:[n.label,{color:toneToOnColor(t,r)}],numberOfLines:1,children:e.label})]})},buildActionStyles=e=>StyleSheet.create({button:{flexGrow:0,flexShrink:0,alignItems:"center",justifyContent:"center"},icon:{marginBottom:e.space.xxs},label:{textAlign:"center"}}),buildStyles=e=>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"}});export{Swipeable};export default Swipeable;
@@ -1 +1 @@
1
- "use strict";import{useEffect,useMemo}from"react";import{StyleSheet,View}from"react-native";import Animated,{cancelAnimation,useAnimatedStyle,useSharedValue,withDelay,withRepeat,withSequence,withTiming}from"react-native-reanimated";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_TYPING_INDICATOR_LABELS=Object.freeze({typing:"Typing"});const 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:s})=>{const o=useSharedValue(.3);useEffect(()=>{if(!t)return o.value=withDelay(160*e,withRepeat(withSequence(withTiming(1,{duration:400}),withTiming(.3,{duration:400})),-1)),()=>cancelAnimation(o)},[t,e,o]);const r=useAnimatedStyle(()=>({opacity:o.value}));return _jsx(Animated.View,{style:[s,{backgroundColor:i},t?{opacity:STILL_OPACITY[e]}:r]})};export const TypingIndicator=({label:e,accessibilityLabel:t,labels:i,bubble:s=!0,style:o,testID:r})=>{const a=useTheme(),l=useMemo(()=>buildStyles(a),[a]),n=useReducedMotion(),c=a.colors["text-subtle"],d=useMemo(()=>({...DEFAULT_TYPING_INDICATOR_LABELS,...i}),[i]);return _jsxs(View,{style:[l.root,s?l.bubble:null,o],accessible:!0,accessibilityRole:"progressbar",accessibilityLabel:e??t??d.typing,accessibilityState:{busy:!0},"aria-busy":!0,testID:r,children:[_jsx(View,{style:l.dots,children:DOT_NAMES.map((e,t)=>_jsx(Dot,{index:t,still:n,colour:c,dotStyle:l.dot},e))}),e?_jsx(Text,{variant:"bodySmall",color:"secondary",children:e}):null]})};const buildStyles=e=>StyleSheet.create({dot:{width:6,height:6,borderRadius:e.radius.pill,...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,...smoothCorners,paddingHorizontal:e.space.md,paddingVertical:e.space.sm+e.space.xs},dots:{flexDirection:"row",alignItems:"center",gap:e.space.xs}});export default TypingIndicator;
1
+ "use strict";import{useEffect,useMemo}from"react";import{StyleSheet,View}from"react-native";import Animated,{cancelAnimation,useAnimatedStyle,useSharedValue,withDelay,withRepeat,withSequence,withTiming}from"react-native-reanimated";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_TYPING_INDICATOR_LABELS=Object.freeze({typing:"Typing"});const 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:s})=>{const o=useSharedValue(.3);useEffect(()=>{if(!t)return o.value=withDelay(160*e,withRepeat(withSequence(withTiming(1,{duration:400}),withTiming(.3,{duration:400})),-1)),()=>cancelAnimation(o)},[t,e,o]);const r=useAnimatedStyle(()=>({opacity:o.value}),[o]);return _jsx(Animated.View,{style:[s,{backgroundColor:i},t?{opacity:STILL_OPACITY[e]}:r]})};export const TypingIndicator=({label:e,accessibilityLabel:t,labels:i,bubble:s=!0,style:o,testID:r})=>{const a=useTheme(),l=useMemo(()=>buildStyles(a),[a]),n=useReducedMotion(),c=a.colors["text-subtle"],d=useMemo(()=>({...DEFAULT_TYPING_INDICATOR_LABELS,...i}),[i]);return _jsxs(View,{style:[l.root,s?l.bubble:null,o],accessible:!0,accessibilityRole:"progressbar",accessibilityLabel:e??t??d.typing,accessibilityState:{busy:!0},"aria-busy":!0,testID:r,children:[_jsx(View,{style:l.dots,children:DOT_NAMES.map((e,t)=>_jsx(Dot,{index:t,still:n,colour:c,dotStyle:l.dot},e))}),e?_jsx(Text,{variant:"bodySmall",color:"secondary",children:e}):null]})};const buildStyles=e=>StyleSheet.create({dot:{width:6,height:6,borderRadius:e.radius.pill,...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,...smoothCorners,paddingHorizontal:e.space.md,paddingVertical:e.space.sm+e.space.xs},dots:{flexDirection:"row",alignItems:"center",gap:e.space.xs}});export default TypingIndicator;
@@ -1 +1 @@
1
- "use strict";import{useCallback,useEffect,useMemo}from"react";import{StyleSheet}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{runOnJS,useAnimatedStyle,useSharedValue,withSpring}from"react-native-reanimated";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{jsx as _jsx}from"react/jsx-runtime";const DEFAULT_MAX_SCALE=4,DEFAULT_MIN_SCALE=1,DEFAULT_DOUBLE_TAP_SCALE=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1};export const ZoomableImage=({children:e,maxScale:a=4,minScale:t=1,doubleTapScale:l=2,disabled:r=!1,haptic:u,style:i,accessibilityLabel:n,testID:s})=>{const o=useSharedValue(1),v=useSharedValue(1),c=useSharedValue(0),S=useSharedValue(0),m=useSharedValue(0),d=useSharedValue(0),h=useCallback(()=>{o.value=withSpring(1,SPRING_CONFIG),v.value=1,c.value=withSpring(0,SPRING_CONFIG),S.value=withSpring(0,SPRING_CONFIG),m.value=0,d.value=0},[o,v,c,S,m,d]);useEffect(()=>{r&&h()},[r,h]);const p=useCallback(()=>{const e=resolveHaptic(u,"impactLight");e&&triggerHaptic(e)},[u]),I=useMemo(()=>Gesture.Pinch().enabled(!r).onStart(()=>{"worklet";v.value=o.value}).onUpdate(e=>{"worklet";const l=v.value*e.scale;o.value=l<t?t+.3*(l-t):l>a?a+.2*(l-a):l}).onEnd(()=>{"worklet";return o.value<t?(o.value=withSpring(t,SPRING_CONFIG),c.value=withSpring(0,SPRING_CONFIG),S.value=withSpring(0,SPRING_CONFIG),v.value=t,m.value=0,void(d.value=0)):o.value>a?(o.value=withSpring(a,SPRING_CONFIG),void(v.value=a)):void(v.value=o.value)}),[r,o,v,c,S,m,d,t,a]),G=useMemo(()=>Gesture.Pan().enabled(!r).minPointers(1).maxPointers(1).onStart(()=>{"worklet";m.value=c.value,d.value=S.value}).onUpdate(e=>{"worklet";o.value<=1||(c.value=m.value+e.translationX,S.value=d.value+e.translationY)}).onEnd(()=>{"worklet";m.value=c.value,d.value=S.value}),[r,o,c,S,m,d]),g=useMemo(()=>Gesture.Tap().enabled(!r).numberOfTaps(2).onEnd(()=>{"worklet";runOnJS(p)(),o.value>1?(o.value=withSpring(1,SPRING_CONFIG),c.value=withSpring(0,SPRING_CONFIG),S.value=withSpring(0,SPRING_CONFIG),v.value=1,m.value=0,d.value=0):(o.value=withSpring(l,SPRING_CONFIG),v.value=l)}),[r,o,v,c,S,m,d,p,l]),N=useMemo(()=>Gesture.Race(I,G,g),[I,G,g]),w=useAnimatedStyle(()=>({transform:[{translateX:c.value},{translateY:S.value},{scale:o.value}]}));return _jsx(GestureDetector,{gesture:N,children:_jsx(Animated.View,{style:[styles.container,i],testID:s,accessibilityLabel:n,accessibilityState:{disabled:r},"aria-disabled":r,children:_jsx(Animated.View,{style:[styles.content,w],children:e})})})};ZoomableImage.displayName="ZoomableImage";const styles=StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center",overflow:"hidden"},content:{width:"100%",height:"100%",alignItems:"center",justifyContent:"center"}});export default ZoomableImage;
1
+ "use strict";import{useCallback,useEffect,useMemo}from"react";import{StyleSheet}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Animated,{runOnJS,useAnimatedStyle,useSharedValue,withSpring}from"react-native-reanimated";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{jsx as _jsx}from"react/jsx-runtime";const DEFAULT_MAX_SCALE=4,DEFAULT_MIN_SCALE=1,DEFAULT_DOUBLE_TAP_SCALE=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1};export const ZoomableImage=({children:e,maxScale:a=4,minScale:t=1,doubleTapScale:l=2,disabled:r=!1,haptic:u,style:i,accessibilityLabel:n,testID:s})=>{const o=useSharedValue(1),v=useSharedValue(1),c=useSharedValue(0),S=useSharedValue(0),m=useSharedValue(0),d=useSharedValue(0),h=useCallback(()=>{o.value=withSpring(1,SPRING_CONFIG),v.value=1,c.value=withSpring(0,SPRING_CONFIG),S.value=withSpring(0,SPRING_CONFIG),m.value=0,d.value=0},[o,v,c,S,m,d]);useEffect(()=>{r&&h()},[r,h]);const p=useCallback(()=>{const e=resolveHaptic(u,"impactLight");e&&triggerHaptic(e)},[u]),I=useMemo(()=>Gesture.Pinch().enabled(!r).onStart(()=>{"worklet";v.value=o.value}).onUpdate(e=>{"worklet";const l=v.value*e.scale;o.value=l<t?t+.3*(l-t):l>a?a+.2*(l-a):l}).onEnd(()=>{"worklet";return o.value<t?(o.value=withSpring(t,SPRING_CONFIG),c.value=withSpring(0,SPRING_CONFIG),S.value=withSpring(0,SPRING_CONFIG),v.value=t,m.value=0,void(d.value=0)):o.value>a?(o.value=withSpring(a,SPRING_CONFIG),void(v.value=a)):void(v.value=o.value)}),[r,o,v,c,S,m,d,t,a]),G=useMemo(()=>Gesture.Pan().enabled(!r).minPointers(1).maxPointers(1).onStart(()=>{"worklet";m.value=c.value,d.value=S.value}).onUpdate(e=>{"worklet";o.value<=1||(c.value=m.value+e.translationX,S.value=d.value+e.translationY)}).onEnd(()=>{"worklet";m.value=c.value,d.value=S.value}),[r,o,c,S,m,d]),g=useMemo(()=>Gesture.Tap().enabled(!r).numberOfTaps(2).onEnd(()=>{"worklet";runOnJS(p)(),o.value>1?(o.value=withSpring(1,SPRING_CONFIG),c.value=withSpring(0,SPRING_CONFIG),S.value=withSpring(0,SPRING_CONFIG),v.value=1,m.value=0,d.value=0):(o.value=withSpring(l,SPRING_CONFIG),v.value=l)}),[r,o,v,c,S,m,d,p,l]),N=useMemo(()=>Gesture.Race(I,G,g),[I,G,g]),w=useAnimatedStyle(()=>({transform:[{translateX:c.value},{translateY:S.value},{scale:o.value}]}),[c,S,o]);return _jsx(GestureDetector,{gesture:N,children:_jsx(Animated.View,{style:[styles.container,i],testID:s,accessibilityLabel:n,accessibilityState:{disabled:r},"aria-disabled":r,children:_jsx(Animated.View,{style:[styles.content,w],children:e})})})};ZoomableImage.displayName="ZoomableImage";const styles=StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center",overflow:"hidden"},content:{width:"100%",height:"100%",alignItems:"center",justifyContent:"center"}});export default ZoomableImage;
@@ -63,6 +63,6 @@ export interface MessageListProps<T> extends Omit<FlatListProps<T>, OwnedListPro
63
63
  * above the keyboard. Scrolled away from the latest, a jump button appears
64
64
  * with the count of messages that arrived meanwhile.
65
65
  */
66
- export declare function MessageList<T>({ messages, keyExtractor, renderMessage, getAuthorKey, getDate, firstUnreadKey, onLoadOlder, loadingOlder, hasOlder, typing, empty, getAnnouncement, followNew, keyboardAware, keyboardOffset, labels: labelOverrides, now, onScroll, contentContainerStyle, style, testID, ...rest }: MessageListProps<T>): React.ReactElement;
66
+ export declare function MessageList<T>({ messages, keyExtractor, renderMessage, getAuthorKey, getDate, firstUnreadKey, onLoadOlder, loadingOlder, hasOlder, typing, empty, getAnnouncement, followNew, keyboardAware, keyboardOffset, labels: labelOverrides, now, onScroll, onContentSizeChange, contentContainerStyle, style, testID, ...rest }: MessageListProps<T>): React.ReactElement;
67
67
  export default MessageList;
68
68
  //# sourceMappingURL=MessageList.d.ts.map
@@ -63,6 +63,6 @@ export interface MessageListProps<T> extends Omit<FlatListProps<T>, OwnedListPro
63
63
  * above the keyboard. Scrolled away from the latest, a jump button appears
64
64
  * with the count of messages that arrived meanwhile.
65
65
  */
66
- export declare function MessageList<T>({ messages, keyExtractor, renderMessage, getAuthorKey, getDate, firstUnreadKey, onLoadOlder, loadingOlder, hasOlder, typing, empty, getAnnouncement, followNew, keyboardAware, keyboardOffset, labels: labelOverrides, now, onScroll, contentContainerStyle, style, testID, ...rest }: MessageListProps<T>): React.ReactElement;
66
+ export declare function MessageList<T>({ messages, keyExtractor, renderMessage, getAuthorKey, getDate, firstUnreadKey, onLoadOlder, loadingOlder, hasOlder, typing, empty, getAnnouncement, followNew, keyboardAware, keyboardOffset, labels: labelOverrides, now, onScroll, onContentSizeChange, contentContainerStyle, style, testID, ...rest }: MessageListProps<T>): React.ReactElement;
67
67
  export default MessageList;
68
68
  //# sourceMappingURL=MessageList.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/mobile-ui",
3
- "version": "0.130.3",
3
+ "version": "0.131.0",
4
4
  "description": "Beautiful, animated, accessible React Native components, theme and form engine for Webority projects.",
5
5
  "keywords": [
6
6
  "react-native",
@@ -115,13 +115,13 @@
115
115
  }
116
116
  },
117
117
  "dependencies": {
118
- "@webority/markdown-core": "0.130.3"
118
+ "@webority/markdown-core": "0.131.0"
119
119
  },
120
120
  "peerDependencies": {
121
121
  "@react-navigation/bottom-tabs": ">=7.0.0",
122
122
  "@react-navigation/native": ">=7.0.0",
123
- "@webority/canvas-kit": "0.130.3",
124
- "@webority/mobile-core": "0.130.3",
123
+ "@webority/canvas-kit": "0.131.0",
124
+ "@webority/mobile-core": "0.131.0",
125
125
  "expo": ">=57.0.0",
126
126
  "expo-file-system": ">=57.0.0",
127
127
  "expo-haptics": ">=57.0.0",
@@ -185,10 +185,10 @@
185
185
  "@types/node": "25.6.0",
186
186
  "@types/react": "19.2.18",
187
187
  "@types/react-test-renderer": "19.1.0",
188
- "@webority/canvas-kit": "0.130.3",
189
- "@webority/mobile-core": "0.130.3",
188
+ "@webority/canvas-kit": "0.131.0",
189
+ "@webority/mobile-core": "0.131.0",
190
190
  "@webority/mobile-dev": "0.0.0",
191
- "@webority/tokens": "0.130.3",
191
+ "@webority/tokens": "0.131.0",
192
192
  "expo": "57.0.31",
193
193
  "expo-file-system": "57.0.7",
194
194
  "expo-haptics": "57.0.3",