207 lines
9.7 KiB
TypeScript
207 lines
9.7 KiB
TypeScript
// Metro module 11340 (f11341).
|
|
import { View } from "react-native";
|
|
import { AppLauncherOptionAutoFocusType } from "../AppLauncherNativeConstants";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import { ApplicationCommandOptionType } from "../../../../flow/Server";
|
|
import AppLauncherChoicesOption from "./choices/AppLauncherChoicesOption";
|
|
import AppLauncherAutocompleteOption from "./autocomplete/AppLauncherAutocompleteOption";
|
|
import AppLauncherTextInputOption from "./text_input/AppLauncherTextInputOption";
|
|
import AppLauncherAttachmentOption from "./attachment/AppLauncherAttachmentOption";
|
|
import AppLauncherBooleanOption from "./boolean/AppLauncherBooleanOption";
|
|
import AppLauncherMentionableOption from "./mentionable/AppLauncherMentionableOption";
|
|
import { MentionableItemTypes } from "./mentionable/AppLauncherMentionableListActionSheet";
|
|
import AutocompleteUtils from "../../../../utils/native/AutocompleteUtils";
|
|
import AppLauncherRoleOption from "./role/AppLauncherRoleOption";
|
|
import AppLauncherUserOption from "./user/AppLauncherUserOption";
|
|
import AppLauncherChannelOption from "./channel/AppLauncherChannelOption";
|
|
import { PressableOpacity } from "../../../../design/void/Pressables/native/Pressables";
|
|
import { CircleXIcon } from "../../../../design/components/Icon/native/redesign/generated/CircleXIcon";
|
|
const useStyles = createStyles({
|
|
dismissableOptionWrapper: {
|
|
flexDirection: "row",
|
|
alignItems: "center"
|
|
},
|
|
optionViewContainer: {
|
|
flex: 1
|
|
},
|
|
dismissButton: {
|
|
marginLeft: 8,
|
|
marginRight: -4,
|
|
padding: 4,
|
|
borderRadius: Module712.radii.round
|
|
},
|
|
option: {
|
|
flex: 1
|
|
}
|
|
});
|
|
export default function AppLauncherCommandOption(props) {
|
|
let r80, r185, styles;
|
|
let option, onStartEditing, onEndEditing2, onOptionValueChange, onPress2, onDismiss;
|
|
L39: {
|
|
option = props.option;
|
|
onStartEditing = props.onStartEditing;
|
|
onEndEditing2 = props.onEndEditing;
|
|
onOptionValueChange = props.onOptionValueChange;
|
|
onPress2 = props.onPress;
|
|
const onPressAttachmentOption = props.onPressAttachmentOption;
|
|
onDismiss = props.onDismiss;
|
|
const { onFocus, channel, autoFocusType, command, optionValues, hasError } = props;
|
|
styles = useStyles();
|
|
const type = option.type;
|
|
if (ApplicationCommandOptionType.STRING !== type && ApplicationCommandOptionType.INTEGER !== type && ApplicationCommandOptionType.NUMBER !== type) {
|
|
if (ApplicationCommandOptionType.ATTACHMENT === type) {
|
|
r80 = <AppLauncherAttachmentOption key={option.name} style={styles.option} option={option} onSelectAttachment={(event) => {
|
|
onEndEditing2(option);
|
|
onOptionValueChange(option, event != null ? [{
|
|
type: "text",
|
|
text: event
|
|
}] : []);
|
|
}} channel={channel} autoFocus={autoFocusType === AppLauncherOptionAutoFocusType.OPTIONAL_OPTION_ADDED} hasError={hasError} onPress={onPressAttachmentOption} />;
|
|
break L39;
|
|
}
|
|
if (ApplicationCommandOptionType.BOOLEAN === type) {
|
|
const r143 = optionValues.current[option.name];
|
|
r80 = <AppLauncherBooleanOption key={option.name} style={styles.option} option={option} initialValue={r143 == null ? void 0 : r143[0]} onPress={(event) => {
|
|
onPress2();
|
|
onEndEditing2(option);
|
|
onOptionValueChange(option, [{
|
|
type: "text",
|
|
text: event.toString()
|
|
}]);
|
|
}} hasError={hasError} />;
|
|
break L39;
|
|
}
|
|
if (ApplicationCommandOptionType.MENTIONABLE === type) {
|
|
const r125 = optionValues.current[option.name];
|
|
r80 = <AppLauncherMentionableOption option={option} initialValue={r125 == null ? void 0 : r125[0]} onMentionablePress={({ mentionable }) => {
|
|
if (mentionable != null) {
|
|
const type = mentionable.type;
|
|
if (MentionableItemTypes.USER === type) {
|
|
onOptionValueChange(option, [{
|
|
type: "userMention",
|
|
userId: mentionable.result.user.id
|
|
}]);
|
|
} else if (MentionableItemTypes.ROLE === type) {
|
|
onOptionValueChange(option, [{
|
|
type: "roleMention",
|
|
roleId: mentionable.result.id
|
|
}]);
|
|
} else if (MentionableItemTypes.GLOBAL === type) {
|
|
const result = mentionable.result;
|
|
if (result.text === AutocompleteUtils.MENTION_EVERYONE().text) {
|
|
onOptionValueChange(option, [{
|
|
type: "textMention",
|
|
text: "@everyone"
|
|
}]);
|
|
} else {
|
|
onOptionValueChange(option, [{
|
|
type: "text",
|
|
text: result.text
|
|
}]);
|
|
}
|
|
}
|
|
} else {
|
|
onOptionValueChange(option, []);
|
|
}
|
|
}} onActionSheetDismiss={() => onEndEditing2(option)} channel={channel} autoFocus={autoFocusType === AppLauncherOptionAutoFocusType.OPTIONAL_OPTION_ADDED} hasError={hasError} onPress={onPress2} />;
|
|
break L39;
|
|
}
|
|
if (ApplicationCommandOptionType.ROLE === type) {
|
|
const r107 = optionValues.current[option.name];
|
|
r80 = <AppLauncherRoleOption key={option.name} style={styles.option} option={option} initialValue={r107 == null ? void 0 : r107[0]} onRolePress={({ role }) => {
|
|
onOptionValueChange(option, role == null ? [] : [{
|
|
type: "roleMention",
|
|
roleId: role.id
|
|
}]);
|
|
}} onActionSheetDismiss={() => {
|
|
onEndEditing2(option);
|
|
}} channel={channel} autoFocus={autoFocusType === AppLauncherOptionAutoFocusType.OPTIONAL_OPTION_ADDED} hasError={hasError} onPress={onPress2} />;
|
|
break L39;
|
|
}
|
|
if (ApplicationCommandOptionType.USER === type) {
|
|
const r88 = optionValues.current[option.name];
|
|
r80 = <AppLauncherUserOption key={option.name} style={styles.option} option={option} initialValue={r88 == null ? void 0 : r88[0]} onUserPress={({ user }) => {
|
|
let r8;
|
|
if (user == null) {
|
|
r8 = [];
|
|
} else {
|
|
let userId = user;
|
|
if (typeof userId !== "string") {
|
|
userId = user.id;
|
|
}
|
|
r8 = [{
|
|
type: "userMention",
|
|
userId
|
|
}];
|
|
}
|
|
onOptionValueChange(option, r8);
|
|
}} onActionSheetDismiss={() => onEndEditing2(option)} channel={channel} autoFocus={autoFocusType === AppLauncherOptionAutoFocusType.OPTIONAL_OPTION_ADDED} hasError={hasError} onPress={onPress2} />;
|
|
break L39;
|
|
}
|
|
if (ApplicationCommandOptionType.CHANNEL === type) {
|
|
const r70 = optionValues.current[option.name];
|
|
r80 = <AppLauncherChannelOption key={option.name} style={styles.option} option={option} initialValue={r70 == null ? void 0 : r70[0]} onChannelPress={({ channel }) => {
|
|
onOptionValueChange(option, channel != null ? [{
|
|
type: "channelMention",
|
|
channelId: channel.id
|
|
}] : []);
|
|
}} onActionSheetDismiss={() => {
|
|
onEndEditing2(option);
|
|
}} channel={channel} autoFocus={autoFocusType === AppLauncherOptionAutoFocusType.OPTIONAL_OPTION_ADDED} hasError={hasError} onPress={onPress2} />;
|
|
break L39;
|
|
}
|
|
return null;
|
|
}
|
|
if (option.choices != null) {
|
|
const r212 = optionValues.current[option.name];
|
|
r185 = <AppLauncherChoicesOption key={option.name} style={styles.option} option={option} initialValue={r212 == null ? void 0 : r212[0]} onSelect={(event) => {
|
|
onEndEditing2(option);
|
|
let text = event?.displayName;
|
|
if (text == null) {
|
|
text = "";
|
|
}
|
|
onOptionValueChange(option, [{
|
|
type: "text",
|
|
text
|
|
}]);
|
|
}} onOpenChoicesSheet={() => {
|
|
onPress2();
|
|
onStartEditing(option);
|
|
}} onDismissChoicesSheet={() => onEndEditing2(option)} autoFocus={autoFocusType === AppLauncherOptionAutoFocusType.OPTIONAL_OPTION_ADDED} hasError={hasError} />;
|
|
} else if (option.autocomplete) {
|
|
const r193 = optionValues.current[option.name];
|
|
r185 = <AppLauncherAutocompleteOption key={option.name} style={styles.option} channel={channel} option={option} activeCommand={command} optionValues={optionValues} initialValue={r193 == null ? void 0 : r193[0]} autoFocus={autoFocusType === AppLauncherOptionAutoFocusType.OPTIONAL_OPTION_ADDED} onSelect={(event) => {
|
|
onEndEditing2(option);
|
|
let text = event?.displayName;
|
|
if (text == null) {
|
|
text = "";
|
|
}
|
|
onOptionValueChange(option, [{
|
|
type: "text",
|
|
text
|
|
}]);
|
|
}} onOpenAutocompleteSheet={() => {
|
|
onPress2();
|
|
onStartEditing(option);
|
|
}} onDismissAutocompleteSheet={() => onEndEditing2(option)} hasError={hasError} />;
|
|
} else {
|
|
const r174 = optionValues.current[option.name];
|
|
r185 = <AppLauncherTextInputOption key={option.name} style={styles.option} option={option} guildId={channel.guild_id} initialValue={r174 == null ? void 0 : r174[0]} onEndEditing={() => onEndEditing2(option)} onChangeText={(a0) => {
|
|
onStartEditing(option);
|
|
onOptionValueChange(option, [{
|
|
type: "text",
|
|
text: a0
|
|
}]);
|
|
}} onFocus={onFocus} autoFocus={[AppLauncherOptionAutoFocusType.FIRST_REQUIRED_OPTION, AppLauncherOptionAutoFocusType.OPTIONAL_OPTION_ADDED].includes(autoFocusType)} hasError={hasError} onPressIn={onPress2} />;
|
|
}
|
|
r80 = r185;
|
|
}
|
|
return onDismiss != null ? <View style={styles.dismissableOptionWrapper}>
|
|
<View style={styles.optionViewContainer}>{r80}</View>
|
|
<PressableOpacity style={styles.dismissButton} onPress={() => onDismiss(option)}>
|
|
<CircleXIcon size="md" />
|
|
</PressableOpacity>
|
|
</View> : r80;
|
|
};
|