458 lines
17 KiB
TypeScript
458 lines
17 KiB
TypeScript
// Metro module 4533 (f4534).
|
|
import _slicedToArray from "../../../../_bundle/_slicedToArray";
|
|
import _toArray from "../../../../_bundle/_toArray";
|
|
import { useContext, useRef, useEffect, useLayoutEffect, useState, createContext, memo, useCallback, Suspense } from "react";
|
|
import { ScrollView, View, StyleSheet } from "react-native";
|
|
import { NOOP } from "../../../../_bundle/Module505";
|
|
import { jsx } from "react/jsx-runtime";
|
|
import { createStyles } from "../../Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import * as _TransitionGroup from "../../TransitionGroup/TransitionGroup";
|
|
import { TransitionGroup } from "../../TransitionGroup/TransitionGroup";
|
|
import { useAlertStore, dismissAlert, openAlert } from "./useAlertStore.native";
|
|
import * as _ReanimatedRexport from "../../../../modules/reanimated/ReanimatedRexport";
|
|
import ReanimatedRexport, { useAnimatedStyle, useSharedValue, useAnimatedReaction } from "../../../../modules/reanimated/ReanimatedRexport";
|
|
import { dismissGlobalKeyboard } from "../../../../utils/native/KeyboardManagerUtils";
|
|
import OverlayView from "../../../void/OverlayView/native/OverlayView";
|
|
import { Dialog } from "../../Dialog/native/Dialog.native";
|
|
import { batchUpdates } from "../../../../_bundle/Module705";
|
|
import { Backdrop } from "../../Backdrop/native/Backdrop.native";
|
|
import * as _index_native from "../../../../intl/index.native";
|
|
import { intl } from "../../../../intl/index.native";
|
|
import { AccessibilityPreferencesContext } from "../../../../_bundle/Module3908";
|
|
import useSafeAreaInsets_native from "../../../../modules/safe_area/useSafeAreaInsets.native";
|
|
import { setAccessibilityFocus } from "../../../../modules/a11y/native/setAccessibilityFocus.android";
|
|
import useWindowDimensions_native from "../../../../modules/screen/useWindowDimensions.native";
|
|
import useBackPressHandler from "../../../../modules/routing/native/useBackPressHandler";
|
|
import { Stack } from "../../Stack/native/Stack.native";
|
|
import { Text } from "../../Text/native/Text";
|
|
import * as _spring from "../../../animation/reanimated/spring/spring";
|
|
import { Button } from "../../Button/native/Button.native";
|
|
function $mk74745($env) {
|
|
return () => {
|
|
const r1 = $env.$parent;
|
|
return (0, r1[0])(r1[2][10]).useAlertStore.setState({
|
|
alerts: $env[0]
|
|
});
|
|
};
|
|
}
|
|
let dismissTopAlert, AlertModalBackdrop, AlertModal, useSharedAnimationState, AlertActions, AlertActionButton, useStyles, c2739_14, c2739_15, c2739_16, c2739_17, c2739_18, c2739_19, c2739_22, c2739_24, withAlertModalSpring, c2739_27, c2739_28;
|
|
let env2739 = {};
|
|
const getAlertModalItemKey = function getAlertModalItemKey(a0) {
|
|
return a0.key;
|
|
};
|
|
dismissTopAlert = function dismissTopAlert() {
|
|
let env14309;
|
|
const r5 = env14309 = {
|
|
$parent: env2739
|
|
};
|
|
const r17 = _toArray(useAlertStore.getState().alerts);
|
|
const r11 = r17[0];
|
|
env14309[0] = r17.slice(1);
|
|
if (!(r11 != null && r11.dismissable === false)) {
|
|
dismissAlert(r11?.key);
|
|
batchUpdates($mk74745(r5));
|
|
}
|
|
};
|
|
AlertModalBackdrop = function AlertModalBackdrop() {
|
|
const context = useContext(c2739_16);
|
|
const [sharedTransitionState, sharedVisible] = useSharedAnimationState();
|
|
let c14310_1 = sharedTransitionState;
|
|
let c14310_2 = sharedVisible;
|
|
const alertStore = useAlertStore((a0) => a0.alerts[0]?.dismissable !== false);
|
|
const r26 = function t() {
|
|
return {
|
|
opacity: _spring.withSpring(c14310_2.get(), c2739_14, "animate-always", (a0) => {
|
|
if (a0 === true && c14310_2.get() === 0 && c14310_1.get() === _TransitionGroup.TransitionStates.YEETED) {
|
|
_ReanimatedRexport.runOnJS(context)();
|
|
}
|
|
})
|
|
};
|
|
};
|
|
r26.__closure = {
|
|
withAlertModalSpring,
|
|
sharedVisible,
|
|
sharedTransitionState,
|
|
TransitionStates: _TransitionGroup.TransitionStates,
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
cleanUp: context
|
|
};
|
|
r26.__workletHash = 4470729133936;
|
|
r26.__initData = c2739_22;
|
|
return <Backdrop blur="strong" style={useAnimatedStyle(r26)} onDismiss={alertStore ? dismissTopAlert : null} accessibilityLabel={intl.string(_index_native.t.Xkfav5)} />;
|
|
};
|
|
AlertModal = function AlertModal(props) {
|
|
let height;
|
|
const { header, title, content, actions, extraContent } = props;
|
|
height = void 0;
|
|
const context2 = useContext(c2739_16);
|
|
const context3 = useContext(c2739_17);
|
|
const styles = useStyles();
|
|
const context4 = useContext(c2739_19);
|
|
const enabled = useContext(AccessibilityPreferencesContext).reducedMotion.enabled;
|
|
const ref = useRef(null);
|
|
const sharedValue = useSharedValue(context3);
|
|
const [sharedTransitionState, sharedVisible] = useSharedAnimationState();
|
|
let c14311_6 = sharedTransitionState;
|
|
let c14311_7 = sharedVisible;
|
|
const safeAreaInsets_native = useSafeAreaInsets_native();
|
|
const { top, bottom } = safeAreaInsets_native;
|
|
useEffect(() => {
|
|
if (context3 === 0) {
|
|
setAccessibilityFocus({
|
|
ref,
|
|
delay: 300
|
|
});
|
|
}
|
|
}, [context3]);
|
|
height = useWindowDimensions_native().height;
|
|
const B = function B() {
|
|
let r75, transform;
|
|
const r0 = height - 32;
|
|
const r26 = 2 * Math.max(top, bottom);
|
|
const r16 = c14311_7.get();
|
|
const r17 = function(a0) {
|
|
if (a0 === true && c14311_7.get() === 0 && c14311_6.get() === _TransitionGroup.TransitionStates.YEETED) {
|
|
_ReanimatedRexport.runOnJS(context2)();
|
|
}
|
|
};
|
|
const r36 = {
|
|
position: "absolute",
|
|
opacity: _spring.withSpring(r16, c2739_14, "animate-always", r17),
|
|
zIndex: 10 - sharedValue.get(),
|
|
height: null,
|
|
maxHeight: null,
|
|
transform: null
|
|
};
|
|
const height2 = sharedValue.get() > 0 ? context4.get() : "auto";
|
|
const maxHeight = r0 - r26;
|
|
r36.height = height2;
|
|
r36.maxHeight = maxHeight;
|
|
if (enabled) {
|
|
transform = [];
|
|
} else {
|
|
transform = [{
|
|
scale: _spring.withSpring(c14311_7.get() === 1 ? 1 - 0.1 * sharedValue.get() : 0.7, c2739_14, "animate-always", void 0)
|
|
}, ,];
|
|
if (c14311_7.get() === 1) {
|
|
let r79 = [0, -20, -34][sharedValue.get()];
|
|
if (r79 == null) {
|
|
r79 = -12 * c14311_7.get();
|
|
}
|
|
r75 = r79;
|
|
} else {
|
|
r75 = 50 - 50 * sharedValue.get();
|
|
}
|
|
transform[1] = {
|
|
translateY: _spring.withSpring(r75, c2739_14, "animate-always", void 0)
|
|
};
|
|
}
|
|
r36.transform = transform;
|
|
return r36;
|
|
};
|
|
B.__closure = {
|
|
sharedVisible,
|
|
sharedTransitionState,
|
|
TransitionStates: _TransitionGroup.TransitionStates,
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
cleanUp: context2,
|
|
windowHeight: height,
|
|
ALERT_MODAL_MARGIN: 16,
|
|
safeAreaTop: top,
|
|
safeAreaBottom: bottom,
|
|
withAlertModalSpring,
|
|
sharedIndex: sharedValue,
|
|
sharedTopHeight: context4,
|
|
useReducedMotion: enabled
|
|
};
|
|
B.__workletHash = 655123755546;
|
|
B.__initData = c2739_24;
|
|
const animatedStyle = useAnimatedStyle(B);
|
|
useLayoutEffect(() => {
|
|
sharedValue.set(context3);
|
|
}, [context3, sharedValue]);
|
|
useBackPressHandler(() => {
|
|
let env25243;
|
|
const r5 = env25243 = {
|
|
$parent: env2739
|
|
};
|
|
const r17 = _toArray(useAlertStore.getState().alerts);
|
|
const r11 = r17[0];
|
|
env25243[0] = r17.slice(1);
|
|
if (!(r11 != null && r11.dismissable === false)) {
|
|
dismissAlert(r11?.key);
|
|
batchUpdates($mk74745(r5));
|
|
}
|
|
return true;
|
|
});
|
|
return <ReanimatedRexport.View importantForAccessibility={context3 === 0 ? "auto" : "no-hide-descendants"} accessibilityElementsHidden={context3 !== 0} style={[styles.content, animatedStyle]} onLayout={(event) => {
|
|
context4.set(event.nativeEvent.layout.height);
|
|
}}>
|
|
<ScrollView alwaysBounceVertical={false}>
|
|
<View style={styles.overflow}>
|
|
<Stack spacing={24}>
|
|
{header}
|
|
<Stack spacing={8} style={[styles.body]}>
|
|
<Text ref={ref} variant="heading-lg/bold" accessibilityRole="header" color="mobile-text-heading-primary">{title}</Text>
|
|
{content != null ? content !== "" ? <Text variant="text-md/medium" color="text-default" style={styles.contentText}>{content}</Text> : null : null}
|
|
</Stack>
|
|
{extraContent}
|
|
{actions != null ? <AlertActions>{actions}</AlertActions> : null}
|
|
</Stack>
|
|
</View>
|
|
</ScrollView>
|
|
</ReanimatedRexport.View>;
|
|
};
|
|
useSharedAnimationState = function useSharedAnimationState() {
|
|
const context5 = useContext(c2739_15);
|
|
const context6 = useContext(c2739_16);
|
|
const sharedValue2 = useSharedValue(context5 === _TransitionGroup.TransitionStates.MOUNTED ? 1 : 0);
|
|
const sharedValue3 = useSharedValue(context5);
|
|
useLayoutEffect(() => {
|
|
sharedValue3.set(context5);
|
|
}, [sharedValue2, context5, sharedValue3]);
|
|
const n = () => sharedValue3.get();
|
|
n.__closure = {
|
|
sharedTransitionState: sharedValue3
|
|
};
|
|
n.__workletHash = 14603144870585;
|
|
n.__initData = c2739_27;
|
|
const r38 = function t(a0) {
|
|
if (a0 === _TransitionGroup.TransitionStates.YEETED) {
|
|
if (sharedValue2.get() === 1) {
|
|
sharedValue2.set(0);
|
|
} else {
|
|
_ReanimatedRexport.runOnJS(context6)();
|
|
}
|
|
} else {
|
|
sharedValue2.set(1);
|
|
}
|
|
};
|
|
r38.__closure = {
|
|
TransitionStates: _TransitionGroup.TransitionStates,
|
|
sharedVisible: sharedValue2,
|
|
runOnJS: _ReanimatedRexport.runOnJS,
|
|
cleanUp: context6
|
|
};
|
|
r38.__workletHash = 9486923983340;
|
|
r38.__initData = c2739_28;
|
|
useAnimatedReaction(n, r38);
|
|
return [sharedValue3, sharedValue2];
|
|
};
|
|
AlertActions = function AlertActions(a0) {
|
|
return (0, jsx)(Stack, {
|
|
spacing: 12,
|
|
children: a0.children
|
|
});
|
|
};
|
|
AlertActionButton = function AlertActionButton(props) {
|
|
let env14313 = {
|
|
$parent: env2739
|
|
};
|
|
env14313[0] = props.onPress;
|
|
const { onPress, loading: _loading, ...props2 } = props;
|
|
let loading = props.loading;
|
|
env14313[1] = void 0;
|
|
env14313[2] = void 0;
|
|
const r18 = _slicedToArray(useState(false), 2);
|
|
const r10 = r18[0];
|
|
env14313[1] = r18[1];
|
|
env14313[2] = useContext(c2739_18);
|
|
if (loading == null) {
|
|
loading = r10;
|
|
}
|
|
let c14314_0 = async (c29409_0) => {
|
|
let c29409_3 = 0;
|
|
L16: {
|
|
L15: {
|
|
try {
|
|
const r27 = env14313[0];
|
|
const r28 = r27 == null ? void 0 : r27(c29409_0);
|
|
if (r28 != null && r28 instanceof Promise) {
|
|
(0, env14313[1])(true);
|
|
c29409_3 = 1;
|
|
await r28;
|
|
c29409_3 = 0;
|
|
dismissAlert(env14313[2]);
|
|
break L15;
|
|
}
|
|
dismissAlert(env14313[2]);
|
|
break L16;
|
|
} catch ($e) {
|
|
let r26 = $e;
|
|
if (c29409_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c29409_3 = 0;
|
|
(0, env14313[1])(false);
|
|
} catch ($e) {
|
|
r26 = $e;
|
|
if (c29409_3 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
throw r26;
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
};
|
|
return <Button {...props2} grow loading={loading} onPress={function() {
|
|
return c14314_0.apply(this, arguments);
|
|
}} />;
|
|
};
|
|
useStyles = createStyles({
|
|
root: {
|
|
flex: 1,
|
|
position: "relative",
|
|
justifyContent: "center",
|
|
alignItems: "center",
|
|
paddingHorizontal: 16
|
|
},
|
|
content: {
|
|
backgroundColor: Module712.colors.MOBILE_ALERT_BACKGROUND_DEFAULT,
|
|
margin: 16,
|
|
width: "100%",
|
|
maxWidth: 400,
|
|
height: "100%",
|
|
borderRadius: Module712.radii.xl,
|
|
borderWidth: 1,
|
|
borderColor: Module712.colors.BORDER_SUBTLE,
|
|
...Module712.shadows.SHADOW_TOP_HIGH
|
|
},
|
|
overflow: {
|
|
width: "100%",
|
|
height: "100%",
|
|
overflow: "hidden",
|
|
padding: 24,
|
|
position: "relative"
|
|
},
|
|
body: {
|
|
alignItems: "center"
|
|
},
|
|
contentText: {
|
|
textAlign: "center"
|
|
}
|
|
});
|
|
c2739_14 = {
|
|
overshootClamping: true,
|
|
damping: 35,
|
|
stiffness: 450,
|
|
mass: 0.5,
|
|
restDisplacementThreshold: 0.001
|
|
};
|
|
c2739_15 = createContext(_TransitionGroup.TransitionStates.YEETED);
|
|
c2739_16 = createContext(NOOP);
|
|
c2739_17 = createContext(0);
|
|
c2739_18 = createContext("");
|
|
c2739_19 = createContext(null);
|
|
const r90 = memo(function() {
|
|
let items;
|
|
let sharedValue4, c14315_2;
|
|
let c14316_0;
|
|
const styles = useStyles();
|
|
let c14315_0 = styles;
|
|
const alertStore = useAlertStore((a0) => a0.alerts);
|
|
sharedValue4 = useSharedValue(0);
|
|
c14316_0 = void 0;
|
|
if (alertStore.length === 0) {
|
|
items = [];
|
|
} else {
|
|
items = [{
|
|
type: "backdrop",
|
|
key: "backdrop"
|
|
}];
|
|
c14316_0 = items;
|
|
alertStore.slice(0, 3).forEach((item, a1) => {
|
|
c14316_0.push({
|
|
type: "alert",
|
|
alert: item,
|
|
key: item.key,
|
|
index: a1
|
|
});
|
|
});
|
|
}
|
|
c14315_2 = items;
|
|
useLayoutEffect(() => {
|
|
if (c14315_2.length > 0) {
|
|
dismissGlobalKeyboard();
|
|
}
|
|
}, [items]);
|
|
return (0, jsx)(TransitionGroup, {
|
|
wrapChildren: useCallback((a0) => <OverlayView style={StyleSheet.absoluteFillObject}>
|
|
<Dialog onDismiss={dismissTopAlert}>
|
|
<View style={c14315_0.root} pointerEvents="box-none">
|
|
{a0}
|
|
</View>
|
|
</Dialog>
|
|
</OverlayView>, [styles]),
|
|
items,
|
|
renderItem: useCallback((a0, a1, a2, a3) => (0, jsx)(c2739_19.Provider, {
|
|
value: sharedValue4,
|
|
children: (0, jsx)(c2739_16.Provider, {
|
|
value: a3,
|
|
children: (0, jsx)(c2739_15.Provider, {
|
|
value: a2,
|
|
children: (0, jsx)(c2739_17.Provider, {
|
|
value: a1.type === "alert" ? a1.index : -1,
|
|
children: (0, jsx)(c2739_18.Provider, {
|
|
value: a0,
|
|
children: (0, jsx)(Suspense, {
|
|
fallback: null,
|
|
children: a1.type === "alert" ? a1.alert.node : (0, jsx)(AlertModalBackdrop, {})
|
|
})
|
|
})
|
|
})
|
|
})
|
|
})
|
|
}, a0), [sharedValue4]),
|
|
getItemKey: getAlertModalItemKey
|
|
});
|
|
});
|
|
c2739_22 = {
|
|
code: "function AlertModalNativeTsx1(){const{withAlertModalSpring,sharedVisible,sharedTransitionState,TransitionStates,runOnJS,cleanUp}=this.__closure;return{opacity:withAlertModalSpring(sharedVisible.get(),function(finished){if(finished===true&&sharedVisible.get()===0&&sharedTransitionState.get()===TransitionStates.YEETED){runOnJS(cleanUp)();}})};}"
|
|
};
|
|
c2739_24 = {
|
|
code: "function AlertModalNativeTsx2(){const{sharedVisible,sharedTransitionState,TransitionStates,runOnJS,cleanUp,windowHeight,ALERT_MODAL_MARGIN,safeAreaTop,safeAreaBottom,withAlertModalSpring,sharedIndex,sharedTopHeight,useReducedMotion}=this.__closure;var _CARD_OFFSETS$sharedI;function onComplete(finished){if(finished===true&&sharedVisible.get()===0&&sharedTransitionState.get()===TransitionStates.YEETED){runOnJS(cleanUp)();}}const CARD_OFFSETS=[0,-20,-34];const maxHeight=windowHeight-ALERT_MODAL_MARGIN*2-Math.max(safeAreaTop,safeAreaBottom)*2;return{position:'absolute',opacity:withAlertModalSpring(sharedVisible.get(),onComplete),zIndex:10-sharedIndex.get(),height:sharedIndex.get()>0?sharedTopHeight.get():'auto',maxHeight:maxHeight,transform:useReducedMotion?[]:[{scale:withAlertModalSpring(sharedVisible.get()===1?1-sharedIndex.get()*0.1:0.7)},{translateY:withAlertModalSpring(sharedVisible.get()===1?(_CARD_OFFSETS$sharedI=CARD_OFFSETS[sharedIndex.get()])!==null&&_CARD_OFFSETS$sharedI!==void 0?_CARD_OFFSETS$sharedI:sharedVisible.get()*-12:50-sharedIndex.get()*50)}]};}"
|
|
};
|
|
const withAlertModalSpring2 = function withAlertModalSpring(a0, a1) {
|
|
return _spring.withSpring(a0, c2739_14, "animate-always", a1);
|
|
};
|
|
withAlertModalSpring2.__closure = {
|
|
withSpring: _spring.withSpring,
|
|
MODAL_SPRING: c2739_14
|
|
};
|
|
withAlertModalSpring2.__workletHash = 15556562210180;
|
|
withAlertModalSpring2.__initData = {
|
|
code: "function withAlertModalSpring_AlertModalNativeTsx3(value,callback){const{withSpring,MODAL_SPRING}=this.__closure;return withSpring(value,MODAL_SPRING,'animate-always',callback);}"
|
|
};
|
|
withAlertModalSpring = withAlertModalSpring2;
|
|
c2739_27 = {
|
|
code: "function AlertModalNativeTsx4(){const{sharedTransitionState}=this.__closure;return sharedTransitionState.get();}"
|
|
};
|
|
c2739_28 = {
|
|
code: "function AlertModalNativeTsx5(transitionState){const{TransitionStates,sharedVisible,runOnJS,cleanUp}=this.__closure;if(transitionState===TransitionStates.YEETED){if(sharedVisible.get()===1){sharedVisible.set(0);}else{runOnJS(cleanUp)();}}else{sharedVisible.set(1);}}"
|
|
};
|
|
export { r90 as AlertModalContainer };
|
|
export function useDismissModalCallback() {
|
|
const context7 = useContext(c2739_18);
|
|
return useCallback(() => {
|
|
dismissAlert(context7);
|
|
}, [context7]);
|
|
}
|
|
export { AlertModal };
|
|
export { AlertActions };
|
|
export { AlertActionButton };
|
|
export function showConfirmModal({ key, title, content, confirmText, cancelText = intl.string(_index_native.t["ETE/oC"]), extraContent, variant = "destructive", onConfirm, onCancel, onCloseCallback, dismissable }) {
|
|
openAlert(key, <AlertModal title={title} content={content} extraContent={extraContent} actions={<>
|
|
<AlertActionButton variant={variant} text={confirmText} onPress={onConfirm} />
|
|
<AlertActionButton variant="secondary" text={cancelText} onPress={onCancel} />
|
|
</>} />, onCloseCallback, {
|
|
dismissable
|
|
});
|
|
}
|