import { jsxs, jsx } from 'react/jsx-runtime';
import { Y as YearlessDateInputWithPicker } from './YearlessDateInputWithPicker-mW5KykHZ.js';
import { useRef, useState, useId, isValidElement } from 'react';
import { F as FieldLabel } from './FieldLabel-DL0D6fvc.js';
import { w as warnDeprecatedErrorUsage } from './utils-pudAMGnO.js';
import { t as textFieldStyles } from './TextField.module-BP-hDP5m.js';
import { c as cx } from './index-SvGbrGuT.js';
import { u as useLayoutPropsUtil } from './useLayoutPropsUtil-loxbyklF.js';
import { c as childrenToString } from './childrenToString-Bz9MqbHb.js';
import { useTrackingId } from './useTrackingId.js';
import { H as Helper } from './Helper-B2UrgJvr.js';

const DateFieldYearless = (props) => {
  const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
  const {
    value,
    defaultValue,
    minDate,
    maxDate,
    unavailable,
    required,
    disablePicker = false,
    mode = "mm/dd",
    error,
    errorAriaLive: _errorAriaLive,
    label,
    moreInfo,
    size,
    disabled,
    loading,
    labelProps,
    warning,
    description,
    id: idProp,
    style,
    disableHint = false,
    onFocus,
    onBlur,
    className,
    onChange,
    ...restProps
  } = componentProps;
  const inputRef = useRef(null);
  const [openInfo, setOpenInfo] = useState(false);
  const handleFocus = (e) => {
    setOpenInfo(true);
    onFocus?.(e);
  };
  const handleBlur = (e) => {
    setOpenInfo(false);
    onBlur?.(e);
  };
  const data = {
    label: childrenToString(props.label),
    labelProps: props.labelProps,
    description: childrenToString(props.description)
  };
  const trackingId = useTrackingId({
    name: "DateFieldYearless",
    data,
    hasOverride: !!props["data-tracking-id"]
  });
  const labelUid = useId();
  const id = idProp ?? labelUid;
  const helperUid = useId();
  warnDeprecatedErrorUsage("DateFieldYearless", error);
  const errorMessages = typeof error === "boolean" || error === void 0 ? void 0 : error;
  const styleCombined = { ...style, ...layoutStyles };
  return /* @__PURE__ */ jsxs(
    "div",
    {
      className: cx(textFieldStyles["textfield"], className),
      "data-anv": "datefield-yearless",
      style: styleCombined,
      children: [
        label && /* @__PURE__ */ jsx(
          FieldLabel,
          {
            moreInfo,
            moreInfoOpen: openInfo,
            required,
            htmlFor: id,
            ...labelProps,
            children: label
          },
          openInfo ? "open" : "closed"
        ),
        /* @__PURE__ */ jsx(
          YearlessDateInputWithPicker,
          {
            ...restProps,
            ref: inputRef,
            mode,
            required,
            minDate,
            maxDate,
            unavailable,
            disablePicker,
            size,
            error: !!error,
            disabled,
            loading,
            id,
            "data-tracking-id": trackingId,
            "aria-describedby": helperUid,
            "aria-invalid": error ? !!error : void 0,
            "aria-label": label ? void 0 : "Select a date",
            value,
            defaultValue,
            onChange,
            onFocus: handleFocus,
            onBlur: handleBlur
          }
        ),
        errorMessages || warning || description || !disableHint && mode ? /* @__PURE__ */ jsx(
          Helper,
          {
            id: helperUid,
            hint: disableHint ? void 0 : `Format: ${mode}`,
            showCounter: false,
            error: typeof errorMessages === "string" || Array.isArray(errorMessages) ? errorMessages : void 0,
            warning,
            errorMessage: isValidElement(errorMessages) ? errorMessages : void 0,
            description
          }
        ) : null
      ]
    }
  );
};
DateFieldYearless.displayName = "DateFieldYearless";

export { DateFieldYearless as D };
//# sourceMappingURL=DateFieldYearless-HNydELvO.js.map
