@dhis2-ui/text-area 9.11.0 → 9.11.1-beta.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.
- package/build/cjs/index.js +0 -2
- package/build/cjs/text-area/__tests__/text-area.test.js +1 -7
- package/build/cjs/text-area/features/accepts_initial_focus/index.js +1 -2
- package/build/cjs/text-area/features/can_be_blurred/index.js +1 -2
- package/build/cjs/text-area/features/can_be_changed/index.js +1 -2
- package/build/cjs/text-area/features/can_be_disabled/index.js +0 -1
- package/build/cjs/text-area/features/can_be_focused/index.js +1 -2
- package/build/cjs/text-area/features/common/index.js +0 -1
- package/build/cjs/text-area/index.js +0 -1
- package/build/cjs/text-area/text-area.e2e.stories.js +41 -0
- package/build/cjs/text-area/text-area.js +10 -61
- package/build/cjs/text-area/{text-area.stories.js → text-area.prod.stories.js} +31 -52
- package/build/cjs/text-area/text-area.styles.js +1 -4
- package/build/cjs/text-area-field/__tests__/text-area-field.test.js +1 -7
- package/build/cjs/text-area-field/features/can_be_required/index.js +0 -1
- package/build/cjs/text-area-field/index.js +0 -1
- package/build/cjs/text-area-field/text-area-field.e2e.stories.js +18 -0
- package/build/cjs/text-area-field/text-area-field.js +3 -34
- package/build/cjs/text-area-field/{text-area-field.stories.js → text-area-field.prod.stories.js} +35 -56
- package/build/es/text-area/features/accepts_initial_focus/index.js +1 -1
- package/build/es/text-area/features/can_be_blurred/index.js +1 -1
- package/build/es/text-area/features/can_be_changed/index.js +1 -1
- package/build/es/text-area/features/can_be_focused/index.js +1 -1
- package/build/es/text-area/{text-area.stories.e2e.js → text-area.e2e.stories.js} +13 -7
- package/build/es/text-area/text-area.js +7 -47
- package/build/es/text-area/{text-area.stories.js → text-area.prod.stories.js} +19 -14
- package/build/es/text-area/text-area.styles.js +1 -1
- package/build/es/text-area-field/text-area-field.e2e.stories.js +10 -0
- package/build/es/text-area-field/text-area-field.js +2 -26
- package/build/es/text-area-field/{text-area-field.stories.js → text-area-field.prod.stories.js} +18 -10
- package/package.json +10 -10
- package/build/cjs/text-area/text-area.stories.e2e.js +0 -30
- package/build/cjs/text-area-field/text-area-field.stories.e2e.js +0 -15
- package/build/es/text-area-field/text-area-field.stories.e2e.js +0 -8
package/build/cjs/index.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _react = require("@testing-library/react");
|
|
4
|
-
|
|
5
4
|
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
5
|
var _textArea = require("../text-area.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
7
|
describe('<TextArea>', () => {
|
|
12
8
|
it('should call the onKeyDown callback when provided', () => {
|
|
13
9
|
const onKeyDown = jest.fn();
|
|
@@ -16,9 +12,7 @@ describe('<TextArea>', () => {
|
|
|
16
12
|
value: "bar",
|
|
17
13
|
onKeyDown: onKeyDown
|
|
18
14
|
}));
|
|
19
|
-
|
|
20
15
|
_react.fireEvent.keyDown(_react.screen.getByRole('textbox'), {});
|
|
21
|
-
|
|
22
16
|
expect(onKeyDown).toHaveBeenCalledWith({
|
|
23
17
|
name: 'foo',
|
|
24
18
|
value: 'bar'
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a TextArea with initialFocus is rendered', () => {
|
|
6
|
-
cy.visitStory('TextArea', 'With
|
|
5
|
+
cy.visitStory('TextArea', 'With initial focus');
|
|
7
6
|
});
|
|
8
7
|
(0, _cypressCucumberPreprocessor.Then)('the TextArea is focused', () => {
|
|
9
8
|
cy.focused().parent('[data-test="dhis2-uicore-textarea"]').should('exist');
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a TextArea with initialFocus and onBlur handler is rendered', () => {
|
|
6
|
-
cy.visitStory('TextArea', 'With
|
|
5
|
+
cy.visitStory('TextArea', 'With initial focus and on blur');
|
|
7
6
|
});
|
|
8
7
|
(0, _cypressCucumberPreprocessor.When)('the TextArea is blurred', () => {
|
|
9
8
|
cy.get('[data-test="dhis2-uicore-textarea"] textarea').blur();
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a TextArea with onChange handler is rendered', () => {
|
|
6
|
-
cy.visitStory('TextArea', 'With
|
|
5
|
+
cy.visitStory('TextArea', 'With on change');
|
|
7
6
|
});
|
|
8
7
|
(0, _cypressCucumberPreprocessor.When)('the TextArea is filled with a character', () => {
|
|
9
8
|
cy.get('[data-test="dhis2-uicore-textarea"]').click().type('a');
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a TextArea with onFocus handler is rendered', () => {
|
|
6
|
-
cy.visitStory('TextArea', 'With
|
|
5
|
+
cy.visitStory('TextArea', 'With on focus');
|
|
7
6
|
});
|
|
8
7
|
(0, _cypressCucumberPreprocessor.When)('the TextArea is focused', () => {
|
|
9
8
|
cy.get('[data-test="dhis2-uicore-textarea"] textarea').focus();
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithOnFocus = exports.WithOnChange = exports.WithInitialFocusAndOnBlur = exports.WithInitialFocus = exports.WithDisabled = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _index = require("./index.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
window.onChange = window.Cypress && window.Cypress.cy.stub();
|
|
11
|
+
window.onBlur = window.Cypress && window.Cypress.cy.stub();
|
|
12
|
+
window.onFocus = window.Cypress && window.Cypress.cy.stub();
|
|
13
|
+
var _default = exports.default = {
|
|
14
|
+
title: 'TextArea'
|
|
15
|
+
};
|
|
16
|
+
const WithOnChange = () => /*#__PURE__*/_react.default.createElement(_index.TextArea, {
|
|
17
|
+
onChange: window.onChange,
|
|
18
|
+
name: "textarea"
|
|
19
|
+
});
|
|
20
|
+
exports.WithOnChange = WithOnChange;
|
|
21
|
+
const WithInitialFocusAndOnBlur = () => /*#__PURE__*/_react.default.createElement(_index.TextArea, {
|
|
22
|
+
initialFocus: true,
|
|
23
|
+
name: "textarea",
|
|
24
|
+
onBlur: window.onBlur
|
|
25
|
+
});
|
|
26
|
+
exports.WithInitialFocusAndOnBlur = WithInitialFocusAndOnBlur;
|
|
27
|
+
const WithOnFocus = () => /*#__PURE__*/_react.default.createElement(_index.TextArea, {
|
|
28
|
+
name: "textarea",
|
|
29
|
+
onFocus: window.onFocus
|
|
30
|
+
});
|
|
31
|
+
exports.WithOnFocus = WithOnFocus;
|
|
32
|
+
const WithInitialFocus = () => /*#__PURE__*/_react.default.createElement(_index.TextArea, {
|
|
33
|
+
name: "textarea",
|
|
34
|
+
initialFocus: true
|
|
35
|
+
});
|
|
36
|
+
exports.WithInitialFocus = WithInitialFocus;
|
|
37
|
+
const WithDisabled = () => /*#__PURE__*/_react.default.createElement(_index.TextArea, {
|
|
38
|
+
name: "textarea",
|
|
39
|
+
disabled: true
|
|
40
|
+
});
|
|
41
|
+
exports.WithDisabled = WithDisabled;
|
|
@@ -4,46 +4,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TextArea = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
|
-
var _statusIcon = require("@dhis2-ui/status-icon");
|
|
11
|
-
|
|
12
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
13
|
-
|
|
9
|
+
var _statusIcon = require("@dhis2-ui/status-icon");
|
|
14
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
|
|
16
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
13
|
var _textAreaStyles = require("./text-area.styles.js");
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
29
|
-
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
19
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
30
20
|
class TextArea extends _react.Component {
|
|
31
21
|
constructor() {
|
|
32
22
|
super(...arguments);
|
|
33
|
-
|
|
34
23
|
_defineProperty(this, "textareaRef", /*#__PURE__*/_react.default.createRef());
|
|
35
|
-
|
|
36
24
|
_defineProperty(this, "state", {
|
|
37
25
|
height: 'auto'
|
|
38
26
|
});
|
|
39
|
-
|
|
40
27
|
_defineProperty(this, "textareaDimensions", {
|
|
41
28
|
width: 0,
|
|
42
29
|
height: 0
|
|
43
30
|
});
|
|
44
|
-
|
|
45
31
|
_defineProperty(this, "userHasResized", false);
|
|
46
|
-
|
|
47
32
|
_defineProperty(this, "setTextareaDimensions", () => {
|
|
48
33
|
const textarea = this.textareaRef.current;
|
|
49
34
|
this.textareaDimensions = {
|
|
@@ -51,7 +36,6 @@ class TextArea extends _react.Component {
|
|
|
51
36
|
height: textarea.clientHeight
|
|
52
37
|
};
|
|
53
38
|
});
|
|
54
|
-
|
|
55
39
|
_defineProperty(this, "hasUserResized", () => {
|
|
56
40
|
const {
|
|
57
41
|
width: oldWidth,
|
|
@@ -63,68 +47,56 @@ class TextArea extends _react.Component {
|
|
|
63
47
|
height: newHeight
|
|
64
48
|
} = this.textareaDimensions;
|
|
65
49
|
const userHasResized = newWidth !== oldWidth || newHeight !== oldHeight;
|
|
66
|
-
|
|
67
50
|
if (userHasResized) {
|
|
68
51
|
this.userHasResized = true;
|
|
69
52
|
this.removeResizeListener();
|
|
70
53
|
}
|
|
71
54
|
});
|
|
72
|
-
|
|
73
55
|
_defineProperty(this, "handleChange", e => {
|
|
74
56
|
if (this.props.onChange) {
|
|
75
57
|
this.props.onChange(this.createHandlerPayload(e), e);
|
|
76
58
|
}
|
|
77
59
|
});
|
|
78
|
-
|
|
79
60
|
_defineProperty(this, "handleBlur", e => {
|
|
80
61
|
if (this.props.onBlur) {
|
|
81
62
|
this.props.onBlur(this.createHandlerPayload(e), e);
|
|
82
63
|
}
|
|
83
64
|
});
|
|
84
|
-
|
|
85
65
|
_defineProperty(this, "handleFocus", e => {
|
|
86
66
|
if (this.props.onFocus) {
|
|
87
67
|
this.props.onFocus(this.createHandlerPayload(e), e);
|
|
88
68
|
}
|
|
89
69
|
});
|
|
90
|
-
|
|
91
70
|
_defineProperty(this, "handleKeyDown", e => {
|
|
92
71
|
if (this.props.onKeyDown) {
|
|
93
72
|
this.props.onKeyDown(this.createHandlerPayload(e), e);
|
|
94
73
|
}
|
|
95
74
|
});
|
|
96
75
|
}
|
|
97
|
-
|
|
98
76
|
componentDidMount() {
|
|
99
77
|
this.attachResizeListener();
|
|
100
|
-
|
|
101
78
|
if (this.props.initialFocus) {
|
|
102
79
|
this.textareaRef.current.focus();
|
|
103
80
|
}
|
|
104
|
-
|
|
105
81
|
if (this.shouldDoAutoGrow()) {
|
|
106
82
|
this.setHeight();
|
|
107
83
|
}
|
|
108
84
|
}
|
|
109
|
-
|
|
110
85
|
componentDidUpdate(prevProps) {
|
|
111
86
|
if (this.shouldDoAutoGrow() && this.props.value !== prevProps.value) {
|
|
112
87
|
this.setHeight();
|
|
113
88
|
}
|
|
114
89
|
}
|
|
115
|
-
|
|
116
90
|
attachResizeListener() {
|
|
117
91
|
const textarea = this.textareaRef.current;
|
|
118
92
|
textarea.addEventListener('mousedown', this.setTextareaDimensions);
|
|
119
93
|
textarea.addEventListener('mouseup', this.hasUserResized);
|
|
120
94
|
}
|
|
121
|
-
|
|
122
95
|
removeResizeListener() {
|
|
123
96
|
const textarea = this.textareaRef.current;
|
|
124
97
|
textarea.removeEventListener('mousedown', this.setTextareaDimensions);
|
|
125
98
|
textarea.removeEventListener('mouseup', this.hasUserResized);
|
|
126
99
|
}
|
|
127
|
-
|
|
128
100
|
setHeight() {
|
|
129
101
|
const textarea = this.textareaRef.current;
|
|
130
102
|
const offset = textarea.offsetHeight - textarea.clientHeight;
|
|
@@ -133,18 +105,15 @@ class TextArea extends _react.Component {
|
|
|
133
105
|
height
|
|
134
106
|
});
|
|
135
107
|
}
|
|
136
|
-
|
|
137
108
|
shouldDoAutoGrow() {
|
|
138
109
|
return this.props.autoGrow && !this.userHasResized;
|
|
139
110
|
}
|
|
140
|
-
|
|
141
111
|
createHandlerPayload(e) {
|
|
142
112
|
return {
|
|
143
113
|
value: e.target.value,
|
|
144
114
|
name: this.props.name
|
|
145
115
|
};
|
|
146
116
|
}
|
|
147
|
-
|
|
148
117
|
render() {
|
|
149
118
|
const {
|
|
150
119
|
className,
|
|
@@ -169,7 +138,7 @@ class TextArea extends _react.Component {
|
|
|
169
138
|
} = this.state;
|
|
170
139
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
171
140
|
"data-test": dataTest,
|
|
172
|
-
className:
|
|
141
|
+
className: `jsx-${_textAreaStyles.styles.__hash}` + " " + _style.default.dynamic([["3036048772", [width, height, resize]]]) + " " + ((0, _classnames.default)('textarea', className) || "")
|
|
173
142
|
}, /*#__PURE__*/_react.default.createElement("textarea", {
|
|
174
143
|
id: name,
|
|
175
144
|
name: name,
|
|
@@ -184,7 +153,7 @@ class TextArea extends _react.Component {
|
|
|
184
153
|
onBlur: this.handleBlur,
|
|
185
154
|
onChange: this.handleChange,
|
|
186
155
|
rows: rows,
|
|
187
|
-
className:
|
|
156
|
+
className: `jsx-${_textAreaStyles.styles.__hash}` + " " + _style.default.dynamic([["3036048772", [width, height, resize]]]) + " " + ((0, _classnames.default)({
|
|
188
157
|
dense,
|
|
189
158
|
disabled,
|
|
190
159
|
error,
|
|
@@ -202,11 +171,9 @@ class TextArea extends _react.Component {
|
|
|
202
171
|
}, _textAreaStyles.styles), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
203
172
|
id: "3036048772",
|
|
204
173
|
dynamic: [width, height, resize]
|
|
205
|
-
}, [
|
|
174
|
+
}, [`textarea.__jsx-style-dynamic-selector{width:${width};height:${height};resize:${resize};}`]));
|
|
206
175
|
}
|
|
207
|
-
|
|
208
176
|
}
|
|
209
|
-
|
|
210
177
|
exports.TextArea = TextArea;
|
|
211
178
|
TextArea.defaultProps = {
|
|
212
179
|
rows: 4,
|
|
@@ -219,59 +186,41 @@ TextArea.propTypes = {
|
|
|
219
186
|
autoGrow: _propTypes.default.bool,
|
|
220
187
|
className: _propTypes.default.string,
|
|
221
188
|
dataTest: _propTypes.default.string,
|
|
222
|
-
|
|
223
189
|
/** Compact mode */
|
|
224
190
|
dense: _propTypes.default.bool,
|
|
225
|
-
|
|
226
191
|
/** Disables the textarea and makes in non-interactive */
|
|
227
192
|
disabled: _propTypes.default.bool,
|
|
228
|
-
|
|
229
193
|
/** Applies 'error' styles for validation feedback. Mutually exclusive with `valid` and `warning` props */
|
|
230
194
|
error: _uiConstants.sharedPropTypes.statusPropType,
|
|
231
|
-
|
|
232
195
|
/** Grabs initial focus on the page */
|
|
233
196
|
initialFocus: _propTypes.default.bool,
|
|
234
|
-
|
|
235
197
|
/** Adds a loading spinner */
|
|
236
198
|
loading: _propTypes.default.bool,
|
|
237
|
-
|
|
238
199
|
/** Name associated with the text area. Passed in object argument to event handlers. */
|
|
239
200
|
name: _propTypes.default.string,
|
|
240
|
-
|
|
241
201
|
/** Placeholder text for an empty textarea */
|
|
242
202
|
placeholder: _propTypes.default.string,
|
|
243
|
-
|
|
244
203
|
/** Makes the textarea read-only */
|
|
245
204
|
readOnly: _propTypes.default.bool,
|
|
246
|
-
|
|
247
205
|
/** [Resize property](https://developer.mozilla.org/en-US/docs/Web/CSS/resize) for the textarea element */
|
|
248
206
|
resize: _propTypes.default.oneOf(['none', 'both', 'horizontal', 'vertical']),
|
|
249
|
-
|
|
250
207
|
/** Initial height of the textarea, in lines of text */
|
|
251
208
|
rows: _propTypes.default.number,
|
|
252
209
|
tabIndex: _propTypes.default.string,
|
|
253
|
-
|
|
254
210
|
/** Applies 'valid' styles for validation feedback. Mutually exclusive with `warning` and `error` props */
|
|
255
211
|
valid: _uiConstants.sharedPropTypes.statusPropType,
|
|
256
|
-
|
|
257
212
|
/** Value in the textarea. Can be used to control component (recommended). Passed in object argument to event handlers. */
|
|
258
213
|
value: _propTypes.default.string,
|
|
259
|
-
|
|
260
214
|
/** Applies 'warning' styles for validation feedback. Mutually exclusive with `valid` and `error` props */
|
|
261
215
|
warning: _uiConstants.sharedPropTypes.statusPropType,
|
|
262
|
-
|
|
263
216
|
/** Width of the text area. Can be any valid CSS measurement */
|
|
264
217
|
width: _propTypes.default.string,
|
|
265
|
-
|
|
266
218
|
/** Called with signature ({ name: string, value: string }, event) */
|
|
267
219
|
onBlur: _propTypes.default.func,
|
|
268
|
-
|
|
269
220
|
/** Called with signature ({ name: string, value: string }, event) */
|
|
270
221
|
onChange: _propTypes.default.func,
|
|
271
|
-
|
|
272
222
|
/** Called with signature ({ name: string, value: string }, event) */
|
|
273
223
|
onFocus: _propTypes.default.func,
|
|
274
|
-
|
|
275
224
|
/** Called with signature ({ name: string, value: string }, event) */
|
|
276
225
|
onKeyDown: _propTypes.default.func
|
|
277
226
|
};
|
|
@@ -4,47 +4,46 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.WithValue = exports.TextareaTextOverflow = exports.StatusWarning = exports.StatusValid = exports.StatusLoading = exports.StatusError = exports.Rows = exports.Resize = exports.ReadOnly = exports.RTL = exports.PlaceholderNoValue = exports.Focus = exports.Disabled = exports.Dense = exports.Default = exports.Autogrow = void 0;
|
|
7
|
-
|
|
8
7
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _index = require("./index.js");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
12
|
+
const description = `
|
|
13
|
+
A textarea allows multiple lines of text input. Use a textarea wherever a user needs to input a lot of information. Do not use a textarea if a short, single line of content is expected.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
Options for textarea inputs are:
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
- Rows: the height of the input, defined by the number of rows of text
|
|
18
|
+
- Resizable: whether the textarea can be resized by the user or not. Can be set for both width and height.
|
|
19
|
+
- Autoheight: if enabled, the texarea will grow in height to adapt to the content.
|
|
19
20
|
|
|
21
|
+
\`\`\`js
|
|
22
|
+
import { TextArea } from '@dhis2/ui'
|
|
23
|
+
\`\`\`
|
|
24
|
+
`;
|
|
20
25
|
window.onChange = (payload, event) => {
|
|
21
26
|
console.log('onChange payload', payload);
|
|
22
27
|
console.log('onChange event', event);
|
|
23
28
|
};
|
|
24
|
-
|
|
25
29
|
window.onFocus = (payload, event) => {
|
|
26
30
|
console.log('onFocus payload', payload);
|
|
27
31
|
console.log('onFocus event', event);
|
|
28
32
|
};
|
|
29
|
-
|
|
30
33
|
window.onBlur = (payload, event) => {
|
|
31
34
|
console.log('onBlur payload', payload);
|
|
32
35
|
console.log('onBlur event', event);
|
|
33
36
|
};
|
|
34
|
-
|
|
35
37
|
const onChange = function () {
|
|
36
38
|
return window.onChange(...arguments);
|
|
37
39
|
};
|
|
38
|
-
|
|
39
40
|
const onFocus = function () {
|
|
40
41
|
return window.onFocus(...arguments);
|
|
41
42
|
};
|
|
42
|
-
|
|
43
43
|
const onBlur = function () {
|
|
44
44
|
return window.onBlur(...arguments);
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
var _default = {
|
|
46
|
+
var _default = exports.default = {
|
|
48
47
|
title: 'Text Area',
|
|
49
48
|
component: _index.TextArea,
|
|
50
49
|
parameters: {
|
|
@@ -55,11 +54,14 @@ var _default = {
|
|
|
55
54
|
}
|
|
56
55
|
},
|
|
57
56
|
argTypes: {
|
|
58
|
-
valid: {
|
|
57
|
+
valid: {
|
|
58
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
59
59
|
},
|
|
60
|
-
error: {
|
|
60
|
+
error: {
|
|
61
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
61
62
|
},
|
|
62
|
-
warning: {
|
|
63
|
+
warning: {
|
|
64
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
63
65
|
}
|
|
64
66
|
},
|
|
65
67
|
args: {
|
|
@@ -69,54 +71,43 @@ var _default = {
|
|
|
69
71
|
onBlur
|
|
70
72
|
}
|
|
71
73
|
};
|
|
72
|
-
exports.default = _default;
|
|
73
|
-
|
|
74
74
|
const Template = args => /*#__PURE__*/_react.default.createElement(_index.TextArea, args);
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
exports.Default = Default;
|
|
78
|
-
const PlaceholderNoValue = Template.bind({});
|
|
79
|
-
exports.PlaceholderNoValue = PlaceholderNoValue;
|
|
75
|
+
const Default = exports.Default = Template.bind({});
|
|
76
|
+
const PlaceholderNoValue = exports.PlaceholderNoValue = Template.bind({});
|
|
80
77
|
PlaceholderNoValue.args = {
|
|
81
78
|
placeholder: 'Hold the place'
|
|
82
79
|
};
|
|
83
80
|
PlaceholderNoValue.storyName = 'Placeholder, no value';
|
|
84
|
-
const WithValue = Template.bind({});
|
|
85
|
-
exports.WithValue = WithValue;
|
|
81
|
+
const WithValue = exports.WithValue = Template.bind({});
|
|
86
82
|
WithValue.args = {
|
|
87
83
|
value: 'This is set through the value prop, which means the component is controlled.'
|
|
88
84
|
};
|
|
89
85
|
WithValue.storyName = 'With value';
|
|
90
|
-
|
|
91
86
|
const Focus = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.TextArea, _extends({}, args, {
|
|
92
87
|
initialFocus: true,
|
|
93
88
|
className: "initially-focused"
|
|
94
89
|
})), /*#__PURE__*/_react.default.createElement(_index.TextArea, _extends({}, args, {
|
|
95
90
|
className: "initially-unfocused"
|
|
96
91
|
})));
|
|
97
|
-
|
|
98
92
|
exports.Focus = Focus;
|
|
99
93
|
Focus.parameters = {
|
|
100
94
|
docs: {
|
|
101
95
|
disable: true
|
|
102
96
|
}
|
|
103
97
|
};
|
|
104
|
-
const StatusValid = Template.bind({});
|
|
105
|
-
exports.StatusValid = StatusValid;
|
|
98
|
+
const StatusValid = exports.StatusValid = Template.bind({});
|
|
106
99
|
StatusValid.args = {
|
|
107
100
|
valid: true,
|
|
108
101
|
value: 'This value is valid'
|
|
109
102
|
};
|
|
110
103
|
StatusValid.storyName = 'Status: Valid';
|
|
111
|
-
const StatusWarning = Template.bind({});
|
|
112
|
-
exports.StatusWarning = StatusWarning;
|
|
104
|
+
const StatusWarning = exports.StatusWarning = Template.bind({});
|
|
113
105
|
StatusWarning.args = {
|
|
114
106
|
warning: true,
|
|
115
107
|
value: 'This value produces a warning'
|
|
116
108
|
};
|
|
117
109
|
StatusWarning.storyName = 'Status: Warning';
|
|
118
|
-
const StatusError = Template.bind({});
|
|
119
|
-
exports.StatusError = StatusError;
|
|
110
|
+
const StatusError = exports.StatusError = Template.bind({});
|
|
120
111
|
StatusError.args = {
|
|
121
112
|
error: true,
|
|
122
113
|
value: 'This value produces an error',
|
|
@@ -124,44 +115,37 @@ StatusError.args = {
|
|
|
124
115
|
validationText: 'This describes the error, if a message is supplied.'
|
|
125
116
|
};
|
|
126
117
|
StatusError.storyName = 'Status: Error';
|
|
127
|
-
const StatusLoading = Template.bind({});
|
|
128
|
-
exports.StatusLoading = StatusLoading;
|
|
118
|
+
const StatusLoading = exports.StatusLoading = Template.bind({});
|
|
129
119
|
StatusLoading.args = {
|
|
130
120
|
loading: true,
|
|
131
121
|
value: 'This value produces a loadingn state'
|
|
132
122
|
};
|
|
133
123
|
StatusLoading.storyName = 'Status: Loading';
|
|
134
|
-
const Disabled = Template.bind({});
|
|
135
|
-
exports.Disabled = Disabled;
|
|
124
|
+
const Disabled = exports.Disabled = Template.bind({});
|
|
136
125
|
Disabled.args = {
|
|
137
126
|
disabled: true,
|
|
138
127
|
value: 'This field is disabled'
|
|
139
128
|
};
|
|
140
|
-
const ReadOnly = Template.bind({});
|
|
141
|
-
exports.ReadOnly = ReadOnly;
|
|
129
|
+
const ReadOnly = exports.ReadOnly = Template.bind({});
|
|
142
130
|
ReadOnly.args = {
|
|
143
131
|
readOnly: true,
|
|
144
132
|
value: 'This field is readOnly'
|
|
145
133
|
};
|
|
146
|
-
const Dense = Template.bind({});
|
|
147
|
-
exports.Dense = Dense;
|
|
134
|
+
const Dense = exports.Dense = Template.bind({});
|
|
148
135
|
Dense.args = {
|
|
149
136
|
dense: true,
|
|
150
137
|
value: 'This field is dense'
|
|
151
138
|
};
|
|
152
|
-
const TextareaTextOverflow = Template.bind({});
|
|
153
|
-
exports.TextareaTextOverflow = TextareaTextOverflow;
|
|
139
|
+
const TextareaTextOverflow = exports.TextareaTextOverflow = Template.bind({});
|
|
154
140
|
TextareaTextOverflow.args = {
|
|
155
141
|
label: 'I have a scrollbar',
|
|
156
142
|
value: ['A line of text', 'A line of text', 'A line of text', 'A line of text', 'A line of text', 'A line of text', 'A line of text', 'A line of text', 'A line of text', 'A line of text', 'A line of text', 'A line of text', 'A line of text', 'A line of text', 'A line of text'].join('\n')
|
|
157
143
|
};
|
|
158
|
-
const Rows = Template.bind({});
|
|
159
|
-
exports.Rows = Rows;
|
|
144
|
+
const Rows = exports.Rows = Template.bind({});
|
|
160
145
|
Rows.args = {
|
|
161
146
|
rows: 8,
|
|
162
147
|
label: 'You can set the height with the rows prop. I have 8'
|
|
163
148
|
};
|
|
164
|
-
|
|
165
149
|
const Resize = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.TextArea, _extends({}, args, {
|
|
166
150
|
name: "textarea1",
|
|
167
151
|
label: "Resize: vertical (default)"
|
|
@@ -178,9 +162,7 @@ const Resize = args => /*#__PURE__*/_react.default.createElement(_react.default.
|
|
|
178
162
|
label: "Resize: horizontal",
|
|
179
163
|
resize: "horizontal"
|
|
180
164
|
})));
|
|
181
|
-
|
|
182
165
|
exports.Resize = Resize;
|
|
183
|
-
|
|
184
166
|
const Autogrow = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.TextArea, _extends({}, args, {
|
|
185
167
|
name: "textarea1",
|
|
186
168
|
label: "Autogrow step 1",
|
|
@@ -204,13 +186,10 @@ const Autogrow = args => /*#__PURE__*/_react.default.createElement(_react.defaul
|
|
|
204
186
|
label: "Autogrow step 4",
|
|
205
187
|
value: ['This TextArea has a height of two rows', 'it also has autoGrow set to true so it will grow with the content.', 'See: rows is still 2...', 'And now I have 4 lines and still no scroll bar in sight.'].join('\n')
|
|
206
188
|
})));
|
|
207
|
-
|
|
208
189
|
exports.Autogrow = Autogrow;
|
|
209
|
-
|
|
210
190
|
const RTL = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
211
191
|
dir: "rtl"
|
|
212
192
|
}, /*#__PURE__*/_react.default.createElement(Template, args));
|
|
213
|
-
|
|
214
193
|
exports.RTL = RTL;
|
|
215
194
|
RTL.args = {
|
|
216
195
|
valid: true,
|
|
@@ -4,9 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.styles = void 0;
|
|
7
|
-
|
|
8
7
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
|
-
|
|
10
|
-
const styles = [".textarea.jsx-1284170182{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:".concat(_uiConstants.spacers.dp8, ";}"), "textarea.jsx-1284170182{box-sizing:border-box;padding:8px 12px;color:".concat(_uiConstants.colors.grey900, ";background-color:white;border:1px solid ").concat(_uiConstants.colors.grey500, ";border-radius:3px;box-shadow:inset 0 0 1px 0 rgba(48,54,60,0.1);outline:0;font-size:14px;line-height:17px;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;}"), "textarea.dense.jsx-1284170182{padding:6px 8px;}", "textarea.jsx-1284170182:focus{outline:none;box-shadow:inset 0 0 0 2px ".concat(_uiConstants.theme.focus, ";border-color:").concat(_uiConstants.theme.focus, ";}"), "textarea.valid.jsx-1284170182{border-color:".concat(_uiConstants.theme.valid, ";}"), "textarea.warning.jsx-1284170182{border-color:".concat(_uiConstants.theme.warning, ";}"), "textarea.error.jsx-1284170182{border-color:".concat(_uiConstants.theme.error, ";}"), "textarea.read-only.jsx-1284170182{background-color:".concat(_uiConstants.colors.grey100, ";border-color:").concat(_uiConstants.colors.grey500, ";cursor:text;}"), "textarea.disabled.jsx-1284170182{background-color:".concat(_uiConstants.colors.grey100, ";border-color:").concat(_uiConstants.colors.grey500, ";color:").concat(_uiConstants.theme.disabled, ";cursor:not-allowed;}")];
|
|
11
|
-
exports.styles = styles;
|
|
8
|
+
const styles = exports.styles = [`.textarea.jsx-1284170182{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;gap:${_uiConstants.spacers.dp8};}`, `textarea.jsx-1284170182{box-sizing:border-box;padding:8px 12px;color:${_uiConstants.colors.grey900};background-color:white;border:1px solid ${_uiConstants.colors.grey500};border-radius:3px;box-shadow:inset 0 0 1px 0 rgba(48,54,60,0.1);outline:0;font-size:14px;line-height:17px;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;}`, "textarea.dense.jsx-1284170182{padding:6px 8px;}", `textarea.jsx-1284170182:focus{outline:none;box-shadow:inset 0 0 0 2px ${_uiConstants.theme.focus};border-color:${_uiConstants.theme.focus};}`, `textarea.valid.jsx-1284170182{border-color:${_uiConstants.theme.valid};}`, `textarea.warning.jsx-1284170182{border-color:${_uiConstants.theme.warning};}`, `textarea.error.jsx-1284170182{border-color:${_uiConstants.theme.error};}`, `textarea.read-only.jsx-1284170182{background-color:${_uiConstants.colors.grey100};border-color:${_uiConstants.colors.grey500};cursor:text;}`, `textarea.disabled.jsx-1284170182{background-color:${_uiConstants.colors.grey100};border-color:${_uiConstants.colors.grey500};color:${_uiConstants.theme.disabled};cursor:not-allowed;}`];
|
|
12
9
|
styles.__hash = "1284170182";
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _react = require("@testing-library/react");
|
|
4
|
-
|
|
5
4
|
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
5
|
var _textAreaField = require("../text-area-field.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
7
|
describe('<TextArea>', () => {
|
|
12
8
|
it('should call the onKeyDown callback when provided', () => {
|
|
13
9
|
const onKeyDown = jest.fn();
|
|
@@ -16,9 +12,7 @@ describe('<TextArea>', () => {
|
|
|
16
12
|
value: "bar",
|
|
17
13
|
onKeyDown: onKeyDown
|
|
18
14
|
}));
|
|
19
|
-
|
|
20
15
|
_react.fireEvent.keyDown(_react.screen.getByRole('textbox'), {});
|
|
21
|
-
|
|
22
16
|
expect(onKeyDown).toHaveBeenCalledWith({
|
|
23
17
|
name: 'foo',
|
|
24
18
|
value: 'bar'
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a TextAreaField with label and a required flag is rendered', () => {
|
|
6
5
|
cy.visitStory('TextAreaField', 'With label and required');
|
|
7
6
|
});
|