UNPKG

@tiller-ds/date

Version:

Date module of Tiller Design System

96 lines (95 loc) 3.46 kB
import * as React from "react"; import { InputProps } from "@tiller-ds/form-elements"; import { ComponentTokens } from "@tiller-ds/theme"; import { ClockType, TimePickerProps } from "./TimePicker"; export declare type TimeInputProps = { /** * Custom classes for the container. * Overrides conflicting default styles, if any. * * The provided `className` is processed using `tailwind-merge` to eliminate redundant or conflicting Tailwind classes. */ className?: string; /** * Enables automatic closing of the popover once a date is manually typed in. * Off by default. */ closeAfterEntry?: boolean; /** * Enables or disables the component's functionality. */ disabled?: boolean; /** * When enabled, the date mask changes on (un)focusing of the input element. * * When the input element is focused, the date mask is shown. * * When the input element is unfocused, the mask is shortened to exclude the placeholder characters. * * **ON** by default. */ dynamicMask?: boolean; /** * Value passed through from validation indicating to display the error on the component. */ error?: React.ReactNode; /** * If true, the popover for choosing a time is set to always have the same optimal width (370px), * meaning it won't stretch with the field component. Only applies to desktop displays. * * On by default. */ fixedPopoverWidth?: boolean; /** * The help text displayed below the date time input field. */ help?: React.ReactNode; /** * Represents the label above the time input field. */ label?: React.ReactNode; /** * The accessor value for the input field component (for validation, fetching, etc.). */ name: string; /** * Defines the behaviour of the component once the focus shifts away from the component. */ onBlur?: () => void; /** * Function that handles the behaviour of the component once its state changes. */ onChange: (value: string | null) => void; /** * Turns this field into a required field in the form. Only applies visual representation (* next to label), * still requires validation on frontend or backend to accompany this value if set to true. */ required?: boolean; /** * Show or hide the mask for time value when no value is present in the field. */ showMaskOnEmpty?: boolean; /** * The value of the field sent on submit and/or retrieved on component render (in Date format). */ value: string | null; /** * Enables or disables the display of a time zone. */ withTimeZone?: boolean; } & Omit<InputProps, "onChange" | "value" | "onClick"> & Pick<TimePickerProps, "type"> & TimeInputTokens; declare type TimeInputTokens = { timeInputTokens?: ComponentTokens<"TimeInput">; inputTokens?: ComponentTokens<"Input">; }; export declare type TimePickerValue = { hour: null; minute: null; type: ""; } | { hour: number; minute: number; type: ClockType; }; export default function TimeInput({ className, type, value, withTimeZone, onBlur, fixedPopoverWidth, allowClear, closeAfterEntry, dynamicMask, showMaskOnEmpty, ...props }: TimeInputProps & TimeInputTokens): JSX.Element; export {};