@webority/mobile-ui 0.130.3 → 0.132.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.
- package/README.md +6 -0
- package/dist/canvas-kit/kit.js +5054 -4863
- package/dist/canvas-kit/manifest.json +39 -2
- package/dist/canvas-kit/release.json +6 -6
- package/lib/commonjs/components/AppBar/AppBar.js +1 -1
- package/lib/commonjs/components/BarChart/BarChart.js +1 -1
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/commonjs/components/ChoiceGroup/ChoiceGroup.js +1 -1
- package/lib/commonjs/components/Confetti/Confetti.js +1 -1
- package/lib/commonjs/components/Drawer/Drawer.js +1 -1
- package/lib/commonjs/components/FileViewer/FileViewer.js +1 -1
- package/lib/commonjs/components/FileViewer/useFileViewerZoom.js +1 -1
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +1 -1
- package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
- package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -1
- package/lib/commonjs/components/Screen/Screen.js +1 -1
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
- package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +1 -1
- package/lib/commonjs/components/Slider/Slider.js +1 -1
- package/lib/commonjs/components/SortableList/SortableList.js +1 -1
- package/lib/commonjs/components/Swipeable/Swipeable.js +1 -1
- package/lib/commonjs/components/TypingIndicator/TypingIndicator.js +1 -1
- package/lib/commonjs/components/WheelPicker/Wheel.js +1 -1
- package/lib/commonjs/components/ZoomableImage/ZoomableImage.js +1 -1
- package/lib/commonjs/navigation/NavigationScreen.js +1 -1
- package/lib/commonjs/network/NetworkStatusBanner.js +1 -1
- package/lib/commonjs/theme/merge.js +1 -1
- package/lib/commonjs/theme/tokens.generated.js +1 -1
- package/lib/module/components/AppBar/AppBar.js +1 -1
- package/lib/module/components/BarChart/BarChart.js +1 -1
- package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/module/components/ChoiceGroup/ChoiceGroup.js +1 -1
- package/lib/module/components/Confetti/Confetti.js +1 -1
- package/lib/module/components/Drawer/Drawer.js +1 -1
- package/lib/module/components/FileViewer/FileViewer.js +1 -1
- package/lib/module/components/FileViewer/useFileViewerZoom.js +1 -1
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/module/components/MessageList/MessageList.js +1 -1
- package/lib/module/components/OTPInput/OTPInput.js +1 -1
- package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -1
- package/lib/module/components/Screen/Screen.js +1 -1
- package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
- package/lib/module/components/SlideToConfirm/SlideToConfirm.js +1 -1
- package/lib/module/components/Slider/Slider.js +1 -1
- package/lib/module/components/SortableList/SortableList.js +1 -1
- package/lib/module/components/Swipeable/Swipeable.js +1 -1
- package/lib/module/components/TypingIndicator/TypingIndicator.js +1 -1
- package/lib/module/components/WheelPicker/Wheel.js +1 -1
- package/lib/module/components/ZoomableImage/ZoomableImage.js +1 -1
- package/lib/module/navigation/NavigationScreen.js +1 -1
- package/lib/module/network/NetworkStatusBanner.js +1 -1
- package/lib/module/theme/merge.js +1 -1
- package/lib/module/theme/tokens.generated.js +1 -1
- package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +3 -1
- package/lib/typescript/commonjs/components/ChoiceGroup/ChoiceGroup.d.ts +3 -3
- package/lib/typescript/commonjs/components/MessageList/MessageList.d.ts +1 -1
- package/lib/typescript/commonjs/components/Screen/Screen.d.ts +4 -0
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +2 -1
- package/lib/typescript/commonjs/navigation/NavigationScreen.d.ts +2 -2
- package/lib/typescript/commonjs/network/NetworkStatusBanner.d.ts +7 -2
- package/lib/typescript/commonjs/theme/tokens.generated.d.ts +1 -1
- package/lib/typescript/commonjs/theme/types.d.ts +5 -1
- package/lib/typescript/module/components/AppBar/AppBar.d.ts +3 -1
- package/lib/typescript/module/components/ChoiceGroup/ChoiceGroup.d.ts +3 -3
- package/lib/typescript/module/components/MessageList/MessageList.d.ts +1 -1
- package/lib/typescript/module/components/Screen/Screen.d.ts +4 -0
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +2 -1
- package/lib/typescript/module/navigation/NavigationScreen.d.ts +2 -2
- package/lib/typescript/module/network/NetworkStatusBanner.d.ts +7 -2
- package/lib/typescript/module/theme/tokens.generated.d.ts +1 -1
- package/lib/typescript/module/theme/types.d.ts +5 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.FloatingActionButtonGroup=exports.FloatingActionButton=exports.DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS=void 0;var cache,_mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var n,i,o=Object.defineProperty,a={__proto__:null,default:e};if(Object(e)!==e)return a;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,a)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((n=o&&Object.getOwnPropertyDescriptor(e,i))&&(n.get||n.set)?o(a,i,n):a[i]=e[i]);return a}const FAB_SIZES=["sm","md","lg"],FAB_TONES=["primary","success","warning","danger","info","neutral"],FAB_POSITIONS=["bottomRight","bottomLeft","bottomCenter"],toneBackground=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["bg-muted"];default:return e.colors.primary}},pressedTintFor=(e,t)=>"neutral"===t?e.colors["surface-pressed"]:_color.ACCENT_PRESSED_TINT,toneForeground=(e,t)=>{if("neutral"===t)return e.colors["text-body"];switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-primary"]}},FloatingActionButton=exports.FloatingActionButton=(0,_react.forwardRef)((e,t)=>{const{icon:n,onPress:i,label:o,collapsed:a=!1,size:r="md",tone:s="primary",position:c,bottomOffset:l,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:_=!1,accessibilityLabel:p,accessibilityHint:b,haptic:g,style:f,containerStyle:v,labelStyle:h,testID:x}=e;(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButton","size",e.size,FAB_SIZES),(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButton","tone",e.tone,FAB_TONES),(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButton","position",e.position,FAB_POSITIONS);const y=!u&&!d,A=(0,_index.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),w=(0,_react.useMemo)(()=>(0,_index.resolveFloatingActionButtonSize)(A,r),[A,r]),N=(0,_react.useMemo)(()=>buildStyles(A),[A]),{scale:S,opacity:I,pressIn:j,pressOut:E}=(0,_usePressAnimation.usePressAnimation)({enabled:y}),F=(0,_usePresenceMotion.usePresenceMotion)(),C=A.space[A.components["floating-action-button"]["edge-offset"]],B=A.space[A.components["floating-action-button"]["bottom-offset"]],P=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,T=F.duration("default");(0,_react.useEffect)(()=>{if(!m)return void(0,_index.setNativeValue)(P,1);const e=_reactNative.Animated.timing(P,{toValue:_?0:1,duration:T,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[m,_,P,T,A.motion.ease["in-out"]]);const O=w.diameter+(l??B)+R.bottom+C,V=P.interpolate({inputRange:[0,1],outputRange:F.range(O,0)}),L=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(P,I),[P,I]),k="string"==typeof o&&o.length>0,D=k&&a,M=F.reduced,z=A.space.sm,G=w["label-padding-x"],U=A.motion.duration.fast,q=A.motion.ease["in-out"],$=(0,_reactNativeReanimated.useSharedValue)(D?1:0),[H,W]=(0,_react.useState)(null);(0,_react.useEffect)(()=>{const e=D?1:0;return $.value=M?e:(0,_reactNativeReanimated.withTiming)(e,{duration:U,easing:_reactNativeReanimated.Easing.bezier(...q)}),()=>(0,_reactNativeReanimated.cancelAnimation)($)},[D,M,$,U,q]);const Y=(0,_react.useCallback)(e=>{const t=Math.ceil(e);W(e=>e===t?e:t)},[]),Z=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({paddingHorizontal:G*(1-$.value)})),Q=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=Math.max(0,1-2*$.value);return null===H?$.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(H+z)*(1-$.value)}}),X=u?A.colors["surface-disabled"]:toneBackground(A,s),J=u?A.colors["text-disabled"]:toneForeground(A,s),K="lg"===r?"md":"sm",ee=d?(0,_jsxRuntime.jsx)(_index2.Spinner,{variant:"circular",size:K,color:J}):(0,_slotIcon.renderSlotIcon)(n,{color:J,size:w.icon,disabled:u}),te=(0,_react.useMemo)(()=>{if(!c)return null;const e=(l??B)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:C};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:C}}},[c,l,R.bottom,B,C]);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[te,{transform:[{translateY:V},{scale:S}],opacity:L},v,f],pointerEvents:m&&_?"none":"auto",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:e=>{if(!y)return;const t=(0,_hapticUtils.resolveHaptic)(g,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),i()},onPressIn:j,onPressOut:E,disabled:!y,accessibilityRole:"button",accessibilityLabel:p,accessibilityHint:b,accessibilityState:{disabled:!y,busy:d},"aria-disabled":!y,"aria-busy":d,testID:x,style:[N.base,k?{height:w.diameter,minWidth:w.diameter,borderRadius:w.diameter/2,..._corners.smoothCorners}:{width:w.diameter,height:w.diameter,borderRadius:w.diameter/2,..._corners.smoothCorners},A.shadow.popover,{backgroundColor:X,opacity:u||d?.55:1}],children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e&&y?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[N.pressedTint,{backgroundColor:pressedTintFor(A,s),borderRadius:w.diameter/2,..._corners.smoothCorners}]}):null,k?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[N.extendedRow,Z],children:[ee,(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[N.labelClip,Q],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{onLayout:e=>Y(e.nativeEvent.layout.width),style:[N.label,{color:J,fontSize:w.text,fontWeight:A.weight.semibold,marginLeft:z},h],numberOfLines:1,children:o})})]}):ee]})})})});FloatingActionButton.displayName="FloatingActionButton";const buildStyles=e=>_reactNative.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},extendedRow:{flexDirection:"row",alignItems:"center"},labelClip:{flexDirection:"row",overflow:"hidden"},label:{includeFontPadding:!1,flexShrink:0}}),FAB_GROUP_MIN_ACTIONS=2,FAB_GROUP_MAX_ACTIONS=6,FAB_GROUP_RANGE="2 to 6",describeActionProblem=e=>e.length<2?`was given ${e.length} action(s); a menu holds 2 to 6.`:e.length>6?`was given ${e.length} actions; a menu holds 2 to 6, so only the first 6 are drawn.`:e.some(e=>"string"!=typeof e.label||""===e.label.trim())?"has an action without a visible `label`; every menu action needs one.":"",DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS=exports.DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS={quickActions:"Quick actions",expanded:(e,t)=>`${e}, expanded, ${t} ${1===t?"action":"actions"}`,collapsed:e=>`${e}, collapsed`},FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:n,actions:i,expanded:o,defaultExpanded:a=!1,onExpandedChange:r,labels:s,position:c="bottomRight",bottomOffset:l,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:_=!1,isScrolling:p=!1,containerStyle:b,secondaryActionStyle:g,labelPillStyle:f,labelStyle:v,testID:h}=e;(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButtonGroup","size",e.size,FAB_SIZES),(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const x=(0,_react.useMemo)(()=>({...DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS,...s}),[s]),y=d??x.quickActions,A=(0,_index.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),w=(0,_react.useMemo)(()=>(0,_index.resolveFloatingActionButtonSize)(A,u),[A,u]),N=(0,_react.useMemo)(()=>buildGroupStyles(A),[A]),S=(0,_usePresenceMotion.usePresenceMotion)(),I=S.duration("default"),j=A.space[A.components["floating-action-button"]["edge-offset"]],E=A.space[A.components["floating-action-button"]["bottom-offset"]],F=A.space[A.components["floating-action-button"]["secondary-gap"]],C=A.components["floating-action-button"]["stagger-ms"],B=(0,_react.useMemo)(()=>i.slice(0,6),[i]),P=B.length,T=(0,_react.useMemo)(()=>B.map((e,t)=>({action:e,index:t})).reverse(),[B]);i.forEach(e=>{(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const O=__DEV__?describeActionProblem(i):"";(0,_react.useEffect)(()=>{__DEV__&&O&&_mobileCore.Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${O}`)},[O]);const V="boolean"==typeof o,[L,k]=(0,_react.useState)(a),D=V?o:L,M=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!_)return void(0,_index.setNativeValue)(M,1);const e=_reactNative.Animated.timing(M,{toValue:p?0:1,duration:I,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[_,p,M,I,A.motion.ease["in-out"]]);const z=_&&p;(0,_react.useEffect)(()=>{z&&D&&(V||k(!1),r?.(!1))},[z,D,V,r]);const G=w.diameter+(l??E)+R.bottom+j,U=M.interpolate({inputRange:[0,1],outputRange:S.range(G,0)}),q=M,$=(0,_react.useRef)((0,_index.createAnimatedValue)(D?1:0)).current,H=(0,_react.useRef)([]),[W,Y]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{const e=H.current;if(e.length!==P){if(e.length<P){const t=e.slice();for(let n=e.length;n<P;n+=1)t.push(new _reactNative.Animated.Value(D?1:0));H.current=t}else H.current=e.slice(0,P);Y(e=>e+1)}},[P]),(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing($,{toValue:D?1:0,duration:I,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0});e.start();const t=H.current.map(e=>_reactNative.Animated.timing(e,{toValue:D?1:0,duration:I,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0})),n=D?t:[...t].reverse(),i=_reactNative.Animated.stagger(C,n);return i.start(),()=>{e.stop(),i.stop()}},[D,$,I,A.motion.ease["in-out"],P,W,C]);const Z=(0,_react.useCallback)(e=>{const t=(0,_hapticUtils.resolveHaptic)(m,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),V||k(e),r?.(e)},[V,r,m]),Q=(0,_react.useRef)(null),X=(0,_react.useRef)(D),J=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(X.current===D)return;X.current=D;const e=J.current;if(J.current=!1,z||e)return;const t=Q.current;t&&("web"===_reactNative.Platform.OS?t.focus?.():_reactNative.AccessibilityInfo.sendAccessibilityEvent(t,"focus")),(0,_announce.announce)(D?x.expanded(y,P):x.collapsed(y))},[D,z,y,P,x]);const K=(0,_react.useCallback)(()=>{Z(!D)},[D,Z]),ee=(0,_react.useCallback)(e=>{!1!==m&&(0,_hapticUtils.triggerHaptic)("selection"),J.current=!0,e.onPress(),V||k(!1),r?.(!1)},[V,r,m]),te=(0,_react.useCallback)(()=>{D&&Z(!1)},[D,Z]);(0,_react.useEffect)(()=>{if(!D)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(Z(!1),!0));return()=>e.remove()},[D,Z]),(0,_react.useEffect)(()=>{if(!D||"web"!==_reactNative.Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&Z(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[D,Z]);const ne=(0,_react.useMemo)(()=>{const e=(l??E)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:j,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:j,alignItems:"flex-end"}}},[c,l,R.bottom,E,j]),slotOffset=e=>-(w.diameter+F)*(e+1),ie=(0,_react.useMemo)(()=>{switch(c){case"bottomLeft":return{left:0,right:0,justifyContent:"flex-start"};case"bottomCenter":return{left:0,right:0,justifyContent:"center"};default:return{left:0,right:0,justifyContent:"flex-end"}}},[c]),oe=.78*w.diameter,ae=(0,_react.useMemo)(()=>{const e=oe+A.space.sm;switch(c){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:w.diameter/2+oe/2+A.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[c,oe,w.diameter,A.space.sm]),re=$.interpolate({inputRange:[0,1],outputRange:[0,.4]}),se=$.interpolate(S.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[D?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:D?"auto":"none",style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:A.colors.scrim,opacity:re}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:te,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:h?`${h}-backdrop`:void 0})}):null,(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:z?"none":"box-none",style:[ne,{transform:[{translateY:U}],opacity:q},b],accessibilityRole:"menu",testID:h,children:[T.map(({action:e,index:t})=>{const n=H.current[t];if(!n)return null;const i=n.interpolate({inputRange:[0,1],outputRange:S.range(0,slotOffset(t))}),o=n.interpolate({inputRange:[0,1],outputRange:S.range(.6,1)}),a=toneBackground(A,e.tone??"primary"),r=toneForeground(A,e.tone??"primary"),s=e.label?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[N.labelSlot,ae],testID:h?`${h}-label-${e.key}`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[N.labelPill,A.shadow.card,{backgroundColor:A.colors.surface,paddingHorizontal:A.space.sm,paddingVertical:A.space.xs,borderRadius:A.radius.sm,..._corners.smoothCorners},f],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{color:A.colors["text-body"],fontSize:A.text.sm.size,fontWeight:A.weight.medium},v],numberOfLines:1,children:e.label})})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:D?"auto":"none",accessibilityElementsHidden:!D,importantForAccessibility:D?"auto":"no-hide-descendants","aria-hidden":!D,style:[N.secondaryRow,ie,{position:"absolute",bottom:0,opacity:n,transform:[{translateY:i},{scale:o}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>ee(e),focusable:D,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[N.fabBase,A.shadow.elevated,{width:oe,height:oe,borderRadius:oe/2,..._corners.smoothCorners,backgroundColor:a},g],testID:h?`${h}-action-${e.key}`:void 0,children:({pressed:t})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[t?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[N.pressedTint,{backgroundColor:pressedTintFor(A,e.tone??"primary"),borderRadius:oe/2,..._corners.smoothCorners}]}):null,(0,_slotIcon.renderSlotIcon)(e.icon,{color:r,size:w.icon,disabled:!1})]})}),s]},e.key)}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:Q,onPress:K,accessibilityRole:"button",accessibilityLabel:y,accessibilityState:{expanded:D},"aria-expanded":D,style:[N.fabBase,A.shadow.popover,{width:w.diameter,height:w.diameter,borderRadius:w.diameter/2,..._corners.smoothCorners,backgroundColor:A.colors.primary}],testID:h?`${h}-primary`:void 0,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[N.pressedTint,{backgroundColor:_color.ACCENT_PRESSED_TINT,borderRadius:w.diameter/2,..._corners.smoothCorners}]}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:n?void 0:{transform:[{rotate:se}]},children:(0,_slotIcon.renderSlotIcon)(D&&n?n:t,{color:A.colors["on-primary"],size:w.icon,disabled:!1})})]})})]})]})};exports.FloatingActionButtonGroup=FloatingActionButtonGroup;const buildGroupStyles=e=>_reactNative.StyleSheet.create({fabBase:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},secondaryRow:{flexDirection:"row",alignItems:"center"},labelSlot:{position:"absolute",top:0,bottom:0,justifyContent:"center"},labelPill:{alignSelf:"auto"}});var _default=exports.default=FloatingActionButton;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.FloatingActionButtonGroup=exports.FloatingActionButton=exports.DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS=void 0;var cache,_mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var n,i,o=Object.defineProperty,a={__proto__:null,default:e};if(Object(e)!==e)return a;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,a)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((n=o&&Object.getOwnPropertyDescriptor(e,i))&&(n.get||n.set)?o(a,i,n):a[i]=e[i]);return a}const FAB_SIZES=["sm","md","lg"],FAB_TONES=["primary","success","warning","danger","info","neutral"],FAB_POSITIONS=["bottomRight","bottomLeft","bottomCenter"],toneBackground=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["bg-muted"];default:return e.colors.primary}},pressedTintFor=(e,t)=>"neutral"===t?e.colors["surface-pressed"]:_color.ACCENT_PRESSED_TINT,toneForeground=(e,t)=>{if("neutral"===t)return e.colors["text-body"];switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-primary"]}},FloatingActionButton=exports.FloatingActionButton=(0,_react.forwardRef)((e,t)=>{const{icon:n,onPress:i,label:o,collapsed:a=!1,size:r="md",tone:s="primary",position:c,bottomOffset:l,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:_=!1,accessibilityLabel:p,accessibilityHint:b,haptic:g,style:f,containerStyle:v,labelStyle:h,testID:x}=e;(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButton","size",e.size,FAB_SIZES),(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButton","tone",e.tone,FAB_TONES),(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButton","position",e.position,FAB_POSITIONS);const y=!u&&!d,A=(0,_index.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),w=(0,_react.useMemo)(()=>(0,_index.resolveFloatingActionButtonSize)(A,r),[A,r]),N=(0,_react.useMemo)(()=>buildStyles(A),[A]),{scale:S,opacity:I,pressIn:j,pressOut:E}=(0,_usePressAnimation.usePressAnimation)({enabled:y}),F=(0,_usePresenceMotion.usePresenceMotion)(),C=A.space[A.components["floating-action-button"]["edge-offset"]],B=A.space[A.components["floating-action-button"]["bottom-offset"]],P=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,T=F.duration("default");(0,_react.useEffect)(()=>{if(!m)return void(0,_index.setNativeValue)(P,1);const e=_reactNative.Animated.timing(P,{toValue:_?0:1,duration:T,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[m,_,P,T,A.motion.ease["in-out"]]);const O=w.diameter+(l??B)+R.bottom+C,V=P.interpolate({inputRange:[0,1],outputRange:F.range(O,0)}),L=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(P,I),[P,I]),k="string"==typeof o&&o.length>0,D=k&&a,M=F.reduced,z=A.space.sm,G=w["label-padding-x"],U=A.motion.duration.fast,q=A.motion.ease["in-out"],$=(0,_reactNativeReanimated.useSharedValue)(D?1:0),[H,W]=(0,_react.useState)(null);(0,_react.useEffect)(()=>{const e=D?1:0;return $.value=M?e:(0,_reactNativeReanimated.withTiming)(e,{duration:U,easing:_reactNativeReanimated.Easing.bezier(...q)}),()=>(0,_reactNativeReanimated.cancelAnimation)($)},[D,M,$,U,q]);const Y=(0,_react.useCallback)(e=>{const t=Math.ceil(e);W(e=>e===t?e:t)},[]),Z=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({paddingHorizontal:G*(1-$.value)}),[G,$]),Q=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=Math.max(0,1-2*$.value);return null===H?$.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(H+z)*(1-$.value)}},[$,H,z]),X=u?A.colors["surface-disabled"]:toneBackground(A,s),J=u?A.colors["text-disabled"]:toneForeground(A,s),K="lg"===r?"md":"sm",ee=d?(0,_jsxRuntime.jsx)(_index2.Spinner,{variant:"circular",size:K,color:J}):(0,_slotIcon.renderSlotIcon)(n,{color:J,size:w.icon,disabled:u}),te=(0,_react.useMemo)(()=>{if(!c)return null;const e=(l??B)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:C};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:C}}},[c,l,R.bottom,B,C]);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[te,{transform:[{translateY:V},{scale:S}],opacity:L},v,f],pointerEvents:m&&_?"none":"auto",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:e=>{if(!y)return;const t=(0,_hapticUtils.resolveHaptic)(g,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),i()},onPressIn:j,onPressOut:E,disabled:!y,accessibilityRole:"button",accessibilityLabel:p,accessibilityHint:b,accessibilityState:{disabled:!y,busy:d},"aria-disabled":!y,"aria-busy":d,testID:x,style:[N.base,k?{height:w.diameter,minWidth:w.diameter,borderRadius:w.diameter/2,..._corners.smoothCorners}:{width:w.diameter,height:w.diameter,borderRadius:w.diameter/2,..._corners.smoothCorners},A.shadow.popover,{backgroundColor:X,opacity:u||d?.55:1}],children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e&&y?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[N.pressedTint,{backgroundColor:pressedTintFor(A,s),borderRadius:w.diameter/2,..._corners.smoothCorners}]}):null,k?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[N.extendedRow,Z],children:[ee,(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[N.labelClip,Q],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{onLayout:e=>Y(e.nativeEvent.layout.width),style:[N.label,{color:J,fontSize:w.text,fontWeight:A.weight.semibold,marginLeft:z},h],numberOfLines:1,children:o})})]}):ee]})})})});FloatingActionButton.displayName="FloatingActionButton";const buildStyles=e=>_reactNative.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},extendedRow:{flexDirection:"row",alignItems:"center"},labelClip:{flexDirection:"row",overflow:"hidden"},label:{includeFontPadding:!1,flexShrink:0}}),FAB_GROUP_MIN_ACTIONS=2,FAB_GROUP_MAX_ACTIONS=6,FAB_GROUP_RANGE="2 to 6",describeActionProblem=e=>e.length<2?`was given ${e.length} action(s); a menu holds 2 to 6.`:e.length>6?`was given ${e.length} actions; a menu holds 2 to 6, so only the first 6 are drawn.`:e.some(e=>"string"!=typeof e.label||""===e.label.trim())?"has an action without a visible `label`; every menu action needs one.":"",DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS=exports.DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS={quickActions:"Quick actions",expanded:(e,t)=>`${e}, expanded, ${t} ${1===t?"action":"actions"}`,collapsed:e=>`${e}, collapsed`},FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:n,actions:i,expanded:o,defaultExpanded:a=!1,onExpandedChange:r,labels:s,position:c="bottomRight",bottomOffset:l,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:_=!1,isScrolling:p=!1,containerStyle:b,secondaryActionStyle:g,labelPillStyle:f,labelStyle:v,testID:h}=e;(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButtonGroup","size",e.size,FAB_SIZES),(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const x=(0,_react.useMemo)(()=>({...DEFAULT_FLOATING_ACTION_BUTTON_GROUP_LABELS,...s}),[s]),y=d??x.quickActions,A=(0,_index.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),w=(0,_react.useMemo)(()=>(0,_index.resolveFloatingActionButtonSize)(A,u),[A,u]),N=(0,_react.useMemo)(()=>buildGroupStyles(A),[A]),S=(0,_usePresenceMotion.usePresenceMotion)(),I=S.duration("default"),j=A.space[A.components["floating-action-button"]["edge-offset"]],E=A.space[A.components["floating-action-button"]["bottom-offset"]],F=A.space[A.components["floating-action-button"]["secondary-gap"]],C=A.components["floating-action-button"]["stagger-ms"],B=(0,_react.useMemo)(()=>i.slice(0,6),[i]),P=B.length,T=(0,_react.useMemo)(()=>B.map((e,t)=>({action:e,index:t})).reverse(),[B]);i.forEach(e=>{(0,_warnInvalidValue.warnInvalidValue)("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const O=__DEV__?describeActionProblem(i):"";(0,_react.useEffect)(()=>{__DEV__&&O&&_mobileCore.Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${O}`)},[O]);const V="boolean"==typeof o,[L,k]=(0,_react.useState)(a),D=V?o:L,M=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!_)return void(0,_index.setNativeValue)(M,1);const e=_reactNative.Animated.timing(M,{toValue:p?0:1,duration:I,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0});return e.start(),()=>e.stop()},[_,p,M,I,A.motion.ease["in-out"]]);const z=_&&p;(0,_react.useEffect)(()=>{z&&D&&(V||k(!1),r?.(!1))},[z,D,V,r]);const G=w.diameter+(l??E)+R.bottom+j,U=M.interpolate({inputRange:[0,1],outputRange:S.range(G,0)}),q=M,$=(0,_react.useRef)((0,_index.createAnimatedValue)(D?1:0)).current,H=(0,_react.useRef)([]),[W,Y]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{const e=H.current;if(e.length!==P){if(e.length<P){const t=e.slice();for(let n=e.length;n<P;n+=1)t.push(new _reactNative.Animated.Value(D?1:0));H.current=t}else H.current=e.slice(0,P);Y(e=>e+1)}},[P]),(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing($,{toValue:D?1:0,duration:I,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0});e.start();const t=H.current.map(e=>_reactNative.Animated.timing(e,{toValue:D?1:0,duration:I,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:!0})),n=D?t:[...t].reverse(),i=_reactNative.Animated.stagger(C,n);return i.start(),()=>{e.stop(),i.stop()}},[D,$,I,A.motion.ease["in-out"],P,W,C]);const Z=(0,_react.useCallback)(e=>{const t=(0,_hapticUtils.resolveHaptic)(m,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),V||k(e),r?.(e)},[V,r,m]),Q=(0,_react.useRef)(null),X=(0,_react.useRef)(D),J=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(X.current===D)return;X.current=D;const e=J.current;if(J.current=!1,z||e)return;const t=Q.current;t&&("web"===_reactNative.Platform.OS?t.focus?.():_reactNative.AccessibilityInfo.sendAccessibilityEvent(t,"focus")),(0,_announce.announce)(D?x.expanded(y,P):x.collapsed(y))},[D,z,y,P,x]);const K=(0,_react.useCallback)(()=>{Z(!D)},[D,Z]),ee=(0,_react.useCallback)(e=>{!1!==m&&(0,_hapticUtils.triggerHaptic)("selection"),J.current=!0,e.onPress(),V||k(!1),r?.(!1)},[V,r,m]),te=(0,_react.useCallback)(()=>{D&&Z(!1)},[D,Z]);(0,_react.useEffect)(()=>{if(!D)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(Z(!1),!0));return()=>e.remove()},[D,Z]),(0,_react.useEffect)(()=>{if(!D||"web"!==_reactNative.Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&Z(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[D,Z]);const ne=(0,_react.useMemo)(()=>{const e=(l??E)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:j,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:j,alignItems:"flex-end"}}},[c,l,R.bottom,E,j]),slotOffset=e=>-(w.diameter+F)*(e+1),ie=(0,_react.useMemo)(()=>{switch(c){case"bottomLeft":return{left:0,right:0,justifyContent:"flex-start"};case"bottomCenter":return{left:0,right:0,justifyContent:"center"};default:return{left:0,right:0,justifyContent:"flex-end"}}},[c]),oe=.78*w.diameter,ae=(0,_react.useMemo)(()=>{const e=oe+A.space.sm;switch(c){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:w.diameter/2+oe/2+A.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[c,oe,w.diameter,A.space.sm]),re=$.interpolate({inputRange:[0,1],outputRange:[0,.4]}),se=$.interpolate(S.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[D?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:D?"auto":"none",style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:A.colors.scrim,opacity:re}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:te,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:h?`${h}-backdrop`:void 0})}):null,(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:z?"none":"box-none",style:[ne,{transform:[{translateY:U}],opacity:q},b],accessibilityRole:"menu",testID:h,children:[T.map(({action:e,index:t})=>{const n=H.current[t];if(!n)return null;const i=n.interpolate({inputRange:[0,1],outputRange:S.range(0,slotOffset(t))}),o=n.interpolate({inputRange:[0,1],outputRange:S.range(.6,1)}),a=toneBackground(A,e.tone??"primary"),r=toneForeground(A,e.tone??"primary"),s=e.label?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[N.labelSlot,ae],testID:h?`${h}-label-${e.key}`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[N.labelPill,A.shadow.card,{backgroundColor:A.colors.surface,paddingHorizontal:A.space.sm,paddingVertical:A.space.xs,borderRadius:A.radius.sm,..._corners.smoothCorners},f],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[{color:A.colors["text-body"],fontSize:A.text.sm.size,fontWeight:A.weight.medium},v],numberOfLines:1,children:e.label})})}):null;return(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:D?"auto":"none",accessibilityElementsHidden:!D,importantForAccessibility:D?"auto":"no-hide-descendants","aria-hidden":!D,style:[N.secondaryRow,ie,{position:"absolute",bottom:0,opacity:n,transform:[{translateY:i},{scale:o}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>ee(e),focusable:D,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[N.fabBase,A.shadow.elevated,{width:oe,height:oe,borderRadius:oe/2,..._corners.smoothCorners,backgroundColor:a},g],testID:h?`${h}-action-${e.key}`:void 0,children:({pressed:t})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[t?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[N.pressedTint,{backgroundColor:pressedTintFor(A,e.tone??"primary"),borderRadius:oe/2,..._corners.smoothCorners}]}):null,(0,_slotIcon.renderSlotIcon)(e.icon,{color:r,size:w.icon,disabled:!1})]})}),s]},e.key)}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:Q,onPress:K,accessibilityRole:"button",accessibilityLabel:y,accessibilityState:{expanded:D},"aria-expanded":D,style:[N.fabBase,A.shadow.popover,{width:w.diameter,height:w.diameter,borderRadius:w.diameter/2,..._corners.smoothCorners,backgroundColor:A.colors.primary}],testID:h?`${h}-primary`:void 0,children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[N.pressedTint,{backgroundColor:_color.ACCENT_PRESSED_TINT,borderRadius:w.diameter/2,..._corners.smoothCorners}]}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:n?void 0:{transform:[{rotate:se}]},children:(0,_slotIcon.renderSlotIcon)(D&&n?n:t,{color:A.colors["on-primary"],size:w.icon,disabled:!1})})]})})]})]})};exports.FloatingActionButtonGroup=FloatingActionButtonGroup;const buildGroupStyles=e=>_reactNative.StyleSheet.create({fabBase:{flexDirection:"row",alignItems:"center",justifyContent:"center",overflow:"hidden"},pressedTint:{position:"absolute",top:0,right:0,bottom:0,left:0},secondaryRow:{flexDirection:"row",alignItems:"center"},labelSlot:{position:"absolute",top:0,bottom:0,justifyContent:"center"},labelPill:{alignSelf:"auto"}});var _default=exports.default=FloatingActionButton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ImageGallery=exports.DEFAULT_IMAGE_GALLERY_LABELS=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index3=require("../Carousel/index.js"),_Modal=require("../Modal/Modal.js"),_index4=require("../Skeleton/index.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,i,l=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((t=l&&Object.getOwnPropertyDescriptor(e,i))&&(t.get||t.set)?l(r,i,t):r[i]=e[i]);return r}const DEFAULT_IMAGE_GALLERY_LABELS=exports.DEFAULT_IMAGE_GALLERY_LABELS={gallery:"Image gallery",imageOf:(e,a)=>`Image ${e} of ${a}`,openFullscreen:"Tap to open fullscreen",closeGallery:"Close gallery"},MAX_SCALE_FALLBACK=4,MIN_SCALE_FALLBACK=1,DOUBLE_TAP_SCALE_FALLBACK=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ImageGallery=({images:e,initialIndex:a=0,showThumbnails:t=!0,showCounter:i=!0,enableLightbox:l=!0,enablePinchZoom:r=!0,onIndexChange:n,haptic:s,loading:o=!1,accessibilityLabel:c,containerStyle:u,testID:d,labels:m})=>{const _=(0,_index.useTheme)(),h=(0,_react.useMemo)(()=>buildStyles(_),[_]),g=(0,_react.useMemo)(()=>({...DEFAULT_IMAGE_GALLERY_LABELS,...m}),[m]),[x,v]=(0,_react.useState)(clamp(a,0,Math.max(0,e.length-1))),[p,b]=(0,_react.useState)(!1),R=(0,_react.useCallback)(e=>{v(e),n?.(e)},[n]),S=(0,_react.useCallback)(()=>{if(!l)return;const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),b(!0)},[l,s]),y=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),b(!1)},[s]),I=(0,_react.useCallback)((a,t)=>{const i=a.alt??g.imageOf(t+1,e.length);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:S,accessibilityRole:"image",accessibilityLabel:i,accessibilityHint:l?g.openFullscreen:void 0,style:h.imageWrap,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:a.source,style:h.image,resizeMode:"cover"})})},[l,e.length,S,h,g]),N=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNative.Image,{source:e.source,style:h.thumbnailImage,resizeMode:"cover"}),[h]),j=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[h.container,u],testID:d,accessibilityLabel:c??g.gallery,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:h.carouselWrap,accessibilityElementsHidden:p,importantForAccessibility:p?"no-hide-descendants":"auto",children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{data:e,defaultIndex:a,onIndexChange:R,renderItem:I,showPagination:!1,showThumbnails:t,renderThumbnail:N,haptic:s}),i&&e.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:h.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:"semibold",style:{color:_.colors["on-scrim"]},accessibilityLabel:g.imageOf(x+1,e.length),children:`${x+1} / ${e.length}`})}):null]}),l?(0,_jsxRuntime.jsx)(Lightbox,{open:p,images:e,initialIndex:x,enablePinchZoom:r,showCounter:i,onClose:y,onIndexChange:R,haptic:s,labels:g}):null]});return o?(0,_jsxRuntime.jsx)(ImageGallerySkeleton,{images:e,showThumbnails:t,showCounter:i,containerStyle:u,testID:d}):j};exports.ImageGallery=ImageGallery,ImageGallery.displayName="ImageGallery";const ImageGallerySkeleton=({images:e,showThumbnails:a=!0,showCounter:t=!0,containerStyle:i,testID:l})=>{const r=(0,_index.useTheme)(),n=Math.min(e?.length||4,6);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{width:"100%"},i],testID:l,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{position:"relative"},children:[(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:"100%",height:280,radius:"lg"}),t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",top:12,right:12},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:44,height:22,radius:"pill"})}):null]}),a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:r.space.md},children:Array.from({length:n}).map((e,a)=>(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:64,height:64,radius:"md",style:{marginRight:r.space.sm}},`sk-thumb-${a}`))}):null]})};ImageGallerySkeleton.displayName="ImageGallerySkeleton",ImageGallery.Skeleton=ImageGallerySkeleton;const Lightbox=({open:e,images:a,initialIndex:t,enablePinchZoom:i,showCounter:l,onClose:r,onIndexChange:n,haptic:s,labels:o})=>{const c=(0,_index.useTheme)(),u=(0,_react.useMemo)(()=>buildLightboxStyles(c),[c]),d=(0,_react.useRef)(null),[m,_]=(0,_react.useState)(t),h=(0,_react.useCallback)(e=>{if(e!==m){const a=(0,_index2.resolveHaptic)(s,"selection");a&&(0,_index2.triggerHaptic)(a),_(e),n(e)}},[m,n,s]),g=(0,_react.useCallback)((e,t)=>(0,_jsxRuntime.jsx)(ZoomableImage,{image:e,index:t,total:a.length,active:t===m,enabled:i,maxScale:4,minScale:1,doubleTapScale:2,haptic:s,imageLabel:o.imageOf}),[m,i,a.length,s,o]),x=a[m]?.caption;return(0,_jsxRuntime.jsx)(_Modal.Modal,{open:e,onClose:r,presentation:"fullScreen",backdropPressClose:!1,animateMount:!1,contentStyle:{backgroundColor:"transparent"},children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:u.backdrop,children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{ref:d,data:a,defaultIndex:t,onIndexChange:h,renderItem:g,showPagination:!1,haptic:s}),l&&a.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:"semibold",style:{color:c.colors["on-scrim"]},accessibilityLabel:o.imageOf(m+1,a.length),children:`${m+1} / ${a.length}`})}):null,(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:o.closeGallery,style:u.closeButton,hitSlop:12,...(0,_hitSlop.hitSlopMarker)(12),children:(c.settings.icons.close??_defaultIcons.defaultIcons.close)({size:24,color:c.colors["on-scrim"]})}),x?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:u.captionWrap,entering:void 0,accessibilityElementsHidden:!1,children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",align:"center",numberOfLines:3,style:u.captionText,children:x})}):null]})})},ZoomableImage=({image:e,index:a,total:t,active:i,enabled:l,maxScale:r,minScale:n,doubleTapScale:s,haptic:o,imageLabel:c})=>{const u=_reactNative.Dimensions.get("window"),d=(0,_reactNativeReanimated.useSharedValue)(1),m=(0,_reactNativeReanimated.useSharedValue)(1),_=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),g=(0,_reactNativeReanimated.useSharedValue)(0),x=(0,_reactNativeReanimated.useSharedValue)(0),v=(0,_react.useCallback)(()=>{d.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),m.value=1,_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),g.value=0,x.value=0},[d,m,_,h,g,x]);_react.default.useEffect(()=>{i||(d.value=(0,_reactNativeReanimated.withTiming)(1,{duration:150}),_.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),h.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),m.value=1,g.value=0,x.value=0)},[i,d,_,h,m,g,x]);const p=(0,_react.useCallback)(()=>{!1!==o&&(0,_index2.triggerHaptic)("impactLight")},[o]),b=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pinch().enabled(l).onStart(()=>{"worklet";m.value=d.value}).onUpdate(e=>{"worklet";const a=m.value*e.scale;d.value=a<n?n+.3*(a-n):a>r?r+.2*(a-r):a}).onEnd(()=>{"worklet";return d.value<n?(d.value=(0,_reactNativeReanimated.withSpring)(n,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),m.value=n,g.value=0,void(x.value=0)):d.value>r?(d.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(m.value=r)):void(m.value=d.value)}),[l,d,m,_,h,g,x,n,r]),R=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pan().minPointers(1).maxPointers(1).onStart(()=>{"worklet";g.value=_.value,x.value=h.value}).onUpdate(e=>{"worklet";d.value<=1||(_.value=g.value+e.translationX,h.value=x.value+e.translationY)}).onEnd(()=>{"worklet";g.value=_.value,x.value=h.value}),[d,_,h,g,x]),S=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().numberOfTaps(2).onEnd(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(p)(),d.value>1?(d.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),m.value=1,g.value=0,x.value=0):(d.value=(0,_reactNativeReanimated.withSpring)(s,SPRING_CONFIG),m.value=s)}),[d,m,_,h,g,x,p,s]),y=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Race(b,R,S),[b,R,S]),I=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:_.value},{translateY:h.value},{scale:d.value}]}));_react.default.useEffect(()=>{i||v()},[i,v]);const N=e.alt??c(a+1,t);return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:y,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[lightboxImageStyles.container,{width:u.width}],children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.Image,{source:e.source,resizeMode:"contain",style:[lightboxImageStyles.image,I],accessibilityLabel:N,accessible:!0})})})},clamp=(e,a,t)=>Math.min(Math.max(e,a),t),buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},carouselWrap:{width:"100%",position:"relative"},imageWrap:{width:"100%",aspectRatio:16/9,backgroundColor:e.colors["bg-subtle"],overflow:"hidden",borderRadius:e.radius.md,..._corners.smoothCorners},image:{width:"100%",height:"100%"},thumbnailImage:{width:"100%",height:"100%"},counterPill:{position:"absolute",top:12,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.55)"}}),buildLightboxStyles=e=>_reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:"#000",justifyContent:"center"},counterPill:{position:"absolute",top:48,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.6)"},closeButton:{position:"absolute",top:44,right:16,width:40,height:40,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)"},captionWrap:{position:"absolute",left:0,right:0,bottom:32,paddingHorizontal:e.space.xl},captionText:{color:e.colors["on-scrim"],lineHeight:21}}),lightboxImageStyles=_reactNative.StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"}});var _default=exports.default=ImageGallery;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ImageGallery=exports.DEFAULT_IMAGE_GALLERY_LABELS=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index3=require("../Carousel/index.js"),_Modal=require("../Modal/Modal.js"),_index4=require("../Skeleton/index.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,i,l=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((t=l&&Object.getOwnPropertyDescriptor(e,i))&&(t.get||t.set)?l(r,i,t):r[i]=e[i]);return r}const DEFAULT_IMAGE_GALLERY_LABELS=exports.DEFAULT_IMAGE_GALLERY_LABELS={gallery:"Image gallery",imageOf:(e,a)=>`Image ${e} of ${a}`,openFullscreen:"Tap to open fullscreen",closeGallery:"Close gallery"},MAX_SCALE_FALLBACK=4,MIN_SCALE_FALLBACK=1,DOUBLE_TAP_SCALE_FALLBACK=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ImageGallery=({images:e,initialIndex:a=0,showThumbnails:t=!0,showCounter:i=!0,enableLightbox:l=!0,enablePinchZoom:r=!0,onIndexChange:n,haptic:s,loading:o=!1,accessibilityLabel:c,containerStyle:u,testID:d,labels:m})=>{const _=(0,_index.useTheme)(),h=(0,_react.useMemo)(()=>buildStyles(_),[_]),g=(0,_react.useMemo)(()=>({...DEFAULT_IMAGE_GALLERY_LABELS,...m}),[m]),[x,v]=(0,_react.useState)(clamp(a,0,Math.max(0,e.length-1))),[p,b]=(0,_react.useState)(!1),R=(0,_react.useCallback)(e=>{v(e),n?.(e)},[n]),S=(0,_react.useCallback)(()=>{if(!l)return;const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),b(!0)},[l,s]),y=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(s,"selection");e&&(0,_index2.triggerHaptic)(e),b(!1)},[s]),I=(0,_react.useCallback)((a,t)=>{const i=a.alt??g.imageOf(t+1,e.length);return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:S,accessibilityRole:"image",accessibilityLabel:i,accessibilityHint:l?g.openFullscreen:void 0,style:h.imageWrap,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:a.source,style:h.image,resizeMode:"cover"})})},[l,e.length,S,h,g]),N=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNative.Image,{source:e.source,style:h.thumbnailImage,resizeMode:"cover"}),[h]),j=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[h.container,u],testID:d,accessibilityLabel:c??g.gallery,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:h.carouselWrap,accessibilityElementsHidden:p,importantForAccessibility:p?"no-hide-descendants":"auto",children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{data:e,defaultIndex:a,onIndexChange:R,renderItem:I,showPagination:!1,showThumbnails:t,renderThumbnail:N,haptic:s}),i&&e.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:h.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:"semibold",style:{color:_.colors["on-scrim"]},accessibilityLabel:g.imageOf(x+1,e.length),children:`${x+1} / ${e.length}`})}):null]}),l?(0,_jsxRuntime.jsx)(Lightbox,{open:p,images:e,initialIndex:x,enablePinchZoom:r,showCounter:i,onClose:y,onIndexChange:R,haptic:s,labels:g}):null]});return o?(0,_jsxRuntime.jsx)(ImageGallerySkeleton,{images:e,showThumbnails:t,showCounter:i,containerStyle:u,testID:d}):j};exports.ImageGallery=ImageGallery,ImageGallery.displayName="ImageGallery";const ImageGallerySkeleton=({images:e,showThumbnails:a=!0,showCounter:t=!0,containerStyle:i,testID:l})=>{const r=(0,_index.useTheme)(),n=Math.min(e?.length||4,6);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{width:"100%"},i],testID:l,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{position:"relative"},children:[(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:"100%",height:280,radius:"lg"}),t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",top:12,right:12},children:(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:44,height:22,radius:"pill"})}):null]}),a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:r.space.md},children:Array.from({length:n}).map((e,a)=>(0,_jsxRuntime.jsx)(_index4.Skeleton,{width:64,height:64,radius:"md",style:{marginRight:r.space.sm}},`sk-thumb-${a}`))}):null]})};ImageGallerySkeleton.displayName="ImageGallerySkeleton",ImageGallery.Skeleton=ImageGallerySkeleton;const Lightbox=({open:e,images:a,initialIndex:t,enablePinchZoom:i,showCounter:l,onClose:r,onIndexChange:n,haptic:s,labels:o})=>{const c=(0,_index.useTheme)(),u=(0,_react.useMemo)(()=>buildLightboxStyles(c),[c]),d=(0,_react.useRef)(null),[m,_]=(0,_react.useState)(t),h=(0,_react.useCallback)(e=>{if(e!==m){const a=(0,_index2.resolveHaptic)(s,"selection");a&&(0,_index2.triggerHaptic)(a),_(e),n(e)}},[m,n,s]),g=(0,_react.useCallback)((e,t)=>(0,_jsxRuntime.jsx)(ZoomableImage,{image:e,index:t,total:a.length,active:t===m,enabled:i,maxScale:4,minScale:1,doubleTapScale:2,haptic:s,imageLabel:o.imageOf}),[m,i,a.length,s,o]),x=a[m]?.caption;return(0,_jsxRuntime.jsx)(_Modal.Modal,{open:e,onClose:r,presentation:"fullScreen",backdropPressClose:!1,animateMount:!1,contentStyle:{backgroundColor:"transparent"},children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:u.backdrop,children:[(0,_jsxRuntime.jsx)(_index3.Carousel,{ref:d,data:a,defaultIndex:t,onIndexChange:h,renderItem:g,showPagination:!1,haptic:s}),l&&a.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:u.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:"semibold",style:{color:c.colors["on-scrim"]},accessibilityLabel:o.imageOf(m+1,a.length),children:`${m+1} / ${a.length}`})}):null,(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:o.closeGallery,style:u.closeButton,hitSlop:12,...(0,_hitSlop.hitSlopMarker)(12),children:(c.settings.icons.close??_defaultIcons.defaultIcons.close)({size:24,color:c.colors["on-scrim"]})}),x?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:u.captionWrap,entering:void 0,accessibilityElementsHidden:!1,children:(0,_jsxRuntime.jsx)(_index5.Text,{variant:"body",align:"center",numberOfLines:3,style:u.captionText,children:x})}):null]})})},ZoomableImage=({image:e,index:a,total:t,active:i,enabled:l,maxScale:r,minScale:n,doubleTapScale:s,haptic:o,imageLabel:c})=>{const u=_reactNative.Dimensions.get("window"),d=(0,_reactNativeReanimated.useSharedValue)(1),m=(0,_reactNativeReanimated.useSharedValue)(1),_=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),g=(0,_reactNativeReanimated.useSharedValue)(0),x=(0,_reactNativeReanimated.useSharedValue)(0),v=(0,_react.useCallback)(()=>{d.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),m.value=1,_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),g.value=0,x.value=0},[d,m,_,h,g,x]);_react.default.useEffect(()=>{i||(d.value=(0,_reactNativeReanimated.withTiming)(1,{duration:150}),_.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),h.value=(0,_reactNativeReanimated.withTiming)(0,{duration:150}),m.value=1,g.value=0,x.value=0)},[i,d,_,h,m,g,x]);const p=(0,_react.useCallback)(()=>{!1!==o&&(0,_index2.triggerHaptic)("impactLight")},[o]),b=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pinch().enabled(l).onStart(()=>{"worklet";m.value=d.value}).onUpdate(e=>{"worklet";const a=m.value*e.scale;d.value=a<n?n+.3*(a-n):a>r?r+.2*(a-r):a}).onEnd(()=>{"worklet";return d.value<n?(d.value=(0,_reactNativeReanimated.withSpring)(n,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),m.value=n,g.value=0,void(x.value=0)):d.value>r?(d.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(m.value=r)):void(m.value=d.value)}),[l,d,m,_,h,g,x,n,r]),R=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Pan().minPointers(1).maxPointers(1).onStart(()=>{"worklet";g.value=_.value,x.value=h.value}).onUpdate(e=>{"worklet";d.value<=1||(_.value=g.value+e.translationX,h.value=x.value+e.translationY)}).onEnd(()=>{"worklet";g.value=_.value,x.value=h.value}),[d,_,h,g,x]),S=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().numberOfTaps(2).onEnd(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(p)(),d.value>1?(d.value=(0,_reactNativeReanimated.withSpring)(1,SPRING_CONFIG),_.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),h.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),m.value=1,g.value=0,x.value=0):(d.value=(0,_reactNativeReanimated.withSpring)(s,SPRING_CONFIG),m.value=s)}),[d,m,_,h,g,x,p,s]),y=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Race(b,R,S),[b,R,S]),I=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:_.value},{translateY:h.value},{scale:d.value}]}),[_,h,d]);_react.default.useEffect(()=>{i||v()},[i,v]);const N=e.alt??c(a+1,t);return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:y,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[lightboxImageStyles.container,{width:u.width}],children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.Image,{source:e.source,resizeMode:"contain",style:[lightboxImageStyles.image,I],accessibilityLabel:N,accessible:!0})})})},clamp=(e,a,t)=>Math.min(Math.max(e,a),t),buildStyles=e=>_reactNative.StyleSheet.create({container:{width:"100%"},carouselWrap:{width:"100%",position:"relative"},imageWrap:{width:"100%",aspectRatio:16/9,backgroundColor:e.colors["bg-subtle"],overflow:"hidden",borderRadius:e.radius.md,..._corners.smoothCorners},image:{width:"100%",height:"100%"},thumbnailImage:{width:"100%",height:"100%"},counterPill:{position:"absolute",top:12,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.55)"}}),buildLightboxStyles=e=>_reactNative.StyleSheet.create({backdrop:{flex:1,backgroundColor:"#000",justifyContent:"center"},counterPill:{position:"absolute",top:48,alignSelf:"center",paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:"rgba(0,0,0,0.6)"},closeButton:{position:"absolute",top:44,right:16,width:40,height:40,borderRadius:e.radius.pill,..._corners.smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.5)"},captionWrap:{position:"absolute",left:0,right:0,bottom:32,paddingHorizontal:e.space.xl},captionText:{color:e.colors["on-scrim"],lineHeight:21}}),lightboxImageStyles=_reactNative.StyleSheet.create({container:{flex:1,alignItems:"center",justifyContent:"center"},image:{width:"100%",height:"100%"}});var _default=exports.default=ImageGallery;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_MESSAGE_LIST_LABELS=void 0,exports.MessageList=MessageList,exports.default=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_index2=require("../Badge/index.js"),_index3=require("../DateSeparator/index.js"),_index4=require("../IconButton/index.js"),_index5=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_MESSAGE_LIST_LABELS=exports.DEFAULT_MESSAGE_LIST_LABELS=Object.freeze({today:"Today",yesterday:"Yesterday",jumpToLatest:"Jump to the latest message",newMessages:e=>1===e?"1 new message":`${e} new messages`,unread:"New messages",loadingOlder:"Loading earlier messages"}),JUMP_AT=160,KEEP_POSITION={minIndexForVisible:0,autoscrollToTopThreshold:JUMP_AT},positionOf=(e,t)=>e?t?"middle":"last":t?"first":"single";function MessageList({messages:e,keyExtractor:t,renderMessage:n,getAuthorKey:r,getDate:s,firstUnreadKey:a,onLoadOlder:o,loadingOlder:i=!1,hasOlder:l=!0,typing:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_MESSAGE_LIST_LABELS=void 0,exports.MessageList=MessageList,exports.default=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_index2=require("../Badge/index.js"),_index3=require("../DateSeparator/index.js"),_index4=require("../IconButton/index.js"),_index5=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_MESSAGE_LIST_LABELS=exports.DEFAULT_MESSAGE_LIST_LABELS=Object.freeze({today:"Today",yesterday:"Yesterday",jumpToLatest:"Jump to the latest message",newMessages:e=>1===e?"1 new message":`${e} new messages`,unread:"New messages",loadingOlder:"Loading earlier messages"}),JUMP_AT=160,FOLLOW_AT=48,KEEP_POSITION={minIndexForVisible:0,autoscrollToTopThreshold:JUMP_AT},positionOf=(e,t)=>e?t?"middle":"last":t?"first":"single";function MessageList({messages:e,keyExtractor:t,renderMessage:n,getAuthorKey:r,getDate:s,firstUnreadKey:a,onLoadOlder:o,loadingOlder:i=!1,hasOlder:l=!0,typing:c,empty:u,getAnnouncement:d,followNew:_,keyboardAware:m=!0,keyboardOffset:x,labels:p,now:f,onScroll:j,onContentSizeChange:y,contentContainerStyle:g,style:b,testID:S,...v}){const L=(0,_index.useTheme)(),h=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),E=(0,_useReducedMotion.useReducedMotion)(),C=(0,_react.useMemo)(()=>buildStyles(L),[L]),R=(0,_react.useMemo)(()=>({...DEFAULT_MESSAGE_LIST_LABELS,...p}),[p]),T=x??h.bottom,w=(0,_react.useRef)(null),A=(0,_react.useRef)(!1),M=(0,_react.useRef)(!0),O=(0,_react.useRef)(0),[I,N]=(0,_react.useState)(!1),[k,q]=(0,_react.useState)(0),D=(0,_react.useMemo)(()=>{const n=s?e.map(e=>(0,_mobileCore.formatDate)(s(e))):null,o=r?e.map(r):null,i=void 0===a?-1:e.findIndex(e=>t(e)===a);return e.map((t,r)=>{const a=r===e.length-1,l=null!==n&&(a||n[r]!==n[r+1]),c=null!==o&&!a&&o[r+1]===o[r]&&!l&&r!==i,u=null!==o&&r>0&&o[r-1]===o[r]&&(null===n||n[r-1]===n[r])&&r-1!==i;return{groupPosition:positionOf(c,u),day:l&&s?(0,_index3.dayLabel)(s(t),{now:f,labels:R}):null,unread:r===i}})},[e,s,r,a,t,f,R]),P=(0,_react.useCallback)(()=>{M.current=!0,w.current?.scrollToOffset({offset:0,animated:!E}),q(0)},[E]),V=e.length>0?t(e[0]):null,F=(0,_react.useRef)(V);(0,_react.useEffect)(()=>{const n=F.current;if(F.current=V,null===n||null===V||n===V)return;const r=e.findIndex(e=>t(e)===n);if(-1===r)return void q(0);const s=e.slice(0,r).reverse();for(const e of s){const t=d?.(e);t&&(0,_announce.announce)(t)}_&&s.some(_)?P():A.current&&q(e=>e+s.length)},[V]);const B=(0,_react.useCallback)(e=>{M.current=e.nativeEvent.contentOffset.y<=FOLLOW_AT;const t=e.nativeEvent.contentOffset.y>JUMP_AT;t!==A.current&&(A.current=t,N(t),t||q(0)),j?.(e)},[j]),U=(0,_react.useCallback)((e,t)=>{const n=t>O.current;O.current=t,n&&M.current&&w.current?.scrollToOffset({offset:0,animated:!1}),y?.(e,t)},[y]),K=(0,_react.useCallback)(()=>{l&&!i&&o?.()},[l,i,o]),z=(0,_react.useCallback)(({item:e,index:t})=>{const r=D[t];return(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[r?.day?(0,_jsxRuntime.jsx)(_index3.DateSeparator,{label:r.day}):null,r?.unread?(0,_jsxRuntime.jsx)(_index3.DateSeparator,{label:R.unread,emphasis:!0}):null,n({item:e,index:t,groupPosition:r?.groupPosition??"single"})]})},[D,R.unread,n]),G=(0,_react.useCallback)(e=>t(e),[t]),J=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardChatScrollView,{...e,inverted:!0,offset:T}),[T]),$=k>0?`${R.newMessages(k)}. ${R.jumpToLatest}`:R.jumpToLatest;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[C.root,b],children:[(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",maintainVisibleContentPosition:KEEP_POSITION,...v,ref:w,data:e,renderItem:z,keyExtractor:G,inverted:!0,onScroll:B,onContentSizeChange:U,onEndReached:o?K:void 0,ListHeaderComponent:c?(0,_jsxRuntime.jsx)(_reactNative.View,{children:c}):null,ListFooterComponent:i?(0,_jsxRuntime.jsx)(_index5.Spinner,{size:"sm",accessibilityLabel:R.loadingOlder,style:C.older}):null,ListEmptyComponent:u?(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.fill,children:u}):null,renderScrollComponent:m?J:void 0,contentContainerStyle:[C.content,0===e.length?C.grow:null,g],testID:S}),I?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:C.jump,pointerEvents:"box-none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.jumpDisc,children:(0,_jsxRuntime.jsx)(_index4.IconButton,{icon:"arrow-down",accessibilityLabel:$,variant:"ghost",tone:"neutral",onPress:P,testID:S?`${S}-jump`:void 0})}),k>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:C.count,pointerEvents:"none",importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,children:(0,_jsxRuntime.jsx)(_index2.Badge,{value:k,max:99,tone:"primary",size:"sm"})}):null]}):null]})}const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1},content:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm},grow:{flexGrow:1},fill:{flex:1},older:{paddingVertical:e.space.md},jump:{position:"absolute",right:e.space.md,bottom:e.space.md},jumpDisc:{borderRadius:e.radius.pill,..._corners.smoothCorners,backgroundColor:e.colors.surface,...e.shadow.elevated},count:{position:"absolute",top:-e.space.xs,right:-e.space.xs}});var _default=exports.default=MessageList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OTPInput=exports.DEFAULT_OTP_INPUT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_OTP_INPUT_LABELS=exports.DEFAULT_OTP_INPUT_LABELS=Object.freeze({field:e=>`Enter ${e}-digit code`}),sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=exports.OTPInput=(0,_react.forwardRef)((e,t)=>{const{value:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.OTPInput=exports.DEFAULT_OTP_INPUT_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_FieldBase=require("../FieldBase/FieldBase.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_OTP_INPUT_LABELS=exports.DEFAULT_OTP_INPUT_LABELS=Object.freeze({field:e=>`Enter ${e}-digit code`}),sanitizeChar=(e,t)=>e?"number-pad"===t?e.replace(/\D/g,""):e:"",OTPInput=exports.OTPInput=(0,_react.forwardRef)((e,t)=>{const{value:a,defaultValue:i,onChange:n,onComplete:r,length:s=6,keyboardType:l="number-pad",autoFocus:o=!1,autoFocusDelay:c=0,disabled:u=!1,error:d,size:_="md",secure:p=!1,haptic:m,labels:x,onFocus:g,accessibilityLabel:f,style:h,cellStyle:v,textStyle:b,testID:y}=e;(0,_warnInvalidValue.warnInvalidValue)("OTPInput","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("OTPInput","keyboardType",e.keyboardType,["number-pad","default"]);const T=x?{...DEFAULT_OTP_INPUT_LABELS,...x}:DEFAULT_OTP_INPUT_LABELS,[j,N]=(0,_index.useControllableState)({value:a,defaultValue:i??"",onChange:n}),I=(0,_index2.useTheme)(),E=(0,_react.useMemo)(()=>buildStyles(I),[I]),A=(0,_index2.resolveOtpInputSize)(I,_),w=I.components["otp-input"][_].radius,V=(0,_react.useRef)([]),[F,P]=(0,_react.useState)(-1),[R,C]=(0,_react.useState)(0),O=(0,_react.useRef)(null),k=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,S=(0,_react.useRef)(new Map),L=(0,_react.useMemo)(()=>{const e=S.current,t=[];for(let a=0;a<s;a+=1){let i=e.get(a);i||(i=new _reactNative.Animated.Value(0),e.set(a,i)),t.push(i)}for(const t of Array.from(e.keys()))t>=s&&e.delete(t);return t},[s]),B=(0,_react.useRef)(-1),D=I.settings.components["otp-input"]?.shakeOnError??!1,z=(0,_index.useReducedMotion)(),M=!0===d||(0,_FieldBase.hasFieldText)(d);(0,_react.useEffect)(()=>{let e;return null===O.current||!M||O.current||(m&&(0,_index3.triggerHaptic)("notificationError"),D&&!z&&((0,_index2.setNativeValue)(k,0),e=_reactNative.Animated.sequence([_reactNative.Animated.timing(k,{toValue:1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(k,{toValue:-1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(k,{toValue:1,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0}),_reactNative.Animated.timing(k,{toValue:0,duration:I.motion.duration.instant,easing:_reactNative.Easing.linear,useNativeDriver:!0})]),e.start())),O.current=M,()=>e?.stop()},[M,k,D,m,z,I.motion.duration.instant]),(0,_react.useEffect)(()=>{const e=B.current;if(B.current=F,e===F)return;if(-1===e&&-1===F)return;const t=[];return L.forEach((a,i)=>{const n=i===F?1:0;if(i!==F&&i!==e)return;const r=_reactNative.Animated.timing(a,{toValue:n,duration:I.motion.duration.fast,easing:_reactNative.Easing.bezier(...I.motion.ease["in-out"]),useNativeDriver:!0});r.start(),t.push(r)}),()=>t.forEach(e=>{e.stop()})},[F,L,I]);const q=(0,_react.useCallback)(e=>{const t=V.current[e];t&&t.focus()},[]);(0,_react.useImperativeHandle)(t,()=>({focus:()=>q(0),blur:()=>{const e=V.current[F>=0?F:0];e?.blur()},clear:()=>{N(""),q(0)}}),[q,F,N]),(0,_react.useEffect)(()=>{if(o&&!u){const e=setTimeout(()=>q(0),c);return()=>clearTimeout(e)}},[o,c,u,q]);const U=(0,_react.useMemo)(()=>{const e=new Array(s).fill("");for(let t=0;t<Math.min(j.length,s);t+=1)e[t]=j[t]??"";return e},[j,s]),H=(0,_react.useCallback)(e=>{const t=e.slice(0,s);t!==j&&(N(t),t.length===s&&r&&r(t))},[s,N,r,j]),W=(0,_react.useCallback)((e,t)=>{const a=t.replace(/\u200B/g,""),i=sanitizeChar(a,l);if(!i){const t=U.slice(),a=(t[e]??"").length>0;if(t[e]="",H(t.join("").slice(0,s)),!a&&e>0){const t=U.slice();t[e-1]="",H(t.join("")),q(e-1)}return}const n=U[e]??"",r=n&&i.length>s&&i.startsWith(n)?i.slice(n.length):i;if(r.length>=s){const t=r.slice(0,s),a=j.length;return H(t),t.length!==a&&m&&(0,_index3.triggerHaptic)(m),void V.current[e]?.blur()}const o=U.slice();let c=e;for(let e=0;e<i.length&&c<s;e+=1)o[c]=i[e]??"",c+=1;const u=o.join("").slice(0,s),d=j.length;H(u),u.length!==d&&m&&(0,_index3.triggerHaptic)(m);const _=Math.min(c,s-1);c>=s?V.current[e]?.blur():q(_)},[U,q,l,s,m,H,j]),$=(0,_react.useCallback)((e,t)=>{if("Backspace"!==t.nativeEvent.key)return;if(0===(U[e]??"").length){if(e>0){const t=U.slice();t[e-1]="",H(t.join("")),q(e-1)}}else{const t=U.slice();t[e]="",H(t.join(""))}},[U,q,H]),G=(0,_react.useCallback)((e,t)=>{P(e),g?.(t)},[g]),K=(0,_react.useCallback)(()=>{P(-1)},[]),X=(0,_react.useCallback)(()=>{if(u)return;const e=U.indexOf("");q(-1===e?s-1:e)},[U,u,q,s]),J=(0,_react.useCallback)(e=>{C(e.nativeEvent.layout.width)},[]),Q=f??T.field(s),Y=R>0?Math.max(24,Math.min(A.cell,Math.floor((R-A.gap*(s-1))/s))):A.cell,Z=k.interpolate({inputRange:[-1,1],outputRange:[-6,6]});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:h,onLayout:J,accessible:!0,accessibilityRole:"none",accessibilityLabel:Q,accessibilityValue:{text:a},accessibilityState:{disabled:u},"aria-disabled":u,testID:y,children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:X,disabled:u,accessible:!1,children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[E.row,{columnGap:A.gap,transform:[{translateX:Z}]}],children:U.map((e,t)=>{const a=F===t,i=e.length>0,n=M?I.colors["danger-border"]:I.colors["focus-ring"],r=L[t];if(!r)return null;const o=p&&i?"●":e;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:E.cellWrapper,children:[(0,_jsxRuntime.jsxs)(_FieldBase.FieldBase,{size:_,width:Y,height:Y,radius:w,borderWidth:1.5,focused:a,error:M,filled:i,disabled:u,paddingHorizontal:I.space.none,paddingVertical:I.space.none,gap:I.space.none,style:v,children:[(0,_jsxRuntime.jsx)(_reactNative.TextInput,{ref:e=>{V.current[t]=e},value:(p&&i?"":e)||"",onChangeText:e=>W(t,e),onKeyPress:e=>$(t,e),onFocus:e=>G(t,e),onBlur:K,keyboardType:l,editable:!u,selectTextOnFocus:!0,caretHidden:i,maxLength:s+1,textContentType:"oneTimeCode",autoComplete:0===t?"sms-otp":"off",importantForAutofill:0===t?"yes":"no",style:[E.input,{fontSize:A.text,color:I.colors["text-body"],...(0,_index2.fontFor)(I,"semibold")},b]}),p&&i?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:E.maskOverlay,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",style:[{fontSize:A.text},b],children:o})}):null]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[E.underline,{backgroundColor:n,opacity:r}]})]},`otp-cell-${t}`)})})}),(0,_jsxRuntime.jsx)(_FieldBase.FieldMessage,{size:_,error:!0,text:d})]})});OTPInput.displayName="OTPInput";const buildStyles=e=>_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},cellWrapper:{alignItems:"center"},input:{width:"100%",height:"100%",textAlign:"center",padding:e.space.none},maskOverlay:{..._reactNative.StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center"},underline:{marginTop:e.space.xs,height:2,width:"60%",borderRadius:e.radius.pill,..._corners.smoothCorners}});var _default=exports.default=OTPInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ScannerOverlay=exports.DEFAULT_SCANNER_OVERLAY_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Button/index.js"),_index4=require("../EmptyState/index.js"),_index5=require("../IconButton/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const MIN_FRAME=240,DEFAULT_FRAME=260,MARK_LENGTH=32,MARK_THICKNESS=4,LIFT=.06,BREATHE_SCALE=1.03,SNAP_SCALE=1.08,T=4,CORNERS=[{key:"tl",style:{top:0,left:0,borderTopWidth:4,borderLeftWidth:4}},{key:"tr",style:{top:0,right:0,borderTopWidth:4,borderRightWidth:4}},{key:"bl",style:{bottom:0,left:0,borderBottomWidth:4,borderLeftWidth:4}},{key:"br",style:{bottom:0,right:0,borderBottomWidth:4,borderRightWidth:4}}],DEFAULT_SCANNER_OVERLAY_LABELS=exports.DEFAULT_SCANNER_OVERLAY_LABELS=Object.freeze({hint:"Point the camera at the code",found:"Code found",invalid:"This code cannot be used. Try another.",torchOn:"Turn torch on",torchOff:"Turn torch off",manualEntry:"Enter code instead",gallery:"Upload from gallery",noPermissionTitle:"Camera access is off",noPermissionMessage:"Allow camera access to scan a code.",permissionAction:"Allow camera access",noCameraTitle:"No camera found",noCameraMessage:"This device has no camera available. You can still add the code another way."}),ScannerOverlay=exports.ScannerOverlay=(0,_react.forwardRef)((e,t)=>{(0,_warnInvalidValue.warnInvalidValue)("ScannerOverlay","state",e.state,["scanning","found","invalid","noPermission","noCamera"]);const{children:i,state:n="scanning",helperText:a,labels:r,torch:s=!1,onTorchChange:o,onManualEntry:l,onGallery:c,onPermissionAction:d,frameSize:u=DEFAULT_FRAME,haptic:m,style:h,testID:_}=e,x=(0,_index.useTheme)(),p=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),f=(0,_useReducedMotion.useReducedMotion)(),v=(0,_react.useMemo)(()=>buildStyles(x),[x]),g=(0,_react.useMemo)(()=>({...DEFAULT_SCANNER_OVERLAY_LABELS,...r}),[r]),y=a??g.hint,[j,b]=(0,_react.useState)({width:0,height:0}),R="scanning"===n||"found"===n||"invalid"===n,A=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.ScannerOverlay=exports.DEFAULT_SCANNER_OVERLAY_LABELS=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Button/index.js"),_index4=require("../EmptyState/index.js"),_index5=require("../IconButton/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const MIN_FRAME=240,DEFAULT_FRAME=260,MARK_LENGTH=32,MARK_THICKNESS=4,LIFT=.06,BREATHE_SCALE=1.03,SNAP_SCALE=1.08,T=4,CORNERS=[{key:"tl",style:{top:0,left:0,borderTopWidth:4,borderLeftWidth:4}},{key:"tr",style:{top:0,right:0,borderTopWidth:4,borderRightWidth:4}},{key:"bl",style:{bottom:0,left:0,borderBottomWidth:4,borderLeftWidth:4}},{key:"br",style:{bottom:0,right:0,borderBottomWidth:4,borderRightWidth:4}}],DEFAULT_SCANNER_OVERLAY_LABELS=exports.DEFAULT_SCANNER_OVERLAY_LABELS=Object.freeze({hint:"Point the camera at the code",found:"Code found",invalid:"This code cannot be used. Try another.",torchOn:"Turn torch on",torchOff:"Turn torch off",manualEntry:"Enter code instead",gallery:"Upload from gallery",noPermissionTitle:"Camera access is off",noPermissionMessage:"Allow camera access to scan a code.",permissionAction:"Allow camera access",noCameraTitle:"No camera found",noCameraMessage:"This device has no camera available. You can still add the code another way."}),ScannerOverlay=exports.ScannerOverlay=(0,_react.forwardRef)((e,t)=>{(0,_warnInvalidValue.warnInvalidValue)("ScannerOverlay","state",e.state,["scanning","found","invalid","noPermission","noCamera"]);const{children:i,state:n="scanning",helperText:a,labels:r,torch:s=!1,onTorchChange:o,onManualEntry:l,onGallery:c,onPermissionAction:d,frameSize:u=DEFAULT_FRAME,haptic:m,style:h,testID:_}=e,x=(0,_index.useTheme)(),p=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),f=(0,_useReducedMotion.useReducedMotion)(),v=(0,_react.useMemo)(()=>buildStyles(x),[x]),g=(0,_react.useMemo)(()=>({...DEFAULT_SCANNER_OVERLAY_LABELS,...r}),[r]),y=a??g.hint,[j,b]=(0,_react.useState)({width:0,height:0}),R="scanning"===n||"found"===n||"invalid"===n,A=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current,N=x.motion.duration.slower,E=x.motion.duration.default;(0,_react.useEffect)(()=>{if(A.setValue(1),f)return;let e;return"scanning"===n&&N>0?e=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(A,{toValue:1.03,duration:2*N,useNativeDriver:!0}),_reactNative.Animated.timing(A,{toValue:1,duration:2*N,useNativeDriver:!0})])):"found"===n&&E>0&&(A.setValue(1.08),e=_reactNative.Animated.timing(A,{toValue:1,duration:E,useNativeDriver:!0})),e?.start(),()=>e?.stop()},[n,f,N,E,A]);const S=(0,_react.useRef)(n);(0,_react.useEffect)(()=>{S.current!==n&&(S.current=n,!1!==m&&("found"===n?(0,_hapticUtils.triggerHaptic)("notificationSuccess"):"invalid"===n&&(0,_hapticUtils.triggerHaptic)("notificationError")))},[n,m]);const{found:w,invalid:V}=g,{noPermissionTitle:C,noPermissionMessage:L}=g,{noCameraTitle:M,noCameraMessage:I}=g;(0,_react.useEffect)(()=>{switch(n){case"scanning":(0,_announce.announce)(y);break;case"found":(0,_announce.announce)(w);break;case"invalid":(0,_announce.announce)(V,{polite:!1});break;case"noPermission":(0,_announce.announce)(`${C}. ${L}`);break;case"noCamera":(0,_announce.announce)(`${M}. ${I}`)}},[n,y,w,V,C,L,M,I]);const O=Math.max(240,Math.min(u,j.width-2*x.space.xl)),P=(j.width-O)/2,k=Math.max(x.space.md,(j.height-O)/2-.06*j.height),q=j.width>0&&j.height>0,F={borderColor:"found"===n?x.colors.success:"invalid"===n?x.colors.danger:x.colors["on-scrim"],width:32,height:32},B="found"===n||"invalid"===n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.pill,{backgroundColor:"found"===n?x.colors.success:x.colors.danger}],children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:"found"===n?x.colors["on-success"]:x.colors["on-danger"]},children:"found"===n?w:V})}):(0,_jsxRuntime.jsx)(_index6.Text,{variant:"bodySmall",align:"center",style:{color:x.colors["on-scrim"]},children:y}),D=R&&null!=o,U=R?"glass":"outline";return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,testID:_,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;b(e=>e.width===t&&e.height===i?e:{width:t,height:i})},style:[v.root,!R&&{backgroundColor:x.colors.bg},h],children:[R?(0,_jsxRuntime.jsx)(_reactNative.View,{style:_reactNative.StyleSheet.absoluteFill,children:i}):null,R&&q?(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"none",style:_reactNative.StyleSheet.absoluteFill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.scrim,{left:0,right:0,top:0,height:k}]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.scrim,{left:0,right:0,top:k+O,bottom:0}]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.scrim,{left:0,width:P,top:k,height:O}]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.scrim,{left:P+O,right:0,top:k,height:O}]}),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{position:"absolute",left:P,top:k,width:O,height:O,transform:[{scale:A}]},children:CORNERS.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:[v.mark,F,e.style]},e.key))})]})}):null,R?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:v.panel,children:(0,_jsxRuntime.jsx)(_index4.EmptyState,{fill:!0,icon:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"noPermission"===n?"camera":"camera-slash",size:48,color:x.colors["text-subtle"]}),title:"noPermission"===n?C:M,description:"noPermission"===n?L:I,action:"noPermission"===n&&d?{label:g.permissionAction,onPress:d}:void 0})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{pointerEvents:"box-none",style:[v.bar,{paddingBottom:Math.max(p.bottom,x.space.md)}],children:[R&&q?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:v.message,children:B}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:v.actions,children:[D?(0,_jsxRuntime.jsx)(_index5.IconButton,{icon:s?"flash":"flash-slash",variant:"glass",size:"lg",active:s,haptic:m,accessibilityLabel:s?g.torchOff:g.torchOn,onPress:()=>o?.(!s)}):null,c?(0,_jsxRuntime.jsx)(_index3.Button,{label:g.gallery,leftIcon:"gallery",variant:U,tone:"neutral",size:"lg",haptic:m,onPress:c}):null,l?(0,_jsxRuntime.jsx)(_index3.Button,{label:g.manualEntry,leftIcon:"keyboard",variant:U,tone:"neutral",size:"lg",haptic:m,onPress:l}):null]})]})]})});ScannerOverlay.displayName="ScannerOverlay";const buildStyles=e=>_reactNative.StyleSheet.create({root:{flex:1,overflow:"hidden"},scrim:{position:"absolute",backgroundColor:e.colors.scrim},mark:{position:"absolute"},message:{alignItems:"center",paddingHorizontal:e.space.xl},pill:{paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,..._corners.smoothCorners},panel:{..._reactNative.StyleSheet.absoluteFill,justifyContent:"center"},bar:{position:"absolute",left:0,right:0,bottom:0,flexDirection:"column",alignItems:"center",justifyContent:"center",gap:e.space.sm,paddingHorizontal:e.space.md},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"center",gap:e.space.sm}});var _default=exports.default=ScannerOverlay;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Screen=Screen;var _react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=require("react-native-reanimated"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useRefreshControl=require("../../hooks/useRefreshControl.js"),_index=require("../../theme/index.js"),_index2=require("../AppBar/index.js"),_index3=require("../AsyncBlock/index.js"),_index4=require("../EmptyState/index.js"),_index5=require("../KeyboardAwareScrollView/index.js"),_index6=require("../KeyboardToolbar/index.js"),_index7=require("../PagedListFooter/index.js"),_ScrollHost=require("./ScrollHost.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_EDGES=["top","bottom"],SCROLL_EVENT_THROTTLE=16,noop=()=>{};function renderFooter(e){return(0,_react.isValidElement)(e)?e:e?(0,_react.createElement)(e):null}const topPaddingOf=e=>{const t=_reactNative.StyleSheet.flatten(e),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Screen=Screen;var _react=require("react"),_reactNative=require("react-native"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=require("react-native-reanimated"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useRefreshControl=require("../../hooks/useRefreshControl.js"),_index=require("../../theme/index.js"),_index2=require("../AppBar/index.js"),_index3=require("../AsyncBlock/index.js"),_index4=require("../EmptyState/index.js"),_index5=require("../KeyboardAwareScrollView/index.js"),_index6=require("../KeyboardToolbar/index.js"),_index7=require("../PagedListFooter/index.js"),_ScrollHost=require("./ScrollHost.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_EDGES=["top","bottom"],SCROLL_EVENT_THROTTLE=16,noop=()=>{};function renderFooter(e){return(0,_react.isValidElement)(e)?e:e?(0,_react.createElement)(e):null}const topPaddingOf=e=>{const t=_reactNative.StyleSheet.flatten(e),r=t?.paddingTop??t?.paddingVertical??t?.padding;return"number"==typeof r?r:0},buildStyles=e=>_reactNative.StyleSheet.create({flex:{flex:1},root:{flex:1,backgroundColor:e.colors.bg},overlay:{position:"absolute",top:0,left:0,right:0},headerRaised:{zIndex:1},footer:{backgroundColor:e.colors.bg,borderTopWidth:_reactNative.StyleSheet.hairlineWidth,borderTopColor:e.colors.border}});function Screen(e){const{title:t,subtitle:r,largeTitle:o=!0,headerShadowOnScroll:n,onBack:a,rightActions:i,leading:l,trailing:s,children:c,onRefresh:d,refreshing:u=!1,footer:_,scroll:f=!0,list:h,edges:m=DEFAULT_EDGES,keyboardToolbar:p=!0,bottomInset:x=0,gutter:v,floatingAction:g,scrollRef:S,onScroll:y,contentContainerStyle:R,testID:b}=e,j=(0,_index.useTheme)(),C=v??void 0===h,E=j.space[j.components.screen.gutter],T=C?E:0,L=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),N=(0,_react.useMemo)(()=>buildStyles(j),[j]),[k]=(0,_react.useState)(()=>new _reactNative.Animated.Value(0)),[O,A]=(0,_react.useState)(0),[V,q]=(0,_react.useState)(0),w=void 0!==a,B=(0,_react.useRef)(a);B.current=a;const F=Boolean(t||r||a||l||s||i?.length),M=o&&void 0!==t,H=M&&(void 0!==h||f),P=H?O:0,z=F&&!H&&(n??j.settings.components.screen?.headerShadowOnScroll??!0),[D,K]=(0,_react.useState)(!1),I=(0,_react.useRef)(z);I.current=z;const headerGap=e=>e>0?e:F?j.space.lg:0,W=void 0!==_,{refreshControl:G}=(0,_useRefreshControl.useRefreshControl)({onRefresh:d??noop,refreshing:u}),U=d?(0,_react.cloneElement)(G,{progressViewOffset:P}):void 0,Y=(0,_reactNativeReanimated.useSharedValue)(0),J=(0,_reactNativeReanimated.useSharedValue)(0),Q=(0,_reactNativeReanimated.useSharedValue)(0),X=(0,_reactNativeReanimated.useSharedValue)(0),Z=(0,_react.useRef)(null),$=(0,_react.useRef)(0),ee=(0,_react.useRef)(0),te=(0,_react.useMemo)(()=>({top:Y,bottom:J,offset:Q,maxOffset:X,scrollTo:e=>{const t=Z.current;t instanceof _reactNative.FlatList?t.scrollToOffset({offset:e,animated:!1}):t?.scrollTo({y:e,animated:!1})}}),[Y,J,Q,X]),re=(0,_react.useCallback)(e=>{Z.current=e,"function"==typeof S?S(e):S&&(S.current=e)},[S]),oe=(0,_react.useCallback)(()=>{X.value=Math.max(0,$.current-ee.current)},[X]),ne=(0,_react.useRef)(y);ne.current=y;const ae=(0,_react.useMemo)(()=>_reactNative.Animated.event([{nativeEvent:{contentOffset:{y:k}}}],{useNativeDriver:!1,listener:e=>{if(Q.value=e.nativeEvent.contentOffset.y,I.current){const t=e.nativeEvent.contentOffset.y>0;K(e=>e===t?e:t)}ne.current?.(e)}}),[k,Q]),ie=(0,_react.useCallback)(e=>{const{height:t}=e.nativeEvent.layout;A(e=>Math.max(e,t))},[]),le=(0,_react.useCallback)(e=>{q(e.nativeEvent.layout.height)},[]);(0,_react.useEffect)(()=>{if(!w)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(B.current?.(),!0));return()=>e.remove()},[w]);const se=m.includes("left")?L.left:0,ce=m.includes("right")?L.right:0,de=m.includes("bottom")?L.bottom:0,ue=m.includes("top")&&!F?L.top:0,fe=j.space[j.components["floating-action-button"]["bottom-offset"]],he=g?.props.bottomOffset??fe,me=g?(0,_index.resolveFloatingActionButtonSize)(j,g.props.size??"md").diameter+he+j.space.lg:0,pe=W?Math.max(0,V-L.bottom):x,xe=g?(0,_react.cloneElement)(g,{bottomOffset:he+pe,position:g.props.position??"bottomRight"}):null,ve=W?me:Math.max(de,g?me+L.bottom:0),ge=x+ve-(W?0:de),Se=m.filter(e=>"top"!==e&&!("bottom"===e&&W)),ye=F?(0,_jsxRuntime.jsx)(_reactNative.View,{style:H?N.overlay:z?N.headerRaised:void 0,onLayout:H?ie:void 0,children:(0,_jsxRuntime.jsx)(_index2.AppBar,{title:t,subtitle:r,variant:M?"large":"default",scrollY:H?k:void 0,elevated:z&&D,onBack:a,rightActions:i,leading:l,trailing:s,gutter:E})}):null,Re=(0,_react.useCallback)(()=>{const e=Z.current?.getNativeScrollRef();e&&e.measureInWindow((e,t,r,o)=>{ee.current=o,Y.value=t+P,J.value=t+o,oe()})},[P,Y,J,oe]);(0,_react.useEffect)(()=>{Re()},[Re]);const be=(0,_react.useCallback)((e,t)=>{$.current=t,oe()},[oe]);let je;if(void 0!==h){const{state:e,paging:t,...r}=h,o=topPaddingOf([r.contentContainerStyle,R]),handleEndReached=e=>{t?.hasMore&&!t.loadingMore&&null==t.errorMore&&t.loadMore(),r.onEndReached?.(e)},n=(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",onEndReachedThreshold:t?.5:void 0,...r,ref:re,refreshControl:U,onScroll:ae,onLayout:e=>{Re(),r.onLayout?.(e)},onContentSizeChange:(e,t)=>{be(e,t),r.onContentSizeChange?.(e,t)},onEndReached:t?handleEndReached:r.onEndReached,ListEmptyComponent:e?.empty?(0,_jsxRuntime.jsx)(_index4.EmptyState,{...e.empty}):void 0,ListFooterComponent:t||r.ListFooterComponent?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[renderFooter(r.ListFooterComponent),t?(0,_jsxRuntime.jsx)(_index7.PagedListFooter,{paging:t}):null]}):void 0,scrollEventThrottle:SCROLL_EVENT_THROTTLE,style:N.flex,contentContainerStyle:[{paddingTop:P,paddingLeft:se+T,paddingRight:ce+T},{paddingBottom:x+ve},r.contentContainerStyle,R,{paddingTop:P+headerGap(o)}]});je=(0,_jsxRuntime.jsx)(_ScrollHost.ScrollHostContext.Provider,{value:te,children:e?(0,_jsxRuntime.jsx)(_index3.AsyncBlock,{loading:e.loading,error:e.error,errorTitle:e.errorTitle,onRetry:e.onRetry,skeleton:e.skeleton,style:[N.flex,{paddingTop:P+headerGap(o)}],children:n}):n})}else je=f?(0,_jsxRuntime.jsx)(_ScrollHost.ScrollHostContext.Provider,{value:te,children:(0,_jsxRuntime.jsxs)(_index5.KeyboardAwareScrollView,{ref:re,refreshControl:U,onScroll:ae,scrollEventThrottle:SCROLL_EVENT_THROTTLE,onLayout:Re,onContentSizeChange:be,safeAreaEdges:Se,style:N.flex,contentContainerStyle:[{paddingHorizontal:T},R,{paddingTop:P+headerGap(topPaddingOf(R))}],children:[c,ge>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:ge}}):null]})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[N.flex,{paddingLeft:se+T,paddingRight:ce+T,paddingBottom:x+ve},R],children:c});const Ce=W?(0,_jsxRuntime.jsx)(_reactNativeKeyboardController.KeyboardStickyView,{onLayout:le,style:[N.footer,{paddingLeft:se+E,paddingRight:ce+E,paddingBottom:de+x}],children:_}):null;return(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:b,style:[N.root,{paddingTop:ue}],children:[H?null:ye,je,Ce,xe,void 0!==h?c:null,H?ye:null,p?(0,_jsxRuntime.jsx)(_index6.KeyboardToolbar,{}):null]})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SegmentedControl=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../FieldBase/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const LABEL_LINE_HEIGHT_RATIO=1.25,activeInkFor=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"neutral":return e.colors["text-body"];case"success":return e.colors["success-text"];case"warning":return e.colors["warning-text"];case"danger":return e.colors["danger-text"];default:return e.colors["info-text"]}},SegmentedControl=exports.SegmentedControl=(0,_react.forwardRef)((e,t)=>{const{segments:r,label:i,helperText:n,error:l,value:s,defaultValue:a,onChange:o,size:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SegmentedControl=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index4=require("../FieldBase/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index5=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const LABEL_LINE_HEIGHT_RATIO=1.25,activeInkFor=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"neutral":return e.colors["text-body"];case"success":return e.colors["success-text"];case"warning":return e.colors["warning-text"];case"danger":return e.colors["danger-text"];default:return e.colors["info-text"]}},SegmentedControl=exports.SegmentedControl=(0,_react.forwardRef)((e,t)=>{const{segments:r,label:i,helperText:n,error:l,value:s,defaultValue:a,onChange:o,size:c="md",fullWidth:d=!0,disabled:u=!1,tone:m="primary",variant:x="segmented",radius:g,labelLines:h=1,haptic:_,accessibilityLabel:p,style:v,containerStyle:b,segmentStyle:f,selectedIndicatorStyle:y,textStyle:S,labelStyle:j,testID:w}=e;(0,_warnInvalidValue.warnInvalidValue)("SegmentedControl","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("SegmentedControl","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("SegmentedControl","variant",e.variant,["underline","pills","segmented"]);const[I,C]=(0,_index.useControllableState)({value:s,defaultValue:a??r[0]?.value,onChange:o}),R=(0,_index2.useTheme)(),V=R.components["segmented-control"],q=(0,_react.useMemo)(()=>buildStyles(R),[R]),k=(0,_react.useMemo)(()=>(0,_index2.resolveSegmentedControlSize)(R,c),[R,c]),F=h>=2?2:1,L=F>1,N="segmented"===x,z="underline"===x,M="pills"===x,T=N?R.space[V["track-padding"]]:0,E=Math.ceil(1.25*k.text)*(F-1),A=V["underline-height"],D=R.space[V["pill-inset"]],H="number"==typeof g?g:g?R.radius[g]:void 0,B=H??R.radius.md,W=void 0===H?R.radius.sm:Math.max(H-T,0),P=H??R.radius.pill,O=H??R.radius.none,[G,X]=(0,_react.useState)([]),J=(0,_react.useRef)((0,_index2.createAnimatedValue)(0)).current,K=Math.max(0,r.findIndex(e=>e.value===I)),Q=G[K],U=Q?.x,Y=(0,_react.useCallback)(e=>{const t=R.motion.spring.snappy,r=_reactNative.Animated.spring(J,{toValue:e,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:!0});return r.start(),r},[R.motion.spring.snappy,J]);(0,_react.useEffect)(()=>{X(e=>e.length===r.length||0===e.length?e:[])},[r.length]);const Z=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(void 0===U)return;const e=null!==Z.current&&Z.current!==K;if(Z.current=K,!e)return void J.setValue(U);const t=Y(U);return()=>t.stop()},[K,U,Y,J]);const $=(0,_react.useCallback)((e,t)=>{const{x:r,width:i}=t.nativeEvent.layout;X(t=>{const n=t[e];if(n&&n.x===r&&n.width===i)return t;const l=t.slice();return l[e]={x:r,width:i},l})},[]),ee=(0,_react.useCallback)(e=>{if(u)return;if(e.value===I)return;const t=(0,_index3.resolveHaptic)(_,"selection");t&&(0,_index3.triggerHaptic)(t),C(e.value)},[u,C,I,_]),te=N?R.colors.surface:M?R.colors["primary-soft"]:R.colors.primary,re=N?W:M?P:O,ie=activeInkFor(R,m),ne=R.colors["bg-muted"],le=(0,_SquircleFill.useSquircle)(N,B),se=!0===l||(0,_index4.hasFieldText)(l),ae=se&&!u,oe=R.colors["field-border-error"],ce=R.size.border,de=(0,_index4.hasFieldText)(i),ue=se?l:n,me=(0,_index4.hasFieldText)(ue),xe=p??("string"==typeof i?i:void 0),ge=(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessibilityRole:"radiogroup",accessibilityLabel:xe,testID:w,style:[q.track,{...L?{minHeight:k.height+E}:{height:k.height},opacity:u?.55:1,alignSelf:d?"stretch":"flex-start"},N?{borderRadius:B,..._corners.smoothCorners,backgroundColor:le.active?"transparent":ne,padding:T}:z?{borderBottomColor:ae?oe:R.colors["border-subtle"],borderBottomWidth:_reactNative.StyleSheet.hairlineWidth}:null,b,v],onLayout:le.onLayout,children:[le.active&&le.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:le.size.width,height:le.size.height,radius:B,fill:ne,stroke:ae?oe:void 0,strokeWidth:ce}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:q.row,children:[Q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[q.thumb,N?L?{top:0,bottom:0}:{top:0,height:k.height-2*T}:M?{top:D,bottom:D,left:D}:{bottom:0,height:A},{width:M?Math.max(Q.width-2*D,0):Q.width,borderRadius:re,..._corners.smoothCorners,backgroundColor:te,transform:[{translateX:J}]},y]}):null,r.map((e,t)=>{const r=e.value===I,i=r?ie:R.colors["text-subtle"],n=(0,_slotIcon.renderSlotIcon)(e.icon,{color:i,size:k.icon,selected:r,disabled:u});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>ee(e),onLayout:e=>$(t,e),disabled:u,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:r,selected:r,disabled:u},"aria-checked":r,"aria-disabled":u,style:({pressed:e})=>[q.segment,L?q.segmentMultiline:null,{paddingHorizontal:k["padding-x"],opacity:e&&!r?.7:1},f],children:[n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:q.segmentIcon,children:n}):null,(0,_jsxRuntime.jsx)(_index5.Text,{variant:"label",weight:r?"semibold":"medium",style:[q.segmentLabel,L?q.segmentLabelMultiline:null,{color:i,fontSize:k.text},S,j],numberOfLines:F,children:e.label})]},String(e.value))})]}),!ae||z||le.active?null:(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,{borderWidth:ce,borderColor:oe,borderRadius:N?B:P,..._corners.smoothCorners}]})]});return de||me?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{alignSelf:d?"stretch":"flex-start"},children:[de?(0,_jsxRuntime.jsx)(_index4.FieldLabel,{size:c,children:i}):null,ge,me?(0,_jsxRuntime.jsx)(_index4.FieldMessage,{size:c,text:ue,error:se}):null]}):ge});SegmentedControl.displayName="SegmentedControl";const buildStyles=e=>_reactNative.StyleSheet.create({track:{flexDirection:"row",alignItems:"stretch",position:"relative"},row:{flex:1,flexDirection:"row",alignItems:"stretch",position:"relative",overflow:"hidden"},thumb:{position:"absolute",left:0},segment:{flexGrow:1,flexShrink:1,flexBasis:"auto",flexDirection:"row",alignItems:"center",justifyContent:"center"},segmentIcon:{marginRight:e.space.xs},segmentMultiline:{paddingVertical:e.space.xs},segmentLabel:{includeFontPadding:!1},segmentLabelMultiline:{flexShrink:1,textAlign:"center"}});var _default=exports.default=SegmentedControl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SlideToConfirm=exports.DEFAULT_SLIDE_TO_CONFIRM_LABELS=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,i=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=i&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?i(n,r,a):n[r]=e[r]);return n}const DEFAULT_SLIDE_TO_CONFIRM_LABELS=exports.DEFAULT_SLIDE_TO_CONFIRM_LABELS=Object.freeze({slide:"Slide to confirm",confirmed:"Confirmed",confirmAction:"Confirm"}),SIZE_MAP={sm:{height:44,pad:"xxs"},md:{height:56,pad:"xs"},lg:{height:64,pad:"sm"}},Chevron=({color:e,size:t})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:0,height:0,borderTopWidth:.4*t,borderBottomWidth:.4*t,borderLeftWidth:.55*t,borderTopColor:"transparent",borderBottomColor:"transparent",borderLeftColor:e,marginLeft:.2*t}}),SlideToConfirm=exports.SlideToConfirm=(0,_react.forwardRef)((e,t)=>{const{onConfirm:a,label:r,tone:i="primary",size:n="md",disabled:o=!1,threshold:l=.9,resetAfter:s=!1,haptic:c,icon:d,labels:u,style:m,trackStyle:_,handleStyle:h,labelStyle:v,testID:f}=e;(0,_warnInvalidValue.warnInvalidValue)("SlideToConfirm","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("SlideToConfirm","size",e.size,["sm","md","lg"]);const p=(0,_react.useMemo)(()=>({...DEFAULT_SLIDE_TO_CONFIRM_LABELS,...u}),[u]),b=(0,_react.useMemo)(()=>[{name:"activate",label:p.confirmAction},{name:"increment",label:p.confirmAction}],[p.confirmAction]),x=(0,_index.useTheme)(),g=SIZE_MAP[n],R=x.space[g.pad],S=g.height-2*R,y=(0,_react.useMemo)(()=>buildStyles(x,g),[x,g]),C=x.colors[i],[j,N]=(0,_react.useState)(!1),w=(0,_reactNativeReanimated.useSharedValue)(0),T=(0,_reactNativeReanimated.useSharedValue)(0),A=(0,_reactNativeReanimated.useSharedValue)(0),E=(0,_react.useRef)(null),L=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(c,"notificationSuccess");e&&(0,_index2.triggerHaptic)(e)},[c]),I=(0,_react.useCallback)(()=>{N(!1),w.value=(0,_reactNativeReanimated.withSpring)(0,{damping:18,stiffness:160,mass:1})},[w]),M=(0,_react.useCallback)(()=>{N(!0),L(),a(),!1!==s&&(E.current&&clearTimeout(E.current),E.current=setTimeout(I,s))},[L,a,s,I]),O=(0,_react.useCallback)(e=>{if(o||j)return;const{actionName:t}=e.nativeEvent;"activate"!==t&&"increment"!==t||M()},[o,j,M]);_react.default.useEffect(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(w),E.current&&clearTimeout(E.current)},[w]);const k=(0,_react.useCallback)(e=>{T.value=Math.max(0,e.nativeEvent.layout.width-S-2*R)},[T,S,R]),V=(0,_react.useMemo)(()=>{const e=l,t={damping:18,stiffness:160,mass:1},a={duration:x.motion.duration.fast,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)};return _reactNativeGestureHandler.Gesture.Pan().enabled(!o&&!j).minDistance(0).onStart(()=>{"worklet";A.value=w.value}).onUpdate(e=>{"worklet";w.value=Math.min(Math.max(A.value+e.translationX,0),T.value)}).onEnd(()=>{"worklet";T.value>0&&w.value>=T.value*e?(w.value=(0,_reactNativeReanimated.withTiming)(T.value,a),(0,_reactNativeReanimated.runOnJS)(M)()):w.value=(0,_reactNativeReanimated.withSpring)(0,t)})},[o,j,l,w,T,A,M,x.motion.duration.fast]),q=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:w.value}]})),D=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({width:w.value+S+R})),W=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=T.value>0?T.value:1;return{opacity:Math.max(0,1-w.value/(.6*e))}});return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[y.track,{backgroundColor:x.colors["bg-subtle"]},_,m],onLayout:k,testID:f,accessibilityRole:"adjustable",accessibilityLabel:j?p.confirmed:r??p.slide,accessibilityState:{disabled:o},"aria-disabled":o,accessibilityActions:b,onAccessibilityAction:O,children:[(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[y.fill,{backgroundColor:C,opacity:o?.5:1},D],pointerEvents:"none"}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[y.labelWrap,W],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",style:[y.label,{color:x.colors["text-muted"]},v],numberOfLines:1,children:j?p.confirmed:r??p.slide})}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:V,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[y.handle,{width:S,height:S,borderRadius:x.radius.pill,..._corners.smoothCorners,backgroundColor:x.colors.surface,opacity:o?.5:1,...x.shadow.card},h,q],children:d??(0,_jsxRuntime.jsx)(Chevron,{color:C,size:.5*S})})})]})});SlideToConfirm.displayName="SlideToConfirm";const buildStyles=(e,t)=>_reactNative.StyleSheet.create({track:{height:t.height,borderRadius:e.radius.pill,..._corners.smoothCorners,justifyContent:"center",overflow:"hidden",padding:e.space[t.pad]},fill:{position:"absolute",left:0,top:0,bottom:0,borderRadius:e.radius.pill,..._corners.smoothCorners},labelWrap:{position:"absolute",left:t.height,right:t.height},label:{textAlign:"center",includeFontPadding:!1},handle:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=SlideToConfirm;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SlideToConfirm=exports.DEFAULT_SLIDE_TO_CONFIRM_LABELS=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,i=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=i&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?i(n,r,a):n[r]=e[r]);return n}const DEFAULT_SLIDE_TO_CONFIRM_LABELS=exports.DEFAULT_SLIDE_TO_CONFIRM_LABELS=Object.freeze({slide:"Slide to confirm",confirmed:"Confirmed",confirmAction:"Confirm"}),SIZE_MAP={sm:{height:44,pad:"xxs"},md:{height:56,pad:"xs"},lg:{height:64,pad:"sm"}},Chevron=({color:e,size:t})=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:0,height:0,borderTopWidth:.4*t,borderBottomWidth:.4*t,borderLeftWidth:.55*t,borderTopColor:"transparent",borderBottomColor:"transparent",borderLeftColor:e,marginLeft:.2*t}}),SlideToConfirm=exports.SlideToConfirm=(0,_react.forwardRef)((e,t)=>{const{onConfirm:a,label:r,tone:i="primary",size:n="md",disabled:o=!1,threshold:l=.9,resetAfter:s=!1,haptic:c,icon:d,labels:u,style:m,trackStyle:_,handleStyle:h,labelStyle:v,testID:f}=e;(0,_warnInvalidValue.warnInvalidValue)("SlideToConfirm","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("SlideToConfirm","size",e.size,["sm","md","lg"]);const p=(0,_react.useMemo)(()=>({...DEFAULT_SLIDE_TO_CONFIRM_LABELS,...u}),[u]),b=(0,_react.useMemo)(()=>[{name:"activate",label:p.confirmAction},{name:"increment",label:p.confirmAction}],[p.confirmAction]),x=(0,_index.useTheme)(),g=SIZE_MAP[n],R=x.space[g.pad],S=g.height-2*R,y=(0,_react.useMemo)(()=>buildStyles(x,g),[x,g]),C=x.colors[i],[j,N]=(0,_react.useState)(!1),w=(0,_reactNativeReanimated.useSharedValue)(0),T=(0,_reactNativeReanimated.useSharedValue)(0),A=(0,_reactNativeReanimated.useSharedValue)(0),E=(0,_react.useRef)(null),L=(0,_react.useCallback)(()=>{const e=(0,_index2.resolveHaptic)(c,"notificationSuccess");e&&(0,_index2.triggerHaptic)(e)},[c]),I=(0,_react.useCallback)(()=>{N(!1),w.value=(0,_reactNativeReanimated.withSpring)(0,{damping:18,stiffness:160,mass:1})},[w]),M=(0,_react.useCallback)(()=>{N(!0),L(),a(),!1!==s&&(E.current&&clearTimeout(E.current),E.current=setTimeout(I,s))},[L,a,s,I]),O=(0,_react.useCallback)(e=>{if(o||j)return;const{actionName:t}=e.nativeEvent;"activate"!==t&&"increment"!==t||M()},[o,j,M]);_react.default.useEffect(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(w),E.current&&clearTimeout(E.current)},[w]);const k=(0,_react.useCallback)(e=>{T.value=Math.max(0,e.nativeEvent.layout.width-S-2*R)},[T,S,R]),V=(0,_react.useMemo)(()=>{const e=l,t={damping:18,stiffness:160,mass:1},a={duration:x.motion.duration.fast,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)};return _reactNativeGestureHandler.Gesture.Pan().enabled(!o&&!j).minDistance(0).onStart(()=>{"worklet";A.value=w.value}).onUpdate(e=>{"worklet";w.value=Math.min(Math.max(A.value+e.translationX,0),T.value)}).onEnd(()=>{"worklet";T.value>0&&w.value>=T.value*e?(w.value=(0,_reactNativeReanimated.withTiming)(T.value,a),(0,_reactNativeReanimated.runOnJS)(M)()):w.value=(0,_reactNativeReanimated.withSpring)(0,t)})},[o,j,l,w,T,A,M,x.motion.duration.fast]),q=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:w.value}]}),[w]),D=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({width:w.value+S+R}),[w,S,R]),W=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=T.value>0?T.value:1;return{opacity:Math.max(0,1-w.value/(.6*e))}},[T,w]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[y.track,{backgroundColor:x.colors["bg-subtle"]},_,m],onLayout:k,testID:f,accessibilityRole:"adjustable",accessibilityLabel:j?p.confirmed:r??p.slide,accessibilityState:{disabled:o},"aria-disabled":o,accessibilityActions:b,onAccessibilityAction:O,children:[(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[y.fill,{backgroundColor:C,opacity:o?.5:1},D],pointerEvents:"none"}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[y.labelWrap,W],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"body",style:[y.label,{color:x.colors["text-muted"]},v],numberOfLines:1,children:j?p.confirmed:r??p.slide})}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:V,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[y.handle,{width:S,height:S,borderRadius:x.radius.pill,..._corners.smoothCorners,backgroundColor:x.colors.surface,opacity:o?.5:1,...x.shadow.card},h,q],children:d??(0,_jsxRuntime.jsx)(Chevron,{color:C,size:.5*S})})})]})});SlideToConfirm.displayName="SlideToConfirm";const buildStyles=(e,t)=>_reactNative.StyleSheet.create({track:{height:t.height,borderRadius:e.radius.pill,..._corners.smoothCorners,justifyContent:"center",overflow:"hidden",padding:e.space[t.pad]},fill:{position:"absolute",left:0,top:0,bottom:0,borderRadius:e.radius.pill,..._corners.smoothCorners},labelWrap:{position:"absolute",left:t.height,right:t.height},label:{textAlign:"center",includeFontPadding:!1},handle:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=SlideToConfirm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Slider=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index4=require("../Text/index.js"),_valueText=require("./valueText.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,i,r=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((a=r&&Object.getOwnPropertyDescriptor(e,i))&&(a.get||a.set)?r(n,i,a):n[i]=e[i]);return n}const VARIANT_SIZE_MAP={inset:{sm:{trackHeight:14,thumbDiameter:10},md:{trackHeight:20,thumbDiameter:14},lg:{trackHeight:26,thumbDiameter:18}},minimal:{sm:{trackHeight:2,thumbDiameter:14},md:{trackHeight:3,thumbDiameter:18},lg:{trackHeight:4,thumbDiameter:22}},bar:{sm:{trackHeight:20,thumbDiameter:20},md:{trackHeight:28,thumbDiameter:28},lg:{trackHeight:36,thumbDiameter:36}}},INSET_RING_RATIO=.3,MIN_THUMB_TOUCH=44,clamp=(e,t,a)=>Math.min(Math.max(e,t),a),snapToStep=(e,t,a,i)=>{if(i<=0)return clamp(e,t,a);const r=Math.round((e-t)/i)*i+t,n=String(i).split(".")[1]?.length??0,s=n>0?Number(r.toFixed(n)):r;return clamp(s,t,a)},BUBBLE_GAP=2,BUBBLE_CARET=8,BUBBLE_WRAP_WIDTH=160,NO_SHADOW={shadowOpacity:0,elevation:0},defaultFormatLabel=e=>String(e),Slider=exports.Slider=(0,_react.forwardRef)((e,t)=>{const{min:a=0,max:i=100,step:r=1,disabled:n=!1,tone:s="primary",size:l="md",variant:c="default",showLabel:o=!1,snapThumb:u=!1,formatLabel:d=defaultFormatLabel,renderLabel:m,accessibilityLabel:h,haptic:_,style:v,containerStyle:b,trackStyle:p,fillStyle:f,thumbStyle:g,labelStyle:R,thumbPressScale:w,labelShowDuration:x,labelOpacity:y,testID:N}=e;(0,_warnInvalidValue.warnInvalidValue)("Slider","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("Slider","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Slider","variant",e.variant,["default","inset","minimal","bar"]);const S=(0,_index2.useTheme)(),k=(0,_react.useMemo)(()=>{const e=(0,_index2.resolveSliderSize)(S,l);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[S,l]),j=(0,_react.useMemo)(()=>"default"===c?k:VARIANT_SIZE_MAP[c][l],[k,l,c]),C="inset"===c?j.trackHeight/2:0,M=S.settings.components.slider?.thumbPressAnimation??!1,V=w??1.1,H=x??S.motion.duration.fast,O=y??1,D=(0,_react.useMemo)(()=>buildStyles(S,j),[S,j]),A=(0,_react.useMemo)(()=>({damping:S.motion.spring.snappy.damping,stiffness:S.motion.spring.snappy.stiffness,mass:S.motion.spring.snappy.mass}),[S.motion.spring.snappy]),[E,T]=(0,_react.useState)(0),I=S.colors[s],W=(0,_valueText.sliderToneInk)(S,s),q=!0===e.range,[P,L]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??(q?[a,i]:a),onChange:e.onChange}),X=(0,_reactNativeReanimated.useSharedValue)(0),B=(0,_reactNativeReanimated.useSharedValue)(0),G=(0,_reactNativeReanimated.useSharedValue)(q?P[0]:P),F=(0,_reactNativeReanimated.useSharedValue)(q?P[1]:P),z=(0,_reactNativeReanimated.useSharedValue)(0),J=(0,_reactNativeReanimated.useSharedValue)(0),U=(0,_reactNativeReanimated.useSharedValue)(1),Z=(0,_reactNativeReanimated.useSharedValue)(1),$="always"===o,K=(0,_reactNativeReanimated.useSharedValue)($?1:0),Q=(0,_reactNativeReanimated.useSharedValue)($?1:0),Y=(0,_react.useMemo)(()=>10**(String(r).split(".")[1]?.length??0),[r]);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(X),(0,_reactNativeReanimated.cancelAnimation)(B),(0,_reactNativeReanimated.cancelAnimation)(U),(0,_reactNativeReanimated.cancelAnimation)(Z),(0,_reactNativeReanimated.cancelAnimation)(K),(0,_reactNativeReanimated.cancelAnimation)(Q)},[X,B,U,Z,K,Q]);const ee=(0,_react.useCallback)((e,t)=>{const r=t-2*C;return i===a||r<=0?C:C+(e-a)/(i-a)*r},[a,i,C]),te=(0,_react.useCallback)((e,t)=>{const n=t-2*C;if(n<=0)return a;const s=clamp((e-C)/n,0,1);return snapToStep(a+s*(i-a),a,i,r)},[a,i,r,C]),ae=(0,_react.useRef)(!1),ie=S.motion.duration.fast,re=(0,_react.useRef)(P);re.current=P;const ne=(0,_react.useRef)(E);ne.current=E;const se=(0,_react.useCallback)((e=!1)=>{const t=ne.current;if(t<=0)return;const place=t=>e?(0,_reactNativeReanimated.withTiming)(t,{duration:ie,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}):t,a=re.current;if(q){const[e,i]=a,r=Math.min(e,i),n=Math.max(e,i);G.value=r,F.value=n,X.value=place(ee(r,t)),B.value=place(ee(n,t))}else{const e=a;G.value=e,F.value=e,X.value=place(ee(e,t))}},[q,ee,G,F,X,B,ie]),[le,ce]=(0,_react.useState)(0),oe=(0,_react.useRef)(!1),ue=(0,_react.useCallback)(e=>{ae.current=e,e||(oe.current=!0,ce(e=>e+1))},[]);(0,_react.useEffect)(()=>{if(ae.current)return;const e=oe.current;oe.current=!1,se(e)},[JSON.stringify(P),E,le,se]);const de=(0,_react.useCallback)(e=>{const t=e.nativeEvent.layout.width;J.value=t,T(t)},[J]),me=(0,_react.useCallback)((e,t)=>{L(q?[e,t]:e)},[q,L]),he=(0,_react.useCallback)(()=>{const e=(0,_index3.resolveHaptic)(_,"selection");e&&(0,_index3.triggerHaptic)(e)},[_]),ve=(0,_react.useRef)(me);ve.current=me;const be=(0,_react.useRef)(he);be.current=he;const pe=(0,_react.useCallback)((e,t)=>ve.current(e,t),[]),fe=(0,_react.useCallback)(()=>be.current(),[]),ge=Math.max(0,(44-j.thumbDiameter)/2),Re=ge>0?ge:void 0,we=(0,_react.useCallback)(e=>{const t="low"===e?X:B,s="low"===e?G:F,l="low"===e?F:G,c="low"===e?U:Z,d="low"===e?K:Q,m="low"===e,h=a,_=i,v=r,b=Y,p=q,f=V,g=M,R=!0===o,w=u,x=O,y=H,N=A,S=C,follow=e=>{"worklet";const a=J.value-2*S;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(z.value+e,S),J.value-S);let r=h+(i-S)/a*(_-h);v>0&&(r=Math.round((r-h)/v)*v+h,r=Math.round(r*b)/b),r=Math.min(Math.max(r,h),_),p&&(m&&r>l.value&&(r=l.value),!m&&r<l.value&&(r=l.value)),t.value=w||_===h?_===h?S:S+(r-h)/(_-h)*a:p?m?Math.min(i,B.value):Math.max(i,X.value):i,r!==s.value&&(s.value=r,r!==h&&r!==_||(0,_reactNativeReanimated.runOnJS)(fe)(),(0,_reactNativeReanimated.runOnJS)(pe)(G.value,F.value))},k=_reactNativeGestureHandler.Gesture.Pan().enabled(!n).minDistance(0);return(void 0===Re?k:k.hitSlop(Re)).onStart(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(ue)(!0),z.value=t.value,g&&(c.value=(0,_reactNativeReanimated.withSpring)(f,N)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(x,{duration:y,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)})),(0,_reactNativeReanimated.runOnJS)(fe)()}).onUpdate(e=>{"worklet";follow(e.translationX)}).onEnd(e=>{"worklet";follow(e.translationX),g&&(c.value=(0,_reactNativeReanimated.withSpring)(1,N)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(0,{duration:y,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}))}).onFinalize(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(ue)(!1)})},[n,a,i,r,Y,q,V,M,o,u,O,H,A,C,Re,pe,fe,ue,X,B,G,F,U,Z,K,Q,z,J]),xe=(0,_react.useMemo)(()=>we("low"),[we]),ye=(0,_react.useMemo)(()=>we("high"),[we]),Ne=(0,_react.useCallback)(e=>{if(n||q||E<=0)return;const t=clamp(e.nativeEvent.locationX,0,E),a=te(t,E);a!==G.value&&(he(),G.value=a,X.value=(0,_reactNativeReanimated.withTiming)(ee(a,E),{duration:S.motion.duration.fast,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}),me(a,a))},[n,q,E,te,ee,me,he,X,G,S.motion.duration.fast]),Se=(0,_react.useCallback)(e=>{if(n)return;const t="increment"===e.nativeEvent.actionName?r:-r,s=r>0?Math.round(t*Y)/Y:t;if(q){const e=Math.round((G.value+s)*Y)/Y,t=clamp(e,a,F.value);t!==G.value&&(G.value=t,X.value=ee(t,E),he(),me(t,F.value))}else{const e=Math.round((G.value+s)*Y)/Y,t=clamp(e,a,i);t!==G.value&&(G.value=t,X.value=ee(t,E),he(),me(t,t))}},[n,r,Y,q,a,i,ee,E,X,G,F,me,he]),ke=j.thumbDiameter/2,je=n?S.colors["surface-disabled"]:I,Ce="inset"===c?{backgroundColor:je,borderColor:S.colors.surface,borderWidth:Math.max(2,Math.round(.3*j.thumbDiameter)),...NO_SHADOW}:"minimal"===c?{backgroundColor:je,borderWidth:0}:"bar"===c?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:S.colors.surface,borderColor:je},Me=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=J.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=n?.55:1;if(q){const a=Math.max(0,B.value-X.value+2*C);return{opacity:t,transform:[{translateX:X.value-C},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:X.value+C-e},{scaleX:1}]}}),Ve=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:X.value-ke},{scale:U.value}]})),He=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:B.value-ke},{scale:Z.value}]})),Oe=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:K.value})),De=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:Q.value})),clampDisplay=e=>clamp(e,a,i),Ae=clampDisplay(q?Math.min(...P):P),Ee=clampDisplay(q?Math.max(...P):P);return(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:[D.container,b,v],testID:N,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:n},"aria-disabled":n,accessibilityValue:q?{min:a,max:i,now:Ae,text:`${Ae} to ${Ee}`}:{min:a,max:i,now:Ae},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Se,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Ne,disabled:n||q,style:D.trackTouch,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:D.trackWrap,onLayout:de,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:D.trackClip,pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.track,{backgroundColor:n?S.colors["surface-disabled"]:S.colors.border},p]}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[D.fill,{backgroundColor:n?S.colors["surface-disabled"]:I},f,Me]})]}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:xe,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[D.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:ke,..._corners.smoothCorners,opacity:n?.55:1},Ce,g,Ve],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[D.bubbleWrap,Oe],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubble,{backgroundColor:I}],children:m?m(Ae):(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",style:[{color:W},R],numberOfLines:1,children:d(Ae)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubbleCaret,{backgroundColor:I}]})]}):null})}),q?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ye,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[D.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:ke,..._corners.smoothCorners,opacity:n?.55:1},Ce,g,He],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[D.bubbleWrap,De],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubble,{backgroundColor:I}],children:m?m(Ee):(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",style:[{color:W},R],numberOfLines:1,children:d(Ee)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubbleCaret,{backgroundColor:I}]})]}):null})}):null]})})})});Slider.displayName="Slider";const buildStyles=(e,t)=>{const a=e.shadow.elevated,i=Math.max(t.thumbDiameter,t.trackHeight),r=i/2+e.space.xs;return _reactNative.StyleSheet.create({container:{width:"100%",paddingVertical:r,justifyContent:"center"},trackTouch:{width:"100%",justifyContent:"center"},trackWrap:{width:"100%",height:i,justifyContent:"center"},trackClip:{position:"absolute",left:0,right:0,height:t.trackHeight,top:(i-t.trackHeight)/2,borderRadius:t.trackHeight/2,..._corners.smoothCorners,overflow:"hidden"},track:{position:"absolute",top:0,right:0,bottom:0,left:0,borderRadius:t.trackHeight/2,..._corners.smoothCorners},fill:{position:"absolute",top:0,left:0,width:"100%",height:t.trackHeight,borderRadius:t.trackHeight/2,..._corners.smoothCorners,transformOrigin:"left"},thumb:{position:"absolute",top:(i-t.thumbDiameter)/2,left:0,borderWidth:2,shadowColor:a.shadowColor,shadowOffset:a.shadowOffset,shadowOpacity:a.shadowOpacity,shadowRadius:a.shadowRadius,elevation:a.elevation,alignItems:"center",justifyContent:"center"},bubbleWrap:{position:"absolute",bottom:t.thumbDiameter+2,left:t.thumbDiameter/2-80,width:160,alignItems:"center"},bubbleCaret:{width:8,height:8,marginTop:-5,borderRadius:e.radius.none,..._corners.smoothCorners,transform:[{rotate:"45deg"}]},bubble:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xxs,borderRadius:e.radius.md,..._corners.smoothCorners,minWidth:36,alignItems:"center",justifyContent:"center",..._reactNative.Platform.select({ios:{shadowColor:e.shadow.card.shadowColor,shadowOffset:e.shadow.card.shadowOffset,shadowOpacity:e.shadow.card.shadowOpacity,shadowRadius:e.shadow.card.shadowRadius},android:{elevation:e.shadow.card.elevation},default:{}})}})};var _default=exports.default=Slider;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Slider=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_index4=require("../Text/index.js"),_valueText=require("./valueText.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,i,r=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(i in e)"default"!==i&&{}.hasOwnProperty.call(e,i)&&((a=r&&Object.getOwnPropertyDescriptor(e,i))&&(a.get||a.set)?r(n,i,a):n[i]=e[i]);return n}const VARIANT_SIZE_MAP={inset:{sm:{trackHeight:14,thumbDiameter:10},md:{trackHeight:20,thumbDiameter:14},lg:{trackHeight:26,thumbDiameter:18}},minimal:{sm:{trackHeight:2,thumbDiameter:14},md:{trackHeight:3,thumbDiameter:18},lg:{trackHeight:4,thumbDiameter:22}},bar:{sm:{trackHeight:20,thumbDiameter:20},md:{trackHeight:28,thumbDiameter:28},lg:{trackHeight:36,thumbDiameter:36}}},INSET_RING_RATIO=.3,MIN_THUMB_TOUCH=44,clamp=(e,t,a)=>Math.min(Math.max(e,t),a),snapToStep=(e,t,a,i)=>{if(i<=0)return clamp(e,t,a);const r=Math.round((e-t)/i)*i+t,n=String(i).split(".")[1]?.length??0,s=n>0?Number(r.toFixed(n)):r;return clamp(s,t,a)},BUBBLE_GAP=2,BUBBLE_CARET=8,BUBBLE_WRAP_WIDTH=160,NO_SHADOW={shadowOpacity:0,elevation:0},defaultFormatLabel=e=>String(e),Slider=exports.Slider=(0,_react.forwardRef)((e,t)=>{const{min:a=0,max:i=100,step:r=1,disabled:n=!1,tone:s="primary",size:l="md",variant:c="default",showLabel:o=!1,snapThumb:u=!1,formatLabel:d=defaultFormatLabel,renderLabel:m,accessibilityLabel:h,haptic:_,style:v,containerStyle:b,trackStyle:p,fillStyle:f,thumbStyle:g,labelStyle:R,thumbPressScale:w,labelShowDuration:x,labelOpacity:y,testID:N}=e;(0,_warnInvalidValue.warnInvalidValue)("Slider","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_warnInvalidValue.warnInvalidValue)("Slider","size",e.size,["sm","md","lg"]),(0,_warnInvalidValue.warnInvalidValue)("Slider","variant",e.variant,["default","inset","minimal","bar"]);const S=(0,_index2.useTheme)(),k=(0,_react.useMemo)(()=>{const e=(0,_index2.resolveSliderSize)(S,l);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[S,l]),j=(0,_react.useMemo)(()=>"default"===c?k:VARIANT_SIZE_MAP[c][l],[k,l,c]),C="inset"===c?j.trackHeight/2:0,M=S.settings.components.slider?.thumbPressAnimation??!1,V=w??1.1,H=x??S.motion.duration.fast,O=y??1,D=(0,_react.useMemo)(()=>buildStyles(S,j),[S,j]),A=(0,_react.useMemo)(()=>({damping:S.motion.spring.snappy.damping,stiffness:S.motion.spring.snappy.stiffness,mass:S.motion.spring.snappy.mass}),[S.motion.spring.snappy]),[E,T]=(0,_react.useState)(0),I=S.colors[s],W=(0,_valueText.sliderToneInk)(S,s),q=!0===e.range,[P,L]=(0,_index.useControllableState)({value:e.value,defaultValue:e.defaultValue??(q?[a,i]:a),onChange:e.onChange}),X=(0,_reactNativeReanimated.useSharedValue)(0),B=(0,_reactNativeReanimated.useSharedValue)(0),G=(0,_reactNativeReanimated.useSharedValue)(q?P[0]:P),F=(0,_reactNativeReanimated.useSharedValue)(q?P[1]:P),z=(0,_reactNativeReanimated.useSharedValue)(0),J=(0,_reactNativeReanimated.useSharedValue)(0),U=(0,_reactNativeReanimated.useSharedValue)(1),Z=(0,_reactNativeReanimated.useSharedValue)(1),$="always"===o,K=(0,_reactNativeReanimated.useSharedValue)($?1:0),Q=(0,_reactNativeReanimated.useSharedValue)($?1:0),Y=(0,_react.useMemo)(()=>10**(String(r).split(".")[1]?.length??0),[r]);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(X),(0,_reactNativeReanimated.cancelAnimation)(B),(0,_reactNativeReanimated.cancelAnimation)(U),(0,_reactNativeReanimated.cancelAnimation)(Z),(0,_reactNativeReanimated.cancelAnimation)(K),(0,_reactNativeReanimated.cancelAnimation)(Q)},[X,B,U,Z,K,Q]);const ee=(0,_react.useCallback)((e,t)=>{const r=t-2*C;return i===a||r<=0?C:C+(e-a)/(i-a)*r},[a,i,C]),te=(0,_react.useCallback)((e,t)=>{const n=t-2*C;if(n<=0)return a;const s=clamp((e-C)/n,0,1);return snapToStep(a+s*(i-a),a,i,r)},[a,i,r,C]),ae=(0,_react.useRef)(!1),ie=S.motion.duration.fast,re=(0,_react.useRef)(P);re.current=P;const ne=(0,_react.useRef)(E);ne.current=E;const se=(0,_react.useCallback)((e=!1)=>{const t=ne.current;if(t<=0)return;const place=t=>e?(0,_reactNativeReanimated.withTiming)(t,{duration:ie,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}):t,a=re.current;if(q){const[e,i]=a,r=Math.min(e,i),n=Math.max(e,i);G.value=r,F.value=n,X.value=place(ee(r,t)),B.value=place(ee(n,t))}else{const e=a;G.value=e,F.value=e,X.value=place(ee(e,t))}},[q,ee,G,F,X,B,ie]),[le,ce]=(0,_react.useState)(0),oe=(0,_react.useRef)(!1),ue=(0,_react.useCallback)(e=>{ae.current=e,e||(oe.current=!0,ce(e=>e+1))},[]);(0,_react.useEffect)(()=>{if(ae.current)return;const e=oe.current;oe.current=!1,se(e)},[JSON.stringify(P),E,le,se]);const de=(0,_react.useCallback)(e=>{const t=e.nativeEvent.layout.width;J.value=t,T(t)},[J]),me=(0,_react.useCallback)((e,t)=>{L(q?[e,t]:e)},[q,L]),he=(0,_react.useCallback)(()=>{const e=(0,_index3.resolveHaptic)(_,"selection");e&&(0,_index3.triggerHaptic)(e)},[_]),ve=(0,_react.useRef)(me);ve.current=me;const be=(0,_react.useRef)(he);be.current=he;const pe=(0,_react.useCallback)((e,t)=>ve.current(e,t),[]),fe=(0,_react.useCallback)(()=>be.current(),[]),ge=Math.max(0,(44-j.thumbDiameter)/2),Re=ge>0?ge:void 0,we=(0,_react.useCallback)(e=>{const t="low"===e?X:B,s="low"===e?G:F,l="low"===e?F:G,c="low"===e?U:Z,d="low"===e?K:Q,m="low"===e,h=a,_=i,v=r,b=Y,p=q,f=V,g=M,R=!0===o,w=u,x=O,y=H,N=A,S=C,follow=e=>{"worklet";const a=J.value-2*S;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(z.value+e,S),J.value-S);let r=h+(i-S)/a*(_-h);v>0&&(r=Math.round((r-h)/v)*v+h,r=Math.round(r*b)/b),r=Math.min(Math.max(r,h),_),p&&(m&&r>l.value&&(r=l.value),!m&&r<l.value&&(r=l.value)),t.value=w||_===h?_===h?S:S+(r-h)/(_-h)*a:p?m?Math.min(i,B.value):Math.max(i,X.value):i,r!==s.value&&(s.value=r,r!==h&&r!==_||(0,_reactNativeReanimated.runOnJS)(fe)(),(0,_reactNativeReanimated.runOnJS)(pe)(G.value,F.value))},k=_reactNativeGestureHandler.Gesture.Pan().enabled(!n).minDistance(0);return(void 0===Re?k:k.hitSlop(Re)).onStart(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(ue)(!0),z.value=t.value,g&&(c.value=(0,_reactNativeReanimated.withSpring)(f,N)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(x,{duration:y,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)})),(0,_reactNativeReanimated.runOnJS)(fe)()}).onUpdate(e=>{"worklet";follow(e.translationX)}).onEnd(e=>{"worklet";follow(e.translationX),g&&(c.value=(0,_reactNativeReanimated.withSpring)(1,N)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(0,{duration:y,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}))}).onFinalize(()=>{"worklet";(0,_reactNativeReanimated.runOnJS)(ue)(!1)})},[n,a,i,r,Y,q,V,M,o,u,O,H,A,C,Re,pe,fe,ue,X,B,G,F,U,Z,K,Q,z,J]),xe=(0,_react.useMemo)(()=>we("low"),[we]),ye=(0,_react.useMemo)(()=>we("high"),[we]),Ne=(0,_react.useCallback)(e=>{if(n||q||E<=0)return;const t=clamp(e.nativeEvent.locationX,0,E),a=te(t,E);a!==G.value&&(he(),G.value=a,X.value=(0,_reactNativeReanimated.withTiming)(ee(a,E),{duration:S.motion.duration.fast,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}),me(a,a))},[n,q,E,te,ee,me,he,X,G,S.motion.duration.fast]),Se=(0,_react.useCallback)(e=>{if(n)return;const t="increment"===e.nativeEvent.actionName?r:-r,s=r>0?Math.round(t*Y)/Y:t;if(q){const e=Math.round((G.value+s)*Y)/Y,t=clamp(e,a,F.value);t!==G.value&&(G.value=t,X.value=ee(t,E),he(),me(t,F.value))}else{const e=Math.round((G.value+s)*Y)/Y,t=clamp(e,a,i);t!==G.value&&(G.value=t,X.value=ee(t,E),he(),me(t,t))}},[n,r,Y,q,a,i,ee,E,X,G,F,me,he]),ke=j.thumbDiameter/2,je=n?S.colors["surface-disabled"]:I,Ce="inset"===c?{backgroundColor:je,borderColor:S.colors.surface,borderWidth:Math.max(2,Math.round(.3*j.thumbDiameter)),...NO_SHADOW}:"minimal"===c?{backgroundColor:je,borderWidth:0}:"bar"===c?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:S.colors.surface,borderColor:je},Me=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=J.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=n?.55:1;if(q){const a=Math.max(0,B.value-X.value+2*C);return{opacity:t,transform:[{translateX:X.value-C},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:X.value+C-e},{scaleX:1}]}},[J,n,q,B,X,C]),Ve=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:X.value-ke},{scale:U.value}]}),[X,ke,U]),He=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:B.value-ke},{scale:Z.value}]}),[B,ke,Z]),Oe=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:K.value}),[K]),De=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:Q.value}),[Q]),clampDisplay=e=>clamp(e,a,i),Ae=clampDisplay(q?Math.min(...P):P),Ee=clampDisplay(q?Math.max(...P):P);return(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:[D.container,b,v],testID:N,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:n},"aria-disabled":n,accessibilityValue:q?{min:a,max:i,now:Ae,text:`${Ae} to ${Ee}`}:{min:a,max:i,now:Ae},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Se,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Ne,disabled:n||q,style:D.trackTouch,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:D.trackWrap,onLayout:de,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:D.trackClip,pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.track,{backgroundColor:n?S.colors["surface-disabled"]:S.colors.border},p]}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[D.fill,{backgroundColor:n?S.colors["surface-disabled"]:I},f,Me]})]}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:xe,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[D.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:ke,..._corners.smoothCorners,opacity:n?.55:1},Ce,g,Ve],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[D.bubbleWrap,Oe],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubble,{backgroundColor:I}],children:m?m(Ae):(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",style:[{color:W},R],numberOfLines:1,children:d(Ae)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubbleCaret,{backgroundColor:I}]})]}):null})}),q?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ye,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[D.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:ke,..._corners.smoothCorners,opacity:n?.55:1},Ce,g,He],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[D.bubbleWrap,De],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubble,{backgroundColor:I}],children:m?m(Ee):(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",weight:"semibold",style:[{color:W},R],numberOfLines:1,children:d(Ee)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[D.bubbleCaret,{backgroundColor:I}]})]}):null})}):null]})})})});Slider.displayName="Slider";const buildStyles=(e,t)=>{const a=e.shadow.elevated,i=Math.max(t.thumbDiameter,t.trackHeight),r=i/2+e.space.xs;return _reactNative.StyleSheet.create({container:{width:"100%",paddingVertical:r,justifyContent:"center"},trackTouch:{width:"100%",justifyContent:"center"},trackWrap:{width:"100%",height:i,justifyContent:"center"},trackClip:{position:"absolute",left:0,right:0,height:t.trackHeight,top:(i-t.trackHeight)/2,borderRadius:t.trackHeight/2,..._corners.smoothCorners,overflow:"hidden"},track:{position:"absolute",top:0,right:0,bottom:0,left:0,borderRadius:t.trackHeight/2,..._corners.smoothCorners},fill:{position:"absolute",top:0,left:0,width:"100%",height:t.trackHeight,borderRadius:t.trackHeight/2,..._corners.smoothCorners,transformOrigin:"left"},thumb:{position:"absolute",top:(i-t.thumbDiameter)/2,left:0,borderWidth:2,shadowColor:a.shadowColor,shadowOffset:a.shadowOffset,shadowOpacity:a.shadowOpacity,shadowRadius:a.shadowRadius,elevation:a.elevation,alignItems:"center",justifyContent:"center"},bubbleWrap:{position:"absolute",bottom:t.thumbDiameter+2,left:t.thumbDiameter/2-80,width:160,alignItems:"center"},bubbleCaret:{width:8,height:8,marginTop:-5,borderRadius:e.radius.none,..._corners.smoothCorners,transform:[{rotate:"45deg"}]},bubble:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xxs,borderRadius:e.radius.md,..._corners.smoothCorners,minWidth:36,alignItems:"center",justifyContent:"center",..._reactNative.Platform.select({ios:{shadowColor:e.shadow.card.shadowColor,shadowOffset:e.shadow.card.shadowOffset,shadowOpacity:e.shadow.card.shadowOpacity,shadowRadius:e.shadow.card.shadowRadius},android:{elevation:e.shadow.card.elevation},default:{}})}})};var _default=exports.default=Slider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_SORTABLE_LIST_LABELS=void 0,exports.SortableList=SortableList,exports.default=void 0,exports.dropIndex=dropIndex,exports.moveItem=moveItem,exports.rowShifts=rowShifts,exports.slotTop=slotTop,exports.topOf=topOf;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_ScrollHost=require("../Screen/ScrollHost.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,l=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=l&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?l(n,r,a):n[r]=e[r]);return n}const DEFAULT_SORTABLE_LIST_LABELS=exports.DEFAULT_SORTABLE_LIST_LABELS=Object.freeze({moveUp:"Move up",moveDown:"Move down"}),LONG_PRESS_MS=350,EDGE_PX=48,SCROLL_STEP_PX=12,SCROLL_SLACK_PX=1,SPRING_CONFIG={damping:22,stiffness:260,mass:1},ACTION_STEP={moveUp:-1,moveDown:1},noop=e=>{};function moveItem(e,t,a){const r=e.slice();if(t<0||t>=r.length)return r;const[l]=r.splice(t,1);return r.splice(a,0,l),r}function topOf(e,t){"worklet";let a=0;for(let r=0;r<t;r++)a+=e[r]??0;return a}function slotTop(e,t,a){"worklet";let r=0,l=0;for(let n=0;n<e.length&&l<a;n++)n!==t&&(r+=e[n]??0,l++);return r}function dropIndex(e,t,a){"worklet";const r=topOf(e,t)+(e[t]??0)/2+a;let l=0,n=0;for(let a=0;a<e.length;a++){const i=e[a]??0;a!==t&&n+i/2<r&&l++,n+=i}return l}function rowShifts(e,t,a){const r=[];let l=0;for(const t of e)r.push(l),l+=t;const n=e.map(()=>0),i=moveItem(e.map((e,t)=>t),t,a);let o=0;for(const t of i)n[t]=o-(r[t]??0),o+=e[t]??0;return n}const buildStyles=e=>_reactNative.StyleSheet.create({handleRow:{flexDirection:"row",alignItems:"center"},handle:{paddingHorizontal:e.space.sm,paddingVertical:e.space.md,gap:e.space.xxs},bar:{width:e.space.md,height:e.space.xxs,backgroundColor:e.colors["text-muted"]},body:{flex:1}});function SortableRow({rowKey:e,index:t,count:a,shift:r,isActive:l,dragging:n,handle:i,disabled:o,shared:s,callbacks:c,labels:u,children:d}){const v=(0,_index.useTheme)(),_=(0,_react.useMemo)(()=>buildStyles(v),[v]),m=(0,_reactNativeReanimated.useSharedValue)(0);(0,_react.useEffect)(()=>{m.value=n&&!l?(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG):r},[n,l,r,m]),(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(m)},[m]);const S=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateY:l?s.dragY.value:m.value}],zIndex:l?1:0})),h=(0,_react.useMemo)(()=>{const{dragIndex:e,dropTo:a,dragY:r,translation:l,absoluteY:n,scrollY:u,scrollStart:d,hostOffset:v,hostStart:_,hostTarget:m,heights:S}=s,{onLift:h,onDrop:f,onSettled:p}=c,R=_reactNativeGestureHandler.Gesture.Pan().enabled(!o).onStart(i=>{"worklet";n.value=i.absoluteY,e.value=t,a.value=t,d.value=u.value,_.value=v.value,m.value=v.value,l.value=0,r.value=0,(0,_reactNativeReanimated.runOnJS)(h)(t)}).onUpdate(a=>{"worklet";e.value===t&&(l.value=a.translationY,n.value=a.absoluteY)}).onFinalize(()=>{"worklet";if(e.value!==t)return;const l=a.value,n=S.value;e.value=-1,r.value=topOf(n,t)+r.value-slotTop(n,t,l),r.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(p)()}),(0,_reactNativeReanimated.runOnJS)(f)(t,l)});return i?R:R.activateAfterLongPress(350)},[o,i,t,c,s]),f=o?[]:[...t>0?[{name:"moveUp",label:u.moveUp}]:[],...t<a-1?[{name:"moveDown",label:u.moveDown}]:[]];return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:S,onLayout:t=>c.onHeight(e,t.nativeEvent.layout.height),accessibilityActions:f,onAccessibilityAction:e=>{if(o)return;const r=t+(ACTION_STEP[e.nativeEvent.actionName]??0);r!==t&&r>=0&&r<a&&c.onMove(t,r)},testID:`sortable-row-${e}`,children:i?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.handleRow,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:h,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.handle,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.body,children:d})]}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:h,children:(0,_jsxRuntime.jsx)(_reactNative.View,{children:d})})})}function SortableList(e){const{data:t,keyExtractor:a,renderItem:r,onReorder:l,handle:n=!1,disabled:i=!1,accessibilityLabel:o,labels:s,testID:c}=e,u=(0,_react.useMemo)(()=>({...DEFAULT_SORTABLE_LIST_LABELS,...s}),[s]),d=(0,_react.useMemo)(()=>t.map((e,t)=>({key:a(e,t),item:e})),[t,a]),v=(0,_react.useMemo)(()=>d.map(e=>e.key),[d]),_=(0,_reactNativeReanimated.useAnimatedRef)(),m=(0,_reactNativeReanimated.useSharedValue)(0),S=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),f=(0,_ScrollHost.useScrollHost)(),p=(0,_reactNativeReanimated.useSharedValue)(0),R=null!==f,g=f?.top??p,x=f?.bottom??p,N=f?.offset??p,b=f?.maxOffset??p,L=f?.scrollTo??noop,w=(0,_reactNativeReanimated.useSharedValue)(0),O=(0,_reactNativeReanimated.useSharedValue)(0),y=(0,_reactNativeReanimated.useSharedValue)(0),E=(0,_reactNativeReanimated.useSharedValue)(0),j=(0,_reactNativeReanimated.useSharedValue)(-1),T=(0,_reactNativeReanimated.useSharedValue)(-1),k=(0,_reactNativeReanimated.useSharedValue)(0),A=(0,_reactNativeReanimated.useSharedValue)([]),I=(0,_react.useRef)(new Map),P=(0,_react.useRef)(v),[C,M]=(0,_react.useState)(null),V=(0,_react.useCallback)(()=>{A.value=P.current.map(e=>I.current.get(e)??0)},[A]);(0,_react.useEffect)(()=>{P.current=v,V()},[v,V]),(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(k)},[k]);const D=(0,_react.useCallback)(e=>{M(t=>t?.dragging?{...t,to:e}:t)},[]),G=(0,_reactNativeReanimated.useFrameCallback)(()=>{"worklet";const e=j.value;if(e<0)return;const t=(0,_reactNativeReanimated.measure)(_);if(t){const e=R?Math.max(t.pageY,g.value):t.pageY,a=R?Math.min(t.pageY+t.height,x.value):t.pageY+t.height,r=Math.max(0,h.value-t.height-SCROLL_SLACK_PX);E.value<e+EDGE_PX?m.value>SCROLL_SLACK_PX?(0,_reactNativeReanimated.scrollTo)(_,0,Math.max(0,m.value-SCROLL_STEP_PX),!1):R&&O.value>0&&(O.value=Math.max(0,O.value-SCROLL_STEP_PX),(0,_reactNativeReanimated.runOnJS)(L)(O.value)):E.value>a-EDGE_PX&&(m.value<r?(0,_reactNativeReanimated.scrollTo)(_,0,Math.min(r,m.value+SCROLL_STEP_PX),!1):R&&O.value<b.value&&(O.value=Math.min(b.value,O.value+SCROLL_STEP_PX),(0,_reactNativeReanimated.runOnJS)(L)(O.value)))}k.value=y.value+m.value-S.value+N.value-w.value;const a=dropIndex(A.value,e,k.value);a!==T.value&&(T.value=a,(0,_reactNativeReanimated.runOnJS)(D)(a))},!1),Y=(0,_react.useCallback)(e=>{(0,_index2.triggerHaptic)("longPress"),G.setActive(!0),M({key:v[e]??"",from:e,to:e,dragging:!0})},[G,v]),H=(0,_react.useCallback)((e,t)=>{G.setActive(!1),M(e=>e?{...e,to:t,dragging:!1}:e),t!==e&&l(moveItem(v,e,t))},[G,v,l]),X=(0,_react.useCallback)(()=>{M(e=>e&&!e.dragging?null:e)},[]),q=(0,_react.useCallback)((e,t)=>{l(moveItem(v,e,t))},[v,l]),F=(0,_react.useCallback)((e,t)=>{I.current.set(e,t),V()},[V]),U=(0,_reactNativeReanimated.useAnimatedScrollHandler)({onScroll:e=>{"worklet";m.value=e.contentOffset.y}}),B=(0,_react.useCallback)((e,t)=>{h.value=t},[h]),J=(0,_react.useMemo)(()=>({scrollRef:_,scrollY:m,scrollStart:S,hostOffset:N,hostStart:w,hostTarget:O,translation:y,absoluteY:E,dragIndex:j,dropTo:T,dragY:k,heights:A}),[_,m,S,N,w,O,y,E,j,T,k,A]),z=(0,_react.useMemo)(()=>({onLift:Y,onDrop:H,onSettled:X,onMove:q,onHeight:F}),[Y,H,X,q,F]),K=!0===C?.dragging,W=K&&C?rowShifts(v.map(e=>I.current.get(e)??0),C.from,C.to):null;return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.ScrollView,{ref:_,onScroll:U,onContentSizeChange:B,scrollEventThrottle:16,scrollEnabled:!K,accessibilityLabel:o,testID:c,children:d.map((e,t)=>{const a=C?.key===e.key;return(0,_jsxRuntime.jsx)(SortableRow,{rowKey:e.key,index:t,count:d.length,shift:W?.[t]??0,isActive:a,dragging:K,handle:n,disabled:i,shared:J,callbacks:z,labels:u,children:r({item:e.item,index:t,isActive:a})},e.key)})})}SortableList.displayName="SortableList";var _default=exports.default=SortableList;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_SORTABLE_LIST_LABELS=void 0,exports.SortableList=SortableList,exports.default=void 0,exports.dropIndex=dropIndex,exports.moveItem=moveItem,exports.rowShifts=rowShifts,exports.slotTop=slotTop,exports.topOf=topOf;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_ScrollHost=require("../Screen/ScrollHost.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,l=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=l&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?l(n,r,a):n[r]=e[r]);return n}const DEFAULT_SORTABLE_LIST_LABELS=exports.DEFAULT_SORTABLE_LIST_LABELS=Object.freeze({moveUp:"Move up",moveDown:"Move down"}),LONG_PRESS_MS=350,EDGE_PX=48,SCROLL_STEP_PX=12,SCROLL_SLACK_PX=1,SPRING_CONFIG={damping:22,stiffness:260,mass:1},ACTION_STEP={moveUp:-1,moveDown:1},noop=e=>{};function moveItem(e,t,a){const r=e.slice();if(t<0||t>=r.length)return r;const[l]=r.splice(t,1);return r.splice(a,0,l),r}function topOf(e,t){"worklet";let a=0;for(let r=0;r<t;r++)a+=e[r]??0;return a}function slotTop(e,t,a){"worklet";let r=0,l=0;for(let n=0;n<e.length&&l<a;n++)n!==t&&(r+=e[n]??0,l++);return r}function dropIndex(e,t,a){"worklet";const r=topOf(e,t)+(e[t]??0)/2+a;let l=0,n=0;for(let a=0;a<e.length;a++){const i=e[a]??0;a!==t&&n+i/2<r&&l++,n+=i}return l}function rowShifts(e,t,a){const r=[];let l=0;for(const t of e)r.push(l),l+=t;const n=e.map(()=>0),i=moveItem(e.map((e,t)=>t),t,a);let o=0;for(const t of i)n[t]=o-(r[t]??0),o+=e[t]??0;return n}const buildStyles=e=>_reactNative.StyleSheet.create({handleRow:{flexDirection:"row",alignItems:"center"},handle:{paddingHorizontal:e.space.sm,paddingVertical:e.space.md,gap:e.space.xxs},bar:{width:e.space.md,height:e.space.xxs,backgroundColor:e.colors["text-muted"]},body:{flex:1}});function SortableRow({rowKey:e,index:t,count:a,shift:r,isActive:l,dragging:n,handle:i,disabled:o,shared:s,callbacks:c,labels:u,children:d}){const v=(0,_index.useTheme)(),_=(0,_react.useMemo)(()=>buildStyles(v),[v]),m=(0,_reactNativeReanimated.useSharedValue)(0);(0,_react.useEffect)(()=>{m.value=n&&!l?(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG):r},[n,l,r,m]),(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(m)},[m]);const S=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateY:l?s.dragY.value:m.value}],zIndex:l?1:0}),[l,s,m]),h=(0,_react.useMemo)(()=>{const{dragIndex:e,dropTo:a,dragY:r,translation:l,absoluteY:n,scrollY:u,scrollStart:d,hostOffset:v,hostStart:_,hostTarget:m,heights:S}=s,{onLift:h,onDrop:f,onSettled:p}=c,R=_reactNativeGestureHandler.Gesture.Pan().enabled(!o).onStart(i=>{"worklet";n.value=i.absoluteY,e.value=t,a.value=t,d.value=u.value,_.value=v.value,m.value=v.value,l.value=0,r.value=0,(0,_reactNativeReanimated.runOnJS)(h)(t)}).onUpdate(a=>{"worklet";e.value===t&&(l.value=a.translationY,n.value=a.absoluteY)}).onFinalize(()=>{"worklet";if(e.value!==t)return;const l=a.value,n=S.value;e.value=-1,r.value=topOf(n,t)+r.value-slotTop(n,t,l),r.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(p)()}),(0,_reactNativeReanimated.runOnJS)(f)(t,l)});return i?R:R.activateAfterLongPress(350)},[o,i,t,c,s]),f=o?[]:[...t>0?[{name:"moveUp",label:u.moveUp}]:[],...t<a-1?[{name:"moveDown",label:u.moveDown}]:[]];return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:S,onLayout:t=>c.onHeight(e,t.nativeEvent.layout.height),accessibilityActions:f,onAccessibilityAction:e=>{if(o)return;const r=t+(ACTION_STEP[e.nativeEvent.actionName]??0);r!==t&&r>=0&&r<a&&c.onMove(t,r)},testID:`sortable-row-${e}`,children:i?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.handleRow,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:h,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_.handle,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.bar})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:_.body,children:d})]}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:h,children:(0,_jsxRuntime.jsx)(_reactNative.View,{children:d})})})}function SortableList(e){const{data:t,keyExtractor:a,renderItem:r,onReorder:l,handle:n=!1,disabled:i=!1,accessibilityLabel:o,labels:s,testID:c}=e,u=(0,_react.useMemo)(()=>({...DEFAULT_SORTABLE_LIST_LABELS,...s}),[s]),d=(0,_react.useMemo)(()=>t.map((e,t)=>({key:a(e,t),item:e})),[t,a]),v=(0,_react.useMemo)(()=>d.map(e=>e.key),[d]),_=(0,_reactNativeReanimated.useAnimatedRef)(),m=(0,_reactNativeReanimated.useSharedValue)(0),S=(0,_reactNativeReanimated.useSharedValue)(0),h=(0,_reactNativeReanimated.useSharedValue)(0),f=(0,_ScrollHost.useScrollHost)(),p=(0,_reactNativeReanimated.useSharedValue)(0),R=null!==f,g=f?.top??p,x=f?.bottom??p,N=f?.offset??p,b=f?.maxOffset??p,L=f?.scrollTo??noop,w=(0,_reactNativeReanimated.useSharedValue)(0),O=(0,_reactNativeReanimated.useSharedValue)(0),y=(0,_reactNativeReanimated.useSharedValue)(0),E=(0,_reactNativeReanimated.useSharedValue)(0),j=(0,_reactNativeReanimated.useSharedValue)(-1),T=(0,_reactNativeReanimated.useSharedValue)(-1),k=(0,_reactNativeReanimated.useSharedValue)(0),A=(0,_reactNativeReanimated.useSharedValue)([]),I=(0,_react.useRef)(new Map),P=(0,_react.useRef)(v),[C,M]=(0,_react.useState)(null),V=(0,_react.useCallback)(()=>{A.value=P.current.map(e=>I.current.get(e)??0)},[A]);(0,_react.useEffect)(()=>{P.current=v,V()},[v,V]),(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(k)},[k]);const D=(0,_react.useCallback)(e=>{M(t=>t?.dragging?{...t,to:e}:t)},[]),G=(0,_reactNativeReanimated.useFrameCallback)(()=>{"worklet";const e=j.value;if(e<0)return;const t=(0,_reactNativeReanimated.measure)(_);if(t){const e=R?Math.max(t.pageY,g.value):t.pageY,a=R?Math.min(t.pageY+t.height,x.value):t.pageY+t.height,r=Math.max(0,h.value-t.height-SCROLL_SLACK_PX);E.value<e+EDGE_PX?m.value>SCROLL_SLACK_PX?(0,_reactNativeReanimated.scrollTo)(_,0,Math.max(0,m.value-SCROLL_STEP_PX),!1):R&&O.value>0&&(O.value=Math.max(0,O.value-SCROLL_STEP_PX),(0,_reactNativeReanimated.runOnJS)(L)(O.value)):E.value>a-EDGE_PX&&(m.value<r?(0,_reactNativeReanimated.scrollTo)(_,0,Math.min(r,m.value+SCROLL_STEP_PX),!1):R&&O.value<b.value&&(O.value=Math.min(b.value,O.value+SCROLL_STEP_PX),(0,_reactNativeReanimated.runOnJS)(L)(O.value)))}k.value=y.value+m.value-S.value+N.value-w.value;const a=dropIndex(A.value,e,k.value);a!==T.value&&(T.value=a,(0,_reactNativeReanimated.runOnJS)(D)(a))},!1),Y=(0,_react.useCallback)(e=>{(0,_index2.triggerHaptic)("longPress"),G.setActive(!0),M({key:v[e]??"",from:e,to:e,dragging:!0})},[G,v]),H=(0,_react.useCallback)((e,t)=>{G.setActive(!1),M(e=>e?{...e,to:t,dragging:!1}:e),t!==e&&l(moveItem(v,e,t))},[G,v,l]),X=(0,_react.useCallback)(()=>{M(e=>e&&!e.dragging?null:e)},[]),q=(0,_react.useCallback)((e,t)=>{l(moveItem(v,e,t))},[v,l]),F=(0,_react.useCallback)((e,t)=>{I.current.set(e,t),V()},[V]),U=(0,_reactNativeReanimated.useAnimatedScrollHandler)({onScroll:e=>{"worklet";m.value=e.contentOffset.y}}),B=(0,_react.useCallback)((e,t)=>{h.value=t},[h]),J=(0,_react.useMemo)(()=>({scrollRef:_,scrollY:m,scrollStart:S,hostOffset:N,hostStart:w,hostTarget:O,translation:y,absoluteY:E,dragIndex:j,dropTo:T,dragY:k,heights:A}),[_,m,S,N,w,O,y,E,j,T,k,A]),z=(0,_react.useMemo)(()=>({onLift:Y,onDrop:H,onSettled:X,onMove:q,onHeight:F}),[Y,H,X,q,F]),K=!0===C?.dragging,W=K&&C?rowShifts(v.map(e=>I.current.get(e)??0),C.from,C.to):null;return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.ScrollView,{ref:_,onScroll:U,onContentSizeChange:B,scrollEventThrottle:16,scrollEnabled:!K,accessibilityLabel:o,testID:c,children:d.map((e,t)=>{const a=C?.key===e.key;return(0,_jsxRuntime.jsx)(SortableRow,{rowKey:e.key,index:t,count:d.length,shift:W?.[t]??0,isActive:a,dragging:K,handle:n,disabled:i,shared:J,callbacks:z,labels:u,children:r({item:e.item,index:t,isActive:a})},e.key)})})}SortableList.displayName="SortableList";var _default=exports.default=SortableList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Swipeable=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,n,i=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((a=i&&Object.getOwnPropertyDescriptor(e,n))&&(a.get||a.set)?i(r,n,a):r[n]=e[n]);return r}const SPRING_CONFIG={damping:22,stiffness:260,mass:1},DRAG_ACTIVATION_OFFSET=10,RUBBER_BAND_FACTOR=.35,FAIL_OFFSET_Y=15,ACTION_ICON_SIZE=20,toneToBg=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;default:return e.colors.neutral}},toneToOnColor=(e,t)=>{switch(t){case"primary":return e.colors["on-primary"];case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-neutral"]}},Swipeable=e=>{const{children:t,leftActions:a,rightActions:n,threshold:i,fullSwipeThreshold:r,onSwipeOpen:s,onSwipeClose:c,disabled:o=!1,haptic:l,containerStyle:u,contentStyle:d,actionStyle:_,accessibilityLabel:m,testID:v}=e,h=(0,_index.useTheme)(),p=i??80,w=r??200,S=(0,_react.useMemo)(()=>buildStyles(h),[h]),b=(0,_react.useMemo)(()=>buildActionStyles(h),[h]),f=!!a&&a.length>0,N=!!n&&n.length>0,R=_reactNative.Dimensions.get("window").width,x=f?p*(a?.length??0):0,g=N?p*(n?.length??0):0,y=(0,_reactNativeReanimated.useSharedValue)(0),I=(0,_reactNativeReanimated.useSharedValue)(0),j=(0,_react.useRef)(null);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(y),(0,_reactNativeReanimated.cancelAnimation)(I)},[y,I]);const O=(0,_react.useCallback)(e=>{j.current!==e&&(j.current=e,s?.(e))},[s]),C=(0,_react.useCallback)(()=>{null!==j.current&&(j.current=null,c?.())},[c]),A=(0,_react.useCallback)(e=>{const t="left"===e?a:n,i=t?.[0];i&&(!1!==l&&(0,_index2.triggerHaptic)("notificationSuccess"),i.onPress(),y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),j.current=null,c?.())},[a,n,y,c,l]),G=(0,_react.useCallback)(()=>{y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),C()},[y,C]),P=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(l,"selection");t&&(0,_index2.triggerHaptic)(t),e.onPress(),G()},[G,l]),k=(0,_react.useMemo)(()=>{const e=x,t=g,a=w,n=-w,i=R,r=-R,s=p,c=f,l=N;return _reactNativeGestureHandler.Gesture.Pan().enabled(!o).withTestId(v?`${v}-gesture`:"swipeable-gesture").activeOffsetX([-10,10]).failOffsetY([-15,15]).onStart(()=>{"worklet";I.value=y.value}).onUpdate(a=>{"worklet";const n=I.value+a.translationX;y.value=n>0&&!c||n<0&&!l?0:n>e&&c?e+.35*(n-e):n<-t&&l?.35*(n+t)-t:n}).onEnd(()=>{"worklet";const o=y.value;return c&&o>=a?(y.value=(0,_reactNativeReanimated.withSpring)(i,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(A)("left")):l&&o<=n?(y.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(A)("right")):c&&o>=s?(y.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(O)("left")):l&&o<=-s?(y.value=(0,_reactNativeReanimated.withSpring)(-t,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(O)("right")):(y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(C)())})},[o,I,A,w,f,N,x,C,O,g,R,p,y,v]),T=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:y.value}]})),F=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:x>0?Math.min(1,Math.max(0,y.value/x)):0})),V=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:g>0?Math.min(1,Math.max(0,-y.value/g)):0})),q=(0,_react.useMemo)(()=>{const e=[];return a?.forEach(t=>{e.push({name:t.key,label:t.label})}),n?.forEach(t=>{e.push({name:t.key,label:t.label})}),e},[a,n]),M=(0,_react.useCallback)(e=>{const t=e.nativeEvent.actionName,i=[...a??[],...n??[]].find(e=>e.key===t);i&&(!1!==l&&(0,_index2.triggerHaptic)("selection"),i.onPress())},[a,n,l]);return f||N?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[S.root,u],testID:v,accessibilityLabel:m,accessibilityActions:q,onAccessibilityAction:M,children:[f?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.actionsRow,S.actionsLeft,{width:x},_,F],pointerEvents:"box-none",children:a?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:h,actionStyles:b,width:p,onPress:P},e.key))}):null,N?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.actionsRow,S.actionsRight,{width:g},_,V],pointerEvents:"box-none",children:n?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:h,actionStyles:b,width:p,onPress:P},e.key))}):null,(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:k,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.content,d,T],children:t})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u,testID:v,children:t})};exports.Swipeable=Swipeable,Swipeable.displayName="Swipeable";const ActionButton=({action:e,theme:t,actionStyles:a,width:n,onPress:i})=>{(0,_warnInvalidValue.warnInvalidValue)("Swipeable","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const r=e.tone??"neutral",s=toneToBg(t,r),c=(0,_slotIcon.renderSlotIcon)(e.icon,{color:toneToOnColor(t,r),size:20,disabled:!1});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>i(e),accessibilityRole:"button",accessibilityLabel:e.label,style:[a.button,{width:n,backgroundColor:s,paddingHorizontal:t.space.sm}],children:[c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:a.icon,children:c}):null,(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",weight:"semibold",style:[a.label,{color:toneToOnColor(t,r)}],numberOfLines:1,children:e.label})]})},buildActionStyles=e=>_reactNative.StyleSheet.create({button:{flexGrow:0,flexShrink:0,alignItems:"center",justifyContent:"center"},icon:{marginBottom:e.space.xxs},label:{textAlign:"center"}}),buildStyles=e=>_reactNative.StyleSheet.create({root:{position:"relative",overflow:"hidden"},content:{backgroundColor:"transparent"},actionsRow:{position:"absolute",top:0,bottom:0,flexDirection:"row"},actionsLeft:{left:0},actionsRight:{right:0,justifyContent:"flex-end"}});var _default=exports.default=Swipeable;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Swipeable=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,n,i=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((a=i&&Object.getOwnPropertyDescriptor(e,n))&&(a.get||a.set)?i(r,n,a):r[n]=e[n]);return r}const SPRING_CONFIG={damping:22,stiffness:260,mass:1},DRAG_ACTIVATION_OFFSET=10,RUBBER_BAND_FACTOR=.35,FAIL_OFFSET_Y=15,ACTION_ICON_SIZE=20,toneToBg=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;default:return e.colors.neutral}},toneToOnColor=(e,t)=>{switch(t){case"primary":return e.colors["on-primary"];case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];default:return e.colors["on-neutral"]}},Swipeable=e=>{const{children:t,leftActions:a,rightActions:n,threshold:i,fullSwipeThreshold:r,onSwipeOpen:s,onSwipeClose:c,disabled:o=!1,haptic:l,containerStyle:u,contentStyle:d,actionStyle:_,accessibilityLabel:m,testID:v}=e,h=(0,_index.useTheme)(),p=i??80,w=r??200,S=(0,_react.useMemo)(()=>buildStyles(h),[h]),b=(0,_react.useMemo)(()=>buildActionStyles(h),[h]),f=!!a&&a.length>0,N=!!n&&n.length>0,R=_reactNative.Dimensions.get("window").width,x=f?p*(a?.length??0):0,g=N?p*(n?.length??0):0,y=(0,_reactNativeReanimated.useSharedValue)(0),I=(0,_reactNativeReanimated.useSharedValue)(0),j=(0,_react.useRef)(null);(0,_react.useEffect)(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(y),(0,_reactNativeReanimated.cancelAnimation)(I)},[y,I]);const O=(0,_react.useCallback)(e=>{j.current!==e&&(j.current=e,s?.(e))},[s]),C=(0,_react.useCallback)(()=>{null!==j.current&&(j.current=null,c?.())},[c]),A=(0,_react.useCallback)(e=>{const t="left"===e?a:n,i=t?.[0];i&&(!1!==l&&(0,_index2.triggerHaptic)("notificationSuccess"),i.onPress(),y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),j.current=null,c?.())},[a,n,y,c,l]),G=(0,_react.useCallback)(()=>{y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),C()},[y,C]),P=(0,_react.useCallback)(e=>{const t=(0,_index2.resolveHaptic)(l,"selection");t&&(0,_index2.triggerHaptic)(t),e.onPress(),G()},[G,l]),k=(0,_react.useMemo)(()=>{const e=x,t=g,a=w,n=-w,i=R,r=-R,s=p,c=f,l=N;return _reactNativeGestureHandler.Gesture.Pan().enabled(!o).withTestId(v?`${v}-gesture`:"swipeable-gesture").activeOffsetX([-10,10]).failOffsetY([-15,15]).onStart(()=>{"worklet";I.value=y.value}).onUpdate(a=>{"worklet";const n=I.value+a.translationX;y.value=n>0&&!c||n<0&&!l?0:n>e&&c?e+.35*(n-e):n<-t&&l?.35*(n+t)-t:n}).onEnd(()=>{"worklet";const o=y.value;return c&&o>=a?(y.value=(0,_reactNativeReanimated.withSpring)(i,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(A)("left")):l&&o<=n?(y.value=(0,_reactNativeReanimated.withSpring)(r,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(A)("right")):c&&o>=s?(y.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(O)("left")):l&&o<=-s?(y.value=(0,_reactNativeReanimated.withSpring)(-t,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(O)("right")):(y.value=(0,_reactNativeReanimated.withSpring)(0,SPRING_CONFIG),void(0,_reactNativeReanimated.runOnJS)(C)())})},[o,I,A,w,f,N,x,C,O,g,R,p,y,v]),T=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:y.value}]}),[y]),F=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:x>0?Math.min(1,Math.max(0,y.value/x)):0}),[x,y]),V=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:g>0?Math.min(1,Math.max(0,-y.value/g)):0}),[g,y]),q=(0,_react.useMemo)(()=>{const e=[];return a?.forEach(t=>{e.push({name:t.key,label:t.label})}),n?.forEach(t=>{e.push({name:t.key,label:t.label})}),e},[a,n]),M=(0,_react.useCallback)(e=>{const t=e.nativeEvent.actionName,i=[...a??[],...n??[]].find(e=>e.key===t);i&&(!1!==l&&(0,_index2.triggerHaptic)("selection"),i.onPress())},[a,n,l]);return f||N?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[S.root,u],testID:v,accessibilityLabel:m,accessibilityActions:q,onAccessibilityAction:M,children:[f?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.actionsRow,S.actionsLeft,{width:x},_,F],pointerEvents:"box-none",children:a?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:h,actionStyles:b,width:p,onPress:P},e.key))}):null,N?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.actionsRow,S.actionsRight,{width:g},_,V],pointerEvents:"box-none",children:n?.map(e=>(0,_jsxRuntime.jsx)(ActionButton,{action:e,theme:h,actionStyles:b,width:p,onPress:P},e.key))}):null,(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:k,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[S.content,d,T],children:t})})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:u,testID:v,children:t})};exports.Swipeable=Swipeable,Swipeable.displayName="Swipeable";const ActionButton=({action:e,theme:t,actionStyles:a,width:n,onPress:i})=>{(0,_warnInvalidValue.warnInvalidValue)("Swipeable","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const r=e.tone??"neutral",s=toneToBg(t,r),c=(0,_slotIcon.renderSlotIcon)(e.icon,{color:toneToOnColor(t,r),size:20,disabled:!1});return(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>i(e),accessibilityRole:"button",accessibilityLabel:e.label,style:[a.button,{width:n,backgroundColor:s,paddingHorizontal:t.space.sm}],children:[c?(0,_jsxRuntime.jsx)(_reactNative.View,{style:a.icon,children:c}):null,(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",weight:"semibold",style:[a.label,{color:toneToOnColor(t,r)}],numberOfLines:1,children:e.label})]})},buildActionStyles=e=>_reactNative.StyleSheet.create({button:{flexGrow:0,flexShrink:0,alignItems:"center",justifyContent:"center"},icon:{marginBottom:e.space.xxs},label:{textAlign:"center"}}),buildStyles=e=>_reactNative.StyleSheet.create({root:{position:"relative",overflow:"hidden"},content:{backgroundColor:"transparent"},actionsRow:{position:"absolute",top:0,bottom:0,flexDirection:"row"},actionsLeft:{left:0},actionsRight:{right:0,justifyContent:"flex-end"}});var _default=exports.default=Swipeable;
|