import {
  useLabel
} from "./chunk-YLEFK7S2.js";
import {
  spaceDelimitedList
} from "./chunk-DTWRSP5P.js";

// src/hooks/useTextField/useTextField.tsx
import { useId } from "react";
function useTextField(props) {
  const {
    isDisabled = false,
    isReadOnly = false,
    isRequired = false,
    inputElementType = "input"
  } = props;
  const { labelProps, fieldProps } = useLabel(props);
  const descriptionId = useId();
  const descriptionProps = { id: descriptionId };
  const errorMessageId = useId();
  const errorMessageProps = { id: errorMessageId };
  const ariaDescribedBy = spaceDelimitedList([
    props.description && descriptionId,
    props.errorMessage && errorMessageId,
    props["aria-describedby"]
  ]);
  return {
    descriptionProps,
    errorMessageProps,
    labelProps,
    inputProps: {
      defaultValue: props.defaultValue,
      value: props.value,
      onChange: props.onChange,
      disabled: isDisabled,
      readOnly: isReadOnly,
      required: isRequired,
      "aria-required": isRequired === true ? true : void 0,
      "aria-invalid": props.isInvalid,
      "aria-describedby": ariaDescribedBy,
      "aria-errormessage": props["aria-errormessage"],
      role: props.role,
      type: inputElementType === "input" ? props.type : void 0,
      pattern: inputElementType === "input" ? props.pattern : void 0,
      autoComplete: props.autoComplete,
      maxLength: props.maxLength,
      minLength: props.minLength,
      name: props.name,
      placeholder: props.placeholder,
      inputMode: props.inputMode,
      // Clipboard events
      onCopy: props.onCopy,
      onCut: props.onCut,
      onPaste: props.onPaste,
      // Composition events
      onCompositionEnd: props.onCompositionEnd,
      onCompositionStart: props.onCompositionStart,
      onCompositionUpdate: props.onCompositionUpdate,
      // Selection events
      onSelect: props.onSelect,
      // Input events
      onBeforeInput: props.onBeforeInput,
      onInput: props.onInput,
      // Focus events
      onFocus: props.onFocus,
      onBlur: props.onBlur,
      ...fieldProps
    }
  };
}

export {
  useTextField
};
//# sourceMappingURL=chunk-UYVF3QSW.js.map
