Files
discord-decomp/sources/components_native/DatePickerActionSheet.tsx
T
2026-07-28 01:06:53 +03:00

366 lines
20 KiB
TypeScript

/* Metro module 9066; source: components_native/DatePickerActionSheet.tsx; dependencies: [57, 31, 27, 482, 33, 4501, 697, 6597, 4080, 477, 6758, 6806, 9067, 1244, 4570, 4017, 1305, 4504, 4573, 4579, 4048, 8994, 3738, 6275, 9068, 4002, 2] */
import Module00057 from '../by-id/module-00057.js'; /* Metro dependency 57 */
import ReanimatedRexport from '../modules/reanimated/ReanimatedRexport.tsx'; /* Metro dependency 4017 */
import UseTheme from '../hooks/useTheme.tsx'; /* Metro dependency 4048 */
import ActionSheetActionCreators from '../modules/action_sheet/native/ActionSheetActionCreators.tsx'; /* Metro dependency 4080 */
import TextStyles from '../modules/rebrand/native/TextStyles.tsx'; /* Metro dependency 6597 */
import UseStableCallback from '../hooks/useStableCallback.tsx'; /* Metro dependency 8994 */
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactNativeModule from '../by-id/module-00027-ReactNative.js'; /* Metro dependency 27 */
import * as ReactModule from '../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as JsxRuntimeModule from '../by-id/module-00033-JsxRuntime.js'; /* Metro dependency 33 */
import * as PlatformUtilsModule from '../utils/PlatformUtils.tsx'; /* Metro dependency 477 */
import * as ConstantsModule from '../external/discord_common/js/shared/Constants.tsx'; /* Metro dependency 482 */
import * as IndexNativeModule from '../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as NativeModule from '../design/void/native.tsx'; /* Metro dependency 1305 */
import * as ReanimatedRexportModule from '../modules/reanimated/ReanimatedRexport.tsx'; /* Metro dependency 4017 */
import * as TimingModule from '../design/animation/reanimated/timing/timing.tsx'; /* Metro dependency 4504 */
import * as SetAccessibilityFocusAndroidModule from '../modules/a11y/native/setAccessibilityFocus.android.tsx'; /* Metro dependency 4570 */
import * as TextModule from '../design/components/Text/native/Text.tsx'; /* Metro dependency 4573 */
import * as BaseTextButtonNativeModule from '../design/components/Button/native/BaseTextButton.native.tsx'; /* Metro dependency 4579 */
import * as BottomSheetNativeModule from '../design/components/Sheet/native/BottomSheet.native.tsx'; /* Metro dependency 6275 */
import * as BottomSheetTitleHeaderNativeModule from '../design/components/Sheet/native/BottomSheetTitleHeader.native.tsx'; /* Metro dependency 6758 */
import * as ActionSheetHeaderPressableTextNativeModule from '../design/components/Sheet/native/ActionSheetHeaderPressableText.native.tsx'; /* Metro dependency 9067 */
function _fun70841(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#70841, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9251:6, offset: 0x01d0a451, size: 523 bytes, params: 8, frame: 24
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const Fonts = (ConstantsModule).Fonts;
let value = JsxRuntimeModule;
const env0_6 = value.jsx;
const env0_7 = value.jsxs;
value = require(4501) /* metro dependency 4501: createStyles */;
let createStyles = value.createStyles;
const object3 = {'backgroundColor': null, 'padding': 12, 'marginHorizontal': 12};
const BACKGROUND_FEEDBACK_CRITICAL = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_FEEDBACK_CRITICAL;
object3.backgroundColor = BACKGROUND_FEEDBACK_CRITICAL;
object3.borderRadius = (importDefault(697) /* metro dependency 697: native */).radii.sm;
const env0_8 = Reflect.apply(createStyles, value, [{rangeErrorContainer: {justifyContent: 'flex-start'},
rangeError: object3, datetimePickerContainer: {'display': 'flex', 'alignItems': 'center'}}]);
value = require(4501) /* metro dependency 4501: createStyles */;
createStyles = value.createStyles;
const object4 = {};
const DISPLAY_SEMIBOLD = Fonts.DISPLAY_SEMIBOLD;
const TEXT_DEFAULT = (importDefault(697) /* metro dependency 697: native */).colors.TEXT_DEFAULT;
copyDataProperties(object4, TextStyles(DISPLAY_SEMIBOLD, TEXT_DEFAULT, 16), undefined);
const env0_9 = Reflect.apply(createStyles, value, [{footer: {'marginVertical': 6, 'paddingHorizontal': 12,
'display': 'flex', 'flexDirection': 'row', 'justifyContent': 'flex-end'}, actionButtonText: object4,
actionButton: {marginLeft: 24}}]);
object = {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)};}'};
(FileImportTrackerModule).fileFinishedImporting('components_native/DatePickerActionSheet.tsx');
exports.default = DatePickerActionSheet;
function closeActionSheet_70842() { // fn#70842, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9251:689, offset: 0x01d0a65c, size: 37 bytes, params: 1, frame: 11
(ActionSheetActionCreators).hideActionSheet();
}
function ActionSheetHeader({title, handleCancel, handleSubmit}) { // fn#70843, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9251:743, offset: 0x01d0a681, size: 332 bytes, params: 2, frame: 27
var bottomSheetTitleHeader;
var object4;
const ActionSheetHeaderPressableText = (ActionSheetHeaderPressableTextNativeModule).ActionSheetHeaderPressableText;
var object5;
const intl = (IndexNativeModule).intl;
const t = (IndexNativeModule).t;
var object6;
const isAndroid2 = (PlatformUtilsModule).isAndroid();
const BottomSheetTitleHeader = (BottomSheetTitleHeaderNativeModule).BottomSheetTitleHeader;
if (isAndroid2) {
bottomSheetTitleHeader = (
<BottomSheetTitleHeader
title={title}
trailing={((ActionSheetCloseButton) => <ActionSheetCloseButton onPress={handleCancel} />)((require(6806) /* metro dependency 6806: ActionSheetCloseButtonNative */).ActionSheetCloseButton)}
/>
);
} else {
bottomSheetTitleHeader = (
<BottomSheetTitleHeader
title={title}
leading={<ActionSheetHeaderPressableText onPress={handleCancel} label={intl.string(t['ETE/oC'])} />}
trailing={<ActionSheetHeaderPressableText onPress={handleSubmit} label={intl.string(t['R3BPH+'])} />}
/>
);
}
return bottomSheetTitleHeader;
}
function DateRangeError({show, errorText}) { // fn#70844, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9251:1550, offset: 0x01d0a7cd, size: 390 bytes, params: 2, frame: 23
const styles = useStyles();
const value2 = ReactModule.useRef(null);
ReactModule.useEffect(_fun70845, [show]);
const useAnimatedStyle = ReanimatedRexportModule.useAnimatedStyle;
const DateRangeErrorS2 = DateRangeErrorS;
object = {};
const STANDARD_EASING = (NativeModule).STANDARD_EASING;
object.STANDARD_EASING = STANDARD_EASING;
object.show = show;
object.withTiming = (require(4504) /* metro dependency 4504: timing */).withTiming;
DateRangeErrorS2.__closure = object;
DateRangeErrorS2.__workletHash = 11991491746736;
DateRangeErrorS2.__initData = env0_10;
const value3 = Reflect.apply(useAnimatedStyle, ReanimatedRexportModule, [DateRangeErrorS2]);
const View2 = (ReanimatedRexport).View;
const items2 = [styles.rangeErrorContainer, value3];
const r4 = show ? 'auto' : 'no-hide-descendants';
const Text = (TextModule).Text;
return (
<View2
style={items2}
accessibilityElementsHidden={!show}
importantForAccessibility={r4}
>
<View
ref={value2}
accessible
accessibilityRole="alert"
style={styles.rangeError}
>
<Text variant="text-md/medium" color="always-white">
{errorText}
</Text>
</View>
</View2>
);
function _fun70845() { // fn#70845, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9251:1636, offset: 0x01d0a953, size: 59 bytes, params: 1, frame: 13
const value = environment.__proto__;
(SetAccessibilityFocusAndroidModule).setAccessibilityFocus({ref: env0_1,
delay: 200});
}
function DateRangeErrorS() { // fn#70846, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9251:1736, owner: DateRangeError.S, offset: 0x01d0a98e, size: 202 bytes, params: 1, frame: 20
const object = {};
let value = environment.__proto__;
const STANDARD_EASING = (NativeModule).STANDARD_EASING;
object.easing = STANDARD_EASING;
object.duration = show ? 200 : 150;
const object2 = {};
const withTiming = TimingModule.withTiming;
showBinding = show;
const value5 = 0;
object2.opacity = Reflect.apply(withTiming, TimingModule, [showBinding ? 1 : value5, object]);
object2.maxHeight = TimingModule.withTiming(show ? 500 : value5, object);
value = TimingModule;
object2.paddingVertical = value.withTiming(show ? 12 : value5, object);
return object2;
}
}
function ActionSheetFooter({handleCancel, handleSubmit, canSubmit}) { // fn#70847, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9251:2392, offset: 0x01d0aa58, size: 524 bytes, params: 2, frame: 33
var r0;
const BaseTextButton = (BaseTextButtonNativeModule).BaseTextButton;
var object2;
const LegacyText = (NativeModule).LegacyText;
var actionButtonText;
const intl = (IndexNativeModule).intl;
var string;
const t = (IndexNativeModule).t;
var actionButton;
var items2;
const styles = useStyles();
if ((require(477) /* metro dependency 477: PlatformUtils */).isAndroid()) {
var viewBindingProps = {style: styles.footer};
object2 = {'shrink': true, 'size': 'md', 'variant': 'secondary'};
actionButtonText = styles.actionButtonText;
string = intl.string;
object2.textElement = (
<LegacyText style={actionButtonText}>
{Reflect.apply(string, intl, [t['ETE/oC']])}
</LegacyText>
);
object2.accessibilityLabel = intl.string(t['ETE/oC']);
actionButton = styles.actionButton;
object2.style = actionButton;
object2.onPress = handleCancel;
items2 = [
<BaseTextButton {...object2} />,
];
var baseTextButtonProps = {'shrink': true, 'disabled': null, 'size': 'md', 'variant': 'secondary',
disabled: !canSubmit};
actionButtonText = styles.actionButtonText;
string = intl.string;
baseTextButtonProps.textElement = (
<LegacyText style={actionButtonText}>
{Reflect.apply(string, intl, [t['cY+Oob']])}
</LegacyText>
);
baseTextButtonProps.accessibilityLabel = intl.string(t['cY+Oob']);
actionButton = styles.actionButton;
baseTextButtonProps.style = actionButton;
baseTextButtonProps.onPress = handleSubmit;
items2[1] = <BaseTextButton {...baseTextButtonProps} />;
r0 = (
<View {...viewBindingProps}>
{items2}
</View>
);
} else {
r0 = null;
}
return r0;
}
function DatePickerActionSheet({mode, title, startDate, maximumDate, minimumDate, onSubmit, onCancel, requireDateChanged}) { // fn#70848, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9251:3109, offset: 0x01d0ac64, size: 1185 bytes, params: 2, frame: 42
var r8;
var r17;
var r16;
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
var date;
mode = mode === undefined ? 'date' : mode;
let r11 = title !== undefined ? title : intl.string((require(1244) /* metro dependency 1244: indexNative */).t.epc9sr);
const onCancel2 = onCancel;
const isAboveMin2 = isAboveMin;
const isBelowMax2 = isBelowMax;
const styles = useStyles();
if (startDate != null) {
r8 = startDate;
} else {
date = new global.Date();
}
const env0_4 = r8;
let binding = env0_4;
let useState = binding.useState;
const value8 = Reflect.apply(useState, binding, [r8]);
binding = onCancel2;
const value9 = binding(value8, 2);
const property = value9[0];
const env0_6 = value9[1];
const binding2 = env0_4;
useState = binding2.useState;
const value10 = binding(Reflect.apply(useState, binding2, [!requireDateChanged]), 2);
const property2 = value10[0];
const env0_8 = value10[1];
const binding3 = env0_4;
useState = binding3.useState;
const value11 = binding(Reflect.apply(useState, binding3, [true]), 2);
const env0_9 = value11[0];
const env0_10 = value11[1];
const binding4 = env0_4;
useState = binding4.useState;
const value12 = binding(Reflect.apply(useState, binding4, [false]), 2);
const property3 = value12[0];
const env0_11 = value12[1];
const value13 = (UseTheme)();
const env0_12 = env0_4.useRef(property);
if (maximumDate != null) {
date = new global.Date(maximumDate.getFullYear() + 1, 0, 1, 0, -1);
} else {
r17 = undefined;
}
if (minimumDate != null) {
date = new global.Date(minimumDate.getFullYear(), 0, 1, 0);
} else {
r16 = undefined;
}
env0_4.useEffect(_fun70851, [property]);
const value20 = (UseStableCallback)(_fun70852);
const value21 = (UseStableCallback)(_fun70853);
const value22 = (UseStableCallback)(_fun70854);
const BottomSheet = (BottomSheetNativeModule).BottomSheet;
const bottomSheetProps = {onDismiss: onCancel,
header: <ActionSheetHeader title={r11} handleCancel={value20} handleSubmit={value21} />};
r11 = property3 && !isAboveMin2(property);
let formatToPlainString = intl.formatToPlainString;
const FsJO55 = (require(1244) /* metro dependency 1244: indexNative */).t.FsJO55;
const object3 = {};
object3.minDate = (importDefault(3738) /* metro dependency 3738 */)(minimumDate).format('L');
const items2 = [
<DateRangeError show={r11} errorText={Reflect.apply(formatToPlainString, intl, [FsJO55, object3])} />,
];
const r14 = property3 && !isBelowMax2(property);
formatToPlainString = intl.formatToPlainString;
const R7r9VN = (require(1244) /* metro dependency 1244: indexNative */).t.R7r9VN;
const object4 = {};
object4.maxDate = (importDefault(3738) /* metro dependency 3738 */)(maximumDate).format('L');
items2[1] = <DateRangeError show={r14} errorText={Reflect.apply(formatToPlainString, intl, [R7r9VN, object4])} />;
items2[2] = (
<View style={styles.datetimePickerContainer}>
{((Component) => <Component theme={(require(4002) /* metro dependency 4002: shared */).isThemeLight(value13) ? 'light' : 'dark'} date={property} onDateChange={value22} maximumDate={r17} minimumDate={r16} mode={mode} />)(importDefault(9068) /* metro dependency 9068 */)}
</View>
);
items2[3] = (
<ActionSheetFooter
handleCancel={value20}
handleSubmit={value21}
canSubmit={property2}
/>
);
return (
<BottomSheet {...bottomSheetProps}>
{items2}
</BottomSheet>
);
function isAboveMin(a0) { // fn#70849, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9251:3608, owner: DatePickerActionSheet.isAboveMin, offset: 0x01d0b105, size: 49 bytes, params: 2, frame: 11
var r0;
var time;
const value2 = minimumDate == null;
if (value2) {
r0 = value2;
} else {
time = a0.getTime();
minimumDateBinding = minimumDate;
r0 = time >= minimumDateBinding.getTime();
}
return r0;
}
function isBelowMax(a0) { // fn#70850, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9251:3672, owner: DatePickerActionSheet.isBelowMax, offset: 0x01d0b136, size: 49 bytes, params: 2, frame: 11
var r0;
var time;
const value2 = maximumDate == null;
if (value2) {
r0 = value2;
} else {
time = a0.getTime();
maximumDateBinding = maximumDate;
r0 = time <= maximumDateBinding.getTime();
}
return r0;
}
function _fun70851() { // fn#70851, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9251:3749, offset: 0x01d0b167, size: 21 bytes, params: 1, frame: 2
env0_12.current = ReactNativeModule.View;
}
function _fun70852() { // fn#70852, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9251:3789, offset: 0x01d0b17c, size: 52 bytes, params: 1, frame: 10
env0_12.current = env0_4;
if (onCancel != null) {
onCancel();
}
closeActionSheet_70842();
}
function _fun70853() { // fn#70853, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9251:3853, offset: 0x01d0b1b0, size: 104 bytes, params: 1, frame: 14
var onSubmitBinding;
var value2;
if (env0_7 && env0_9) {
onSubmitBinding = onSubmit;
value2 = environment.__proto__;
onSubmitBinding((importDefault(3738) /* metro dependency 3738 */)(env0_12.current));
}
if (env0_9) {
value = environment.__proto__;
closeActionSheet_70842();
} else {
env0_11(true);
}
}
function _fun70854(a0) { // fn#70854, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9251:3937, offset: 0x01d0b218, size: 103 bytes, params: 2, frame: 14
if (a0 != null) {
if (!(minimumDate == null && maximumDate == null)) {
env0_10(isAboveMin(a0) && isBelowMax(a0));
}
env0_11(false);
env0_8(true);
env0_6(a0);
}
}
}
}
global.__d(_fun70841, 9066, [57, 31, 27, 482, 33, 4501, 697, 6597, 4080, 477, 6758, 6806, 9067, 1244, 4570, 4017,
1305, 4504, 4573, 4579, 4048, 8994, 3738, 6275, 9068, 4002,
2]) /* metro module 9066, dependencies: [57, 31, 27, 482, 33, 4501, 697, 6597, 4080, 477, 6758, 6806, 9067, 1244, 4570, 4017, 1305, 4504, 4573, 4579, 4048, 8994, 3738, 6275, 9068, 4002, 2] */;