@dhis2-ui/text-area 8.14.8 → 8.15.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 +11 -9
  2. package/types/index.d.ts +209 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/text-area",
3
- "version": "8.14.8",
3
+ "version": "8.15.0-alpha.1",
4
4
  "description": "UI TextArea",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,21 +32,23 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@dhis2/prop-types": "^3.1.2",
35
- "@dhis2-ui/box": "8.14.8",
36
- "@dhis2-ui/field": "8.14.8",
37
- "@dhis2-ui/loader": "8.14.8",
38
- "@dhis2-ui/status-icon": "8.14.8",
39
- "@dhis2/ui-constants": "8.14.8",
40
- "@dhis2/ui-icons": "8.14.8",
35
+ "@dhis2-ui/box": "8.15.0-alpha.1",
36
+ "@dhis2-ui/field": "8.15.0-alpha.1",
37
+ "@dhis2-ui/loader": "8.15.0-alpha.1",
38
+ "@dhis2-ui/status-icon": "8.15.0-alpha.1",
39
+ "@dhis2/ui-constants": "8.15.0-alpha.1",
40
+ "@dhis2/ui-icons": "8.15.0-alpha.1",
41
41
  "classnames": "^2.3.1",
42
42
  "prop-types": "^15.7.2"
43
43
  },
44
44
  "files": [
45
- "build"
45
+ "build",
46
+ "types"
46
47
  ],
47
48
  "devDependencies": {
48
49
  "react": "16.13",
49
50
  "react-dom": "16.13",
50
51
  "styled-jsx": "^4.0.1"
51
- }
52
+ },
53
+ "types": "types"
52
54
  }
@@ -0,0 +1,209 @@
1
+ import * as React from 'react'
2
+
3
+ export type TextAreaResize = 'none' | 'both' | 'horizontal' | 'vertical'
4
+
5
+ export interface TextAreaEventPayload {
6
+ value?: string
7
+ name?: string
8
+ }
9
+
10
+ export type TextAreaEventHandler<Event extends React.SyntheticEvent> = (
11
+ payload: TextAreaEventPayload,
12
+ event: Event
13
+ ) => void
14
+
15
+ type TextAreaFocusHandler = TextAreaEventHandler<
16
+ React.FocusEvent<HTMLInputElement>
17
+ >
18
+ type TextAreaChangeHandler = TextAreaEventHandler<
19
+ React.ChangeEvent<HTMLInputElement>
20
+ >
21
+ type TextAreaKeyHandler = TextAreaEventHandler<
22
+ React.KeyboardEvent<HTMLInputElement>
23
+ >
24
+
25
+ export interface TextAreaProps {
26
+ /**
27
+ * Grow the text area in response to overflow instead of adding a scroll bar
28
+ */
29
+ autoGrow?: boolean
30
+ className?: string
31
+ dataTest?: string
32
+ /**
33
+ * Compact mode
34
+ */
35
+ dense?: boolean
36
+ /**
37
+ * Disables the textarea and makes in non-interactive
38
+ */
39
+ disabled?: boolean
40
+ /**
41
+ * Applies 'error' styles for validation feedback. Mutually exclusive with `valid` and `warning` props
42
+ */
43
+ error?: boolean
44
+ /**
45
+ * Grabs initial focus on the page
46
+ */
47
+ initialFocus?: boolean
48
+ /**
49
+ * Adds a loading spinner
50
+ */
51
+ loading?: boolean
52
+ /**
53
+ * Name associated with the text area. Passed in object argument to event handlers.
54
+ */
55
+ name?: string
56
+ /**
57
+ * Placeholder text for an empty textarea
58
+ */
59
+ placeholder?: string
60
+ /**
61
+ * Makes the textarea read-only
62
+ */
63
+ readOnly?: boolean
64
+ /**
65
+ * [Resize property](https://developer.mozilla.org/en-US/docs/Web/CSS/resize) for the textarea element
66
+ */
67
+ resize?: TextAreaResize
68
+ /**
69
+ * Initial height of the textarea, in lines of text
70
+ */
71
+ rows?: number
72
+ tabIndex?: string
73
+ /**
74
+ * Applies 'valid' styles for validation feedback. Mutually exclusive with `warning` and `error` props
75
+ */
76
+ valid?: boolean
77
+ /**
78
+ * Value in the textarea. Can be used to control component (recommended). Passed in object argument to event handlers.
79
+ */
80
+ value?: string
81
+ /**
82
+ * Applies 'warning' styles for validation feedback. Mutually exclusive with `valid` and `error` props
83
+ */
84
+ warning?: boolean
85
+ /**
86
+ * Width of the text area. Can be any valid CSS measurement
87
+ */
88
+ width?: string
89
+ /**
90
+ * Called with signature ({ name: string, value: string }, event)
91
+ */
92
+ onBlur?: TextAreaFocusHandler
93
+ /**
94
+ * Called with signature ({ name: string, value: string }, event)
95
+ */
96
+ onChange?: TextAreaChangeHandler
97
+ /**
98
+ * Called with signature ({ name: string, value: string }, event)
99
+ */
100
+ onFocus?: TextAreaFocusHandler
101
+ /**
102
+ * Called with signature ({ name: string, value: string }, event)
103
+ */
104
+ onKeyDown?: TextAreaKeyHandler
105
+ }
106
+
107
+ export class TextArea extends React.Component<TextAreaProps, any> {
108
+ render(): JSX.Element
109
+ }
110
+
111
+ export interface TextAreaFieldProps {
112
+ /**
113
+ * Grow the text area in response to overflow instead of adding a scroll bar
114
+ */
115
+ autoGrow?: boolean
116
+ className?: string
117
+ dataTest?: string
118
+ /**
119
+ * Compact mode
120
+ */
121
+ dense?: boolean
122
+ /**
123
+ * Disables the textarea and makes in non-interactive
124
+ */
125
+ disabled?: boolean
126
+ /**
127
+ * Applies 'error' styles for validation feedback. Mutually exclusive with `valid` and `warning` props
128
+ */
129
+ error?: boolean
130
+ /**
131
+ * Adds useful help text below the textarea
132
+ */
133
+ helpText?: string
134
+ /**
135
+ * Grabs initial focus on the page
136
+ */
137
+ initialFocus?: boolean
138
+ /**
139
+ * Sets the width of the textarea. Minimum 220px. Any valid CSS measurement can be used
140
+ */
141
+ inputWidth?: string
142
+ /**
143
+ * Labels the textarea
144
+ */
145
+ label?: string
146
+ /**
147
+ * Adds a loading spinner
148
+ */
149
+ loading?: boolean
150
+ /**
151
+ * Name associated with the text area. Passed in object argument to event handlers.
152
+ */
153
+ name?: string
154
+ /**
155
+ * Placeholder text for an empty textarea
156
+ */
157
+ placeholder?: string
158
+ /**
159
+ * Makes the textarea read-only
160
+ */
161
+ readOnly?: boolean
162
+ /**
163
+ * Adds an asterisk to the label to indicate this field is required
164
+ */
165
+ required?: boolean
166
+ /**
167
+ * [Resize property](https://developer.mozilla.org/en-US/docs/Web/CSS/resize) for the textarea element
168
+ */
169
+ resize?: TextAreaResize
170
+ /**
171
+ * Initial height of the textarea, in lines of text
172
+ */
173
+ rows?: number
174
+ tabIndex?: string
175
+ /**
176
+ * Applies 'valid' styles for validation feedback. Mutually exclusive with `warning` and `error` props
177
+ */
178
+ valid?: boolean
179
+ /**
180
+ * Validation text below the textarea to provide validation feedback. Changes appearance depending on validation status
181
+ */
182
+ validationText?: string
183
+ /**
184
+ * Value in the textarea. Can be used to control component (recommended). Passed in object argument to event handlers.
185
+ */
186
+ value?: string
187
+ /**
188
+ * Applies 'warning' styles for validation feedback. Mutually exclusive with `valid` and `error` props
189
+ */
190
+ warning?: boolean
191
+ /**
192
+ * Called with signature ({ name: string, value: string }, event)
193
+ */
194
+ onBlur?: TextAreaFocusHandler
195
+ /**
196
+ * Called with signature ({ name: string, value: string }, event)
197
+ */
198
+ onChange?: TextAreaChangeHandler
199
+ /**
200
+ * Called with signature ({ name: string, value: string }, event)
201
+ */
202
+ onFocus?: TextAreaFocusHandler
203
+ /**
204
+ * Called with signature ({ name: string, value: string }, event)
205
+ */
206
+ onKeyDown?: TextAreaKeyHandler
207
+ }
208
+
209
+ export const TextAreaField: React.FC<TextAreaFieldProps>