186 lines
7.7 KiB
TypeScript
186 lines
7.7 KiB
TypeScript
// Metro module 8253 (f8254).
|
|
import { useRef, useEffect, useState } from "react";
|
|
import { View } from "react-native";
|
|
import { jsx } from "react/jsx-runtime";
|
|
import { createStyles } from "../design/components/Styles/native/createStyles";
|
|
import Module712 from "../_bundle/Module712";
|
|
import ActionSheetActionCreators from "../modules/action_sheet/native/ActionSheetActionCreators";
|
|
import { isAndroid } from "../utils/PlatformUtils";
|
|
import { BottomSheetTitleHeader } from "../design/components/Sheet/native/BottomSheetTitleHeader.native";
|
|
import { ActionSheetCloseButton } from "../design/components/Sheet/native/ActionSheetCloseButton.native";
|
|
import { ActionSheetHeaderPressableText } from "../design/components/Sheet/native/ActionSheetHeaderPressableText.native";
|
|
import { intl, t } from "../intl/index.native";
|
|
import { setAccessibilityFocus } from "../modules/a11y/native/setAccessibilityFocus.android";
|
|
import ReanimatedRexport, { useAnimatedStyle } from "../modules/reanimated/ReanimatedRexport";
|
|
import * as _native from "../design/void/native";
|
|
import * as _timing from "../design/animation/reanimated/timing/timing";
|
|
import { Text } from "../design/components/Text/native/Text";
|
|
import { BaseTextButton } from "../design/components/Button/native/BaseTextButton.native";
|
|
import useTheme from "../hooks/useTheme";
|
|
import useStableCallback from "../hooks/useStableCallback";
|
|
import Module3771 from "../_bundle/Module3771";
|
|
import { BottomSheet } from "../design/components/Sheet/native/BottomSheet.native";
|
|
import getTheme from "../_bundle/getTheme";
|
|
import { isThemeLight } from "../design/shared";
|
|
let useStyles, useStyles2, __initData, DateRangeError, ActionSheetFooter;
|
|
const ActionSheetHeader = function ActionSheetHeader(props) {
|
|
const { title, handleCancel, handleSubmit } = props;
|
|
return isAndroid() ? <BottomSheetTitleHeader title={title} trailing={<ActionSheetCloseButton onPress={handleCancel} />} /> : <BottomSheetTitleHeader title={title} leading={<ActionSheetHeaderPressableText onPress={handleCancel} label={intl.string(t["ETE/oC"])} />} trailing={<ActionSheetHeaderPressableText onPress={handleSubmit} label={intl.string(t["R3BPH+"])} />} />;
|
|
};
|
|
DateRangeError = function DateRangeError(props) {
|
|
const { show, errorText } = props;
|
|
const styles = useStyles();
|
|
const ref = useRef(null);
|
|
useEffect(() => {
|
|
setAccessibilityFocus({
|
|
ref,
|
|
delay: 200
|
|
});
|
|
}, [show]);
|
|
const A = function A() {
|
|
const r7 = {
|
|
easing: _native.STANDARD_EASING,
|
|
duration: show ? 200 : 150
|
|
};
|
|
return {
|
|
opacity: _timing.withTiming(show ? 1 : 0, r7),
|
|
maxHeight: _timing.withTiming(show ? 500 : 0, r7),
|
|
paddingVertical: _timing.withTiming(show ? 12 : 0, r7)
|
|
};
|
|
};
|
|
A.__closure = {
|
|
STANDARD_EASING: _native.STANDARD_EASING,
|
|
show,
|
|
withTiming: _timing.withTiming
|
|
};
|
|
A.__workletHash = 11991491746736;
|
|
A.__initData = __initData;
|
|
return <ReanimatedRexport.View style={[styles.rangeErrorContainer, useAnimatedStyle(A)]} accessibilityElementsHidden={!show} importantForAccessibility={show ? "auto" : "no-hide-descendants"}>
|
|
<View ref={ref} accessible accessibilityRole="alert" style={styles.rangeError}>
|
|
<Text variant="text-md/medium" color="text-overlay-light">{errorText}</Text>
|
|
</View>
|
|
</ReanimatedRexport.View>;
|
|
};
|
|
ActionSheetFooter = function ActionSheetFooter(props) {
|
|
const { handleCancel, handleSubmit, canSubmit } = props;
|
|
const styles2 = useStyles2();
|
|
return isAndroid() ? <View style={styles2.footer}>
|
|
<BaseTextButton shrink size="md" variant="secondary" textElement={<Text variant="text-md/semibold">
|
|
{intl.string(t["ETE/oC"])}
|
|
</Text>} accessibilityLabel={intl.string(t["ETE/oC"])} style={styles2.actionButton} onPress={handleCancel} />
|
|
<BaseTextButton shrink disabled={!canSubmit} size="md" variant="secondary" textElement={<Text variant="text-md/semibold">
|
|
{intl.string(t["cY+Oob"])}
|
|
</Text>} accessibilityLabel={intl.string(t["cY+Oob"])} style={styles2.actionButton} onPress={handleSubmit} />
|
|
</View> : null;
|
|
};
|
|
useStyles = createStyles({
|
|
rangeErrorContainer: {
|
|
justifyContent: "flex-start"
|
|
},
|
|
rangeError: {
|
|
backgroundColor: Module712.colors.BACKGROUND_FEEDBACK_CRITICAL,
|
|
padding: 12,
|
|
marginHorizontal: 12,
|
|
borderRadius: Module712.radii.sm
|
|
},
|
|
datetimePickerContainer: {
|
|
display: "flex",
|
|
alignItems: "center"
|
|
}
|
|
});
|
|
useStyles2 = createStyles({
|
|
footer: {
|
|
marginVertical: 6,
|
|
paddingHorizontal: 12,
|
|
display: "flex",
|
|
flexDirection: "row",
|
|
justifyContent: "flex-end"
|
|
},
|
|
actionButton: {
|
|
marginLeft: 24
|
|
}
|
|
});
|
|
__initData = {
|
|
code: "function DatePickerActionSheetTsx1(){const{STANDARD_EASING,show,withTiming}=this.__closure;const animationSettings={easing:STANDARD_EASING,duration:show?200:150};return{opacity:withTiming(show?1:0,animationSettings),maxHeight:withTiming(show?500:0,animationSettings),paddingVertical:withTiming(show?12:0,animationSettings)};}"
|
|
};
|
|
export default function DatePickerActionSheet(props) {
|
|
const { mode = "date", title = intl.string(t.epc9sr) } = props;
|
|
let startDate = props.startDate;
|
|
const { maximumDate, minimumDate, onSubmit, onCancel, requireDateChanged } = props;
|
|
const styles = useStyles();
|
|
if (startDate == null) {
|
|
startDate = new Date();
|
|
}
|
|
const current = startDate;
|
|
const [state, setState] = useState(current);
|
|
const [state2, setState2] = useState(!requireDateChanged);
|
|
const [state3, setState3] = useState(true);
|
|
let [show2, setState4] = useState(false);
|
|
const theme = useTheme();
|
|
const ref2 = useRef(state);
|
|
const maximumDate2 = maximumDate != null ? new Date(maximumDate.getFullYear() + 1, 0, 1, 0, -1) : void 0;
|
|
const minimumDate2 = minimumDate != null ? new Date(minimumDate.getFullYear(), 0, 1, 0) : void 0;
|
|
useEffect(() => {
|
|
ref2.current = state;
|
|
}, [state]);
|
|
const stableCallback2 = useStableCallback(() => {
|
|
ref2.current = current;
|
|
if (onCancel != null) {
|
|
onCancel();
|
|
}
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
});
|
|
const stableCallback = useStableCallback(() => {
|
|
const current2 = ref2.current;
|
|
let r7 = state2;
|
|
if (state2) {
|
|
r7 = state3;
|
|
}
|
|
if (r7) {
|
|
onSubmit(Module3771(current2));
|
|
}
|
|
if (state3) {
|
|
ActionSheetActionCreators.hideActionSheet();
|
|
} else {
|
|
setState4(true);
|
|
}
|
|
});
|
|
const stableCallback3 = useStableCallback((a0) => {
|
|
if (a0 != null) {
|
|
if (!(minimumDate == null && maximumDate == null)) {
|
|
setState3((minimumDate == null || a0.getTime() >= minimumDate.getTime()) && (maximumDate == null || a0.getTime() <= maximumDate.getTime()));
|
|
}
|
|
setState4(false);
|
|
setState2(true);
|
|
setState(a0);
|
|
}
|
|
});
|
|
const props2 = {
|
|
onDismiss: onCancel,
|
|
header: <ActionSheetHeader title={title} handleCancel={stableCallback2} handleSubmit={stableCallback} />,
|
|
children: null
|
|
};
|
|
const children = [<DateRangeError show={show2 ? !(minimumDate == null || state.getTime() >= minimumDate.getTime()) : show2} errorText={intl.formatToPlainString(t.FsJO55, {
|
|
minDate: Module3771(minimumDate).format("L")
|
|
})} />, , , ,];
|
|
if (show2) {
|
|
show2 = !(maximumDate == null || state.getTime() <= maximumDate.getTime());
|
|
}
|
|
children[1] = <DateRangeError show={show2} errorText={intl.formatToPlainString(t.R7r9VN, {
|
|
maxDate: Module3771(maximumDate).format("L")
|
|
})} />;
|
|
children[2] = <View style={styles.datetimePickerContainer}>
|
|
{jsx(getTheme, {
|
|
theme: isThemeLight(theme) ? "light" : "dark",
|
|
date: state,
|
|
onDateChange: stableCallback3,
|
|
maximumDate: maximumDate2,
|
|
minimumDate: minimumDate2,
|
|
mode
|
|
})}
|
|
</View>;
|
|
children[3] = <ActionSheetFooter handleCancel={stableCallback2} handleSubmit={stableCallback} canSubmit={state2} />;
|
|
props2.children = children;
|
|
return <BottomSheet {...props2} />;
|
|
};
|