@webority/mobile-ui 0.173.1 → 0.174.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.
@@ -2,7 +2,7 @@
2
2
  "kind": "WeborityPhone",
3
3
  "library": {
4
4
  "name": "@webority/mobile-ui",
5
- "version": "0.173.1"
5
+ "version": "0.174.0"
6
6
  },
7
7
  "rendererProtocolVersion": 14,
8
8
  "platform": "Phone",
@@ -3730,6 +3730,12 @@
3730
3730
  "description": "The shadow under the card, as a shadow name or none.",
3731
3731
  "default": "card"
3732
3732
  },
3733
+ {
3734
+ "name": "flex",
3735
+ "type": "number",
3736
+ "required": false,
3737
+ "description": "Share of the free space along the parent's main axis, as React Native flex. Unset, the card sizes to its content."
3738
+ },
3733
3739
  {
3734
3740
  "name": "footer",
3735
3741
  "type": "node",
@@ -17229,6 +17235,12 @@
17229
17235
  "required": false,
17230
17236
  "description": "A small line under the figure, such as a period or a delta."
17231
17237
  },
17238
+ {
17239
+ "name": "flex",
17240
+ "type": "number",
17241
+ "required": false,
17242
+ "description": "Share of the free space along the parent's main axis, as React Native flex. Unset, the tile sizes to its content."
17243
+ },
17232
17244
  {
17233
17245
  "name": "icon",
17234
17246
  "type": "icon",
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "webority-phone",
3
- "version": "0.173.1",
3
+ "version": "0.174.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.173.1"
9
+ "version": "0.174.0"
10
10
  },
11
11
  "files": {
12
12
  "manifest.json": {
13
- "sha256": "0eeb3ef53df758f84362a388199bd72abb9eaa026a99b31ee85ab0d0da80475b",
14
- "bytes": 673399
13
+ "sha256": "84d3fc1f1f39c6868cd074635bfbe7e93f5d6efea2fd61604087c630108891f9",
14
+ "bytes": 673889
15
15
  },
16
16
  "kit.js": {
17
- "sha256": "14069eb34cd7d1d1b54958b015e9ab0a29164020cd815d5a66cea523980b0b39",
18
- "bytes": 5706905
17
+ "sha256": "78c044bff22c4ee7a20083fe0c042456da74ccf96d59b26f42d11b362a1765ee",
18
+ "bytes": 5707590
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:R="sheet",animateMount:y=!0,handleIndicatorStyle:N,sheetStyle:g,header:M,actions:j,actionsLayout:C="auto",footer:w,headerStyle:k,footerStyle:O,children:I,accessibilityLabel:V,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,G=p?"inline":"modal",L=(0,_index2.useTheme)(),q=(0,_usePresenceMotion.usePresenceMotion)(),W=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[Y,$]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),z=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&$(e=>e===a?e:a)},[]),K=(0,_reactNative.useWindowDimensions)(),X="dialog"===R||"auto"===R&&Math.min(K.width,K.height)>=600,J=Math.min(560,Y-2*L.space.xl),[Q,Z]=(0,_ModalSafeArea.useModalInsets)(),ee="modal"===G?Q.top:W.top,te="modal"===G?Q.bottom:W.bottom,ae=t.includes("content"),[re,oe]=useMeasuredHeight(),[ne,se]=useMeasuredHeight(),[ie,ce,le]=useMeasuredHeight(),[ue,de]=useMeasuredHeight(),he=X?L.space.md:re,me=ae?Math.min(he+(P?ne:0)+ie+(H?ue:0)+te,F-ee):0,ve=(0,_react.useCallback)((e,t)=>{ae&&le(t),f?.(e,t)},[ae,f,le]),fe=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,me),[t,F,me]),be=F,xe=fe[fe.length-1]??0,Se=(0,_reactNativeReanimated.useSharedValue)(be),pe=(0,_reactNativeReanimated.useSharedValue)(be),Re=(0,_reactNativeReanimated.useSharedValue)(1),ye=(0,_reactNativeReanimated.useSharedValue)(-1),[Ne,ge]=(0,_react.useState)(-1),[Me,je]=(0,_react.useState)(!1),[Ce,we]=(0,_react.useState)(!1),ke=(0,_react.useRef)(!1),Oe=(0,_react.useRef)(i);Oe.current=i;const[Ie,Ve]=(0,_react.useState)(!1),Ae=(0,_react.useRef)(!y&&a),Te=(0,_react.useRef)(-1),Ee=(0,_react.useRef)(!1);Ee.current="modal"===G?Ce:Ie;const Be=(0,_react.useRef)(u);Be.current=u;const Pe=(0,_react.useRef)(r);Pe.current=r;const De=(0,_react.useRef)(!1),He=(0,_react.useRef)(!0),Ge=(0,_react.useRef)([]),Le=(0,_react.useCallback)(e=>{const t=Ge.current;Ge.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(He.current=!0,()=>{He.current=!1,Le(!1)}),[Le]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=fe.length)return be;const t=fe[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return X?(F-t)/2:F-t},[fe,F,be,X]),We=(0,_react.useCallback)(e=>{Te.current=e;Ne!==e&&(ge(e),ye.value=e,e>=0&&n?.(e))},[Ne,ye,n]),Fe=(0,_react.useCallback)(()=>{ye.value<0&&(ke.current=!0,"modal"===G?(je(!1),"ios"!==_reactNative.Platform.OS&&we(!1)):Ve(!1))},[G,ye]),Ue=(0,_react.useCallback)(()=>{ke.current&&we(!1)},[]);(0,_react.useEffect)(()=>{("modal"===G?!Ce:!Ie)&&ke.current&&(ke.current=!1,Oe.current?.(),Le(!0))},[G,Ce,Ie,Le]);const Ye=(0,_react.useCallback)((e,t,a)=>{s?.(t,a),Se.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeWorklets.scheduleOnRN)(Fe)})},[s,Se,Fe]),$e=(0,_react.useRef)(null),ze=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,fe.length-1):Math.max(Ne,0),a=ye.value,r=qe(t);return ke.current=!1,Le(!1),"modal"===G?(we(!0),je(!0)):Ve(!0),a<0&&Ae.current?(Se.value=r,Re.value=1,We(t),void s?.(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(...L.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),We(t),void s?.(a,t)):(a<0&&(Se.value=be,Re.value=1),We(t),void(a<0&&t>=0&&!Ee.current?$e.current={fromIndex:a,target:t}:Ye(r,a,t)))},[Ye,be,Ne,ye,G,s,q,Re,fe.length,We,Le,L.motion.ease.decelerate,Se,qe]),Ke=(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;We(-1),s?.(t,-1);const a=q.reduced?Re:Se,r=q.reduced?0:be;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:q.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...L.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeWorklets.scheduleOnRN)(Fe)})}),[be,ye,Fe,s,q,Re,We,Se,L.motion.ease.accelerate]),Xe=(0,_react.useCallback)((e,t,a)=>{const r=Be.current;if(!r)return void e();if(De.current)return void t?.();const o=r();"boolean"!=typeof o?(De.current=!0,a?.(),o.then(a=>{De.current=!1,a&&He.current&&Te.current>=0?e():t?.()},e=>{throw De.current=!1,e})):(o?e:t)?.()},[]),Je=(0,_react.useCallback)(()=>new Promise(e=>{Te.current<0?e(!0):Xe(()=>{Pe.current(),Ke(),e(!0)},()=>e(!1))}),[Ke,Xe]),Qe=(0,_react.useCallback)(()=>{Pe.current()},[]),Ze=(0,_react.useCallback)(()=>{l&&Je()},[l,Je]),et=(0,_react.useRef)(null),tt=(0,_react.useRef)(ze);tt.current=ze;const at=(0,_react.useRef)(Ke);at.current=Ke,(0,_react.useEffect)(()=>{const e=et.current!==a;et.current=a,e?a?tt.current(o??0):at.current():a&&"number"==typeof o&&o!==ye.value&&tt.current(o)},[a,o,ye]);const rt=(0,_react.useRef)({hostHeight:F,contentSnap:me}),ot=(0,_react.useRef)(qe);ot.current=qe,(0,_react.useEffect)(()=>{const e=rt.current;if(e.hostHeight===F&&e.contentSnap===me)return;if(rt.current={hostHeight:F,contentSnap:me},e.hostHeight===F&&ye.value<0)return;const t=ot.current(ye.value);Se.value=Ae.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,me,ye,Se]);const nt="modal"===G?Ce:Ie;(0,_react.useEffect)(()=>{const e=$e.current;null!==e&&nt&&($e.current=null,Te.current===e.target&&Ye(ot.current(e.target),e.fromIndex,e.target))},[nt,Ye]);const st=F-xe,it=(0,_react.useMemo)(()=>fe.map(e=>F-e),[fe,F]),ct=(0,_react.useCallback)(()=>{const e=Te.current;e<0||Ye(qe(e),e,e)},[Ye,qe]),lt=(0,_react.useCallback)((e,t)=>{const a=ye.value;-1!==e?(We(e),Ye(t,a,e)):Xe(()=>{_reactNative.Keyboard.dismiss(),(0,_index3.triggerHaptic)("selection"),Pe.current(),Ke()},ct,ct)},[Ye,Ke,ye,Xe,We,ct]),ut=(0,_react.useMemo)(()=>({testID:T?`${T}-content-gesture`:"bottom-sheet-content-gesture"}),[T]),dt=(0,_reactNativeGestureHandler.useNativeGesture)(ut),_t=(0,_react.useMemo)(()=>{const e=it,t=be,a=st,r=c;return{testID:T?`${T}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";pe.value=Se.value},onUpdate:e=>{"worklet";const t=pe.value+e.translationY;Se.value=t<a?a+.25*(t-a):t},onDeactivate:a=>{"worklet";const o=Se.value,n=a.velocityY,[s]=e;if(void 0===s)return void(0,_reactNativeWorklets.scheduleOnRN)(lt,-1,t);if(n>1e3)return r?void(0,_reactNativeWorklets.scheduleOnRN)(lt,-1,t):void(0,_reactNativeWorklets.scheduleOnRN)(lt,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)(lt,-1,t):(0,_reactNativeWorklets.scheduleOnRN)(lt,i,c)}}},[be,pe,c,lt,st,it,T,Se]),ht=(0,_reactNativeGestureHandler.usePanGesture)(_t),{height:mt}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),vt="shift"===S,ft=(0,_reactNativeReanimated.useDerivedValue)(()=>vt?mt.value:0,[vt,mt]),bt=fe[Math.max(Ne,0)]??xe,xt=L.space.md,St=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(X){const e=ft.value,t=F+e-bt-xt,a=e<0&&Se.value>t?t:Se.value;return{top:Math.max(a,ee),opacity:Re.value}}const e=Se.value+ft.value,t=ft.value<0?ee:st;return{top:Math.max(e,t),opacity:Re.value}},[X,ft,F,bt,xt,Se,ee,Re,st]),pt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=ft.value;if(X){const t=F+e-bt-xt,a=e<0&&Se.value>t?t:Se.value,r=Math.max(a,ee),o=F+e-xt-r;return{height:o<0?0:Math.min(o,bt)}}const t=e<0?ee:st,a=Se.value+e,r=Math.max(a,t),o=F+e-r;return{height:o<0?0:Math.min(o,xe)}},[ft,X,F,bt,xt,Se,ee,st,xe]),Rt=Ne>=0,yt=(0,_react.useMemo)(()=>buildStyles(L),[L]),Nt=(0,_react.useCallback)(()=>{l&&Xe(()=>{(0,_index3.triggerHaptic)("selection"),Pe.current(),Ke()})},[l,Ke,Xe]),gt=(0,_react.useMemo)(()=>({testID:T?`${T}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||(0,_reactNativeWorklets.scheduleOnRN)(Nt)}}),[Nt,T]),Mt=(0,_reactNativeGestureHandler.useTapGesture)(gt),jt=(0,_react.useMemo)(()=>({snapIndex:Ne,snapPoints:fe,close:Qe,requestClose:Je}),[Ne,fe,Qe,Je]);if("inline"===G&&!Ie)return null;if("modal"===G&&!Ce)return null;const Ct=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===G?yt.backdropModal:yt.backdropInline,{backgroundColor:"modal"===G?(0,_color.transparentOf)(L.colors.scrim):L.colors.scrim}],onLayout:z,testID:T,accessibilityViewIsModal:A??Rt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Mt,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:V,accessibilityViewIsModal:A??Rt,accessibilityActions:[{name:"escape",label:B.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Ze()},onAccessibilityEscape:Ze,style:[yt.sheet,{height:xe,backgroundColor:L.colors.surface,borderTopLeftRadius:L.radius.xl,borderTopRightRadius:L.radius.xl,..._corners.smoothCorners,...L.shadow.modal},X?{height:bt,left:(Y-J)/2,right:void 0,width:J,borderBottomLeftRadius:L.radius.xl,borderBottomRightRadius:L.radius.xl}:null,g,St],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[yt.body,pt],keyboardOffset:ft,children:[X?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:L.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ht,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:yt.handleRow,onLayout:ae?oe:void 0,accessible:!0,accessibilityLabel:B.dragHandle,accessibilityHint:B.dragHandleHintText,testID:T?`${T}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[yt.handle,{backgroundColor:L.colors.border},N]})})}),P&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[yt.header,k],onLayout:ae?se: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:dt,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,testID:T?`${T}-scroll`:void 0,style:yt.scrollContent,onScroll:v,onContentSizeChange:ve,onLayout:b,scrollEventThrottle:x,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:I})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:ae?[yt.content,{overflow:"visible"}]:yt.content,children:ae?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:ce,children:I}):I}),H&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[yt.footer,O],onLayout:ae?de:void 0,children:[D?(0,_jsxRuntime.jsx)(_reactNative.View,{style:yt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:C})}):null,w]})]})})]}),wt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:jt,children:Ct});return"modal"===G?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:Me,onClose:Ze,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Z,onDismissed:"ios"===_reactNative.Platform.OS?Ue:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:yt.modalRoot,children:wt}):wt}):wt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset: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:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},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"),_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:R="sheet",animateMount:N=!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,G=p?"inline":"modal",L=(0,_index2.useTheme)(),q=(0,_usePresenceMotion.usePresenceMotion)(),W=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[Y,K]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),$=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&K(e=>e===a?e:a)},[]),z=(0,_reactNative.useWindowDimensions)(),X="dialog"===R||"auto"===R&&Math.min(z.width,z.height)>=600,J=Math.min(560,Y-2*L.space.xl),[Q,Z]=(0,_ModalSafeArea.useModalInsets)(),ee="modal"===G?Q.top:W.top,te="modal"===G?Q.bottom:W.bottom,ae=t.includes("content"),[re,oe]=useMeasuredHeight(),[ne,se]=useMeasuredHeight(),[ie,ce,le]=useMeasuredHeight(),[ue,de]=useMeasuredHeight(),he=X?L.space.md:re,me=ae?Math.min(he+(P?ne:0)+ie+(H?ue:0)+te,F-ee):0,ve=(0,_react.useCallback)((e,t)=>{ae&&le(t),f?.(e,t)},[ae,f,le]),fe=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,me),[t,F,me]),be=F,xe=fe[fe.length-1]??0,Se=(0,_reactNativeReanimated.useSharedValue)(be),pe=(0,_reactNativeReanimated.useSharedValue)(be),Re=(0,_reactNativeReanimated.useSharedValue)(1),Ne=(0,_reactNativeReanimated.useSharedValue)(-1),[ye,ge]=(0,_react.useState)(-1),[Me,je]=(0,_react.useState)(!1),[Ce,we]=(0,_react.useState)(!1),ke=(0,_react.useRef)(!1),Oe=(0,_react.useRef)(i);Oe.current=i;const[Ve,Ie]=(0,_react.useState)(!1),Ae=(0,_react.useRef)(!N&&a),Te=(0,_react.useRef)(-1),Ee=(0,_react.useRef)(!1);Ee.current="modal"===G?Ce:Ve;const Be=(0,_react.useRef)(u);Be.current=u;const Pe=(0,_react.useRef)(r);Pe.current=r;const De=(0,_react.useRef)(!1),He=(0,_react.useRef)(!0),Ge=(0,_react.useRef)([]),Le=(0,_react.useCallback)(e=>{const t=Ge.current;Ge.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(He.current=!0,()=>{He.current=!1,Le(!1)}),[Le]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=fe.length)return be;const t=fe[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return X?(F-t)/2:F-t},[fe,F,be,X]),We=(0,_react.useCallback)(e=>{Te.current=e;ye!==e&&(ge(e),Ne.value=e,e>=0&&n?.(e))},[ye,Ne,n]),Fe=(0,_react.useCallback)(()=>{Ne.value<0&&(ke.current=!0,"modal"===G?(je(!1),"ios"!==_reactNative.Platform.OS&&we(!1)):Ie(!1))},[G,Ne]),Ue=(0,_react.useCallback)(()=>{ke.current&&we(!1)},[]);(0,_react.useEffect)(()=>{("modal"===G?!Ce:!Ve)&&ke.current&&(ke.current=!1,Oe.current?.(),Le(!0))},[G,Ce,Ve,Le]);const Ye=(0,_react.useCallback)((e,t,a)=>{s?.(t,a),Se.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeWorklets.scheduleOnRN)(Fe)})},[s,Se,Fe]),Ke=(0,_react.useRef)(null),$e=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,fe.length-1):Math.max(ye,0),a=Ne.value,r=qe(t);return ke.current=!1,Le(!1),"modal"===G?(we(!0),je(!0)):Ie(!0),a<0&&Ae.current?(Se.value=r,Re.value=1,We(t),void s?.(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(...L.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),We(t),void s?.(a,t)):(a<0&&(Se.value=be,Re.value=1),We(t),void(a<0&&t>=0&&!Ee.current?Ke.current={fromIndex:a,target:t}:Ye(r,a,t)))},[Ye,be,ye,Ne,G,s,q,Re,fe.length,We,Le,L.motion.ease.decelerate,Se,qe]),ze=(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,Ke.current=null;const t=Ne.value;We(-1),s?.(t,-1);const a=q.reduced?Re:Se,r=q.reduced?0:be;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:q.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...L.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeWorklets.scheduleOnRN)(Fe)})}),[be,Ne,Fe,s,q,Re,We,Se,L.motion.ease.accelerate]),Xe=(0,_react.useCallback)((e,t,a)=>{const r=Be.current;if(!r)return void e();if(De.current)return void t?.();const o=r();"boolean"!=typeof o?(De.current=!0,a?.(),o.then(a=>{De.current=!1,a&&He.current&&Te.current>=0?e():t?.()},e=>{throw De.current=!1,e})):(o?e:t)?.()},[]),Je=(0,_react.useCallback)(()=>new Promise(e=>{Te.current<0?e(!0):Xe(()=>{Pe.current(),ze(),e(!0)},()=>e(!1))}),[ze,Xe]),Qe=(0,_react.useCallback)(()=>{Pe.current()},[]),Ze=(0,_react.useCallback)(()=>{l&&Je()},[l,Je]),et=(0,_react.useRef)(null),tt=(0,_react.useRef)($e);tt.current=$e;const at=(0,_react.useRef)(ze);at.current=ze,(0,_react.useEffect)(()=>{const e=et.current!==a;et.current=a,e?a?tt.current(o??0):at.current():a&&"number"==typeof o&&o!==Ne.value&&tt.current(o)},[a,o,Ne]);const rt=(0,_react.useRef)({hostHeight:F,contentSnap:me}),ot=(0,_react.useRef)(qe);ot.current=qe,(0,_react.useEffect)(()=>{const e=rt.current;if(e.hostHeight===F&&e.contentSnap===me)return;if(rt.current={hostHeight:F,contentSnap:me},e.hostHeight===F&&Ne.value<0)return;const t=ot.current(Ne.value);Se.value=Ae.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,me,Ne,Se]);const nt="modal"===G?Ce:Ve;(0,_react.useEffect)(()=>{const e=Ke.current;null!==e&&nt&&(Ke.current=null,Te.current===e.target&&Ye(ot.current(e.target),e.fromIndex,e.target))},[nt,Ye]);const st=F-xe,it=(0,_react.useMemo)(()=>fe.map(e=>F-e),[fe,F]),ct=(0,_react.useCallback)(()=>{const e=Te.current;e<0||Ye(qe(e),e,e)},[Ye,qe]),lt=(0,_react.useCallback)((e,t)=>{const a=Ne.value;-1!==e?(We(e),Ye(t,a,e)):Xe(()=>{_reactNative.Keyboard.dismiss(),(0,_index3.triggerHaptic)("selection"),Pe.current(),ze()},ct,ct)},[Ye,ze,Ne,Xe,We,ct]),ut=(0,_react.useMemo)(()=>({testID:T?`${T}-content-gesture`:"bottom-sheet-content-gesture"}),[T]),dt=(0,_reactNativeGestureHandler.useNativeGesture)(ut),_t=(0,_react.useMemo)(()=>{const e=it,t=be,a=st,r=c;return{testID:T?`${T}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";pe.value=Se.value},onUpdate:e=>{"worklet";const t=pe.value+e.translationY;Se.value=t<a?a+.25*(t-a):t},onDeactivate:a=>{"worklet";const o=Se.value,n=a.velocityY,[s]=e;if(void 0===s)return void(0,_reactNativeWorklets.scheduleOnRN)(lt,-1,t);if(n>1e3)return r?void(0,_reactNativeWorklets.scheduleOnRN)(lt,-1,t):void(0,_reactNativeWorklets.scheduleOnRN)(lt,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)(lt,-1,t):(0,_reactNativeWorklets.scheduleOnRN)(lt,i,c)}}},[be,pe,c,lt,st,it,T,Se]),ht=(0,_reactNativeGestureHandler.usePanGesture)(_t),{height:mt,progress:vt}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ft="shift"===S,bt=(0,_reactNativeReanimated.useDerivedValue)(()=>ft?mt.value:0,[ft,mt]),xt=(0,_reactNativeReanimated.useSharedValue)(0);(0,_reactNativeReanimated.useAnimatedReaction)(()=>ft&&vt.value>=1?mt.value:0,e=>{xt.value=e},[ft,mt,vt,xt]);const St=fe[Math.max(ye,0)]??xe,pt=L.space.md,Rt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=bt.value;if(X){const t=F+e-St-pt,a=e<0&&Se.value>t?t:Se.value;return{top:Se.value,transform:[{translateY:Math.max(a,ee)-Se.value}],opacity:Re.value}}const t=e<0?ee:st,a=Math.max(Se.value+e,t);return{top:Se.value,transform:[{translateY:a-Se.value}],opacity:Re.value}},[X,bt,F,St,pt,Se,ee,Re,st]),Nt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=xt.value;if(X){const t=F+e-St-pt,a=e<0&&Se.value>t?t:Se.value,r=Math.max(a,ee),o=F+e-pt-r;return{height:o<0?0:Math.min(o,St)}}const t=e<0?ee:st,a=Se.value+e,r=Math.max(a,t),o=F+e-r;return{height:o<0?0:Math.min(o,xe)}},[xt,X,F,St,pt,Se,ee,st,xe]),yt=ye>=0,gt=(0,_react.useMemo)(()=>buildStyles(L),[L]),Mt=(0,_react.useCallback)(()=>{l&&Xe(()=>{(0,_index3.triggerHaptic)("selection"),Pe.current(),ze()})},[l,ze,Xe]),jt=(0,_react.useMemo)(()=>({testID:T?`${T}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||(0,_reactNativeWorklets.scheduleOnRN)(Mt)}}),[Mt,T]),Ct=(0,_reactNativeGestureHandler.useTapGesture)(jt),wt=(0,_react.useMemo)(()=>({snapIndex:ye,snapPoints:fe,close:Qe,requestClose:Je}),[ye,fe,Qe,Je]);if("inline"===G&&!Ve)return null;if("modal"===G&&!Ce)return null;const kt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===G?gt.backdropModal:gt.backdropInline,{backgroundColor:"modal"===G?(0,_color.transparentOf)(L.colors.scrim):L.colors.scrim}],onLayout:$,testID:T,accessibilityViewIsModal:A??yt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Ct,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??yt,accessibilityActions:[{name:"escape",label:B.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Ze()},onAccessibilityEscape:Ze,style:[gt.sheet,{height:xe,backgroundColor:L.colors.surface,borderTopLeftRadius:L.radius.xl,borderTopRightRadius:L.radius.xl,..._corners.smoothCorners,...L.shadow.modal},X?{height:St,left:(Y-J)/2,right:void 0,width:J,borderBottomLeftRadius:L.radius.xl,borderBottomRightRadius:L.radius.xl}:null,g,Rt],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[gt.body,Nt],settledKeyboardOffset:xt,children:[X?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:L.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ht,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:gt.handleRow,onLayout:ae?oe:void 0,accessible:!0,accessibilityLabel:B.dragHandle,accessibilityHint:B.dragHandleHintText,testID:T?`${T}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[gt.handle,{backgroundColor:L.colors.border},y]})})}),P&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[gt.header,k],onLayout:ae?se: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:dt,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,testID:T?`${T}-scroll`:void 0,style:gt.scrollContent,onScroll:v,onContentSizeChange:ve,onLayout:b,scrollEventThrottle:x,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:V})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:ae?[gt.content,{overflow:"visible"}]:gt.content,children:ae?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:ce,children:V}):V}),H&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[gt.footer,O],onLayout:ae?de:void 0,children:[D?(0,_jsxRuntime.jsx)(_reactNative.View,{style:gt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:C})}):null,w]})]})})]}),Ot=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:wt,children:kt});return"modal"===G?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:Me,onClose:Ze,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Z,onDismissed:"ios"===_reactNative.Platform.OS?Ue:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:gt.modalRoot,children:Ot}):Ot}):Ot};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"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Card=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../text/index.js"),_cardG=require("../../text/phone/card.g.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_guards=require("../../utils/guards.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_shadows=require("../../utils/shadows.js"),_squircle=require("../../utils/squircle.js"),_themeStyles=require("../../utils/themeStyles.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index3=require("../Skeleton/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,s,a=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(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=a&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?a(r,s,i):r[s]=e[s]);return r}const OUTER_LAYOUT_KEYS=new Set(["flex","flexGrow","flexShrink","flexBasis","alignSelf","width","height","minWidth","maxWidth","minHeight","maxHeight","position","top","right","bottom","left","start","end","zIndex"]),splitOuterLayout=e=>{const t={},i={};for(const[s,a]of Object.entries(_reactNative.StyleSheet.flatten(e)??{}))(OUTER_LAYOUT_KEYS.has(s)||s.startsWith("margin")?t:i)[s]=a;return{outer:t,inner:i}},BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},CardRoot=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{children:i,variant:s,elevation:a="card",radius:r,padding:n,interactive:o=!1,pressAnimation:l="scale",bg:d,header:c,title:u,titleFont:h,lead:x,action:m,headerActions:_,collapsible:p=!1,collapsed:g,defaultCollapsed:b=!1,onCollapsedChange:j,collapsedSummary:y,onRemove:f,separatorHeight:v=_reactNative.StyleSheet.hairlineWidth,footer:R,imageSource:S,imageHeight:C=160,imageAspectRatio:w,imageOverlay:V,loading:A=!1,gradient:q,onPress:N,haptic:T,contextMenu:k,accessibilityLabel:F,accessibilityHint:O,accessibilityRole:P,style:B,headerStyle:I,bodyStyle:L,footerStyle:M,testID:H,labels:z,onLayout:W,...E}=e;(0,_assertValidValue.assertValidValue)("Card","variant",e.variant,["elevated","outline","filled","flat"]),(0,_assertValidValue.assertValidValue)("Card","radius",e.radius,["sm","md","lg","xl","pill"]),(0,_assertValidValue.assertValidValue)("Card","padding",e.padding,["none","sm","md","lg","xl"]),(0,_assertValidValue.assertValidValue)("Card","titleFont",e.titleFont,["sans","serif"]),(0,_assertValidValue.assertValidValue)("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const U=(0,_index2.useTheme)(),D=U.settings.components.card,G=s??D?.defaultVariant??"elevated",K=r??D?.defaultRadius??"lg",Y=n??D?.defaultPadding??"md",X=h??D?.defaultTitleFont??"sans",$=(0,_index.useMobileUiText)("card",_cardG.CARD_TEXT),J=(0,_react.useMemo)(()=>({...$,...z}),[$,z]),Q=o||"function"==typeof N,Z=(0,_useContextMenu.useContextMenu)(k,{haptic:T||!1,testID:H,accessibilityActions:E.accessibilityActions,onAccessibilityAction:E.onAccessibilityAction}),ee=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,Z.hostRef),[t,Z.hostRef]),te=Q||Z.enabled,{style:ie,pressIn:se,pressOut:ae}=(0,_usePressAnimation.usePressAnimation)({preset:l||"scale",enabled:te&&!1!==l}),re=stylesFor(U),ne=Boolean(S),oe=U.space[paddingMap[Y]],le=(0,_react.useMemo)(()=>q?"string"==typeof q?U.settings.gradients[q]??null:q:null,[q,U.settings.gradients]),de="flat"===G,ce=de?U.radius.none:U.radius[K],ue=resolveBackground(U,d),[he,xe]=(0,_useControllableState.useControllableState)({value:g,defaultValue:b,onChange:j}),me=p&&he,pe=hasBuiltInHeaderContent(e),ge=Boolean(c)||pe,be=(0,_SquircleFill.useSquircle)(!ne&&!le&&!de,ce,W),je=_reactNative.StyleSheet.flatten(B)??{},ye="string"==typeof je.backgroundColor?je.backgroundColor:void 0,fe="string"==typeof je.borderColor?je.borderColor:void 0,ve=ye??ue??("filled"===G?U.colors["bg-subtle"]:U.colors.surface),Re="outline"===G?U.size.border:0,Se=fe??U.colors.border,Ce="none"===a?void 0:U.shadow[a],we="elevated"===G&&(0,_shadows.supportsBoxShadow)()&&Ce?(0,_shadows.toBoxShadow)(Ce):void 0,Ve=be.active&&"elevated"===G&&!we,Ae=be.active&&!Ve?{backgroundColor:"transparent",borderColor:"transparent"}:null,qe=(0,_react.useMemo)(()=>{const e={borderRadius:Ve&&be.size?(0,_squircle.squircleHostRadius)(be.size.width,be.size.height,ce):ce,..._corners.smoothCorners,padding:ne||be.active?U.space.none:oe,overflow:be.active?"visible":"hidden"};switch(G){case"flat":return{...e,backgroundColor:ue??U.colors.surface,borderBottomWidth:v,borderBottomColor:U.colors.border};case"outline":return{...e,backgroundColor:be.active?"transparent":ue??U.colors.surface,borderWidth:U.size.border,borderColor:be.active?"transparent":U.colors.border};case"filled":return{...e,backgroundColor:be.active?"transparent":ue??U.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??U.colors.surface,...we?{boxShadow:we}:Ce}}},[U,G,Ce,ce,ne,oe,be.active,be.size,we,Ve,ue,v]),Ne=(0,_react.useMemo)(()=>({..."number"==typeof w?{width:"100%",aspectRatio:w}:{width:"100%",height:C},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:U.radius.none,borderBottomRightRadius:U.radius.none,..._corners.smoothCorners}),[U,ce,w,C]),Te=u??"",ke=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.titleColumn,children:[u?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(U,X),children:u}):null,x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",style:re.lead,children:x}):null,me&&y?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",style:re.lead,children:y}):null]}),isCardTextAction(m)?(0,_jsxRuntime.jsx)(CardTextActionButton,{action:m,haptic:T}):m?(0,_jsxRuntime.jsx)(_reactNative.View,{style:re.actionNode,children:m}):null,_,p?(0,_jsxRuntime.jsx)(CardIconAction,{icon:me?"chevron-down":"chevron-up",label:`${me?J.show:J.hide} ${Te}`.trim(),expanded:!me,onPress:()=>xe(!me),haptic:T}):null,f?(0,_jsxRuntime.jsx)(CardIconAction,{icon:"trash",label:J.remove,onPress:f,color:U.colors["danger-text"],haptic:T}):null]}),Fe=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[ge?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.header,!c&&re.headerRow,me&&re.headerFolded,I],children:c??ke}):null,me?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ge||R?re.body:null,L],children:i}),R&&!me?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.footer,M],children:R}):null]}),Oe=S?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.imageWrapper,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:S,resizeMode:"cover",style:Ne,accessibilityLabel:"",accessible:!1}),V?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:re.imageOverlay,children:V}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{padding:oe},children:Fe})]}):Fe,Pe=le?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index2.Gradient,{gradient:le,style:_reactNative.StyleSheet.absoluteFill}),Oe]}):be.active&&be.size?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:be.size.width,height:be.size.height,radius:ce,fill:ve,stroke:Re?Se:void 0,strokeWidth:Re}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.squircleClip,{padding:oe,borderRadius:be.size?(0,_squircle.squircleHostRadius)(be.size.width,be.size.height,ce):ce}],children:Oe})]}):Oe,{outer:Be,inner:Ie}=splitOuterLayout(B);let Le;if(te){const handlePress=e=>{Q&&(T&&(0,_hapticUtils.triggerHaptic)(T),N?.(e))};Le=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[ie,Be],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:ee,onPress:handlePress,onPressIn:se,onPressOut:ae,accessibilityRole:P??(Q?"button":void 0),accessibilityLabel:F,accessibilityHint:O,testID:H,onLayout:be.onLayout,style:[qe,Ie,Ae,re.pressFill],...E,...Z.hostProps,children:Pe})})}else Le=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityLabel:F,accessibilityHint:O,accessibilityRole:P,testID:H,onLayout:be.onLayout,style:[qe,B,Ae],...E,children:Pe});return A?(0,_jsxRuntime.jsx)(CardSkeleton,{...e}):Z.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Le,Z.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:[qe,B,Ae,re.preview],children:Pe}))]}):Le})),CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:a,header:r,footer:n,imageSource:o,imageHeight:l=160,imageAspectRatio:d,headerStyle:c,bodyStyle:u,footerStyle:h,style:x,labels:m,..._})=>{const p=(0,_index2.useTheme)(),g=p.settings.components.card,b=e??g?.defaultVariant??"elevated",j=i??g?.defaultRadius??"lg",y=s??g?.defaultPadding??"md",f={...(0,_index.useMobileUiText)("card",_cardG.CARD_TEXT),...m},v=paddingMap[y],R=p.space[v],S="flat"===b?p.radius.none:p.radius[j],C=void 0!==r||hasBuiltInHeaderContent(_),w=resolveBackground(p,a)??p.colors.surface,V="outline"===b?1:0,A="outline"===b?p.colors.border:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{backgroundColor:w,borderRadius:S,..._corners.smoothCorners,borderWidth:V,borderColor:A,overflow:"hidden"},x],accessibilityRole:"progressbar",accessibilityLabel:f.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==o?(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:"100%",height:d?void 0:l,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,C?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:R,paddingBottom:p.space.sm},c],children:(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"60%",height:18})}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:R},u],children:(0,_jsxRuntime.jsx)(_index3.SkeletonText,{lines:3,fontSize:p.text.base.size,lastLineWidth:"55%"})}),void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:R,paddingTop:p.space.sm,flexDirection:"row"},h],children:(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton";const Card=exports.Card=Object.assign(CardRoot,{Skeleton:CardSkeleton});Card.displayName="Card";const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!_react.default.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:a,haptic:r})=>{const n=(0,_index2.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{r&&(0,_hapticUtils.triggerHaptic)(r),i()},style:iconActionStyle,children:(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:e,size:20,color:a??n.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:textActionStyle,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?(0,_index2.fontFor)(e,"semibold","display"):{fontFamily:void 0,...(0,_index2.fontFor)(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return(0,_guards.isOneOf)(BACKGROUND_TOKENS,t)?e.colors[t]:t},buildStyles=e=>_reactNative.StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{..._reactNative.StyleSheet.absoluteFill},squircleClip:{overflow:"hidden",..._corners.smoothCorners},pressFill:{flexGrow:1},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=Card;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Card=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../text/index.js"),_cardG=require("../../text/phone/card.g.js"),_index2=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_guards=require("../../utils/guards.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_shadows=require("../../utils/shadows.js"),_squircle=require("../../utils/squircle.js"),_themeStyles=require("../../utils/themeStyles.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index3=require("../Skeleton/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,s,a=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(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=a&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?a(r,s,i):r[s]=e[s]);return r}const OUTER_LAYOUT_KEYS=new Set(["flex","flexGrow","flexShrink","flexBasis","alignSelf","width","height","minWidth","maxWidth","minHeight","maxHeight","position","top","right","bottom","left","start","end","zIndex"]),splitOuterLayout=e=>{const t={},i={};for(const[s,a]of Object.entries(_reactNative.StyleSheet.flatten(e)??{}))(OUTER_LAYOUT_KEYS.has(s)||s.startsWith("margin")?t:i)[s]=a;return{outer:t,inner:i}},flexStyleOf=e=>void 0===e?[]:[{flex:e}],BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},CardRoot=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{children:i,variant:s,elevation:a="card",radius:r,padding:n,interactive:l=!1,pressAnimation:o="scale",bg:d,header:c,title:u,titleFont:x,lead:h,action:m,headerActions:_,collapsible:p=!1,collapsed:g,defaultCollapsed:b=!1,onCollapsedChange:j,collapsedSummary:y,onRemove:f,separatorHeight:v=_reactNative.StyleSheet.hairlineWidth,footer:R,imageSource:S,imageHeight:C=160,imageAspectRatio:w,imageOverlay:V,loading:A=!1,gradient:q,onPress:N,haptic:T,contextMenu:k,accessibilityLabel:F,accessibilityHint:O,accessibilityRole:P,flex:B,style:I,headerStyle:L,bodyStyle:M,footerStyle:H,testID:z,labels:W,onLayout:E,...U}=e;(0,_assertValidValue.assertValidValue)("Card","variant",e.variant,["elevated","outline","filled","flat"]),(0,_assertValidValue.assertValidValue)("Card","radius",e.radius,["sm","md","lg","xl","pill"]),(0,_assertValidValue.assertValidValue)("Card","padding",e.padding,["none","sm","md","lg","xl"]),(0,_assertValidValue.assertValidValue)("Card","titleFont",e.titleFont,["sans","serif"]),(0,_assertValidValue.assertValidValue)("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const D=(0,_index2.useTheme)(),G=D.settings.components.card,K=s??G?.defaultVariant??"elevated",Y=r??G?.defaultRadius??"lg",X=n??G?.defaultPadding??"md",$=x??G?.defaultTitleFont??"sans",J=(0,_index.useMobileUiText)("card",_cardG.CARD_TEXT),Q=(0,_react.useMemo)(()=>({...J,...W}),[J,W]),Z=l||"function"==typeof N,ee=(0,_useContextMenu.useContextMenu)(k,{haptic:T||!1,testID:z,accessibilityActions:U.accessibilityActions,onAccessibilityAction:U.onAccessibilityAction}),te=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,ee.hostRef),[t,ee.hostRef]),ie=Z||ee.enabled,{style:se,pressIn:ae,pressOut:re}=(0,_usePressAnimation.usePressAnimation)({preset:o||"scale",enabled:ie&&!1!==o}),ne=stylesFor(D),le=Boolean(S),oe=D.space[paddingMap[X]],de=(0,_react.useMemo)(()=>q?"string"==typeof q?D.settings.gradients[q]??null:q:null,[q,D.settings.gradients]),ce="flat"===K,ue=ce?D.radius.none:D.radius[Y],xe=resolveBackground(D,d),[he,me]=(0,_useControllableState.useControllableState)({value:g,defaultValue:b,onChange:j}),pe=p&&he,ge=hasBuiltInHeaderContent(e),be=Boolean(c)||ge,je=(0,_SquircleFill.useSquircle)(!le&&!de&&!ce,ue,E),ye=_reactNative.StyleSheet.flatten(I)??{},fe="string"==typeof ye.backgroundColor?ye.backgroundColor:void 0,ve="string"==typeof ye.borderColor?ye.borderColor:void 0,Re=fe??xe??("filled"===K?D.colors["bg-subtle"]:D.colors.surface),Se="outline"===K?D.size.border:0,Ce=ve??D.colors.border,we="none"===a?void 0:D.shadow[a],Ve="elevated"===K&&(0,_shadows.supportsBoxShadow)()&&we?(0,_shadows.toBoxShadow)(we):void 0,Ae=je.active&&"elevated"===K&&!Ve,qe=je.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,Ne=(0,_react.useMemo)(()=>{const e={borderRadius:Ae&&je.size?(0,_squircle.squircleHostRadius)(je.size.width,je.size.height,ue):ue,..._corners.smoothCorners,padding:le||je.active?D.space.none:oe,overflow:je.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:xe??D.colors.surface,borderBottomWidth:v,borderBottomColor:D.colors.border};case"outline":return{...e,backgroundColor:je.active?"transparent":xe??D.colors.surface,borderWidth:D.size.border,borderColor:je.active?"transparent":D.colors.border};case"filled":return{...e,backgroundColor:je.active?"transparent":xe??D.colors["bg-subtle"]};default:return{...e,backgroundColor:xe??D.colors.surface,...Ve?{boxShadow:Ve}:we}}},[D,K,we,ue,le,oe,je.active,je.size,Ve,Ae,xe,v]),Te=(0,_react.useMemo)(()=>({..."number"==typeof w?{width:"100%",aspectRatio:w}:{width:"100%",height:C},borderTopLeftRadius:ue,borderTopRightRadius:ue,borderBottomLeftRadius:D.radius.none,borderBottomRightRadius:D.radius.none,..._corners.smoothCorners}),[D,ue,w,C]),ke=u??"",Fe=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:ne.titleColumn,children:[u?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(D,$),children:u}):null,h?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",style:ne.lead,children:h}):null,pe&&y?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",style:ne.lead,children:y}):null]}),isCardTextAction(m)?(0,_jsxRuntime.jsx)(CardTextActionButton,{action:m,haptic:T}):m?(0,_jsxRuntime.jsx)(_reactNative.View,{style:ne.actionNode,children:m}):null,_,p?(0,_jsxRuntime.jsx)(CardIconAction,{icon:pe?"chevron-down":"chevron-up",label:`${pe?Q.show:Q.hide} ${ke}`.trim(),expanded:!pe,onPress:()=>me(!pe),haptic:T}):null,f?(0,_jsxRuntime.jsx)(CardIconAction,{icon:"trash",label:Q.remove,onPress:f,color:D.colors["danger-text"],haptic:T}):null]}),Oe=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[be?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ne.header,!c&&ne.headerRow,pe&&ne.headerFolded,L],children:c??Fe}):null,pe?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[be||R?ne.body:null,M],children:i}),R&&!pe?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ne.footer,H],children:R}):null]}),Pe=S?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:ne.imageWrapper,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:S,resizeMode:"cover",style:Te,accessibilityLabel:"",accessible:!1}),V?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:ne.imageOverlay,children:V}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{padding:oe},children:Oe})]}):Oe,Be=de?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index2.Gradient,{gradient:de,style:_reactNative.StyleSheet.absoluteFill}),Pe]}):je.active&&je.size?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:je.size.width,height:je.size.height,radius:ue,fill:Re,stroke:Se?Ce:void 0,strokeWidth:Se}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ne.squircleClip,{padding:oe,borderRadius:je.size?(0,_squircle.squircleHostRadius)(je.size.width,je.size.height,ue):ue}],children:Pe})]}):Pe,{outer:Ie,inner:Le}=splitOuterLayout(I);let Me;if(ie){const handlePress=e=>{Z&&(T&&(0,_hapticUtils.triggerHaptic)(T),N?.(e))};Me=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[se,...flexStyleOf(B),Ie],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:te,onPress:handlePress,onPressIn:ae,onPressOut:re,accessibilityRole:P??(Z?"button":void 0),accessibilityLabel:F,accessibilityHint:O,testID:z,onLayout:je.onLayout,style:[Ne,Le,qe,ne.pressFill],...U,...ee.hostProps,children:Be})})}else Me=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityLabel:F,accessibilityHint:O,accessibilityRole:P,testID:z,onLayout:je.onLayout,style:[Ne,...flexStyleOf(B),I,qe],...U,children:Be});return A?(0,_jsxRuntime.jsx)(CardSkeleton,{...e}):ee.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Me,ee.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:[Ne,I,qe,ne.preview],children:Be}))]}):Me})),CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:a,header:r,footer:n,imageSource:l,imageHeight:o=160,imageAspectRatio:d,headerStyle:c,bodyStyle:u,footerStyle:x,flex:h,style:m,labels:_,...p})=>{const g=(0,_index2.useTheme)(),b=g.settings.components.card,j=e??b?.defaultVariant??"elevated",y=i??b?.defaultRadius??"lg",f=s??b?.defaultPadding??"md",v={...(0,_index.useMobileUiText)("card",_cardG.CARD_TEXT),..._},R=paddingMap[f],S=g.space[R],C="flat"===j?g.radius.none:g.radius[y],w=void 0!==r||hasBuiltInHeaderContent(p),V=resolveBackground(g,a)??g.colors.surface,A="outline"===j?1:0,q="outline"===j?g.colors.border:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{backgroundColor:V,borderRadius:C,..._corners.smoothCorners,borderWidth:A,borderColor:q,overflow:"hidden"},...flexStyleOf(h),m],accessibilityRole:"progressbar",accessibilityLabel:v.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:"100%",height:d?void 0:o,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,w?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingBottom:g.space.sm},c],children:(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"60%",height:18})}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S},u],children:(0,_jsxRuntime.jsx)(_index3.SkeletonText,{lines:3,fontSize:g.text.base.size,lastLineWidth:"55%"})}),void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingTop:g.space.sm,flexDirection:"row"},x],children:(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton";const Card=exports.Card=Object.assign(CardRoot,{Skeleton:CardSkeleton});Card.displayName="Card";const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!_react.default.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:a,haptic:r})=>{const n=(0,_index2.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{r&&(0,_hapticUtils.triggerHaptic)(r),i()},style:iconActionStyle,children:(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:e,size:20,color:a??n.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:textActionStyle,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?(0,_index2.fontFor)(e,"semibold","display"):{fontFamily:void 0,...(0,_index2.fontFor)(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return(0,_guards.isOneOf)(BACKGROUND_TOKENS,t)?e.colors[t]:t},buildStyles=e=>_reactNative.StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{..._reactNative.StyleSheet.absoluteFill},squircleClip:{overflow:"hidden",..._corners.smoothCorners},pressFill:{flexGrow:1},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=Card;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.StatTile=exports.DEFAULT_STAT_TILE_LABELS=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Card/index.js"),_index4=require("../IconBadge/index.js"),_index5=require("../Skeleton/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_STAT_TILE_LABELS=exports.DEFAULT_STAT_TILE_LABELS=Object.freeze({trendUp:"up",trendDown:"down",trendFlat:"no change"}),isText=e=>"string"==typeof e||"number"==typeof e,TREND_ICON={up:"arrow-up",down:"arrow-down",flat:"minus"},TREND_SIGN={up:"+",down:"-",flat:""},trendToneTextKey=e=>`${e}-text`,percentText=e=>(0,_mobileCore.formatPercent)(Math.abs(e),{scale:"percent",maximumFractionDigits:1}),trendFigure=e=>"number"==typeof e.value?`${TREND_SIGN[e.direction]}${percentText(e.value)}`:e.value,trendSpoken=(e,t)=>{const i=[{up:t.trendUp,down:t.trendDown,flat:t.trendFlat}[e.direction]];return"flat"!==e.direction&&i.push("number"==typeof e.value?percentText(e.value):e.value),e.period&&i.push(e.period),i.join(" ")},StatTile=exports.StatTile=(0,_react.forwardRef)((e,t)=>{const{label:i,value:n,icon:r,iconVariant:s,tone:a="primary",caption:l,trend:o,sparkline:d,onPress:c,loading:x=!1,accessibilityLabel:u,labels:_,style:p,testID:m}=e,j=(0,_index.useTheme)();(0,_assertValidValue.assertValidValue)("StatTile","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("StatTile","trend.direction",o?.direction,["up","down","flat"]),(0,_assertValidValue.assertValidValue)("StatTile","trend.goodWhen",o?.goodWhen,["up","down"]);const T=(0,_react.useMemo)(()=>({...DEFAULT_STAT_TILE_LABELS,..._}),[_]),h=o?`, ${trendSpoken(o,T)}`:"",y=isText(i)?`${i}, `:"",v=u??(isText(n)?`${y}${n}${h}`:void 0),w=!!o&&o.direction===(o.goodWhen??"up"),f=o&&"flat"!==o.direction?w?"success":"danger":"secondary",S="secondary"===f?j.colors["text-muted"]:j.colors[trendToneTextKey(f)];return x?(0,_jsxRuntime.jsx)(_index3.Card,{ref:t,variant:"outline",style:p,testID:m,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.row,{columnGap:j.space.md}],children:[void 0===r?null:(0,_jsxRuntime.jsx)(_index5.Skeleton,{shape:"circle",width:40,height:40}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.text,children:[(0,_jsxRuntime.jsx)(_index5.Skeleton,{shape:"text",width:"50%",height:12}),(0,_jsxRuntime.jsx)(_index5.Skeleton,{shape:"text",width:"35%",height:24,style:{marginTop:j.space.xs}})]})]})}):(0,_jsxRuntime.jsx)(_index3.Card,{ref:t,variant:"outline",onPress:c,accessibilityLabel:v,style:p,testID:m,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.row,{columnGap:j.space.md}],children:[void 0===r?null:(0,_jsxRuntime.jsx)(_index4.IconBadge,{icon:r,iconVariant:s,tone:a}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.text,children:[(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:i}),isText(n)?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"h3",numberOfLines:1,children:n}):n,o?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.trend,{columnGap:j.space.xxs}],testID:m?`${m}-trend`:void 0,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:TREND_ICON[o.direction],size:"xs",color:S})}),(0,_jsxRuntime.jsxs)(_index6.Text,{variant:"caption",color:f,numberOfLines:2,style:styles.text,children:[trendFigure(o),o.period?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",color:"tertiary",children:` ${o.period}`}):null]})]}):null,null==l||""===l?null:isText(l)?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",color:"tertiary",numberOfLines:1,children:l}):l,null==d?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginTop:j.space.sm},children:d})]})]})})});StatTile.displayName="StatTile";const styles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},text:{flex:1,minWidth:0},trend:{flexDirection:"row",alignItems:"center"}});var _default=exports.default=StatTile;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.StatTile=exports.DEFAULT_STAT_TILE_LABELS=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../Card/index.js"),_index4=require("../IconBadge/index.js"),_index5=require("../Skeleton/index.js"),_index6=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_STAT_TILE_LABELS=exports.DEFAULT_STAT_TILE_LABELS=Object.freeze({trendUp:"up",trendDown:"down",trendFlat:"no change"}),isText=e=>"string"==typeof e||"number"==typeof e,TREND_ICON={up:"arrow-up",down:"arrow-down",flat:"minus"},TREND_SIGN={up:"+",down:"-",flat:""},trendToneTextKey=e=>`${e}-text`,percentText=e=>(0,_mobileCore.formatPercent)(Math.abs(e),{scale:"percent",maximumFractionDigits:1}),trendFigure=e=>"number"==typeof e.value?`${TREND_SIGN[e.direction]}${percentText(e.value)}`:e.value,trendSpoken=(e,t)=>{const i=[{up:t.trendUp,down:t.trendDown,flat:t.trendFlat}[e.direction]];return"flat"!==e.direction&&i.push("number"==typeof e.value?percentText(e.value):e.value),e.period&&i.push(e.period),i.join(" ")},StatTile=exports.StatTile=(0,_react.forwardRef)((e,t)=>{const{label:i,value:n,icon:r,iconVariant:s,tone:a="primary",caption:l,trend:o,sparkline:d,onPress:x,loading:c=!1,accessibilityLabel:u,labels:_,flex:p,style:m,testID:j}=e,T=(0,_index.useTheme)();(0,_assertValidValue.assertValidValue)("StatTile","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("StatTile","trend.direction",o?.direction,["up","down","flat"]),(0,_assertValidValue.assertValidValue)("StatTile","trend.goodWhen",o?.goodWhen,["up","down"]);const h=(0,_react.useMemo)(()=>({...DEFAULT_STAT_TILE_LABELS,..._}),[_]),y=o?`, ${trendSpoken(o,h)}`:"",v=isText(i)?`${i}, `:"",f=u??(isText(n)?`${v}${n}${y}`:void 0),w=!!o&&o.direction===(o.goodWhen??"up"),S=o&&"flat"!==o.direction?w?"success":"danger":"secondary",R="secondary"===S?T.colors["text-muted"]:T.colors[trendToneTextKey(S)];return c?(0,_jsxRuntime.jsx)(_index3.Card,{ref:t,variant:"outline",flex:p,style:m,testID:j,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.row,{columnGap:T.space.md}],children:[void 0===r?null:(0,_jsxRuntime.jsx)(_index5.Skeleton,{shape:"circle",width:40,height:40}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.text,children:[(0,_jsxRuntime.jsx)(_index5.Skeleton,{shape:"text",width:"50%",height:12}),(0,_jsxRuntime.jsx)(_index5.Skeleton,{shape:"text",width:"35%",height:24,style:{marginTop:T.space.xs}})]})]})}):(0,_jsxRuntime.jsx)(_index3.Card,{ref:t,variant:"outline",flex:p,onPress:x,accessibilityLabel:f,style:m,testID:j,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.row,{columnGap:T.space.md}],children:[void 0===r?null:(0,_jsxRuntime.jsx)(_index4.IconBadge,{icon:r,iconVariant:s,tone:a}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.text,children:[(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:i}),isText(n)?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"h3",numberOfLines:1,children:n}):n,o?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.trend,{columnGap:T.space.xxs}],testID:j?`${j}-trend`:void 0,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:TREND_ICON[o.direction],size:"xs",color:R})}),(0,_jsxRuntime.jsxs)(_index6.Text,{variant:"caption",color:S,numberOfLines:2,style:styles.text,children:[trendFigure(o),o.period?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",color:"tertiary",children:` ${o.period}`}):null]})]}):null,null==l||""===l?null:isText(l)?(0,_jsxRuntime.jsx)(_index6.Text,{variant:"caption",color:"tertiary",numberOfLines:1,children:l}):l,null==d?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginTop:T.space.sm},children:d})]})]})})});StatTile.displayName="StatTile";const styles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},text:{flex:1,minWidth:0},trend:{flexDirection:"row",alignItems:"center"}});var _default=exports.default=StatTile;
@@ -1 +1 @@
1
- "use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useNativeGesture,usePanGesture,useTapGesture}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{scheduleOnRN}from"react-native-worklets";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useMobileUiText}from"../../text/index.js";import{BOTTOM_SHEET_TEXT}from"../../text/phone/bottomSheet.g.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:r,onSnapChange:n,onAnimate:a,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:b,onContentSizeChange:p,onScrollLayout:S,scrollEventThrottle:v,keyboardBehavior:y="shift",inline:g=!1,presentation:x="sheet",animateMount:C=!0,handleIndicatorStyle:w,sheetStyle:M,header:R,actions:_,actionsLayout:T="auto",footer:k,headerStyle:O,footerStyle:E,children:I,accessibilityLabel:j,accessibilityViewIsModal:A,testID:V}=e;assertValidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),assertValidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),assertValidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const N=useMobileUiText("bottomSheet",BOTTOM_SHEET_TEXT),D=useMemo(()=>({...N,...h}),[N,h]),B=null!=R||null!=d,P=null!=_&&_.length>0,L=null!=k||P,H=g?"inline":"modal",G=useTheme(),F=usePresenceMotion(),U=useSafeAreaInsets(),[Y,$]=useState(()=>Dimensions.get("window").height),[z,K]=useState(()=>Dimensions.get("window").width),X=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&$(e=>e===t?e:t),o>0&&K(e=>e===o?e:o)},[]),W=useWindowDimensions(),q="dialog"===x||"auto"===x&&Math.min(W.width,W.height)>=600,J=Math.min(560,z-2*G.space.xl),[Q,Z]=useModalInsets(),ee="modal"===H?Q.top:U.top,te="modal"===H?Q.bottom:U.bottom,oe=t.includes("content"),[se,re]=useMeasuredHeight(),[ne,ae]=useMeasuredHeight(),[le,ie,ue]=useMeasuredHeight(),[ce,de]=useMeasuredHeight(),he=q?G.space.md:se,me=oe?Math.min(he+(B?ne:0)+le+(L?ce:0)+te,Y-ee):0,fe=useCallback((e,t)=>{oe&&ue(t),p?.(e,t)},[oe,p,ue]),be=useMemo(()=>resolveSnapPoints(t,Y,me),[t,Y,me]),pe=Y,Se=be[be.length-1]??0,ve=useSharedValue(pe),ye=useSharedValue(pe),ge=useSharedValue(1),xe=useSharedValue(-1),[Ce,we]=useState(-1),[Me,Re]=useState(!1),[Te,ke]=useState(!1),Oe=useRef(!1),Ee=useRef(l);Ee.current=l;const[Ie,je]=useState(!1),Ae=useRef(!C&&o),Ve=useRef(-1),Ne=useRef(!1);Ne.current="modal"===H?Te:Ie;const De=useRef(c);De.current=c;const Be=useRef(s);Be.current=s;const Pe=useRef(!1),Le=useRef(!0),He=useRef([]),Ge=useCallback(e=>{const t=He.current;He.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Le.current=!0,()=>{Le.current=!1,Ge(!1)}),[Ge]);const Fe=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 q?(Y-t)/2:Y-t},[be,Y,pe,q]),Ue=useCallback(e=>{Ve.current=e;Ce!==e&&(we(e),xe.value=e,e>=0&&n?.(e))},[Ce,xe,n]),Ye=useCallback(()=>{xe.value<0&&(Oe.current=!0,"modal"===H?(Re(!1),"ios"!==Platform.OS&&ke(!1)):je(!1))},[H,xe]),$e=useCallback(()=>{Oe.current&&ke(!1)},[]);useEffect(()=>{("modal"===H?!Te:!Ie)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[H,Te,Ie,Ge]);const ze=useCallback((e,t,o)=>{a?.(t,o),ve.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&scheduleOnRN(Ye)})},[a,ve,Ye]),Ke=useRef(null),Xe=useCallback(e=>{const t="number"==typeof e?clamp(e,0,be.length-1):Math.max(Ce,0),o=xe.value,s=Fe(t);return Oe.current=!1,Ge(!1),"modal"===H?(ke(!0),Re(!0)):je(!0),o<0&&Ae.current?(ve.value=s,ge.value=1,Ue(t),void a?.(o,t)):o<0&&F.reduced?(ve.value=s,ge.value=0,ge.value=withTiming(1,{duration:F.duration("fast"),easing:Easing.bezier(...G.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ue(t),void a?.(o,t)):(o<0&&(ve.value=pe,ge.value=1),Ue(t),void(o<0&&t>=0&&!Ne.current?Ke.current={fromIndex:o,target:t}:ze(s,o,t)))},[ze,pe,Ce,xe,H,a,F,ge,be.length,Ue,Ge,G.motion.ease.decelerate,ve,Fe]),We=useCallback(()=>new Promise(e=>{if(Ve.current<0)return void(Ne.current?He.current.push(e):e(!0));He.current.push(e),Ae.current=!1,Ke.current=null;const t=xe.value;Ue(-1),a?.(t,-1);const o=F.reduced?ge:ve,s=F.reduced?0:pe;o.value=withTiming(s,{duration:F.duration("fast"),easing:Easing.bezier(...G.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&scheduleOnRN(Ye)})}),[pe,xe,Ye,a,F,ge,Ue,ve,G.motion.ease.accelerate]),qe=useCallback((e,t,o)=>{const s=De.current;if(!s)return void e();if(Pe.current)return void t?.();const r=s();"boolean"!=typeof r?(Pe.current=!0,o?.(),r.then(o=>{Pe.current=!1,o&&Le.current&&Ve.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(r?e:t)?.()},[]),Je=useCallback(()=>new Promise(e=>{Ve.current<0?e(!0):qe(()=>{Be.current(),We(),e(!0)},()=>e(!1))}),[We,qe]),Qe=useCallback(()=>{Be.current()},[]),Ze=useCallback(()=>{u&&Je()},[u,Je]),et=useRef(null),tt=useRef(Xe);tt.current=Xe;const ot=useRef(We);ot.current=We,useEffect(()=>{const e=et.current!==o;et.current=o,e?o?tt.current(r??0):ot.current():o&&"number"==typeof r&&r!==xe.value&&tt.current(r)},[o,r,xe]);const st=useRef({hostHeight:Y,contentSnap:me}),rt=useRef(Fe);rt.current=Fe,useEffect(()=>{const e=st.current;if(e.hostHeight===Y&&e.contentSnap===me)return;if(st.current={hostHeight:Y,contentSnap:me},e.hostHeight===Y&&xe.value<0)return;const t=rt.current(xe.value);ve.value=Ae.current?t:withSpring(t,SPRING_CONFIG)},[Y,me,xe,ve]);const nt="modal"===H?Te:Ie;useEffect(()=>{const e=Ke.current;null!==e&&nt&&(Ke.current=null,Ve.current===e.target&&ze(rt.current(e.target),e.fromIndex,e.target))},[nt,ze]);const at=Y-Se,lt=useMemo(()=>be.map(e=>Y-e),[be,Y]),it=useCallback(()=>{const e=Ve.current;e<0||ze(Fe(e),e,e)},[ze,Fe]),ut=useCallback((e,t)=>{const o=xe.value;-1!==e?(Ue(e),ze(t,o,e)):qe(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Be.current(),We()},it,it)},[ze,We,xe,qe,Ue,it]),ct=useMemo(()=>({testID:V?`${V}-content-gesture`:"bottom-sheet-content-gesture"}),[V]),dt=useNativeGesture(ct),ht=useMemo(()=>{const e=lt,t=pe,o=at,s=i;return{testID:V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";ye.value=ve.value},onUpdate:e=>{"worklet";const t=ye.value+e.translationY;ve.value=t<o?o+.25*(t-o):t},onDeactivate:o=>{"worklet";const r=ve.value,n=o.velocityY,[a]=e;if(void 0===a)return void scheduleOnRN(ut,-1,t);if(n>1e3)return s?void scheduleOnRN(ut,-1,t):void scheduleOnRN(ut,0,a);let l=0,i=a,u=1/0,c=0;for(const t of e){const e=Math.abs(r-t);e<u&&(u=e,i=t,l=c),c++}s&&r-a>80?scheduleOnRN(ut,-1,t):scheduleOnRN(ut,l,i)}}},[pe,ye,i,ut,at,lt,V,ve]),mt=usePanGesture(ht),{height:ft}=useReanimatedKeyboardAnimation(),bt="shift"===y,pt=useDerivedValue(()=>bt?ft.value:0,[bt,ft]),St=be[Math.max(Ce,0)]??Se,vt=G.space.md,yt=useAnimatedStyle(()=>{if(q){const e=pt.value,t=Y+e-St-vt,o=e<0&&ve.value>t?t:ve.value;return{top:Math.max(o,ee),opacity:ge.value}}const e=ve.value+pt.value,t=pt.value<0?ee:at;return{top:Math.max(e,t),opacity:ge.value}},[q,pt,Y,St,vt,ve,ee,ge,at]),gt=useAnimatedStyle(()=>{const e=pt.value;if(q){const t=Y+e-St-vt,o=e<0&&ve.value>t?t:ve.value,s=Math.max(o,ee),r=Y+e-vt-s;return{height:r<0?0:Math.min(r,St)}}const t=e<0?ee:at,o=ve.value+e,s=Math.max(o,t),r=Y+e-s;return{height:r<0?0:Math.min(r,Se)}},[pt,q,Y,St,vt,ve,ee,at,Se]),xt=Ce>=0,Ct=useMemo(()=>buildStyles(G),[G]),wt=useCallback(()=>{u&&qe(()=>{triggerHaptic("selection"),Be.current(),We()})},[u,We,qe]),Mt=useMemo(()=>({testID:V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||scheduleOnRN(wt)}}),[wt,V]),Rt=useTapGesture(Mt),_t=useMemo(()=>({snapIndex:Ce,snapPoints:be,close:Qe,requestClose:Je}),[Ce,be,Qe,Je]);if("inline"===H&&!Ie)return null;if("modal"===H&&!Te)return null;const Tt=_jsxs(View,{collapsable:!1,style:["modal"===H?Ct.backdropModal:Ct.backdropInline,{backgroundColor:"modal"===H?transparentOf(G.colors.scrim):G.colors.scrim}],onLayout:X,testID:V,accessibilityViewIsModal:A??xt,children:[_jsx(GestureDetector,{gesture:Rt,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:D.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:j,accessibilityViewIsModal:A??xt,accessibilityActions:[{name:"escape",label:D.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Ze()},onAccessibilityEscape:Ze,style:[Ct.sheet,{height:Se,backgroundColor:G.colors.surface,borderTopLeftRadius:G.radius.xl,borderTopRightRadius:G.radius.xl,...smoothCorners,...G.shadow.modal},q?{height:St,left:(z-J)/2,right:void 0,width:J,borderBottomLeftRadius:G.radius.xl,borderBottomRightRadius:G.radius.xl}:null,M,yt],children:_jsxs(SheetBody,{style:[Ct.body,gt],keyboardOffset:pt,children:[q?_jsx(View,{style:{height:G.space.md}}):_jsx(GestureDetector,{gesture:mt,children:_jsx(View,{style:Ct.handleRow,onLayout:oe?re:void 0,accessible:!0,accessibilityLabel:D.dragHandle,accessibilityHint:D.dragHandleHintText,testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[Ct.handle,{backgroundColor:G.colors.border},w]})})}),B&&_jsxs(View,{style:[Ct.header,O],onLayout:oe?ae:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,R]}),m?_jsx(GestureDetector,{gesture:dt,children:_jsx(ScrollView,{ref:f,testID:V?`${V}-scroll`:void 0,style:Ct.scrollContent,onScroll:b,onContentSizeChange:fe,onLayout:S,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:I})}):_jsx(View,{style:oe?[Ct.content,{overflow:"visible"}]:Ct.content,children:oe?_jsx(View,{onLayout:ie,children:I}):I}),L&&_jsxs(View,{style:[Ct.footer,E],onLayout:oe?de:void 0,children:[P?_jsx(View,{style:Ct.actions,children:_jsx(OverlayActions,{actions:_??[],layout:T})}):null,k]})]})})]}),kt=_jsx(BottomSheetContext.Provider,{value:_t,children:Tt});return"modal"===H?_jsx(Modal,{open:Me,onClose:Ze,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Z,onDismissed:"ios"===Platform.OS?$e:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:Ct.modalRoot,children:kt}):kt}):kt},SheetBody=({style:e,keyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,r=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:Math.max(e,0)}},[s,t]);return _jsx(Animated.View,{style:[e,r],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
1
+ "use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useNativeGesture,usePanGesture,useTapGesture}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,useAnimatedReaction,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{scheduleOnRN}from"react-native-worklets";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useMobileUiText}from"../../text/index.js";import{BOTTOM_SHEET_TEXT}from"../../text/phone/bottomSheet.g.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:r,onSnapChange:a,onAnimate:n,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:b,onContentSizeChange:p,onScrollLayout:S,scrollEventThrottle:v,keyboardBehavior:y="shift",inline:g=!1,presentation:x="sheet",animateMount:C=!0,handleIndicatorStyle:w,sheetStyle:M,header:R,actions:_,actionsLayout:T="auto",footer:O,headerStyle:k,footerStyle:E,children:I,accessibilityLabel:A,accessibilityViewIsModal:j,testID:V}=e;assertValidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),assertValidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),assertValidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const N=useMobileUiText("bottomSheet",BOTTOM_SHEET_TEXT),D=useMemo(()=>({...N,...h}),[N,h]),B=null!=R||null!=d,P=null!=_&&_.length>0,L=null!=O||P,H=g?"inline":"modal",G=useTheme(),F=usePresenceMotion(),U=useSafeAreaInsets(),[Y,K]=useState(()=>Dimensions.get("window").height),[$,z]=useState(()=>Dimensions.get("window").width),X=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&K(e=>e===t?e:t),o>0&&z(e=>e===o?e:o)},[]),W=useWindowDimensions(),q="dialog"===x||"auto"===x&&Math.min(W.width,W.height)>=600,J=Math.min(560,$-2*G.space.xl),[Q,Z]=useModalInsets(),ee="modal"===H?Q.top:U.top,te="modal"===H?Q.bottom:U.bottom,oe=t.includes("content"),[se,re]=useMeasuredHeight(),[ae,ne]=useMeasuredHeight(),[le,ie,ue]=useMeasuredHeight(),[ce,de]=useMeasuredHeight(),he=q?G.space.md:se,me=oe?Math.min(he+(B?ae:0)+le+(L?ce:0)+te,Y-ee):0,fe=useCallback((e,t)=>{oe&&ue(t),p?.(e,t)},[oe,p,ue]),be=useMemo(()=>resolveSnapPoints(t,Y,me),[t,Y,me]),pe=Y,Se=be[be.length-1]??0,ve=useSharedValue(pe),ye=useSharedValue(pe),ge=useSharedValue(1),xe=useSharedValue(-1),[Ce,we]=useState(-1),[Me,Re]=useState(!1),[Te,Oe]=useState(!1),ke=useRef(!1),Ee=useRef(l);Ee.current=l;const[Ie,Ae]=useState(!1),je=useRef(!C&&o),Ve=useRef(-1),Ne=useRef(!1);Ne.current="modal"===H?Te:Ie;const De=useRef(c);De.current=c;const Be=useRef(s);Be.current=s;const Pe=useRef(!1),Le=useRef(!0),He=useRef([]),Ge=useCallback(e=>{const t=He.current;He.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Le.current=!0,()=>{Le.current=!1,Ge(!1)}),[Ge]);const Fe=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 q?(Y-t)/2:Y-t},[be,Y,pe,q]),Ue=useCallback(e=>{Ve.current=e;Ce!==e&&(we(e),xe.value=e,e>=0&&a?.(e))},[Ce,xe,a]),Ye=useCallback(()=>{xe.value<0&&(ke.current=!0,"modal"===H?(Re(!1),"ios"!==Platform.OS&&Oe(!1)):Ae(!1))},[H,xe]),Ke=useCallback(()=>{ke.current&&Oe(!1)},[]);useEffect(()=>{("modal"===H?!Te:!Ie)&&ke.current&&(ke.current=!1,Ee.current?.(),Ge(!0))},[H,Te,Ie,Ge]);const $e=useCallback((e,t,o)=>{n?.(t,o),ve.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&scheduleOnRN(Ye)})},[n,ve,Ye]),ze=useRef(null),Xe=useCallback(e=>{const t="number"==typeof e?clamp(e,0,be.length-1):Math.max(Ce,0),o=xe.value,s=Fe(t);return ke.current=!1,Ge(!1),"modal"===H?(Oe(!0),Re(!0)):Ae(!0),o<0&&je.current?(ve.value=s,ge.value=1,Ue(t),void n?.(o,t)):o<0&&F.reduced?(ve.value=s,ge.value=0,ge.value=withTiming(1,{duration:F.duration("fast"),easing:Easing.bezier(...G.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ue(t),void n?.(o,t)):(o<0&&(ve.value=pe,ge.value=1),Ue(t),void(o<0&&t>=0&&!Ne.current?ze.current={fromIndex:o,target:t}:$e(s,o,t)))},[$e,pe,Ce,xe,H,n,F,ge,be.length,Ue,Ge,G.motion.ease.decelerate,ve,Fe]),We=useCallback(()=>new Promise(e=>{if(Ve.current<0)return void(Ne.current?He.current.push(e):e(!0));He.current.push(e),je.current=!1,ze.current=null;const t=xe.value;Ue(-1),n?.(t,-1);const o=F.reduced?ge:ve,s=F.reduced?0:pe;o.value=withTiming(s,{duration:F.duration("fast"),easing:Easing.bezier(...G.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&scheduleOnRN(Ye)})}),[pe,xe,Ye,n,F,ge,Ue,ve,G.motion.ease.accelerate]),qe=useCallback((e,t,o)=>{const s=De.current;if(!s)return void e();if(Pe.current)return void t?.();const r=s();"boolean"!=typeof r?(Pe.current=!0,o?.(),r.then(o=>{Pe.current=!1,o&&Le.current&&Ve.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(r?e:t)?.()},[]),Je=useCallback(()=>new Promise(e=>{Ve.current<0?e(!0):qe(()=>{Be.current(),We(),e(!0)},()=>e(!1))}),[We,qe]),Qe=useCallback(()=>{Be.current()},[]),Ze=useCallback(()=>{u&&Je()},[u,Je]),et=useRef(null),tt=useRef(Xe);tt.current=Xe;const ot=useRef(We);ot.current=We,useEffect(()=>{const e=et.current!==o;et.current=o,e?o?tt.current(r??0):ot.current():o&&"number"==typeof r&&r!==xe.value&&tt.current(r)},[o,r,xe]);const st=useRef({hostHeight:Y,contentSnap:me}),rt=useRef(Fe);rt.current=Fe,useEffect(()=>{const e=st.current;if(e.hostHeight===Y&&e.contentSnap===me)return;if(st.current={hostHeight:Y,contentSnap:me},e.hostHeight===Y&&xe.value<0)return;const t=rt.current(xe.value);ve.value=je.current?t:withSpring(t,SPRING_CONFIG)},[Y,me,xe,ve]);const at="modal"===H?Te:Ie;useEffect(()=>{const e=ze.current;null!==e&&at&&(ze.current=null,Ve.current===e.target&&$e(rt.current(e.target),e.fromIndex,e.target))},[at,$e]);const nt=Y-Se,lt=useMemo(()=>be.map(e=>Y-e),[be,Y]),it=useCallback(()=>{const e=Ve.current;e<0||$e(Fe(e),e,e)},[$e,Fe]),ut=useCallback((e,t)=>{const o=xe.value;-1!==e?(Ue(e),$e(t,o,e)):qe(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Be.current(),We()},it,it)},[$e,We,xe,qe,Ue,it]),ct=useMemo(()=>({testID:V?`${V}-content-gesture`:"bottom-sheet-content-gesture"}),[V]),dt=useNativeGesture(ct),ht=useMemo(()=>{const e=lt,t=pe,o=nt,s=i;return{testID:V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";ye.value=ve.value},onUpdate:e=>{"worklet";const t=ye.value+e.translationY;ve.value=t<o?o+.25*(t-o):t},onDeactivate:o=>{"worklet";const r=ve.value,a=o.velocityY,[n]=e;if(void 0===n)return void scheduleOnRN(ut,-1,t);if(a>1e3)return s?void scheduleOnRN(ut,-1,t):void scheduleOnRN(ut,0,n);let l=0,i=n,u=1/0,c=0;for(const t of e){const e=Math.abs(r-t);e<u&&(u=e,i=t,l=c),c++}s&&r-n>80?scheduleOnRN(ut,-1,t):scheduleOnRN(ut,l,i)}}},[pe,ye,i,ut,nt,lt,V,ve]),mt=usePanGesture(ht),{height:ft,progress:bt}=useReanimatedKeyboardAnimation(),pt="shift"===y,St=useDerivedValue(()=>pt?ft.value:0,[pt,ft]),vt=useSharedValue(0);useAnimatedReaction(()=>pt&&bt.value>=1?ft.value:0,e=>{vt.value=e},[pt,ft,bt,vt]);const yt=be[Math.max(Ce,0)]??Se,gt=G.space.md,xt=useAnimatedStyle(()=>{const e=St.value;if(q){const t=Y+e-yt-gt,o=e<0&&ve.value>t?t:ve.value;return{top:ve.value,transform:[{translateY:Math.max(o,ee)-ve.value}],opacity:ge.value}}const t=e<0?ee:nt,o=Math.max(ve.value+e,t);return{top:ve.value,transform:[{translateY:o-ve.value}],opacity:ge.value}},[q,St,Y,yt,gt,ve,ee,ge,nt]),Ct=useAnimatedStyle(()=>{const e=vt.value;if(q){const t=Y+e-yt-gt,o=e<0&&ve.value>t?t:ve.value,s=Math.max(o,ee),r=Y+e-gt-s;return{height:r<0?0:Math.min(r,yt)}}const t=e<0?ee:nt,o=ve.value+e,s=Math.max(o,t),r=Y+e-s;return{height:r<0?0:Math.min(r,Se)}},[vt,q,Y,yt,gt,ve,ee,nt,Se]),wt=Ce>=0,Mt=useMemo(()=>buildStyles(G),[G]),Rt=useCallback(()=>{u&&qe(()=>{triggerHaptic("selection"),Be.current(),We()})},[u,We,qe]),_t=useMemo(()=>({testID:V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||scheduleOnRN(Rt)}}),[Rt,V]),Tt=useTapGesture(_t),Ot=useMemo(()=>({snapIndex:Ce,snapPoints:be,close:Qe,requestClose:Je}),[Ce,be,Qe,Je]);if("inline"===H&&!Ie)return null;if("modal"===H&&!Te)return null;const kt=_jsxs(View,{collapsable:!1,style:["modal"===H?Mt.backdropModal:Mt.backdropInline,{backgroundColor:"modal"===H?transparentOf(G.colors.scrim):G.colors.scrim}],onLayout:X,testID:V,accessibilityViewIsModal:j??wt,children:[_jsx(GestureDetector,{gesture:Tt,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:D.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:A,accessibilityViewIsModal:j??wt,accessibilityActions:[{name:"escape",label:D.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Ze()},onAccessibilityEscape:Ze,style:[Mt.sheet,{height:Se,backgroundColor:G.colors.surface,borderTopLeftRadius:G.radius.xl,borderTopRightRadius:G.radius.xl,...smoothCorners,...G.shadow.modal},q?{height:yt,left:($-J)/2,right:void 0,width:J,borderBottomLeftRadius:G.radius.xl,borderBottomRightRadius:G.radius.xl}:null,M,xt],children:_jsxs(SheetBody,{style:[Mt.body,Ct],settledKeyboardOffset:vt,children:[q?_jsx(View,{style:{height:G.space.md}}):_jsx(GestureDetector,{gesture:mt,children:_jsx(View,{style:Mt.handleRow,onLayout:oe?re:void 0,accessible:!0,accessibilityLabel:D.dragHandle,accessibilityHint:D.dragHandleHintText,testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[Mt.handle,{backgroundColor:G.colors.border},w]})})}),B&&_jsxs(View,{style:[Mt.header,k],onLayout:oe?ne:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,R]}),m?_jsx(GestureDetector,{gesture:dt,children:_jsx(ScrollView,{ref:f,testID:V?`${V}-scroll`:void 0,style:Mt.scrollContent,onScroll:b,onContentSizeChange:fe,onLayout:S,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:I})}):_jsx(View,{style:oe?[Mt.content,{overflow:"visible"}]:Mt.content,children:oe?_jsx(View,{onLayout:ie,children:I}):I}),L&&_jsxs(View,{style:[Mt.footer,E],onLayout:oe?de:void 0,children:[P?_jsx(View,{style:Mt.actions,children:_jsx(OverlayActions,{actions:_??[],layout:T})}):null,O]})]})})]}),Et=_jsx(BottomSheetContext.Provider,{value:Ot,children:kt});return"modal"===H?_jsx(Modal,{open:Me,onClose:Ze,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Z,onDismissed:"ios"===Platform.OS?Ke:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:Mt.modalRoot,children:Et}):Et}):Et},SheetBody=({style:e,settledKeyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,r=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:Math.max(e,0)}},[s,t]);return _jsx(Animated.View,{style:[e,r],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{backgroundColor:e.colors.surface},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
@@ -1 +1 @@
1
- "use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{useMobileUiText}from"../../text/index.js";import{CARD_TEXT}from"../../text/phone/card.g.js";import{fontFor,Gradient,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{isOneOf}from"../../utils/guards.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{squircleHostRadius}from"../../utils/squircle.js";import{themeStyles}from"../../utils/themeStyles.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const OUTER_LAYOUT_KEYS=new Set(["flex","flexGrow","flexShrink","flexBasis","alignSelf","width","height","minWidth","maxWidth","minHeight","maxHeight","position","top","right","bottom","left","start","end","zIndex"]),splitOuterLayout=e=>{const t={},i={};for(const[s,o]of Object.entries(StyleSheet.flatten(e)??{}))(OUTER_LAYOUT_KEYS.has(s)||s.startsWith("margin")?t:i)[s]=o;return{outer:t,inner:i}},BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},CardRoot=React.memo(forwardRef((e,t)=>{const{children:i,variant:s,elevation:o="card",radius:r,padding:a,interactive:l=!1,pressAnimation:n="scale",bg:d,header:c,title:u,titleFont:m,lead:h,action:p,headerActions:g,collapsible:b=!1,collapsed:f,defaultCollapsed:y=!1,onCollapsedChange:x,collapsedSummary:S,onRemove:j,separatorHeight:C=StyleSheet.hairlineWidth,footer:v,imageSource:_,imageHeight:w=160,imageAspectRatio:R,imageOverlay:A,loading:T=!1,gradient:V,onPress:F,haptic:k,contextMenu:B,accessibilityLabel:I,accessibilityHint:H,accessibilityRole:L,style:O,headerStyle:P,bodyStyle:z,footerStyle:M,testID:E,labels:q,onLayout:W,...D}=e;assertValidValue("Card","variant",e.variant,["elevated","outline","filled","flat"]),assertValidValue("Card","radius",e.radius,["sm","md","lg","xl","pill"]),assertValidValue("Card","padding",e.padding,["none","sm","md","lg","xl"]),assertValidValue("Card","titleFont",e.titleFont,["sans","serif"]),assertValidValue("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const U=useTheme(),N=U.settings.components.card,G=s??N?.defaultVariant??"elevated",K=r??N?.defaultRadius??"lg",Y=a??N?.defaultPadding??"md",X=m??N?.defaultTitleFont??"sans",$=useMobileUiText("card",CARD_TEXT),J=useMemo(()=>({...$,...q}),[$,q]),Q=l||"function"==typeof F,Z=useContextMenu(B,{haptic:k||!1,testID:E,accessibilityActions:D.accessibilityActions,onAccessibilityAction:D.onAccessibilityAction}),ee=useMemo(()=>mergeRefs(t,Z.hostRef),[t,Z.hostRef]),te=Q||Z.enabled,{style:ie,pressIn:se,pressOut:oe}=usePressAnimation({preset:n||"scale",enabled:te&&!1!==n}),re=stylesFor(U),ae=Boolean(_),le=U.space[paddingMap[Y]],ne=useMemo(()=>V?"string"==typeof V?U.settings.gradients[V]??null:V:null,[V,U.settings.gradients]),de="flat"===G,ce=de?U.radius.none:U.radius[K],ue=resolveBackground(U,d),[me,he]=useControllableState({value:f,defaultValue:y,onChange:x}),pe=b&&me,ge=hasBuiltInHeaderContent(e),be=Boolean(c)||ge,fe=useSquircle(!ae&&!ne&&!de,ce,W),ye=StyleSheet.flatten(O)??{},xe="string"==typeof ye.backgroundColor?ye.backgroundColor:void 0,Se="string"==typeof ye.borderColor?ye.borderColor:void 0,je=xe??ue??("filled"===G?U.colors["bg-subtle"]:U.colors.surface),Ce="outline"===G?U.size.border:0,ve=Se??U.colors.border,we="none"===o?void 0:U.shadow[o],Re="elevated"===G&&supportsBoxShadow()&&we?toBoxShadow(we):void 0,Ae=fe.active&&"elevated"===G&&!Re,Te=fe.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,Ve=useMemo(()=>{const e={borderRadius:Ae&&fe.size?squircleHostRadius(fe.size.width,fe.size.height,ce):ce,...smoothCorners,padding:ae||fe.active?U.space.none:le,overflow:fe.active?"visible":"hidden"};switch(G){case"flat":return{...e,backgroundColor:ue??U.colors.surface,borderBottomWidth:C,borderBottomColor:U.colors.border};case"outline":return{...e,backgroundColor:fe.active?"transparent":ue??U.colors.surface,borderWidth:U.size.border,borderColor:fe.active?"transparent":U.colors.border};case"filled":return{...e,backgroundColor:fe.active?"transparent":ue??U.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??U.colors.surface,...Re?{boxShadow:Re}:we}}},[U,G,we,ce,ae,le,fe.active,fe.size,Re,Ae,ue,C]),Fe=useMemo(()=>({..."number"==typeof R?{width:"100%",aspectRatio:R}:{width:"100%",height:w},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:U.radius.none,borderBottomRightRadius:U.radius.none,...smoothCorners}),[U,ce,R,w]),ke=u??"",Be=_jsxs(_Fragment,{children:[_jsxs(View,{style:re.titleColumn,children:[u?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(U,X),children:u}):null,h?_jsx(Text,{variant:"bodySmall",style:re.lead,children:h}):null,pe&&S?_jsx(Text,{variant:"caption",style:re.lead,children:S}):null]}),isCardTextAction(p)?_jsx(CardTextActionButton,{action:p,haptic:k}):p?_jsx(View,{style:re.actionNode,children:p}):null,g,b?_jsx(CardIconAction,{icon:pe?"chevron-down":"chevron-up",label:`${pe?J.show:J.hide} ${ke}`.trim(),expanded:!pe,onPress:()=>he(!pe),haptic:k}):null,j?_jsx(CardIconAction,{icon:"trash",label:J.remove,onPress:j,color:U.colors["danger-text"],haptic:k}):null]}),Ie=_jsxs(_Fragment,{children:[be?_jsx(View,{style:[re.header,!c&&re.headerRow,pe&&re.headerFolded,P],children:c??Be}):null,pe?null:_jsx(View,{style:[be||v?re.body:null,z],children:i}),v&&!pe?_jsx(View,{style:[re.footer,M],children:v}):null]}),He=_?_jsxs(_Fragment,{children:[_jsxs(View,{style:re.imageWrapper,children:[_jsx(Image,{source:_,resizeMode:"cover",style:Fe,accessibilityLabel:"",accessible:!1}),A?_jsx(View,{pointerEvents:"box-none",style:re.imageOverlay,children:A}):null]}),_jsx(View,{style:{padding:le},children:Ie})]}):Ie,Le=ne?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:ne,style:StyleSheet.absoluteFill}),He]}):fe.active&&fe.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:fe.size.width,height:fe.size.height,radius:ce,fill:je,stroke:Ce?ve:void 0,strokeWidth:Ce}),_jsx(View,{style:[re.squircleClip,{padding:le,borderRadius:fe.size?squircleHostRadius(fe.size.width,fe.size.height,ce):ce}],children:He})]}):He,{outer:Oe,inner:Pe}=splitOuterLayout(O);let ze;if(te){const handlePress=e=>{Q&&(k&&triggerHaptic(k),F?.(e))};ze=_jsx(Animated.View,{style:[ie,Oe],children:_jsx(Pressable,{ref:ee,onPress:handlePress,onPressIn:se,onPressOut:oe,accessibilityRole:L??(Q?"button":void 0),accessibilityLabel:I,accessibilityHint:H,testID:E,onLayout:fe.onLayout,style:[Ve,Pe,Te,re.pressFill],...D,...Z.hostProps,children:Le})})}else ze=_jsx(View,{ref:t,accessibilityLabel:I,accessibilityHint:H,accessibilityRole:L,testID:E,onLayout:fe.onLayout,style:[Ve,O,Te],...D,children:Le});return T?_jsx(CardSkeleton,{...e}):Z.enabled?_jsxs(_Fragment,{children:[ze,Z.renderSurface(_jsx(View,{style:[Ve,O,Te,re.preview],children:Le}))]}):ze})),CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:o,header:r,footer:a,imageSource:l,imageHeight:n=160,imageAspectRatio:d,headerStyle:c,bodyStyle:u,footerStyle:m,style:h,labels:p,...g})=>{const b=useTheme(),f=b.settings.components.card,y=e??f?.defaultVariant??"elevated",x=i??f?.defaultRadius??"lg",S=s??f?.defaultPadding??"md",j={...useMobileUiText("card",CARD_TEXT),...p},C=paddingMap[S],v=b.space[C],_="flat"===y?b.radius.none:b.radius[x],w=void 0!==r||hasBuiltInHeaderContent(g),R=resolveBackground(b,o)??b.colors.surface,A="outline"===y?1:0,T="outline"===y?b.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:R,borderRadius:_,...smoothCorners,borderWidth:A,borderColor:T,overflow:"hidden"},h],accessibilityRole:"progressbar",accessibilityLabel:j.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,w?_jsx(View,{style:[{padding:v,paddingBottom:b.space.sm},c],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:v},u],children:_jsx(SkeletonText,{lines:3,fontSize:b.text.base.size,lastLineWidth:"55%"})}),void 0!==a?_jsx(View,{style:[{padding:v,paddingTop:b.space.sm,flexDirection:"row"},m],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton";const Card=Object.assign(CardRoot,{Skeleton:CardSkeleton});Card.displayName="Card";const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:o,haptic:r})=>{const a=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{r&&triggerHaptic(r),i()},style:iconActionStyle,children:_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:_jsx(AppIcon,{name:e,size:20,color:o??a.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&triggerHaptic(t),e.onPress()},style:textActionStyle,children:_jsx(Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?fontFor(e,"semibold","display"):{fontFamily:void 0,...fontFor(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return isOneOf(BACKGROUND_TOKENS,t)?e.colors[t]:t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},squircleClip:{overflow:"hidden",...smoothCorners},pressFill:{flexGrow:1},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=themeStyles(buildStyles);export{Card};export default Card;
1
+ "use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{useMobileUiText}from"../../text/index.js";import{CARD_TEXT}from"../../text/phone/card.g.js";import{fontFor,Gradient,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{isOneOf}from"../../utils/guards.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{squircleHostRadius}from"../../utils/squircle.js";import{themeStyles}from"../../utils/themeStyles.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const OUTER_LAYOUT_KEYS=new Set(["flex","flexGrow","flexShrink","flexBasis","alignSelf","width","height","minWidth","maxWidth","minHeight","maxHeight","position","top","right","bottom","left","start","end","zIndex"]),splitOuterLayout=e=>{const t={},i={};for(const[s,o]of Object.entries(StyleSheet.flatten(e)??{}))(OUTER_LAYOUT_KEYS.has(s)||s.startsWith("margin")?t:i)[s]=o;return{outer:t,inner:i}},flexStyleOf=e=>void 0===e?[]:[{flex:e}],BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},CardRoot=React.memo(forwardRef((e,t)=>{const{children:i,variant:s,elevation:o="card",radius:r,padding:l,interactive:a=!1,pressAnimation:n="scale",bg:d,header:c,title:u,titleFont:m,lead:h,action:p,headerActions:g,collapsible:b=!1,collapsed:f,defaultCollapsed:x=!1,onCollapsedChange:y,collapsedSummary:S,onRemove:j,separatorHeight:C=StyleSheet.hairlineWidth,footer:v,imageSource:_,imageHeight:w=160,imageAspectRatio:R,imageOverlay:A,loading:T=!1,gradient:V,onPress:F,haptic:k,contextMenu:B,accessibilityLabel:O,accessibilityHint:I,accessibilityRole:H,flex:L,style:P,headerStyle:z,bodyStyle:M,footerStyle:E,testID:q,labels:W,onLayout:D,...U}=e;assertValidValue("Card","variant",e.variant,["elevated","outline","filled","flat"]),assertValidValue("Card","radius",e.radius,["sm","md","lg","xl","pill"]),assertValidValue("Card","padding",e.padding,["none","sm","md","lg","xl"]),assertValidValue("Card","titleFont",e.titleFont,["sans","serif"]),assertValidValue("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const N=useTheme(),G=N.settings.components.card,K=s??G?.defaultVariant??"elevated",Y=r??G?.defaultRadius??"lg",X=l??G?.defaultPadding??"md",$=m??G?.defaultTitleFont??"sans",J=useMobileUiText("card",CARD_TEXT),Q=useMemo(()=>({...J,...W}),[J,W]),Z=a||"function"==typeof F,ee=useContextMenu(B,{haptic:k||!1,testID:q,accessibilityActions:U.accessibilityActions,onAccessibilityAction:U.onAccessibilityAction}),te=useMemo(()=>mergeRefs(t,ee.hostRef),[t,ee.hostRef]),ie=Z||ee.enabled,{style:se,pressIn:oe,pressOut:re}=usePressAnimation({preset:n||"scale",enabled:ie&&!1!==n}),le=stylesFor(N),ae=Boolean(_),ne=N.space[paddingMap[X]],de=useMemo(()=>V?"string"==typeof V?N.settings.gradients[V]??null:V:null,[V,N.settings.gradients]),ce="flat"===K,ue=ce?N.radius.none:N.radius[Y],me=resolveBackground(N,d),[he,pe]=useControllableState({value:f,defaultValue:x,onChange:y}),ge=b&&he,be=hasBuiltInHeaderContent(e),fe=Boolean(c)||be,xe=useSquircle(!ae&&!de&&!ce,ue,D),ye=StyleSheet.flatten(P)??{},Se="string"==typeof ye.backgroundColor?ye.backgroundColor:void 0,je="string"==typeof ye.borderColor?ye.borderColor:void 0,Ce=Se??me??("filled"===K?N.colors["bg-subtle"]:N.colors.surface),ve="outline"===K?N.size.border:0,we=je??N.colors.border,Re="none"===o?void 0:N.shadow[o],Ae="elevated"===K&&supportsBoxShadow()&&Re?toBoxShadow(Re):void 0,Te=xe.active&&"elevated"===K&&!Ae,Ve=xe.active&&!Te?{backgroundColor:"transparent",borderColor:"transparent"}:null,Fe=useMemo(()=>{const e={borderRadius:Te&&xe.size?squircleHostRadius(xe.size.width,xe.size.height,ue):ue,...smoothCorners,padding:ae||xe.active?N.space.none:ne,overflow:xe.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:me??N.colors.surface,borderBottomWidth:C,borderBottomColor:N.colors.border};case"outline":return{...e,backgroundColor:xe.active?"transparent":me??N.colors.surface,borderWidth:N.size.border,borderColor:xe.active?"transparent":N.colors.border};case"filled":return{...e,backgroundColor:xe.active?"transparent":me??N.colors["bg-subtle"]};default:return{...e,backgroundColor:me??N.colors.surface,...Ae?{boxShadow:Ae}:Re}}},[N,K,Re,ue,ae,ne,xe.active,xe.size,Ae,Te,me,C]),ke=useMemo(()=>({..."number"==typeof R?{width:"100%",aspectRatio:R}:{width:"100%",height:w},borderTopLeftRadius:ue,borderTopRightRadius:ue,borderBottomLeftRadius:N.radius.none,borderBottomRightRadius:N.radius.none,...smoothCorners}),[N,ue,R,w]),Be=u??"",Oe=_jsxs(_Fragment,{children:[_jsxs(View,{style:le.titleColumn,children:[u?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(N,$),children:u}):null,h?_jsx(Text,{variant:"bodySmall",style:le.lead,children:h}):null,ge&&S?_jsx(Text,{variant:"caption",style:le.lead,children:S}):null]}),isCardTextAction(p)?_jsx(CardTextActionButton,{action:p,haptic:k}):p?_jsx(View,{style:le.actionNode,children:p}):null,g,b?_jsx(CardIconAction,{icon:ge?"chevron-down":"chevron-up",label:`${ge?Q.show:Q.hide} ${Be}`.trim(),expanded:!ge,onPress:()=>pe(!ge),haptic:k}):null,j?_jsx(CardIconAction,{icon:"trash",label:Q.remove,onPress:j,color:N.colors["danger-text"],haptic:k}):null]}),Ie=_jsxs(_Fragment,{children:[fe?_jsx(View,{style:[le.header,!c&&le.headerRow,ge&&le.headerFolded,z],children:c??Oe}):null,ge?null:_jsx(View,{style:[fe||v?le.body:null,M],children:i}),v&&!ge?_jsx(View,{style:[le.footer,E],children:v}):null]}),He=_?_jsxs(_Fragment,{children:[_jsxs(View,{style:le.imageWrapper,children:[_jsx(Image,{source:_,resizeMode:"cover",style:ke,accessibilityLabel:"",accessible:!1}),A?_jsx(View,{pointerEvents:"box-none",style:le.imageOverlay,children:A}):null]}),_jsx(View,{style:{padding:ne},children:Ie})]}):Ie,Le=de?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:de,style:StyleSheet.absoluteFill}),He]}):xe.active&&xe.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:xe.size.width,height:xe.size.height,radius:ue,fill:Ce,stroke:ve?we:void 0,strokeWidth:ve}),_jsx(View,{style:[le.squircleClip,{padding:ne,borderRadius:xe.size?squircleHostRadius(xe.size.width,xe.size.height,ue):ue}],children:He})]}):He,{outer:Pe,inner:ze}=splitOuterLayout(P);let Me;if(ie){const handlePress=e=>{Z&&(k&&triggerHaptic(k),F?.(e))};Me=_jsx(Animated.View,{style:[se,...flexStyleOf(L),Pe],children:_jsx(Pressable,{ref:te,onPress:handlePress,onPressIn:oe,onPressOut:re,accessibilityRole:H??(Z?"button":void 0),accessibilityLabel:O,accessibilityHint:I,testID:q,onLayout:xe.onLayout,style:[Fe,ze,Ve,le.pressFill],...U,...ee.hostProps,children:Le})})}else Me=_jsx(View,{ref:t,accessibilityLabel:O,accessibilityHint:I,accessibilityRole:H,testID:q,onLayout:xe.onLayout,style:[Fe,...flexStyleOf(L),P,Ve],...U,children:Le});return T?_jsx(CardSkeleton,{...e}):ee.enabled?_jsxs(_Fragment,{children:[Me,ee.renderSurface(_jsx(View,{style:[Fe,P,Ve,le.preview],children:Le}))]}):Me})),CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:o,header:r,footer:l,imageSource:a,imageHeight:n=160,imageAspectRatio:d,headerStyle:c,bodyStyle:u,footerStyle:m,flex:h,style:p,labels:g,...b})=>{const f=useTheme(),x=f.settings.components.card,y=e??x?.defaultVariant??"elevated",S=i??x?.defaultRadius??"lg",j=s??x?.defaultPadding??"md",C={...useMobileUiText("card",CARD_TEXT),...g},v=paddingMap[j],_=f.space[v],w="flat"===y?f.radius.none:f.radius[S],R=void 0!==r||hasBuiltInHeaderContent(b),A=resolveBackground(f,o)??f.colors.surface,T="outline"===y?1:0,V="outline"===y?f.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:A,borderRadius:w,...smoothCorners,borderWidth:T,borderColor:V,overflow:"hidden"},...flexStyleOf(h),p],accessibilityRole:"progressbar",accessibilityLabel:C.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==a?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,R?_jsx(View,{style:[{padding:_,paddingBottom:f.space.sm},c],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:_},u],children:_jsx(SkeletonText,{lines:3,fontSize:f.text.base.size,lastLineWidth:"55%"})}),void 0!==l?_jsx(View,{style:[{padding:_,paddingTop:f.space.sm,flexDirection:"row"},m],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton";const Card=Object.assign(CardRoot,{Skeleton:CardSkeleton});Card.displayName="Card";const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:o,haptic:r})=>{const l=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{r&&triggerHaptic(r),i()},style:iconActionStyle,children:_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:_jsx(AppIcon,{name:e,size:20,color:o??l.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&triggerHaptic(t),e.onPress()},style:textActionStyle,children:_jsx(Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?fontFor(e,"semibold","display"):{fontFamily:void 0,...fontFor(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return isOneOf(BACKGROUND_TOKENS,t)?e.colors[t]:t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},squircleClip:{overflow:"hidden",...smoothCorners},pressFill:{flexGrow:1},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=themeStyles(buildStyles);export{Card};export default Card;
@@ -1 +1 @@
1
- "use strict";import{formatPercent}from"@webority/mobile-core";import{forwardRef,useMemo}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{AppIcon}from"../AppIcon/index.js";import{Card}from"../Card/index.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_STAT_TILE_LABELS=Object.freeze({trendUp:"up",trendDown:"down",trendFlat:"no change"});const isText=e=>"string"==typeof e||"number"==typeof e,TREND_ICON={up:"arrow-up",down:"arrow-down",flat:"minus"},TREND_SIGN={up:"+",down:"-",flat:""},trendToneTextKey=e=>`${e}-text`,percentText=e=>formatPercent(Math.abs(e),{scale:"percent",maximumFractionDigits:1}),trendFigure=e=>"number"==typeof e.value?`${TREND_SIGN[e.direction]}${percentText(e.value)}`:e.value,trendSpoken=(e,t)=>{const n=[{up:t.trendUp,down:t.trendDown,flat:t.trendFlat}[e.direction]];return"flat"!==e.direction&&n.push("number"==typeof e.value?percentText(e.value):e.value),e.period&&n.push(e.period),n.join(" ")},StatTile=forwardRef((e,t)=>{const{label:n,value:r,icon:i,iconVariant:s,tone:o="primary",caption:a,trend:l,sparkline:d,onPress:c,loading:p=!1,accessibilityLabel:x,labels:m,style:u,testID:T}=e,h=useTheme();assertValidValue("StatTile","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("StatTile","trend.direction",l?.direction,["up","down","flat"]),assertValidValue("StatTile","trend.goodWhen",l?.goodWhen,["up","down"]);const f=useMemo(()=>({...DEFAULT_STAT_TILE_LABELS,...m}),[m]),y=l?`, ${trendSpoken(l,f)}`:"",j=isText(n)?`${n}, `:"",w=x??(isText(r)?`${j}${r}${y}`:void 0),_=!!l&&l.direction===(l.goodWhen??"up"),S=l&&"flat"!==l.direction?_?"success":"danger":"secondary",g="secondary"===S?h.colors["text-muted"]:h.colors[trendToneTextKey(S)];return _jsx(Card,p?{ref:t,variant:"outline",style:u,testID:T,children:_jsxs(View,{style:[styles.row,{columnGap:h.space.md}],children:[void 0===i?null:_jsx(Skeleton,{shape:"circle",width:40,height:40}),_jsxs(View,{style:styles.text,children:[_jsx(Skeleton,{shape:"text",width:"50%",height:12}),_jsx(Skeleton,{shape:"text",width:"35%",height:24,style:{marginTop:h.space.xs}})]})]})}:{ref:t,variant:"outline",onPress:c,accessibilityLabel:w,style:u,testID:T,children:_jsxs(View,{style:[styles.row,{columnGap:h.space.md}],children:[void 0===i?null:_jsx(IconBadge,{icon:i,iconVariant:s,tone:o}),_jsxs(View,{style:styles.text,children:[_jsx(Text,{variant:"caption",color:"secondary",numberOfLines:1,children:n}),isText(r)?_jsx(Text,{variant:"h3",numberOfLines:1,children:r}):r,l?_jsxs(View,{style:[styles.trend,{columnGap:h.space.xxs}],testID:T?`${T}-trend`:void 0,children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:_jsx(AppIcon,{name:TREND_ICON[l.direction],size:"xs",color:g})}),_jsxs(Text,{variant:"caption",color:S,numberOfLines:2,style:styles.text,children:[trendFigure(l),l.period?_jsx(Text,{variant:"caption",color:"tertiary",children:` ${l.period}`}):null]})]}):null,null==a||""===a?null:isText(a)?_jsx(Text,{variant:"caption",color:"tertiary",numberOfLines:1,children:a}):a,null==d?null:_jsx(View,{style:{marginTop:h.space.sm},children:d})]})]})})});StatTile.displayName="StatTile";const styles=StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},text:{flex:1,minWidth:0},trend:{flexDirection:"row",alignItems:"center"}});export{StatTile};export default StatTile;
1
+ "use strict";import{formatPercent}from"@webority/mobile-core";import{forwardRef,useMemo}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{AppIcon}from"../AppIcon/index.js";import{Card}from"../Card/index.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_STAT_TILE_LABELS=Object.freeze({trendUp:"up",trendDown:"down",trendFlat:"no change"});const isText=e=>"string"==typeof e||"number"==typeof e,TREND_ICON={up:"arrow-up",down:"arrow-down",flat:"minus"},TREND_SIGN={up:"+",down:"-",flat:""},trendToneTextKey=e=>`${e}-text`,percentText=e=>formatPercent(Math.abs(e),{scale:"percent",maximumFractionDigits:1}),trendFigure=e=>"number"==typeof e.value?`${TREND_SIGN[e.direction]}${percentText(e.value)}`:e.value,trendSpoken=(e,t)=>{const n=[{up:t.trendUp,down:t.trendDown,flat:t.trendFlat}[e.direction]];return"flat"!==e.direction&&n.push("number"==typeof e.value?percentText(e.value):e.value),e.period&&n.push(e.period),n.join(" ")},StatTile=forwardRef((e,t)=>{const{label:n,value:r,icon:i,iconVariant:s,tone:o="primary",caption:a,trend:l,sparkline:d,onPress:c,loading:p=!1,accessibilityLabel:x,labels:m,flex:u,style:T,testID:f}=e,h=useTheme();assertValidValue("StatTile","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("StatTile","trend.direction",l?.direction,["up","down","flat"]),assertValidValue("StatTile","trend.goodWhen",l?.goodWhen,["up","down"]);const y=useMemo(()=>({...DEFAULT_STAT_TILE_LABELS,...m}),[m]),j=l?`, ${trendSpoken(l,y)}`:"",w=isText(n)?`${n}, `:"",_=x??(isText(r)?`${w}${r}${j}`:void 0),S=!!l&&l.direction===(l.goodWhen??"up"),g=l&&"flat"!==l.direction?S?"success":"danger":"secondary",V="secondary"===g?h.colors["text-muted"]:h.colors[trendToneTextKey(g)];return _jsx(Card,p?{ref:t,variant:"outline",flex:u,style:T,testID:f,children:_jsxs(View,{style:[styles.row,{columnGap:h.space.md}],children:[void 0===i?null:_jsx(Skeleton,{shape:"circle",width:40,height:40}),_jsxs(View,{style:styles.text,children:[_jsx(Skeleton,{shape:"text",width:"50%",height:12}),_jsx(Skeleton,{shape:"text",width:"35%",height:24,style:{marginTop:h.space.xs}})]})]})}:{ref:t,variant:"outline",flex:u,onPress:c,accessibilityLabel:_,style:T,testID:f,children:_jsxs(View,{style:[styles.row,{columnGap:h.space.md}],children:[void 0===i?null:_jsx(IconBadge,{icon:i,iconVariant:s,tone:o}),_jsxs(View,{style:styles.text,children:[_jsx(Text,{variant:"caption",color:"secondary",numberOfLines:1,children:n}),isText(r)?_jsx(Text,{variant:"h3",numberOfLines:1,children:r}):r,l?_jsxs(View,{style:[styles.trend,{columnGap:h.space.xxs}],testID:f?`${f}-trend`:void 0,children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:_jsx(AppIcon,{name:TREND_ICON[l.direction],size:"xs",color:V})}),_jsxs(Text,{variant:"caption",color:g,numberOfLines:2,style:styles.text,children:[trendFigure(l),l.period?_jsx(Text,{variant:"caption",color:"tertiary",children:` ${l.period}`}):null]})]}):null,null==a||""===a?null:isText(a)?_jsx(Text,{variant:"caption",color:"tertiary",numberOfLines:1,children:a}):a,null==d?null:_jsx(View,{style:{marginTop:h.space.sm},children:d})]})]})})});StatTile.displayName="StatTile";const styles=StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},text:{flex:1,minWidth:0},trend:{flexDirection:"row",alignItems:"center"}});export{StatTile};export default StatTile;
@@ -89,6 +89,8 @@ export interface CardProps extends Omit<PressableProps, "style" | "children"> {
89
89
  */
90
90
  contextMenu?: ContextMenuConfig | undefined;
91
91
  accessibilityLabel?: string | undefined;
92
+ /** Share of the free space along the parent's main axis, as React Native `flex`. Unset, the card sizes to its content. */
93
+ flex?: number | undefined;
92
94
  /** The outer box. */
93
95
  style?: StyleProp<ViewStyle> | undefined;
94
96
  /** Style applied to the header wrapper View. */
@@ -53,6 +53,8 @@ export interface StatTileProps {
53
53
  accessibilityLabel?: string | undefined;
54
54
  /** The words the spoken trend uses for each direction. Give only the ones to change. */
55
55
  labels?: Partial<StatTileLabels> | undefined;
56
+ /** Share of the free space along the parent's main axis, as React Native `flex`. Unset, the tile sizes to its content. */
57
+ flex?: number | undefined;
56
58
  style?: StyleProp<ViewStyle> | undefined;
57
59
  testID?: string | undefined;
58
60
  }
@@ -89,6 +89,8 @@ export interface CardProps extends Omit<PressableProps, "style" | "children"> {
89
89
  */
90
90
  contextMenu?: ContextMenuConfig | undefined;
91
91
  accessibilityLabel?: string | undefined;
92
+ /** Share of the free space along the parent's main axis, as React Native `flex`. Unset, the card sizes to its content. */
93
+ flex?: number | undefined;
92
94
  /** The outer box. */
93
95
  style?: StyleProp<ViewStyle> | undefined;
94
96
  /** Style applied to the header wrapper View. */
@@ -53,6 +53,8 @@ export interface StatTileProps {
53
53
  accessibilityLabel?: string | undefined;
54
54
  /** The words the spoken trend uses for each direction. Give only the ones to change. */
55
55
  labels?: Partial<StatTileLabels> | undefined;
56
+ /** Share of the free space along the parent's main axis, as React Native `flex`. Unset, the tile sizes to its content. */
57
+ flex?: number | undefined;
56
58
  style?: StyleProp<ViewStyle> | undefined;
57
59
  testID?: string | undefined;
58
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/mobile-ui",
3
- "version": "0.173.1",
3
+ "version": "0.174.0",
4
4
  "description": "Beautiful, animated, accessible React Native components, theme and form engine for Webority projects.",
5
5
  "keywords": [
6
6
  "react-native",
@@ -126,13 +126,13 @@
126
126
  }
127
127
  },
128
128
  "dependencies": {
129
- "@webority/markdown-core": "0.173.1"
129
+ "@webority/markdown-core": "0.174.0"
130
130
  },
131
131
  "peerDependencies": {
132
132
  "@react-navigation/bottom-tabs": ">=7.0.0",
133
133
  "@react-navigation/native": ">=7.0.0",
134
- "@webority/canvas-kit": "0.173.1",
135
- "@webority/mobile-core": "0.173.1",
134
+ "@webority/canvas-kit": "0.174.0",
135
+ "@webority/mobile-core": "0.174.0",
136
136
  "expo": ">=58.0.0",
137
137
  "expo-file-system": ">=58.0.0",
138
138
  "expo-haptics": ">=58.0.0",
@@ -196,10 +196,10 @@
196
196
  "@types/jest": "29.5.14",
197
197
  "@types/node": "25.6.0",
198
198
  "@types/react": "19.3.0",
199
- "@webority/canvas-kit": "0.173.1",
200
- "@webority/mobile-core": "0.173.1",
199
+ "@webority/canvas-kit": "0.174.0",
200
+ "@webority/mobile-core": "0.174.0",
201
201
  "@webority/mobile-dev": "0.0.0",
202
- "@webority/tokens": "0.173.1",
202
+ "@webority/tokens": "0.174.0",
203
203
  "expo": "58.0.23",
204
204
  "expo-file-system": "58.0.13",
205
205
  "expo-haptics": "58.0.7",