@webority/mobile-ui 0.148.0 → 0.149.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 (46) hide show
  1. package/dist/canvas-kit/kit.js +4580 -4419
  2. package/dist/canvas-kit/manifest.json +1 -1
  3. package/dist/canvas-kit/release.json +5 -5
  4. package/lib/commonjs/components/BarChart/BarChart.js +1 -1
  5. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  6. package/lib/commonjs/components/Drawer/Drawer.js +1 -1
  7. package/lib/commonjs/components/FieldBase/useFloatingLabel.js +1 -1
  8. package/lib/commonjs/components/FileViewer/useFileViewerZoom.js +1 -1
  9. package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
  10. package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
  11. package/lib/commonjs/components/SignaturePad/SignaturePad.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/WheelPicker/Wheel.js +1 -1
  17. package/lib/commonjs/components/ZoomableImage/ZoomableImage.js +1 -1
  18. package/lib/commonjs/hooks/useDragToDismiss.js +1 -1
  19. package/lib/commonjs/navigation/NavigationScreen.js +1 -1
  20. package/lib/module/components/BarChart/BarChart.js +1 -1
  21. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  22. package/lib/module/components/Drawer/Drawer.js +1 -1
  23. package/lib/module/components/FieldBase/useFloatingLabel.js +1 -1
  24. package/lib/module/components/FileViewer/useFileViewerZoom.js +1 -1
  25. package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
  26. package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
  27. package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
  28. package/lib/module/components/SlideToConfirm/SlideToConfirm.js +1 -1
  29. package/lib/module/components/Slider/Slider.js +1 -1
  30. package/lib/module/components/SortableList/SortableList.js +1 -1
  31. package/lib/module/components/Swipeable/Swipeable.js +1 -1
  32. package/lib/module/components/WheelPicker/Wheel.js +1 -1
  33. package/lib/module/components/ZoomableImage/ZoomableImage.js +1 -1
  34. package/lib/module/hooks/useDragToDismiss.js +1 -1
  35. package/lib/module/navigation/NavigationScreen.js +1 -1
  36. package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +1 -1
  37. package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +1 -1
  38. package/lib/typescript/commonjs/components/FileViewer/useFileViewerZoom.d.ts +3 -3
  39. package/lib/typescript/commonjs/components/Swipeable/Swipeable.d.ts +1 -1
  40. package/lib/typescript/commonjs/hooks/useDragToDismiss.d.ts +5 -5
  41. package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +1 -1
  42. package/lib/typescript/module/components/Drawer/Drawer.d.ts +1 -1
  43. package/lib/typescript/module/components/FileViewer/useFileViewerZoom.d.ts +3 -3
  44. package/lib/typescript/module/components/Swipeable/Swipeable.d.ts +1 -1
  45. package/lib/typescript/module/hooks/useDragToDismiss.d.ts +5 -5
  46. package/package.json +9 -9
@@ -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{assertValidValue}from"../../utils/assertValidValue.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_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:s=!1,threshold:n=.9,resetAfter:l=!1,haptic:c,icon:d,labels:u,style:m,trackStyle:h,handleStyle:f,labelStyle:p,testID:b}=e;assertValidValue("SlideToConfirm","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("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,A=useMemo(()=>buildStyles(v,y),[v,y]),w=v.colors[r],[T,j]=useState(!1),_=useSharedValue(0),V=useSharedValue(0),E=useSharedValue(0),k=useRef(null),L=useCallback(()=>{const e=resolveHaptic(c,"notificationSuccess");e&&triggerHaptic(e)},[c]),M=useCallback(()=>{j(!1),_.value=withSpring(0,{damping:18,stiffness:160,mass:1})},[_]),R=useCallback(()=>{j(!0),L(),i(),!1!==l&&(k.current&&clearTimeout(k.current),k.current=setTimeout(M,l))},[L,i,l,M]),D=useCallback(e=>{if(s||T)return;const{actionName:t}=e.nativeEvent;"activate"!==t&&"increment"!==t||R()},[s,T,R]);React.useEffect(()=>()=>{cancelAnimation(_),k.current&&clearTimeout(k.current)},[_]);const I=useCallback(e=>{V.value=Math.max(0,e.nativeEvent.layout.width-x-2*C)},[V,x,C]),O=useMemo(()=>{const e=n,t={damping:18,stiffness:160,mass:1},i={duration:v.motion.duration.fast,easing:Easing.out(Easing.cubic)};return Gesture.Pan().enabled(!s&&!T).minDistance(0).onStart(()=>{"worklet";E.value=_.value}).onUpdate(e=>{"worklet";_.value=Math.min(Math.max(E.value+e.translationX,0),V.value)}).onEnd(()=>{"worklet";V.value>0&&_.value>=V.value*e?(_.value=withTiming(V.value,i),runOnJS(R)()):_.value=withSpring(0,t)})},[s,T,n,_,V,E,R,v.motion.duration.fast]),z=useAnimatedStyle(()=>({transform:[{translateX:_.value}]}),[_]),F=useAnimatedStyle(()=>({width:_.value+x+C}),[_,x,C]),W=useAnimatedStyle(()=>{const e=V.value>0?V.value:1;return{opacity:Math.max(0,1-_.value/(.6*e))}},[V,_]);return _jsxs(View,{ref:t,style:[A.track,{backgroundColor:v.colors["bg-subtle"]},h,m],onLayout:I,testID:b,accessibilityRole:"adjustable",accessibilityLabel:T?g.confirmed:a??g.slide,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityActions:S,onAccessibilityAction:D,children:[_jsx(Animated.View,{style:[A.fill,{backgroundColor:w,opacity:s?.5:1},F],pointerEvents:"none"}),_jsx(Animated.View,{style:[A.labelWrap,W],pointerEvents:"none",children:_jsx(Text,{variant:"body",style:[A.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:[A.handle,{width:x,height:x,borderRadius:v.radius.pill,...smoothCorners,backgroundColor:v.colors.surface,opacity:s?.5:1,...v.shadow.card},f,z],children:d??_jsx(Chevron,{color:w,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{GestureDetector,usePanGesture}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{assertValidValue}from"../../utils/assertValidValue.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_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:s=!1,threshold:n=.9,resetAfter:l=!1,haptic:c,icon:u,labels:d,style:m,trackStyle:h,handleStyle:f,labelStyle:p,testID:b}=e;assertValidValue("SlideToConfirm","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("SlideToConfirm","size",e.size,["sm","md","lg"]);const g=useMemo(()=>({...DEFAULT_SLIDE_TO_CONFIRM_LABELS,...d}),[d]),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,A=useMemo(()=>buildStyles(v,y),[v,y]),w=v.colors[r],[T,j]=useState(!1),_=useSharedValue(0),V=useSharedValue(0),E=useSharedValue(0),k=useRef(null),L=useCallback(()=>{const e=resolveHaptic(c,"notificationSuccess");e&&triggerHaptic(e)},[c]),M=useCallback(()=>{j(!1),_.value=withSpring(0,{damping:18,stiffness:160,mass:1})},[_]),R=useCallback(()=>{j(!0),L(),i(),!1!==l&&(k.current&&clearTimeout(k.current),k.current=setTimeout(M,l))},[L,i,l,M]),D=useCallback(e=>{if(s||T)return;const{actionName:t}=e.nativeEvent;"activate"!==t&&"increment"!==t||R()},[s,T,R]);React.useEffect(()=>()=>{cancelAnimation(_),k.current&&clearTimeout(k.current)},[_]);const I=useCallback(e=>{V.value=Math.max(0,e.nativeEvent.layout.width-x-2*C)},[V,x,C]),O=useMemo(()=>{const e=n,t={damping:18,stiffness:160,mass:1},i={duration:v.motion.duration.fast,easing:Easing.out(Easing.cubic)};return{enabled:!s&&!T,minDistance:0,onActivate:()=>{"worklet";E.value=_.value},onUpdate:e=>{"worklet";_.value=Math.min(Math.max(E.value+e.translationX,0),V.value)},onDeactivate:()=>{"worklet";V.value>0&&_.value>=V.value*e?(_.value=withTiming(V.value,i),runOnJS(R)()):_.value=withSpring(0,t)}}},[s,T,n,_,V,E,R,v.motion.duration.fast]),z=usePanGesture(O),F=useAnimatedStyle(()=>({transform:[{translateX:_.value}]}),[_]),P=useAnimatedStyle(()=>({width:_.value+x+C}),[_,x,C]),W=useAnimatedStyle(()=>{const e=V.value>0?V.value:1;return{opacity:Math.max(0,1-_.value/(.6*e))}},[V,_]);return _jsxs(View,{ref:t,style:[A.track,{backgroundColor:v.colors["bg-subtle"]},h,m],onLayout:I,testID:b,accessibilityRole:"adjustable",accessibilityLabel:T?g.confirmed:a??g.slide,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityActions:S,onAccessibilityAction:D,children:[_jsx(Animated.View,{style:[A.fill,{backgroundColor:w,opacity:s?.5:1},P],pointerEvents:"none"}),_jsx(Animated.View,{style:[A.labelWrap,W],pointerEvents:"none",children:_jsx(Text,{variant:"body",style:[A.label,{color:v.colors["text-muted"]},p],numberOfLines:1,children:T?g.confirmed:a??g.slide})}),_jsx(GestureDetector,{gesture:z,children:_jsx(Animated.View,{style:[A.handle,{width:x,height:x,borderRadius:v.radius.pill,...smoothCorners,backgroundColor:v.colors.surface,opacity:s?.5:1,...v.shadow.card},f,F],children:u??_jsx(Chevron,{color:w,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{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.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,s=String(i).split(".")[1]?.length??0,n=s>0?Number(r.toFixed(s)):r;return clamp(n,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:s=!1,tone:n="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;assertValidValue("Slider","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Slider","size",e.size,["sm","md","lg"]),assertValidValue("Slider","variant",e.variant,["default","inset","minimal","bar"]);const V=useTheme(),A=useMemo(()=>{const e=resolveSliderSize(V,o);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[V,o]),j=useMemo(()=>"default"===l?A:VARIANT_SIZE_MAP[l][o],[A,o,l]),M="inset"===l?j.trackHeight/2:0,_=V.settings.components.slider?.thumbPressAnimation??!1,D=S??1.1,H=k??V.motion.duration.fast,E=C??1,O=useMemo(()=>buildStyles(V,j),[V,j]),T=useMemo(()=>({damping:V.motion.spring.snappy.damping,stiffness:V.motion.spring.snappy.stiffness,mass:V.motion.spring.snappy.mass}),[V.motion.spring.snappy]),[R,I]=useState(0),W=V.colors[n],L=sliderToneInk(V,n),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 s=t-2*M;if(s<=0)return a;const n=clamp((e-M)/s,0,1);return snapToStep(a+n*(i-a),a,i,r)},[a,i,r,M]),ae=useRef(!1),ie=V.motion.duration.fast,re=useRef(P);re.current=P;const se=useRef(R);se.current=R;const ne=useCallback((e=!1)=>{const t=se.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),s=Math.max(e,i);z.value=r,G.value=s,B.value=place(ee(r,t)),F.value=place(ee(s,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,ne(e)},[JSON.stringify(P),R,oe,ne]);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,n="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,V=M,follow=e=>{"worklet";const a=U.value-2*V;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(J.value+e,V),U.value-V);let r=h+(i-V)/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?V:V+(r-h)/(b-h)*a:g?m?Math.min(i,F.value):Math.max(i,B.value):i,r!==n.value&&(n.value=r,r!==h&&r!==b||runOnJS(ge)(),runOnJS(fe)(z.value,G.value))},A=Gesture.Pan().enabled(!s).minDistance(0);return(void 0===we?A:A.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)})},[s,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(s||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:V.motion.duration.fast,easing:Easing.out(Easing.cubic)}),me(a,a))},[s,N,R,te,ee,me,he,B,z,V.motion.duration.fast]),xe=useCallback(e=>{if(s)return;const t="increment"===e.nativeEvent.actionName?r:-r,n=r>0?Math.round(t*Y)/Y:t;if(N){const e=Math.round((z.value+n)*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+n)*Y)/Y,t=clamp(e,a,i);t!==z.value&&(z.value=t,B.value=ee(t,R),he(),me(t,t))}},[s,r,Y,N,a,i,ee,R,B,z,G,me,he]),Ve=j.thumbDiameter/2,Ae=s?V.colors["surface-disabled"]:W,je="inset"===l?{backgroundColor:Ae,borderColor:V.colors.surface,borderWidth:Math.max(2,Math.round(.3*j.thumbDiameter)),...NO_SHADOW}:"minimal"===l?{backgroundColor:Ae,borderWidth:0}:"bar"===l?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:V.colors.surface,borderColor:Ae},Me=useAnimatedStyle(()=>{const e=U.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=s?.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,s,N,F,B,M]),De=useAnimatedStyle(()=>({transform:[{translateX:B.value-Ve},{scale:Z.value}]}),[B,Ve,Z]),He=useAnimatedStyle(()=>({transform:[{translateX:F.value-Ve},{scale:$.value}]}),[F,Ve,$]),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:s},"aria-disabled":s,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:s||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:s?V.colors["surface-disabled"]:V.colors.border},g]}),_jsx(Animated.View,{style:[O.fill,{backgroundColor:s?V.colors["surface-disabled"]:W},v,Me]})]}),_jsx(GestureDetector,{gesture:Se,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:Ve,...smoothCorners,opacity:s?.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:Ve,...smoothCorners,opacity:s?.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{GestureDetector,usePanGesture}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{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.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,s=String(i).split(".")[1]?.length??0,n=s>0?Number(r.toFixed(s)):r;return clamp(n,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:s=!1,tone:n="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;assertValidValue("Slider","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Slider","size",e.size,["sm","md","lg"]),assertValidValue("Slider","variant",e.variant,["default","inset","minimal","bar"]);const V=useTheme(),A=useMemo(()=>{const e=resolveSliderSize(V,o);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[V,o]),j=useMemo(()=>"default"===l?A:VARIANT_SIZE_MAP[l][o],[A,o,l]),M="inset"===l?j.trackHeight/2:0,_=V.settings.components.slider?.thumbPressAnimation??!1,D=S??1.1,H=k??V.motion.duration.fast,E=C??1,O=useMemo(()=>buildStyles(V,j),[V,j]),T=useMemo(()=>({damping:V.motion.spring.snappy.damping,stiffness:V.motion.spring.snappy.stiffness,mass:V.motion.spring.snappy.mass}),[V.motion.spring.snappy]),[R,I]=useState(0),W=V.colors[n],P=sliderToneInk(V,n),L=!0===e.range,[N,X]=useControllableState({value:e.value,defaultValue:e.defaultValue??(L?[a,i]:a),onChange:e.onChange}),B=useSharedValue(0),F=useSharedValue(0),G=useSharedValue(L?N[0]:N),z=useSharedValue(L?N[1]:N),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 s=t-2*M;if(s<=0)return a;const n=clamp((e-M)/s,0,1);return snapToStep(a+n*(i-a),a,i,r)},[a,i,r,M]),ae=useRef(!1),ie=V.motion.duration.fast,re=useRef(N);re.current=N;const se=useRef(R);se.current=R;const ne=useCallback((e=!1)=>{const t=se.current;if(t<=0)return;const place=t=>e?withTiming(t,{duration:ie,easing:Easing.out(Easing.cubic)}):t,a=re.current;if(L){const[e,i]=a,r=Math.min(e,i),s=Math.max(e,i);G.value=r,z.value=s,B.value=place(ee(r,t)),F.value=place(ee(s,t))}else{const e=a;G.value=e,z.value=e,B.value=place(ee(e,t))}},[L,ee,G,z,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,ne(e)},[JSON.stringify(N),R,oe,ne]);const de=useCallback(e=>{const t=e.nativeEvent.layout.width;U.value=t,I(t)},[U]),me=useCallback((e,t)=>{X(L?[e,t]:e)},[L,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,n="low"===e?G:z,o="low"===e?z:G,l="low"===e?Z:$,d="low"===e?K:Q,m="low"===e,h=a,b=i,p=r,f=Y,g=L,v=D,w=_,y=!0===u,S=c,k=E,C=H,x=T,V=M,follow=e=>{"worklet";const a=U.value-2*V;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(J.value+e,V),U.value-V);let r=h+(i-V)/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?V:V+(r-h)/(b-h)*a:g?m?Math.min(i,F.value):Math.max(i,B.value):i,r!==n.value&&(n.value=r,r!==h&&r!==b||runOnJS(ge)(),runOnJS(fe)(G.value,z.value))};return{enabled:!s,minDistance:0,...void 0===we?{}:{hitSlop:we},onActivate:()=>{"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)},onDeactivate: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)}}},[s,a,i,r,Y,L,D,_,u,c,E,H,T,M,we,fe,ge,ce,B,F,G,z,Z,$,K,Q,J,U]),Se=useMemo(()=>ye("low"),[ye]),ke=useMemo(()=>ye("high"),[ye]),Ce=usePanGesture(Se),xe=usePanGesture(ke),Ve=useCallback(e=>{if(s||L||R<=0)return;const t=clamp(e.nativeEvent.locationX,0,R),a=te(t,R);a!==G.value&&(he(),G.value=a,B.value=withTiming(ee(a,R),{duration:V.motion.duration.fast,easing:Easing.out(Easing.cubic)}),me(a,a))},[s,L,R,te,ee,me,he,B,G,V.motion.duration.fast]),Ae=useCallback(e=>{if(s)return;const t="increment"===e.nativeEvent.actionName?r:-r,n=r>0?Math.round(t*Y)/Y:t;if(L){const e=Math.round((G.value+n)*Y)/Y,t=clamp(e,a,z.value);t!==G.value&&(G.value=t,B.value=ee(t,R),he(),me(t,z.value))}else{const e=Math.round((G.value+n)*Y)/Y,t=clamp(e,a,i);t!==G.value&&(G.value=t,B.value=ee(t,R),he(),me(t,t))}},[s,r,Y,L,a,i,ee,R,B,G,z,me,he]),je=j.thumbDiameter/2,Me=s?V.colors["surface-disabled"]:W,De="inset"===l?{backgroundColor:Me,borderColor:V.colors.surface,borderWidth:Math.max(2,Math.round(.3*j.thumbDiameter)),...NO_SHADOW}:"minimal"===l?{backgroundColor:Me,borderWidth:0}:"bar"===l?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:V.colors.surface,borderColor:Me},He=useAnimatedStyle(()=>{const e=U.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=s?.55:1;if(L){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,s,L,F,B,M]),Ee=useAnimatedStyle(()=>({transform:[{translateX:B.value-je},{scale:Z.value}]}),[B,je,Z]),Oe=useAnimatedStyle(()=>({transform:[{translateX:F.value-je},{scale:$.value}]}),[F,je,$]),Te=useAnimatedStyle(()=>({opacity:K.value}),[K]),Re=useAnimatedStyle(()=>({opacity:Q.value}),[Q]),clampDisplay=e=>clamp(e,a,i),Ie=clampDisplay(L?Math.min(...N):N),We=clampDisplay(L?Math.max(...N):N);return _jsx(View,{ref:t,style:[O.container,f,p],testID:x,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityValue:L?{min:a,max:i,now:Ie,text:`${Ie} to ${We}`}:{min:a,max:i,now:Ie},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Ae,children:_jsx(Pressable,{onPress:Ve,disabled:s||L,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:s?V.colors["surface-disabled"]:V.colors.border},g]}),_jsx(Animated.View,{style:[O.fill,{backgroundColor:s?V.colors["surface-disabled"]:W},v,He]})]}),_jsx(GestureDetector,{gesture:Ce,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:je,...smoothCorners,opacity:s?.55:1},De,w,Ee],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[O.bubbleWrap,Te],pointerEvents:"none",children:[_jsx(View,{style:[O.bubble,{backgroundColor:W}],children:m?m(Ie):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:P},y],numberOfLines:1,children:d(Ie)})}),_jsx(View,{style:[O.bubbleCaret,{backgroundColor:W}]})]}):null})}),L?_jsx(GestureDetector,{gesture:xe,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:je,...smoothCorners,opacity:s?.55:1},De,w,Oe],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[O.bubbleWrap,Re],pointerEvents:"none",children:[_jsx(View,{style:[O.bubble,{backgroundColor:W}],children:m?m(We):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:P},y],numberOfLines:1,children:d(We)})}),_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}),[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
+ "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{GestureDetector,usePanGesture}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;return{enabled:!n,activateAfterLongPress:s?void 0:350,onActivate: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)}}},[n,s,t,i,u]),g=usePanGesture(f),p=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:p,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:g,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:g,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 P=useCallback(e=>{D(t=>t?.dragging?{...t,to:e}:t)},[]),G=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(P)(a))},!1),N=useCallback(e=>{triggerHaptic("longPress"),G.setActive(!0),D({key:m[e]??"",from:e,to:e,dragging:!0})},[G,m]),H=useCallback((e,t)=>{G.setActive(!1),D(e=>e?{...e,to:t,dragging:!1}:e),t!==e&&o(moveItem(m,e,t))},[G,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{assertValidValue}from"../../utils/assertValidValue.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:i,threshold:s,fullSwipeThreshold:o,onSwipeOpen:r,onSwipeClose:a,disabled:l=!1,haptic:c,containerStyle:u,contentStyle:d,actionStyle:m,accessibilityLabel:h,testID:p}=e,S=useTheme(),b=s??80,f=o??200,w=useMemo(()=>buildStyles(S),[S]),g=useMemo(()=>buildActionStyles(S),[S]),y=!!n&&n.length>0,x=!!i&&i.length>0,v=Dimensions.get("window").width,A=y?b*(n?.length??0):0,I=x?b*(i?.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,r?.(e))},[r]),G=useCallback(()=>{null!==O.current&&(O.current=null,a?.())},[a]),N=useCallback(e=>{const t="left"===e?n:i,s=t?.[0];s&&(!1!==c&&triggerHaptic("notificationSuccess"),s.onPress(),_.value=withSpring(0,SPRING_CONFIG),O.current=null,a?.())},[n,i,_,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=A,t=I,n=f,i=-f,s=v,o=-v,r=b,a=y,c=x;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 i=C.value+n.translationX;_.value=i>0&&!a||i<0&&!c?0:i>e&&a?e+.35*(i-e):i<-t&&c?.35*(i+t)-t:i}).onEnd(()=>{"worklet";const l=_.value;return a&&l>=n?(_.value=withSpring(s,SPRING_CONFIG),void runOnJS(N)("left")):c&&l<=i?(_.value=withSpring(o,SPRING_CONFIG),void runOnJS(N)("right")):a&&l>=r?(_.value=withSpring(e,SPRING_CONFIG),void runOnJS(j)("left")):c&&l<=-r?(_.value=withSpring(-t,SPRING_CONFIG),void runOnJS(j)("right")):(_.value=withSpring(0,SPRING_CONFIG),void runOnJS(G)())})},[l,C,N,f,y,x,A,G,j,I,v,b,_,p]),T=useAnimatedStyle(()=>({transform:[{translateX:_.value}]}),[_]),V=useAnimatedStyle(()=>({opacity:A>0?Math.min(1,Math.max(0,_.value/A)):0}),[A,_]),F=useAnimatedStyle(()=>({opacity:I>0?Math.min(1,Math.max(0,-_.value/I)):0}),[I,_]),E=useMemo(()=>{const e=[];return n?.forEach(t=>{e.push({name:t.key,label:t.label})}),i?.forEach(t=>{e.push({name:t.key,label:t.label})}),e},[n,i]),D=useCallback(e=>{const t=e.nativeEvent.actionName,s=[...n??[],...i??[]].find(e=>e.key===t);s&&(!1!==c&&triggerHaptic("selection"),s.onPress())},[n,i,c]);return y||x?_jsxs(View,{style:[w.root,u],testID:p,accessibilityLabel:h,accessibilityActions:E,onAccessibilityAction:D,children:[y?_jsx(Animated.View,{style:[w.actionsRow,w.actionsLeft,{width:A},m,V],pointerEvents:"box-none",children:n?.map(e=>_jsx(ActionButton,{action:e,theme:S,actionStyles:g,width:b,onPress:k},e.key))}):null,x?_jsx(Animated.View,{style:[w.actionsRow,w.actionsRight,{width:I},m,F],pointerEvents:"box-none",children:i?.map(e=>_jsx(ActionButton,{action:e,theme:S,actionStyles:g,width:b,onPress:k},e.key))}):null,_jsx(GestureDetector,{gesture:P,children:_jsx(Animated.View,{style:[w.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:i,onPress:s})=>{assertValidValue("Swipeable","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const o=e.tone??"neutral",r=toneToBg(t,o),a=renderSlotIcon(e.icon,{color:toneToOnColor(t,o),size:20,disabled:!1});return _jsxs(Pressable,{onPress:()=>s(e),accessibilityRole:"button",accessibilityLabel:e.label,style:[n.button,{width:i,backgroundColor:r,paddingHorizontal:t.space.sm}],children:[a?_jsx(View,{style:n.icon,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:a}):null,_jsx(Text,{variant:"bodySmall",weight:"semibold",style:[n.label,{color:toneToOnColor(t,o)}],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{GestureDetector,usePanGesture}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{assertValidValue}from"../../utils/assertValidValue.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:i,threshold:s,fullSwipeThreshold:o,onSwipeOpen:r,onSwipeClose:a,disabled:l=!1,haptic:c,containerStyle:u,contentStyle:d,actionStyle:m,accessibilityLabel:h,testID:p}=e,S=useTheme(),b=s??80,f=o??200,g=useMemo(()=>buildStyles(S),[S]),w=useMemo(()=>buildActionStyles(S),[S]),y=!!n&&n.length>0,v=!!i&&i.length>0,x=Dimensions.get("window").width,A=y?b*(n?.length??0):0,I=v?b*(i?.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,r?.(e))},[r]),G=useCallback(()=>{null!==O.current&&(O.current=null,a?.())},[a]),N=useCallback(e=>{const t="left"===e?n:i,s=t?.[0];s&&(!1!==c&&triggerHaptic("notificationSuccess"),s.onPress(),_.value=withSpring(0,SPRING_CONFIG),O.current=null,a?.())},[n,i,_,a,c]),R=useCallback(()=>{_.value=withSpring(0,SPRING_CONFIG),G()},[_,G]),P=useCallback(e=>{const t=resolveHaptic(c,"selection");t&&triggerHaptic(t),e.onPress(),R()},[R,c]),k=useMemo(()=>{const e=A,t=I,n=f,i=-f,s=x,o=-x,r=b,a=y,c=v;return{enabled:!l,testID:p?`${p}-gesture`:"swipeable-gesture",activeOffsetX:[-10,10],failOffsetY:[-15,15],onActivate:()=>{"worklet";C.value=_.value},onUpdate:n=>{"worklet";const i=C.value+n.translationX;_.value=i>0&&!a||i<0&&!c?0:i>e&&a?e+.35*(i-e):i<-t&&c?.35*(i+t)-t:i},onDeactivate:()=>{"worklet";const l=_.value;return a&&l>=n?(_.value=withSpring(s,SPRING_CONFIG),void runOnJS(N)("left")):c&&l<=i?(_.value=withSpring(o,SPRING_CONFIG),void runOnJS(N)("right")):a&&l>=r?(_.value=withSpring(e,SPRING_CONFIG),void runOnJS(j)("left")):c&&l<=-r?(_.value=withSpring(-t,SPRING_CONFIG),void runOnJS(j)("right")):(_.value=withSpring(0,SPRING_CONFIG),void runOnJS(G)())}}},[l,C,N,f,y,v,A,G,j,I,x,b,_,p]),T=usePanGesture(k),V=useAnimatedStyle(()=>({transform:[{translateX:_.value}]}),[_]),F=useAnimatedStyle(()=>({opacity:A>0?Math.min(1,Math.max(0,_.value/A)):0}),[A,_]),D=useAnimatedStyle(()=>({opacity:I>0?Math.min(1,Math.max(0,-_.value/I)):0}),[I,_]),E=useMemo(()=>{const e=[];return n?.forEach(t=>{e.push({name:t.key,label:t.label})}),i?.forEach(t=>{e.push({name:t.key,label:t.label})}),e},[n,i]),B=useCallback(e=>{const t=e.nativeEvent.actionName,s=[...n??[],...i??[]].find(e=>e.key===t);s&&(!1!==c&&triggerHaptic("selection"),s.onPress())},[n,i,c]);return y||v?_jsxs(View,{style:[g.root,u],testID:p,accessibilityLabel:h,accessibilityActions:E,onAccessibilityAction:B,children:[y?_jsx(Animated.View,{style:[g.actionsRow,g.actionsLeft,{width:A},m,F],pointerEvents:"box-none",children:n?.map(e=>_jsx(ActionButton,{action:e,theme:S,actionStyles:w,width:b,onPress:P},e.key))}):null,v?_jsx(Animated.View,{style:[g.actionsRow,g.actionsRight,{width:I},m,D],pointerEvents:"box-none",children:i?.map(e=>_jsx(ActionButton,{action:e,theme:S,actionStyles:w,width:b,onPress:P},e.key))}):null,_jsx(GestureDetector,{gesture:T,children:_jsx(Animated.View,{style:[g.content,d,V],children:t})})]}):_jsx(View,{style:u,testID:p,children:t})};Swipeable.displayName="Swipeable";const ActionButton=({action:e,theme:t,actionStyles:n,width:i,onPress:s})=>{assertValidValue("Swipeable","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const o=e.tone??"neutral",r=toneToBg(t,o),a=renderSlotIcon(e.icon,{color:toneToOnColor(t,o),size:20,disabled:!1});return _jsxs(Pressable,{onPress:()=>s(e),accessibilityRole:"button",accessibilityLabel:e.label,style:[n.button,{width:i,backgroundColor:r,paddingHorizontal:t.space.sm}],children:[a?_jsx(View,{style:n.icon,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:a}):null,_jsx(Text,{variant:"bodySmall",weight:"semibold",style:[n.label,{color:toneToOnColor(t,o)}],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{Fragment,memo,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Platform,Pressable,StyleSheet,TextInput,View}from"react-native";import{createAnimatedValue,setNativeValue}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const WHEEL_VISIBLE_ITEMS=5;export const WHEEL_CENTER_OFFSET=Math.floor(2.5);const HAPTIC_DEBOUNCE_MS=35,WEB_SETTLE_MS=120,SCALE_STOPS=[-2,-1,0,1,2],WheelRow=memo(({label:e,index:t,scrollY:n,itemHeight:a,selected:r,theme:i,reducedMotion:s,onPress:l,editor:c})=>{const{opacity:o,scale:u}=useMemo(()=>{const e=Animated.subtract(Animated.divide(n,a),t);return{opacity:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.3,.6,1,.6,.3],extrapolate:"clamp"}),scale:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.85,.95,1.05,.95,.85],extrapolate:"clamp"})}},[n,a,t]),m=_jsx(Text,{variant:"h3",weight:r?"semibold":"medium",color:r?"primary":"secondary",numberOfLines:1,maxFontSizeMultiplier:1.5,style:{letterSpacing:i["letter-spacing"].normal},children:e});return _jsx(Animated.View,{style:[styles.row,{height:a},s?{opacity:o}:{opacity:o,transform:[{scale:u}]}],accessible:!1,importantForAccessibility:"no",children:c??(l?_jsx(Pressable,{focusable:!1,accessible:!1,onPress:()=>l(t),style:styles.rowPress,children:m}):m)})});export const Wheel=({label:e,items:t,selectedIndex:n,onIndexChange:a,itemHeight:r,width:i,theme:s,haptic:l,disabled:c,reducedMotion:o,typeable:u,testID:m})=>{const d="web"===Platform.OS,[b,y]=useState(null),f=useRef(!1),h=useRef(null),p=useRef(createAnimatedValue(n*r)).current,x=useRef(n*r),g=useRef(n*r),S=useRef(n),v=useRef(0),E=useRef(null),T=useRef(()=>{}),w=t.length-1;useEffect(()=>{S.current=n;const e=n*r;if(g.current===e)return;if(g.current=e,Math.abs(x.current-e)<1)return;x.current=e,d||setNativeValue(p,e);const t=requestAnimationFrame(()=>{h.current?.scrollTo({y:e,animated:!1})});return()=>cancelAnimationFrame(t)},[n,r,p,d]),useEffect(()=>{const e=x.current,t=requestAnimationFrame(()=>{h.current?.scrollTo({y:e,animated:!1})});return()=>cancelAnimationFrame(t)},[]),useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]);const M=useCallback((e,r)=>{if(!(e===n||e<0||e>w)){if("accessibility"===r){const e=resolveHaptic(l,"denseTick");e&&triggerHaptic(e)}if("keyboard"!==r){const n=t[e];n&&announce(n.accessibilityLabel??n.label)}a(e)}},[n,w,t,l,a]),A=useCallback(()=>{!c&&u&&(f.current=!0,y(String(t[n]?.value??"")))},[c,u,t,n]),_=useCallback(e=>{if(!f.current)return;f.current=!1,y(null);const n=e.trim();if(!/^\d+$/.test(n))return;const a=Number(n),r=t.findIndex(e=>e.value===a);r>=0&&M(r,"keyboard")},[t,M]);T.current=()=>{E.current=null;const e=Math.max(0,Math.min(w,Math.round(x.current/r))),t=e*r;Math.abs(x.current-t)>=1&&h.current?.scrollTo({y:t,animated:!o}),M(e,"scroll")};const j=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{y:p}}}],{useNativeDriver:!d,listener:e=>{const t=e.nativeEvent.contentOffset.y;x.current=t;const n=Math.round(t/r);if(n!==S.current&&n>=0&&n<=w){const e=Date.now();if(e-v.current>=35){const t=resolveHaptic(l,"denseTick");t&&triggerHaptic(t),v.current=e}S.current=n}d&&(E.current&&clearTimeout(E.current),E.current=setTimeout(()=>T.current(),120))}}),[p,r,w,l,d]),C=useCallback(e=>{const t=e.nativeEvent.contentOffset.y;M(Math.max(0,Math.min(w,Math.round(t/r))),"scroll")},[M,w,r]),R=useCallback(e=>{if(c)return;const t=e.nativeEvent.actionName;"increment"===t?M(Math.min(w,n+1),"accessibility"):"decrement"===t&&M(Math.max(0,n-1),"accessibility")},[c,M,w,n]),F=useCallback(e=>{c||h.current?.scrollTo({y:e*r,animated:!o})},[c,r,o]),k=useCallback(({item:t,index:a})=>{const i=a===n,l=i&&null!==b;return _jsx(WheelRow,{label:t.label,index:a,scrollY:p,itemHeight:r,selected:i,theme:s,reducedMotion:o,onPress:i&&u?A:d?F:void 0,editor:l?_jsx(TextInput,{autoFocus:!0,selectTextOnFocus:!0,keyboardType:"number-pad",returnKeyType:"done",accessibilityLabel:e,value:b,onChangeText:y,onSubmitEditing:()=>_(b),onBlur:()=>_(b),style:{width:"100%",padding:s.space.none,textAlign:"center",fontSize:s.text.xl.size,color:s.colors["text-body"],fontWeight:s.weight.semibold,letterSpacing:s["letter-spacing"].normal}}):void 0})},[p,r,n,s,o,d,F,u,A,b,_,e]),I=useCallback((e,t)=>`${String(e.value)}-${t}`,[]),L=t[n]?t[n].accessibilityLabel??t[n].label:"",P=d?{focusable:!0,role:"spinbutton","aria-label":e,"aria-valuetext":L,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":w,"aria-disabled":c,onKeyDown:e=>{if(c)return;const t={ArrowDown:Math.min(w,n+1),PageDown:Math.min(w,n+1),ArrowUp:Math.max(0,n-1),PageUp:Math.max(0,n-1),Home:0,End:w}[e.nativeEvent.key];void 0!==t&&(e.preventDefault(),M(t,"keyboard"))}}:void 0;return _jsxs(View,{style:[void 0===i?styles.columnFlex:{width:i},{height:5*r},styles.column,c?styles.disabled:null],testID:m,...P,children:[d?null:_jsx(View,{pointerEvents:"none",style:styles.a11yLayer,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:e,accessibilityValue:{text:L},accessibilityState:{disabled:Boolean(c)},"aria-disabled":Boolean(c),accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:R}),_jsx(Animated.ScrollView,{ref:h,showsVerticalScrollIndicator:!1,snapToInterval:r,snapToAlignment:"start",decelerationRate:"fast",bounces:!1,scrollEnabled:!c,nestedScrollEnabled:!0,scrollEventThrottle:16,onScroll:j,onMomentumScrollEnd:C,contentOffset:{x:0,y:n*r},contentContainerStyle:{paddingVertical:r*WHEEL_CENTER_OFFSET},style:[styles.list,{height:5*r}],importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:t.map((e,t)=>_jsx(Fragment,{children:k({item:e,index:t})},I(e,t)))})]})};const styles=StyleSheet.create({column:{overflow:"hidden"},columnFlex:{flex:1},disabled:{opacity:.5},list:{flexGrow:0},row:{alignItems:"center",justifyContent:"center"},rowPress:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",flex:1},a11yLayer:{...StyleSheet.absoluteFill,zIndex:2}});
1
+ "use strict";import{Fragment,memo,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Platform,Pressable,StyleSheet,TextInput,View}from"react-native";import{createAnimatedValue,setNativeValue}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const WHEEL_VISIBLE_ITEMS=5;export const WHEEL_CENTER_OFFSET=Math.floor(2.5);const HAPTIC_DEBOUNCE_MS=35,WEB_SETTLE_MS=120,SCALE_STOPS=[-2,-1,0,1,2],WheelRow=memo(({label:e,index:t,scrollY:n,itemHeight:r,selected:a,theme:i,reducedMotion:s,onPress:l,editor:c})=>{const{opacity:o,scale:u}=useMemo(()=>{const e=Animated.subtract(Animated.divide(n,r),t);return{opacity:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.3,.6,1,.6,.3],extrapolate:"clamp"}),scale:e.interpolate({inputRange:SCALE_STOPS,outputRange:[.85,.95,1.05,.95,.85],extrapolate:"clamp"})}},[n,r,t]),m=_jsx(Text,{variant:"h3",weight:a?"semibold":"medium",color:a?"primary":"secondary",numberOfLines:1,maxFontSizeMultiplier:1.5,style:{letterSpacing:i["letter-spacing"].normal},children:e});return _jsx(Animated.View,{style:[styles.row,{height:r},s?{opacity:o}:{opacity:o,transform:[{scale:u}]}],accessible:!1,importantForAccessibility:"no",children:c??(l?_jsx(Pressable,{focusable:!1,accessible:!1,onPress:()=>l(t),style:styles.rowPress,children:m}):m)})});export const Wheel=({label:e,items:t,selectedIndex:n,onIndexChange:r,itemHeight:a,width:i,theme:s,haptic:l,disabled:c,reducedMotion:o,typeable:u,testID:m})=>{const d="web"===Platform.OS,[b,f]=useState(null),y=useRef(!1),h=useRef(null),p=useRef(createAnimatedValue(n*a)).current,x=useRef(n*a),v=useRef(n*a),g=useRef(n),S=useRef(0),E=useRef(null),T=useRef(()=>{}),w=t.length-1;useEffect(()=>{g.current=n;const e=n*a;if(v.current===e)return;if(v.current=e,Math.abs(x.current-e)<1)return;x.current=e,d||setNativeValue(p,e);const t=requestAnimationFrame(()=>{h.current?.scrollTo({y:e,animated:!1})});return()=>cancelAnimationFrame(t)},[n,a,p,d]),useEffect(()=>{const e=x.current,t=requestAnimationFrame(()=>{h.current?.scrollTo({y:e,animated:!1})});return()=>cancelAnimationFrame(t)},[]),useEffect(()=>()=>{E.current&&clearTimeout(E.current)},[]);const M=useCallback((e,a)=>{if(!(e===n||e<0||e>w)){if("accessibility"===a){const e=resolveHaptic(l,"denseTick");e&&triggerHaptic(e)}if("keyboard"!==a){const n=t[e];n&&announce(n.accessibilityLabel??n.label)}r(e)}},[n,w,t,l,r]),A=useCallback(()=>{!c&&u&&(y.current=!0,f(String(t[n]?.value??"")))},[c,u,t,n]),_=useCallback(e=>{if(!y.current)return;y.current=!1,f(null);const n=e.trim();if(!/^\d+$/.test(n))return;const r=Number(n),a=t.findIndex(e=>e.value===r);a>=0&&M(a,"keyboard")},[t,M]);T.current=()=>{E.current=null;const e=Math.max(0,Math.min(w,Math.round(x.current/a))),t=e*a;Math.abs(x.current-t)>=1&&h.current?.scrollTo({y:t,animated:!o}),M(e,"scroll")};const j=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{y:p}}}],{useNativeDriver:nativeDriver,listener:e=>{const t=e.nativeEvent.contentOffset.y;x.current=t;const n=Math.round(t/a);if(n!==g.current&&n>=0&&n<=w){const e=Date.now();if(e-S.current>=35){const t=resolveHaptic(l,"denseTick");t&&triggerHaptic(t),S.current=e}g.current=n}d&&(E.current&&clearTimeout(E.current),E.current=setTimeout(()=>T.current(),120))}}),[p,a,w,l,d]),C=useCallback(e=>{const t=e.nativeEvent.contentOffset.y;M(Math.max(0,Math.min(w,Math.round(t/a))),"scroll")},[M,w,a]),R=useCallback(e=>{if(c)return;const t=e.nativeEvent.actionName;"increment"===t?M(Math.min(w,n+1),"accessibility"):"decrement"===t&&M(Math.max(0,n-1),"accessibility")},[c,M,w,n]),F=useCallback(e=>{c||h.current?.scrollTo({y:e*a,animated:!o})},[c,a,o]),k=useCallback(({item:t,index:r})=>{const i=r===n,l=i&&null!==b;return _jsx(WheelRow,{label:t.label,index:r,scrollY:p,itemHeight:a,selected:i,theme:s,reducedMotion:o,onPress:i&&u?A:d?F:void 0,editor:l?_jsx(TextInput,{autoFocus:!0,selectTextOnFocus:!0,keyboardType:"number-pad",returnKeyType:"done",accessibilityLabel:e,value:b,onChangeText:f,onSubmitEditing:()=>_(b),onBlur:()=>_(b),style:{width:"100%",padding:s.space.none,textAlign:"center",fontSize:s.text.xl.size,color:s.colors["text-body"],fontWeight:s.weight.semibold,letterSpacing:s["letter-spacing"].normal}}):void 0})},[p,a,n,s,o,d,F,u,A,b,_,e]),I=useCallback((e,t)=>`${String(e.value)}-${t}`,[]),L=t[n]?t[n].accessibilityLabel??t[n].label:"",P=d?{focusable:!0,role:"spinbutton","aria-label":e,"aria-valuetext":L,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":w,"aria-disabled":c,onKeyDown:e=>{if(c)return;const t={ArrowDown:Math.min(w,n+1),PageDown:Math.min(w,n+1),ArrowUp:Math.max(0,n-1),PageUp:Math.max(0,n-1),Home:0,End:w}[e.nativeEvent.key];void 0!==t&&(e.preventDefault(),M(t,"keyboard"))}}:void 0;return _jsxs(View,{style:[void 0===i?styles.columnFlex:{width:i},{height:5*a},styles.column,c?styles.disabled:null],testID:m,...P,children:[d?null:_jsx(View,{pointerEvents:"none",style:styles.a11yLayer,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:e,accessibilityValue:{text:L},accessibilityState:{disabled:Boolean(c)},"aria-disabled":Boolean(c),accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:R}),_jsx(Animated.ScrollView,{ref:h,showsVerticalScrollIndicator:!1,snapToInterval:a,snapToAlignment:"start",decelerationRate:"fast",bounces:!1,scrollEnabled:!c,nestedScrollEnabled:!0,scrollEventThrottle:16,onScroll:j,onMomentumScrollEnd:C,contentOffset:{x:0,y:n*a},contentContainerStyle:{paddingVertical:a*WHEEL_CENTER_OFFSET},style:[styles.list,{height:5*a}],importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:t.map((e,t)=>_jsx(Fragment,{children:k({item:e,index:t})},I(e,t)))})]})};const styles=StyleSheet.create({column:{overflow:"hidden"},columnFlex:{flex:1},disabled:{opacity:.5},list:{flexGrow:0},row:{alignItems:"center",justifyContent:"center"},rowPress:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",flex:1},a11yLayer:{...StyleSheet.absoluteFill,zIndex:2}});
@@ -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}]}),[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;
1
+ "use strict";import{useCallback,useEffect,useMemo}from"react";import{StyleSheet}from"react-native";import{GestureDetector,useCompetingGestures,usePanGesture,usePinchGesture,useTapGesture}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:u=!1,haptic:i,style:s,accessibilityLabel:r,testID:n})=>{const o=useSharedValue(1),v=useSharedValue(1),c=useSharedValue(0),S=useSharedValue(0),m=useSharedValue(0),d=useSharedValue(0),p=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(()=>{u&&p()},[u,p]);const h=useCallback(()=>{const e=resolveHaptic(i,"impactLight");e&&triggerHaptic(e)},[i]),G=useMemo(()=>({enabled:!u,onActivate:()=>{"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},onDeactivate:()=>{"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)}}),[u,o,v,c,S,m,d,t,a]),I=usePinchGesture(G),g=useMemo(()=>({enabled:!u,minPointers:1,maxPointers:1,onActivate:()=>{"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)},onDeactivate:()=>{"worklet";m.value=c.value,d.value=S.value}}),[u,o,c,S,m,d]),N=usePanGesture(g),w=useMemo(()=>({enabled:!u,numberOfTaps:2,onDeactivate:()=>{"worklet";runOnJS(h)(),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)}}),[u,o,v,c,S,m,d,h,l]),_=useTapGesture(w),C=useCompetingGestures(I,N,_),b=useAnimatedStyle(()=>({transform:[{translateX:c.value},{translateY:S.value},{scale:o.value}]}),[c,S,o]);return _jsx(GestureDetector,{gesture:C,children:_jsx(Animated.View,{style:[styles.container,s],testID:n,accessibilityLabel:r,accessibilityState:{disabled:u},"aria-disabled":u,children:_jsx(Animated.View,{style:[styles.content,b],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 +1 @@
1
- "use strict";import{useMemo,useRef}from"react";import{Animated,Easing}from"react-native";import{Gesture}from"react-native-gesture-handler";import{createAnimatedValue,setNativeValue,useTheme}from"../theme/index.js";import{nativeDriver}from"../utils/nativeDriver.js";import{usePresenceMotion}from"./usePresenceMotion.js";export const DRAG_DISMISS_DISTANCE=100;export const DRAG_DISMISS_VELOCITY=.5;export const createDragToDismissController=({drag:e,travel:t,onDismiss:r,opacity:a},i,s)=>{const{snappy:n}=i.spring,springBack=()=>Animated.spring(e,{toValue:0,damping:n.damping,stiffness:n.stiffness,mass:n.mass,useNativeDriver:nativeDriver}).start(),o=!0===s?.reduced?a:void 0,u=s?.duration("default")??i.duration.default;return{move:t=>{setNativeValue(e,Math.max(0,t))},release:(a,s)=>{if(a>100||s>.5){if(o)return void Animated.timing(o,{toValue:0,duration:u,easing:Easing.bezier(...i.ease.accelerate),useNativeDriver:nativeDriver}).start(()=>r());Animated.timing(e,{toValue:"function"==typeof t?t():t,duration:i.duration.fast,easing:Easing.bezier(...i.ease.accelerate),useNativeDriver:nativeDriver}).start(()=>r())}else springBack()},cancel:springBack}};export const useDragToDismiss=e=>{const{drag:t,travel:r,onDismiss:a,contentAtTop:i,scrollGesture:s}=e,{motion:n}=useTheme(),o=usePresenceMotion(),u=useRef(createAnimatedValue(1)).current;return useMemo(()=>{const e=createDragToDismissController({drag:t,travel:r,onDismiss:a,opacity:u},n,o),l=Gesture.Pan().runOnJS(!0).activeOffsetY(6).failOffsetX([-12,12]).onUpdate(t=>e.move(t.translationY)).onEnd(t=>e.release(t.translationY,t.velocityY/1e3)).onFinalize((_e,t)=>{t||e.cancel()});let c=0,m=!1;const v=Gesture.Pan().runOnJS(!0).activeOffsetY(8).failOffsetX([-12,12]).onBegin(()=>{c=0,m=!1}).onUpdate(t=>{if(!m){if(i&&!i())return;m=!0,c=t.translationY}e.move(t.translationY-c)}).onEnd(t=>{m&&e.release(t.translationY-c,t.velocityY/1e3)}).onFinalize((_e,t)=>{!t&&m&&e.cancel()});return s&&v.simultaneousWithExternalGesture(s),{handleGesture:l,sheetGesture:v,opacity:u}},[t,r,a,i,s,n,o,u])};
1
+ "use strict";import{useMemo,useRef}from"react";import{Animated,Easing}from"react-native";import{usePanGesture}from"react-native-gesture-handler";import{createAnimatedValue,setNativeValue,useTheme}from"../theme/index.js";import{nativeDriver}from"../utils/nativeDriver.js";import{usePresenceMotion}from"./usePresenceMotion.js";export const DRAG_DISMISS_DISTANCE=100;export const DRAG_DISMISS_VELOCITY=.5;export const createDragToDismissController=({drag:e,travel:t,onDismiss:a,opacity:i},r,s)=>{const{snappy:n}=r.spring,springBack=()=>Animated.spring(e,{toValue:0,damping:n.damping,stiffness:n.stiffness,mass:n.mass,useNativeDriver:nativeDriver}).start(),o=!0===s?.reduced?i:void 0,u=s?.duration("default")??r.duration.default;return{move:t=>{setNativeValue(e,Math.max(0,t))},release:(i,s)=>{if(i>100||s>.5){if(o)return void Animated.timing(o,{toValue:0,duration:u,easing:Easing.bezier(...r.ease.accelerate),useNativeDriver:nativeDriver}).start(()=>a());Animated.timing(e,{toValue:"function"==typeof t?t():t,duration:r.duration.fast,easing:Easing.bezier(...r.ease.accelerate),useNativeDriver:nativeDriver}).start(()=>a())}else springBack()},cancel:springBack}};export const useDragToDismiss=e=>{const{drag:t,travel:a,onDismiss:i,contentAtTop:r,scrollGesture:s}=e,{motion:n}=useTheme(),o=usePresenceMotion(),u=useRef(createAnimatedValue(1)).current,c=useMemo(()=>createDragToDismissController({drag:t,travel:a,onDismiss:i,opacity:u},n,o),[t,a,i,u,n,o]),l=useMemo(()=>({runOnJS:!0,activeOffsetY:6,failOffsetX:[-12,12],onUpdate:e=>c.move(e.translationY),onDeactivate:e=>c.release(e.translationY,e.velocityY/1e3),onFinalize:e=>{e.canceled&&c.cancel()}}),[c]),m=usePanGesture(l),v=useMemo(()=>{let e=0,t=!1;return{runOnJS:!0,activeOffsetY:8,failOffsetX:[-12,12],simultaneousWith:s,onBegin:()=>{e=0,t=!1},onUpdate:a=>{if(!t){if(r&&!r())return;t=!0,e=a.translationY}c.move(a.translationY-e)},onDeactivate:a=>{t&&c.release(a.translationY-e,a.velocityY/1e3)},onFinalize:e=>{e.canceled&&t&&c.cancel()}}},[c,r,s]),f=usePanGesture(v);return useMemo(()=>({handleGesture:m,sheetGesture:f,opacity:u}),[m,f,u])};
@@ -1 +1 @@
1
- "use strict";import{BottomTabBarHeightContext}from"@react-navigation/bottom-tabs";import{useNavigation}from"@react-navigation/native";import{useContext}from"react";import{Screen}from"../components/Screen/index.js";import{useTheme}from"../theme/index.js";import{jsx as _jsx}from"react/jsx-runtime";const TAB_EDGES=["top"];export function NavigationScreen({kind:t="pushed",appBar:e=!0,onBack:o,...i}){const n=useNavigation(),r=useContext(BottomTabBarHeightContext),a=!0===useTheme().settings.components.screen?.tabBarFloats,s=e?i:{...i,title:void 0,subtitle:void 0,leading:void 0,trailing:void 0,rightActions:void 0};return _jsx(Screen,"tab"===t?{...s,largeTitle:!1,edges:TAB_EDGES,bottomInset:a?r??0:0}:{...s,largeTitle:!1,onBack:"root"!==t&&e?o??n.goBack:void 0})}
1
+ "use strict";import{useNavigation}from"@react-navigation/native";import{createContext,useContext}from"react";import{Screen}from"../components/Screen/index.js";import{useTheme}from"../theme/index.js";import{jsx as _jsx}from"react/jsx-runtime";const TabBarHeightContext=(()=>{try{return require("@react-navigation/bottom-tabs").BottomTabBarHeightContext}catch{return createContext(void 0)}})(),TAB_EDGES=["top"];export function NavigationScreen({kind:t="pushed",appBar:e=!0,onBack:o,...i}){const r=useNavigation(),n=useContext(TabBarHeightContext),a=!0===useTheme().settings.components.screen?.tabBarFloats,s=e?i:{...i,title:void 0,subtitle:void 0,leading:void 0,trailing:void 0,rightActions:void 0};return _jsx(Screen,"tab"===t?{...s,largeTitle:!1,edges:TAB_EDGES,bottomInset:a?n??0:0}:{...s,largeTitle:!1,onBack:"root"!==t&&e?o??r.goBack:void 0})}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * BottomSheet — Reanimated 3 + Gesture Handler 2 implementation.
2
+ * BottomSheet — Reanimated 3 + Gesture Handler 3 implementation.
3
3
  *
4
4
  * A polished, theme-aware bottom sheet with multi-snap-point support,
5
5
  * UI-thread driven pan gestures, and native-driver spring animations.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Drawer — slide-in side drawer (left / right / top / bottom).
3
3
  *
4
- * Built on Reanimated 3 + Gesture Handler 2 — gestures and animations run on the
4
+ * Built on Reanimated 4 and Gesture Handler 3's hooks: gestures and animations run on the
5
5
  * UI thread for buttery 60/120fps motion. Mirrors the BottomSheet ergonomics:
6
6
  * imperative ref API, controlled/uncontrolled visibility, swipe-to-dismiss,
7
7
  * tap-backdrop-to-dismiss, full a11y (modal dialog).
@@ -1,5 +1,5 @@
1
1
  import type { ViewStyle } from "react-native";
2
- import { Gesture } from "react-native-gesture-handler";
2
+ import { useNativeGesture, useSimultaneousGestures } from "react-native-gesture-handler";
3
3
  import type Animated from "react-native-reanimated";
4
4
  import type { AnimatedRef } from "react-native-reanimated";
5
5
  import { useAnimatedStyle } from "react-native-reanimated";
@@ -15,8 +15,8 @@ interface UseFileViewerZoomOptions {
15
15
  }
16
16
  export type UseFileViewerZoomResult = {
17
17
  scrollRef: AnimatedRef<Animated.ScrollView>;
18
- scrollGesture: ReturnType<typeof Gesture.Native>;
19
- zoomGesture: ReturnType<typeof Gesture.Simultaneous>;
18
+ scrollGesture: ReturnType<typeof useNativeGesture>;
19
+ zoomGesture: ReturnType<typeof useSimultaneousGestures>;
20
20
  zoomStyle: ReturnType<typeof useAnimatedStyle<ViewStyle>>;
21
21
  zoomLevel: number;
22
22
  resetZoom: () => void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Swipeable — Reanimated 3 + Gesture Handler 2 implementation.
2
+ * Swipeable: Reanimated 4 and Gesture Handler 3 hook implementation.
3
3
  *
4
4
  * Wraps any content and reveals contextual actions when the user
5
5
  * swipes left or right. Past `fullSwipeThreshold`, the first action
@@ -11,7 +11,7 @@
11
11
  * there moves the sheet, whatever the content is doing;
12
12
  * - `sheetGesture` for the sheet itself: a downward drag anywhere moves the
13
13
  * sheet while `contentAtTop()` says the content cannot scroll up any
14
- * further. Pass the list's own `Gesture.Native()` as `scrollGesture` so
14
+ * further. Pass the list's own `useNativeGesture()` as `scrollGesture` so
15
15
  * the two run together: the list scrolls as usual, and once it is at its
16
16
  * top the same finger pulls the sheet down.
17
17
  *
@@ -25,12 +25,12 @@
25
25
  * `<Modal>` needs its own one inside the modal (BottomSheet does the same).
26
26
  */
27
27
  import { Animated } from "react-native";
28
- import { Gesture } from "react-native-gesture-handler";
28
+ import { type useNativeGesture, usePanGesture } from "react-native-gesture-handler";
29
29
  import type { Theme } from "../theme/types";
30
30
  import { type PresenceMotion } from "./usePresenceMotion";
31
31
  /** The gesture types as the installed gesture-handler builds them; typed off the value so a second copy of the package cannot split them. */
32
- export type SheetPanGesture = ReturnType<typeof Gesture.Pan>;
33
- export type SheetNativeGesture = ReturnType<typeof Gesture.Native>;
32
+ export type SheetPanGesture = ReturnType<typeof usePanGesture>;
33
+ export type SheetNativeGesture = ReturnType<typeof useNativeGesture>;
34
34
  /** Release beyond this many px of downward drag dismisses. */
35
35
  export declare const DRAG_DISMISS_DISTANCE = 100;
36
36
  /** Release above this downward velocity (px/ms) dismisses. */
@@ -43,7 +43,7 @@ export interface UseDragToDismissOptions {
43
43
  onDismiss: () => void;
44
44
  /** Whether the content under the finger is scrolled to its top. Default: always. */
45
45
  contentAtTop?: () => boolean;
46
- /** The scrollable content's `Gesture.Native()`, so the sheet drag runs alongside its scroll. */
46
+ /** The scrollable content's `useNativeGesture()`, so the sheet drag runs alongside its scroll. */
47
47
  scrollGesture?: SheetNativeGesture;
48
48
  }
49
49
  export interface UseDragToDismissResult {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * BottomSheet — Reanimated 3 + Gesture Handler 2 implementation.
2
+ * BottomSheet — Reanimated 3 + Gesture Handler 3 implementation.
3
3
  *
4
4
  * A polished, theme-aware bottom sheet with multi-snap-point support,
5
5
  * UI-thread driven pan gestures, and native-driver spring animations.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Drawer — slide-in side drawer (left / right / top / bottom).
3
3
  *
4
- * Built on Reanimated 3 + Gesture Handler 2 — gestures and animations run on the
4
+ * Built on Reanimated 4 and Gesture Handler 3's hooks: gestures and animations run on the
5
5
  * UI thread for buttery 60/120fps motion. Mirrors the BottomSheet ergonomics:
6
6
  * imperative ref API, controlled/uncontrolled visibility, swipe-to-dismiss,
7
7
  * tap-backdrop-to-dismiss, full a11y (modal dialog).
@@ -1,5 +1,5 @@
1
1
  import type { ViewStyle } from "react-native";
2
- import { Gesture } from "react-native-gesture-handler";
2
+ import { useNativeGesture, useSimultaneousGestures } from "react-native-gesture-handler";
3
3
  import type Animated from "react-native-reanimated";
4
4
  import type { AnimatedRef } from "react-native-reanimated";
5
5
  import { useAnimatedStyle } from "react-native-reanimated";
@@ -15,8 +15,8 @@ interface UseFileViewerZoomOptions {
15
15
  }
16
16
  export type UseFileViewerZoomResult = {
17
17
  scrollRef: AnimatedRef<Animated.ScrollView>;
18
- scrollGesture: ReturnType<typeof Gesture.Native>;
19
- zoomGesture: ReturnType<typeof Gesture.Simultaneous>;
18
+ scrollGesture: ReturnType<typeof useNativeGesture>;
19
+ zoomGesture: ReturnType<typeof useSimultaneousGestures>;
20
20
  zoomStyle: ReturnType<typeof useAnimatedStyle<ViewStyle>>;
21
21
  zoomLevel: number;
22
22
  resetZoom: () => void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Swipeable — Reanimated 3 + Gesture Handler 2 implementation.
2
+ * Swipeable: Reanimated 4 and Gesture Handler 3 hook implementation.
3
3
  *
4
4
  * Wraps any content and reveals contextual actions when the user
5
5
  * swipes left or right. Past `fullSwipeThreshold`, the first action
@@ -11,7 +11,7 @@
11
11
  * there moves the sheet, whatever the content is doing;
12
12
  * - `sheetGesture` for the sheet itself: a downward drag anywhere moves the
13
13
  * sheet while `contentAtTop()` says the content cannot scroll up any
14
- * further. Pass the list's own `Gesture.Native()` as `scrollGesture` so
14
+ * further. Pass the list's own `useNativeGesture()` as `scrollGesture` so
15
15
  * the two run together: the list scrolls as usual, and once it is at its
16
16
  * top the same finger pulls the sheet down.
17
17
  *
@@ -25,12 +25,12 @@
25
25
  * `<Modal>` needs its own one inside the modal (BottomSheet does the same).
26
26
  */
27
27
  import { Animated } from "react-native";
28
- import { Gesture } from "react-native-gesture-handler";
28
+ import { type useNativeGesture, usePanGesture } from "react-native-gesture-handler";
29
29
  import type { Theme } from "../theme/types.js";
30
30
  import { type PresenceMotion } from "./usePresenceMotion.js";
31
31
  /** The gesture types as the installed gesture-handler builds them; typed off the value so a second copy of the package cannot split them. */
32
- export type SheetPanGesture = ReturnType<typeof Gesture.Pan>;
33
- export type SheetNativeGesture = ReturnType<typeof Gesture.Native>;
32
+ export type SheetPanGesture = ReturnType<typeof usePanGesture>;
33
+ export type SheetNativeGesture = ReturnType<typeof useNativeGesture>;
34
34
  /** Release beyond this many px of downward drag dismisses. */
35
35
  export declare const DRAG_DISMISS_DISTANCE = 100;
36
36
  /** Release above this downward velocity (px/ms) dismisses. */
@@ -43,7 +43,7 @@ export interface UseDragToDismissOptions {
43
43
  onDismiss: () => void;
44
44
  /** Whether the content under the finger is scrolled to its top. Default: always. */
45
45
  contentAtTop?: () => boolean;
46
- /** The scrollable content's `Gesture.Native()`, so the sheet drag runs alongside its scroll. */
46
+ /** The scrollable content's `useNativeGesture()`, so the sheet drag runs alongside its scroll. */
47
47
  scrollGesture?: SheetNativeGesture;
48
48
  }
49
49
  export interface UseDragToDismissResult {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/mobile-ui",
3
- "version": "0.148.0",
3
+ "version": "0.149.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.148.0"
118
+ "@webority/markdown-core": "0.149.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.148.0",
124
- "@webority/mobile-core": "0.148.0",
123
+ "@webority/canvas-kit": "0.149.0",
124
+ "@webority/mobile-core": "0.149.0",
125
125
  "expo": ">=58.0.0",
126
126
  "expo-file-system": ">=58.0.0",
127
127
  "expo-haptics": ">=58.0.0",
@@ -129,12 +129,12 @@
129
129
  "react": "^19.3.0",
130
130
  "react-hook-form": "^7.55.0",
131
131
  "react-native": ">=0.88.0",
132
- "react-native-gesture-handler": "^2.21.0 || ^3.0.0",
132
+ "react-native-gesture-handler": "^3.3.0",
133
133
  "react-native-keyboard-controller": ">=1.21.9",
134
134
  "react-native-reanimated": "^4.0.0",
135
135
  "react-native-safe-area-context": ">=5.4.0",
136
136
  "react-native-svg": ">=15.0.0",
137
- "react-native-worklets": ">=0.10.0"
137
+ "react-native-worklets": ">=0.13.0"
138
138
  },
139
139
  "peerDependenciesMeta": {
140
140
  "@react-navigation/bottom-tabs": {
@@ -185,10 +185,10 @@
185
185
  "@types/node": "25.6.0",
186
186
  "@types/react": "19.3.0",
187
187
  "@types/react-test-renderer": "19.3.0",
188
- "@webority/canvas-kit": "0.148.0",
189
- "@webority/mobile-core": "0.148.0",
188
+ "@webority/canvas-kit": "0.149.0",
189
+ "@webority/mobile-core": "0.149.0",
190
190
  "@webority/mobile-dev": "0.0.0",
191
- "@webority/tokens": "0.148.0",
191
+ "@webority/tokens": "0.149.0",
192
192
  "expo": "58.0.23",
193
193
  "expo-file-system": "58.0.13",
194
194
  "expo-haptics": "58.0.7",