@dhis2-ui/input 8.15.0 → 8.16.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +13 -10
  2. package/types/index.d.ts +240 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/input",
3
- "version": "8.15.0",
3
+ "version": "8.16.0-alpha.1",
4
4
  "description": "UI Input",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,6 +13,7 @@
13
13
  "main": "./build/cjs/index.js",
14
14
  "module": "./build/es/index.js",
15
15
  "exports": {
16
+ "types": "./types/index.d.ts",
16
17
  "import": "./build/es/index.js",
17
18
  "require": "./build/cjs/index.js"
18
19
  },
@@ -32,22 +33,24 @@
32
33
  },
33
34
  "dependencies": {
34
35
  "@dhis2/prop-types": "^3.1.2",
35
- "@dhis2-ui/box": "8.15.0",
36
- "@dhis2-ui/field": "8.15.0",
37
- "@dhis2-ui/input": "8.15.0",
38
- "@dhis2-ui/loader": "8.15.0",
39
- "@dhis2-ui/status-icon": "8.15.0",
40
- "@dhis2/ui-constants": "8.15.0",
41
- "@dhis2/ui-icons": "8.15.0",
36
+ "@dhis2-ui/box": "8.16.0-alpha.1",
37
+ "@dhis2-ui/field": "8.16.0-alpha.1",
38
+ "@dhis2-ui/input": "8.16.0-alpha.1",
39
+ "@dhis2-ui/loader": "8.16.0-alpha.1",
40
+ "@dhis2-ui/status-icon": "8.16.0-alpha.1",
41
+ "@dhis2/ui-constants": "8.16.0-alpha.1",
42
+ "@dhis2/ui-icons": "8.16.0-alpha.1",
42
43
  "classnames": "^2.3.1",
43
44
  "prop-types": "^15.7.2"
44
45
  },
45
46
  "files": [
46
- "build"
47
+ "build",
48
+ "types"
47
49
  ],
48
50
  "devDependencies": {
49
51
  "react": "16.13",
50
52
  "react-dom": "16.13",
51
53
  "styled-jsx": "^4.0.1"
52
- }
54
+ },
55
+ "types": "types"
53
56
  }
@@ -0,0 +1,240 @@
1
+ import * as React from 'react'
2
+
3
+ export type InputType =
4
+ | 'text'
5
+ | 'number'
6
+ | 'password'
7
+ | 'email'
8
+ | 'url'
9
+ | 'tel'
10
+ | 'date'
11
+ | 'datetime'
12
+ | 'datetime-local'
13
+ | 'month'
14
+ | 'week'
15
+ | 'time'
16
+ | 'search'
17
+
18
+ export interface InputEventPayload {
19
+ value: string | undefined
20
+ name: string | undefined
21
+ }
22
+
23
+ export type InputEventHandler<Event extends React.SyntheticEvent> = (
24
+ payload: InputEventPayload,
25
+ event: Event
26
+ ) => void
27
+
28
+ export type InputFocusHandler = InputEventHandler<
29
+ React.FocusEvent<HTMLInputElement>
30
+ >
31
+ export type InputChangeHandler = InputEventHandler<
32
+ React.ChangeEvent<HTMLInputElement>
33
+ >
34
+ export type InputKeyHandler = InputEventHandler<
35
+ React.KeyboardEvent<HTMLInputElement>
36
+ >
37
+
38
+ export interface InputProps {
39
+ /**
40
+ * The [native `autocomplete` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocomplete)
41
+ */
42
+ autoComplete?: string
43
+ className?: string
44
+ dataTest?: string
45
+ /**
46
+ * Makes the input smaller
47
+ */
48
+ dense?: boolean
49
+ /**
50
+ * Disables the input
51
+ */
52
+ disabled?: boolean
53
+ /**
54
+ * Applies 'error' appearance for validation feedback. Mutually exclusive with `valid` and `warning` props
55
+ */
56
+ error?: boolean
57
+ /**
58
+ * The input grabs initial focus on the page
59
+ */
60
+ initialFocus?: boolean
61
+ /**
62
+ * Adds a loading indicator beside the input
63
+ */
64
+ loading?: boolean
65
+ /**
66
+ * The [native `max` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max), for use when `type` is `'number'`
67
+ */
68
+ max?: string
69
+ /**
70
+ * The [native `min` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-min), for use when `type` is `'number'`
71
+ */
72
+ min?: string
73
+ /**
74
+ * Name associated with the input. Passed to event handler callbacks in object
75
+ */
76
+ name?: string
77
+ /**
78
+ * Placeholder text for the input
79
+ */
80
+ placeholder?: string
81
+ /**
82
+ * Makes the input read-only
83
+ */
84
+ readOnly?: boolean
85
+ /**
86
+ * Sets a role attribute on the input
87
+ */
88
+ role?: string
89
+ /**
90
+ * The [native `step` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step), for use when `type` is `'number'`
91
+ */
92
+ step?: string
93
+ tabIndex?: string
94
+ /**
95
+ * The native input `type` attribute
96
+ */
97
+ type?: InputType
98
+ /**
99
+ * Applies 'valid' appearance for validation feedback. Mutually exclusive with `error` and `warning` props
100
+ */
101
+ valid?: boolean
102
+ /**
103
+ * Value in the input. Can be used to control the component (recommended). Passed to event handler callbacks in object
104
+ */
105
+ value?: string
106
+ /**
107
+ * Applies 'warning' appearance for validation feedback. Mutually exclusive with `valid` and `error` props
108
+ */
109
+ warning?: boolean
110
+ /**
111
+ * Called with signature `({ name: string, value: string }, event)`
112
+ */
113
+ onBlur?: InputFocusHandler
114
+ /**
115
+ * Called with signature `({ name: string, value: string }, event)`
116
+ */
117
+ onChange?: InputChangeHandler
118
+ /**
119
+ * Called with signature `({ name: string, value: string }, event)`
120
+ */
121
+ onFocus?: InputFocusHandler
122
+ /**
123
+ * Called with signature `({ name: string, value: string }, event)`
124
+ */
125
+ onKeyDown?: InputKeyHandler
126
+ }
127
+
128
+ export class Input extends React.Component<InputProps, any> {
129
+ render(): JSX.Element
130
+ }
131
+
132
+ export interface InputFieldProps {
133
+ /**
134
+ * The [native `autocomplete` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autocomplete)
135
+ */
136
+ autoComplete?: string
137
+ className?: string
138
+ dataTest?: string
139
+ /**
140
+ * Makes the input smaller
141
+ */
142
+ dense?: boolean
143
+ /**
144
+ * Disables the input
145
+ */
146
+ disabled?: boolean
147
+ /**
148
+ * Applies 'error' appearance for validation feedback. Mutually exclusive with `valid` and `warning` props
149
+ */
150
+ error?: boolean
151
+ /**
152
+ * Guiding text for how to use this input
153
+ */
154
+ helpText?: string
155
+ /**
156
+ * The input grabs initial focus on the page
157
+ */
158
+ initialFocus?: boolean
159
+ /**
160
+ * Defines the width of the input. Can be any valid CSS measurement
161
+ */
162
+ inputWidth?: string
163
+ /**
164
+ * Label text for the input
165
+ */
166
+ label?: string
167
+ /**
168
+ * Adds a loading indicator beside the input
169
+ */
170
+ loading?: boolean
171
+ /**
172
+ * The [native `max` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max), for use when `type` is `'number'`
173
+ */
174
+ max?: string
175
+ /**
176
+ * The [native `min` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-min), for use when `type` is `'number'`
177
+ */
178
+ min?: string
179
+ /**
180
+ * Name associated with the input. Passed to event handler callbacks in object
181
+ */
182
+ name?: string
183
+ /**
184
+ * Placeholder text for the input
185
+ */
186
+ placeholder?: string
187
+ /**
188
+ * Makes the input read-only
189
+ */
190
+ readOnly?: boolean
191
+ /**
192
+ * Indicates this input is required
193
+ */
194
+ required?: boolean
195
+ /**
196
+ * The [native `step` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-step), for use when `type` is `'number'`
197
+ */
198
+ step?: string
199
+ tabIndex?: string
200
+ /**
201
+ * Type of input
202
+ */
203
+ type?: InputType
204
+ /**
205
+ * Applies 'valid' appearance for validation feedback. Mutually exclusive with `error` and `warning` props
206
+ */
207
+ valid?: boolean
208
+ /**
209
+ * Text below input for validation feedback. Receives styles depending on validation status
210
+ */
211
+ validationText?: string
212
+ /**
213
+ * Value in the input. Can be used to control the component (recommended). Passed to event handler callbacks in object
214
+ */
215
+ value?: string
216
+ /**
217
+ * Applies 'warning' appearance for validation feedback. Mutually exclusive with `valid` and `error` props
218
+ */
219
+ warning?: boolean
220
+ /**
221
+ * Called with signature `({ name: string, value: string }, event)`
222
+ */
223
+ onBlur?: InputFocusHandler
224
+ /**
225
+ * Called with signature `({ name: string, value: string }, event)`
226
+ */
227
+ onChange?: InputChangeHandler
228
+ /**
229
+ * Called with signature `({ name: string, value: string }, event)`
230
+ */
231
+ onFocus?: InputFocusHandler
232
+ /**
233
+ * Called with signature `({ name: string, value: string }, event)`
234
+ */
235
+ onKeyDown?: InputKeyHandler
236
+ }
237
+
238
+ export class InputField extends React.Component<InputFieldProps, any> {
239
+ render(): JSX.Element
240
+ }