276 lines
13 KiB
TypeScript
276 lines
13 KiB
TypeScript
/* Metro module 9026; source: modules/phone/native/CodeField.tsx; dependencies: [57, 31, 27, 33, 4501, 697, 1305, 7981, 1244, 4578, 4573, 5467, 2] */
|
|
function _fun70213(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#70213, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9211:6, offset: 0x01cf2a09, size: 601 bytes, params: 8, frame: 25
|
|
const env0_0 = require;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_3 = importDefault(57) /* metro dependency 57 */;
|
|
const env0_4 = importAll(31) /* metro dependency 31 */;
|
|
let value = require(27) /* metro dependency 27 */;
|
|
const env0_5 = value.View;
|
|
const env0_6 = value.ScrollView;
|
|
value = require(33) /* metro dependency 33 */;
|
|
const env0_7 = value.jsx;
|
|
const env0_8 = value.jsxs;
|
|
value = require(4501) /* metro dependency 4501: createStyles */;
|
|
const createStyles = value.createStyles;
|
|
const object = {};
|
|
object.viewWrapper = {flex: 1};
|
|
const BACKGROUND_BASE_LOW = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_BASE_LOW;
|
|
object.background = {backgroundColor: BACKGROUND_BASE_LOW, flex: 1};
|
|
object.backgroundFlex = {'flex': 1, 'justifyContent': 'space-between'};
|
|
object.container = {padding: 16};
|
|
object.title = {textAlign: 'center'};
|
|
object.subtitle = {'marginTop': 8, 'lineHeight': 18, 'textAlign': 'center'};
|
|
object.inputContainer = {'marginTop': 20, 'width': '100%', 'alignItems': 'center'};
|
|
object.codeContainer = {'maxWidth': 336, 'width': '100%', 'flexDirection': 'row', 'justifyContent': 'space-around'};
|
|
object.spacer = {width: 4};
|
|
const object3 = {'borderWidth': 1, 'borderRadius': 5, 'alignItems': 'center'};
|
|
let BACKGROUND_BASE_LOWEST = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_BASE_LOWEST;
|
|
object3.backgroundColor = BACKGROUND_BASE_LOWEST;
|
|
BACKGROUND_BASE_LOWEST = (importDefault(697) /* metro dependency 697: native */).colors.BACKGROUND_BASE_LOWEST;
|
|
object3.borderColor = BACKGROUND_BASE_LOWEST;
|
|
object.inputWrapper = object3;
|
|
const RED_400 = (importDefault(697) /* metro dependency 697: native */).unsafe_rawColors.RED_400;
|
|
object.inputWrapperError = {borderColor: RED_400};
|
|
object.input = {textAlign: 'center'};
|
|
object.singleInputWrapper = {width: '100%'};
|
|
object.singleInputButton = {'marginTop': 8, 'justifyContent': 'flex-end'};
|
|
const env0_10 = Reflect.apply(createStyles, value, [object]);
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/phone/native/CodeField.tsx');
|
|
exports.default = CodeField;
|
|
exports.CodeType = {NUMERIC: 'numeric', ALPHANUMERIC: 'alphanumeric'};
|
|
exports.CodeBlocks = CodeBlocks;
|
|
}
|
|
|
|
function SingleCodeInput({loading, error, count, codeType = env0_9.NUMERIC, onCodeEntered, disabled, code, setCode}) { // fn#70214, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9211:1066, offset: 0x01cf2c62, size: 500 bytes, params: 2, frame: 29
|
|
loading = !(loading === undefined) && loading;
|
|
count = count === undefined ? 6 : count;
|
|
const styles = useStyles();
|
|
const TextInput = (require(7981) /* metro dependency 7981: TextInputNative */).TextInput;
|
|
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
const string = intl.string;
|
|
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
|
|
const NUMERIC = env0_9.NUMERIC;
|
|
const textInput = <TextInput errorMessage={error} value={code} autoCapitalize="characters" maxLength={count} accessibilityLabel={Reflect.apply(string,
|
|
intl,
|
|
[t['ysthA+']])} textContentType="oneTimeCode" keyboardType={codeType !== NUMERIC ? 'default' : 'number-pad'} onChange={onChange_70215} isDisabled={disabled} isClearable autoFocus />;
|
|
const Button = (require(4578) /* metro dependency 4578: ButtonNative */).Button;
|
|
return (
|
|
<View style={styles.singleInputWrapper}>
|
|
{textInput}
|
|
<View style={styles.singleInputButton}>
|
|
<Button
|
|
loading={loading}
|
|
variant="primary"
|
|
size="lg"
|
|
text={intl.string((require(1244) /* metro dependency 1244: indexNative */).t['13ofGu'])}
|
|
onPress={function() {
|
|
return onCodeEntered(code);
|
|
}}
|
|
disabled={code.length !== count || disabled}
|
|
/>
|
|
</View>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
function CodeFieldInner({title, description, error, onCodeEntered, loading, count, codeType = env0_9.NUMERIC, actions, footer, backgroundStyle, disabled}) { // fn#70217, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9211:1783, offset: 0x01cf2ebf, size: 515 bytes, params: 2, frame: 37
|
|
loading = !(loading === undefined) && loading;
|
|
count = count === undefined ? 6 : count;
|
|
const styles = useStyles();
|
|
const [property, property2] = env0_3(env0_4.useState(''), 2);
|
|
const items3 = [styles.background, backgroundStyle];
|
|
const Text = (require(4573) /* metro dependency 4573: Text */).Text;
|
|
const items2 = [<Text style={styles.title} accessibilityRole="header" variant="heading-xl/extrabold" color="mobile-text-heading-primary">{title}</Text>];
|
|
items2[1] = <Text style={styles.subtitle} variant="text-sm/medium" color="text-default">{description}</Text>;
|
|
items2[2] = <View style={styles.inputContainer}><SingleCodeInput loading={loading} error={error} count={count} onCodeEntered={onCodeEntered} codeType={codeType} disabled={disabled} code={property} setCode={property2} /></View>;
|
|
items2[3] = actions;
|
|
return (
|
|
<ScrollView
|
|
style={items3}
|
|
contentContainerStyle={styles.backgroundFlex}
|
|
keyboardShouldPersistTaps="handled"
|
|
alwaysBounceVertical={false}
|
|
>
|
|
<View style={styles.container}>
|
|
{items2}
|
|
</View>
|
|
{((Component) => <Component>{footer}</Component>)(importDefault(5467) /* metro dependency 5467: KeyboardAwareView */)}
|
|
</ScrollView>
|
|
);
|
|
}
|
|
|
|
function CodeField(a0) { // fn#70218, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9211:2661, offset: 0x01cf30c2, size: 123 bytes, params: 2, frame: 19
|
|
const styles = useStyles();
|
|
return a0.disableKeyboardAvoidingView ? <CodeFieldInner {...a0} /> : ((Component) => <Component style={styles.viewWrapper}><CodeFieldInner {...a0} /></Component>)(importDefault(5467) /* metro dependency 5467: KeyboardAwareView */);
|
|
}
|
|
|
|
function CodeBlocks({hasError, onCodeEntered, count, codeType}) { // fn#70219, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9211:2853, offset: 0x01cf313d, size: 362 bytes, params: 2, frame: 22
|
|
var environment;
|
|
var r0;
|
|
var r2;
|
|
var value;
|
|
var NUMERIC;
|
|
var value7;
|
|
reducibleJoin2: while (true) {
|
|
if (count !== undefined) {
|
|
break reducibleJoin2;
|
|
}
|
|
value = 6;
|
|
count = value;
|
|
break reducibleJoin2;
|
|
}
|
|
reducibleJoin4: while (true) {
|
|
if (codeType !== undefined) {
|
|
r0 = codeType;
|
|
break reducibleJoin4;
|
|
}
|
|
value = environment;
|
|
NUMERIC = env0_9.NUMERIC;
|
|
r0 = NUMERIC;
|
|
break reducibleJoin4;
|
|
}
|
|
const env0_3 = r0;
|
|
const styles = useStyles();
|
|
const env0_4 = styles;
|
|
let binding = env0_4;
|
|
const useState = binding.useState;
|
|
let Array = global.Array;
|
|
const value2 = Array(count);
|
|
const value4 = env0_3(Reflect.apply(useState, binding, [value2.fill('')]), 2);
|
|
const property = value4[0];
|
|
const env0_6 = value4[1];
|
|
binding = env0_4;
|
|
const useRef = binding.useRef;
|
|
Array = global.Array;
|
|
const value6 = Array(count);
|
|
const env0_7 = Reflect.apply(useRef, binding, [value6.fill(null)]);
|
|
const env0_8 = env0_4.useRef(onCodeEntered);
|
|
env0_4.useEffect(_fun70220);
|
|
env0_4.useEffect(_fun70221, [property]);
|
|
if (0 < count) {
|
|
r2 = 0;
|
|
reducibleLoop5: while (true) {
|
|
CodeBlocks_loop(r2);
|
|
value7 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
|
|
if (value7 < count) {
|
|
r2 = value7;
|
|
continue reducibleLoop5;
|
|
}
|
|
break reducibleLoop5;
|
|
}
|
|
}
|
|
return <View style={styles.codeContainer} />;
|
|
}
|
|
|
|
function SingleCodeInputOnChange(a0) { // fn#70215, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9211:1482, owner: SingleCodeInput.onChange, offset: 0x01cf2e56, size: 85 bytes, params: 2, frame: 14
|
|
const binding = env0_0;
|
|
const NUMERIC = env1_9.NUMERIC;
|
|
setCode(a0.replace(binding === NUMERIC ? RegExp('\\D', 'g') : RegExp('[^A-Z0-9]', 'g'), ''));
|
|
}
|
|
|
|
function _fun70221() { // fn#70221, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9211:3091, offset: 0x01cf32a7, size: 60 bytes, params: 1, frame: 14
|
|
var current;
|
|
var binding2;
|
|
let binding = env0_5;
|
|
if (((a0) => a0.every(_fun70223))(binding)) {
|
|
binding = env0_8;
|
|
current = binding.current;
|
|
binding2 = env0_5;
|
|
Reflect.apply(current, binding, [binding2.join('')]);
|
|
}
|
|
}
|
|
|
|
function CodeBlocks_loop(a0) { // fn#70224, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9211:3218, owner: CodeBlocks._loop, offset: 0x01cf3313, size: 406 bytes, params: 2, frame: 26
|
|
var environment;
|
|
var binding;
|
|
var push;
|
|
var value2;
|
|
const env0_0 = a0;
|
|
if (a0 === count / 2) {
|
|
binding = env0_9;
|
|
push = binding.push;
|
|
value2 = environment.__proto__;
|
|
Reflect.apply(push, binding, [<View style={styles.spacer} key="spacer" />]);
|
|
}
|
|
binding = env0_9;
|
|
push = binding.push;
|
|
const items2 = [styles.inputWrapper];
|
|
items2[1] = hasError ? styles.inputWrapperError : null;
|
|
const TextInput = (require(1305) /* metro dependency 1305: native */).TextInput;
|
|
const binding2 = env0_3;
|
|
const NUMERIC = env1_9.NUMERIC;
|
|
Reflect.apply(push, binding, [<View style={items2} key={a0}><TextInput ref={ref_70225} style={[{height: 42,
|
|
width: 252 / count}, styles.input]} keyboardType={binding2 !== NUMERIC ? 'default' : 'phone-pad'} autoFocus={a0 === 0} value={env0_5[a0]} onKeyPress={onKeyPress_70226} onChangeText={onChangeText} selection={{start: env0_5[a0].length, end: env0_5[a0].length}} autoCapitalize="characters" autoCorrect={false} /></View>]);
|
|
}
|
|
|
|
function isCodeEntered(a0) { // fn#70222, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9211:3102, offset: 0x01cf32e3, size: 25 bytes, params: 2, frame: 11
|
|
return a0.every(function(a0) {
|
|
return a0.trim() !== '';
|
|
});
|
|
}
|
|
|
|
function _loopRef(a0) { // fn#70225, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9211:3374, owner: CodeBlocks._loop.ref, offset: 0x01cf34a9, size: 30 bytes, params: 2, frame: 3
|
|
env1_7.current[env0_0] = a0;
|
|
}
|
|
|
|
function _loopOnKeyPress(a0) { // fn#70226, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9211:3521, owner: CodeBlocks._loop.onKeyPress, offset: 0x01cf34c7, size: 29 bytes, params: 2, frame: 13
|
|
onKeyPress_body(env0_0, a0);
|
|
}
|
|
|
|
function _loopOnChangeText(a0) { // fn#70228, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9211:3770, owner: CodeBlocks._loop.onChangeText, offset: 0x01cf3587, size: 202 bytes, params: 2, frame: 17
|
|
var r6;
|
|
let value = a0;
|
|
const binding = env0_0;
|
|
if (value[0] !== env1_5[binding]) {
|
|
r6 = value;
|
|
} else {
|
|
value = value.slice(1);
|
|
r6 = value;
|
|
}
|
|
value = r6.replace('-', '');
|
|
value = value.trim();
|
|
value = value.toUpperCase();
|
|
r6 = value !== '' ? value.split('') : [''];
|
|
const binding2 = env1_5;
|
|
const items3 = [];
|
|
arraySpread(items3, binding2, 0, r6);
|
|
const splice = items3.splice;
|
|
const items2 = [binding, 1];
|
|
arraySpread(items2, r6, 2, r6);
|
|
apply(splice, items2, items3, r6);
|
|
env1_6(items3.slice(0, count));
|
|
}
|
|
|
|
function onKeyPress_body(a0, {nativeEvent}) { // fn#70227, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9211:3524, owner: CodeBlocks._loop.onKeyPress.body, offset: 0x01cf34e4, size: 163 bytes, params: 3, frame: 19
|
|
var value;
|
|
var binding;
|
|
var binding2;
|
|
var value2;
|
|
var items2;
|
|
var property;
|
|
if (nativeEvent.key !== 'Backspace') {
|
|
value = environment.__proto__.__proto__;
|
|
property = env2_7.current[a0 + 1];
|
|
if (property != null) {
|
|
property.focus();
|
|
}
|
|
} else {
|
|
value = environment.__proto__.__proto__;
|
|
if (env2_5[a0] === '') {
|
|
binding = env2_6;
|
|
binding2 = env2_5;
|
|
value2 = a0 - 1;
|
|
items2 = [];
|
|
arraySpread(items2, binding2, 0, undefined);
|
|
items2[value2] = '';
|
|
binding(items2);
|
|
property = env2_7.current[a0 - 1];
|
|
if (property != null) {
|
|
property.focus();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|