import { getHours } from '@wojtekmaj/date-utils'; import clsx from 'clsx'; import { convert24to12 } from '../shared/dates.js'; import { getAmPmLabels } from '../shared/utils.js'; type AmPmProps = { ariaLabel?: string; autoFocus?: boolean; className: string; disabled?: boolean; inputRef?: React.RefObject; locale?: string; maxTime?: string; minTime?: string; onChange?: (event: React.ChangeEvent & { target: HTMLSelectElement }) => void; onKeyDown?: ( event: React.KeyboardEvent & { target: HTMLSelectElement }, ) => void; required?: boolean; value?: string | null; }; export default function AmPm({ ariaLabel, autoFocus, className, disabled, inputRef, locale, maxTime, minTime, onChange, onKeyDown, required, value, }: AmPmProps): React.ReactElement { const amDisabled = minTime ? convert24to12(getHours(minTime))[1] === 'pm' : false; const pmDisabled = maxTime ? convert24to12(getHours(maxTime))[1] === 'am' : false; const name = 'amPm'; const [amLabel, pmLabel] = getAmPmLabels(locale); return ( ); }