@webority/mobile-ui 0.178.1 → 0.178.2

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.178.1"
5
+ "version": "0.178.2"
6
6
  },
7
7
  "rendererProtocolVersion": 14,
8
8
  "platform": "Phone",
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "webority-phone",
3
- "version": "0.178.1",
3
+ "version": "0.178.2",
4
4
  "platform": "Phone",
5
5
  "kitModuleVersion": 2,
6
6
  "rendererProtocolVersion": 14,
7
7
  "library": {
8
8
  "name": "@webority/mobile-ui",
9
- "version": "0.178.1"
9
+ "version": "0.178.2"
10
10
  },
11
11
  "files": {
12
12
  "manifest.json": {
13
- "sha256": "833b20900f097cc6828985c5c94fbd1abad6432780f21483fe9c335d560b2cd3",
13
+ "sha256": "58900e1d09149037afa991bba7d299745244334eac36541cfc6e726c9e5d3166",
14
14
  "bytes": 673973
15
15
  },
16
16
  "kit.js": {
17
- "sha256": "b0a5b1fde500f031a5bad9be26662c928f86dab3292f7138c27204e138b94bf7",
18
- "bytes": 5706179
17
+ "sha256": "59bfda0991ef2f6a3843291deacb062573388bb722da7fe55578328efac89f2d",
18
+ "bytes": 5706853
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: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,{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
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_reactNativeWorklets=require("react-native-worklets"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../text/index.js"),_bottomSheetG=require("../../text/phone/bottomSheet.g.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,o=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=o&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?o(n,r,a):n[r]=e[r]);return n}const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:o,onSnapChange:n,onAnimate:s,onAfterClose:i,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:b,scrollEventThrottle:x,keyboardBehavior:S="shift",inline:p=!1,presentation:N="sheet",animateMount:R=!0,handleIndicatorStyle:y,sheetStyle:g,header:M,actions:j,actionsLayout:C="auto",footer:w,headerStyle:k,footerStyle:O,children:V,accessibilityLabel:I,accessibilityViewIsModal:A,testID:T}=e;(0,_assertValidValue.assertValidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_assertValidValue.assertValidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_assertValidValue.assertValidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const E=(0,_index.useMobileUiText)("bottomSheet",_bottomSheetG.BOTTOM_SHEET_TEXT),B=(0,_react.useMemo)(()=>({...E,..._}),[E,_]),P=null!=M||null!=d,D=null!=j&&j.length>0,H=null!=w||D,L=p?"inline":"modal",G=(0,_index2.useTheme)(),q=(0,_usePresenceMotion.usePresenceMotion)(),W=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),F="modal"===L&&"android"===_reactNative.Platform.OS,[U,Y]=(0,_react.useState)(()=>_reactNative.Dimensions.get(F?"screen":"window").height),[K,$]=(0,_react.useState)(()=>_reactNative.Dimensions.get(F?"screen":"window").width),z=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;F&&Math.abs(t-_reactNative.Dimensions.get("window").height)<1&&t<_reactNative.Dimensions.get("screen").height-1||(t>0&&Y(e=>e===t?e:t),a>0&&$(e=>e===a?e:a))},[F]),X=(0,_reactNative.useWindowDimensions)(),J="dialog"===N||"auto"===N&&Math.min(X.width,X.height)>=600,Q=Math.min(560,K-2*G.space.xl),[Z,ee]=(0,_ModalSafeArea.useModalInsets)(),te="modal"===L?Z.top:W.top,ae="modal"===L?Z.bottom:W.bottom,re=t.includes("content"),[oe,ne]=useMeasuredHeight(),[se,ie]=useMeasuredHeight(),[ce,le,ue]=useMeasuredHeight(),[de,he]=useMeasuredHeight(),me=J?G.space.md:oe,ve=re?Math.min(me+(P?se:0)+ce+(H?de:0)+ae,U-te):0,fe=(0,_react.useCallback)((e,t)=>{re&&ue(t),f?.(e,t)},[re,f,ue]),be=(0,_react.useMemo)(()=>resolveSnapPoints(t,U,ve),[t,U,ve]),xe=U,Se=be[be.length-1]??0,pe=(0,_reactNativeReanimated.useSharedValue)(xe),Ne=(0,_reactNativeReanimated.useSharedValue)(xe),Re=(0,_reactNativeReanimated.useSharedValue)(1),ye=(0,_reactNativeReanimated.useSharedValue)(-1),[ge,Me]=(0,_react.useState)(-1),[je,Ce]=(0,_react.useState)(!1),[we,ke]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ve=(0,_react.useRef)(i);Ve.current=i;const[Ie,Ae]=(0,_react.useState)(!1),Te=(0,_react.useRef)(!R&&a),Ee=(0,_react.useRef)(-1),Be=(0,_react.useRef)(!1);Be.current="modal"===L?we:Ie;const Pe=(0,_react.useRef)(u);Pe.current=u;const De=(0,_react.useRef)(r);De.current=r;const He=(0,_react.useRef)(!1),Le=(0,_react.useRef)(!0),Ge=(0,_react.useRef)([]),qe=(0,_react.useCallback)(e=>{const t=Ge.current;Ge.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(Le.current=!0,()=>{Le.current=!1,qe(!1)}),[qe]);const We=(0,_react.useCallback)(e=>{if(e<0||e>=be.length)return xe;const t=be[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return J?(U-t)/2:U-t},[be,U,xe,J]),Fe=(0,_react.useCallback)(e=>{Ee.current=e;ge!==e&&(Me(e),ye.value=e,e>=0&&n?.(e))},[ge,ye,n]),Ue=(0,_react.useCallback)(()=>{ye.value<0&&(Oe.current=!0,"modal"===L?(Ce(!1),"ios"!==_reactNative.Platform.OS&&ke(!1)):Ae(!1))},[L,ye]),Ye=(0,_react.useCallback)(()=>{Oe.current&&ke(!1)},[]);(0,_react.useEffect)(()=>{("modal"===L?!we:!Ie)&&Oe.current&&(Oe.current=!1,Ve.current?.(),qe(!0))},[L,we,Ie,qe]);const Ke=(0,_react.useCallback)((e,t,a)=>{s?.(t,a),pe.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeWorklets.scheduleOnRN)(Ue)})},[s,pe,Ue]),$e=(0,_react.useRef)(null),ze=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,be.length-1):Math.max(ge,0),a=ye.value,r=We(t);return Oe.current=!1,qe(!1),"modal"===L?(ke(!0),Ce(!0)):Ae(!0),a<0&&Te.current?(pe.value=r,Re.value=1,Fe(t),void s?.(a,t)):a<0&&q.reduced?(pe.value=r,Re.value=0,Re.value=(0,_reactNativeReanimated.withTiming)(1,{duration:q.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...G.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void s?.(a,t)):(a<0&&(pe.value=xe,Re.value=1),Fe(t),void(a<0&&t>=0&&!Be.current?$e.current={fromIndex:a,target:t}:Ke(r,a,t)))},[Ke,xe,ge,ye,L,s,q,Re,be.length,Fe,qe,G.motion.ease.decelerate,pe,We]),Xe=(0,_react.useCallback)(()=>new Promise(e=>{if(Ee.current<0)return void(Be.current?Ge.current.push(e):e(!0));Ge.current.push(e),Te.current=!1,$e.current=null;const t=ye.value;Fe(-1),s?.(t,-1);const a=q.reduced?Re:pe,r=q.reduced?0:xe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:q.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...G.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeWorklets.scheduleOnRN)(Ue)})}),[xe,ye,Ue,s,q,Re,Fe,pe,G.motion.ease.accelerate]),Je=(0,_react.useCallback)((e,t,a)=>{const r=Pe.current;if(!r)return void e();if(He.current)return void t?.();const o=r();"boolean"!=typeof o?(He.current=!0,a?.(),o.then(a=>{He.current=!1,a&&Le.current&&Ee.current>=0?e():t?.()},e=>{throw He.current=!1,e})):(o?e:t)?.()},[]),Qe=(0,_react.useCallback)(()=>new Promise(e=>{Ee.current<0?e(!0):Je(()=>{De.current(),Xe(),e(!0)},()=>e(!1))}),[Xe,Je]),Ze=(0,_react.useCallback)(()=>{De.current()},[]),et=(0,_react.useCallback)(()=>{l&&Qe()},[l,Qe]),tt=(0,_react.useRef)(null),at=(0,_react.useRef)(ze);at.current=ze;const rt=(0,_react.useRef)(Xe);rt.current=Xe,(0,_react.useLayoutEffect)(()=>{const e=tt.current!==a;tt.current=a,e?a?at.current(o??0):rt.current():a&&"number"==typeof o&&o!==ye.value&&at.current(o)},[a,o,ye]);const ot=(0,_react.useRef)({hostHeight:U,contentSnap:ve}),nt=(0,_react.useRef)(We);nt.current=We,(0,_react.useEffect)(()=>{const e=ot.current;if(e.hostHeight===U&&e.contentSnap===ve)return;if(ot.current={hostHeight:U,contentSnap:ve},e.hostHeight===U&&ye.value<0)return;const t=nt.current(ye.value);pe.value=Te.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[U,ve,ye,pe]);const st="modal"===L?we:Ie;(0,_react.useLayoutEffect)(()=>{const e=$e.current;null!==e&&st&&($e.current=null,Ee.current===e.target&&Ke(nt.current(e.target),e.fromIndex,e.target))},[st,Ke]);const it=U-Se,ct=(0,_react.useMemo)(()=>be.map(e=>U-e),[be,U]),lt=(0,_react.useCallback)(()=>{const e=Ee.current;e<0||Ke(We(e),e,e)},[Ke,We]),ut=(0,_react.useCallback)((e,t)=>{const a=ye.value;-1!==e?(Fe(e),Ke(t,a,e)):Je(()=>{_reactNative.Keyboard.dismiss(),(0,_index3.triggerHaptic)("selection"),De.current(),Xe()},lt,lt)},[Ke,Xe,ye,Je,Fe,lt]),dt=(0,_react.useMemo)(()=>({testID:T?`${T}-content-gesture`:"bottom-sheet-content-gesture"}),[T]),_t=(0,_reactNativeGestureHandler.useNativeGesture)(dt),ht=(0,_react.useMemo)(()=>{const e=ct,t=xe,a=it,r=c;return{testID:T?`${T}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";Ne.value=pe.value},onUpdate:e=>{"worklet";const t=Ne.value+e.translationY;pe.value=t<a?a+.25*(t-a):t},onDeactivate:a=>{"worklet";const o=pe.value,n=a.velocityY,[s]=e;if(void 0===s)return void(0,_reactNativeWorklets.scheduleOnRN)(ut,-1,t);if(n>1e3)return r?void(0,_reactNativeWorklets.scheduleOnRN)(ut,-1,t):void(0,_reactNativeWorklets.scheduleOnRN)(ut,0,s);let i=0,c=s,l=1/0,u=0;for(const t of e){const e=Math.abs(o-t);e<l&&(l=e,c=t,i=u),u++}r&&o-s>80?(0,_reactNativeWorklets.scheduleOnRN)(ut,-1,t):(0,_reactNativeWorklets.scheduleOnRN)(ut,i,c)}}},[xe,Ne,c,ut,it,ct,T,pe]),mt=(0,_reactNativeGestureHandler.usePanGesture)(ht),{height:vt,progress:ft}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),bt="shift"===S,xt=(0,_reactNativeReanimated.useDerivedValue)(()=>bt?vt.value:0,[bt,vt]),St=(0,_reactNativeReanimated.useSharedValue)(0);(0,_reactNativeReanimated.useAnimatedReaction)(()=>bt&&ft.value>=1?vt.value:0,e=>{St.value=e},[bt,vt,ft,St]);const pt=be[Math.max(ge,0)]??Se,Nt=G.space.md,Rt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=xt.value;if(J){const t=U+e-pt-Nt,a=e<0&&pe.value>t?t:pe.value;return{top:pe.value,transform:[{translateY:Math.max(a,te)-pe.value}],opacity:Re.value}}const t=e<0?te:it,a=Math.max(pe.value+e,t);return{top:pe.value,transform:[{translateY:a-pe.value}],opacity:Re.value}},[J,xt,U,pt,Nt,pe,te,Re,it]),yt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=St.value;if(J){const t=U+e-pt-Nt,a=e<0&&pe.value>t?t:pe.value,r=Math.max(a,te),o=U+e-Nt-r;return{height:o<0?0:Math.min(o,pt)}}const t=e<0?te:it,a=Math.max(pe.value+e,t),r=U+e-a;return{height:r<0?0:Math.min(r,Se)}},[St,J,U,pt,Nt,pe,te,it,Se]),gt=ge>=0,Mt=(0,_react.useMemo)(()=>buildStyles(G),[G]),jt=(0,_react.useCallback)(()=>{l&&Je(()=>{(0,_index3.triggerHaptic)("selection"),De.current(),Xe()})},[l,Xe,Je]),Ct=(0,_react.useMemo)(()=>({testID:T?`${T}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||(0,_reactNativeWorklets.scheduleOnRN)(jt)}}),[jt,T]),wt=(0,_reactNativeGestureHandler.useTapGesture)(Ct),kt=(0,_react.useMemo)(()=>({snapIndex:ge,snapPoints:be,close:Ze,requestClose:Qe}),[ge,be,Ze,Qe]);if("inline"===L&&!Ie)return null;if("modal"===L&&!we)return null;const Ot=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===L?Mt.backdropModal:Mt.backdropInline,{backgroundColor:"modal"===L?(0,_color.transparentOf)(G.colors.scrim):G.colors.scrim}],onLayout:z,testID:T,accessibilityViewIsModal:A??gt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:wt,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:B.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:I,accessibilityViewIsModal:A??gt,accessibilityActions:[{name:"escape",label:B.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&et()},onAccessibilityEscape:et,style:[Mt.sheet,{height:Se,backgroundColor:G.colors.surface,borderTopLeftRadius:G.radius.xl,borderTopRightRadius:G.radius.xl,..._corners.smoothCorners,...G.shadow.modal},J?{height:pt,left:(K-Q)/2,right:void 0,width:Q,borderBottomLeftRadius:G.radius.xl,borderBottomRightRadius:G.radius.xl}:null,g,Rt],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[Mt.body,yt],settledKeyboardOffset:St,children:[J?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:G.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:mt,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:Mt.handleRow,onLayout:re?ne:void 0,accessible:!0,accessibilityLabel:B.dragHandle,accessibilityHint:B.dragHandleHintText,testID:T?`${T}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[Mt.handle,{backgroundColor:G.colors.border},y]})})}),P&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Mt.header,k],onLayout:re?ie:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",accessibilityRole:"header",children:d}):null,M]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:_t,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,testID:T?`${T}-scroll`:void 0,style:Mt.scrollContent,onScroll:v,onContentSizeChange:fe,onLayout:b,scrollEventThrottle:x,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:V})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:re?[Mt.content,{overflow:"visible"}]:Mt.content,children:re?(0,_jsxRuntime.jsx)(_reactNative.View,{style:Mt.contentMeasure,onLayout:le,children:V}):V}),H&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[Mt.footer,O],onLayout:re?he:void 0,children:[D?(0,_jsxRuntime.jsx)(_reactNative.View,{style:Mt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:C})}):null,w]})]})})]}),Vt=(0,_jsxRuntime.jsx)(BottomSheetContext,{value:kt,children:Ot});return"modal"===L?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:je,onClose:et,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:ee,onDismissed:"ios"===_reactNative.Platform.OS?Ye:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:Mt.modalRoot,children:Vt}):Vt}):Vt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,settledKeyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,o=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:Math.max(e,0)}},[r,t]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,o],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{backgroundColor:e.colors.surface},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},contentMeasure:{position:"absolute",top:0,left:0,right:0},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useModalInsets=exports.ModalSafeArea=exports.InsetsProbe=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_jsxRuntime=require("react/jsx-runtime");const useModalInsets=()=>{const{top:e,bottom:t}=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)();return(0,_react.useState)({top:e,bottom:t})};exports.useModalInsets=useModalInsets;const InsetsProbe=({onChange:e})=>{const{top:t,bottom:s}=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)();return(0,_react.useEffect)(()=>{e(e=>e.top===t&&e.bottom===s?e:{top:t,bottom:s})},[t,s,e]),null};exports.InsetsProbe=InsetsProbe;const ModalSafeArea=({onInsets:e,children:t})=>(0,_jsxRuntime.jsxs)(_reactNativeSafeAreaContext.SafeAreaProvider,{style:styles.fill,children:[(0,_jsxRuntime.jsx)(InsetsProbe,{onChange:e}),t]});exports.ModalSafeArea=ModalSafeArea;const styles=_reactNative.StyleSheet.create({fill:{flex:1}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useModalInsets=exports.ModalSafeArea=exports.InsetsProbe=void 0;var _react=require("react"),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_jsxRuntime=require("react/jsx-runtime");const translucentWindowInsets=e=>{if("android"!==_reactNative.Platform.OS)return e;const t=_reactNative.Dimensions.get("screen"),r=_reactNative.Dimensions.get("window"),a=t.height-r.height;if(a<=0)return e;const s=_reactNative.StatusBar.currentHeight??e.top;return{top:s,bottom:Math.max(a-s,e.bottom)}},useModalInsets=()=>{const{top:e,bottom:t}=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)();return(0,_react.useState)(()=>translucentWindowInsets({top:e,bottom:t}))};exports.useModalInsets=useModalInsets;const InsetsProbe=({onChange:e})=>{const{top:t,bottom:r}=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)();return(0,_react.useEffect)(()=>{e(e=>e.top===t&&e.bottom===r?e:{top:t,bottom:r})},[t,r,e]),null};exports.InsetsProbe=InsetsProbe;const ModalSafeArea=({onInsets:e,children:t})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[a]=(0,_react.useState)(()=>{const{top:e,bottom:t}=translucentWindowInsets({top:r.top,bottom:r.bottom}),{width:a,height:s}=_reactNative.Dimensions.get("android"===_reactNative.Platform.OS?"screen":"window");return{frame:{x:0,y:0,width:a,height:s},insets:{top:e,bottom:t,left:r.left,right:r.right}}});return(0,_jsxRuntime.jsxs)(_reactNativeSafeAreaContext.SafeAreaProvider,{style:styles.fill,initialMetrics:a,children:[(0,_jsxRuntime.jsx)(InsetsProbe,{onChange:e}),t]})};exports.ModalSafeArea=ModalSafeArea;const styles=_reactNative.StyleSheet.create({fill:{flex:1}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PagedList=PagedList;var _react=require("react"),_reactNative=require("react-native"),_useRefreshControl=require("../../hooks/useRefreshControl.js"),_index=require("../../text/index.js"),_asyncBlockG=require("../../text/phone/asyncBlock.g.js"),_index2=require("../AsyncBlock/index.js"),_index3=require("../EmptyState/index.js"),_index4=require("../PagedListFooter/index.js"),_jsxRuntime=require("react/jsx-runtime");const noop=()=>{},styles=_reactNative.StyleSheet.create({flex:{flex:1},grow:{flexGrow:1}}),isElementFooter=e=>(0,_react.isValidElement)(e);function renderFooter(e){if(null==e)return null;if(isElementFooter(e))return e;const t=e;return(0,_jsxRuntime.jsx)(t,{})}function PagedList(e){const{state:t,paging:r,empty:s,skeleton:n,errorTitle:o,data:i,placeholderStyle:l,onRefresh:a,refreshing:d,progressViewOffset:u,ref:x,onEndReached:c,ListFooterComponent:_,style:f,contentContainerStyle:y,...h}=e,m=(0,_index.useMobileUiText)("asyncBlock",_asyncBlockG.ASYNC_BLOCK_TEXT),j="data"===t?.status||"empty"===t?.status?t:void 0,{refreshControl:p}=(0,_useRefreshControl.useRefreshControl)({onRefresh:j?j.refresh:a??noop,refreshing:j?j.refreshing:d}),g=a||j?void 0===u?p:(0,_react.cloneElement)(p,{progressViewOffset:u}):void 0,handleEndReached=e=>{r?.hasMore&&!r.loadingMore&&null==r.errorMore&&r.loadMore(),c?.(e)},renderList=(e,t)=>(0,_jsxRuntime.jsx)(_reactNative.FlatList,{data:e,keyboardShouldPersistTaps:"handled",onEndReachedThreshold:r?.5:void 0,...h,ref:x,refreshControl:g,onEndReached:r?handleEndReached:c,ListEmptyComponent:t,ListFooterComponent:r||_?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[renderFooter(_),r?(0,_jsxRuntime.jsx)(_index4.PagedListFooter,{paging:r}):null]}):void 0,style:[styles.flex,f],contentContainerStyle:[y,t?styles.grow:void 0]});return"empty"===t?.status?renderList([],(0,_jsxRuntime.jsx)(_index3.EmptyState,{...s??{title:m.emptyTitle}})):t?(0,_jsxRuntime.jsx)(_index2.AsyncBlock,{state:t,skeleton:n,errorTitle:o,style:[styles.flex,l],children:e=>renderList(e,void 0)}):renderList(i,s?(0,_jsxRuntime.jsx)(_index3.EmptyState,{...s}):void 0)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PagedList=PagedList;var _react=require("react"),_reactNative=require("react-native"),_useRefreshControl=require("../../hooks/useRefreshControl.js"),_index=require("../../text/index.js"),_asyncBlockG=require("../../text/phone/asyncBlock.g.js"),_index2=require("../AsyncBlock/index.js"),_index3=require("../EmptyState/index.js"),_index4=require("../PagedListFooter/index.js"),_jsxRuntime=require("react/jsx-runtime");const noop=()=>{},styles=_reactNative.StyleSheet.create({flex:{flex:1},grow:{flexGrow:1}}),isElementFooter=e=>(0,_react.isValidElement)(e);function renderFooter(e){if(null==e)return null;if(isElementFooter(e))return e;const t=e;return(0,_jsxRuntime.jsx)(t,{})}function PagedList(e){const{state:t,paging:r,empty:s,skeleton:n,errorTitle:o,data:i,placeholderStyle:l,onRefresh:a,refreshing:d,progressViewOffset:u,ref:x,onEndReached:c,ListFooterComponent:_,style:f,contentContainerStyle:y,...h}=e,m=(0,_index.useMobileUiText)("asyncBlock",_asyncBlockG.ASYNC_BLOCK_TEXT),j="data"===t?.status||"empty"===t?.status?t:void 0,{refreshControl:p}=(0,_useRefreshControl.useRefreshControl)({onRefresh:j?j.refresh:a??noop,refreshing:j?j.refreshing:d}),g=a||j?void 0===u?p:(0,_react.cloneElement)(p,{progressViewOffset:u}):void 0,handleEndReached=e=>{r?.hasMore&&!r.loadingMore&&null==r.errorMore&&r.loadMore(),c?.(e)},renderList=(e,t)=>(0,_jsxRuntime.jsx)(_reactNative.FlatList,{data:e,keyboardShouldPersistTaps:"handled",onEndReachedThreshold:r?.5:void 0,...h,ref:x,refreshControl:g,onEndReached:r?handleEndReached:c,ListEmptyComponent:t,ListFooterComponent:r||_?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[renderFooter(_),r?(0,_jsxRuntime.jsx)(_index4.PagedListFooter,{paging:r}):null]}):void 0,style:[styles.flex,f],contentContainerStyle:[y,t?styles.grow:void 0]});return"empty"===t?.status?renderList([],(0,_jsxRuntime.jsx)(_index3.EmptyState,{fill:!0,...s??{title:m.emptyTitle}})):t?(0,_jsxRuntime.jsx)(_index2.AsyncBlock,{state:t,skeleton:n,errorTitle:o,style:[styles.flex,l],children:e=>renderList(e,void 0)}):renderList(i,s?(0,_jsxRuntime.jsx)(_index3.EmptyState,{fill:!0,...s}):void 0)}
@@ -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,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,{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
+ "use strict";import{createContext,useCallback,useContext,useEffect,useLayoutEffect,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:a,onSnapChange:r,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:g="shift",inline:y=!1,presentation:x="sheet",animateMount:w=!0,handleIndicatorStyle:C,sheetStyle:M,header:R,actions:_,actionsLayout:T="auto",footer:O,headerStyle:E,footerStyle:k,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 D=useMobileUiText("bottomSheet",BOTTOM_SHEET_TEXT),N=useMemo(()=>({...D,...h}),[D,h]),B=null!=R||null!=d,P=null!=_&&_.length>0,L=null!=O||P,H=y?"inline":"modal",G=useTheme(),F=usePresenceMotion(),U=useSafeAreaInsets(),Y="modal"===H&&"android"===Platform.OS,[K,$]=useState(()=>Dimensions.get(Y?"screen":"window").height),[z,X]=useState(()=>Dimensions.get(Y?"screen":"window").width),W=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;Y&&Math.abs(t-Dimensions.get("window").height)<1&&t<Dimensions.get("screen").height-1||(t>0&&$(e=>e===t?e:t),o>0&&X(e=>e===o?e:o))},[Y]),q=useWindowDimensions(),J="dialog"===x||"auto"===x&&Math.min(q.width,q.height)>=600,Q=Math.min(560,z-2*G.space.xl),[Z,ee]=useModalInsets(),te="modal"===H?Z.top:U.top,oe="modal"===H?Z.bottom:U.bottom,se=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,le]=useMeasuredHeight(),[ie,ue,ce]=useMeasuredHeight(),[de,he]=useMeasuredHeight(),me=J?G.space.md:ae,fe=se?Math.min(me+(B?ne:0)+ie+(L?de:0)+oe,K-te):0,be=useCallback((e,t)=>{se&&ce(t),p?.(e,t)},[se,p,ce]),pe=useMemo(()=>resolveSnapPoints(t,K,fe),[t,K,fe]),Se=K,ve=pe[pe.length-1]??0,ge=useSharedValue(Se),ye=useSharedValue(Se),xe=useSharedValue(1),we=useSharedValue(-1),[Ce,Me]=useState(-1),[Re,Te]=useState(!1),[Oe,Ee]=useState(!1),ke=useRef(!1),Ie=useRef(l);Ie.current=l;const[Ae,je]=useState(!1),Ve=useRef(!w&&o),De=useRef(-1),Ne=useRef(!1);Ne.current="modal"===H?Oe:Ae;const Be=useRef(c);Be.current=c;const Pe=useRef(s);Pe.current=s;const Le=useRef(!1),He=useRef(!0),Ge=useRef([]),Fe=useCallback(e=>{const t=Ge.current;Ge.current=[];for(const o of t)o(e)},[]);useEffect(()=>(He.current=!0,()=>{He.current=!1,Fe(!1)}),[Fe]);const Ue=useCallback(e=>{if(e<0||e>=pe.length)return Se;const t=pe[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return J?(K-t)/2:K-t},[pe,K,Se,J]),Ye=useCallback(e=>{De.current=e;Ce!==e&&(Me(e),we.value=e,e>=0&&r?.(e))},[Ce,we,r]),Ke=useCallback(()=>{we.value<0&&(ke.current=!0,"modal"===H?(Te(!1),"ios"!==Platform.OS&&Ee(!1)):je(!1))},[H,we]),$e=useCallback(()=>{ke.current&&Ee(!1)},[]);useEffect(()=>{("modal"===H?!Oe:!Ae)&&ke.current&&(ke.current=!1,Ie.current?.(),Fe(!0))},[H,Oe,Ae,Fe]);const ze=useCallback((e,t,o)=>{n?.(t,o),ge.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&scheduleOnRN(Ke)})},[n,ge,Ke]),Xe=useRef(null),We=useCallback(e=>{const t="number"==typeof e?clamp(e,0,pe.length-1):Math.max(Ce,0),o=we.value,s=Ue(t);return ke.current=!1,Fe(!1),"modal"===H?(Ee(!0),Te(!0)):je(!0),o<0&&Ve.current?(ge.value=s,xe.value=1,Ye(t),void n?.(o,t)):o<0&&F.reduced?(ge.value=s,xe.value=0,xe.value=withTiming(1,{duration:F.duration("fast"),easing:Easing.bezier(...G.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ye(t),void n?.(o,t)):(o<0&&(ge.value=Se,xe.value=1),Ye(t),void(o<0&&t>=0&&!Ne.current?Xe.current={fromIndex:o,target:t}:ze(s,o,t)))},[ze,Se,Ce,we,H,n,F,xe,pe.length,Ye,Fe,G.motion.ease.decelerate,ge,Ue]),qe=useCallback(()=>new Promise(e=>{if(De.current<0)return void(Ne.current?Ge.current.push(e):e(!0));Ge.current.push(e),Ve.current=!1,Xe.current=null;const t=we.value;Ye(-1),n?.(t,-1);const o=F.reduced?xe:ge,s=F.reduced?0:Se;o.value=withTiming(s,{duration:F.duration("fast"),easing:Easing.bezier(...G.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&scheduleOnRN(Ke)})}),[Se,we,Ke,n,F,xe,Ye,ge,G.motion.ease.accelerate]),Je=useCallback((e,t,o)=>{const s=Be.current;if(!s)return void e();if(Le.current)return void t?.();const a=s();"boolean"!=typeof a?(Le.current=!0,o?.(),a.then(o=>{Le.current=!1,o&&He.current&&De.current>=0?e():t?.()},e=>{throw Le.current=!1,e})):(a?e:t)?.()},[]),Qe=useCallback(()=>new Promise(e=>{De.current<0?e(!0):Je(()=>{Pe.current(),qe(),e(!0)},()=>e(!1))}),[qe,Je]),Ze=useCallback(()=>{Pe.current()},[]),et=useCallback(()=>{u&&Qe()},[u,Qe]),tt=useRef(null),ot=useRef(We);ot.current=We;const st=useRef(qe);st.current=qe,useLayoutEffect(()=>{const e=tt.current!==o;tt.current=o,e?o?ot.current(a??0):st.current():o&&"number"==typeof a&&a!==we.value&&ot.current(a)},[o,a,we]);const at=useRef({hostHeight:K,contentSnap:fe}),rt=useRef(Ue);rt.current=Ue,useEffect(()=>{const e=at.current;if(e.hostHeight===K&&e.contentSnap===fe)return;if(at.current={hostHeight:K,contentSnap:fe},e.hostHeight===K&&we.value<0)return;const t=rt.current(we.value);ge.value=Ve.current?t:withSpring(t,SPRING_CONFIG)},[K,fe,we,ge]);const nt="modal"===H?Oe:Ae;useLayoutEffect(()=>{const e=Xe.current;null!==e&&nt&&(Xe.current=null,De.current===e.target&&ze(rt.current(e.target),e.fromIndex,e.target))},[nt,ze]);const lt=K-ve,it=useMemo(()=>pe.map(e=>K-e),[pe,K]),ut=useCallback(()=>{const e=De.current;e<0||ze(Ue(e),e,e)},[ze,Ue]),ct=useCallback((e,t)=>{const o=we.value;-1!==e?(Ye(e),ze(t,o,e)):Je(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Pe.current(),qe()},ut,ut)},[ze,qe,we,Je,Ye,ut]),dt=useMemo(()=>({testID:V?`${V}-content-gesture`:"bottom-sheet-content-gesture"}),[V]),ht=useNativeGesture(dt),mt=useMemo(()=>{const e=it,t=Se,o=lt,s=i;return{testID:V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";ye.value=ge.value},onUpdate:e=>{"worklet";const t=ye.value+e.translationY;ge.value=t<o?o+.25*(t-o):t},onDeactivate:o=>{"worklet";const a=ge.value,r=o.velocityY,[n]=e;if(void 0===n)return void scheduleOnRN(ct,-1,t);if(r>1e3)return s?void scheduleOnRN(ct,-1,t):void scheduleOnRN(ct,0,n);let l=0,i=n,u=1/0,c=0;for(const t of e){const e=Math.abs(a-t);e<u&&(u=e,i=t,l=c),c++}s&&a-n>80?scheduleOnRN(ct,-1,t):scheduleOnRN(ct,l,i)}}},[Se,ye,i,ct,lt,it,V,ge]),ft=usePanGesture(mt),{height:bt,progress:pt}=useReanimatedKeyboardAnimation(),St="shift"===g,vt=useDerivedValue(()=>St?bt.value:0,[St,bt]),gt=useSharedValue(0);useAnimatedReaction(()=>St&&pt.value>=1?bt.value:0,e=>{gt.value=e},[St,bt,pt,gt]);const yt=pe[Math.max(Ce,0)]??ve,xt=G.space.md,wt=useAnimatedStyle(()=>{const e=vt.value;if(J){const t=K+e-yt-xt,o=e<0&&ge.value>t?t:ge.value;return{top:ge.value,transform:[{translateY:Math.max(o,te)-ge.value}],opacity:xe.value}}const t=e<0?te:lt,o=Math.max(ge.value+e,t);return{top:ge.value,transform:[{translateY:o-ge.value}],opacity:xe.value}},[J,vt,K,yt,xt,ge,te,xe,lt]),Ct=useAnimatedStyle(()=>{const e=gt.value;if(J){const t=K+e-yt-xt,o=e<0&&ge.value>t?t:ge.value,s=Math.max(o,te),a=K+e-xt-s;return{height:a<0?0:Math.min(a,yt)}}const t=e<0?te:lt,o=Math.max(ge.value+e,t),s=K+e-o;return{height:s<0?0:Math.min(s,ve)}},[gt,J,K,yt,xt,ge,te,lt,ve]),Mt=Ce>=0,Rt=useMemo(()=>buildStyles(G),[G]),_t=useCallback(()=>{u&&Je(()=>{triggerHaptic("selection"),Pe.current(),qe()})},[u,qe,Je]),Tt=useMemo(()=>({testID:V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||scheduleOnRN(_t)}}),[_t,V]),Ot=useTapGesture(Tt),Et=useMemo(()=>({snapIndex:Ce,snapPoints:pe,close:Ze,requestClose:Qe}),[Ce,pe,Ze,Qe]);if("inline"===H&&!Ae)return null;if("modal"===H&&!Oe)return null;const kt=_jsxs(View,{collapsable:!1,style:["modal"===H?Rt.backdropModal:Rt.backdropInline,{backgroundColor:"modal"===H?transparentOf(G.colors.scrim):G.colors.scrim}],onLayout:W,testID:V,accessibilityViewIsModal:j??Mt,children:[_jsx(GestureDetector,{gesture:Ot,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:N.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:A,accessibilityViewIsModal:j??Mt,accessibilityActions:[{name:"escape",label:N.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&et()},onAccessibilityEscape:et,style:[Rt.sheet,{height:ve,backgroundColor:G.colors.surface,borderTopLeftRadius:G.radius.xl,borderTopRightRadius:G.radius.xl,...smoothCorners,...G.shadow.modal},J?{height:yt,left:(z-Q)/2,right:void 0,width:Q,borderBottomLeftRadius:G.radius.xl,borderBottomRightRadius:G.radius.xl}:null,M,wt],children:_jsxs(SheetBody,{style:[Rt.body,Ct],settledKeyboardOffset:gt,children:[J?_jsx(View,{style:{height:G.space.md}}):_jsx(GestureDetector,{gesture:ft,children:_jsx(View,{style:Rt.handleRow,onLayout:se?re:void 0,accessible:!0,accessibilityLabel:N.dragHandle,accessibilityHint:N.dragHandleHintText,testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[Rt.handle,{backgroundColor:G.colors.border},C]})})}),B&&_jsxs(View,{style:[Rt.header,E],onLayout:se?le:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,R]}),m?_jsx(GestureDetector,{gesture:ht,children:_jsx(ScrollView,{ref:f,testID:V?`${V}-scroll`:void 0,style:Rt.scrollContent,onScroll:b,onContentSizeChange:be,onLayout:S,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:I})}):_jsx(View,{style:se?[Rt.content,{overflow:"visible"}]:Rt.content,children:se?_jsx(View,{style:Rt.contentMeasure,onLayout:ue,children:I}):I}),L&&_jsxs(View,{style:[Rt.footer,k],onLayout:se?he:void 0,children:[P?_jsx(View,{style:Rt.actions,children:_jsx(OverlayActions,{actions:_??[],layout:T})}):null,O]})]})})]}),It=_jsx(BottomSheetContext,{value:Et,children:kt});return"modal"===H?_jsx(Modal,{open:Re,onClose:et,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:ee,onDismissed:"ios"===Platform.OS?$e:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:Rt.modalRoot,children:It}):It}):It},SheetBody=({style:e,settledKeyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,a=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:Math.max(e,0)}},[s,t]);return _jsx(Animated.View,{style:[e,a],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"},contentMeasure:{position:"absolute",top:0,left:0,right:0},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
@@ -1 +1 @@
1
- "use strict";import{useEffect,useState}from"react";import{StyleSheet}from"react-native";import{SafeAreaProvider,useSafeAreaInsets}from"react-native-safe-area-context";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const useModalInsets=()=>{const{top:e,bottom:t}=useSafeAreaInsets();return useState({top:e,bottom:t})};export const InsetsProbe=({onChange:e})=>{const{top:t,bottom:s}=useSafeAreaInsets();return useEffect(()=>{e(e=>e.top===t&&e.bottom===s?e:{top:t,bottom:s})},[t,s,e]),null};export const ModalSafeArea=({onInsets:e,children:t})=>_jsxs(SafeAreaProvider,{style:styles.fill,children:[_jsx(InsetsProbe,{onChange:e}),t]});const styles=StyleSheet.create({fill:{flex:1}});
1
+ "use strict";import{useEffect,useState}from"react";import{Dimensions,Platform,StatusBar,StyleSheet}from"react-native";import{SafeAreaProvider,useSafeAreaInsets}from"react-native-safe-area-context";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const translucentWindowInsets=t=>{if("android"!==Platform.OS)return t;const e=Dimensions.get("screen"),s=Dimensions.get("window"),o=e.height-s.height;if(o<=0)return t;const n=StatusBar.currentHeight??t.top;return{top:n,bottom:Math.max(o-n,t.bottom)}};export const useModalInsets=()=>{const{top:t,bottom:e}=useSafeAreaInsets();return useState(()=>translucentWindowInsets({top:t,bottom:e}))};export const InsetsProbe=({onChange:t})=>{const{top:e,bottom:s}=useSafeAreaInsets();return useEffect(()=>{t(t=>t.top===e&&t.bottom===s?t:{top:e,bottom:s})},[e,s,t]),null};export const ModalSafeArea=({onInsets:t,children:e})=>{const s=useSafeAreaInsets(),[o]=useState(()=>{const{top:t,bottom:e}=translucentWindowInsets({top:s.top,bottom:s.bottom}),{width:o,height:n}=Dimensions.get("android"===Platform.OS?"screen":"window");return{frame:{x:0,y:0,width:o,height:n},insets:{top:t,bottom:e,left:s.left,right:s.right}}});return _jsxs(SafeAreaProvider,{style:styles.fill,initialMetrics:o,children:[_jsx(InsetsProbe,{onChange:t}),e]})};const styles=StyleSheet.create({fill:{flex:1}});
@@ -1 +1 @@
1
- "use strict";import{cloneElement,isValidElement}from"react";import{FlatList,StyleSheet}from"react-native";import{useRefreshControl}from"../../hooks/useRefreshControl.js";import{useMobileUiText}from"../../text/index.js";import{ASYNC_BLOCK_TEXT}from"../../text/phone/asyncBlock.g.js";import{AsyncBlock}from"../AsyncBlock/index.js";import{EmptyState}from"../EmptyState/index.js";import{PagedListFooter}from"../PagedListFooter/index.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const noop=()=>{},styles=StyleSheet.create({flex:{flex:1},grow:{flexGrow:1}}),isElementFooter=e=>isValidElement(e);function renderFooter(e){if(null==e)return null;if(isElementFooter(e))return e;return _jsx(e,{})}export function PagedList(e){const{state:t,paging:o,empty:r,skeleton:s,errorTitle:n,data:i,placeholderStyle:l,onRefresh:a,refreshing:m,progressViewOffset:d,ref:f,onEndReached:p,ListFooterComponent:c,style:y,contentContainerStyle:h,...x}=e,u=useMobileUiText("asyncBlock",ASYNC_BLOCK_TEXT),g="data"===t?.status||"empty"===t?.status?t:void 0,{refreshControl:j}=useRefreshControl({onRefresh:g?g.refresh:a??noop,refreshing:g?g.refreshing:m}),E=a||g?void 0===d?j:cloneElement(j,{progressViewOffset:d}):void 0,handleEndReached=e=>{o?.hasMore&&!o.loadingMore&&null==o.errorMore&&o.loadMore(),p?.(e)},renderList=(e,t)=>_jsx(FlatList,{data:e,keyboardShouldPersistTaps:"handled",onEndReachedThreshold:o?.5:void 0,...x,ref:f,refreshControl:E,onEndReached:o?handleEndReached:p,ListEmptyComponent:t,ListFooterComponent:o||c?_jsxs(_Fragment,{children:[renderFooter(c),o?_jsx(PagedListFooter,{paging:o}):null]}):void 0,style:[styles.flex,y],contentContainerStyle:[h,t?styles.grow:void 0]});return"empty"===t?.status?renderList([],_jsx(EmptyState,{...r??{title:u.emptyTitle}})):t?_jsx(AsyncBlock,{state:t,skeleton:s,errorTitle:n,style:[styles.flex,l],children:e=>renderList(e,void 0)}):renderList(i,r?_jsx(EmptyState,{...r}):void 0)}
1
+ "use strict";import{cloneElement,isValidElement}from"react";import{FlatList,StyleSheet}from"react-native";import{useRefreshControl}from"../../hooks/useRefreshControl.js";import{useMobileUiText}from"../../text/index.js";import{ASYNC_BLOCK_TEXT}from"../../text/phone/asyncBlock.g.js";import{AsyncBlock}from"../AsyncBlock/index.js";import{EmptyState}from"../EmptyState/index.js";import{PagedListFooter}from"../PagedListFooter/index.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const noop=()=>{},styles=StyleSheet.create({flex:{flex:1},grow:{flexGrow:1}}),isElementFooter=e=>isValidElement(e);function renderFooter(e){if(null==e)return null;if(isElementFooter(e))return e;return _jsx(e,{})}export function PagedList(e){const{state:t,paging:o,empty:r,skeleton:s,errorTitle:n,data:l,placeholderStyle:i,onRefresh:a,refreshing:m,progressViewOffset:d,ref:f,onEndReached:p,ListFooterComponent:c,style:y,contentContainerStyle:h,...x}=e,u=useMobileUiText("asyncBlock",ASYNC_BLOCK_TEXT),g="data"===t?.status||"empty"===t?.status?t:void 0,{refreshControl:j}=useRefreshControl({onRefresh:g?g.refresh:a??noop,refreshing:g?g.refreshing:m}),E=a||g?void 0===d?j:cloneElement(j,{progressViewOffset:d}):void 0,handleEndReached=e=>{o?.hasMore&&!o.loadingMore&&null==o.errorMore&&o.loadMore(),p?.(e)},renderList=(e,t)=>_jsx(FlatList,{data:e,keyboardShouldPersistTaps:"handled",onEndReachedThreshold:o?.5:void 0,...x,ref:f,refreshControl:E,onEndReached:o?handleEndReached:p,ListEmptyComponent:t,ListFooterComponent:o||c?_jsxs(_Fragment,{children:[renderFooter(c),o?_jsx(PagedListFooter,{paging:o}):null]}):void 0,style:[styles.flex,y],contentContainerStyle:[h,t?styles.grow:void 0]});return"empty"===t?.status?renderList([],_jsx(EmptyState,{fill:!0,...r??{title:u.emptyTitle}})):t?_jsx(AsyncBlock,{state:t,skeleton:s,errorTitle:n,style:[styles.flex,i],children:e=>renderList(e,void 0)}):renderList(l,r?_jsx(EmptyState,{fill:!0,...r}):void 0)}
@@ -6,7 +6,7 @@ export interface ModalInsets {
6
6
  }
7
7
  /**
8
8
  * Top and bottom insets of the window a native Modal draws in, seeded from the
9
- * app-level provider and corrected once the Modal's own provider reports.
9
+ * window it spans and corrected once the Modal's own provider reports.
10
10
  * Pass the setter to `ModalSafeArea` as `onInsets`.
11
11
  */
12
12
  export declare const useModalInsets: () => [ModalInsets, Dispatch<SetStateAction<ModalInsets>>];
@@ -6,7 +6,7 @@ import type { EmptyStateProps } from "../EmptyState";
6
6
  export type PagedListProps<ItemT> = Omit<FlatListProps<ItemT>, "data" | "refreshControl" | "ListEmptyComponent"> & {
7
7
  /** From usePagedList or useInfiniteDataState: draws PagedListFooter and calls loadMore on end reached. */
8
8
  paging?: PagedListPaging | undefined;
9
- /** Drawn when there are no rows. */
9
+ /** Drawn when there are no rows, centred in the space the list is given (`fill`, unless the screen sets it). */
10
10
  empty?: EmptyStateProps | undefined;
11
11
  skeleton?: React.ReactNode | undefined;
12
12
  errorTitle?: string | undefined;
@@ -6,7 +6,7 @@ export interface ModalInsets {
6
6
  }
7
7
  /**
8
8
  * Top and bottom insets of the window a native Modal draws in, seeded from the
9
- * app-level provider and corrected once the Modal's own provider reports.
9
+ * window it spans and corrected once the Modal's own provider reports.
10
10
  * Pass the setter to `ModalSafeArea` as `onInsets`.
11
11
  */
12
12
  export declare const useModalInsets: () => [ModalInsets, Dispatch<SetStateAction<ModalInsets>>];
@@ -6,7 +6,7 @@ import type { EmptyStateProps } from "../EmptyState/index.js";
6
6
  export type PagedListProps<ItemT> = Omit<FlatListProps<ItemT>, "data" | "refreshControl" | "ListEmptyComponent"> & {
7
7
  /** From usePagedList or useInfiniteDataState: draws PagedListFooter and calls loadMore on end reached. */
8
8
  paging?: PagedListPaging | undefined;
9
- /** Drawn when there are no rows. */
9
+ /** Drawn when there are no rows, centred in the space the list is given (`fill`, unless the screen sets it). */
10
10
  empty?: EmptyStateProps | undefined;
11
11
  skeleton?: React.ReactNode | undefined;
12
12
  errorTitle?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/mobile-ui",
3
- "version": "0.178.1",
3
+ "version": "0.178.2",
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.178.1"
129
+ "@webority/markdown-core": "0.178.2"
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.178.1",
135
- "@webority/mobile-core": "0.178.1",
134
+ "@webority/canvas-kit": "0.178.2",
135
+ "@webority/mobile-core": "0.178.2",
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.178.1",
200
- "@webority/mobile-core": "0.178.1",
199
+ "@webority/canvas-kit": "0.178.2",
200
+ "@webority/mobile-core": "0.178.2",
201
201
  "@webority/mobile-dev": "0.0.0",
202
- "@webority/tokens": "0.178.1",
202
+ "@webority/tokens": "0.178.2",
203
203
  "expo": "58.0.23",
204
204
  "expo-file-system": "58.0.13",
205
205
  "expo-haptics": "58.0.7",