-
Notifications
You must be signed in to change notification settings - Fork 428
/
Copy pathinput.d.ts
258 lines (258 loc) · 8.57 KB
/
input.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
declare module '@salesforce/design-system-react/components/input' {
import * as React from 'react';
type Props = {
/**
* The aria-activedescendant attribute contains the ID of the currently active child object that is part of a composite widget within the Document Object Model. It makes do with the overhead of having all or more than one child focusable. As the name specifies, it helps in managing the current active child of the composite widget.
*/
'aria-activedescendant'?: string;
/**
* Indicates if the suggestions in a composite widget are values that complete the current textbox input.
*/
'aria-autocomplete'?: string;
/**
* An HTML ID that is shared with ARIA-supported devices with the
* `aria-controls` attribute in order to relate the input with
* another region of the page. An example would be a select box
* that shows or hides a panel.
*/
'aria-controls'?: string;
/**
* The `aria-describedby` attribute is used to indicate the IDs of the elements that describe the object. It is used to establish a relationship between widgets or groups and text that described them. This is very similar to aria-labelledby: a label describes the essence of an object, while a description provides more information that the user might need.
*/
'aria-describedby'?: string;
/**
* Use the `aria-expanded` state to indicate whether regions of the content are collapsible, and to expose whether a region is currently expanded or collapsed.
*/
'aria-expanded'?: boolean;
/**
* Indicates that the element has a popup context menu or sub-level menu.
*/
'aria-haspopup'?: boolean;
/**
* The aria-labelledby attribute contains the element IDs of labels in objects such as input elements, widgets, and groups. The attribute establishes relationships between objects and their labels. Assistive technology, such as screen readers, use this attribute to catalog the objects in a document so that users can navigate between them. Without an element ID, the assistive technology cannot catalog the object.
*/
'aria-labelledby'?: string;
/**
* An HTML ID that is shared with ARIA-supported devices with the
* `aria-controls` attribute in order to relate the input with
* another region of the page. An example would be a search field
* that shows search results.
*/
'aria-owns'?: string;
/**
* The `aria-required` attribute is used to indicate that user input is required on an element before a form can be submitted.
*/
'aria-required'?: boolean;
/**
* **Assistive text for accessibility**
* * `label`: Visually hidden label but read out loud by screen readers.
* * `spinner`: Text for loading spinner icon.
*/
assistiveText?: Partial<{
label?: string;
spinner?: string;
}>;
/**
* Disabled brower's autocomplete when "off" is used.
*/
autoComplete?: string;
/**
* Elements are added after the `input`.
*/
children?: React.ReactNode;
/**
* Class names to be added to the outer container of the input.
*/
className?: Record<string, boolean>[] | Record<string, boolean> | string;
/**
* This is the initial value of an uncontrolled form element and
* is present only to provide compatibility with hybrid framework
* applications that are not entirely React. It should only be used
* in an application without centralized state (Redux, Flux).
* "Controlled components" with centralized state is highly recommended.
* See [Code Overview](https://github.com/salesforce/design-system-react/blob/master/docs/codebase-overview.md#controlled-and-uncontrolled-components) for more information.
*/
defaultValue?: number | string;
/**
* Disables the input and prevents editing the contents.
*/
disabled?: boolean;
/**
* Message to display when the input is in an error state. When this is present, also visually highlights the component as in error.
*/
errorText?: React.ReactNode | string;
/**
* A [Tooltip](https://react.lightningdesignsystem.com/components/tooltips/) component that is displayed next to the label.
*/
fieldLevelHelpTooltip?: React.ReactNode;
/**
* Displays text or node to the left of the input. This follows the fixed text input UX pattern.
*/
fixedTextLeft?: React.ReactNode | string;
/**
* Displays text or node to the right of the input. This follows the fixed text input UX pattern.
*/
fixedTextRight?: React.ReactNode | string;
/**
* If true, loading spinner appears inside input on right hand side.
*/
hasSpinner?: boolean;
/**
* Left aligned icon, must be instace of `design-system-react/components/icon/input-icon`
*/
iconLeft?: React.ReactNode;
/**
* Right aligned icon, must be instace of `design-system-react/components/icon/input-icon`
*/
iconRight?: React.ReactNode;
/**
* Every input must have a unique ID in order to support keyboard navigation and ARIA support.
*/
id?: string;
/**
* Displays help text under the input.
*/
inlineHelpText?: React.ReactNode | string;
/**
* This callback exposes the input reference / DOM node to parent components. `<Parent inputRef={(inputComponent) => this.input = inputComponent} />
*/
inputRef?: React.RefCallback<HTMLInputElement>;
/**
* Displays the value of the input statically. This follows the static input UX pattern.
*/
isStatic?: boolean;
/**
* This label appears above the input.
*/
label?: string;
/**
* Triggered when focus is removed.
*/
onBlur?: React.FocusEventHandler<HTMLInputElement>;
/**
* This callback fires when the input changes. Passes in `event, { value }`.
*/
onChange?: (
e:
| React.ChangeEvent<HTMLInputElement>
| React.KeyboardEvent<HTMLButtonElement>
| React.MouseEvent<HTMLButtonElement>,
value: { value: string; number?: number }
) => any;
/**
* This event fires when the input is clicked.
*/
onClick?: React.MouseEventHandler<HTMLInputElement>;
/**
* Triggered when component is focused.
*/
onFocus?: React.FocusEventHandler<HTMLInputElement>;
/**
* Similar to `onchange`. Triggered when an element gets user input.
*/
onInput?: React.FormEventHandler<HTMLInputElement>;
/**
* Triggered when a submittable `<input>` element is invalid.
*/
onInvalid?: React.FormEventHandler<HTMLInputElement>;
/**
* Triggered when a key is pressed down
*/
onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;
/**
* Triggered when a key is pressed and released
*/
onKeyPress?: React.KeyboardEventHandler<HTMLInputElement>;
/**
* Triggered when a key is released
*/
onKeyUp?: React.KeyboardEventHandler<HTMLInputElement>;
/**
* Triggered after some text has been selected in an element.
*/
onSelect?: React.ReactEventHandler<HTMLInputElement>;
/**
* Fires when a form is submitted.
*/
onSubmit?: React.ReactEventHandler<HTMLInputElement>;
/**
* Text that will appear in an empty input.
*/
placeholder?: string;
/**
* Sets the minimum number of characters that an `<input>` can accept.
*/
minLength?: string;
/**
* Specifies minimum accepted value for a counter input
*/
minValue?: number;
/**
* Sets the maximum number of characters that an `<input>` can accept.
*/
maxLength?: string;
/**
* Specifies maximum accepted value for a counter input
*/
maxValue?: number;
/**
* Name of the submitted form parameter.
*/
name?: string;
/**
* Displays the value of the input as read-only. This is used in the inline edit UX pattern.
*/
readOnly?: boolean;
/**
* Highlights the input as a required field (does not perform any validation).
*/
required?: boolean;
/**
* ARIA role
*/
role?: string;
/**
* Determines the step size upon increment or decrement. Can be set to decimal values.
*/
step?: number;
/**
* styles to be added to input
*/
styleInput?: Record<string, any>;
/**
* Custom styles to be passed to the component container
*/
styleContainer?: Record<string, any>;
/**
* The `<Input>` element includes support for all HTML5 types.
*/
type?:
| 'text'
| 'password'
| 'datetime'
| 'datetime-local'
| 'date'
| 'month'
| 'time'
| 'week'
| 'number'
| 'email'
| 'url'
| 'search'
| 'tel'
| 'color';
/**
* The input is a controlled component, and will always display this value.
*/
value?: number | string;
/**
* Which UX pattern of input? The default is `base` while other option is `counter`
*/
variant?: 'base' | COUNTER;
};
/**
* The HTML `input` with a label and error messaging.
*/
function Component(props: Props): JSX.Element;
export default Component;
}