decord/source/design/components/TextField/native/useTextField.native.tsx

177 lines
4.3 KiB
TypeScript
Raw Normal View History

// Module ID: 6686
// Function ID: 6687
// Name: useTextField
// Dependencies: [32, 19, 5023, 2]
2026-07-29 08:29:29 +00:00
// Exports: useTextField, useTextFieldState
2026-07-20 16:05:17 +00:00
// Module 6686 (useTextField)
import setAccessibilityFocus from "setAccessibilityFocus" /* 5023 */;
import _slicedToArray from "module_32" /* 32 */;
import noop from "module_19" /* 19 */;
2026-07-20 16:05:17 +00:00
require = fn;
const size = fn(2);
let result = size.fileFinishedImporting("design/components/TextField/native/useTextField.native.tsx");
2026-07-29 08:29:29 +00:00
export const useTextFieldState = function useTextFieldState(onClear) {
({ value, onChange } = onClear);
2026-07-20 16:05:17 +00:00
onClear = onClear.onClear;
2026-07-29 08:29:29 +00:00
let str = first;
if (first == null) {
str = onClear.defaultValue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (str == null) {
str = "";
2026-07-20 16:05:17 +00:00
}
const tmp = _slicedToArray(noop.useState(str), 2);
closure_2 = tmp[1];
2026-07-29 08:29:29 +00:00
if (first == null) {
first = tmp[0];
2026-07-20 16:05:17 +00:00
}
const items = [onChange];
const setTextValue = obj.useCallback((arg0) => {
obj3(arg0);
2026-07-29 08:29:29 +00:00
if (onChange != null) {
2026-07-20 16:05:17 +00:00
onChange(arg0);
}
}, items);
const items1 = [setTextValue, onClear];
return {
2026-07-20 16:05:17 +00:00
value: first,
setTextValue,
clear: noop.useCallback(() => {
2026-07-29 08:29:29 +00:00
callback1("");
if (onClear != null) {
2026-07-20 16:05:17 +00:00
onClear();
}
}, items1),
hasValue: first.length > 0
};
2026-07-29 08:29:29 +00:00
};
export const useTextField = function useTextField(onClear, ref) {
ref = callback1.useRef(null);
onClear = ref;
2026-07-20 16:05:17 +00:00
const items = [ref, onClear.onClear];
const obj2 = {};
2026-07-29 08:29:29 +00:00
const callback = callback1.useCallback(() => {
const current = onClear.current;
if (current != null) {
2026-07-20 16:05:17 +00:00
current.clear();
}
2026-07-29 08:29:29 +00:00
onClear = onChange.onClear;
if (onClear != null) {
2026-07-20 16:05:17 +00:00
onClear();
}
const result = setAccessibilityFocus.setAccessibilityFocus({ ref: onClear });
2026-07-20 16:05:17 +00:00
}, items);
const merged = Object.assign(onClear);
obj2.onClear = callback;
2026-07-29 08:29:29 +00:00
onChange = undefined;
let obj3;
2026-07-29 08:29:29 +00:00
callback1 = undefined;
({ value, onChange } = obj2);
onClear = obj2.onClear;
2026-07-29 08:29:29 +00:00
let str = first;
if (first == null) {
str = obj2.defaultValue;
2026-07-29 08:29:29 +00:00
}
if (str == null) {
str = "";
}
const tmp4 = obj3(callback1.useState(str), 2);
obj3 = tmp4[1];
2026-07-29 08:29:29 +00:00
if (first == null) {
first = tmp4[0];
}
const items1 = [onChange];
callback1 = obj.useCallback((arg0) => {
obj3(arg0);
2026-07-29 08:29:29 +00:00
if (onChange != null) {
onChange(arg0);
}
}, items1);
const items2 = [callback1, onClear];
obj3 = {
2026-07-29 08:29:29 +00:00
value: first,
setTextValue: callback1,
clear: obj.useCallback(() => {
callback1("");
if (onClear != null) {
onClear();
}
}, items2),
hasValue: first.length > 0
};
const items3 = [ref, obj3];
2026-07-29 08:29:29 +00:00
const imperativeHandle = obj.useImperativeHandle(ref, () => ({
2026-07-20 16:05:17 +00:00
blur() {
const current = onClear.current;
2026-07-29 08:29:29 +00:00
if (current != null) {
2026-07-20 16:05:17 +00:00
current.blur();
}
},
focus() {
const current = onClear.current;
2026-07-29 08:29:29 +00:00
if (current != null) {
2026-07-20 16:05:17 +00:00
current.focus();
}
},
isFocused() {
const current = onClear.current;
2026-07-20 16:05:17 +00:00
let isFocusedResult;
2026-07-29 08:29:29 +00:00
if (current != null) {
2026-07-20 16:05:17 +00:00
isFocusedResult = current.isFocused();
}
return true === isFocusedResult;
},
getText() {
return obj3.value;
2026-07-20 16:05:17 +00:00
},
setText(text) {
if ("" === text) {
obj3.clear();
2026-07-20 16:05:17 +00:00
} else {
const current = onClear.current;
2026-07-29 08:29:29 +00:00
if (current != null) {
const obj = { text };
2026-07-20 16:05:17 +00:00
current.setNativeProps(obj);
}
obj3.setTextValue(text);
2026-07-20 16:05:17 +00:00
}
},
measure(arg0) {
const current = onClear.current;
2026-07-29 08:29:29 +00:00
if (current != null) {
2026-07-20 16:05:17 +00:00
current.measure(arg0);
}
},
measureInWindow(arg0) {
const current = onClear.current;
2026-07-29 08:29:29 +00:00
if (current != null) {
2026-07-20 16:05:17 +00:00
current.measureInWindow(arg0);
}
},
measureLayout(arg0, arg1, arg2) {
const current = onClear.current;
2026-07-29 08:29:29 +00:00
if (current != null) {
2026-07-20 16:05:17 +00:00
current.measureLayout(arg0, arg1, arg2);
}
}
2026-07-29 08:29:29 +00:00
}), items3);
const obj4 = { innerRef: ref, state: obj3, inputProps: null };
const obj5 = {};
2026-07-20 16:05:17 +00:00
const merged1 = Object.assign(onClear);
obj5.onChange = undefined;
obj5.onChangeText = obj3.setTextValue;
obj5.editable = !onClear.isDisabled;
2026-07-29 08:29:29 +00:00
const isDisabled = onClear.isDisabled;
let focusable = !isDisabled;
if (!isDisabled) {
focusable = onClear.focusable;
}
obj5.focusable = focusable;
obj5["aria-disabled"] = onClear.isDisabled;
obj4.inputProps = obj5;
return obj4;
2026-07-20 16:05:17 +00:00
};