decord/source/design/void/InputView/native/InputView.tsx

421 lines
16 KiB
TypeScript
Raw Normal View History

2026-09-03 10:05:34 +00:00
// Module ID: 14063
// Function ID: 14064
2026-07-29 08:29:29 +00:00
// Name: Fonts
2026-09-03 10:05:34 +00:00
// Dependencies: [109, 19, 17, 673, 21, 4478, 709, 5393, 4204, 1296, 4474, 1233, 6235, 1362, 11972, 1234, 2]
2026-07-23 10:11:24 +00:00
2026-09-03 10:05:34 +00:00
// Module 14063 (Fonts)
2026-09-02 09:53:35 +00:00
import ThemesDefault from "Themes" /* 709 */;
import getSystemLocale from "getSystemLocale" /* 1233 */;
import set from "set" /* 1234 */;
import Button from "Button" /* 1296 */;
import AccessibilityAnnouncer from "AccessibilityAnnouncer" /* 1362 */;
2026-09-01 10:26:29 +00:00
import Text from "Text" /* 4474 */;
2026-09-03 10:05:34 +00:00
import CircleXIcon from "CircleXIcon" /* 6235 */;
import BottomSheetTextInputDefault from "BottomSheetTextInput" /* 11972 */;
2026-08-24 06:08:38 +00:00
import closure_4 from "_objectWithoutProperties" /* 109 */;
import get_ActivityIndicator from "get ActivityIndicator" /* 17 */;
2026-09-02 09:53:35 +00:00
import { Fonts } from "ME" /* 673 */;
2026-08-24 06:08:38 +00:00
import jsxProd from "jsxProd" /* 21 */;
2026-09-01 10:26:29 +00:00
import createCacheKey from "createCacheKey" /* 4478 */;
2026-08-24 06:08:38 +00:00
import importAllResult from "noop" /* 19 */;
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-23 10:11:24 +00:00
let closure_3 = ["numberOfLines", "disableConstantNumberOfLines", "inputTextColor", "placeholder", "placeholderTextColor", "editable", "large", "accessibilityHint", "maxLength", "inActionSheet", "trailingButton", "clearButtonVisibility", "disabled", "style", "inputTextStyle", "onChangeText", "onFocus", "value"];
2026-07-29 08:29:29 +00:00
({ View: c5, Pressable: closure_6, TouchableWithoutFeedback: error, Platform } = get_ActivityIndicator);
({ jsx: c9, jsxs: c10 } = jsxProd);
createCacheKey = { disabled: { opacity: 0.5 }, topContainer: { minHeight: 16, alignItems: "center", flexDirection: "row", marginBottom: 5, flexWrap: "wrap" }, inputViewTitle: { marginRight: 5 }, inputViewError: null, inputBorder: null, inputView: null, inputViewBorder: null, inputViewBorderActive: null, inputContainer: null, bottomContainer: null, charactersLength: null, closeIcon: null, clearButton: null, required: null };
2026-08-24 06:08:38 +00:00
createCacheKey = { fontSize: 10, color: ThemesDefault.unsafe_rawColors.RED_400 };
2026-07-29 08:29:29 +00:00
createCacheKey[3] = createCacheKey;
2026-08-24 06:08:38 +00:00
createCacheKey[4] = { backgroundColor: ThemesDefault.colors.TEXT_MUTED };
let obj1 = { backgroundColor: ThemesDefault.colors.TEXT_MUTED };
2026-07-29 08:29:29 +00:00
createCacheKey[5] = { fontSize: 16, paddingBottom: 0, paddingTop: 0, textAlignVertical: "top", flex: 1, color: require("result").DARK_PRIMARY_100_LIGHT_PRIMARY_500 };
createCacheKey[6] = { marginTop: 8, height: 2 };
2026-07-23 10:11:24 +00:00
let obj2 = { fontSize: 16, paddingBottom: 0, paddingTop: 0, textAlignVertical: "top", flex: 1, color: require("result").DARK_PRIMARY_100_LIGHT_PRIMARY_500 };
2026-08-24 06:08:38 +00:00
createCacheKey[7] = { backgroundColor: ThemesDefault.unsafe_rawColors.TRANSPARENT };
2026-07-29 08:29:29 +00:00
createCacheKey[8] = { flexDirection: "row", alignItems: "center", position: "relative" };
createCacheKey[9] = { marginTop: 5 };
2026-08-24 06:08:38 +00:00
let obj3 = { backgroundColor: ThemesDefault.unsafe_rawColors.TRANSPARENT };
2026-07-29 08:29:29 +00:00
createCacheKey[10] = { alignSelf: "flex-end", fontFamily: Fonts.CODE_BOLD, color: require("result").DARK_PRIMARY_400_LIGHT_PRIMARY_300 };
2026-07-23 10:11:24 +00:00
let obj4 = { alignSelf: "flex-end", fontFamily: Fonts.CODE_BOLD, color: require("result").DARK_PRIMARY_400_LIGHT_PRIMARY_300 };
2026-08-24 06:08:38 +00:00
createCacheKey[11] = { tintColor: ThemesDefault.colors.INTERACTIVE_TEXT_DEFAULT };
2026-07-29 08:29:29 +00:00
createCacheKey[12] = { position: "absolute", right: 6 };
2026-08-24 06:08:38 +00:00
let obj5 = { tintColor: ThemesDefault.colors.INTERACTIVE_TEXT_DEFAULT };
createCacheKey[13] = { color: ThemesDefault.unsafe_rawColors.RED_400 };
let closure_11 = createCacheKey.createLegacyClassComponentStyles(createCacheKey);
2026-07-20 16:05:17 +00:00
const obj7 = { NEVER: "never", WITH_CONTENT: "with-content", ALWAYS: "always" };
2026-07-29 08:29:29 +00:00
const PureComponent = importAllResult.PureComponent;
class InputView extends PureComponent {
constructor() {
applyArgumentsResult = HermesBuiltin.applyArguments(new.target, new.target);
closure_0 = applyArgumentsResult;
applyArgumentsResult.state = { active: false, value: applyArgumentsResult.props.value, valueProp: applyArgumentsResult.props.value };
applyArgumentsResult._ref = undefined;
applyArgumentsResult.handleFocus = function handleFocus() {
const onFocus = applyArgumentsResult.props.onFocus;
if (onFocus != null) {
onFocus();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
applyArgumentsResult.setState({ active: true });
};
applyArgumentsResult.handleBlur = function handleBlur() {
applyArgumentsResult.setState({ active: false });
};
applyArgumentsResult.handleChangeText = function handleChangeText(value) {
value.setState({ value }, () => {
const onChangeText = value.props.onChangeText;
if (onChangeText != null) {
onChangeText(value);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
});
};
applyArgumentsResult.handleClear = function handleClear() {
applyArgumentsResult.handleChangeText("");
};
applyArgumentsResult.handleEndEditing = function handleEndEditing() {
const onEnd = applyArgumentsResult.props.onEnd;
if (onEnd != null) {
onEnd(applyArgumentsResult.state.value);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult.handleSubmitEditing = function handleSubmitEditing() {
const onNext = applyArgumentsResult.props.onNext;
if (onNext != null) {
onNext();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult.getText = function getText() {
return applyArgumentsResult.state.value;
};
applyArgumentsResult.isFocused = function isFocused() {
const _ref = applyArgumentsResult._ref;
let flag;
if (_ref != null) {
flag = _ref.isFocused();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (flag == null) {
flag = false;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return flag;
};
applyArgumentsResult.focus = function focus() {
const _ref = applyArgumentsResult._ref;
if (_ref != null) {
_ref.focus();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult.blur = function blur() {
const _ref = applyArgumentsResult._ref;
if (_ref != null) {
_ref.blur();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult.setText = function setText(arg0) {
const _ref = applyArgumentsResult._ref;
if (_ref != null) {
const obj = { text: null };
obj[0] = arg0;
_ref.setNativeProps(obj);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult.setRef = function setRef(_ref) {
closure_0._ref = _ref;
};
applyArgumentsResult.measure = function measure(arg0) {
const _ref = applyArgumentsResult._ref;
if (_ref != null) {
_ref.measure(arg0);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult.measureInWindow = function measureInWindow(arg0) {
const _ref = applyArgumentsResult._ref;
if (_ref != null) {
_ref.measureInWindow(arg0);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult.measureLayout = function measureLayout(arg0, arg1, arg2) {
const _ref = applyArgumentsResult._ref;
if (_ref != null) {
_ref.measureLayout(arg0, arg1, arg2);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
};
return applyArgumentsResult;
}
}
const prototype = InputView.prototype;
InputView["getDerivedStateFromProps"] = function getDerivedStateFromProps(value, valueProp) {
value = value.value;
if (value !== valueProp.valueProp) {
if (value !== valueProp.value) {
const obj = { value: null, valueProp: null };
obj[0] = value;
obj[1] = value;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return { valueProp: value };
}
};
prototype["renderBorder"] = function renderBorder() {
2026-08-24 06:08:38 +00:00
const tmp = callback4(this.context);
2026-07-29 08:29:29 +00:00
const props = this.props;
let backgroundColor = props.borderColor;
if (props.showBorder) {
if (backgroundColor == null) {
backgroundColor = tmp.inputBorder.backgroundColor;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const items = [tmp.inputViewBorder, , ];
let obj = { backgroundColor: null };
obj[0] = backgroundColor;
items[1] = obj;
let inputViewBorderActive = this.state.active;
if (inputViewBorderActive) {
inputViewBorderActive = tmp.inputViewBorderActive;
}
obj = { style: null };
items[2] = inputViewBorderActive;
obj[0] = items;
return closure_9(closure_5, obj);
} else {
return null;
}
};
prototype["renderTopContainer"] = function renderTopContainer() {
2026-08-24 06:08:38 +00:00
const tmp = callback4(this.context);
2026-07-29 08:29:29 +00:00
const props = this.props;
({ error, title, errorProps, helpText } = props);
let tmp2 = null != error;
({ showTopContainer, errorStyles, required } = props);
if (tmp2) {
tmp2 = "" !== error;
}
let tmp3;
if (tmp2) {
let obj = {};
const merged = Object.assign(errorProps);
const items = [tmp.inputViewError, errorStyles];
obj.style = items;
const items1 = ["(", error, ")"];
obj.children = items1;
2026-08-24 06:08:38 +00:00
tmp3 = callback3(Button.LegacyText, obj);
2026-07-29 08:29:29 +00:00
}
let tmp10 = null != title;
if (tmp10) {
tmp10 = "" !== title;
}
let tmp12Result;
if (tmp10) {
let str5 = "text-default";
if (null !== error) {
str5 = "text-default";
if ("" !== error) {
str5 = "text-feedback-critical";
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
obj = { variant: "heading-md/semibold", color: null, style: null, children: null };
obj[1] = str5;
const items2 = [tmp.inputViewTitle];
obj[2] = items2;
obj[3] = title;
2026-08-24 06:08:38 +00:00
tmp12Result = callback2(Text.Text, obj);
2026-07-29 08:29:29 +00:00
const tmp12 = callback2;
}
let tmp15 = null != helpText;
if (tmp15) {
tmp15 = "" !== helpText;
}
let tmp16;
if (tmp15) {
obj = { variant: "text-xs/medium", children: null };
obj[1] = helpText;
2026-08-24 06:08:38 +00:00
tmp16 = callback2(Text.Text, obj);
2026-07-29 08:29:29 +00:00
}
2026-08-24 06:08:38 +00:00
obj1 = { style: tmp.topContainer, children: null };
2026-07-29 08:29:29 +00:00
const items3 = [tmp12Result, tmp16, , ];
let tmp22 = null == tmp3;
if (tmp22) {
tmp22 = required;
}
if (tmp22) {
const obj2 = { style: null, children: "*" };
obj2[0] = tmp.required;
2026-08-24 06:08:38 +00:00
tmp22 = callback2(Button.LegacyText, obj2);
2026-07-29 08:29:29 +00:00
}
items3[2] = tmp22;
items3[3] = tmp3;
obj1[1] = items3;
return callback3(closure_5, obj1);
};
prototype["renderBottomContainer"] = function renderBottomContainer() {
const self = this;
2026-08-24 06:08:38 +00:00
const tmp = callback4(this.context);
2026-07-29 08:29:29 +00:00
const props = this.props;
const maxLength = props.maxLength;
let tmp2 = null;
if (props.showCharactersRemaining) {
tmp2 = null;
if (null != maxLength) {
let obj = { style: null, children: null };
obj[0] = tmp.bottomContainer;
obj = { accessible: true, style: null, accessibilityLabel: null, children: null };
obj[1] = tmp.charactersLength;
2026-08-24 06:08:38 +00:00
const intl = getSystemLocale.intl;
2026-07-29 08:29:29 +00:00
obj = { remainingCharacters: null };
obj[0] = maxLength - self.getText().length;
2026-08-24 06:08:38 +00:00
obj[2] = intl.formatToPlainString(getSystemLocale.t.fR1cof, obj);
2026-07-29 08:29:29 +00:00
obj[3] = maxLength - self.getText().length;
2026-08-24 06:08:38 +00:00
obj[1] = callback2(Button.LegacyText, obj);
2026-07-29 08:29:29 +00:00
tmp2 = callback2(closure_5, obj);
}
}
return tmp2;
};
prototype["renderTrailingButton"] = function renderTrailingButton() {
const self = this;
({ trailingButton, clearButtonVisibility, clearButtonAccessibilityLabel } = this.props);
if (null == trailingButton) {
if (clearButtonVisibility === obj7.ALWAYS) {
const obj = { hitSlop: 16, style: null, onPress: null, accessible: true, accessibilityRole: "button", accessibilityLabel: null, children: null };
obj[1] = tmp.clearButton;
obj[2] = self.handleClear;
if (clearButtonAccessibilityLabel == null) {
2026-08-24 06:08:38 +00:00
const intl = getSystemLocale.intl;
clearButtonAccessibilityLabel = intl.string(getSystemLocale.t.VkKicb);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[5] = clearButtonAccessibilityLabel;
2026-08-24 06:08:38 +00:00
obj[6] = closure_9(CircleXIcon.CircleXIcon, { size: "sm" });
2026-07-29 08:29:29 +00:00
let tmp3Result = tmp3(closure_6, obj);
const tmp4 = closure_6;
} else {
tmp3Result = null;
if (clearButtonVisibility === tmp9.WITH_CONTENT) {
tmp3Result = null;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
trailingButton = tmp3Result;
}
return trailingButton;
};
prototype["renderTextView"] = function renderTextView() {
const self = this;
const props = this.props;
({ numberOfLines, inputTextColor, placeholder, placeholderTextColor, large, maxLength, trailingButton, clearButtonVisibility, style, onChangeText, onFocus, value } = props);
({ disableConstantNumberOfLines, editable, accessibilityHint, inActionSheet, disabled, inputTextStyle } = props);
const tmp2 = callback(props, closure_3);
2026-08-24 06:08:38 +00:00
const items = [callback4(this.context).inputView, , , , ];
2026-07-29 08:29:29 +00:00
if (disableConstantNumberOfLines) {
let num2 = 21;
if (large) {
num2 = 30;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let obj = { maxHeight: null };
obj[0] = num2 * numberOfLines;
} else {
let num = 21;
if (large) {
num = 30;
}
obj = { minHeight: null };
obj[0] = num * numberOfLines;
}
items[1] = obj;
if (null != inputTextColor) {
obj = { color: null };
obj[0] = inputTextColor;
2026-08-24 06:08:38 +00:00
obj1 = obj;
2026-07-29 08:29:29 +00:00
} else {
obj1 = {};
}
items[2] = obj1;
if (large) {
const obj2 = { fontSize: 25, fontFamily: null };
obj2[1] = Fonts.PRIMARY_SEMIBOLD;
let obj3 = obj2;
} else {
obj3 = {};
}
items[3] = obj3;
items[4] = inputTextStyle;
if (placeholderTextColor != null) {
let formatToPlainStringResult;
if (null != maxLength) {
2026-08-24 06:08:38 +00:00
const intl = getSystemLocale.intl;
2026-07-29 08:29:29 +00:00
const obj4 = { maxLength: null };
obj4[0] = maxLength;
2026-08-24 06:08:38 +00:00
formatToPlainStringResult = intl.formatToPlainString(getSystemLocale.t["+DFxLc"], obj4);
2026-07-29 08:29:29 +00:00
}
const items1 = [formatToPlainStringResult, accessibilityHint];
const _Boolean = Boolean;
const found = items1.filter(Boolean);
const joined = found.join(",");
if (inActionSheet) {
2026-08-24 06:08:38 +00:00
let TextInput = BottomSheetTextInputDefault;
2026-07-29 08:29:29 +00:00
} else {
2026-08-24 06:08:38 +00:00
TextInput = Button.TextInput;
2026-07-29 08:29:29 +00:00
}
const obj5 = { accessibilityState: null, style: null, ref: null, onChangeText: null, onFocus: null, onBlur: null, onEndEditing: null, onSubmitEditing: null, value: null, clearButtonMode: "never", placeholder: null, placeholderTextColor: null, editable: null, maxLength: null, accessibilityHint: null };
let obj6 = { disabled: null };
obj6[0] = disabled;
obj5[0] = obj6;
obj5[1] = items;
({ setRef: obj10[2], handleChangeText: obj10[3], handleFocus: obj10[4], handleBlur: obj10[5], handleEndEditing: obj10[6], handleSubmitEditing: obj10[7] } = self);
obj5[8] = this.state.value;
obj5[10] = placeholder;
obj5[11] = placeholderTextColor;
obj5[12] = editable;
obj5[13] = maxLength;
obj5[14] = joined;
const merged = Object.assign(tmp2);
return closure_9(TextInput, obj5);
} else {
2026-08-24 06:08:38 +00:00
obj6 = AccessibilityAnnouncer;
const unsafe_rawColors = ThemesDefault.unsafe_rawColors;
2026-07-29 08:29:29 +00:00
const isThemeDarkResult = obj6.isThemeDark(self.context.theme);
}
};
prototype["render"] = function render() {
const self = this;
2026-08-24 06:08:38 +00:00
const tmp = callback4(this.context);
2026-07-29 08:29:29 +00:00
const props = this.props;
const disabled = props.disabled;
let obj = { accessible: false, onPress: this.focus, children: null };
const items = [props.style, ];
let disabled2 = disabled;
if (disabled) {
disabled2 = tmp.disabled;
}
obj = { style: items, pointerEvents: null, children: null };
items[1] = disabled2;
let str = "auto";
if (disabled) {
str = "none";
}
obj[1] = str;
const items1 = [self.renderTopContainer(), , , , ];
obj = { style: items2, children: null };
items2 = [tmp.inputContainer, props.inputContainerStyle];
const items3 = [self.renderTextView(), self.renderTrailingButton()];
obj[1] = items3;
items1[1] = closure_10(closure_5, obj);
2026-08-24 06:08:38 +00:00
const obj4 = set;
2026-07-29 08:29:29 +00:00
const tmp2 = closure_9;
const tmp3 = closure_7;
const tmp6 = require;
2026-08-24 06:08:38 +00:00
items1[2] = set.isAndroid() && self.renderBorder();
2026-07-29 08:29:29 +00:00
items1[3] = self.renderBottomContainer();
2026-08-24 06:08:38 +00:00
const tmp8 = set.isAndroid() && self.renderBorder();
const isAndroidResult = set.isAndroid();
2026-07-29 08:29:29 +00:00
let renderBorderResult = !isAndroidResult;
if (!isAndroidResult) {
renderBorderResult = self.renderBorder();
}
items1[4] = renderBorderResult;
obj[2] = items1;
obj[2] = closure_10(closure_5, obj);
return tmp2(tmp3, obj);
};
InputView.contextType = require("ManaContext").ThemeContext;
InputView.defaultProps = { showBorder: true, value: "", returnKeyType: "next", disabled: false, autoFocus: false, multiline: false, numberOfLines: 1, showTopContainer: true, showCharactersRemaining: false, clearButtonVisibility: "never", inActionSheet: false };
2026-08-24 06:08:38 +00:00
let obj6 = { color: ThemesDefault.unsafe_rawColors.RED_400 };
const result = require("set").fileFinishedImporting("design/void/InputView/native/InputView.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default InputView;
2026-07-20 16:05:17 +00:00
export const ClearButtonVisibility = obj7;