@dhis2-ui/file-input 8.15.1 → 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 +287 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/file-input",
3
- "version": "8.15.1",
3
+ "version": "8.16.0-alpha.1",
4
4
  "description": "UI FileInput",
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
  },
@@ -33,23 +34,25 @@
33
34
  },
34
35
  "dependencies": {
35
36
  "@dhis2/prop-types": "^3.1.2",
36
- "@dhis2-ui/button": "8.15.1",
37
- "@dhis2-ui/field": "8.15.1",
38
- "@dhis2-ui/label": "8.15.1",
39
- "@dhis2-ui/loader": "8.15.1",
40
- "@dhis2-ui/status-icon": "8.15.1",
41
- "@dhis2/ui-constants": "8.15.1",
42
- "@dhis2/ui-icons": "8.15.1",
37
+ "@dhis2-ui/button": "8.16.0-alpha.1",
38
+ "@dhis2-ui/field": "8.16.0-alpha.1",
39
+ "@dhis2-ui/label": "8.16.0-alpha.1",
40
+ "@dhis2-ui/loader": "8.16.0-alpha.1",
41
+ "@dhis2-ui/status-icon": "8.16.0-alpha.1",
42
+ "@dhis2/ui-constants": "8.16.0-alpha.1",
43
+ "@dhis2/ui-icons": "8.16.0-alpha.1",
43
44
  "classnames": "^2.3.1",
44
45
  "prop-types": "^15.7.2"
45
46
  },
46
47
  "files": [
47
- "build"
48
+ "build",
49
+ "types"
48
50
  ],
49
51
  "devDependencies": {
50
52
  "@dhis2/d2-i18n": "^1.1.0",
51
53
  "react": "16.13",
52
54
  "react-dom": "16.13",
53
55
  "styled-jsx": "^4.0.1"
54
- }
56
+ },
57
+ "types": "types"
55
58
  }
@@ -0,0 +1,287 @@
1
+ import * as React from 'react'
2
+
3
+ export interface FileInputEventPayload {
4
+ files: FileList
5
+ name?: string
6
+ }
7
+
8
+ type FileInputEventHandler<Event extends React.SyntheticEvent> = (
9
+ arg0: FileInputEventPayload,
10
+ event: Event
11
+ ) => void
12
+
13
+ type FileInputFocusHandler = FileInputEventHandler<
14
+ React.FocusEvent<HTMLInputElement>
15
+ >
16
+ type FileInputChangeHandler = FileInputEventHandler<
17
+ React.ChangeEvent<HTMLInputElement>
18
+ >
19
+ type FileInputKeyHandler = FileInputEventHandler<
20
+ React.KeyboardEvent<HTMLInputElement>
21
+ >
22
+
23
+ export interface FileInputProps {
24
+ /**
25
+ * The `accept` attribute of the [native file input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept)
26
+ */
27
+ accept?: string
28
+ buttonLabel?: string
29
+ className?: string
30
+ dataTest?: string
31
+ disabled?: boolean
32
+ /**
33
+ * Input status. Mutually exclusive with `warning` and `valid`
34
+ */
35
+ error?: boolean
36
+ initialFocus?: boolean
37
+ /**
38
+ * Button size. Mutually exclusive with `small`
39
+ */
40
+ large?: boolean
41
+ /**
42
+ * The `multiple` attribute of the [native file input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#multiple)
43
+ */
44
+ multiple?: boolean
45
+ name?: string
46
+ /**
47
+ * Button size. Mutually exclusive with `large`
48
+ */
49
+ small?: boolean
50
+ tabIndex?: string
51
+ /**
52
+ * Input status. Mutually exclusive with `warning` and `error`
53
+ */
54
+ valid?: boolean
55
+ /**
56
+ * Input status. Mutually exclusive with `valid` and `error`
57
+ */
58
+ warning?: boolean
59
+ /**
60
+ * Called with signature `(object, event)`
61
+ */
62
+ onBlur?: FileInputFocusHandler
63
+ /**
64
+ * Called with signature `(object, event)`
65
+ */
66
+ onChange?: FileInputChangeHandler
67
+ /**
68
+ * Called with signature `(object, event)`
69
+ */
70
+ onFocus?: FileInputFocusHandler
71
+ /**
72
+ * Called with signature `(object, event)`
73
+ */
74
+ onKeyDown?: FileInputKeyHandler
75
+ }
76
+
77
+ export class FileInput extends React.Component<FileInputProps, any> {
78
+ render(): JSX.Element
79
+ }
80
+
81
+ type TranslateableProp = string | ((arg: any) => string)
82
+
83
+ export interface FileInputFieldProps {
84
+ /**
85
+ * The `accept` attribute of the [native file input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept)
86
+ */
87
+ accept?: string
88
+ /**
89
+ * Text on the button
90
+ */
91
+ buttonLabel?: TranslateableProp
92
+ children?: React.ReactNode
93
+ className?: string
94
+ dataTest?: string
95
+ /**
96
+ * Disables the button
97
+ */
98
+ disabled?: boolean
99
+ /**
100
+ * Applies 'error' styling to the validation text. Mutually exclusive with `warning` and `valid` props
101
+ */
102
+ error?: boolean
103
+ /**
104
+ * Useful guiding text for the user
105
+ */
106
+ helpText?: string
107
+ initialFocus?: boolean
108
+ /**
109
+ * A descriptive label above the button
110
+ */
111
+ label?: string
112
+ /**
113
+ * Size of the button. Mutually exclusive with the `small` prop
114
+ */
115
+ large?: boolean
116
+ /**
117
+ * The `multiple` attribute of the [native file input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#multiple)
118
+ */
119
+ multiple?: boolean
120
+ /**
121
+ * Name associated with input. Passed to event handler callbacks
122
+ */
123
+ name?: string
124
+ /**
125
+ * Placeholder below the button
126
+ */
127
+ placeholder?: TranslateableProp
128
+ /**
129
+ * Adds an asterisk to indicate this field is required
130
+ */
131
+ required?: boolean
132
+ /**
133
+ * Size of the button. Mutually exclusive with the `large` prop
134
+ */
135
+ small?: boolean
136
+ tabIndex?: string
137
+ /**
138
+ * Applies 'valid' styling to the validation text. Mutually exclusive with `warning` and `error` props
139
+ */
140
+ valid?: boolean
141
+ /**
142
+ * Text below the button that provides validation feedback
143
+ */
144
+ validationText?: string
145
+ /**
146
+ * Applies 'warning' styling to the validation text. Mutually exclusive with `valid` and `error` props
147
+ */
148
+ warning?: boolean
149
+ onBlur?: FileInputFocusHandler
150
+ /**
151
+ * Called with signature `({ name: string, files: [] }, event)`
152
+ */
153
+ onChange?: FileInputChangeHandler
154
+ /**
155
+ * Called with signature `({ name: string, files: [] }, event)`
156
+ */
157
+ onFocus?: FileInputFocusHandler
158
+ /**
159
+ * Called with signature `({ name: string, files: [] }, event)`
160
+ */
161
+ onKeyDown?: FileInputKeyHandler
162
+ }
163
+
164
+ export const FileInputField: React.FC<FileInputFieldProps>
165
+
166
+ export interface FileInputFieldWithListProps {
167
+ /**
168
+ * The `accept` attribute of the [native file input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept)
169
+ */
170
+ accept?: string
171
+ /**
172
+ * Text on the button
173
+ */
174
+ buttonLabel?: TranslateableProp
175
+ className?: string
176
+ dataTest?: string
177
+ /**
178
+ * Disables the button
179
+ */
180
+ disabled?: boolean
181
+ /**
182
+ * Applies 'error' styling to the button and validation text. Mutually exclusive with `warning` and `valid` props
183
+ */
184
+ error?: boolean
185
+ files?: File[]
186
+ /**
187
+ * Useful guiding text for the user
188
+ */
189
+ helpText?: string
190
+ initialFocus?: boolean
191
+ /**
192
+ * A descriptive label above the button
193
+ */
194
+ label?: string
195
+ /**
196
+ * Size of the button. Mutually exclusive with the `small` prop
197
+ */
198
+ large?: boolean
199
+ /**
200
+ * The `multiple` attribute of the [native file input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#multiple)
201
+ */
202
+ multiple?: boolean
203
+ /**
204
+ * Name associated with input. Passed to event handler callbacks
205
+ */
206
+ name?: string
207
+ /**
208
+ * Placeholder below the button
209
+ */
210
+ placeholder?: TranslateableProp
211
+ /**
212
+ * Text used for the button that removes a file from the list
213
+ */
214
+ removeText?: TranslateableProp
215
+ /**
216
+ * Adds an asterisk to indicate this field is required
217
+ */
218
+ required?: boolean
219
+ /**
220
+ * Size of the button. Mutually exclusive with the `large` prop
221
+ */
222
+ small?: boolean
223
+ tabIndex?: string
224
+ /**
225
+ * Applies 'valid' styling to the button and validation text. Mutually exclusive with `warning` and `error` props
226
+ */
227
+ valid?: boolean
228
+ /**
229
+ * Text below the button that provides validation feedback
230
+ */
231
+ validationText?: string
232
+ /**
233
+ * Applies 'warning' styling to the button and validation text. Mutually exclusive with `valid` and `error` props
234
+ */
235
+ warning?: boolean
236
+ /**
237
+ * Called with signature `({ name: string, files: [] }, event)`
238
+ */
239
+ onBlur?: FileInputFocusHandler
240
+ /**
241
+ * Called with signature `({ name: string, files: [] }, event)`
242
+ */
243
+ onChange: FileInputChangeHandler
244
+ /**
245
+ * Called with signature `({ name: string, files: [] }, event)`
246
+ */
247
+ onFocus?: FileInputFocusHandler
248
+ /**
249
+ * Called with signature `({ name: string, files: [] }, event)`
250
+ */
251
+ onKeyDown?: FileInputKeyHandler
252
+ }
253
+
254
+ export class FileInputFieldWithList extends React.Component<
255
+ FileInputFieldWithListProps,
256
+ any
257
+ > {
258
+ render(): JSX.Element
259
+ }
260
+
261
+ export interface FileListItemProps {
262
+ onRemove: (arg0: {}, event: React.MouseEvent<HTMLSpanElement>) => void
263
+ cancelText?: string
264
+ className?: string
265
+ dataTest?: string
266
+ label?: string
267
+ loading?: boolean
268
+ removeText?: string
269
+ onCancel?: (arg0: {}, event: React.MouseEvent<HTMLSpanElement>) => void
270
+ }
271
+
272
+ export const FileListItem: React.FC<FileListItemProps>
273
+
274
+ export interface FileListPlaceholderProps {
275
+ children?: string
276
+ dataTest?: string
277
+ }
278
+
279
+ export const FileListPlaceholder: React.FC<FileListPlaceholderProps>
280
+
281
+ export interface FileListProps {
282
+ children?: React.ReactNode
283
+ className?: string
284
+ dataTest?: string
285
+ }
286
+
287
+ export const FileList: React.FC<FileListProps>