UNPKG

@acusti/css-value-input

Version:

React component that renders a text input that can take and update a CSS value of a particular type with a default unit

44 lines (43 loc) 1.69 kB
import { CSSValueType } from '../../css-values/src'; import { ChangeEvent, FocusEvent, KeyboardEvent, ReactNode } from 'react'; export type Props = { /** * Boolean indicating if the user can submit an empty value (i.e. clear * the value). Defaults to true. */ allowEmpty?: boolean; className?: string; cssValueType?: CSSValueType; disabled?: boolean; /** * Function that receives a value and converts it to its numerical equivalent * (i.e. '12px' → 12). Defaults to parseFloat(). */ getValueAsNumber?: (value: number | string) => number; icon?: ReactNode; label?: string; max?: number; min?: number; name?: string; onBlur?: (event: FocusEvent<HTMLInputElement>) => unknown; onChange?: (event: ChangeEvent<HTMLInputElement>) => unknown; onFocus?: (event: FocusEvent<HTMLInputElement>) => unknown; onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => unknown; onKeyUp?: (event: KeyboardEvent<HTMLInputElement>) => unknown; /** * Custom event handler triggered when the user presses enter/return * or blurs the input after making a change. Hitting esc will restore * the previous submitted value or original value. */ onSubmitValue: (value: string) => unknown; placeholder?: string; step?: number; tabIndex?: number; title?: string; unit?: string; /** Regex or validator function to validate non-numeric values */ validator?: ((value: string) => boolean) | RegExp; value?: string; }; declare const _default: import('react').ForwardRefExoticComponent<Props & import('react').RefAttributes<HTMLInputElement>>; export default _default;