PageSourceSearch

https://app.sundaysky.com/client/useTextField.CHRha60e.js

js sundaysky.com collected 2026-10-01 08:42:06 UTC 2,431 bytes, 64 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9f746a80-abb1-52f4-9433-2cb199ee6973")}catch(e){}}();
3import { o as __toESM } from "./rolldown-runtime.D1cXj70v.js";
4import { dt as require_react } from "./vendor~index~newNavigation~AccountTierManagementPage~AdminContainer~AISystemPromptManager~C~h0mf93xb.B-8UGg7U.js";
5//#region client/utils/hooks/useTextField.ts
6var import_react = /* @__PURE__ */ __toESM(require_react());
7var useTextField = (props) => {
8	const cleanInitialValue = props.initialValue || "";
9	const [value, setValue] = (0, import_react.useState)(cleanInitialValue);
10	const [isDirty, setDirty] = (0, import_react.useState)(!!cleanInitialValue);
11	const [errorText, setErrorText] = (0, import_react.useState)(props.validate?.(cleanInitialValue));
12	const inputRef = (0, import_react.useRef)();
13	(0, import_react.useEffect)(() => setValue(cleanInitialValue), [setValue, cleanInitialValue]);
14	(0, import_react.useEffect)(() => setErrorText(props.validate?.(value)), [setErrorText, value]);
15	(0, import_react.useEffect)(() => {
16		if (props.validateEachRender) setErrorText(props.validate?.(value));
17	});
18	const handleChange = (0, import_react.useCallback)((e) => {
19		setDirty(true);
20		setValue(e.target.value);
21	}, [setDirty, setValue]);
22	const handleInvalid = (0, import_react.useCallback)((e) => {
23		e.preventDefault();
24		setDirty(true);
25	}, [setDirty]);
26	const handleBlur = (0, import_react.useCallback)(() => {
27		setDirty(true);
28	}, [setDirty]);
29	const reset = (0, import_react.useCallback)(() => {
30		setValue(cleanInitialValue);
31		setDirty(!!cleanInitialValue);
32		setErrorText(props.validate?.(cleanInitialValue));
33	}, [
34		cleanInitialValue,
35		setValue,
36		setDirty,
37		setErrorText
38	]);
39	return {
40		value,
41		setValue,
42		isDirty,
43		setDirty,
44		errorText,
45		setErrorText,
46		isValid: !isDirty || !errorText,
47		reset,
48		focus: () => inputRef?.current?.focus(),
49		textFieldProps: {
50			value,
51			helperText: isDirty && errorText || " ",
52			error: isDirty && !!errorText,
53			inputRef,
54			onChange: handleChange,
55			onInvalid: handleInvalid,
56			onBlur: handleBlur
57		}
58	};
59};
60//#endregion
61export { useTextField as t };
62
63//# sourceMappingURL=useTextField.CHRha60e.js.map
64//# debugId=9f746a80-abb1-52f4-9433-2cb199ee6973

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.