/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-af8d194 | Cube Dev Team */
import { mergeProps as mergeProps$1 } from "../../../utils/react/mergeProps.js";
import { useProviderProps } from "../../../provider.js";
import { useFieldProps } from "../../form/Form/use-field/use-field-props.js";
import { TextInputBase } from "./TextInputBase.js";
import { castNullableStringValue } from "../../../utils/react/nullableValue.js";
import { forwardRef, useRef } from "react";
import { jsx } from "react/jsx-runtime";
import { useTextField as useTextField$1 } from "react-aria";

//#region src/components/fields/TextInput/TextInput.tsx
const TextInput = forwardRef(function TextInput(props, ref) {
	props = castNullableStringValue(props);
	props = useProviderProps(props);
	props = useFieldProps(props, {
		defaultValidationTrigger: "onBlur",
		valuePropsMapper: ({ value, onChange }) => ({
			onChange,
			value: value?.toString() ?? ""
		})
	});
	let { labelProps: userLabelProps, inputRef: propsInputRef, form, ...restProps } = props;
	let localInputRef = useRef(null);
	let inputRef = propsInputRef ?? localInputRef;
	let { labelProps, inputProps } = useTextField$1(restProps, inputRef);
	const mergedLabelProps = mergeProps$1(labelProps, userLabelProps);
	return /* @__PURE__ */ jsx(TextInputBase, {
		...restProps,
		ref,
		labelProps: mergedLabelProps,
		inputProps,
		inputRef
	});
});
/**
* TextInputs are text inputs that allow users to input custom text entries
* with a keyboard. Various decorations can be displayed around the field to
* communicate the entry requirements.
*/
TextInput.cubeInputType = "Text";

//#endregion
export { TextInput, useTextField$1 as useTextField };
//# sourceMappingURL=TextInput.js.map