import { Temporal } from "@js-temporal/polyfill"; import React from "react"; import { InputProps } from "../input"; import "./durationinput.scss"; import { DurationMode } from "./parsers"; export type DurationNoTime = Pick; export type DurationInputProps = { /** The id, is set: passed to the first input. */ id?: string; inputProps?: InputProps; /** Disabled state. */ disabled?: boolean; /** The associated form's id. */ form?: string; /** Component title attribute */ label?: string; /** Which ISO flavor to use for parsing and formatting. Default "designator" */ mode?: DurationMode; /** The name. */ name?: string; /** Whether to apply padding. */ pad?: boolean | "h" | "v"; /** Whether a value is required. */ required?: boolean; type?: "duration"; /** ISO 8601 duration value for the chosen mode. Empty or null renders zeros */ value?: string; /** Optional label overrides for individual fields */ labelOverrides?: Partial>; /** Optional placeholder overrides for individual fields */ placeholderOverrides?: Partial>; /** Gets called when the value is changed. */ onChange?: React.ChangeEventHandler; }; /** * A segmented input for ISO 8601 **duration** values that emits a normalized ISO string. * Renders three small numeric fields (Y/M/D) in "designator" mode, or a single numeric field in "weeks" mode. * * TODO: Replace with native Temporal.Duration parsing and formatting once widely supported. * This component adheres to the ISO 8601-1 “Duration” specification. * Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/Duration * Spec proposal: https://tc39.es/proposal-temporal/docs/duration.html * * Supported ISO 8601 duration flavors (date-only; no time components): * * - **Designator** (`PnYnMnD`): uses explicit unit letters, e.g. `P3Y6M4D` or `P14D`. * Weeks values (e.g. `P2W`) are internally converted to days (`P14D`). * - **Weeks** (`PnW`): week-only shorthand, e.g. `P2W`. Cannot be combined with Y/M/D units. */ export declare const DurationInput: React.FC;