UNPKG

2 kBTypeScriptView Raw
1/*
2 * Copyright 2020 Ladifire. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12
13export type ValidationState = 'valid' | 'invalid';
14
15export interface Validation {
16 /** Whether the input should display its "valid" or "invalid" visual styling. */
17 validationState?: ValidationState,
18 /**
19 * Whether user input is required on the input before form submission.
20 * Often paired with the `necessityIndicator` prop to add a visual indicator to the input.
21 */
22 isRequired?: boolean
23}
24
25export interface InputBase {
26 /** Whether the input is disabled. */
27 isDisabled?: boolean,
28 /** Whether the input can be selected but not changed by the user. */
29 isReadOnly?: boolean
30}
31
32export interface ValueBase<T> {
33 /** The current value (controlled). */
34 value?: T,
35 /** The default value (uncontrolled). */
36 defaultValue?: T,
37 /** Handler that is called when the value changes. */
38 onChange?: (value: T) => void
39}
40
41export interface TextInputBase {
42 /** Temporary text that occupies the text input when it is empty. */
43 placeholder?: string
44}
45
46export interface RangeValue<T> {
47 /** The start value of the range. */
48 start: T,
49 /** The end value of the range. */
50 end: T
51}
52
53export interface RangeInputBase<T> {
54 /** The smallest value allowed for the input. */
55 minValue?: T,
56 /** The largest value allowed for the input. */
57 maxValue?: T,
58 /** The amount that the input value changes with each increment or decrement "tick". */
59 step?: T // ??
60}