@webority/mobile-ui 0.179.0 → 0.180.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 +1 -1
- package/dist/canvas-kit/kit.js +10 -10
- package/dist/canvas-kit/manifest.json +11 -1
- package/dist/canvas-kit/release.json +6 -6
- package/lib/commonjs/components/BottomSheet/BottomSheet.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/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/commonjs/components/NonModalBottomSheet/NonModalBottomSheet.js +1 -1
- package/lib/commonjs/components/Skeleton/Skeleton.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/ZoomableImage/ZoomableImage.js +1 -1
- package/lib/commonjs/theme/Gradient.js +1 -1
- package/lib/commonjs/theme/tokens.generated.js +1 -1
- package/lib/commonjs/utils/animatedDeps.js +1 -0
- package/lib/module/components/BottomSheet/BottomSheet.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/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/module/components/NonModalBottomSheet/NonModalBottomSheet.js +1 -1
- package/lib/module/components/Skeleton/Skeleton.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/ZoomableImage/ZoomableImage.js +1 -1
- package/lib/module/theme/Gradient.js +1 -1
- package/lib/module/theme/tokens.generated.js +1 -1
- package/lib/module/utils/animatedDeps.js +1 -0
- package/lib/typescript/commonjs/theme/Gradient.d.ts +2 -2
- package/lib/typescript/commonjs/theme/tokens.generated.d.ts +1 -1
- package/lib/typescript/commonjs/utils/animatedDeps.d.ts +2 -0
- package/lib/typescript/module/theme/Gradient.d.ts +2 -2
- package/lib/typescript/module/theme/tokens.generated.d.ts +1 -1
- package/lib/typescript/module/utils/animatedDeps.d.ts +2 -0
- package/package.json +7 -7
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"kind": "WeborityPhone",
|
|
3
3
|
"library": {
|
|
4
4
|
"name": "@webority/mobile-ui",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.180.0"
|
|
6
6
|
},
|
|
7
7
|
"rendererProtocolVersion": 14,
|
|
8
8
|
"platform": "Phone",
|
|
@@ -23196,6 +23196,16 @@
|
|
|
23196
23196
|
"version": "0.177.0",
|
|
23197
23197
|
"components": [],
|
|
23198
23198
|
"values": {}
|
|
23199
|
+
},
|
|
23200
|
+
{
|
|
23201
|
+
"version": "0.178.0",
|
|
23202
|
+
"components": [],
|
|
23203
|
+
"values": {}
|
|
23204
|
+
},
|
|
23205
|
+
{
|
|
23206
|
+
"version": "0.179.0",
|
|
23207
|
+
"components": [],
|
|
23208
|
+
"values": {}
|
|
23199
23209
|
}
|
|
23200
23210
|
]
|
|
23201
23211
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webority-phone",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.180.0",
|
|
4
4
|
"platform": "Phone",
|
|
5
5
|
"kitModuleVersion": 2,
|
|
6
6
|
"rendererProtocolVersion": 14,
|
|
7
7
|
"library": {
|
|
8
8
|
"name": "@webority/mobile-ui",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.180.0"
|
|
10
10
|
},
|
|
11
11
|
"files": {
|
|
12
12
|
"manifest.json": {
|
|
13
|
-
"sha256": "
|
|
14
|
-
"bytes":
|
|
13
|
+
"sha256": "2e3c4d89aab07b7e9d802efedbf29de1f0b2ae39272bb4dd62d9619e91dcb29e",
|
|
14
|
+
"bytes": 674141
|
|
15
15
|
},
|
|
16
16
|
"kit.js": {
|
|
17
|
-
"sha256": "
|
|
18
|
-
"bytes":
|
|
17
|
+
"sha256": "676c1caf291257d342902329b03081ed15a59168c757f21773238ca3b357815a",
|
|
18
|
+
"bytes": 5707123
|
|
19
19
|
},
|
|
20
20
|
"kit.css": {
|
|
21
21
|
"sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_reactNativeWorklets=require("react-native-worklets"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../text/index.js"),_bottomSheetG=require("../../text/phone/bottomSheet.g.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,o=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=o&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?o(n,r,a):n[r]=e[r]);return n}const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:o,onSnapChange:n,onAnimate:s,onAfterClose:i,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:b,scrollEventThrottle:x,keyboardBehavior:S="shift",inline:p=!1,presentation:N="sheet",animateMount:R=!0,handleIndicatorStyle:y,sheetStyle:g,header:M,actions:j,actionsLayout:C="auto",footer:w,headerStyle:k,footerStyle:O,children:V,accessibilityLabel:I,accessibilityViewIsModal:A,testID:T}=e;(0,_assertValidValue.assertValidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_assertValidValue.assertValidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_assertValidValue.assertValidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const E=(0,_index.useMobileUiText)("bottomSheet",_bottomSheetG.BOTTOM_SHEET_TEXT),B=(0,_react.useMemo)(()=>({...E,..._}),[E,_]),P=null!=M||null!=d,D=null!=j&&j.length>0,H=null!=w||D,L=p?"inline":"modal",G=(0,_index2.useTheme)(),q=(0,_usePresenceMotion.usePresenceMotion)(),W=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),F="modal"===L&&"android"===_reactNative.Platform.OS,[U,Y]=(0,_react.useState)(()=>_reactNative.Dimensions.get(F?"screen":"window").height),[K,$]=(0,_react.useState)(()=>_reactNative.Dimensions.get(F?"screen":"window").width),z=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;F&&Math.abs(t-_reactNative.Dimensions.get("window").height)<1&&t<_reactNative.Dimensions.get("screen").height-1||(t>0&&Y(e=>e===t?e:t),a>0&&$(e=>e===a?e:a))},[F]),X=(0,_reactNative.useWindowDimensions)(),J="dialog"===N||"auto"===N&&Math.min(X.width,X.height)>=600,Q=Math.min(560,K-2*G.space.xl),[Z,ee]=(0,_ModalSafeArea.useModalInsets)(),te="modal"===L?Z.top:W.top,ae="modal"===L?Z.bottom:W.bottom,re=t.includes("content"),[oe,ne]=useMeasuredHeight(),[se,ie]=useMeasuredHeight(),[ce,le,ue]=useMeasuredHeight(),[de,he]=useMeasuredHeight(),me=J?G.space.md:oe,ve=re?Math.min(me+(P?se:0)+ce+(H?de:0)+ae,U-te):0,fe=(0,_react.useCallback)((e,t)=>{re&&ue(t),f?.(e,t)},[re,f,ue]),be=(0,_react.useMemo)(()=>resolveSnapPoints(t,U,ve),[t,U,ve]),xe=U,Se=be[be.length-1]??0,pe=(0,_reactNativeReanimated.useSharedValue)(xe),Ne=(0,_reactNativeReanimated.useSharedValue)(xe),Re=(0,_reactNativeReanimated.useSharedValue)(1),ye=(0,_reactNativeReanimated.useSharedValue)(-1),[ge,Me]=(0,_react.useState)(-1),[je,Ce]=(0,_react.useState)(!1),[we,ke]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ve=(0,_react.useRef)(i);Ve.current=i;const[Ie,Ae]=(0,_react.useState)(!1),Te=(0,_react.useRef)(!R&&a),Ee=(0,_react.useRef)(-1),Be=(0,_react.useRef)(!1);Be.current="modal"===L?we:Ie;const Pe=(0,_react.useRef)(u);Pe.current=u;const De=(0,_react.useRef)(r);De.current=r;const He=(0,_react.useRef)(!1),Le=(0,_react.useRef)(!0),Ge=(0,_react.useRef)([]),qe=(0,_react.useCallback)(e=>{const t=Ge.current;Ge.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(Le.current=!0,()=>{Le.current=!1,qe(!1)}),[qe]);const We=(0,_react.useCallback)(e=>{if(e<0||e>=be.length)return xe;const t=be[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return J?(U-t)/2:U-t},[be,U,xe,J]),Fe=(0,_react.useCallback)(e=>{Ee.current=e;ge!==e&&(Me(e),ye.value=e,e>=0&&n?.(e))},[ge,ye,n]),Ue=(0,_react.useCallback)(()=>{ye.value<0&&(Oe.current=!0,"modal"===L?(Ce(!1),"ios"!==_reactNative.Platform.OS&&ke(!1)):Ae(!1))},[L,ye]),Ye=(0,_react.useCallback)(()=>{Oe.current&&ke(!1)},[]);(0,_react.useEffect)(()=>{("modal"===L?!we:!Ie)&&Oe.current&&(Oe.current=!1,Ve.current?.(),qe(!0))},[L,we,Ie,qe]);const Ke=(0,_react.useCallback)((e,t,a)=>{s?.(t,a),pe.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeWorklets.scheduleOnRN)(Ue)})},[s,pe,Ue]),$e=(0,_react.useRef)(null),ze=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,be.length-1):Math.max(ge,0),a=ye.value,r=We(t);return Oe.current=!1,qe(!1),"modal"===L?(ke(!0),Ce(!0)):Ae(!0),a<0&&Te.current?(pe.value=r,Re.value=1,Fe(t),void s?.(a,t)):a<0&&q.reduced?(pe.value=r,Re.value=0,Re.value=(0,_reactNativeReanimated.withTiming)(1,{duration:q.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...G.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void s?.(a,t)):(a<0&&(pe.value=xe,Re.value=1),Fe(t),void(a<0&&t>=0&&!Be.current?$e.current={fromIndex:a,target:t}:Ke(r,a,t)))},[Ke,xe,ge,ye,L,s,q,Re,be.length,Fe,qe,G.motion.ease.decelerate,pe,We]),Xe=(0,_react.useCallback)(()=>new Promise(e=>{if(Ee.current<0)return void(Be.current?Ge.current.push(e):e(!0));Ge.current.push(e),Te.current=!1,$e.current=null;const t=ye.value;Fe(-1),s?.(t,-1);const a=q.reduced?Re:pe,r=q.reduced?0:xe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:q.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...G.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeWorklets.scheduleOnRN)(Ue)})}),[xe,ye,Ue,s,q,Re,Fe,pe,G.motion.ease.accelerate]),Je=(0,_react.useCallback)((e,t,a)=>{const r=Pe.current;if(!r)return void e();if(He.current)return void t?.();const o=r();"boolean"!=typeof o?(He.current=!0,a?.(),o.then(a=>{He.current=!1,a&&Le.current&&Ee.current>=0?e():t?.()},e=>{throw He.current=!1,e})):(o?e:t)?.()},[]),Qe=(0,_react.useCallback)(()=>new Promise(e=>{Ee.current<0?e(!0):Je(()=>{De.current(),Xe(),e(!0)},()=>e(!1))}),[Xe,Je]),Ze=(0,_react.useCallback)(()=>{De.current()},[]),et=(0,_react.useCallback)(()=>{l&&Qe()},[l,Qe]),tt=(0,_react.useRef)(null),at=(0,_react.useRef)(ze);at.current=ze;const rt=(0,_react.useRef)(Xe);rt.current=Xe,(0,_react.useLayoutEffect)(()=>{const e=tt.current!==a;tt.current=a,e?a?at.current(o??0):rt.current():a&&"number"==typeof o&&o!==ye.value&&at.current(o)},[a,o,ye]);const ot=(0,_react.useRef)({hostHeight:U,contentSnap:ve}),nt=(0,_react.useRef)(We);nt.current=We,(0,_react.useEffect)(()=>{const e=ot.current;if(e.hostHeight===U&&e.contentSnap===ve)return;if(ot.current={hostHeight:U,contentSnap:ve},e.hostHeight===U&&ye.value<0)return;const t=nt.current(ye.value);pe.value=Te.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[U,ve,ye,pe]);const st="modal"===L?we:Ie;(0,_react.useLayoutEffect)(()=>{const e=$e.current;null!==e&&st&&($e.current=null,Ee.current===e.target&&Ke(nt.current(e.target),e.fromIndex,e.target))},[st,Ke]);const it=U-Se,ct=(0,_react.useMemo)(()=>be.map(e=>U-e),[be,U]),lt=(0,_react.useCallback)(()=>{const e=Ee.current;e<0||Ke(We(e),e,e)},[Ke,We]),ut=(0,_react.useCallback)((e,t)=>{const a=ye.value;-1!==e?(Fe(e),Ke(t,a,e)):Je(()=>{_reactNative.Keyboard.dismiss(),(0,_index3.triggerHaptic)("selection"),De.current(),Xe()},lt,lt)},[Ke,Xe,ye,Je,Fe,lt]),dt=(0,_react.useMemo)(()=>({testID:T?`${T}-content-gesture`:"bottom-sheet-content-gesture"}),[T]),_t=(0,_reactNativeGestureHandler.useNativeGesture)(dt),ht=(0,_react.useMemo)(()=>{const e=ct,t=xe,a=it,r=c;return{testID:T?`${T}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";Ne.value=pe.value},onUpdate:e=>{"worklet";const t=Ne.value+e.translationY;pe.value=t<a?a+.25*(t-a):t},onDeactivate:a=>{"worklet";const o=pe.value,n=a.velocityY,[s]=e;if(void 0===s)return void(0,_reactNativeWorklets.scheduleOnRN)(ut,-1,t);if(n>1e3)return r?void(0,_reactNativeWorklets.scheduleOnRN)(ut,-1,t):void(0,_reactNativeWorklets.scheduleOnRN)(ut,0,s);let i=0,c=s,l=1/0,u=0;for(const t of e){const e=Math.abs(o-t);e<l&&(l=e,c=t,i=u),u++}r&&o-s>80?(0,_reactNativeWorklets.scheduleOnRN)(ut,-1,t):(0,_reactNativeWorklets.scheduleOnRN)(ut,i,c)}}},[xe,Ne,c,ut,it,ct,T,pe]),mt=(0,_reactNativeGestureHandler.usePanGesture)(ht),{height:vt,progress:ft}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),bt="shift"===S,xt=(0,_reactNativeReanimated.useDerivedValue)(()=>bt?vt.value:0,[bt,vt]),St=(0,_reactNativeReanimated.useSharedValue)(0);(0,_reactNativeReanimated.useAnimatedReaction)(()=>bt&&ft.value>=1?vt.value:0,e=>{St.value=e},[bt,vt,ft,St]);const pt=be[Math.max(ge,0)]??Se,Nt=G.space.md,Rt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=xt.value;if(J){const t=U+e-pt-Nt,a=e<0&&pe.value>t?t:pe.value;return{top:pe.value,transform:[{translateY:Math.max(a,te)-pe.value}],opacity:Re.value}}const t=e<0?te:it,a=Math.max(pe.value+e,t);return{top:pe.value,transform:[{translateY:a-pe.value}],opacity:Re.value}},[J,xt,U,pt,Nt,pe,te,Re,it]),yt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=St.value;if(J){const t=U+e-pt-Nt,a=e<0&&pe.value>t?t:pe.value,r=Math.max(a,te),o=U+e-Nt-r;return{height:o<0?0:Math.min(o,pt)}}const t=e<0?te:it,a=Math.max(pe.value+e,t),r=U+e-a;return{height:r<0?0:Math.min(r,Se)}},[St,J,U,pt,Nt,pe,te,it,Se]),gt=ge>=0,Mt=(0,_react.useMemo)(()=>buildStyles(G),[G]),jt=(0,_react.useCallback)(()=>{l&&Je(()=>{(0,_index3.triggerHaptic)("selection"),De.current(),Xe()})},[l,Xe,Je]),Ct=(0,_react.useMemo)(()=>({testID:T?`${T}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||(0,_reactNativeWorklets.scheduleOnRN)(jt)}}),[jt,T]),wt=(0,_reactNativeGestureHandler.useTapGesture)(Ct),kt=(0,_react.useMemo)(()=>({snapIndex:ge,snapPoints:be,close:Ze,requestClose:Qe}),[ge,be,Ze,Qe]);if("inline"===L&&!Ie)return null;if("modal"===L&&!we)return null;const Ot=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===L?Mt.backdropModal:Mt.backdropInline,{backgroundColor:"modal"===L?(0,_color.transparentOf)(G.colors.scrim):G.colors.scrim}],onLayout:z,testID:T,accessibilityViewIsModal:A??gt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:wt,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:B.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:I,accessibilityViewIsModal:A??gt,accessibilityActions:[{name:"escape",label:B.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&et()},onAccessibilityEscape:et,style:[Mt.sheet,{height:Se,backgroundColor:G.colors.surface,borderTopLeftRadius:G.radius.xl,borderTopRightRadius:G.radius.xl,..._corners.smoothCorners,...G.shadow.modal},J?{height:pt,left:(K-Q)/2,right:void 0,width:Q,borderBottomLeftRadius:G.radius.xl,borderBottomRightRadius:G.radius.xl}:null,g,Rt],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[Mt.body,yt],settledKeyboardOffset:St,children:[J?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:G.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:mt,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:Mt.handleRow,onLayout:re?ne:void 0,accessible:!0,accessibilityLabel:B.dragHandle,accessibilityHint:B.dragHandleHintText,testID:T?`${T}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[Mt.handle,{backgroundColor:G.colors.border},y]})})}),P&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Mt.header,k],onLayout:re?ie:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",accessibilityRole:"header",children:d}):null,M]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:_t,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,testID:T?`${T}-scroll`:void 0,style:Mt.scrollContent,onScroll:v,onContentSizeChange:fe,onLayout:b,scrollEventThrottle:x,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:V})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:re?[Mt.content,{overflow:"visible"}]:Mt.content,children:re?(0,_jsxRuntime.jsx)(_reactNative.View,{style:Mt.contentMeasure,onLayout:le,children:V}):V}),H&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Mt.footer,O],onLayout:re?he:void 0,children:[D?(0,_jsxRuntime.jsx)(_reactNative.View,{style:Mt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:C})}):null,w]})]})})]}),Vt=(0,_jsxRuntime.jsx)(BottomSheetContext,{value:kt,children:Ot});return"modal"===L?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:je,onClose:et,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:ee,onDismissed:"ios"===_reactNative.Platform.OS?Ye:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:Mt.modalRoot,children:Vt}):Vt}):Vt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,settledKeyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,o=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:Math.max(e,0)}},[r,t]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,o],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{backgroundColor:e.colors.surface},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},contentMeasure:{position:"absolute",top:0,left:0,right:0},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_reactNativeWorklets=require("react-native-worklets"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../text/index.js"),_bottomSheetG=require("../../text/phone/bottomSheet.g.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_animatedDeps=require("../../utils/animatedDeps.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,s=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=s&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?s(n,r,a):n[r]=e[r]);return n}const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:s,onSnapChange:n,onAnimate:o,onAfterClose:i,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:b,scrollEventThrottle:p,keyboardBehavior:x="shift",inline:S=!1,presentation:N="sheet",animateMount:R=!0,handleIndicatorStyle:y,sheetStyle:g,header:M,actions:w,actionsLayout:j="auto",footer:C,headerStyle:k,footerStyle:O,children:D,accessibilityLabel:V,accessibilityViewIsModal:I,testID:A}=e;(0,_assertValidValue.assertValidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_assertValidValue.assertValidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_assertValidValue.assertValidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const T=(0,_index.useMobileUiText)("bottomSheet",_bottomSheetG.BOTTOM_SHEET_TEXT),E=(0,_react.useMemo)(()=>({...T,..._}),[T,_]),B=null!=M||null!=d,P=null!=w&&w.length>0,H=null!=C||P,L=S?"inline":"modal",G=(0,_index2.useTheme)(),q=(0,_usePresenceMotion.usePresenceMotion)(),W=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),F="modal"===L&&"android"===_reactNative.Platform.OS,[U,Y]=(0,_react.useState)(()=>_reactNative.Dimensions.get(F?"screen":"window").height),[K,$]=(0,_react.useState)(()=>_reactNative.Dimensions.get(F?"screen":"window").width),z=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;F&&Math.abs(t-_reactNative.Dimensions.get("window").height)<1&&t<_reactNative.Dimensions.get("screen").height-1||(t>0&&Y(e=>e===t?e:t),a>0&&$(e=>e===a?e:a))},[F]),X=(0,_reactNative.useWindowDimensions)(),J="dialog"===N||"auto"===N&&Math.min(X.width,X.height)>=600,Q=Math.min(560,K-2*G.space.xl),[Z,ee]=(0,_ModalSafeArea.useModalInsets)(),te="modal"===L?Z.top:W.top,ae="modal"===L?Z.bottom:W.bottom,re=t.includes("content"),[se,ne]=useMeasuredHeight(),[oe,ie]=useMeasuredHeight(),[ce,le,ue]=useMeasuredHeight(),[de,he]=useMeasuredHeight(),me=J?G.space.md:se,ve=re?Math.min(me+(B?oe:0)+ce+(H?de:0)+ae,U-te):0,fe=(0,_react.useCallback)((e,t)=>{re&&ue(t),f?.(e,t)},[re,f,ue]),be=(0,_react.useMemo)(()=>resolveSnapPoints(t,U,ve),[t,U,ve]),pe=U,xe=be[be.length-1]??0,Se=(0,_reactNativeReanimated.useSharedValue)(pe),Ne=(0,_reactNativeReanimated.useSharedValue)(pe),Re=(0,_reactNativeReanimated.useSharedValue)(1),ye=(0,_reactNativeReanimated.useSharedValue)(-1),[ge,Me]=(0,_react.useState)(-1),[we,je]=(0,_react.useState)(!1),[Ce,ke]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),De=(0,_react.useRef)(i);De.current=i;const[Ve,Ie]=(0,_react.useState)(!1),Ae=(0,_react.useRef)(!R&&a),Te=(0,_react.useRef)(-1),Ee=(0,_react.useRef)(!1);Ee.current="modal"===L?Ce:Ve;const Be=(0,_react.useRef)(u);Be.current=u;const Pe=(0,_react.useRef)(r);Pe.current=r;const He=(0,_react.useRef)(!1),Le=(0,_react.useRef)(!0),Ge=(0,_react.useRef)([]),qe=(0,_react.useCallback)(e=>{const t=Ge.current;Ge.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(Le.current=!0,()=>{Le.current=!1,qe(!1)}),[qe]);const We=(0,_react.useCallback)(e=>{if(e<0||e>=be.length)return pe;const t=be[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return J?(U-t)/2:U-t},[be,U,pe,J]),Fe=(0,_react.useCallback)(e=>{Te.current=e;ge!==e&&(Me(e),ye.value=e,e>=0&&n?.(e))},[ge,ye,n]),Ue=(0,_react.useCallback)(()=>{ye.value<0&&(Oe.current=!0,"modal"===L?(je(!1),"ios"!==_reactNative.Platform.OS&&ke(!1)):Ie(!1))},[L,ye]),Ye=(0,_react.useCallback)(()=>{Oe.current&&ke(!1)},[]);(0,_react.useEffect)(()=>{("modal"===L?!Ce:!Ve)&&Oe.current&&(Oe.current=!1,De.current?.(),qe(!0))},[L,Ce,Ve,qe]);const Ke=(0,_react.useCallback)((e,t,a)=>{o?.(t,a),Se.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeWorklets.scheduleOnRN)(Ue)})},[o,Se,Ue]),$e=(0,_react.useRef)(null),ze=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,be.length-1):Math.max(ge,0),a=ye.value,r=We(t);return Oe.current=!1,qe(!1),"modal"===L?(ke(!0),je(!0)):Ie(!0),a<0&&Ae.current?(Se.value=r,Re.value=1,Fe(t),void o?.(a,t)):a<0&&q.reduced?(Se.value=r,Re.value=0,Re.value=(0,_reactNativeReanimated.withTiming)(1,{duration:q.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...G.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void o?.(a,t)):(a<0&&(Se.value=pe,Re.value=1),Fe(t),void(a<0&&t>=0&&!Ee.current?$e.current={fromIndex:a,target:t}:Ke(r,a,t)))},[Ke,pe,ge,ye,L,o,q,Re,be.length,Fe,qe,G.motion.ease.decelerate,Se,We]),Xe=(0,_react.useCallback)(()=>new Promise(e=>{if(Te.current<0)return void(Ee.current?Ge.current.push(e):e(!0));Ge.current.push(e),Ae.current=!1,$e.current=null;const t=ye.value;Fe(-1),o?.(t,-1);const a=q.reduced?Re:Se,r=q.reduced?0:pe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:q.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...G.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeWorklets.scheduleOnRN)(Ue)})}),[pe,ye,Ue,o,q,Re,Fe,Se,G.motion.ease.accelerate]),Je=(0,_react.useCallback)((e,t,a)=>{const r=Be.current;if(!r)return void e();if(He.current)return void t?.();const s=r();"boolean"!=typeof s?(He.current=!0,a?.(),s.then(a=>{He.current=!1,a&&Le.current&&Te.current>=0?e():t?.()},e=>{throw He.current=!1,e})):(s?e:t)?.()},[]),Qe=(0,_react.useCallback)(()=>new Promise(e=>{Te.current<0?e(!0):Je(()=>{Pe.current(),Xe(),e(!0)},()=>e(!1))}),[Xe,Je]),Ze=(0,_react.useCallback)(()=>{Pe.current()},[]),et=(0,_react.useCallback)(()=>{l&&Qe()},[l,Qe]),tt=(0,_react.useRef)(null),at=(0,_react.useRef)(ze);at.current=ze;const rt=(0,_react.useRef)(Xe);rt.current=Xe,(0,_react.useLayoutEffect)(()=>{const e=tt.current!==a;tt.current=a,e?a?at.current(s??0):rt.current():a&&"number"==typeof s&&s!==ye.value&&at.current(s)},[a,s,ye]);const st=(0,_react.useRef)({hostHeight:U,contentSnap:ve}),nt=(0,_react.useRef)(We);nt.current=We,(0,_react.useEffect)(()=>{const e=st.current;if(e.hostHeight===U&&e.contentSnap===ve)return;if(st.current={hostHeight:U,contentSnap:ve},e.hostHeight===U&&ye.value<0)return;const t=nt.current(ye.value);Se.value=Ae.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[U,ve,ye,Se]);const ot="modal"===L?Ce:Ve;(0,_react.useLayoutEffect)(()=>{const e=$e.current;null!==e&&ot&&($e.current=null,Te.current===e.target&&Ke(nt.current(e.target),e.fromIndex,e.target))},[ot,Ke]);const it=U-xe,ct=(0,_react.useMemo)(()=>be.map(e=>U-e),[be,U]),lt=(0,_react.useCallback)(()=>{const e=Te.current;e<0||Ke(We(e),e,e)},[Ke,We]),ut=(0,_react.useCallback)((e,t)=>{const a=ye.value;-1!==e?(Fe(e),Ke(t,a,e)):Je(()=>{_reactNative.Keyboard.dismiss(),(0,_index3.triggerHaptic)("selection"),Pe.current(),Xe()},lt,lt)},[Ke,Xe,ye,Je,Fe,lt]),dt=(0,_react.useMemo)(()=>({testID:A?`${A}-content-gesture`:"bottom-sheet-content-gesture"}),[A]),_t=(0,_reactNativeGestureHandler.useNativeGesture)(dt),ht=(0,_react.useMemo)(()=>{const e=ct,t=pe,a=it,r=c;return{testID:A?`${A}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";Ne.value=Se.value},onUpdate:e=>{"worklet";const t=Ne.value+e.translationY;Se.value=t<a?a+.25*(t-a):t},onDeactivate:a=>{"worklet";const s=Se.value,n=a.velocityY,[o]=e;if(void 0===o)return void(0,_reactNativeWorklets.scheduleOnRN)(ut,-1,t);if(n>1e3)return r?void(0,_reactNativeWorklets.scheduleOnRN)(ut,-1,t):void(0,_reactNativeWorklets.scheduleOnRN)(ut,0,o);let i=0,c=o,l=1/0,u=0;for(const t of e){const e=Math.abs(s-t);e<l&&(l=e,c=t,i=u),u++}r&&s-o>80?(0,_reactNativeWorklets.scheduleOnRN)(ut,-1,t):(0,_reactNativeWorklets.scheduleOnRN)(ut,i,c)}}},[pe,Ne,c,ut,it,ct,A,Se]),mt=(0,_reactNativeGestureHandler.usePanGesture)(ht),{height:vt,progress:ft}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),bt="shift"===x,pt=(0,_reactNativeReanimated.useDerivedValue)(()=>bt?vt.value:0,...(0,_animatedDeps.webDeps)([bt,vt])),xt=(0,_reactNativeReanimated.useSharedValue)(0);(0,_reactNativeReanimated.useAnimatedReaction)(()=>bt&&ft.value>=1?vt.value:0,e=>{xt.value=e},[bt,vt,ft,xt]);const St=be[Math.max(ge,0)]??xe,Nt=G.space.md,Rt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=pt.value;if(J){const t=U+e-St-Nt,a=e<0&&Se.value>t?t:Se.value;return{top:Se.value,transform:[{translateY:Math.max(a,te)-Se.value}],opacity:Re.value}}const t=e<0?te:it,a=Math.max(Se.value+e,t);return{top:Se.value,transform:[{translateY:a-Se.value}],opacity:Re.value}},...(0,_animatedDeps.webDeps)([J,pt,U,St,Nt,Se,te,Re,it])),yt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=xt.value;if(J){const t=U+e-St-Nt,a=e<0&&Se.value>t?t:Se.value,r=Math.max(a,te),s=U+e-Nt-r;return{height:s<0?0:Math.min(s,St)}}const t=e<0?te:it,a=Math.max(Se.value+e,t),r=U+e-a;return{height:r<0?0:Math.min(r,xe)}},...(0,_animatedDeps.webDeps)([xt,J,U,St,Nt,Se,te,it,xe])),gt=ge>=0,Mt=(0,_react.useMemo)(()=>buildStyles(G),[G]),wt=(0,_react.useCallback)(()=>{l&&Je(()=>{(0,_index3.triggerHaptic)("selection"),Pe.current(),Xe()})},[l,Xe,Je]),jt=(0,_react.useMemo)(()=>({testID:A?`${A}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||(0,_reactNativeWorklets.scheduleOnRN)(wt)}}),[wt,A]),Ct=(0,_reactNativeGestureHandler.useTapGesture)(jt),kt=(0,_react.useMemo)(()=>({snapIndex:ge,snapPoints:be,close:Ze,requestClose:Qe}),[ge,be,Ze,Qe]);if("inline"===L&&!Ve)return null;if("modal"===L&&!Ce)return null;const Ot=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===L?Mt.backdropModal:Mt.backdropInline,{backgroundColor:"modal"===L?(0,_color.transparentOf)(G.colors.scrim):G.colors.scrim}],onLayout:z,testID:A,accessibilityViewIsModal:I??gt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Ct,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:E.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:V,accessibilityViewIsModal:I??gt,accessibilityActions:[{name:"escape",label:E.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&et()},onAccessibilityEscape:et,style:[Mt.sheet,{height:xe,backgroundColor:G.colors.surface,borderTopLeftRadius:G.radius.xl,borderTopRightRadius:G.radius.xl,..._corners.smoothCorners,...G.shadow.modal},J?{height:St,left:(K-Q)/2,right:void 0,width:Q,borderBottomLeftRadius:G.radius.xl,borderBottomRightRadius:G.radius.xl}:null,g,Rt],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[Mt.body,yt],settledKeyboardOffset:xt,children:[J?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:G.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:mt,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:Mt.handleRow,onLayout:re?ne:void 0,accessible:!0,accessibilityLabel:E.dragHandle,accessibilityHint:E.dragHandleHintText,testID:A?`${A}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[Mt.handle,{backgroundColor:G.colors.border},y]})})}),B&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Mt.header,k],onLayout:re?ie:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",accessibilityRole:"header",children:d}):null,M]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:_t,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,testID:A?`${A}-scroll`:void 0,style:Mt.scrollContent,onScroll:v,onContentSizeChange:fe,onLayout:b,scrollEventThrottle:p,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:D})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:re?[Mt.content,{overflow:"visible"}]:Mt.content,children:re?(0,_jsxRuntime.jsx)(_reactNative.View,{style:Mt.contentMeasure,onLayout:le,children:D}):D}),H&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Mt.footer,O],onLayout:re?he:void 0,children:[P?(0,_jsxRuntime.jsx)(_reactNative.View,{style:Mt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:w??[],layout:j})}):null,C]})]})})]}),Dt=(0,_jsxRuntime.jsx)(BottomSheetContext,{value:kt,children:Ot});return"modal"===L?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:we,onClose:et,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:ee,onDismissed:"ios"===_reactNative.Platform.OS?Ye:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:Mt.modalRoot,children:Dt}):Dt}):Dt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,settledKeyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,s=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:Math.max(e,0)}},...(0,_animatedDeps.webDeps)([r,t]));return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,s],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{backgroundColor:e.colors.surface},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},contentMeasure:{position:"absolute",top:0,left:0,right:0},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Confetti=Confetti,exports.default=exports.buildPieces=exports.DEFAULT_PHYSICS=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_reactNativeWorklets=require("react-native-worklets"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,r,i=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((t=i&&Object.getOwnPropertyDescriptor(e,r))&&(t.get||t.set)?i(s,r,t):s[r]=e[r]);return s}const TAU=2*Math.PI,DEG=Math.PI/180,SPEED_FACTOR={slow:1.6,normal:1,fast:.6},DEFAULT_PHYSICS=exports.DEFAULT_PHYSICS={velocity:1,drag:1,fallSpeed:1,spread:0},PRESET_SHAPES={pop:["strip","strip","strip","square","circle","triangle","star","streamer"],rain:["strip","strip","strip","circle","square"],fireworks:["circle","circle","star","star","triangle","strip"]},rand=(e,a)=>e+Math.random()*(a-e),itemAt=(e,a,t)=>{const r=e[a];if(void 0===r)throw new Error(`Confetti needs at least one ${t}`);return r},pick=e=>itemAt(e,Math.floor(Math.random()*e.length),"shape"),randomSign=()=>Math.random()<.5?1:-1,commonPiece=(e,a)=>({color:itemAt(e.colors,a%e.colors.length,"colour"),size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:randomSign(),flutterFreq:rand(2,5)}),popPiece=(e,a)=>{const t=e.physics.spread>0?e.physics.spread/2:100,r=(-90+rand(-t,t))*DEG,i=rand(1.8,4.2)*e.physics.velocity;return{...commonPiece(e,a),x0Frac:e.originXFrac,y0Frac:e.originYFrac,vxFrac:Math.cos(r)*i*.7,vyFrac:Math.sin(r)*i,drag:rand(5.5,7.5)*e.physics.drag,terminalFrac:rand(.22,.44)*e.physics.fallSpeed,delay:rand(0,.05),swayAmp:rand(4,16),swayFreq:rand(1,3)}},rainPiece=(e,a)=>({...commonPiece(e,a),x0Frac:Math.random(),y0Frac:-.05,vxFrac:rand(-.12,.12)*e.physics.velocity,vyFrac:rand(.05,.25)*e.physics.velocity,drag:rand(2.5,4)*e.physics.drag,terminalFrac:rand(.95,1.35)*e.physics.fallSpeed,delay:rand(0,.35),swayAmp:rand(10,30),swayFreq:rand(1,3)}),FIREWORK_BURSTS=4,buildFireworks=(e,a)=>{const t=Math.max(1,Math.round(e/4)),r=a.physics.spread>0?a.physics.spread/2:180,i=[];for(let s=0;s<4&&i.length<e;s+=1){const n=rand(.18,.82),c=rand(.18,.52),o=s/4*.5+rand(0,.06);for(let s=0;s<t&&i.length<e;s+=1){const e=rand(-r,r)*DEG,t=rand(1.4,3.4)*a.physics.velocity;i.push({...commonPiece(a,i.length),x0Frac:n,y0Frac:c,vxFrac:Math.cos(e)*t*.7,vyFrac:Math.sin(e)*t,drag:rand(6.5,8.5)*a.physics.drag,terminalFrac:rand(.18,.38)*a.physics.fallSpeed,delay:o,swayAmp:rand(3,12),swayFreq:rand(1,3)})}}return i},buildPieces=(e,a,t)=>{if("fireworks"===a)return buildFireworks(e,t);const r="rain"===a?rainPiece:popPiece;return Array.from({length:e},(e,a)=>r(t,a))};exports.buildPieces=buildPieces;const SHAPE_BOX={strip:{w:1,h:.45},square:{w:1,h:1},circle:{w:1,h:1},triangle:{w:1,h:1},star:{w:1.2,h:1.2},streamer:{w:3,h:1.2}},TRIANGLE_POINTS="50,4 96,96 4,96",STAR_POINTS="50,2 61,36 97,36 68,58 79,94 50,72 21,94 32,58 3,36 39,36",STREAMER_PATH="M2,50 C20,6 44,94 62,50 S92,6 98,50",ShapeBody=({shape:e,color:a})=>"triangle"===e||"star"===e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:"100%",height:"100%",viewBox:"0 0 100 100",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Polygon,{points:"star"===e?STAR_POINTS:TRIANGLE_POINTS,fill:a})}):"streamer"===e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:STREAMER_PATH,stroke:a,strokeWidth:22,strokeLinecap:"round",fill:"none"})}):null,ConfettiPiece=({piece:e,progress:a,width:t,height:r,fadeOut:i})=>{const s=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const s=1-e.delay,n=s<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/s)),c=(1-Math.exp(-e.drag*n))/e.drag,o=e.x0Frac*t+e.vxFrac*t*c,l=e.y0Frac*r+e.terminalFrac*r*n+(e.vyFrac-e.terminalFrac)*r*c,d=Math.sin(n*e.swayFreq*TAU)*e.swayAmp,h=e.rotateDir*e.rotations*360*n,p=.35+.65*Math.abs(Math.cos(n*e.flutterFreq*TAU));return{opacity:i?Math.max(0,1-Math.max(0,n-.75)/.25):1,transform:[{translateX:o+d},{translateY:l},{rotate:`${h}deg`},{scaleY:p}]}},[e,a,t,r,i]),n=SHAPE_BOX[e.shape],c="triangle"===e.shape||"star"===e.shape||"streamer"===e.shape;return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[{position:"absolute",width:e.size*n.w,height:e.size*n.h,borderRadius:"circle"===e.shape?e.size*n.h/2:1,backgroundColor:c?"transparent":e.color},s],children:(0,_jsxRuntime.jsx)(ShapeBody,{shape:e.shape,color:e.color})})};function Confetti({ref:e,count:a=80,colors:t,preset:r="pop",shapes:i,speed:s="normal",physics:n,origin:c,duration:o=2800,fadeOut:l=!0,autoStart:d=!1,recycle:h=!1,size:p=10,onComplete:u,style:_,testID:m}){(0,_assertValidValue.assertValidValue)("Confetti","preset",r,["pop","rain","fireworks"]),(0,_assertValidValue.assertValidValue)("Confetti","speed",s,["slow","normal","fast"]);for(const e of i??[])(0,_assertValidValue.assertValidValue)("Confetti","shapes",e,["strip","square","circle","triangle","star","streamer"]);const v=(0,_index2.useTheme)(),y=(0,_index.useReducedMotion)(),f=(0,_reactNative.useWindowDimensions)(),[g,S]=(0,_react.useState)({width:f.width,height:f.height}),[x
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Confetti=Confetti,exports.default=exports.buildPieces=exports.DEFAULT_PHYSICS=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_reactNativeWorklets=require("react-native-worklets"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_animatedDeps=require("../../utils/animatedDeps.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,r,i=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((t=i&&Object.getOwnPropertyDescriptor(e,r))&&(t.get||t.set)?i(s,r,t):s[r]=e[r]);return s}const TAU=2*Math.PI,DEG=Math.PI/180,SPEED_FACTOR={slow:1.6,normal:1,fast:.6},DEFAULT_PHYSICS=exports.DEFAULT_PHYSICS={velocity:1,drag:1,fallSpeed:1,spread:0},PRESET_SHAPES={pop:["strip","strip","strip","square","circle","triangle","star","streamer"],rain:["strip","strip","strip","circle","square"],fireworks:["circle","circle","star","star","triangle","strip"]},rand=(e,a)=>e+Math.random()*(a-e),itemAt=(e,a,t)=>{const r=e[a];if(void 0===r)throw new Error(`Confetti needs at least one ${t}`);return r},pick=e=>itemAt(e,Math.floor(Math.random()*e.length),"shape"),randomSign=()=>Math.random()<.5?1:-1,commonPiece=(e,a)=>({color:itemAt(e.colors,a%e.colors.length,"colour"),size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:randomSign(),flutterFreq:rand(2,5)}),popPiece=(e,a)=>{const t=e.physics.spread>0?e.physics.spread/2:100,r=(-90+rand(-t,t))*DEG,i=rand(1.8,4.2)*e.physics.velocity;return{...commonPiece(e,a),x0Frac:e.originXFrac,y0Frac:e.originYFrac,vxFrac:Math.cos(r)*i*.7,vyFrac:Math.sin(r)*i,drag:rand(5.5,7.5)*e.physics.drag,terminalFrac:rand(.22,.44)*e.physics.fallSpeed,delay:rand(0,.05),swayAmp:rand(4,16),swayFreq:rand(1,3)}},rainPiece=(e,a)=>({...commonPiece(e,a),x0Frac:Math.random(),y0Frac:-.05,vxFrac:rand(-.12,.12)*e.physics.velocity,vyFrac:rand(.05,.25)*e.physics.velocity,drag:rand(2.5,4)*e.physics.drag,terminalFrac:rand(.95,1.35)*e.physics.fallSpeed,delay:rand(0,.35),swayAmp:rand(10,30),swayFreq:rand(1,3)}),FIREWORK_BURSTS=4,buildFireworks=(e,a)=>{const t=Math.max(1,Math.round(e/4)),r=a.physics.spread>0?a.physics.spread/2:180,i=[];for(let s=0;s<4&&i.length<e;s+=1){const n=rand(.18,.82),c=rand(.18,.52),o=s/4*.5+rand(0,.06);for(let s=0;s<t&&i.length<e;s+=1){const e=rand(-r,r)*DEG,t=rand(1.4,3.4)*a.physics.velocity;i.push({...commonPiece(a,i.length),x0Frac:n,y0Frac:c,vxFrac:Math.cos(e)*t*.7,vyFrac:Math.sin(e)*t,drag:rand(6.5,8.5)*a.physics.drag,terminalFrac:rand(.18,.38)*a.physics.fallSpeed,delay:o,swayAmp:rand(3,12),swayFreq:rand(1,3)})}}return i},buildPieces=(e,a,t)=>{if("fireworks"===a)return buildFireworks(e,t);const r="rain"===a?rainPiece:popPiece;return Array.from({length:e},(e,a)=>r(t,a))};exports.buildPieces=buildPieces;const SHAPE_BOX={strip:{w:1,h:.45},square:{w:1,h:1},circle:{w:1,h:1},triangle:{w:1,h:1},star:{w:1.2,h:1.2},streamer:{w:3,h:1.2}},TRIANGLE_POINTS="50,4 96,96 4,96",STAR_POINTS="50,2 61,36 97,36 68,58 79,94 50,72 21,94 32,58 3,36 39,36",STREAMER_PATH="M2,50 C20,6 44,94 62,50 S92,6 98,50",ShapeBody=({shape:e,color:a})=>"triangle"===e||"star"===e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:"100%",height:"100%",viewBox:"0 0 100 100",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Polygon,{points:"star"===e?STAR_POINTS:TRIANGLE_POINTS,fill:a})}):"streamer"===e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:STREAMER_PATH,stroke:a,strokeWidth:22,strokeLinecap:"round",fill:"none"})}):null,ConfettiPiece=({piece:e,progress:a,width:t,height:r,fadeOut:i})=>{const s=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const s=1-e.delay,n=s<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/s)),c=(1-Math.exp(-e.drag*n))/e.drag,o=e.x0Frac*t+e.vxFrac*t*c,l=e.y0Frac*r+e.terminalFrac*r*n+(e.vyFrac-e.terminalFrac)*r*c,d=Math.sin(n*e.swayFreq*TAU)*e.swayAmp,h=e.rotateDir*e.rotations*360*n,p=.35+.65*Math.abs(Math.cos(n*e.flutterFreq*TAU));return{opacity:i?Math.max(0,1-Math.max(0,n-.75)/.25):1,transform:[{translateX:o+d},{translateY:l},{rotate:`${h}deg`},{scaleY:p}]}},...(0,_animatedDeps.webDeps)([e,a,t,r,i])),n=SHAPE_BOX[e.shape],c="triangle"===e.shape||"star"===e.shape||"streamer"===e.shape;return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[{position:"absolute",width:e.size*n.w,height:e.size*n.h,borderRadius:"circle"===e.shape?e.size*n.h/2:1,backgroundColor:c?"transparent":e.color},s],children:(0,_jsxRuntime.jsx)(ShapeBody,{shape:e.shape,color:e.color})})};function Confetti({ref:e,count:a=80,colors:t,preset:r="pop",shapes:i,speed:s="normal",physics:n,origin:c,duration:o=2800,fadeOut:l=!0,autoStart:d=!1,recycle:h=!1,size:p=10,onComplete:u,style:_,testID:m}){(0,_assertValidValue.assertValidValue)("Confetti","preset",r,["pop","rain","fireworks"]),(0,_assertValidValue.assertValidValue)("Confetti","speed",s,["slow","normal","fast"]);for(const e of i??[])(0,_assertValidValue.assertValidValue)("Confetti","shapes",e,["strip","square","circle","triangle","star","streamer"]);const v=(0,_index2.useTheme)(),y=(0,_index.useReducedMotion)(),f=(0,_reactNative.useWindowDimensions)(),[g,S]=(0,_react.useState)({width:f.width,height:f.height}),[w,x]=(0,_react.useState)(!1),[F,P]=(0,_react.useState)([]),R=(0,_react.useMemo)(()=>t??[v.colors.primary,v.colors.neutral,v.colors.success,v.colors.warning,v.colors.danger,v.colors.info],[t,v.colors]),A=(0,_reactNativeReanimated.useSharedValue)(0),E=o*SPEED_FACTOR[s],M=(0,_react.useCallback)(()=>{x(!1),u?.()},[u]),T=(0,_react.useCallback)(()=>{if(y)return void u?.();(0,_reactNativeReanimated.cancelAnimation)(A),A.value=0,P(buildPieces(a,r,{colors:R,baseSize:p,originXFrac:c?c.x/Math.max(1,g.width):.5,originYFrac:c?c.y/Math.max(1,g.height):.5,physics:{velocity:void 0===n?.velocity?DEFAULT_PHYSICS.velocity:n.velocity,drag:void 0===n?.drag?DEFAULT_PHYSICS.drag:n.drag,fallSpeed:void 0===n?.fallSpeed?DEFAULT_PHYSICS.fallSpeed:n.fallSpeed,spread:void 0===n?.spread?DEFAULT_PHYSICS.spread:n.spread},shapes:i??PRESET_SHAPES[r]})),x(!0);const e=(0,_reactNativeReanimated.withTiming)(1,{duration:E,easing:_reactNativeReanimated.Easing.linear},e=>{"worklet";e&&!h&&(0,_reactNativeWorklets.scheduleOnRN)(M)});A.value=h?(0,_reactNativeReanimated.withRepeat)(e,-1,!1):e},[y,A,E,h,M,u,a,R,r,i,n,p,c,g.width,g.height]),N=(0,_react.useCallback)(()=>{(0,_reactNativeReanimated.cancelAnimation)(A),x(!1)},[A]);(0,_react.useImperativeHandle)(e,()=>({start:T,stop:N}),[T,N]);const j=(0,_react.useRef)(d).current,C=(0,_react.useRef)(T).current;(0,_react.useEffect)(()=>(j&&C(),()=>(0,_reactNativeReanimated.cancelAnimation)(A)),[A,j,C]);const k=(0,_react.useCallback)(e=>{const{width:a,height:t}=e.nativeEvent.layout;a>0&&t>0&&S({width:a,height:t})},[]),b=(0,_react.useMemo)(()=>F.map((e,a)=>({key:`confetti-${a}`,piece:e})),[F]);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_reactNative.StyleSheet.absoluteFill,_],pointerEvents:"none",onLayout:k,testID:m,children:w?b.map(({key:e,piece:a})=>(0,_jsxRuntime.jsx)(ConfettiPiece,{piece:a,progress:A,width:g.width,height:g.height,fadeOut:l},e)):null})}var _default=exports.default=Confetti;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Drawer=Drawer,exports.default=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_reactNativeWorklets=require("react-native-worklets"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../text/index.js"),_drawerG=require("../../text/phone/drawer.g.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,i=Object.defineProperty,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Drawer=Drawer,exports.default=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_reactNativeWorklets=require("react-native-worklets"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../text/index.js"),_drawerG=require("../../text/phone/drawer.g.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_animatedDeps=require("../../utils/animatedDeps.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,i=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=i&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?i(s,r,a):s[r]=e[r]);return s}const DEFAULT_CLOSE_VELOCITY_THRESHOLD=1e3,DEFAULT_DRAG_ACTIVATION_OFFSET=10;function Drawer({ref:e,...t}){const{open:a,defaultOpen:r=!1,onOpenChange:i,side:s="left",width:n,enableSwipe:o=!0,enableBackdropPress:c=!0,backdropOpacity:l=.5,haptic:u,sheetStyle:d,children:_,accessibilityLabel:p,labels:v,testID:f}=t,h=(0,_index2.useTheme)();(0,_assertValidValue.assertValidValue)("Drawer","side",t.side,["left","right","top","bottom"]);const m=(0,_index.useMobileUiText)("drawer",_drawerG.DRAWER_TEXT),b=(0,_react.useMemo)(()=>({...m,...v}),[m,v]),R=(0,_usePresenceMotion.usePresenceMotion)(),N=R.reduced,g=R.duration("default"),O=R.duration("fast"),E=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),T="boolean"==typeof a,w=(0,_reactNative.useWindowDimensions)(),S="left"===s||"right"===s,x=(0,_react.useMemo)(()=>resolveSize(n,S,w),[n,S,w]),D=(0,_react.useMemo)(()=>closedOffsetOf(s,x),[s,x]),y=(0,_reactNativeReanimated.useSharedValue)(r?0:D),M=(0,_reactNativeReanimated.useSharedValue)(r?0:D),C=(0,_reactNativeReanimated.useSharedValue)(r?1:0),[A,L]=(0,_react.useState)(r),j=(0,_reactNativeReanimated.useSharedValue)(r);(0,_react.useEffect)(()=>{A||N||(y.value=D,M.value=D)},[D,A,y,M,N]);const k=h.motion.spring.snappy,V=(0,_react.useCallback)(()=>{if(N)return y.value=0,void(C.value=(0,_reactNativeReanimated.withTiming)(1,{duration:g,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}));C.value=1,y.value=(0,_reactNativeReanimated.withSpring)(0,k)},[y,C,k,N,g]),F=(0,_react.useCallback)(()=>{N?C.value=(0,_reactNativeReanimated.withTiming)(0,{duration:O,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(y.value=D)}):y.value=(0,_reactNativeReanimated.withSpring)(D,k)},[y,C,D,k,N,O]),I=(0,_react.useCallback)(e=>{L(t=>t===e?t:(i?.(e),e)),j.value=e},[i,j]),P=(0,_react.useCallback)(()=>{I(!0),V()},[I,V]),q=(0,_react.useCallback)(()=>{I(!1),F()},[I,F]),U=(0,_react.useCallback)(()=>{A?q():P()},[A,P,q]);(0,_react.useImperativeHandle)(e,()=>({open:P,close:q,toggle:U}),[P,q,U]);const G=(0,_react.useRef)({isOpen:A,open:P,close:q});G.current={isOpen:A,open:P,close:q},(0,_react.useEffect)(()=>{if(!T)return;const e=G.current;a!==e.isOpen&&(a?e.open():e.close())},[a,T]);const H=(0,_react.useMemo)(()=>{const e=D,t=s,a=o;return{...S?{activeOffsetX:[-DEFAULT_DRAG_ACTIVATION_OFFSET,DEFAULT_DRAG_ACTIVATION_OFFSET],failOffsetY:[-15,15]}:{activeOffsetY:[-DEFAULT_DRAG_ACTIVATION_OFFSET,DEFAULT_DRAG_ACTIVATION_OFFSET],failOffsetX:[-15,15]},onActivate:()=>{"worklet";a&&(M.value=y.value)},onUpdate:t=>{"worklet";if(!a)return;const r=S?t.translationX:t.translationY,i=M.value+r,s=Math.min(0,e),n=Math.max(0,e);y.value=i<s?s+.25*(i-s):i>n?n+.25*(i-n):i},onDeactivate:r=>{"worklet";if(!a)return;const i=S?r.velocityX:r.velocityY,s=y.value;let n=!1;n="left"===t||"top"===t?i<-DEFAULT_CLOSE_VELOCITY_THRESHOLD:i>DEFAULT_CLOSE_VELOCITY_THRESHOLD;const o=Math.abs(e),c=Math.abs(s)/o;n||c>.5?((0,_reactNativeWorklets.scheduleOnRN)(I,!1),N?C.value=(0,_reactNativeReanimated.withTiming)(0,{duration:O,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},t=>{"worklet";t&&(y.value=e)}):y.value=(0,_reactNativeReanimated.withSpring)(e,k)):((0,_reactNativeWorklets.scheduleOnRN)(I,!0),N?(y.value=0,C.value=(0,_reactNativeReanimated.withTiming)(1,{duration:g,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION})):y.value=(0,_reactNativeReanimated.withSpring)(0,k))}}},[D,M,o,S,y,C,I,s,k,N,g,O]),W=(0,_reactNativeGestureHandler.usePanGesture)(H),Y=(0,_reactNativeReanimated.useAnimatedStyle)(()=>S?{opacity:C.value,transform:[{translateX:y.value}]}:{opacity:C.value,transform:[{translateY:y.value}]},...(0,_animatedDeps.webDeps)([S,y,C])),X=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:(0,_reactNativeReanimated.interpolate)(y.value,[D,0],[0,l],_reactNativeReanimated.Extrapolation.CLAMP)*C.value,pointerEvents:Math.abs(y.value-D)<.5?"none":"auto"}),...(0,_animatedDeps.webDeps)([y,D,l,C])),B=(0,_react.useMemo)(()=>buildStyles(h),[h]),z=(0,_react.useCallback)(()=>{if(!c)return;const e=(0,_index3.resolveHaptic)(u,"selection");e&&(0,_index3.triggerHaptic)(e),q()},[c,q,u]),J=(0,_react.useMemo)(()=>sideLayoutOf(s,x,E),[s,x,E]),K=(0,_react.useRef)(r);return A&&(K.current=!0),K.current?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_reactNative.StyleSheet.absoluteFill,pointerEvents:"box-none",testID:f,accessibilityViewIsModal:A,children:[(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[B.backdrop,{backgroundColor:h.colors.scrim},X],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:z,accessibilityRole:"button",accessibilityLabel:b.close,disabled:!c||!A})}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:W,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:p??b.drawer,style:[J,{backgroundColor:h.colors.surface,...h.shadow.modal},d,Y],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.content,children:_})})})]}):null}const closedOffsetOf=(e,t)=>{switch(e){case"left":case"top":return-t;case"right":case"bottom":return t}},sideLayoutOf=(e,t,a)=>{switch(e){case"left":return{position:"absolute",top:0,bottom:0,left:0,width:t,paddingTop:a.top,paddingBottom:a.bottom,paddingLeft:a.left};case"right":return{position:"absolute",top:0,bottom:0,right:0,width:t,paddingTop:a.top,paddingBottom:a.bottom,paddingRight:a.right};case"top":return{position:"absolute",top:0,left:0,right:0,height:t,paddingTop:a.top,paddingLeft:a.left,paddingRight:a.right};case"bottom":return{position:"absolute",bottom:0,left:0,right:0,height:t,paddingBottom:a.bottom,paddingLeft:a.left,paddingRight:a.right}}},resolveSize=(e,t,a)=>{if("number"==typeof e)return e;if("string"==typeof e){const r=parseFloat(e);if(Number.isNaN(r))return t?280:Math.round(.4*a.height);return r/100*(t?a.width:a.height)}return t?280:Math.round(.4*a.height)},buildStyles=e=>_reactNative.StyleSheet.create({backdrop:{..._reactNative.StyleSheet.absoluteFill},content:{flex:1}});var _default=exports.default=Drawer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FloatingActionButton=FloatingActionButton,exports.default=exports.FloatingActionButtonGroup=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("../../text/index.js"),_floatingActionButtonG=require("../../text/phone/floatingActionButton.g.js"),_index2=require("../../theme/index.js"),_announce=require("../../utils/announce.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,n,o=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)&&((i=o&&Object.getOwnPropertyDescriptor(e,n))&&(i.get||i.set)?o(r,n,i):r[n]=e[n]);return r}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"]}};function FloatingActionButton({ref:e,...t}){const{icon:i,onPress:n,label:o,collapsed:r=!1,size:a="md",tone:s="primary",position:c,bottomOffset:l,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:_=!1,accessibilityLabel:p,accessibilityHint:b,haptic:f,style:g,labelStyle:v,testID:h}=t;(0,_assertValidValue.assertValidValue)("FloatingActionButton","size",t.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","tone",t.tone,FAB_TONES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","position",t.position,FAB_POSITIONS);const x=!u&&!d,y=(0,_index2.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),A=(0,_react.useMemo)(()=>(0,_index2.resolveFloatingActionButtonSize)(y,a),[y,a]),j=(0,_react.useMemo)(()=>buildStyles(y),[y]),{style:N,pressIn:S,pressOut:w}=(0,_usePressAnimation.usePressAnimation)({enabled:x}),V=(0,_usePresenceMotion.usePresenceMotion)(),I=y.space[y.components["floating-action-button"]["edge-offset"]],E=y.space[y.components["floating-action-button"]["bottom-offset"]],C=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current,F=V.duration("default");(0,_react.useEffect)(()=>{if(!m)return void(0,_index2.setNativeValue)(C,1);const e=_reactNative.Animated.timing(C,{toValue:_?0:1,duration:F,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[m,_,C,F,y.motion.ease["in-out"]]);const P=A.diameter+(l??E)+R.bottom+I,B=C.interpolate({inputRange:[0,1],outputRange:V.range(P,0)}),T=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(C,N.opacity),[C,N.opacity]),D="string"==typeof o&&o.length>0,O=D&&r,k=V.reduced,M=y.space.sm,q=A["label-padding-x"],z=y.motion.duration.fast,L=y.motion.ease["in-out"],G=(0,_reactNativeReanimated.useSharedValue)(O?1:0),[H,U]=(0,_react.useState)(null);(0,_react.useEffect)(()=>{const e=O?1:0;return G.value=k?e:(0,_reactNativeReanimated.withTiming)(e,{duration:z,easing:_reactNativeReanimated.Easing.bezier(...L)}),()=>(0,_reactNativeReanimated.cancelAnimation)(G)},[O,k,G,z,L]);const $=(0,_react.useCallback)(e=>{const t=Math.ceil(e);U(e=>e===t?e:t)},[]),W=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({paddingHorizontal:q*(1-G.value)}),[q,G]),Y=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=Math.max(0,1-2*G.value);return null===H?G.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(H+M)*(1-G.value)}},[G,H,M]),Z=u?y.colors["surface-disabled"]:toneBackground(y,s),X=u?y.colors["text-disabled"]:toneForeground(y,s),J="lg"===a?"md":"sm",K=d?(0,_jsxRuntime.jsx)(_index3.Spinner,{variant:"circular",size:J,color:X}):(0,_slotIcon.renderSlotIcon)(i,{color:X,size:A.icon,disabled:u}),Q=(0,_react.useMemo)(()=>{if(!c)return null;const e=(l??E)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:I};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:I}}},[c,l,R.bottom,E,I]);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[Q,{transform:[{translateY:B},...N.transform],opacity:T},g],pointerEvents:m&&_?"none":"auto",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:e,onPress:e=>{if(!x)return;const t=(0,_hapticUtils.resolveHaptic)(f,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),n()},onPressIn:S,onPressOut:w,disabled:!x,accessibilityRole:"button",accessibilityLabel:p,accessibilityHint:b,accessibilityState:{disabled:!x,busy:d},"aria-disabled":!x,"aria-busy":d,testID:h,style:[j.base,D?{height:A.diameter,minWidth:A.diameter,borderRadius:A.diameter/2,..._corners.smoothCorners}:{width:A.diameter,height:A.diameter,borderRadius:A.diameter/2,..._corners.smoothCorners},y.shadow.popover,{backgroundColor:Z,opacity:u||d?.55:1}],children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e&&x?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[j.pressedTint,{backgroundColor:pressedTintFor(y,s),borderRadius:A.diameter/2,..._corners.smoothCorners}]}):null,D?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[j.extendedRow,W],children:[K,(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[j.labelClip,Y],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{onLayout:e=>$(e.nativeEvent.layout.width),style:[j.label,{color:X,fontSize:A.text,fontWeight:y.weight.semibold,marginLeft:M},v],numberOfLines:1,children:o})})]}):K]})})})}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.":"",FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:i,actions:n,expanded:o,defaultExpanded:r=!1,onExpandedChange:a,labels:s,position:c="bottomRight",bottomOffset:l,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:_=!1,isScrolling:p=!1,style:b,secondaryActionStyle:f,labelPillStyle:g,labelStyle:v,testID:h}=e;(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","size",e.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const x=(0,_index.useMobileUiText)("floatingActionButton",_floatingActionButtonG.FLOATING_ACTION_BUTTON_TEXT),y=(0,_react.useMemo)(()=>({...x,...s}),[x,s]),R=d??y.quickActions,A=(0,_index2.useTheme)(),j=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),N=(0,_react.useMemo)(()=>(0,_index2.resolveFloatingActionButtonSize)(A,u),[A,u]),S=(0,_react.useMemo)(()=>buildGroupStyles(A),[A]),w=(0,_usePresenceMotion.usePresenceMotion)(),V=w.duration("default"),I=A.space[A.components["floating-action-button"]["edge-offset"]],E=A.space[A.components["floating-action-button"]["bottom-offset"]],C=A.space[A.components["floating-action-button"]["secondary-gap"]],F=A.components["floating-action-button"]["stagger-ms"],P=(0,_react.useMemo)(()=>n.slice(0,6),[n]),B=P.length,T=(0,_react.useMemo)(()=>P.map((e,t)=>({action:e,index:t})).reverse(),[P]);n.forEach(e=>{(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const D=__DEV__?describeActionProblem(n):"";(0,_react.useEffect)(()=>{__DEV__&&D&&_mobileCore.Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${D}`)},[D]);const O="boolean"==typeof o,[k,M]=(0,_react.useState)(r),q="boolean"==typeof o?o:k,z=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!_)return void(0,_index2.setNativeValue)(z,1);const e=_reactNative.Animated.timing(z,{toValue:p?0:1,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[_,p,z,V,A.motion.ease["in-out"]]);const L=_&&p;(0,_react.useEffect)(()=>{L&&q&&(O||M(!1),a?.(!1))},[L,q,O,a]);const G=N.diameter+(l??E)+j.bottom+I,H=z.interpolate({inputRange:[0,1],outputRange:w.range(G,0)}),U=z,$=(0,_react.useRef)((0,_index2.createAnimatedValue)(q?1:0)).current,W=(0,_react.useRef)([]),[Y,Z]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{const e=W.current;if(e.length!==B){if(e.length<B){const t=e.slice();for(let i=e.length;i<B;i+=1)t.push(new _reactNative.Animated.Value(q?1:0));W.current=t}else W.current=e.slice(0,B);Z(e=>e+1)}},[B,q]),(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing($,{toValue:q?1:0,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});e.start();const t=W.current.map(e=>_reactNative.Animated.timing(e,{toValue:q?1:0,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver})),i=q?t:[...t].reverse(),n=_reactNative.Animated.stagger(F,i);return n.start(),()=>{e.stop(),n.stop()}},[q,$,V,A.motion.ease["in-out"],B,Y,F]);const X=(0,_react.useCallback)(e=>{const t=(0,_hapticUtils.resolveHaptic)(m,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),O||M(e),a?.(e)},[O,a,m]),J=(0,_react.useRef)(null),K=(0,_react.useRef)(q),Q=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(K.current===q)return;K.current=q;const e=Q.current;if(Q.current=!1,L||e)return;const t=J.current;t&&("web"===_reactNative.Platform.OS?"focus"in t&&"function"==typeof t.focus&&t.focus():_reactNative.AccessibilityInfo.sendAccessibilityEvent(t,"focus")),(0,_announce.announce)(q?(0,_index.pluralText)(y,"expanded",B,{label:R}):(0,_index.fillText)(y.collapsed,{label:R}))},[q,L,R,B,y]);const ee=(0,_react.useCallback)(()=>{X(!q)},[q,X]),te=(0,_react.useCallback)(e=>{!1!==m&&(0,_hapticUtils.triggerHaptic)("selection"),Q.current=!0,e.onPress(),O||M(!1),a?.(!1)},[O,a,m]),ie=(0,_react.useCallback)(()=>{q&&X(!1)},[q,X]);(0,_react.useEffect)(()=>{if(!q)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(X(!1),!0));return()=>e.remove()},[q,X]),(0,_react.useEffect)(()=>{if(!q||"web"!==_reactNative.Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&X(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[q,X]);const ne=(0,_react.useMemo)(()=>{const e=(l??E)+j.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:I,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:I,alignItems:"flex-end"}}},[c,l,j.bottom,E,I]),slotOffset=e=>-(N.diameter+C)*(e+1),oe=(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]),re=.78*N.diameter,ae=(0,_react.useMemo)(()=>{const e=re+A.space.sm;switch(c){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:N.diameter/2+re/2+A.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[c,re,N.diameter,A.space.sm]),se=$.interpolate({inputRange:[0,1],outputRange:[0,.4]}),ce=$.interpolate(w.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:q?"auto":"none",style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:A.colors.scrim,opacity:se}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:ie,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:h?`${h}-backdrop`:void 0})}):null,(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:L?"none":"box-none",style:[ne,{transform:[{translateY:H}],opacity:U},b],accessibilityRole:"menu",testID:h,children:[T.map(({action:e,index:t})=>{const i=W.current[t];if(!i)return null;const n=i.interpolate({inputRange:[0,1],outputRange:w.range(0,slotOffset(t))}),o=i.interpolate({inputRange:[0,1],outputRange:w.range(.6,1)}),r=toneBackground(A,e.tone??"primary"),a=toneForeground(A,e.tone??"primary"),s=e.label?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[S.labelSlot,ae],testID:h?`${h}-label-${e.key}`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[S.labelPill,A.shadow.card,{backgroundColor:A.colors.surface,paddingHorizontal:A.space.sm,paddingVertical:A.space.xs,borderRadius:A.radius.sm,..._corners.smoothCorners},g],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:q?"auto":"none",accessibilityElementsHidden:!q,importantForAccessibility:q?"auto":"no-hide-descendants","aria-hidden":!q,style:[S.secondaryRow,oe,{position:"absolute",bottom:0,opacity:i,transform:[{translateY:n},{scale:o}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>te(e),focusable:q,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[S.fabBase,A.shadow.elevated,{width:re,height:re,borderRadius:re/2,..._corners.smoothCorners,backgroundColor:r},f],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:[S.pressedTint,{backgroundColor:pressedTintFor(A,e.tone??"primary"),borderRadius:re/2,..._corners.smoothCorners}]}):null,(0,_slotIcon.renderSlotIcon)(e.icon,{color:a,size:N.icon,disabled:!1})]})}),s]},e.key)}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:J,onPress:ee,accessibilityRole:"button",accessibilityLabel:R,accessibilityState:{expanded:q},"aria-expanded":q,style:[S.fabBase,A.shadow.popover,{width:N.diameter,height:N.diameter,borderRadius:N.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:[S.pressedTint,{backgroundColor:_color.ACCENT_PRESSED_TINT,borderRadius:N.diameter/2,..._corners.smoothCorners}]}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:i?void 0:{transform:[{rotate:ce}]},children:(0,_slotIcon.renderSlotIcon)(q&&i?i:t,{color:A.colors["on-primary"],size:N.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.FloatingActionButton=FloatingActionButton,exports.default=exports.FloatingActionButtonGroup=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("../../text/index.js"),_floatingActionButtonG=require("../../text/phone/floatingActionButton.g.js"),_index2=require("../../theme/index.js"),_animatedDeps=require("../../utils/animatedDeps.js"),_announce=require("../../utils/announce.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index3=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,n,r=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(n in e)"default"!==n&&{}.hasOwnProperty.call(e,n)&&((i=r&&Object.getOwnPropertyDescriptor(e,n))&&(i.get||i.set)?r(a,n,i):a[n]=e[n]);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"]}};function FloatingActionButton({ref:e,...t}){const{icon:i,onPress:n,label:r,collapsed:a=!1,size:o="md",tone:s="primary",position:c,bottomOffset:l,disabled:u=!1,loading:d=!1,hideOnScroll:m=!1,isScrolling:_=!1,accessibilityLabel:p,accessibilityHint:b,haptic:f,style:g,labelStyle:v,testID:h}=t;(0,_assertValidValue.assertValidValue)("FloatingActionButton","size",t.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","tone",t.tone,FAB_TONES),(0,_assertValidValue.assertValidValue)("FloatingActionButton","position",t.position,FAB_POSITIONS);const x=!u&&!d,y=(0,_index2.useTheme)(),R=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),A=(0,_react.useMemo)(()=>(0,_index2.resolveFloatingActionButtonSize)(y,o),[y,o]),j=(0,_react.useMemo)(()=>buildStyles(y),[y]),{style:N,pressIn:S,pressOut:w}=(0,_usePressAnimation.usePressAnimation)({enabled:x}),V=(0,_usePresenceMotion.usePresenceMotion)(),I=y.space[y.components["floating-action-button"]["edge-offset"]],E=y.space[y.components["floating-action-button"]["bottom-offset"]],C=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current,F=V.duration("default");(0,_react.useEffect)(()=>{if(!m)return void(0,_index2.setNativeValue)(C,1);const e=_reactNative.Animated.timing(C,{toValue:_?0:1,duration:F,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[m,_,C,F,y.motion.ease["in-out"]]);const P=A.diameter+(l??E)+R.bottom+I,B=C.interpolate({inputRange:[0,1],outputRange:V.range(P,0)}),D=(0,_react.useMemo)(()=>_reactNative.Animated.multiply(C,N.opacity),[C,N.opacity]),T="string"==typeof r&&r.length>0,O=T&&a,k=V.reduced,M=y.space.sm,q=A["label-padding-x"],z=y.motion.duration.fast,L=y.motion.ease["in-out"],G=(0,_reactNativeReanimated.useSharedValue)(O?1:0),[H,U]=(0,_react.useState)(null);(0,_react.useEffect)(()=>{const e=O?1:0;return G.value=k?e:(0,_reactNativeReanimated.withTiming)(e,{duration:z,easing:_reactNativeReanimated.Easing.bezier(...L)}),()=>(0,_reactNativeReanimated.cancelAnimation)(G)},[O,k,G,z,L]);const $=(0,_react.useCallback)(e=>{const t=Math.ceil(e);U(e=>e===t?e:t)},[]),W=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({paddingHorizontal:q*(1-G.value)}),...(0,_animatedDeps.webDeps)([q,G])),Y=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=Math.max(0,1-2*G.value);return null===H?G.value>=1?{opacity:e,width:0}:{opacity:e}:{opacity:e,width:(H+M)*(1-G.value)}},...(0,_animatedDeps.webDeps)([G,H,M])),Z=u?y.colors["surface-disabled"]:toneBackground(y,s),X=u?y.colors["text-disabled"]:toneForeground(y,s),J="lg"===o?"md":"sm",K=d?(0,_jsxRuntime.jsx)(_index3.Spinner,{variant:"circular",size:J,color:X}):(0,_slotIcon.renderSlotIcon)(i,{color:X,size:A.icon,disabled:u}),Q=(0,_react.useMemo)(()=>{if(!c)return null;const e=(l??E)+R.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:I};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center"};default:return{position:"absolute",bottom:e,right:I}}},[c,l,R.bottom,E,I]);return(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[Q,{transform:[{translateY:B},...N.transform],opacity:D},g],pointerEvents:m&&_?"none":"auto",children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:e,onPress:e=>{if(!x)return;const t=(0,_hapticUtils.resolveHaptic)(f,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),n()},onPressIn:S,onPressOut:w,disabled:!x,accessibilityRole:"button",accessibilityLabel:p,accessibilityHint:b,accessibilityState:{disabled:!x,busy:d},"aria-disabled":!x,"aria-busy":d,testID:h,style:[j.base,T?{height:A.diameter,minWidth:A.diameter,borderRadius:A.diameter/2,..._corners.smoothCorners}:{width:A.diameter,height:A.diameter,borderRadius:A.diameter/2,..._corners.smoothCorners},y.shadow.popover,{backgroundColor:Z,opacity:u||d?.55:1}],children:({pressed:e})=>(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[e&&x?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",testID:"fab-pressed",style:[j.pressedTint,{backgroundColor:pressedTintFor(y,s),borderRadius:A.diameter/2,..._corners.smoothCorners}]}):null,T?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[j.extendedRow,W],children:[K,(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[j.labelClip,Y],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{onLayout:e=>$(e.nativeEvent.layout.width),style:[j.label,{color:X,fontSize:A.text,fontWeight:y.weight.semibold,marginLeft:M},v],numberOfLines:1,children:r})})]}):K]})})})}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.":"",FloatingActionButtonGroup=e=>{const{primaryIcon:t,primaryActiveIcon:i,actions:n,expanded:r,defaultExpanded:a=!1,onExpandedChange:o,labels:s,position:c="bottomRight",bottomOffset:l,size:u="md",accessibilityLabel:d,haptic:m,hideOnScroll:_=!1,isScrolling:p=!1,style:b,secondaryActionStyle:f,labelPillStyle:g,labelStyle:v,testID:h}=e;(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","size",e.size,FAB_SIZES),(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","position",e.position,FAB_POSITIONS);const x=(0,_index.useMobileUiText)("floatingActionButton",_floatingActionButtonG.FLOATING_ACTION_BUTTON_TEXT),y=(0,_react.useMemo)(()=>({...x,...s}),[x,s]),R=d??y.quickActions,A=(0,_index2.useTheme)(),j=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),N=(0,_react.useMemo)(()=>(0,_index2.resolveFloatingActionButtonSize)(A,u),[A,u]),S=(0,_react.useMemo)(()=>buildGroupStyles(A),[A]),w=(0,_usePresenceMotion.usePresenceMotion)(),V=w.duration("default"),I=A.space[A.components["floating-action-button"]["edge-offset"]],E=A.space[A.components["floating-action-button"]["bottom-offset"]],C=A.space[A.components["floating-action-button"]["secondary-gap"]],F=A.components["floating-action-button"]["stagger-ms"],P=(0,_react.useMemo)(()=>n.slice(0,6),[n]),B=P.length,D=(0,_react.useMemo)(()=>P.map((e,t)=>({action:e,index:t})).reverse(),[P]);n.forEach(e=>{(0,_assertValidValue.assertValidValue)("FloatingActionButtonGroup","actions[].tone",e.tone,FAB_TONES)});const T=__DEV__?describeActionProblem(n):"";(0,_react.useEffect)(()=>{__DEV__&&T&&_mobileCore.Logger.warn(`[@webority/mobile-ui] FloatingActionButtonGroup ${T}`)},[T]);const O="boolean"==typeof r,[k,M]=(0,_react.useState)(a),q="boolean"==typeof r?r:k,z=(0,_react.useRef)((0,_index2.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!_)return void(0,_index2.setNativeValue)(z,1);const e=_reactNative.Animated.timing(z,{toValue:p?0:1,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[_,p,z,V,A.motion.ease["in-out"]]);const L=_&&p;(0,_react.useEffect)(()=>{L&&q&&(O||M(!1),o?.(!1))},[L,q,O,o]);const G=N.diameter+(l??E)+j.bottom+I,H=z.interpolate({inputRange:[0,1],outputRange:w.range(G,0)}),U=z,$=(0,_react.useRef)((0,_index2.createAnimatedValue)(q?1:0)).current,W=(0,_react.useRef)([]),[Y,Z]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{const e=W.current;if(e.length!==B){if(e.length<B){const t=e.slice();for(let i=e.length;i<B;i+=1)t.push(new _reactNative.Animated.Value(q?1:0));W.current=t}else W.current=e.slice(0,B);Z(e=>e+1)}},[B,q]),(0,_react.useEffect)(()=>{const e=_reactNative.Animated.timing($,{toValue:q?1:0,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver});e.start();const t=W.current.map(e=>_reactNative.Animated.timing(e,{toValue:q?1:0,duration:V,easing:_reactNative.Easing.bezier(...A.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver})),i=q?t:[...t].reverse(),n=_reactNative.Animated.stagger(F,i);return n.start(),()=>{e.stop(),n.stop()}},[q,$,V,A.motion.ease["in-out"],B,Y,F]);const X=(0,_react.useCallback)(e=>{const t=(0,_hapticUtils.resolveHaptic)(m,"impactLight");t&&(0,_hapticUtils.triggerHaptic)(t),O||M(e),o?.(e)},[O,o,m]),J=(0,_react.useRef)(null),K=(0,_react.useRef)(q),Q=(0,_react.useRef)(!1);(0,_react.useEffect)(()=>{if(K.current===q)return;K.current=q;const e=Q.current;if(Q.current=!1,L||e)return;const t=J.current;t&&("web"===_reactNative.Platform.OS?"focus"in t&&"function"==typeof t.focus&&t.focus():_reactNative.AccessibilityInfo.sendAccessibilityEvent(t,"focus")),(0,_announce.announce)(q?(0,_index.pluralText)(y,"expanded",B,{label:R}):(0,_index.fillText)(y.collapsed,{label:R}))},[q,L,R,B,y]);const ee=(0,_react.useCallback)(()=>{X(!q)},[q,X]),te=(0,_react.useCallback)(e=>{!1!==m&&(0,_hapticUtils.triggerHaptic)("selection"),Q.current=!0,e.onPress(),O||M(!1),o?.(!1)},[O,o,m]),ie=(0,_react.useCallback)(()=>{q&&X(!1)},[q,X]);(0,_react.useEffect)(()=>{if(!q)return;const e=_reactNative.BackHandler.addEventListener("hardwareBackPress",()=>(X(!1),!0));return()=>e.remove()},[q,X]),(0,_react.useEffect)(()=>{if(!q||"web"!==_reactNative.Platform.OS)return;const onKeyDown=e=>{"Escape"===e.key&&X(!1)};return window.addEventListener("keydown",onKeyDown),()=>window.removeEventListener("keydown",onKeyDown)},[q,X]);const ne=(0,_react.useMemo)(()=>{const e=(l??E)+j.bottom;switch(c){case"bottomLeft":return{position:"absolute",bottom:e,left:I,alignItems:"flex-start"};case"bottomCenter":return{position:"absolute",bottom:e,alignSelf:"center",alignItems:"center"};default:return{position:"absolute",bottom:e,right:I,alignItems:"flex-end"}}},[c,l,j.bottom,E,I]),slotOffset=e=>-(N.diameter+C)*(e+1),re=(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]),ae=.78*N.diameter,oe=(0,_react.useMemo)(()=>{const e=ae+A.space.sm;switch(c){case"bottomLeft":return{left:e,alignItems:"flex-start"};case"bottomCenter":return{right:N.diameter/2+ae/2+A.space.sm,alignItems:"flex-end"};default:return{right:e,alignItems:"flex-end"}}},[c,ae,N.diameter,A.space.sm]),se=$.interpolate({inputRange:[0,1],outputRange:[0,.4]}),ce=$.interpolate(w.reduced?{inputRange:[0,.5,.5001,1],outputRange:["0deg","0deg","45deg","45deg"]}:{inputRange:[0,1],outputRange:["0deg","45deg"]});return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:q?"auto":"none",style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:A.colors.scrim,opacity:se}],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:ie,accessibilityElementsHidden:!0,importantForAccessibility:"no",testID:h?`${h}-backdrop`:void 0})}):null,(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{pointerEvents:L?"none":"box-none",style:[ne,{transform:[{translateY:H}],opacity:U},b],accessibilityRole:"menu",testID:h,children:[D.map(({action:e,index:t})=>{const i=W.current[t];if(!i)return null;const n=i.interpolate({inputRange:[0,1],outputRange:w.range(0,slotOffset(t))}),r=i.interpolate({inputRange:[0,1],outputRange:w.range(.6,1)}),a=toneBackground(A,e.tone??"primary"),o=toneForeground(A,e.tone??"primary"),s=e.label?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[S.labelSlot,oe],testID:h?`${h}-label-${e.key}`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[S.labelPill,A.shadow.card,{backgroundColor:A.colors.surface,paddingHorizontal:A.space.sm,paddingVertical:A.space.xs,borderRadius:A.radius.sm,..._corners.smoothCorners},g],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:q?"auto":"none",accessibilityElementsHidden:!q,importantForAccessibility:q?"auto":"no-hide-descendants","aria-hidden":!q,style:[S.secondaryRow,re,{position:"absolute",bottom:0,opacity:i,transform:[{translateY:n},{scale:r}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>te(e),focusable:q,accessibilityRole:"menuitem",accessibilityLabel:e.accessibilityLabel,style:[S.fabBase,A.shadow.elevated,{width:ae,height:ae,borderRadius:ae/2,..._corners.smoothCorners,backgroundColor:a},f],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:[S.pressedTint,{backgroundColor:pressedTintFor(A,e.tone??"primary"),borderRadius:ae/2,..._corners.smoothCorners}]}):null,(0,_slotIcon.renderSlotIcon)(e.icon,{color:o,size:N.icon,disabled:!1})]})}),s]},e.key)}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:J,onPress:ee,accessibilityRole:"button",accessibilityLabel:R,accessibilityState:{expanded:q},"aria-expanded":q,style:[S.fabBase,A.shadow.popover,{width:N.diameter,height:N.diameter,borderRadius:N.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:[S.pressedTint,{backgroundColor:_color.ACCENT_PRESSED_TINT,borderRadius:N.diameter/2,..._corners.smoothCorners}]}):null,(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:i?void 0:{transform:[{rotate:ce}]},children:(0,_slotIcon.renderSlotIcon)(q&&i?i:t,{color:A.colors["on-primary"],size:N.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=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeWorklets=require("react-native-worklets"),_index=require("../../text/index.js"),_imageGalleryG=require("../../text/phone/imageGallery.g.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index4=require("../Carousel/index.js"),_Modal=require("../Modal/Modal.js"),_index5=require("../Skeleton/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,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)&&((a=l&&Object.getOwnPropertyDescriptor(e,i))&&(a.get||a.set)?l(r,i,a):r[i]=e[i]);return r}const MAX_SCALE_FALLBACK=4,MIN_SCALE_FALLBACK=1,DOUBLE_TAP_SCALE_FALLBACK=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ImageGallery=({images:e,initialIndex:t=0,showThumbnails:a=!0,showCounter:i=!0,enableLightbox:l=!0,enablePinchZoom:r=!0,onIndexChange:n,haptic:s,loading:o=!1,accessibilityLabel:c,style:u,testID:d,labels:m})=>{const _=(0,_index2.useTheme)(),h=(0,_react.useMemo)(()=>buildStyles(_),[_]),x=(0,_index.useMobileUiText)("imageGallery",_imageGalleryG.IMAGE_GALLERY_TEXT),g=(0,_react.useMemo)(()=>({...x,...m}),[x,m]),[v,p]=(0,_react.useState)(clamp(t,0,Math.max(0,e.length-1))),[b,y]=(0,_react.useState)(!1),R=(0,_react.useCallback)(e=>{p(e),n?.(e)},[n]),N=(0,_react.useCallback)(()=>{if(!l)return;const e=(0,_index3.resolveHaptic)(s,"selection");e&&(0,_index3.triggerHaptic)(e),y(!0)},[l,s]),j=(0,_react.useCallback)(()=>{const e=(0,_index3.resolveHaptic)(s,"selection");e&&(0,_index3.triggerHaptic)(e),y(!1)},[s]),I=(0,_react.useCallback)((t,a)=>{const i=t.alt??(0,_index.fillText)(g.imageOf,{index:a+1,total:e.length});return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:N,accessibilityRole:"image",accessibilityLabel:i,accessibilityHint:l?g.openFullscreen:void 0,style:h.imageWrap,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:t.source,style:h.image,resizeMode:"cover"})})},[l,e.length,N,h,g]),S=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNative.Image,{source:e.source,style:h.thumbnailImage,resizeMode:"cover"}),[h]),w=(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:b,importantForAccessibility:b?"no-hide-descendants":"auto",children:[(0,_jsxRuntime.jsx)(_index4.Carousel,{data:e,defaultIndex:t,onIndexChange:R,renderItem:I,showPagination:!1,showThumbnails:a,renderThumbnail:S,haptic:s}),i&&e.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:h.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"label",weight:"semibold",style:{color:_.colors["on-scrim"]},accessibilityLabel:(0,_index.fillText)(g.imageOf,{index:v+1,total:e.length}),children:`${v+1} / ${e.length}`})}):null]}),l?(0,_jsxRuntime.jsx)(Lightbox,{open:b,images:e,initialIndex:v,enablePinchZoom:r,showCounter:i,onClose:j,onIndexChange:R,haptic:s,labels:g,testID:d}):null]});return o?(0,_jsxRuntime.jsx)(ImageGallerySkeleton,{images:e,showThumbnails:a,showCounter:i,style:u,testID:d}):w};exports.ImageGallery=ImageGallery,ImageGallery.displayName="ImageGallery";const ImageGallerySkeleton=({images:e,showThumbnails:t=!0,showCounter:a=!0,style:i,testID:l})=>{const r=(0,_index2.useTheme)(),n=Math.min(e?.length||4,6),s=(0,_react.useMemo)(()=>Array.from({length:n},(e,t)=>({key:`sk-thumb-${t}`})),[n]);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)(_index5.Skeleton,{width:"100%",height:280,radius:"lg"}),a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",top:12,right:12},children:(0,_jsxRuntime.jsx)(_index5.Skeleton,{width:44,height:22,radius:"pill"})}):null]}),t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:r.space.md},children:s.map(e=>(0,_jsxRuntime.jsx)(_index5.Skeleton,{width:64,height:64,radius:"md",style:{marginRight:r.space.sm}},e.key))}):null]})};ImageGallerySkeleton.displayName="ImageGallerySkeleton",ImageGallery.Skeleton=ImageGallerySkeleton;const Lightbox=({open:e,images:t,initialIndex:a,enablePinchZoom:i,showCounter:l,onClose:r,onIndexChange:n,haptic:s,labels:o,testID:c})=>{const u=(0,_index2.useTheme)(),d=(0,_react.useMemo)(()=>buildLightboxStyles(u),[u]),m=(0,_react.useRef)(null),[_,h]=(0,_react.useState)(a),x=(0,_react.useCallback)(e=>{if(e!==_){const t=(0,_index3.resolveHaptic)(s,"selection");t&&(0,_index3.triggerHaptic)(t),h(e),n(e)}},[_,n,s]),g=(0,_react.useCallback)((e,a)=>(0,_jsxRuntime.jsx)(ZoomableImage,{image:e,index:a,total:t.length,active:a===_,enabled:i,maxScale:4,minScale:1,doubleTapScale:2,haptic:s,imageLabel:o.imageOf}),[_,i,t.length,s,o]),v=t[_]?.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:d.backdrop,children:[(0,_jsxRuntime.jsx)(_index4.Carousel,{ref:m,testID:c?`${c}-lightbox`:void 0,data:t,defaultIndex:a,onIndexChange:x,renderItem:g,showPagination:!1,haptic:s}),l&&t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:d.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"label",weight:"semibold",style:{color:u.colors["on-scrim"]},accessibilityLabel:(0,_index.fillText)(o.imageOf,{index:_+1,total:t.length}),children:`${_+1} / ${t.length}`})}):null,(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:o.closeGallery,style:d.closeButton,hitSlop:12,...(0,_hitSlop.hitSlopMarker)(12),children:(u.settings.icons.close??_defaultIcons.defaultIcons.close)({size:24,color:u.colors["on-scrim"]})}),v?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:d.captionWrap,accessibilityElementsHidden:!1,children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"body",align:"center",numberOfLines:3,style:d.captionText,children:v})}):null]})})},ZoomableImage=({image:e,index:t,total:a,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),x=(0,_reactNativeReanimated.useSharedValue)(0),g=(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),x.value=0,g.value=0},[d,m,_,h,x,g]);_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,x.value=0,g.value=0)},[i,d,_,h,m,x,g]);const p=(0,_react.useCallback)(()=>{!1!==o&&(0,_index3.triggerHaptic)("impactLight")},[o]),b=(0,_react.useMemo)(()=>({enabled:l,onActivate:()=>{"worklet";m.value=d.value},onUpdate:e=>{"worklet";const t=m.value*e.scale;d.value=t<n?n+.3*(t-n):t>r?r+.2*(t-r):t},onDeactivate:()=>{"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,x.value=0,void(g.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,x,g,n,r]),y=(0,_reactNativeGestureHandler.usePinchGesture)(b),R=(0,_react.useMemo)(()=>({minPointers:1,maxPointers:1,onActivate:()=>{"worklet";x.value=_.value,g.value=h.value},onUpdate:e=>{"worklet";d.value<=1||(_.value=x.value+e.translationX,h.value=g.value+e.translationY)},onDeactivate:()=>{"worklet";x.value=_.value,g.value=h.value}}),[d,_,h,x,g]),N=(0,_reactNativeGestureHandler.usePanGesture)(R),j=(0,_react.useMemo)(()=>({numberOfTaps:2,onDeactivate:()=>{"worklet";(0,_reactNativeWorklets.scheduleOnRN)(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,x.value=0,g.value=0):(d.value=(0,_reactNativeReanimated.withSpring)(s,SPRING_CONFIG),m.value=s)}}),[d,m,_,h,x,g,p,s]),I=(0,_reactNativeGestureHandler.useTapGesture)(j),S=(0,_reactNativeGestureHandler.useCompetingGestures)(y,N,I),w=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:_.value},{translateY:h.value},{scale:d.value}]}),[_,h,d]);_react.default.useEffect(()=>{i||v()},[i,v]);const f=e.alt??(0,_index.fillText)(c,{index:t+1,total:a});return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:S,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,w],accessibilityLabel:f,accessible:!0})})})},clamp=(e,t,a)=>Math.min(Math.max(e,t),a),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"]}}),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=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeWorklets=require("react-native-worklets"),_index=require("../../text/index.js"),_imageGalleryG=require("../../text/phone/imageGallery.g.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_animatedDeps=require("../../utils/animatedDeps.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_defaultIcons=require("../AppIcon/defaultIcons.js"),_index4=require("../Carousel/index.js"),_Modal=require("../Modal/Modal.js"),_index5=require("../Skeleton/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,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)&&((a=l&&Object.getOwnPropertyDescriptor(e,i))&&(a.get||a.set)?l(r,i,a):r[i]=e[i]);return r}const MAX_SCALE_FALLBACK=4,MIN_SCALE_FALLBACK=1,DOUBLE_TAP_SCALE_FALLBACK=2,SPRING_CONFIG={damping:18,stiffness:220,mass:1},ImageGallery=({images:e,initialIndex:t=0,showThumbnails:a=!0,showCounter:i=!0,enableLightbox:l=!0,enablePinchZoom:r=!0,onIndexChange:n,haptic:s,loading:o=!1,accessibilityLabel:c,style:u,testID:d,labels:m})=>{const _=(0,_index2.useTheme)(),h=(0,_react.useMemo)(()=>buildStyles(_),[_]),x=(0,_index.useMobileUiText)("imageGallery",_imageGalleryG.IMAGE_GALLERY_TEXT),g=(0,_react.useMemo)(()=>({...x,...m}),[x,m]),[v,p]=(0,_react.useState)(clamp(t,0,Math.max(0,e.length-1))),[b,y]=(0,_react.useState)(!1),R=(0,_react.useCallback)(e=>{p(e),n?.(e)},[n]),j=(0,_react.useCallback)(()=>{if(!l)return;const e=(0,_index3.resolveHaptic)(s,"selection");e&&(0,_index3.triggerHaptic)(e),y(!0)},[l,s]),N=(0,_react.useCallback)(()=>{const e=(0,_index3.resolveHaptic)(s,"selection");e&&(0,_index3.triggerHaptic)(e),y(!1)},[s]),I=(0,_react.useCallback)((t,a)=>{const i=t.alt??(0,_index.fillText)(g.imageOf,{index:a+1,total:e.length});return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:j,accessibilityRole:"image",accessibilityLabel:i,accessibilityHint:l?g.openFullscreen:void 0,style:h.imageWrap,children:(0,_jsxRuntime.jsx)(_reactNative.Image,{source:t.source,style:h.image,resizeMode:"cover"})})},[l,e.length,j,h,g]),S=(0,_react.useCallback)(e=>(0,_jsxRuntime.jsx)(_reactNative.Image,{source:e.source,style:h.thumbnailImage,resizeMode:"cover"}),[h]),w=(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:b,importantForAccessibility:b?"no-hide-descendants":"auto",children:[(0,_jsxRuntime.jsx)(_index4.Carousel,{data:e,defaultIndex:t,onIndexChange:R,renderItem:I,showPagination:!1,showThumbnails:a,renderThumbnail:S,haptic:s}),i&&e.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:h.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"label",weight:"semibold",style:{color:_.colors["on-scrim"]},accessibilityLabel:(0,_index.fillText)(g.imageOf,{index:v+1,total:e.length}),children:`${v+1} / ${e.length}`})}):null]}),l?(0,_jsxRuntime.jsx)(Lightbox,{open:b,images:e,initialIndex:v,enablePinchZoom:r,showCounter:i,onClose:N,onIndexChange:R,haptic:s,labels:g,testID:d}):null]});return o?(0,_jsxRuntime.jsx)(ImageGallerySkeleton,{images:e,showThumbnails:a,showCounter:i,style:u,testID:d}):w};exports.ImageGallery=ImageGallery,ImageGallery.displayName="ImageGallery";const ImageGallerySkeleton=({images:e,showThumbnails:t=!0,showCounter:a=!0,style:i,testID:l})=>{const r=(0,_index2.useTheme)(),n=Math.min(e?.length||4,6),s=(0,_react.useMemo)(()=>Array.from({length:n},(e,t)=>({key:`sk-thumb-${t}`})),[n]);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)(_index5.Skeleton,{width:"100%",height:280,radius:"lg"}),a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{position:"absolute",top:12,right:12},children:(0,_jsxRuntime.jsx)(_index5.Skeleton,{width:44,height:22,radius:"pill"})}):null]}),t?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:r.space.md},children:s.map(e=>(0,_jsxRuntime.jsx)(_index5.Skeleton,{width:64,height:64,radius:"md",style:{marginRight:r.space.sm}},e.key))}):null]})};ImageGallerySkeleton.displayName="ImageGallerySkeleton",ImageGallery.Skeleton=ImageGallerySkeleton;const Lightbox=({open:e,images:t,initialIndex:a,enablePinchZoom:i,showCounter:l,onClose:r,onIndexChange:n,haptic:s,labels:o,testID:c})=>{const u=(0,_index2.useTheme)(),d=(0,_react.useMemo)(()=>buildLightboxStyles(u),[u]),m=(0,_react.useRef)(null),[_,h]=(0,_react.useState)(a),x=(0,_react.useCallback)(e=>{if(e!==_){const t=(0,_index3.resolveHaptic)(s,"selection");t&&(0,_index3.triggerHaptic)(t),h(e),n(e)}},[_,n,s]),g=(0,_react.useCallback)((e,a)=>(0,_jsxRuntime.jsx)(ZoomableImage,{image:e,index:a,total:t.length,active:a===_,enabled:i,maxScale:4,minScale:1,doubleTapScale:2,haptic:s,imageLabel:o.imageOf}),[_,i,t.length,s,o]),v=t[_]?.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:d.backdrop,children:[(0,_jsxRuntime.jsx)(_index4.Carousel,{ref:m,testID:c?`${c}-lightbox`:void 0,data:t,defaultIndex:a,onIndexChange:x,renderItem:g,showPagination:!1,haptic:s}),l&&t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:d.counterPill,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"label",weight:"semibold",style:{color:u.colors["on-scrim"]},accessibilityLabel:(0,_index.fillText)(o.imageOf,{index:_+1,total:t.length}),children:`${_+1} / ${t.length}`})}):null,(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:r,accessibilityRole:"button",accessibilityLabel:o.closeGallery,style:d.closeButton,hitSlop:12,...(0,_hitSlop.hitSlopMarker)(12),children:(u.settings.icons.close??_defaultIcons.defaultIcons.close)({size:24,color:u.colors["on-scrim"]})}),v?(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:d.captionWrap,accessibilityElementsHidden:!1,children:(0,_jsxRuntime.jsx)(_index6.Text,{variant:"body",align:"center",numberOfLines:3,style:d.captionText,children:v})}):null]})})},ZoomableImage=({image:e,index:t,total:a,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),x=(0,_reactNativeReanimated.useSharedValue)(0),g=(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),x.value=0,g.value=0},[d,m,_,h,x,g]);_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,x.value=0,g.value=0)},[i,d,_,h,m,x,g]);const p=(0,_react.useCallback)(()=>{!1!==o&&(0,_index3.triggerHaptic)("impactLight")},[o]),b=(0,_react.useMemo)(()=>({enabled:l,onActivate:()=>{"worklet";m.value=d.value},onUpdate:e=>{"worklet";const t=m.value*e.scale;d.value=t<n?n+.3*(t-n):t>r?r+.2*(t-r):t},onDeactivate:()=>{"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,x.value=0,void(g.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,x,g,n,r]),y=(0,_reactNativeGestureHandler.usePinchGesture)(b),R=(0,_react.useMemo)(()=>({minPointers:1,maxPointers:1,onActivate:()=>{"worklet";x.value=_.value,g.value=h.value},onUpdate:e=>{"worklet";d.value<=1||(_.value=x.value+e.translationX,h.value=g.value+e.translationY)},onDeactivate:()=>{"worklet";x.value=_.value,g.value=h.value}}),[d,_,h,x,g]),j=(0,_reactNativeGestureHandler.usePanGesture)(R),N=(0,_react.useMemo)(()=>({numberOfTaps:2,onDeactivate:()=>{"worklet";(0,_reactNativeWorklets.scheduleOnRN)(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,x.value=0,g.value=0):(d.value=(0,_reactNativeReanimated.withSpring)(s,SPRING_CONFIG),m.value=s)}}),[d,m,_,h,x,g,p,s]),I=(0,_reactNativeGestureHandler.useTapGesture)(N),S=(0,_reactNativeGestureHandler.useCompetingGestures)(y,j,I),w=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:_.value},{translateY:h.value},{scale:d.value}]}),...(0,_animatedDeps.webDeps)([_,h,d]));_react.default.useEffect(()=>{i||v()},[i,v]);const f=e.alt??(0,_index.fillText)(c,{index:t+1,total:a});return(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:S,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,w],accessibilityLabel:f,accessible:!0})})})},clamp=(e,t,a)=>Math.min(Math.max(e,t),a),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"]}}),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=exports.NonModalBottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeWorklets=require("react-native-worklets"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../text/index.js"),_nonModalBottomSheetG=require("../../text/phone/nonModalBottomSheet.g.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_corners=require("../../utils/corners.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,i={__proto__:null,default:e};if(Object(e)!==e)return i;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,i)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(i,r,a):i[r]=e[r]);return i}const ERROR_PREFIX="[@webority/mobile-ui] NonModalBottomSheet: ",SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,OVERSHOOT_TO_CLOSE=80,PERCENT_PATTERN=/^(\d+(?:\.\d+)?|\.\d+)%$/,parsePercent=e=>{if("string"!=typeof e)return;const t=PERCENT_PATTERN.exec(e);if(!t)return;const a=Number(t[1]);return a>0&&a<=100?a:void 0},isValidSnapPoint=e=>"number"==typeof e?Number.isFinite(e)&&e>0:void 0!==parsePercent(e),validateProps=(e,t)=>{if(0===e.length)throw new Error(`${ERROR_PREFIX}snapPoints needs at least one snap point.`);for(const t of e)if(!isValidSnapPoint(t))throw new Error(`${ERROR_PREFIX}snap point ${String(t)} is not a positive number or a percentage up to 100%.`);if(null!=t&&(!Number.isInteger(t)||t<0||t>=e.length))throw new Error(`${ERROR_PREFIX}snapIndex ${t} is outside the snap points.`)},resolveNonModalSnapPoints=(e,t)=>e.map(e=>"number"==typeof e?e:parseFloat(e)/100*t).sort((e,t)=>e-t),topAt=(e,t,a)=>{const r=e[a];if(void 0===r)throw new Error(`${ERROR_PREFIX}snap index ${a} has no snap point.`);return Math.max(0,t-r)},NonModalBottomSheet=e=>{const{open:t,onClose:a,snapPoints:r,snapIndex:n,onSnapChange:i,enablePanDownToClose:o=!0,scrollable:s=!1,title:c,header:l,footer:u,labels:d,handleIndicatorStyle:_,sheetStyle:h,children:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.NonModalBottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeWorklets=require("react-native-worklets"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../text/index.js"),_nonModalBottomSheetG=require("../../text/phone/nonModalBottomSheet.g.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_animatedDeps=require("../../utils/animatedDeps.js"),_corners=require("../../utils/corners.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,i={__proto__:null,default:e};if(Object(e)!==e)return i;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,i)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(i,r,a):i[r]=e[r]);return i}const ERROR_PREFIX="[@webority/mobile-ui] NonModalBottomSheet: ",SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,OVERSHOOT_TO_CLOSE=80,PERCENT_PATTERN=/^(\d+(?:\.\d+)?|\.\d+)%$/,parsePercent=e=>{if("string"!=typeof e)return;const t=PERCENT_PATTERN.exec(e);if(!t)return;const a=Number(t[1]);return a>0&&a<=100?a:void 0},isValidSnapPoint=e=>"number"==typeof e?Number.isFinite(e)&&e>0:void 0!==parsePercent(e),validateProps=(e,t)=>{if(0===e.length)throw new Error(`${ERROR_PREFIX}snapPoints needs at least one snap point.`);for(const t of e)if(!isValidSnapPoint(t))throw new Error(`${ERROR_PREFIX}snap point ${String(t)} is not a positive number or a percentage up to 100%.`);if(null!=t&&(!Number.isInteger(t)||t<0||t>=e.length))throw new Error(`${ERROR_PREFIX}snapIndex ${t} is outside the snap points.`)},resolveNonModalSnapPoints=(e,t)=>e.map(e=>"number"==typeof e?e:parseFloat(e)/100*t).sort((e,t)=>e-t),topAt=(e,t,a)=>{const r=e[a];if(void 0===r)throw new Error(`${ERROR_PREFIX}snap index ${a} has no snap point.`);return Math.max(0,t-r)},NonModalBottomSheet=e=>{const{open:t,onClose:a,snapPoints:r,snapIndex:n,onSnapChange:i,enablePanDownToClose:o=!0,scrollable:s=!1,title:c,header:l,footer:u,labels:d,handleIndicatorStyle:_,sheetStyle:h,children:m,accessibilityLabel:v,testID:p}=e;validateProps(r,n);const R=(0,_index.useMobileUiText)("nonModalBottomSheet",_nonModalBottomSheetG.NON_MODAL_BOTTOM_SHEET_TEXT),f=(0,_react.useMemo)(()=>({...R,...d}),[R,d]),x=(0,_index2.useTheme)(),N=(0,_usePresenceMotion.usePresenceMotion)(),b=N.reduced,E=(0,_react.useMemo)(()=>buildStyles(x),[x]),[S,g]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),M=(0,_react.useCallback)(e=>{const t=e.nativeEvent.layout.height;t>0&&g(t)},[]),w=(0,_react.useMemo)(()=>resolveNonModalSnapPoints(r,S),[r,S]),y=w[w.length-1]??0,O=S,P=Math.max(0,S-y),j=(0,_react.useCallback)(e=>topAt(w,S,e),[w,S]),[T,C]=(0,_react.useState)(!1),[I,k]=(0,_react.useState)(-1),D=(0,_react.useRef)(-1),q=(0,_react.useRef)(a);q.current=a;const A=(0,_react.useRef)(i);A.current=i;const V=(0,_reactNativeReanimated.useSharedValue)(O),B=(0,_reactNativeReanimated.useSharedValue)(O),G=(0,_react.useCallback)(()=>{D.current<0&&C(!1)},[]),F=(0,_react.useCallback)(()=>{if(D.current=-1,k(-1),b)return V.value=O,void G();V.value=(0,_reactNativeReanimated.withTiming)(O,{duration:N.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...x.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeWorklets.scheduleOnRN)(G)})},[O,N,b,x.motion.ease.accelerate,V,G]),H=(0,_react.useCallback)(e=>{const t=j(e);V.value=b?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[b,j,V]),$=(0,_react.useCallback)((e,t)=>{e!==D.current&&(D.current=e,k(e),H(e),t&&A.current?.(e))},[H]),L=(0,_react.useEffectEvent)(e=>{if(!e)return void(D.current>=0&&F());const t=n??0;C(!0);const a=j(t);b?V.value=a:(V.value=O,V.value=(0,_reactNativeReanimated.withSpring)(a,SPRING_CONFIG)),D.current=t,k(t)});(0,_react.useEffect)(()=>{L(t)},[t]);const W=(0,_react.useEffectEvent)(e=>{t&&T&&e!==D.current&&$(e,!1)});(0,_react.useEffect)(()=>{null!=n&&W(n)},[n]);const X=(0,_react.useEffectEvent)(e=>{const t=D.current;t>=0&&(V.value=topAt(w,e,t))});(0,_react.useEffect)(()=>{X(S)},[S]);const Y=(0,_react.useCallback)(e=>{if(e<0)return(0,_index3.triggerHaptic)("selection"),F(),void q.current();e!==D.current?$(e,!0):H(e)},[$,H,F]),U=(0,_react.useCallback)(e=>{const t=D.current;t<0||$(Math.min(Math.max(t+e,0),w.length-1),!0)},[$,w.length]),z=(0,_react.useMemo)(()=>w.map(e=>S-e),[w,S]),J=(0,_react.useMemo)(()=>{const e=z,t=P,a=o;return{testID:p?`${p}-pan-gesture`:"non-modal-bottom-sheet-pan-gesture",activeOffsetY:[-10,10],onActivate:()=>{"worklet";B.value=V.value},onUpdate:e=>{"worklet";const a=B.value+e.translationY;V.value=a<t?t+.25*(a-t):a},onDeactivate:t=>{"worklet";const r=V.value,n=e[0];if(void 0===n)return;if(t.velocityY>1e3)return void(0,_reactNativeWorklets.scheduleOnRN)(Y,a?-1:0);if(a&&r-n>80)return void(0,_reactNativeWorklets.scheduleOnRN)(Y,-1);let i=0,o=1/0,s=0;for(const t of e){const e=Math.abs(r-t);e<o&&(o=e,i=s),s++}(0,_reactNativeWorklets.scheduleOnRN)(Y,i)}}},[B,o,Y,P,z,p,V]),K=(0,_reactNativeGestureHandler.usePanGesture)(J),Q=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({top:Math.max(V.value,P)}),...(0,_animatedDeps.webDeps)([P])),Z=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=Math.max(V.value,P),t=S-e;return{height:Math.max(0,Math.min(t,y))}},...(0,_animatedDeps.webDeps)([S,y,P]));return T?(0,_jsxRuntime.jsx)(_reactNative.View,{collapsable:!1,style:_reactNative.StyleSheet.absoluteFill,pointerEvents:"box-none",onLayout:M,testID:p,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityLabel:v,testID:p?`${p}-sheet`:void 0,style:[E.sheet,{height:y,backgroundColor:x.colors.surface,borderTopLeftRadius:x.radius.xl,borderTopRightRadius:x.radius.xl,..._corners.smoothCorners,...x.shadow.modal},h,Q],children:(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[E.body,Z],children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:K,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:E.handleRow,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:f.dragHandle,accessibilityHint:f.swipeHintText,accessibilityValue:{text:(0,_index.fillText)(f.snapPointText,{position:I+1,total:w.length})},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:e=>{"increment"===e.nativeEvent.actionName?U(1):"decrement"===e.nativeEvent.actionName&&U(-1)},testID:p?`${p}-handle`:void 0,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[E.handle,{backgroundColor:x.colors.border},_]})})}),null!=c?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",accessibilityRole:"header",children:c}):null,l,s?(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:E.scrollContent,children:m}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:E.content,children:m}),u]})})}):null};exports.NonModalBottomSheet=NonModalBottomSheet,NonModalBottomSheet.displayName="NonModalBottomSheet";const buildStyles=e=>_reactNative.StyleSheet.create({sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1}});var _default=exports.default=NonModalBottomSheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SkeletonText=exports.SkeletonCircle=exports.Skeleton=void 0;var _react=require("react"),_reactNative=require("react-native"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../text/index.js"),_skeletonG=require("../../text/phone/skeleton.g.js"),_index2=require("../../theme/index.js"),_Gradient=require("../../theme/Gradient.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_SkeletonClock=require("./SkeletonClock.js"),_SkeletonProvider=require("./SkeletonProvider.js"),_jsxRuntime=require("react/jsx-runtime");const resolveRadius=(e,t)=>"number"==typeof t?t:e.radius[t],resolveWidth=e=>void 0===e?"100%":e,radiusForShape=(e,t,s,i,r)=>{if(void 0!==r)return resolveRadius(e,r);switch(t){case"circle":return"number"==typeof s?Math.min(s,i)/2:i/2;case"rounded":return e.radius.md;default:return e.radius.sm}},Skeleton=e=>{const{shape:t="rect",width:s="100%",height:i=16,radius:r,variant:n,colors:o,labels:a,style:l,testID:u}=e;(0,_assertValidValue.assertValidValue)("Skeleton","shape",e.shape,["rect","rounded","circle","text"]),(0,_assertValidValue.assertValidValue)("Skeleton","variant",e.variant,["shimmer","pulse","none"]);const d=(0,_index2.useTheme)(),c=(0,_SkeletonProvider.useSkeletonDefaults)(),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.SkeletonText=exports.SkeletonCircle=exports.Skeleton=void 0;var _react=require("react"),_reactNative=require("react-native"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../text/index.js"),_skeletonG=require("../../text/phone/skeleton.g.js"),_index2=require("../../theme/index.js"),_Gradient=require("../../theme/Gradient.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_SkeletonClock=require("./SkeletonClock.js"),_SkeletonProvider=require("./SkeletonProvider.js"),_jsxRuntime=require("react/jsx-runtime");const resolveRadius=(e,t)=>"number"==typeof t?t:e.radius[t],resolveWidth=e=>void 0===e?"100%":e,radiusForShape=(e,t,s,i,r)=>{if(void 0!==r)return resolveRadius(e,r);switch(t){case"circle":return"number"==typeof s?Math.min(s,i)/2:i/2;case"rounded":return e.radius.md;default:return e.radius.sm}},Skeleton=e=>{const{shape:t="rect",width:s="100%",height:i=16,radius:r,variant:n,colors:o,labels:a,style:l,testID:u}=e;(0,_assertValidValue.assertValidValue)("Skeleton","shape",e.shape,["rect","rounded","circle","text"]),(0,_assertValidValue.assertValidValue)("Skeleton","variant",e.variant,["shimmer","pulse","none"]);const d=(0,_index2.useTheme)(),c=(0,_SkeletonProvider.useSkeletonDefaults)(),h=(0,_SkeletonClock.useSkeletonClock)(),m=(0,_useReducedMotion.useReducedMotion)(),x=n??c.variant??"shimmer",k=m&&"auto"===(c.animation??"auto");let _=x;h.enabled?k&&"shimmer"===x&&(_="pulse"):_="none";const p=o?.background??c.colors?.background??d.colors.skeleton,S=o?.highlight??c.colors?.highlight??d.colors["skeleton-highlight"],{responsive:v}=(0,_index3.useScreenDimensions)(),y=(0,_react.useMemo)(()=>buildStyles(),[]),b=(0,_index.useMobileUiText)("skeleton",_skeletonG.SKELETON_TEXT),g=(0,_react.useMemo)(()=>({...b,...a}),[b,a]),j=resolveWidth(s),R=v.size(i),V=radiusForShape(d,t,j,R,r),[M,f]=(0,_react.useState)(0),q=(0,_react.useMemo)(()=>M<=0?0:Math.max(48,.7*M),[M]),w=(0,_react.useMemo)(()=>M<=0?0:h.shimmer.interpolate({inputRange:[0,1],outputRange:[-q,M]}),[h.shimmer,q,M]),C=(0,_react.useMemo)(()=>"none"===_?null:"pulse"===_?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[_reactNative.StyleSheet.absoluteFill,{backgroundColor:S,opacity:h.pulse.interpolate({inputRange:[0,1],outputRange:[0,.55]})}]}):M<=0?null:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[y.shimmerBand,{width:q,transform:[{translateX:w}],backgroundImage:[(0,_Gradient.toBackgroundImage)({colors:["transparent",S,"transparent"],locations:[0,.5,1],start:{x:0,y:.5},end:{x:1,y:.5}})]}]}),[_,S,h.pulse,M,y.shimmerBand,q,w]);return(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:e=>{const t=e.nativeEvent.layout.width;t!==M&&f(t)},accessible:!0,accessibilityLabel:g.loading,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,accessibilityLiveRegion:"polite",testID:u,style:[y.base,{width:j,height:R,borderRadius:V,..._corners.smoothCorners,backgroundColor:p},l],children:C})};exports.Skeleton=Skeleton,Skeleton.displayName="Skeleton";const SkeletonCircle=({size:e,style:t,...s})=>{const{responsive:i}=(0,_index3.useScreenDimensions)(),r=i.size(e);return(0,_jsxRuntime.jsx)(Skeleton,{...s,shape:"circle",width:r,height:e,style:t})};exports.SkeletonCircle=SkeletonCircle,SkeletonCircle.displayName="SkeletonCircle";const SkeletonText=({lines:e=3,lastLineWidth:t="60%",spacing:s,fontSize:i,variant:r,radius:n="sm",width:o="100%",labels:a,style:l,testID:u})=>{const d=(0,_index2.useTheme)(),c=s??d.space.xs,h=Math.max(1,e),m=(0,_react.useMemo)(()=>Array.from({length:h},(e,t)=>({key:`sk-text-line-${t}`,index:t})),[h]);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:l,testID:u,children:m.map(e=>{const s=e.index===h-1&&h>1?t:o;return(0,_jsxRuntime.jsx)(Skeleton,{shape:"text",width:s,height:i??d.text.base.size,radius:n,variant:r,labels:a,style:e.index<h-1?{marginBottom:c}:void 0},e.key)})})};exports.SkeletonText=SkeletonText,SkeletonText.displayName="SkeletonText";const buildStyles=()=>_reactNative.StyleSheet.create({base:{overflow:"hidden"},shimmerBand:{position:"absolute",top:0,bottom:0,left:0}});var _default=exports.default=Skeleton;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SlideToConfirm=SlideToConfirm,exports.default=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeWorklets=require("react-native-worklets"),_index=require("../../text/index.js"),_slideToConfirmG=require("../../text/phone/slideToConfirm.g.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index4=require("../Text/index.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 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}});function SlideToConfirm({ref:e,...t}){const{onConfirm:a,label:i,tone:r="primary",size:n="md",disabled:s=!1,threshold:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.SlideToConfirm=SlideToConfirm,exports.default=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeWorklets=require("react-native-worklets"),_index=require("../../text/index.js"),_slideToConfirmG=require("../../text/phone/slideToConfirm.g.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_animatedDeps=require("../../utils/animatedDeps.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index4=require("../Text/index.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 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}});function SlideToConfirm({ref:e,...t}){const{onConfirm:a,label:i,tone:r="primary",size:n="md",disabled:s=!1,threshold:l=.9,resetAfter:o=!1,haptic:c,icon:d,labels:u,style:m,trackStyle:_,handleStyle:h,labelStyle:v,testID:f}=t;(0,_assertValidValue.assertValidValue)("SlideToConfirm","tone",t.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("SlideToConfirm","size",t.size,["sm","md","lg"]);const p=(0,_index.useMobileUiText)("slideToConfirm",_slideToConfirmG.SLIDE_TO_CONFIRM_TEXT),b=(0,_react.useMemo)(()=>({...p,...u}),[p,u]),x=(0,_react.useMemo)(()=>[{name:"activate",label:b.confirmAction},{name:"increment",label:b.confirmAction}],[b.confirmAction]),g=(0,_index2.useTheme)(),y=SIZE_MAP[n],R=g.space[y.pad],j=y.height-2*R,C=(0,_react.useMemo)(()=>buildStyles(g,y),[g,y]),N=g.colors[r],[S,w]=(0,_react.useState)(!1),T=(0,_reactNativeReanimated.useSharedValue)(0),V=(0,_reactNativeReanimated.useSharedValue)(0),k=(0,_reactNativeReanimated.useSharedValue)(0),q=(0,_react.useRef)(null),M=(0,_react.useCallback)(()=>{const e=(0,_index3.resolveHaptic)(c,"notificationSuccess");e&&(0,_index3.triggerHaptic)(e)},[c]),A=(0,_react.useCallback)(()=>{w(!1),T.value=(0,_reactNativeReanimated.withSpring)(0,{damping:18,stiffness:160,mass:1})},[T]),D=(0,_react.useCallback)(()=>{w(!0),M(),a(),!1!==o&&(q.current&&clearTimeout(q.current),q.current=setTimeout(A,o))},[M,a,o,A]),W=(0,_react.useCallback)(e=>{if(s||S)return;const{actionName:t}=e.nativeEvent;"activate"!==t&&"increment"!==t||D()},[s,S,D]);_react.default.useEffect(()=>()=>{(0,_reactNativeReanimated.cancelAnimation)(T),q.current&&clearTimeout(q.current)},[T]);const E=(0,_react.useCallback)(e=>{V.value=Math.max(0,e.nativeEvent.layout.width-j-2*R)},[V,j,R]),O=(0,_react.useMemo)(()=>{const e=l,t={damping:18,stiffness:160,mass:1},a={duration:g.motion.duration.fast,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)};return{enabled:!s&&!S,minDistance:0,onActivate:()=>{"worklet";k.value=T.value},onUpdate:e=>{"worklet";T.value=Math.min(Math.max(k.value+e.translationX,0),V.value)},onDeactivate:()=>{"worklet";V.value>0&&T.value>=V.value*e?(T.value=(0,_reactNativeReanimated.withTiming)(V.value,a),(0,_reactNativeWorklets.scheduleOnRN)(D)):T.value=(0,_reactNativeReanimated.withSpring)(0,t)}}},[s,S,l,T,V,k,D,g.motion.duration.fast]),P=(0,_reactNativeGestureHandler.usePanGesture)(O),G=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:T.value}]}),...(0,_animatedDeps.webDeps)([T])),I=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({width:T.value+j+R}),...(0,_animatedDeps.webDeps)([T,j,R])),L=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=V.value>0?V.value:1;return{opacity:Math.max(0,1-T.value/(.6*e))}},...(0,_animatedDeps.webDeps)([V,T]));return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:e,style:[C.track,{backgroundColor:g.colors["bg-subtle"]},_,m],onLayout:E,testID:f,accessibilityRole:"adjustable",accessibilityLabel:S?b.confirmed:i??b.slide,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityActions:x,onAccessibilityAction:W,children:[(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[C.fill,{backgroundColor:N,opacity:s?.5:1},I],pointerEvents:"none"}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[C.labelWrap,L],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",style:[C.label,{color:g.colors["text-muted"]},v],numberOfLines:1,children:S?b.confirmed:i??b.slide})}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:P,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[C.handle,{width:j,height:j,borderRadius:g.radius.pill,..._corners.smoothCorners,backgroundColor:g.colors.surface,opacity:s?.5:1,...g.shadow.card},h,G],children:d??(0,_jsxRuntime.jsx)(Chevron,{color:N,size:.5*j})})})]})}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.Slider=Slider,exports.default=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeWorklets=require("react-native-worklets"),_index=require("../../hooks/index.js"),_index2=require("../../text/index.js"),_sliderG=require("../../text/phone/slider.g.js"),_index3=require("../../theme/index.js"),_index4=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index5=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),isPair=e=>Array.isArray(e);function Slider({ref: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,trackStyle:b,fillStyle:f,thumbStyle:g,labelStyle:p,thumbPressScale:R,labelShowDuration:x,labelOpacity:N,testID:y}=t;(0,_assertValidValue.assertValidValue)("Slider","tone",t.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Slider","size",t.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Slider","variant",t.variant,["default","inset","minimal","bar"]);const w=(0,_index3.useTheme)(),k=(0,_index2.useMobileUiText)("slider",_sliderG.SLIDER_TEXT),j=(0,_react.useMemo)(()=>{const e=(0,_index3.resolveSliderSize)(w,l);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[w,l]),S=(0,_react.useMemo)(()=>"default"===c?j:VARIANT_SIZE_MAP[c][l],[j,l,c]),C="inset"===c?S.trackHeight/2:0,V=w.settings.components.slider?.thumbPressAnimation??!1,M=R??1.1,A=x??w.motion.duration.fast,D=N??1,H=(0,_react.useMemo)(()=>buildStyles(w,S),[w,S]),O=(0,_react.useMemo)(()=>({damping:w.motion.spring.snappy.damping,stiffness:w.motion.spring.snappy.stiffness,mass:w.motion.spring.snappy.mass}),[w.motion.spring.snappy]),[T,E]=(0,_react.useState)(0),I=w.colors[s],W=(0,_valueText.sliderToneInk)(w,s),P=!0===t.range,q=(0,_react.useCallback)(e=>{if(!0!==t.range){if(Array.isArray(e))throw new Error("Slider received a range value in single mode.");t.onChange?.(e)}else{if(!Array.isArray(e))throw new Error("Slider received a single value in range mode.");t.onChange?.(e)}},[t.onChange,t.range]),[G,L]=(0,_index.useControllableState)({value:t.value,defaultValue:t.defaultValue??(P?[a,i]:a),onChange:q}),X=(0,_reactNativeReanimated.useSharedValue)(0),B=(0,_reactNativeReanimated.useSharedValue)(0),U=(0,_reactNativeReanimated.useSharedValue)(isPair(G)?G[0]:G),F=(0,_reactNativeReanimated.useSharedValue)(isPair(G)?G[1]:G),z=(0,_reactNativeReanimated.useSharedValue)(0),$=(0,_reactNativeReanimated.useSharedValue)(0),Z=(0,_reactNativeReanimated.useSharedValue)(1),J=(0,_reactNativeReanimated.useSharedValue)(1),K="always"===o,Q=(0,_reactNativeReanimated.useSharedValue)(K?1:0),Y=(0,_reactNativeReanimated.useSharedValue)(K?1:0),ee=(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)(Z),(0,_reactNativeReanimated.cancelAnimation)(J),(0,_reactNativeReanimated.cancelAnimation)(Q),(0,_reactNativeReanimated.cancelAnimation)(Y)},[X,B,Z,J,Q,Y]);const te=(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]),ae=(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]),ie=(0,_react.useRef)(!1),re=w.motion.duration.fast,ne=(0,_react.useRef)(G);ne.current=G;const se=(0,_react.useRef)(T);se.current=T;const le=(0,_react.useCallback)((e=!1)=>{const t=se.current;if(t<=0)return;const place=t=>e?(0,_reactNativeReanimated.withTiming)(t,{duration:re,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}):t,a=ne.current;if(isPair(a)){const[e,i]=a,r=Math.min(e,i),n=Math.max(e,i);U.value=r,F.value=n,X.value=place(te(r,t)),B.value=place(te(n,t))}else{const e=a;U.value=e,F.value=e,X.value=place(te(e,t))}},[te,U,F,X,B,re]),[ce,oe]=(0,_react.useState)(0),ue=(0,_react.useRef)(!1),de=(0,_react.useCallback)(e=>{ie.current=e,e||(ue.current=!0,oe(e=>e+1))},[]);(0,_react.useEffect)(()=>{if(ie.current)return;const e=ue.current;ue.current=!1,le(e)},[JSON.stringify(G),T,ce,le]);const me=(0,_react.useCallback)(e=>{const t=e.nativeEvent.layout.width;$.value=t,E(t)},[$]),he=(0,_react.useCallback)((e,t)=>{L(P?[e,t]:e)},[P,L]),ve=(0,_react.useCallback)(()=>{const e=(0,_index4.resolveHaptic)(_,"selection");e&&(0,_index4.triggerHaptic)(e)},[_]),be=(0,_react.useRef)(he);be.current=he;const fe=(0,_react.useRef)(ve);fe.current=ve;const ge=(0,_react.useCallback)((e,t)=>be.current(e,t),[]),pe=(0,_react.useCallback)(()=>fe.current(),[]),Re=Math.max(0,(MIN_THUMB_TOUCH-S.thumbDiameter)/2),xe=Re>0?Re:void 0,Ne=(0,_react.useCallback)(e=>{const t="low"===e?X:B,s="low"===e?U:F,l="low"===e?F:U,c="low"===e?Z:J,d="low"===e?Q:Y,m="low"===e,h=a,_=i,v=r,b=ee,f=P,g=M,p=V,R=!0===o,x=u,N=D,w=A,k=O,j=C,S=m&&y?`${y}-pan`:void 0,follow=e=>{"worklet";const a=$.value-2*j;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(z.value+e,j),$.value-j);let r=h+(i-j)/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),_),f&&(m&&r>l.value&&(r=l.value),!m&&r<l.value&&(r=l.value)),t.value=x||_===h?_===h?j:j+(r-h)/(_-h)*a:f?m?Math.min(i,B.value):Math.max(i,X.value):i,r!==s.value&&(s.value=r,r!==h&&r!==_||(0,_reactNativeWorklets.scheduleOnRN)(pe),(0,_reactNativeWorklets.scheduleOnRN)(ge,U.value,F.value))};return{enabled:!n,minDistance:0,testID:S,...void 0===xe?{}:{hitSlop:xe},onActivate:()=>{"worklet";(0,_reactNativeWorklets.scheduleOnRN)(de,!0),z.value=t.value,p&&(c.value=(0,_reactNativeReanimated.withSpring)(g,k)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(N,{duration:w,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)})),(0,_reactNativeWorklets.scheduleOnRN)(pe)},onUpdate:e=>{"worklet";follow(e.translationX)},onDeactivate:e=>{"worklet";follow(e.translationX),p&&(c.value=(0,_reactNativeReanimated.withSpring)(1,k)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(0,{duration:w,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}))},onFinalize:()=>{"worklet";(0,_reactNativeWorklets.scheduleOnRN)(de,!1)}}},[n,a,i,r,ee,P,M,V,o,u,D,A,O,C,xe,y,ge,pe,de,X,B,U,F,Z,J,Q,Y,z,$]),ye=(0,_react.useMemo)(()=>Ne("low"),[Ne]),we=(0,_react.useMemo)(()=>Ne("high"),[Ne]),ke=(0,_reactNativeGestureHandler.usePanGesture)(ye),je=(0,_reactNativeGestureHandler.usePanGesture)(we),Se=(0,_react.useCallback)(e=>{if(n||P||T<=0)return;const t=clamp(e.nativeEvent.locationX,0,T),a=ae(t,T);a!==U.value&&(ve(),U.value=a,X.value=(0,_reactNativeReanimated.withTiming)(te(a,T),{duration:w.motion.duration.fast,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}),he(a,a))},[n,P,T,ae,te,he,ve,X,U,w.motion.duration.fast]),Ce=(0,_react.useCallback)(e=>{if(n)return;const t="increment"===e.nativeEvent.actionName?r:-r,s=r>0?Math.round(t*ee)/ee:t;if(P){const e=Math.round((U.value+s)*ee)/ee,t=clamp(e,a,F.value);t!==U.value&&(U.value=t,X.value=te(t,T),ve(),he(t,F.value))}else{const e=Math.round((U.value+s)*ee)/ee,t=clamp(e,a,i);t!==U.value&&(U.value=t,X.value=te(t,T),ve(),he(t,t))}},[n,r,ee,P,a,i,te,T,X,U,F,he,ve]),Ve=S.thumbDiameter/2,Me=n?w.colors["surface-disabled"]:I,Ae="inset"===c?{backgroundColor:Me,borderColor:w.colors.surface,borderWidth:Math.max(2,Math.round(S.thumbDiameter*INSET_RING_RATIO)),...NO_SHADOW}:"minimal"===c?{backgroundColor:Me,borderWidth:0}:"bar"===c?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:w.colors.surface,borderColor:Me},De=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=$.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=n?.55:1;if(P){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}]}},[$,n,P,B,X,C]),He=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:X.value-Ve},{scale:Z.value}]}),[X,Ve,Z]),Oe=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:B.value-Ve},{scale:J.value}]}),[B,Ve,J]),Te=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:Q.value}),[Q]),Ee=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:Y.value}),[Y]),clampDisplay=e=>clamp(e,a,i),Ie=clampDisplay(isPair(G)?Math.min(...G):G),We=clampDisplay(isPair(G)?Math.max(...G):G);return(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e,style:[H.container,v],testID:y,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:n},"aria-disabled":n,accessibilityValue:P?{min:a,max:i,now:Ie,text:(0,_index2.fillText)(k.text,{start:Ie,end:We})}:{min:a,max:i,now:Ie},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Ce,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Se,disabled:n||P,style:H.trackTouch,testID:y?`${y}-track-press`:void 0,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.trackWrap,onLayout:me,testID:y?`${y}-track`:void 0,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.trackClip,pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.track,{backgroundColor:n?w.colors["surface-disabled"]:w.colors.border},b]}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[H.fill,{backgroundColor:n?w.colors["surface-disabled"]:I},f,De],testID:y?`${y}-fill`:void 0})]}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ke,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[H.thumb,{width:S.thumbDiameter,height:S.thumbDiameter,borderRadius:Ve,..._corners.smoothCorners,opacity:n?.55:1},Ae,g,He],testID:y?`${y}-thumb`:void 0,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[H.bubbleWrap,Te],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.bubble,{backgroundColor:I}],children:m?m(Ie):(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",weight:"semibold",style:[{color:W},p],numberOfLines:1,children:d(Ie)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.bubbleCaret,{backgroundColor:I}]})]}):null})}),P?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:je,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[H.thumb,{width:S.thumbDiameter,height:S.thumbDiameter,borderRadius:Ve,..._corners.smoothCorners,opacity:n?.55:1},Ae,g,Oe],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[H.bubbleWrap,Ee],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.bubble,{backgroundColor:I}],children:m?m(We):(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",weight:"semibold",style:[{color:W},p],numberOfLines:1,children:d(We)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.bubbleCaret,{backgroundColor:I}]})]}):null})}):null]})})})}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.Slider=Slider,exports.default=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeWorklets=require("react-native-worklets"),_index=require("../../hooks/index.js"),_index2=require("../../text/index.js"),_sliderG=require("../../text/phone/slider.g.js"),_index3=require("../../theme/index.js"),_index4=require("../../utils/index.js"),_animatedDeps=require("../../utils/animatedDeps.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index5=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),isPair=e=>Array.isArray(e);function Slider({ref: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,trackStyle:b,fillStyle:p,thumbStyle:f,labelStyle:g,thumbPressScale:R,labelShowDuration:x,labelOpacity:w,testID:N}=t;(0,_assertValidValue.assertValidValue)("Slider","tone",t.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Slider","size",t.size,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Slider","variant",t.variant,["default","inset","minimal","bar"]);const y=(0,_index3.useTheme)(),k=(0,_index2.useMobileUiText)("slider",_sliderG.SLIDER_TEXT),j=(0,_react.useMemo)(()=>{const e=(0,_index3.resolveSliderSize)(y,l);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[y,l]),S=(0,_react.useMemo)(()=>"default"===c?j:VARIANT_SIZE_MAP[c][l],[j,l,c]),C="inset"===c?S.trackHeight/2:0,D=y.settings.components.slider?.thumbPressAnimation??!1,V=R??1.1,M=x??y.motion.duration.fast,A=w??1,H=(0,_react.useMemo)(()=>buildStyles(y,S),[y,S]),O=(0,_react.useMemo)(()=>({damping:y.motion.spring.snappy.damping,stiffness:y.motion.spring.snappy.stiffness,mass:y.motion.spring.snappy.mass}),[y.motion.spring.snappy]),[T,E]=(0,_react.useState)(0),I=y.colors[s],W=(0,_valueText.sliderToneInk)(y,s),P=!0===t.range,q=(0,_react.useCallback)(e=>{if(!0!==t.range){if(Array.isArray(e))throw new Error("Slider received a range value in single mode.");t.onChange?.(e)}else{if(!Array.isArray(e))throw new Error("Slider received a single value in range mode.");t.onChange?.(e)}},[t.onChange,t.range]),[G,L]=(0,_index.useControllableState)({value:t.value,defaultValue:t.defaultValue??(P?[a,i]:a),onChange:q}),X=(0,_reactNativeReanimated.useSharedValue)(0),B=(0,_reactNativeReanimated.useSharedValue)(0),U=(0,_reactNativeReanimated.useSharedValue)(isPair(G)?G[0]:G),F=(0,_reactNativeReanimated.useSharedValue)(isPair(G)?G[1]:G),z=(0,_reactNativeReanimated.useSharedValue)(0),$=(0,_reactNativeReanimated.useSharedValue)(0),Z=(0,_reactNativeReanimated.useSharedValue)(1),J=(0,_reactNativeReanimated.useSharedValue)(1),K="always"===o,Q=(0,_reactNativeReanimated.useSharedValue)(K?1:0),Y=(0,_reactNativeReanimated.useSharedValue)(K?1:0),ee=(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)(Z),(0,_reactNativeReanimated.cancelAnimation)(J),(0,_reactNativeReanimated.cancelAnimation)(Q),(0,_reactNativeReanimated.cancelAnimation)(Y)},[X,B,Z,J,Q,Y]);const te=(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]),ae=(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]),ie=(0,_react.useRef)(!1),re=y.motion.duration.fast,ne=(0,_react.useRef)(G);ne.current=G;const se=(0,_react.useRef)(T);se.current=T;const le=(0,_react.useCallback)((e=!1)=>{const t=se.current;if(t<=0)return;const place=t=>e?(0,_reactNativeReanimated.withTiming)(t,{duration:re,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}):t,a=ne.current;if(isPair(a)){const[e,i]=a,r=Math.min(e,i),n=Math.max(e,i);U.value=r,F.value=n,X.value=place(te(r,t)),B.value=place(te(n,t))}else{const e=a;U.value=e,F.value=e,X.value=place(te(e,t))}},[te,U,F,X,B,re]),[ce,oe]=(0,_react.useState)(0),ue=(0,_react.useRef)(!1),de=(0,_react.useCallback)(e=>{ie.current=e,e||(ue.current=!0,oe(e=>e+1))},[]);(0,_react.useEffect)(()=>{if(ie.current)return;const e=ue.current;ue.current=!1,le(e)},[JSON.stringify(G),T,ce,le]);const me=(0,_react.useCallback)(e=>{const t=e.nativeEvent.layout.width;$.value=t,E(t)},[$]),he=(0,_react.useCallback)((e,t)=>{L(P?[e,t]:e)},[P,L]),ve=(0,_react.useCallback)(()=>{const e=(0,_index4.resolveHaptic)(_,"selection");e&&(0,_index4.triggerHaptic)(e)},[_]),be=(0,_react.useRef)(he);be.current=he;const pe=(0,_react.useRef)(ve);pe.current=ve;const fe=(0,_react.useCallback)((e,t)=>be.current(e,t),[]),ge=(0,_react.useCallback)(()=>pe.current(),[]),Re=Math.max(0,(MIN_THUMB_TOUCH-S.thumbDiameter)/2),xe=Re>0?Re:void 0,we=(0,_react.useCallback)(e=>{const t="low"===e?X:B,s="low"===e?U:F,l="low"===e?F:U,c="low"===e?Z:J,d="low"===e?Q:Y,m="low"===e,h=a,_=i,v=r,b=ee,p=P,f=V,g=D,R=!0===o,x=u,w=A,y=M,k=O,j=C,S=m&&N?`${N}-pan`:void 0,follow=e=>{"worklet";const a=$.value-2*j;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(z.value+e,j),$.value-j);let r=h+(i-j)/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=x||_===h?_===h?j:j+(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,_reactNativeWorklets.scheduleOnRN)(ge),(0,_reactNativeWorklets.scheduleOnRN)(fe,U.value,F.value))};return{enabled:!n,minDistance:0,testID:S,...void 0===xe?{}:{hitSlop:xe},onActivate:()=>{"worklet";(0,_reactNativeWorklets.scheduleOnRN)(de,!0),z.value=t.value,g&&(c.value=(0,_reactNativeReanimated.withSpring)(f,k)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(w,{duration:y,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)})),(0,_reactNativeWorklets.scheduleOnRN)(ge)},onUpdate:e=>{"worklet";follow(e.translationX)},onDeactivate:e=>{"worklet";follow(e.translationX),g&&(c.value=(0,_reactNativeReanimated.withSpring)(1,k)),R&&(d.value=(0,_reactNativeReanimated.withTiming)(0,{duration:y,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}))},onFinalize:()=>{"worklet";(0,_reactNativeWorklets.scheduleOnRN)(de,!1)}}},[n,a,i,r,ee,P,V,D,o,u,A,M,O,C,xe,N,fe,ge,de,X,B,U,F,Z,J,Q,Y,z,$]),Ne=(0,_react.useMemo)(()=>we("low"),[we]),ye=(0,_react.useMemo)(()=>we("high"),[we]),ke=(0,_reactNativeGestureHandler.usePanGesture)(Ne),je=(0,_reactNativeGestureHandler.usePanGesture)(ye),Se=(0,_react.useCallback)(e=>{if(n||P||T<=0)return;const t=clamp(e.nativeEvent.locationX,0,T),a=ae(t,T);a!==U.value&&(ve(),U.value=a,X.value=(0,_reactNativeReanimated.withTiming)(te(a,T),{duration:y.motion.duration.fast,easing:_reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.cubic)}),he(a,a))},[n,P,T,ae,te,he,ve,X,U,y.motion.duration.fast]),Ce=(0,_react.useCallback)(e=>{if(n)return;const t="increment"===e.nativeEvent.actionName?r:-r,s=r>0?Math.round(t*ee)/ee:t;if(P){const e=Math.round((U.value+s)*ee)/ee,t=clamp(e,a,F.value);t!==U.value&&(U.value=t,X.value=te(t,T),ve(),he(t,F.value))}else{const e=Math.round((U.value+s)*ee)/ee,t=clamp(e,a,i);t!==U.value&&(U.value=t,X.value=te(t,T),ve(),he(t,t))}},[n,r,ee,P,a,i,te,T,X,U,F,he,ve]),De=S.thumbDiameter/2,Ve=n?y.colors["surface-disabled"]:I,Me="inset"===c?{backgroundColor:Ve,borderColor:y.colors.surface,borderWidth:Math.max(2,Math.round(S.thumbDiameter*INSET_RING_RATIO)),...NO_SHADOW}:"minimal"===c?{backgroundColor:Ve,borderWidth:0}:"bar"===c?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:y.colors.surface,borderColor:Ve},Ae=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=$.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=n?.55:1;if(P){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}]}},...(0,_animatedDeps.webDeps)([$,n,P,B,X,C])),He=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:X.value-De},{scale:Z.value}]}),...(0,_animatedDeps.webDeps)([X,De,Z])),Oe=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({transform:[{translateX:B.value-De},{scale:J.value}]}),...(0,_animatedDeps.webDeps)([B,De,J])),Te=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:Q.value}),...(0,_animatedDeps.webDeps)([Q])),Ee=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:Y.value}),...(0,_animatedDeps.webDeps)([Y])),clampDisplay=e=>clamp(e,a,i),Ie=clampDisplay(isPair(G)?Math.min(...G):G),We=clampDisplay(isPair(G)?Math.max(...G):G);return(0,_jsxRuntime.jsx)(_reactNative.View,{ref:e,style:[H.container,v],testID:N,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:n},"aria-disabled":n,accessibilityValue:P?{min:a,max:i,now:Ie,text:(0,_index2.fillText)(k.text,{start:Ie,end:We})}:{min:a,max:i,now:Ie},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Ce,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:Se,disabled:n||P,style:H.trackTouch,testID:N?`${N}-track-press`:void 0,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.trackWrap,onLayout:me,testID:N?`${N}-track`:void 0,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:H.trackClip,pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.track,{backgroundColor:n?y.colors["surface-disabled"]:y.colors.border},b]}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[H.fill,{backgroundColor:n?y.colors["surface-disabled"]:I},p,Ae],testID:N?`${N}-fill`:void 0})]}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ke,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[H.thumb,{width:S.thumbDiameter,height:S.thumbDiameter,borderRadius:De,..._corners.smoothCorners,opacity:n?.55:1},Me,f,He],testID:N?`${N}-thumb`:void 0,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[H.bubbleWrap,Te],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.bubble,{backgroundColor:I}],children:m?m(Ie):(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",weight:"semibold",style:[{color:W},g],numberOfLines:1,children:d(Ie)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.bubbleCaret,{backgroundColor:I}]})]}):null})}),P?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:je,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[H.thumb,{width:S.thumbDiameter,height:S.thumbDiameter,borderRadius:De,..._corners.smoothCorners,opacity:n?.55:1},Me,f,Oe],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o?(0,_jsxRuntime.jsxs)(_reactNativeReanimated.default.View,{style:[H.bubbleWrap,Ee],pointerEvents:"none",children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.bubble,{backgroundColor:I}],children:m?m(We):(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",weight:"semibold",style:[{color:W},g],numberOfLines:1,children:d(We)})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[H.bubbleCaret,{backgroundColor:I}]})]}):null})}):null]})})})}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;
|