import { DateInput as ArkDateInput } from "@ark-ui/react/date-input"; import { type DateInputDateValue } from "@ark-ui/react/date-input"; import { injectComponentStyle } from "@bysages/core/styling"; import type { CSSProperties } from "react"; import type { ComponentProps } from "react"; import { useElementId } from "../../internal/id"; export type { DateInputFocusChangeDetails, DateInputValueChangeDetails, } from "@ark-ui/react/date-input"; type DateInputRootProps = ComponentProps & { /** One rung of the control-height ladder for the segmented field. */ size?: "sm" | "md" | "lg"; }; function DateInputRoot(props: DateInputRootProps) { injectComponentStyle("date-input"); const id = useElementId("date-input", props); const { size = "md", ...rest } = props; return ; } /** Ark's DateInput, dressed in the paper-and-ink system: a segmented * field where the focused segment takes the flat ink fill. The API is * Ark's own — Root, Label, Control, SegmentGroup, Segment, SegmentContext, * HiddenInput. */ type DateInputFacadeValue = DateInputDateValue | DateInputDateValue[]; type DateInputFacadeProps = { value?: DateInputFacadeValue; defaultValue?: DateInputFacadeValue; disabled?: boolean; invalid?: boolean; required?: boolean; label?: string; size?: "sm" | "md" | "lg"; className?: string; style?: CSSProperties; onValueChange?: (value: DateInputDateValue[]) => void; }; function toDateInputValue(value: DateInputFacadeValue | undefined) { if (value === undefined) return undefined; return Array.isArray(value) ? value : [value]; } /** The complete segmented date field behind one model value. */ function DateInputFacade(props: DateInputFacadeProps) { const { value, defaultValue, disabled, invalid, required, label, size = "md", className, style, onValueChange, } = props; return ( onValueChange?.(event.value)} > {label ? {label} : null} {(segmentProps: any) => } ); } export const DateInput: typeof DateInputFacade & Omit & { Root: typeof DateInputRoot } = Object.assign( DateInputFacade, { ...ArkDateInput, Root: DateInputRoot, }, ) as typeof DateInputFacade & Omit & { Root: typeof DateInputRoot };