@dhis2-ui/text-area 8.2.6 → 8.4.0
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.
- package/build/cjs/text-area/__tests__/text-area.test.js +28 -0
- package/build/cjs/text-area/text-area.js +11 -1
- package/build/cjs/text-area-field/__tests__/text-area-field.test.js +28 -0
- package/build/cjs/text-area-field/text-area-field.js +6 -1
- package/build/es/text-area/__tests__/text-area.test.js +19 -0
- package/build/es/text-area/text-area.js +11 -1
- package/build/es/text-area-field/__tests__/text-area-field.test.js +19 -0
- package/build/es/text-area-field/text-area-field.js +6 -1
- package/package.json +8 -8
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
4
|
+
|
|
5
|
+
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _textArea = require("../text-area.js");
|
|
8
|
+
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
|
|
11
|
+
describe('<TextArea>', () => {
|
|
12
|
+
it('should call the onKeyDown callback when provided', () => {
|
|
13
|
+
const onKeyDown = jest.fn();
|
|
14
|
+
(0, _react.render)( /*#__PURE__*/_react2.default.createElement(_textArea.TextArea, {
|
|
15
|
+
name: "foo",
|
|
16
|
+
value: "bar",
|
|
17
|
+
onKeyDown: onKeyDown
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
_react.fireEvent.keyDown(_react.screen.getByRole('textbox'), {});
|
|
21
|
+
|
|
22
|
+
expect(onKeyDown).toHaveBeenCalledWith({
|
|
23
|
+
name: 'foo',
|
|
24
|
+
value: 'bar'
|
|
25
|
+
}, expect.objectContaining({}));
|
|
26
|
+
expect(onKeyDown).toHaveBeenCalledTimes(1);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -87,6 +87,12 @@ class TextArea extends _react.Component {
|
|
|
87
87
|
this.props.onFocus(this.createHandlerPayload(e), e);
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
+
|
|
91
|
+
_defineProperty(this, "handleKeyDown", e => {
|
|
92
|
+
if (this.props.onKeyDown) {
|
|
93
|
+
this.props.onKeyDown(this.createHandlerPayload(e), e);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
90
96
|
}
|
|
91
97
|
|
|
92
98
|
componentDidMount() {
|
|
@@ -174,6 +180,7 @@ class TextArea extends _react.Component {
|
|
|
174
180
|
readOnly: readOnly,
|
|
175
181
|
tabIndex: tabIndex,
|
|
176
182
|
onFocus: this.handleFocus,
|
|
183
|
+
onKeyDown: this.handleKeyDown,
|
|
177
184
|
onBlur: this.handleBlur,
|
|
178
185
|
onChange: this.handleChange,
|
|
179
186
|
rows: rows,
|
|
@@ -263,5 +270,8 @@ TextArea.propTypes = {
|
|
|
263
270
|
onChange: _propTypes.default.func,
|
|
264
271
|
|
|
265
272
|
/** Called with signature ({ name: string, value: string }, event) */
|
|
266
|
-
onFocus: _propTypes.default.func
|
|
273
|
+
onFocus: _propTypes.default.func,
|
|
274
|
+
|
|
275
|
+
/** Called with signature ({ name: string, value: string }, event) */
|
|
276
|
+
onKeyDown: _propTypes.default.func
|
|
267
277
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = require("@testing-library/react");
|
|
4
|
+
|
|
5
|
+
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
+
|
|
7
|
+
var _textAreaField = require("../text-area-field.js");
|
|
8
|
+
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
|
|
11
|
+
describe('<TextArea>', () => {
|
|
12
|
+
it('should call the onKeyDown callback when provided', () => {
|
|
13
|
+
const onKeyDown = jest.fn();
|
|
14
|
+
(0, _react.render)( /*#__PURE__*/_react2.default.createElement(_textAreaField.TextAreaField, {
|
|
15
|
+
name: "foo",
|
|
16
|
+
value: "bar",
|
|
17
|
+
onKeyDown: onKeyDown
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
_react.fireEvent.keyDown(_react.screen.getByRole('textbox'), {});
|
|
21
|
+
|
|
22
|
+
expect(onKeyDown).toHaveBeenCalledWith({
|
|
23
|
+
name: 'foo',
|
|
24
|
+
value: 'bar'
|
|
25
|
+
}, expect.objectContaining({}));
|
|
26
|
+
expect(onKeyDown).toHaveBeenCalledTimes(1);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -24,6 +24,7 @@ const TextAreaField = _ref => {
|
|
|
24
24
|
className,
|
|
25
25
|
onChange,
|
|
26
26
|
onFocus,
|
|
27
|
+
onKeyDown,
|
|
27
28
|
onBlur,
|
|
28
29
|
initialFocus,
|
|
29
30
|
dense,
|
|
@@ -64,6 +65,7 @@ const TextAreaField = _ref => {
|
|
|
64
65
|
minWidth: "220px"
|
|
65
66
|
}, /*#__PURE__*/_react.default.createElement(_index.TextArea, {
|
|
66
67
|
onFocus: onFocus,
|
|
68
|
+
onKeyDown: onKeyDown,
|
|
67
69
|
onBlur: onBlur,
|
|
68
70
|
onChange: onChange,
|
|
69
71
|
name: name,
|
|
@@ -158,5 +160,8 @@ TextAreaField.propTypes = {
|
|
|
158
160
|
onChange: _propTypes.default.func,
|
|
159
161
|
|
|
160
162
|
/** Called with signature ({ name: string, value: string }, event) */
|
|
161
|
-
onFocus: _propTypes.default.func
|
|
163
|
+
onFocus: _propTypes.default.func,
|
|
164
|
+
|
|
165
|
+
/** Called with signature ({ name: string, value: string }, event) */
|
|
166
|
+
onKeyDown: _propTypes.default.func
|
|
162
167
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { render, fireEvent, screen } from '@testing-library/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { TextArea } from '../text-area.js';
|
|
4
|
+
describe('<TextArea>', () => {
|
|
5
|
+
it('should call the onKeyDown callback when provided', () => {
|
|
6
|
+
const onKeyDown = jest.fn();
|
|
7
|
+
render( /*#__PURE__*/React.createElement(TextArea, {
|
|
8
|
+
name: "foo",
|
|
9
|
+
value: "bar",
|
|
10
|
+
onKeyDown: onKeyDown
|
|
11
|
+
}));
|
|
12
|
+
fireEvent.keyDown(screen.getByRole('textbox'), {});
|
|
13
|
+
expect(onKeyDown).toHaveBeenCalledWith({
|
|
14
|
+
name: 'foo',
|
|
15
|
+
value: 'bar'
|
|
16
|
+
}, expect.objectContaining({}));
|
|
17
|
+
expect(onKeyDown).toHaveBeenCalledTimes(1);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -68,6 +68,12 @@ export class TextArea extends Component {
|
|
|
68
68
|
this.props.onFocus(this.createHandlerPayload(e), e);
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
|
+
|
|
72
|
+
_defineProperty(this, "handleKeyDown", e => {
|
|
73
|
+
if (this.props.onKeyDown) {
|
|
74
|
+
this.props.onKeyDown(this.createHandlerPayload(e), e);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
componentDidMount() {
|
|
@@ -155,6 +161,7 @@ export class TextArea extends Component {
|
|
|
155
161
|
readOnly: readOnly,
|
|
156
162
|
tabIndex: tabIndex,
|
|
157
163
|
onFocus: this.handleFocus,
|
|
164
|
+
onKeyDown: this.handleKeyDown,
|
|
158
165
|
onBlur: this.handleBlur,
|
|
159
166
|
onChange: this.handleChange,
|
|
160
167
|
rows: rows,
|
|
@@ -242,5 +249,8 @@ TextArea.propTypes = {
|
|
|
242
249
|
onChange: PropTypes.func,
|
|
243
250
|
|
|
244
251
|
/** Called with signature ({ name: string, value: string }, event) */
|
|
245
|
-
onFocus: PropTypes.func
|
|
252
|
+
onFocus: PropTypes.func,
|
|
253
|
+
|
|
254
|
+
/** Called with signature ({ name: string, value: string }, event) */
|
|
255
|
+
onKeyDown: PropTypes.func
|
|
246
256
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { render, fireEvent, screen } from '@testing-library/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { TextAreaField } from '../text-area-field.js';
|
|
4
|
+
describe('<TextArea>', () => {
|
|
5
|
+
it('should call the onKeyDown callback when provided', () => {
|
|
6
|
+
const onKeyDown = jest.fn();
|
|
7
|
+
render( /*#__PURE__*/React.createElement(TextAreaField, {
|
|
8
|
+
name: "foo",
|
|
9
|
+
value: "bar",
|
|
10
|
+
onKeyDown: onKeyDown
|
|
11
|
+
}));
|
|
12
|
+
fireEvent.keyDown(screen.getByRole('textbox'), {});
|
|
13
|
+
expect(onKeyDown).toHaveBeenCalledWith({
|
|
14
|
+
name: 'foo',
|
|
15
|
+
value: 'bar'
|
|
16
|
+
}, expect.objectContaining({}));
|
|
17
|
+
expect(onKeyDown).toHaveBeenCalledTimes(1);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -10,6 +10,7 @@ const TextAreaField = _ref => {
|
|
|
10
10
|
className,
|
|
11
11
|
onChange,
|
|
12
12
|
onFocus,
|
|
13
|
+
onKeyDown,
|
|
13
14
|
onBlur,
|
|
14
15
|
initialFocus,
|
|
15
16
|
dense,
|
|
@@ -50,6 +51,7 @@ const TextAreaField = _ref => {
|
|
|
50
51
|
minWidth: "220px"
|
|
51
52
|
}, /*#__PURE__*/React.createElement(TextArea, {
|
|
52
53
|
onFocus: onFocus,
|
|
54
|
+
onKeyDown: onKeyDown,
|
|
53
55
|
onBlur: onBlur,
|
|
54
56
|
onChange: onChange,
|
|
55
57
|
name: name,
|
|
@@ -143,6 +145,9 @@ TextAreaField.propTypes = {
|
|
|
143
145
|
onChange: PropTypes.func,
|
|
144
146
|
|
|
145
147
|
/** Called with signature ({ name: string, value: string }, event) */
|
|
146
|
-
onFocus: PropTypes.func
|
|
148
|
+
onFocus: PropTypes.func,
|
|
149
|
+
|
|
150
|
+
/** Called with signature ({ name: string, value: string }, event) */
|
|
151
|
+
onKeyDown: PropTypes.func
|
|
147
152
|
};
|
|
148
153
|
export { TextAreaField };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/text-area",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
4
4
|
"description": "UI TextArea",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"styled-jsx": "^4"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@dhis2/prop-types": "^3.
|
|
35
|
-
"@dhis2-ui/box": "8.
|
|
36
|
-
"@dhis2-ui/field": "8.
|
|
37
|
-
"@dhis2-ui/loader": "8.
|
|
38
|
-
"@dhis2-ui/status-icon": "8.
|
|
39
|
-
"@dhis2/ui-constants": "8.
|
|
40
|
-
"@dhis2/ui-icons": "8.
|
|
34
|
+
"@dhis2/prop-types": "^3.1.2",
|
|
35
|
+
"@dhis2-ui/box": "8.4.0",
|
|
36
|
+
"@dhis2-ui/field": "8.4.0",
|
|
37
|
+
"@dhis2-ui/loader": "8.4.0",
|
|
38
|
+
"@dhis2-ui/status-icon": "8.4.0",
|
|
39
|
+
"@dhis2/ui-constants": "8.4.0",
|
|
40
|
+
"@dhis2/ui-icons": "8.4.0",
|
|
41
41
|
"classnames": "^2.3.1",
|
|
42
42
|
"prop-types": "^15.7.2"
|
|
43
43
|
},
|