@dxc-technology/halstack-react 0.0.0-3b81157 → 0.0.0-3ce9060
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/HalstackContext.d.ts +11 -1
- package/HalstackContext.js +1 -1
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +2 -14
- package/accordion/Accordion.stories.tsx +2 -100
- package/accordion/types.d.ts +0 -12
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +21 -42
- package/accordion-group/AccordionGroup.stories.tsx +77 -76
- package/accordion-group/AccordionGroup.test.js +6 -16
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +0 -12
- package/alert/Alert.js +1 -3
- package/box/Box.d.ts +1 -1
- package/box/Box.js +5 -22
- package/box/Box.stories.tsx +25 -53
- package/box/types.d.ts +0 -12
- package/button/Button.d.ts +1 -1
- package/button/Button.js +45 -54
- package/button/Button.stories.tsx +1 -1
- package/button/Button.test.js +11 -0
- package/button/types.d.ts +4 -0
- package/card/Card.d.ts +1 -1
- package/card/Card.js +18 -35
- package/card/Card.stories.tsx +0 -29
- package/card/types.d.ts +1 -7
- package/chip/Chip.js +23 -36
- package/chip/Chip.stories.tsx +25 -17
- package/common/coreTokens.js +1 -1
- package/common/variables.d.ts +10 -0
- package/common/variables.js +10 -0
- package/date-input/Calendar.js +2 -2
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +4 -22
- package/dialog/Dialog.stories.tsx +52 -176
- package/dialog/types.d.ts +0 -13
- package/file-input/FileItem.js +2 -2
- package/file-input/types.d.ts +1 -1
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +43 -61
- package/footer/Footer.stories.tsx +19 -95
- package/footer/Footer.test.js +3 -1
- package/footer/types.d.ts +10 -12
- package/grid/Grid.d.ts +1 -1
- package/grid/Grid.js +1 -1
- package/grid/Grid.stories.tsx +38 -38
- package/header/Header.d.ts +1 -1
- package/header/Header.js +3 -30
- package/header/Header.stories.tsx +7 -71
- package/header/types.d.ts +0 -14
- package/image/Image.d.ts +4 -0
- package/image/Image.js +85 -0
- package/image/Image.stories.tsx +127 -0
- package/image/types.d.ts +72 -0
- package/layout/ApplicationLayout.d.ts +2 -2
- package/layout/ApplicationLayout.js +14 -11
- package/layout/ApplicationLayout.stories.tsx +1 -1
- package/layout/Icons.d.ts +7 -4
- package/layout/Icons.js +52 -56
- package/main.d.ts +2 -1
- package/main.js +8 -0
- package/nav-tabs/NavTabs.d.ts +2 -2
- package/nav-tabs/NavTabs.js +7 -10
- package/nav-tabs/NavTabs.stories.tsx +14 -0
- package/nav-tabs/Tab.js +22 -26
- package/nav-tabs/types.d.ts +8 -9
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +6 -4
- package/number-input/NumberInput.test.js +278 -95
- package/package.json +2 -2
- package/paginator/Paginator.js +1 -1
- package/paginator/Paginator.test.js +13 -0
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +39 -0
- package/password-input/PasswordInput.js +35 -82
- package/password-input/PasswordInput.stories.tsx +1 -0
- package/password-input/PasswordInput.test.js +27 -34
- package/radio-group/Radio.js +10 -10
- package/radio-group/RadioGroup.js +8 -10
- package/select/Select.stories.tsx +3 -3
- package/select/Select.test.js +4 -4
- package/text-input/TextInput.js +62 -78
- package/textarea/Textarea.js +24 -22
- package/textarea/Textarea.stories.jsx +8 -0
- package/textarea/Textarea.test.js +59 -15
- package/textarea/types.d.ts +4 -0
- package/toggle-group/ToggleGroup.js +79 -56
- package/toggle-group/ToggleGroup.stories.tsx +6 -3
- package/toggle-group/ToggleGroup.test.js +37 -23
- package/toggle-group/types.d.ts +22 -13
- package/useTheme.d.ts +10 -0
- package/utils/FocusLock.js +2 -3
- package/card/ice-cream.jpg +0 -0
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- /package/{number-input/numberInputContextTypes.js → image/types.js} +0 -0
package/text-input/TextInput.js
CHANGED
|
@@ -29,7 +29,7 @@ var _utils = require("../common/utils");
|
|
|
29
29
|
|
|
30
30
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _NumberInput = require("../number-input/NumberInput");
|
|
33
33
|
|
|
34
34
|
var _Suggestions = _interopRequireDefault(require("./Suggestions"));
|
|
35
35
|
|
|
@@ -88,20 +88,20 @@ var hasSuggestions = function hasSuggestions(suggestions) {
|
|
|
88
88
|
return typeof suggestions === "function" || (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) > 0;
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
var
|
|
91
|
+
var isRequired = function isRequired(value, optional) {
|
|
92
92
|
return value === "" && !optional;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
var isLengthIncorrect = function isLengthIncorrect(value, minLength, maxLength) {
|
|
96
|
-
return value
|
|
96
|
+
return value != null && (value.length < minLength || value.length > maxLength);
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
var isNumberIncorrect = function isNumberIncorrect(value, minNumber, maxNumber) {
|
|
100
|
-
return
|
|
100
|
+
return value < minNumber || value > maxNumber;
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
-
var
|
|
104
|
-
return pattern && !new RegExp(pattern).test(value);
|
|
103
|
+
var patternMismatch = function patternMismatch(pattern, value) {
|
|
104
|
+
return pattern != null && !new RegExp(pattern).test(value);
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
@@ -182,10 +182,10 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
182
182
|
var colorsTheme = (0, _useTheme["default"])();
|
|
183
183
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
184
184
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
185
|
-
var numberInputContext = (0, _react.useContext)(
|
|
185
|
+
var numberInputContext = (0, _react.useContext)(_NumberInput.NumberInputContext);
|
|
186
186
|
|
|
187
187
|
var getNumberErrorMessage = function getNumberErrorMessage(value) {
|
|
188
|
-
if (
|
|
188
|
+
if (value < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) return translatedLabels.numberInput.valueGreaterThanOrEqualToErrorMessage(numberInputContext.minNumber);else if (value > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) return translatedLabels.numberInput.valueLessThanOrEqualToErrorMessage(numberInputContext.maxNumber);
|
|
189
189
|
};
|
|
190
190
|
|
|
191
191
|
var getTextInputWidth = (0, _react.useCallback)(function () {
|
|
@@ -207,22 +207,22 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
207
207
|
};
|
|
208
208
|
|
|
209
209
|
var changeValue = function changeValue(newValue) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (
|
|
213
|
-
value:
|
|
210
|
+
var formattedValue = typeof newValue === "number" ? newValue.toString() : newValue;
|
|
211
|
+
value !== null && value !== void 0 ? value : setInnerValue(formattedValue);
|
|
212
|
+
if (isRequired(formattedValue, optional)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
213
|
+
value: formattedValue,
|
|
214
214
|
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
215
|
-
});else if (isLengthIncorrect(
|
|
216
|
-
value:
|
|
215
|
+
});else if (isLengthIncorrect(formattedValue, minLength, maxLength)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
216
|
+
value: formattedValue,
|
|
217
217
|
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
218
|
-
});else if (
|
|
219
|
-
value:
|
|
218
|
+
});else if (patternMismatch(pattern, formattedValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
219
|
+
value: formattedValue,
|
|
220
220
|
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
221
|
-
});else if (isNumberIncorrect(newValue, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
222
|
-
value:
|
|
223
|
-
error: getNumberErrorMessage(newValue)
|
|
221
|
+
});else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && isNumberIncorrect(Number(newValue), numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
222
|
+
value: formattedValue,
|
|
223
|
+
error: getNumberErrorMessage(Number(newValue))
|
|
224
224
|
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
225
|
-
value:
|
|
225
|
+
value: formattedValue
|
|
226
226
|
});
|
|
227
227
|
};
|
|
228
228
|
|
|
@@ -242,18 +242,18 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
242
242
|
|
|
243
243
|
var handleInputOnBlur = function handleInputOnBlur(event) {
|
|
244
244
|
closeSuggestions();
|
|
245
|
-
if (
|
|
245
|
+
if (isRequired(event.target.value, optional)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
246
246
|
value: event.target.value,
|
|
247
247
|
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
248
248
|
});else if (isLengthIncorrect(event.target.value, minLength, maxLength)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
249
249
|
value: event.target.value,
|
|
250
250
|
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
251
|
-
});else if (
|
|
251
|
+
});else if (patternMismatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
252
252
|
value: event.target.value,
|
|
253
253
|
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
254
|
-
});else if (isNumberIncorrect(event.target.value, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
254
|
+
});else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && isNumberIncorrect(Number(event.target.value), numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
255
255
|
value: event.target.value,
|
|
256
|
-
error: getNumberErrorMessage(event.target.value)
|
|
256
|
+
error: getNumberErrorMessage(Number(event.target.value))
|
|
257
257
|
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
258
258
|
value: event.target.value
|
|
259
259
|
});
|
|
@@ -338,49 +338,33 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
338
338
|
var setNumberProps = function setNumberProps(type, min, max, step) {
|
|
339
339
|
var _inputRef$current2, _inputRef$current3, _inputRef$current4, _inputRef$current5;
|
|
340
340
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
341
|
+
min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.setAttribute("min", min));
|
|
342
|
+
max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.setAttribute("max", max));
|
|
343
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.setAttribute("step", step);
|
|
344
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : _inputRef$current5.setAttribute("type", type);
|
|
345
345
|
};
|
|
346
346
|
|
|
347
347
|
var decrementNumber = function decrementNumber() {
|
|
348
|
-
var
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);
|
|
354
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && (parseInt(numberValue) === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || numberValue === "" || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && parseInt(numberValue) - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber))) {
|
|
355
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);
|
|
356
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && parseInt(numberValue) - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) >= (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue !== "") {
|
|
357
|
-
changeValue(parseInt(numberValue) - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
358
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue == "") {
|
|
359
|
-
changeValue(-(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
360
|
-
} else if (numberValue === "") {
|
|
361
|
-
changeValue(-1);
|
|
348
|
+
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
349
|
+
var numberValue = Number(currentValue);
|
|
350
|
+
var steppedValue = Math.round((numberValue - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) + Number.EPSILON) * 100) / 100;
|
|
351
|
+
|
|
352
|
+
if (currentValue !== "") {
|
|
353
|
+
if (numberValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || steppedValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberValue);else if (numberValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else if (numberValue === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else changeValue(steppedValue);
|
|
362
354
|
} else {
|
|
363
|
-
changeValue(
|
|
355
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) >= 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) < 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(-numberInputContext.stepNumber);
|
|
364
356
|
}
|
|
365
357
|
};
|
|
366
358
|
|
|
367
359
|
var incrementNumber = function incrementNumber() {
|
|
368
|
-
var
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);
|
|
374
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.maxNumber && (parseInt(numberValue) === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && parseInt(numberValue) + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber))) {
|
|
375
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);
|
|
376
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.maxNumber && parseInt(numberValue) + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) <= (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue !== "") {
|
|
377
|
-
changeValue(parseInt(numberValue) + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
378
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue == "") {
|
|
379
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber);
|
|
380
|
-
} else if (numberValue === "") {
|
|
381
|
-
changeValue(1);
|
|
360
|
+
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
361
|
+
var numberValue = Number(currentValue);
|
|
362
|
+
var steppedValue = Math.round((numberValue + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) + Number.EPSILON) * 100) / 100;
|
|
363
|
+
|
|
364
|
+
if (currentValue !== "") {
|
|
365
|
+
if (numberValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) || steppedValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberValue);else if (numberValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if (numberValue === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(steppedValue);
|
|
382
366
|
} else {
|
|
383
|
-
changeValue(
|
|
367
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) > 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) <= 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(numberInputContext.stepNumber);
|
|
384
368
|
}
|
|
385
369
|
};
|
|
386
370
|
|
|
@@ -410,7 +394,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
410
394
|
changeVisualFocusIndex(-1);
|
|
411
395
|
}
|
|
412
396
|
|
|
413
|
-
|
|
397
|
+
numberInputContext != null && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
414
398
|
}, [value, innerValue, suggestions, numberInputContext]);
|
|
415
399
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
416
400
|
theme: colorsTheme.textInput
|
|
@@ -502,51 +486,51 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
502
486
|
backgroundType: backgroundType,
|
|
503
487
|
"aria-label": "Error"
|
|
504
488
|
}, _Icons["default"].error), !disabled && clearable && (value !== null && value !== void 0 ? value : innerValue).length > 0 && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
489
|
+
"aria-label": translatedLabels.textInput.clearFieldActionTitle,
|
|
505
490
|
onClick: handleClearActionOnClick,
|
|
506
491
|
onMouseDown: function onMouseDown(event) {
|
|
507
492
|
event.stopPropagation();
|
|
508
493
|
},
|
|
509
|
-
backgroundType: backgroundType,
|
|
510
494
|
tabIndex: tabIndex,
|
|
511
495
|
title: translatedLabels.textInput.clearFieldActionTitle,
|
|
512
|
-
"
|
|
513
|
-
|
|
496
|
+
type: "button",
|
|
497
|
+
backgroundType: backgroundType
|
|
514
498
|
}, _Icons["default"].clear), (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(Action, {
|
|
515
|
-
|
|
499
|
+
"aria-label": translatedLabels.numberInput.decrementValueTitle,
|
|
516
500
|
disabled: disabled,
|
|
517
501
|
onClick: handleDecrementActionOnClick,
|
|
518
502
|
onMouseDown: function onMouseDown(event) {
|
|
519
503
|
event.stopPropagation();
|
|
520
504
|
},
|
|
521
|
-
|
|
505
|
+
ref: actionRef,
|
|
522
506
|
tabIndex: tabIndex,
|
|
523
507
|
title: translatedLabels.numberInput.decrementValueTitle,
|
|
524
|
-
"
|
|
525
|
-
|
|
508
|
+
type: "button",
|
|
509
|
+
backgroundType: backgroundType
|
|
526
510
|
}, _Icons["default"].decrement), /*#__PURE__*/_react["default"].createElement(Action, {
|
|
527
|
-
|
|
511
|
+
"aria-label": translatedLabels.numberInput.incrementValueTitle,
|
|
528
512
|
disabled: disabled,
|
|
529
513
|
onClick: handleIncrementActionOnClick,
|
|
530
514
|
onMouseDown: function onMouseDown(event) {
|
|
531
515
|
event.stopPropagation();
|
|
532
516
|
},
|
|
533
|
-
|
|
517
|
+
ref: actionRef,
|
|
534
518
|
tabIndex: tabIndex,
|
|
535
519
|
title: translatedLabels.numberInput.incrementValueTitle,
|
|
536
|
-
"
|
|
537
|
-
|
|
520
|
+
type: "button",
|
|
521
|
+
backgroundType: backgroundType
|
|
538
522
|
}, _Icons["default"].increment)), action && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
539
|
-
|
|
523
|
+
"aria-label": action.title,
|
|
540
524
|
disabled: disabled,
|
|
541
525
|
onClick: action.onClick,
|
|
542
526
|
onMouseDown: function onMouseDown(event) {
|
|
543
527
|
event.stopPropagation();
|
|
544
528
|
},
|
|
545
|
-
|
|
546
|
-
"aria-label": action.title,
|
|
547
|
-
backgroundType: backgroundType,
|
|
529
|
+
ref: actionRef,
|
|
548
530
|
tabIndex: tabIndex,
|
|
549
|
-
|
|
531
|
+
title: action.title,
|
|
532
|
+
type: "button",
|
|
533
|
+
backgroundType: backgroundType
|
|
550
534
|
}, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
551
535
|
src: action.icon
|
|
552
536
|
}) : action.icon), suffix && /*#__PURE__*/_react["default"].createElement(Suffix, {
|
|
@@ -559,7 +543,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
559
543
|
}, error)));
|
|
560
544
|
});
|
|
561
545
|
|
|
562
|
-
var TextInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n
|
|
546
|
+
var TextInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
563
547
|
return calculateWidth(props.margin, props.size);
|
|
564
548
|
}, function (props) {
|
|
565
549
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -607,7 +591,7 @@ var HelperText = _styledComponents["default"].span(_templateObject4 || (_templat
|
|
|
607
591
|
return props.theme.helperTextLineHeight;
|
|
608
592
|
});
|
|
609
593
|
|
|
610
|
-
var InputContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
594
|
+
var InputContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n position: relative;\n display: flex;\n align-items: center;\n height: calc(2.5rem - 2px);\n padding: 0 0.5rem;\n\n ", "\n box-shadow: 0 0 0 2px transparent;\n border-radius: 4px;\n border: 1px solid\n ", ";\n ", "\n ", ";\n\n ", ";\n"])), function (props) {
|
|
611
595
|
if (props.disabled) return props.backgroundType === "dark" ? "background-color: ".concat(props.theme.disabledContainerFillColorOnDark, ";") : "background-color: ".concat(props.theme.disabledContainerFillColor, ";");
|
|
612
596
|
}, function (props) {
|
|
613
597
|
if (props.disabled) return props.backgroundType === "dark" ? props.theme.disabledBorderColorOnDark : props.theme.disabledBorderColor;else return props.backgroundType === "dark" ? props.theme.enabledBorderColorOnDark : props.theme.enabledBorderColor;
|
|
@@ -642,7 +626,7 @@ var Action = _styledComponents["default"].button(_templateObject7 || (_templateO
|
|
|
642
626
|
}, function (props) {
|
|
643
627
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledActionIconColorOnDark : props.theme.disabledActionIconColor : props.backgroundType === "dark" ? props.theme.actionIconColorOnDark : props.theme.actionIconColor;
|
|
644
628
|
}, function (props) {
|
|
645
|
-
return !props.disabled && "\n &:focus
|
|
629
|
+
return !props.disabled && "\n &:focus, \n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.focusActionBorderColorOnDark : props.theme.focusActionBorderColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.focusActionIconColorOnDark : props.theme.focusActionIconColor, ";\n }\n &:hover {\n background-color: ").concat(props.backgroundType === "dark" ? props.theme.hoverActionBackgroundColorOnDark : props.theme.hoverActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.hoverActionIconColorOnDark : props.theme.hoverActionIconColor, ";\n }\n &:active {\n background-color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionBackgroundColorOnDark : props.theme.activeActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionIconColorOnDark : props.theme.activeActionIconColor, ";\n }\n ");
|
|
646
630
|
});
|
|
647
631
|
|
|
648
632
|
var Prefix = _styledComponents["default"].span(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n height: 1.5rem;\n line-height: 1.5rem;\n margin-left: 0.25rem;\n padding: 0 0.5rem 0 0;\n ", ";\n font-family: ", ";\n font-size: 1rem;\n pointer-events: none;\n"])), function (props) {
|
package/textarea/Textarea.js
CHANGED
|
@@ -53,6 +53,8 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
53
53
|
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
54
54
|
_ref$disabled = _ref.disabled,
|
|
55
55
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
56
|
+
_ref$readOnly = _ref.readOnly,
|
|
57
|
+
readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
|
|
56
58
|
_ref$optional = _ref.optional,
|
|
57
59
|
optional = _ref$optional === void 0 ? false : _ref$optional,
|
|
58
60
|
_ref$verticalGrow = _ref.verticalGrow,
|
|
@@ -112,7 +114,15 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
112
114
|
});
|
|
113
115
|
};
|
|
114
116
|
|
|
115
|
-
var
|
|
117
|
+
var autoVerticalGrow = function autoVerticalGrow() {
|
|
118
|
+
var textareaLineHeight = parseInt(window.getComputedStyle(textareaRef.current)["line-height"]);
|
|
119
|
+
var textareaPaddingTopBottom = parseInt(window.getComputedStyle(textareaRef.current)["padding-top"]) * 2;
|
|
120
|
+
textareaRef.current.style.height = "".concat(textareaLineHeight * rows, "px");
|
|
121
|
+
var newHeight = textareaRef.current.scrollHeight - textareaPaddingTopBottom;
|
|
122
|
+
textareaRef.current.style.height = "".concat(newHeight, "px");
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
var handleOnBlur = function handleOnBlur(event) {
|
|
116
126
|
if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
117
127
|
value: event.target.value,
|
|
118
128
|
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
@@ -127,19 +137,11 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
127
137
|
});
|
|
128
138
|
};
|
|
129
139
|
|
|
130
|
-
var
|
|
140
|
+
var handleOnChange = function handleOnChange(event) {
|
|
131
141
|
changeValue(event.target.value);
|
|
142
|
+
verticalGrow === "auto" && autoVerticalGrow();
|
|
132
143
|
};
|
|
133
144
|
|
|
134
|
-
(0, _react.useLayoutEffect)(function () {
|
|
135
|
-
if (verticalGrow === "auto") {
|
|
136
|
-
var textareaLineHeight = parseInt(window.getComputedStyle(textareaRef.current)["line-height"]);
|
|
137
|
-
var textareaPaddingTopBottom = parseInt(window.getComputedStyle(textareaRef.current)["padding-top"]) * 2;
|
|
138
|
-
textareaRef.current.style.height = "".concat(textareaLineHeight * rows, "px");
|
|
139
|
-
var newHeight = textareaRef.current.scrollHeight - textareaPaddingTopBottom;
|
|
140
|
-
textareaRef.current.style.height = "".concat(newHeight, "px");
|
|
141
|
-
}
|
|
142
|
-
}, [value, verticalGrow, rows, innerValue]);
|
|
143
145
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
144
146
|
theme: colorsTheme.textarea
|
|
145
147
|
}, /*#__PURE__*/_react["default"].createElement(TextareaContainer, {
|
|
@@ -161,9 +163,10 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
161
163
|
placeholder: placeholder,
|
|
162
164
|
verticalGrow: verticalGrow,
|
|
163
165
|
rows: rows,
|
|
164
|
-
onChange:
|
|
165
|
-
onBlur:
|
|
166
|
+
onChange: handleOnChange,
|
|
167
|
+
onBlur: handleOnBlur,
|
|
166
168
|
disabled: disabled,
|
|
169
|
+
readOnly: readOnly,
|
|
167
170
|
error: error,
|
|
168
171
|
minLength: minLength,
|
|
169
172
|
maxLength: maxLength,
|
|
@@ -171,9 +174,9 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
171
174
|
backgroundType: backgroundType,
|
|
172
175
|
ref: textareaRef,
|
|
173
176
|
tabIndex: tabIndex,
|
|
174
|
-
"aria-invalid": error ?
|
|
177
|
+
"aria-invalid": error ? true : false,
|
|
175
178
|
"aria-errormessage": error ? errorId : undefined,
|
|
176
|
-
"aria-required":
|
|
179
|
+
"aria-required": !disabled && !optional
|
|
177
180
|
}), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
178
181
|
id: errorId,
|
|
179
182
|
backgroundType: backgroundType,
|
|
@@ -240,18 +243,17 @@ var HelperText = _styledComponents["default"].span(_templateObject4 || (_templat
|
|
|
240
243
|
return props.theme.helperTextLineHeight;
|
|
241
244
|
});
|
|
242
245
|
|
|
243
|
-
var Textarea = _styledComponents["default"].textarea(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n ", ";\n ", "\n\n padding: 0.5rem 1rem;\n box-shadow: 0 0 0 2px transparent;\n border-radius: 0.25rem;\n border: 1px solid\n ", ";\n ", "\n\n ", ";\n
|
|
244
|
-
|
|
246
|
+
var Textarea = _styledComponents["default"].textarea(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n ", ";\n\n ", "\n\n padding: 0.5rem 1rem;\n box-shadow: 0 0 0 2px transparent;\n border-radius: 0.25rem;\n border: 1px solid\n ", ";\n\n ", "\n\n ", ";\n\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n line-height: 1.5em;\n\n ::placeholder {\n color: ", ";\n }\n"])), function (_ref2) {
|
|
247
|
+
var verticalGrow = _ref2.verticalGrow;
|
|
248
|
+
if (verticalGrow === "none") return "resize: none;";else if (verticalGrow === "auto") return "resize: none; overflow: hidden;";else if (verticalGrow === "manual") return "resize: vertical;";else return "resize: none;";
|
|
245
249
|
}, function (props) {
|
|
246
250
|
if (props.disabled) return props.backgroundType === "dark" ? "background-color: ".concat(props.theme.disabledContainerFillColorOnDark, ";") : "background-color: ".concat(props.theme.disabledContainerFillColor, ";");else return "background-color: transparent;";
|
|
247
251
|
}, function (props) {
|
|
248
|
-
if (props.disabled) return props.backgroundType === "dark" ? props.theme.disabledBorderColorOnDark : props.theme.disabledBorderColor;else return props.backgroundType === "dark" ? props.theme.enabledBorderColorOnDark : props.theme.enabledBorderColor;
|
|
249
|
-
}, function (props) {
|
|
250
|
-
return props.error && !props.disabled && "border-color: transparent;\n box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.errorBorderColorOnDark : props.theme.errorBorderColor, ";\n ");
|
|
252
|
+
if (props.disabled) return props.backgroundType === "dark" ? props.theme.disabledBorderColorOnDark : props.theme.disabledBorderColor;else if (props.error) return "transparent";else if (props.readOnly) return props.theme.readOnlyBorderColor;else return props.backgroundType === "dark" ? props.theme.enabledBorderColorOnDark : props.theme.enabledBorderColor;
|
|
251
253
|
}, function (props) {
|
|
252
|
-
return props.disabled && "
|
|
254
|
+
return props.error && !props.disabled && "box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.errorBorderColorOnDark : props.theme.errorBorderColor, ";\n ");
|
|
253
255
|
}, function (props) {
|
|
254
|
-
return !props.disabled
|
|
256
|
+
return !props.disabled ? "&:hover {\n border-color: ".concat(props.error ? "transparent" : props.readOnly ? props.theme.hoverReadOnlyBorderColor : props.backgroundType === "dark" ? props.theme.hoverBorderColorOnDark : props.theme.hoverBorderColor, ";\n ").concat(props.error && "box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.hoverErrorBorderColorOnDark : props.theme.hoverErrorBorderColor, ";"), "\n }\n &:focus, &:focus-within {\n outline: none;\n border-color: transparent;\n box-shadow: 0 0 0 2px ").concat(props.backgroundType === "dark" ? props.theme.focusBorderColorOnDark : props.theme.focusBorderColor, ";\n }") : "cursor: not-allowed;";
|
|
255
257
|
}, function (props) {
|
|
256
258
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledValueFontColorOnDark : props.theme.disabledValueFontColor : props.backgroundType === "dark" ? props.theme.valueFontColorOnDark : props.theme.valueFontColor;
|
|
257
259
|
}, function (props) {
|
|
@@ -43,6 +43,14 @@ export const Chromatic = () => (
|
|
|
43
43
|
<Title title="Disabled with value" theme="light" level={4} />
|
|
44
44
|
<DxcTextarea label="Disabled" defaultValue="Example text" disabled />
|
|
45
45
|
</ExampleContainer>
|
|
46
|
+
<ExampleContainer>
|
|
47
|
+
<Title title="Read only" theme="light" level={4} />
|
|
48
|
+
<DxcTextarea label="Label" readOnly defaultValue="Example text" verticalGrow="manual" />
|
|
49
|
+
</ExampleContainer>
|
|
50
|
+
<ExampleContainer pseudoState="pseudo-hover">
|
|
51
|
+
<Title title="Hovered read only" theme="light" level={4} />
|
|
52
|
+
<DxcTextarea label="Label" readOnly defaultValue="Example text" verticalGrow="manual" />
|
|
53
|
+
</ExampleContainer>
|
|
46
54
|
<ExampleContainer>
|
|
47
55
|
<Title title="With error" theme="light" level={4} />
|
|
48
56
|
<DxcTextarea
|
|
@@ -78,7 +78,7 @@ describe("Textarea component tests", function () {
|
|
|
78
78
|
var textarea = getByLabelText("Example label");
|
|
79
79
|
expect(textarea.rows).toBe(10);
|
|
80
80
|
});
|
|
81
|
-
test("Renders with correct
|
|
81
|
+
test("Renders with correct accessibility attributes", function () {
|
|
82
82
|
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
83
83
|
label: "Example label"
|
|
84
84
|
})),
|
|
@@ -116,17 +116,61 @@ describe("Textarea component tests", function () {
|
|
|
116
116
|
|
|
117
117
|
expect(onChange).not.toHaveBeenCalled();
|
|
118
118
|
});
|
|
119
|
+
test("Read-only textarea does not trigger onChange function", function () {
|
|
120
|
+
var onChange = jest.fn();
|
|
121
|
+
|
|
122
|
+
var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
123
|
+
label: "Example label",
|
|
124
|
+
onChange: onChange,
|
|
125
|
+
readOnly: true
|
|
126
|
+
})),
|
|
127
|
+
getByLabelText = _render10.getByLabelText;
|
|
128
|
+
|
|
129
|
+
var textarea = getByLabelText("Example label");
|
|
130
|
+
|
|
131
|
+
_userEvent["default"].type(textarea, "Test");
|
|
132
|
+
|
|
133
|
+
expect(onChange).not.toHaveBeenCalled();
|
|
134
|
+
});
|
|
135
|
+
test("Read-only textarea sends its value on submit", function () {
|
|
136
|
+
var handlerOnSubmit = jest.fn(function (e) {
|
|
137
|
+
e.preventDefault();
|
|
138
|
+
var formData = new FormData(e.target);
|
|
139
|
+
var formProps = Object.fromEntries(formData);
|
|
140
|
+
expect(formProps).toStrictEqual({
|
|
141
|
+
data: "Comments"
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
var _render11 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement("form", {
|
|
146
|
+
onSubmit: handlerOnSubmit
|
|
147
|
+
}, /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
148
|
+
label: "Example label",
|
|
149
|
+
name: "data",
|
|
150
|
+
defaultValue: "Comments",
|
|
151
|
+
readOnly: true
|
|
152
|
+
}), /*#__PURE__*/_react["default"].createElement("button", {
|
|
153
|
+
type: "submit"
|
|
154
|
+
}, "Submit"))),
|
|
155
|
+
getByText = _render11.getByText;
|
|
156
|
+
|
|
157
|
+
var submit = getByText("Submit");
|
|
158
|
+
|
|
159
|
+
_userEvent["default"].click(submit);
|
|
160
|
+
|
|
161
|
+
expect(handlerOnSubmit).toHaveBeenCalled();
|
|
162
|
+
});
|
|
119
163
|
test("Not optional constraint (onBlur)", function () {
|
|
120
164
|
var onChange = jest.fn();
|
|
121
165
|
var onBlur = jest.fn();
|
|
122
166
|
|
|
123
|
-
var
|
|
167
|
+
var _render12 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
124
168
|
label: "Example label",
|
|
125
169
|
placeholder: "Placeholder",
|
|
126
170
|
onChange: onChange,
|
|
127
171
|
onBlur: onBlur
|
|
128
172
|
})),
|
|
129
|
-
getByLabelText =
|
|
173
|
+
getByLabelText = _render12.getByLabelText;
|
|
130
174
|
|
|
131
175
|
var textarea = getByLabelText("Example label");
|
|
132
176
|
|
|
@@ -156,12 +200,12 @@ describe("Textarea component tests", function () {
|
|
|
156
200
|
test("Not optional constraint (onChange)", function () {
|
|
157
201
|
var onChange = jest.fn();
|
|
158
202
|
|
|
159
|
-
var
|
|
203
|
+
var _render13 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
160
204
|
label: "Example label",
|
|
161
205
|
placeholder: "Placeholder",
|
|
162
206
|
onChange: onChange
|
|
163
207
|
})),
|
|
164
|
-
getByLabelText =
|
|
208
|
+
getByLabelText = _render13.getByLabelText;
|
|
165
209
|
|
|
166
210
|
var textarea = getByLabelText("Example label");
|
|
167
211
|
|
|
@@ -190,7 +234,7 @@ describe("Textarea component tests", function () {
|
|
|
190
234
|
var onChange = jest.fn();
|
|
191
235
|
var onBlur = jest.fn();
|
|
192
236
|
|
|
193
|
-
var
|
|
237
|
+
var _render14 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
194
238
|
label: "Example label",
|
|
195
239
|
placeholder: "Placeholder",
|
|
196
240
|
onChange: onChange,
|
|
@@ -201,7 +245,7 @@ describe("Textarea component tests", function () {
|
|
|
201
245
|
},
|
|
202
246
|
pattern: "^.*(?=.*[a-zA-Z])(?=.*\\d)(?=.*[!&$%&? \"]).*$"
|
|
203
247
|
})),
|
|
204
|
-
getByLabelText =
|
|
248
|
+
getByLabelText = _render14.getByLabelText;
|
|
205
249
|
|
|
206
250
|
var textarea = getByLabelText("Example label");
|
|
207
251
|
|
|
@@ -249,7 +293,7 @@ describe("Textarea component tests", function () {
|
|
|
249
293
|
var onChange = jest.fn();
|
|
250
294
|
var onBlur = jest.fn();
|
|
251
295
|
|
|
252
|
-
var
|
|
296
|
+
var _render15 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
253
297
|
label: "Example label",
|
|
254
298
|
placeholder: "Placeholder",
|
|
255
299
|
onChange: onChange,
|
|
@@ -261,7 +305,7 @@ describe("Textarea component tests", function () {
|
|
|
261
305
|
minLength: 5,
|
|
262
306
|
maxLength: 10
|
|
263
307
|
})),
|
|
264
|
-
getByLabelText =
|
|
308
|
+
getByLabelText = _render15.getByLabelText;
|
|
265
309
|
|
|
266
310
|
var textarea = getByLabelText("Example label");
|
|
267
311
|
|
|
@@ -309,7 +353,7 @@ describe("Textarea component tests", function () {
|
|
|
309
353
|
var onChange = jest.fn();
|
|
310
354
|
var onBlur = jest.fn();
|
|
311
355
|
|
|
312
|
-
var
|
|
356
|
+
var _render16 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
313
357
|
label: "Example label",
|
|
314
358
|
placeholder: "Placeholder",
|
|
315
359
|
onChange: onChange,
|
|
@@ -322,7 +366,7 @@ describe("Textarea component tests", function () {
|
|
|
322
366
|
minLength: 5,
|
|
323
367
|
maxLength: 10
|
|
324
368
|
})),
|
|
325
|
-
getByLabelText =
|
|
369
|
+
getByLabelText = _render16.getByLabelText;
|
|
326
370
|
|
|
327
371
|
var textarea = getByLabelText("Example label");
|
|
328
372
|
|
|
@@ -387,11 +431,11 @@ describe("Textarea component tests", function () {
|
|
|
387
431
|
test("onBlur function is called correctly", function () {
|
|
388
432
|
var onBlur = jest.fn();
|
|
389
433
|
|
|
390
|
-
var
|
|
434
|
+
var _render17 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
391
435
|
label: "Example label",
|
|
392
436
|
onBlur: onBlur
|
|
393
437
|
})),
|
|
394
|
-
getByLabelText =
|
|
438
|
+
getByLabelText = _render17.getByLabelText;
|
|
395
439
|
|
|
396
440
|
var textarea = getByLabelText("Example label");
|
|
397
441
|
|
|
@@ -411,12 +455,12 @@ describe("Textarea component tests", function () {
|
|
|
411
455
|
test("onChange function is called correctly", function () {
|
|
412
456
|
var onChange = jest.fn();
|
|
413
457
|
|
|
414
|
-
var
|
|
458
|
+
var _render18 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Textarea["default"], {
|
|
415
459
|
label: "Example label",
|
|
416
460
|
value: "Test value",
|
|
417
461
|
onChange: onChange
|
|
418
462
|
})),
|
|
419
|
-
getByLabelText =
|
|
463
|
+
getByLabelText = _render18.getByLabelText;
|
|
420
464
|
|
|
421
465
|
var textarea = getByLabelText("Example label");
|
|
422
466
|
|
package/textarea/types.d.ts
CHANGED
|
@@ -34,6 +34,10 @@ declare type Props = {
|
|
|
34
34
|
* If true, the component will be disabled.
|
|
35
35
|
*/
|
|
36
36
|
disabled?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* If true, the component will not be mutable, meaning the user can not edit the control.
|
|
39
|
+
*/
|
|
40
|
+
readOnly?: boolean;
|
|
37
41
|
/**
|
|
38
42
|
* If true, the textarea will be optional, showing '(Optional)'
|
|
39
43
|
* next to the label. Otherwise, the field will be considered required
|