@dxc-technology/halstack-react 0.0.0-fdc49d2 → 0.0.0-feed711
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 +12 -0
- package/HalstackContext.js +295 -0
- package/accordion/Accordion.js +5 -27
- package/accordion/Accordion.stories.tsx +4 -4
- package/accordion/types.d.ts +1 -1
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +14 -15
- package/accordion-group/AccordionGroup.stories.tsx +1 -1
- package/accordion-group/AccordionGroup.test.js +24 -6
- package/accordion-group/types.d.ts +5 -1
- package/alert/Alert.js +4 -1
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +5 -3
- package/badge/types.d.ts +1 -0
- package/bleed/Bleed.js +1 -34
- package/bleed/Bleed.stories.tsx +94 -95
- package/bleed/types.d.ts +1 -1
- package/box/Box.js +22 -32
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +123 -0
- package/bulleted-list/BulletedList.stories.tsx +200 -0
- package/bulleted-list/types.d.ts +11 -0
- package/{list → bulleted-list}/types.js +0 -0
- package/button/Button.js +53 -68
- package/button/Button.stories.tsx +9 -0
- package/button/types.d.ts +7 -7
- package/card/Card.js +24 -27
- package/checkbox/Checkbox.d.ts +1 -1
- package/checkbox/Checkbox.js +38 -28
- package/checkbox/Checkbox.stories.tsx +124 -128
- package/checkbox/types.d.ts +3 -3
- package/chip/types.d.ts +1 -1
- package/common/variables.js +229 -98
- package/date-input/DateInput.js +41 -23
- package/date-input/DateInput.test.js +9 -22
- package/date-input/types.d.ts +12 -9
- package/dialog/Dialog.js +46 -50
- package/dialog/Dialog.stories.tsx +1 -2
- package/dialog/Dialog.test.js +34 -4
- package/dialog/types.d.ts +2 -2
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +242 -250
- package/dropdown/Dropdown.stories.tsx +126 -63
- package/dropdown/Dropdown.test.js +510 -108
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +80 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +92 -0
- package/dropdown/types.d.ts +25 -5
- package/file-input/FileInput.js +9 -6
- package/file-input/FileItem.js +7 -5
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +57 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +21 -0
- package/{radio → flex}/types.js +0 -0
- package/footer/Footer.js +15 -88
- package/footer/Icons.js +1 -1
- package/footer/types.d.ts +1 -1
- package/header/Header.js +95 -114
- package/header/Header.stories.tsx +46 -36
- package/header/Header.test.js +18 -2
- package/header/Icons.js +2 -2
- package/header/types.d.ts +2 -2
- package/inset/Inset.js +1 -34
- package/inset/Inset.stories.tsx +36 -36
- package/inset/types.d.ts +25 -1
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +71 -131
- package/layout/ApplicationLayout.stories.tsx +83 -93
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +13 -2
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +18 -33
- package/link/Link.d.ts +3 -2
- package/link/Link.js +57 -74
- package/link/Link.stories.tsx +95 -53
- package/link/Link.test.js +7 -15
- package/link/types.d.ts +7 -23
- package/main.d.ts +7 -10
- package/main.js +43 -61
- package/number-input/NumberInput.test.js +2 -4
- package/number-input/types.d.ts +13 -10
- package/package.json +14 -12
- package/paginator/Paginator.js +17 -38
- package/paginator/Paginator.test.js +42 -0
- package/paragraph/Paragraph.d.ts +6 -0
- package/paragraph/Paragraph.js +38 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/password-input/PasswordInput.js +7 -4
- package/password-input/PasswordInput.test.js +3 -6
- package/password-input/types.d.ts +14 -11
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +57 -51
- package/progress-bar/ProgressBar.stories.jsx +13 -11
- package/progress-bar/ProgressBar.test.js +67 -22
- package/progress-bar/types.d.ts +3 -4
- package/quick-nav/QuickNav.js +83 -25
- package/quick-nav/QuickNav.stories.tsx +43 -16
- package/quick-nav/types.d.ts +4 -8
- package/radio-group/Radio.js +1 -1
- package/radio-group/RadioGroup.js +21 -20
- package/resultsetTable/ResultsetTable.test.js +42 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +199 -0
- package/select/Option.js +1 -1
- package/select/Select.js +102 -199
- package/select/Select.stories.tsx +145 -100
- package/select/Select.test.js +440 -281
- package/select/types.d.ts +31 -12
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +184 -52
- package/sidenav/Sidenav.stories.tsx +154 -156
- package/sidenav/Sidenav.test.js +25 -37
- package/sidenav/types.d.ts +50 -27
- package/slider/Slider.d.ts +1 -1
- package/slider/Slider.js +5 -4
- package/slider/Slider.stories.tsx +8 -8
- package/slider/Slider.test.js +68 -10
- package/slider/types.d.ts +4 -0
- package/spinner/Spinner.js +1 -1
- package/switch/Switch.d.ts +2 -2
- package/switch/Switch.js +113 -54
- package/switch/Switch.stories.tsx +16 -38
- package/switch/Switch.test.js +122 -8
- package/switch/types.d.ts +5 -6
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +9 -11
- package/tabs/Tabs.stories.tsx +0 -8
- package/tabs/Tabs.test.js +26 -9
- package/tabs/types.d.ts +5 -1
- package/tabs-nav/NavTabs.d.ts +8 -0
- package/tabs-nav/NavTabs.js +125 -0
- package/tabs-nav/NavTabs.stories.tsx +170 -0
- package/tabs-nav/NavTabs.test.js +82 -0
- package/tabs-nav/Tab.d.ts +4 -0
- package/tabs-nav/Tab.js +130 -0
- package/tabs-nav/types.d.ts +53 -0
- package/{row → tabs-nav}/types.js +0 -0
- package/tag/Tag.js +5 -8
- package/tag/types.d.ts +1 -1
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +55 -0
- package/text-input/TextInput.js +60 -97
- package/text-input/TextInput.stories.tsx +1 -2
- package/text-input/TextInput.test.js +22 -35
- package/text-input/types.d.ts +27 -12
- package/textarea/Textarea.js +10 -19
- package/textarea/types.d.ts +10 -7
- package/toggle-group/ToggleGroup.d.ts +1 -1
- package/toggle-group/ToggleGroup.js +5 -4
- package/toggle-group/ToggleGroup.stories.tsx +4 -4
- package/toggle-group/ToggleGroup.test.js +35 -4
- package/toggle-group/types.d.ts +9 -1
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +131 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/{stack → typography}/types.js +0 -0
- package/useTheme.js +2 -2
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.js +43 -44
- package/wizard/Wizard.stories.tsx +20 -1
- package/wizard/types.d.ts +5 -4
- package/ThemeContext.d.ts +0 -10
- package/ThemeContext.js +0 -243
- package/list/List.d.ts +0 -4
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/list/types.d.ts +0 -7
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/Radio.test.js +0 -71
- package/radio/types.d.ts +0 -54
- package/row/Row.d.ts +0 -3
- package/row/Row.js +0 -127
- package/row/Row.stories.tsx +0 -237
- package/row/types.d.ts +0 -28
- package/stack/Stack.d.ts +0 -3
- package/stack/Stack.js +0 -97
- package/stack/Stack.stories.tsx +0 -164
- package/stack/types.d.ts +0 -24
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
package/text-input/TextInput.js
CHANGED
|
@@ -21,6 +21,8 @@ var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
|
21
21
|
|
|
22
22
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
23
23
|
|
|
24
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
25
|
+
|
|
24
26
|
var _variables = require("../common/variables.js");
|
|
25
27
|
|
|
26
28
|
var _utils = require("../common/utils.js");
|
|
@@ -31,7 +33,9 @@ var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColor
|
|
|
31
33
|
|
|
32
34
|
var _NumberInputContext = _interopRequireDefault(require("../number-input/NumberInputContext"));
|
|
33
35
|
|
|
34
|
-
var
|
|
36
|
+
var _Suggestion = _interopRequireDefault(require("./Suggestion"));
|
|
37
|
+
|
|
38
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16;
|
|
35
39
|
|
|
36
40
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
37
41
|
|
|
@@ -106,14 +110,6 @@ var makeCancelable = function makeCancelable(promise) {
|
|
|
106
110
|
};
|
|
107
111
|
};
|
|
108
112
|
|
|
109
|
-
var getNotOptionalErrorMessage = function getNotOptionalErrorMessage() {
|
|
110
|
-
return "This field is required. Please, enter a value.";
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
var getPatternErrorMessage = function getPatternErrorMessage() {
|
|
114
|
-
return "Please match the format requested.";
|
|
115
|
-
};
|
|
116
|
-
|
|
117
113
|
var patternMatch = function patternMatch(pattern, value) {
|
|
118
114
|
return new RegExp(pattern).test(value);
|
|
119
115
|
};
|
|
@@ -205,6 +201,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
205
201
|
var inputRef = (0, _react.useRef)(null);
|
|
206
202
|
var actionRef = (0, _react.useRef)(null);
|
|
207
203
|
var colorsTheme = (0, _useTheme["default"])();
|
|
204
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
208
205
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
209
206
|
var autosuggestId = "".concat(inputId, "-listBox");
|
|
210
207
|
var errorId = "error-".concat(inputId);
|
|
@@ -221,10 +218,6 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
221
218
|
return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
|
|
222
219
|
};
|
|
223
220
|
|
|
224
|
-
var getLengthErrorMessage = function getLengthErrorMessage() {
|
|
225
|
-
return "Min length ".concat(minLength, ", max length ").concat(maxLength, ".");
|
|
226
|
-
};
|
|
227
|
-
|
|
228
221
|
var isNumberIncorrect = function isNumberIncorrect(value) {
|
|
229
222
|
return (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) && parseInt(value) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) && parseInt(value) > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);
|
|
230
223
|
};
|
|
@@ -236,7 +229,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
236
229
|
};
|
|
237
230
|
|
|
238
231
|
var getNumberErrorMessage = function getNumberErrorMessage(value) {
|
|
239
|
-
if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && parseInt(value) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) return
|
|
232
|
+
if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && parseInt(value) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) return translatedLabels.numberInput.valueGreaterThanOrEqualToErrorMessage(numberInputContext.minNumber);else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.maxNumber && parseInt(value) > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) return translatedLabels.numberInput.valueLessThanOrEqualToErrorMessage(numberInputContext.maxNumber);
|
|
240
233
|
};
|
|
241
234
|
|
|
242
235
|
var hasSuggestions = function hasSuggestions() {
|
|
@@ -257,19 +250,18 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
257
250
|
var changedValue = typeof newValue === "number" ? newValue.toString() : newValue;
|
|
258
251
|
if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
259
252
|
value: changedValue,
|
|
260
|
-
error:
|
|
253
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
261
254
|
});else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
262
255
|
value: changedValue,
|
|
263
|
-
error:
|
|
256
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
264
257
|
});else if (newValue && pattern && !patternMatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
265
258
|
value: changedValue,
|
|
266
|
-
error:
|
|
259
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
267
260
|
});else if (newValue && isNumberIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
268
261
|
value: changedValue,
|
|
269
262
|
error: getNumberErrorMessage(newValue)
|
|
270
263
|
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
271
|
-
value: changedValue
|
|
272
|
-
error: null
|
|
264
|
+
value: changedValue
|
|
273
265
|
});
|
|
274
266
|
};
|
|
275
267
|
|
|
@@ -291,31 +283,30 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
291
283
|
suggestions && closeSuggestions();
|
|
292
284
|
if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
293
285
|
value: event.target.value,
|
|
294
|
-
error:
|
|
286
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
295
287
|
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
296
288
|
value: event.target.value,
|
|
297
|
-
error:
|
|
289
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
298
290
|
});else if (event.target.value && pattern && !patternMatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
299
291
|
value: event.target.value,
|
|
300
|
-
error:
|
|
292
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
301
293
|
});else if (event.target.value && isNumberIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
302
294
|
value: event.target.value,
|
|
303
295
|
error: getNumberErrorMessage(event.target.value)
|
|
304
296
|
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
305
|
-
value: event.target.value
|
|
306
|
-
error: null
|
|
297
|
+
value: event.target.value
|
|
307
298
|
});
|
|
308
299
|
};
|
|
309
300
|
|
|
310
301
|
var handleIOnKeyDown = function handleIOnKeyDown(event) {
|
|
311
|
-
switch (event.
|
|
312
|
-
case
|
|
313
|
-
|
|
302
|
+
switch (event.key) {
|
|
303
|
+
case "Down":
|
|
304
|
+
case "ArrowDown":
|
|
305
|
+
event.preventDefault();
|
|
306
|
+
|
|
314
307
|
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
|
|
315
308
|
decrementNumber();
|
|
316
|
-
event.preventDefault();
|
|
317
309
|
} else {
|
|
318
|
-
event.preventDefault();
|
|
319
310
|
openSuggestions();
|
|
320
311
|
|
|
321
312
|
if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
|
|
@@ -327,13 +318,13 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
327
318
|
|
|
328
319
|
break;
|
|
329
320
|
|
|
330
|
-
case
|
|
331
|
-
|
|
321
|
+
case "Up":
|
|
322
|
+
case "ArrowUp":
|
|
323
|
+
event.preventDefault();
|
|
324
|
+
|
|
332
325
|
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number") {
|
|
333
326
|
incrementNumber();
|
|
334
|
-
event.preventDefault();
|
|
335
327
|
} else {
|
|
336
|
-
event.preventDefault();
|
|
337
328
|
openSuggestions();
|
|
338
329
|
|
|
339
330
|
if (!isAutosuggestError && !isSearching && filteredSuggestions.length > 0) {
|
|
@@ -345,8 +336,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
345
336
|
|
|
346
337
|
break;
|
|
347
338
|
|
|
348
|
-
case
|
|
349
|
-
|
|
339
|
+
case "Esc":
|
|
340
|
+
case "Escape":
|
|
350
341
|
event.preventDefault();
|
|
351
342
|
|
|
352
343
|
if (hasSuggestions()) {
|
|
@@ -356,8 +347,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
356
347
|
|
|
357
348
|
break;
|
|
358
349
|
|
|
359
|
-
case
|
|
360
|
-
// Enter
|
|
350
|
+
case "Enter":
|
|
361
351
|
if (hasSuggestions() && !isSearching) {
|
|
362
352
|
var validFocusedSuggestion = filteredSuggestions.length > 0 && visualFocusedSuggIndex >= 0 && visualFocusedSuggIndex < filteredSuggestions.length;
|
|
363
353
|
validFocusedSuggestion && changeValue(filteredSuggestions[visualFocusedSuggIndex]);
|
|
@@ -470,45 +460,22 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
470
460
|
|
|
471
461
|
(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
472
462
|
}, [value, innerValue, suggestions, numberInputContext]);
|
|
473
|
-
|
|
474
|
-
var HighlightedSuggestion = function HighlightedSuggestion(_ref2) {
|
|
475
|
-
var suggestion = _ref2.suggestion,
|
|
476
|
-
index = _ref2.index;
|
|
477
|
-
var regEx = new RegExp(value !== null && value !== void 0 ? value : innerValue, "i");
|
|
478
|
-
var matchedWords = suggestion.match(regEx);
|
|
479
|
-
var noMatchedWords = suggestion.replace(regEx, "");
|
|
480
|
-
var isLastOption = index === lastOptionIndex;
|
|
481
|
-
return /*#__PURE__*/_react["default"].createElement(Suggestion, {
|
|
482
|
-
id: "suggestion-".concat(index),
|
|
483
|
-
onClick: function onClick() {
|
|
484
|
-
changeValue(suggestion);
|
|
485
|
-
closeSuggestions();
|
|
486
|
-
},
|
|
487
|
-
visualFocused: visualFocusedSuggIndex === index,
|
|
488
|
-
role: "option",
|
|
489
|
-
"aria-selected": visualFocusedSuggIndex === index && "true"
|
|
490
|
-
}, /*#__PURE__*/_react["default"].createElement(StyledSuggestion, {
|
|
491
|
-
last: isLastOption,
|
|
492
|
-
visualFocused: visualFocusedSuggIndex === index
|
|
493
|
-
}, typeof suggestions === "function" ? suggestion : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, matchedWords), noMatchedWords)));
|
|
494
|
-
};
|
|
495
|
-
|
|
496
463
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
497
464
|
theme: colorsTheme.textInput
|
|
498
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
465
|
+
}, /*#__PURE__*/_react["default"].createElement(TextInputContainer, {
|
|
499
466
|
margin: margin,
|
|
500
|
-
|
|
501
|
-
|
|
467
|
+
size: size,
|
|
468
|
+
ref: ref
|
|
502
469
|
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
503
470
|
htmlFor: inputId,
|
|
504
471
|
disabled: disabled,
|
|
505
472
|
backgroundType: backgroundType,
|
|
506
|
-
helperText:
|
|
507
|
-
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null,
|
|
473
|
+
hasHelperText: helperText ? true : false
|
|
474
|
+
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
508
475
|
disabled: disabled,
|
|
509
476
|
backgroundType: backgroundType
|
|
510
477
|
}, helperText), /*#__PURE__*/_react["default"].createElement(InputContainer, {
|
|
511
|
-
error: error,
|
|
478
|
+
error: error ? true : false,
|
|
512
479
|
disabled: disabled,
|
|
513
480
|
backgroundType: backgroundType,
|
|
514
481
|
onClick: handleInputContainerOnClick,
|
|
@@ -559,8 +526,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
559
526
|
},
|
|
560
527
|
backgroundType: backgroundType,
|
|
561
528
|
tabIndex: tabIndex,
|
|
562
|
-
title:
|
|
563
|
-
"aria-label":
|
|
529
|
+
title: translatedLabels.textInput.clearFieldActionTitle,
|
|
530
|
+
"aria-label": translatedLabels.textInput.clearFieldActionTitle
|
|
564
531
|
}, textInputIcons.clear), (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(Action, {
|
|
565
532
|
ref: actionRef,
|
|
566
533
|
disabled: disabled,
|
|
@@ -572,8 +539,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
572
539
|
},
|
|
573
540
|
backgroundType: backgroundType,
|
|
574
541
|
tabIndex: tabIndex,
|
|
575
|
-
title:
|
|
576
|
-
"aria-label":
|
|
542
|
+
title: translatedLabels.numberInput.decrementValueTitle,
|
|
543
|
+
"aria-label": translatedLabels.numberInput.decrementValueTitle
|
|
577
544
|
}, textInputIcons.decrement), /*#__PURE__*/_react["default"].createElement(Action, {
|
|
578
545
|
ref: actionRef,
|
|
579
546
|
disabled: disabled,
|
|
@@ -585,8 +552,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
585
552
|
},
|
|
586
553
|
backgroundType: backgroundType,
|
|
587
554
|
tabIndex: tabIndex,
|
|
588
|
-
title:
|
|
589
|
-
"aria-label":
|
|
555
|
+
title: translatedLabels.numberInput.incrementValueTitle,
|
|
556
|
+
"aria-label": translatedLabels.numberInput.incrementValueTitle
|
|
590
557
|
}, textInputIcons.increment)) : action && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
591
558
|
ref: actionRef,
|
|
592
559
|
disabled: disabled,
|
|
@@ -607,7 +574,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
607
574
|
backgroundType: backgroundType
|
|
608
575
|
}, suffix), isOpen && (filteredSuggestions.length > 0 || isSearching || isAutosuggestError) && /*#__PURE__*/_react["default"].createElement(Suggestions, {
|
|
609
576
|
id: autosuggestId,
|
|
610
|
-
|
|
577
|
+
error: isAutosuggestError ? true : false,
|
|
611
578
|
onMouseDown: function onMouseDown(event) {
|
|
612
579
|
event.preventDefault();
|
|
613
580
|
},
|
|
@@ -615,14 +582,22 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
615
582
|
role: "listbox",
|
|
616
583
|
"aria-label": label
|
|
617
584
|
}, !isSearching && !isAutosuggestError && filteredSuggestions.length > 0 && filteredSuggestions.map(function (suggestion, index) {
|
|
618
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
619
|
-
key: "suggestion-".concat(
|
|
585
|
+
return /*#__PURE__*/_react["default"].createElement(_Suggestion["default"], {
|
|
586
|
+
key: "suggestion-".concat(index),
|
|
587
|
+
id: "suggestion-".concat(index),
|
|
588
|
+
value: value !== null && value !== void 0 ? value : innerValue,
|
|
589
|
+
onClick: function onClick() {
|
|
590
|
+
changeValue(suggestion);
|
|
591
|
+
closeSuggestions();
|
|
592
|
+
},
|
|
620
593
|
suggestion: suggestion,
|
|
621
|
-
|
|
594
|
+
isLast: index === lastOptionIndex,
|
|
595
|
+
visuallyFocused: visualFocusedSuggIndex === index,
|
|
596
|
+
highlighted: typeof suggestions === "function"
|
|
622
597
|
});
|
|
623
|
-
}), isSearching && /*#__PURE__*/_react["default"].createElement(SuggestionsSystemMessage, null,
|
|
598
|
+
}), isSearching && /*#__PURE__*/_react["default"].createElement(SuggestionsSystemMessage, null, translatedLabels.textInput.searchingMessage), isAutosuggestError && /*#__PURE__*/_react["default"].createElement(SuggestionsError, null, /*#__PURE__*/_react["default"].createElement(SuggestionsErrorIcon, {
|
|
624
599
|
backgroundType: backgroundType
|
|
625
|
-
}, textInputIcons.error),
|
|
600
|
+
}, textInputIcons.error), translatedLabels.textInput.fetchingDataErrorMessage))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
626
601
|
id: errorId,
|
|
627
602
|
backgroundType: backgroundType,
|
|
628
603
|
"aria-live": error ? "assertive" : "off"
|
|
@@ -640,7 +615,7 @@ var calculateWidth = function calculateWidth(margin, size) {
|
|
|
640
615
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
641
616
|
};
|
|
642
617
|
|
|
643
|
-
var
|
|
618
|
+
var TextInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
644
619
|
return calculateWidth(props.margin, props.size);
|
|
645
620
|
}, function (props) {
|
|
646
621
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -667,7 +642,7 @@ var Label = _styledComponents["default"].label(_templateObject2 || (_templateObj
|
|
|
667
642
|
}, function (props) {
|
|
668
643
|
return props.theme.labelLineHeight;
|
|
669
644
|
}, function (props) {
|
|
670
|
-
return !props.
|
|
645
|
+
return !props.hasHelperText && "margin-bottom: 0.25rem";
|
|
671
646
|
});
|
|
672
647
|
|
|
673
648
|
var OptionalLabel = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-weight: ", ";\n"])), function (props) {
|
|
@@ -755,9 +730,9 @@ var Error = _styledComponents["default"].span(_templateObject12 || (_templateObj
|
|
|
755
730
|
});
|
|
756
731
|
|
|
757
732
|
var Suggestions = _styledComponents["default"].ul(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2["default"])(["\n position: absolute;\n z-index: 1;\n max-height: 304px;\n overflow-y: auto;\n top: calc(100% + 4px);\n left: 0;\n margin: 0;\n padding: 0.25rem 0;\n width: 100%;\n background-color: ", ";\n border: 1px solid\n ", ";\n border-radius: 0.25rem;\n box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);\n cursor: default;\n color: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n"])), function (props) {
|
|
758
|
-
return props.
|
|
733
|
+
return props.error ? props.theme.errorListDialogBackgroundColor : props.theme.listDialogBackgroundColor;
|
|
759
734
|
}, function (props) {
|
|
760
|
-
return props.
|
|
735
|
+
return props.error ? props.theme.errorListDialogBorderColor : props.theme.listDialogBorderColor;
|
|
761
736
|
}, function (props) {
|
|
762
737
|
return props.theme.listOptionFontColor;
|
|
763
738
|
}, function (props) {
|
|
@@ -770,27 +745,15 @@ var Suggestions = _styledComponents["default"].ul(_templateObject13 || (_templat
|
|
|
770
745
|
return props.theme.listOptionFontWeight;
|
|
771
746
|
});
|
|
772
747
|
|
|
773
|
-
var
|
|
774
|
-
return props.visualFocused ? props.theme.focusListOptionBorderColor : "transparent";
|
|
775
|
-
}, function (props) {
|
|
776
|
-
return props.theme.hoverListOptionBackgroundColor;
|
|
777
|
-
}, function (props) {
|
|
778
|
-
return props.theme.activeListOptionBackgroundColor;
|
|
779
|
-
});
|
|
780
|
-
|
|
781
|
-
var StyledSuggestion = _styledComponents["default"].span(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2["default"])(["\n width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n padding: 0.25rem 0.5rem 0.188rem 0.5rem;\n ", ";\n"])), function (props) {
|
|
782
|
-
return props.last || props.visualFocused ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
|
|
783
|
-
});
|
|
784
|
-
|
|
785
|
-
var SuggestionsSystemMessage = _styledComponents["default"].span(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0.25rem 1rem;\n color: ", ";\n line-height: 1.715em;\n"])), function (props) {
|
|
748
|
+
var SuggestionsSystemMessage = _styledComponents["default"].span(_templateObject14 || (_templateObject14 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0.25rem 1rem;\n color: ", ";\n line-height: 1.715em;\n"])), function (props) {
|
|
786
749
|
return props.theme.systemMessageFontColor;
|
|
787
750
|
});
|
|
788
751
|
|
|
789
|
-
var SuggestionsErrorIcon = _styledComponents["default"].span(
|
|
752
|
+
var SuggestionsErrorIcon = _styledComponents["default"].span(_templateObject15 || (_templateObject15 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-wrap: wrap;\n align-content: center;\n margin-right: 0.5rem;\n height: 18px;\n width: 18px;\n color: ", ";\n"])), function (props) {
|
|
790
753
|
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
791
754
|
});
|
|
792
755
|
|
|
793
|
-
var SuggestionsError = _styledComponents["default"].span(
|
|
756
|
+
var SuggestionsError = _styledComponents["default"].span(_templateObject16 || (_templateObject16 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n padding: 0.25rem 1rem;\n align-items: center;\n line-height: 1.715em;\n color: ", ";\n"])), function (props) {
|
|
794
757
|
return props.theme.errorListDialogFontColor;
|
|
795
758
|
});
|
|
796
759
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { userEvent, within,
|
|
3
|
-
import { fireEvent } from "@testing-library/react";
|
|
2
|
+
import { userEvent, within, fireEvent } from "@storybook/testing-library";
|
|
4
3
|
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
5
4
|
import Title from "../../.storybook/components/Title";
|
|
6
5
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
@@ -118,8 +118,7 @@ describe("TextInput component tests", function () {
|
|
|
118
118
|
|
|
119
119
|
expect(onBlur).toHaveBeenCalled();
|
|
120
120
|
expect(onBlur).toHaveBeenCalledWith({
|
|
121
|
-
value: "Test"
|
|
122
|
-
error: null
|
|
121
|
+
value: "Test"
|
|
123
122
|
});
|
|
124
123
|
});
|
|
125
124
|
test("Not optional constraint (onChange)", function () {
|
|
@@ -143,8 +142,7 @@ describe("TextInput component tests", function () {
|
|
|
143
142
|
|
|
144
143
|
expect(onChange).toHaveBeenCalled();
|
|
145
144
|
expect(onChange).toHaveBeenCalledWith({
|
|
146
|
-
value: "Test"
|
|
147
|
-
error: null
|
|
145
|
+
value: "Test"
|
|
148
146
|
});
|
|
149
147
|
|
|
150
148
|
_userEvent["default"].clear(input);
|
|
@@ -205,16 +203,14 @@ describe("TextInput component tests", function () {
|
|
|
205
203
|
|
|
206
204
|
expect(onChange).toHaveBeenCalled();
|
|
207
205
|
expect(onChange).toHaveBeenCalledWith({
|
|
208
|
-
value: "pattern4&"
|
|
209
|
-
error: null
|
|
206
|
+
value: "pattern4&"
|
|
210
207
|
});
|
|
211
208
|
|
|
212
209
|
_react2.fireEvent.blur(input);
|
|
213
210
|
|
|
214
211
|
expect(onBlur).toHaveBeenCalled();
|
|
215
212
|
expect(onBlur).toHaveBeenCalledWith({
|
|
216
|
-
value: "pattern4&"
|
|
217
|
-
error: null
|
|
213
|
+
value: "pattern4&"
|
|
218
214
|
});
|
|
219
215
|
});
|
|
220
216
|
test("Length constraint", function () {
|
|
@@ -268,16 +264,14 @@ describe("TextInput component tests", function () {
|
|
|
268
264
|
|
|
269
265
|
expect(onChange).toHaveBeenCalled();
|
|
270
266
|
expect(onChange).toHaveBeenCalledWith({
|
|
271
|
-
value: "length"
|
|
272
|
-
error: null
|
|
267
|
+
value: "length"
|
|
273
268
|
});
|
|
274
269
|
|
|
275
270
|
_react2.fireEvent.blur(input);
|
|
276
271
|
|
|
277
272
|
expect(onBlur).toHaveBeenCalled();
|
|
278
273
|
expect(onBlur).toHaveBeenCalledWith({
|
|
279
|
-
value: "length"
|
|
280
|
-
error: null
|
|
274
|
+
value: "length"
|
|
281
275
|
});
|
|
282
276
|
});
|
|
283
277
|
test("Pattern and length constraints", function () {
|
|
@@ -350,16 +344,14 @@ describe("TextInput component tests", function () {
|
|
|
350
344
|
|
|
351
345
|
expect(onChange).toHaveBeenCalled();
|
|
352
346
|
expect(onChange).toHaveBeenCalledWith({
|
|
353
|
-
value: "tests4&"
|
|
354
|
-
error: null
|
|
347
|
+
value: "tests4&"
|
|
355
348
|
});
|
|
356
349
|
|
|
357
350
|
_react2.fireEvent.blur(input);
|
|
358
351
|
|
|
359
352
|
expect(onBlur).toHaveBeenCalled();
|
|
360
353
|
expect(onBlur).toHaveBeenCalledWith({
|
|
361
|
-
value: "tests4&"
|
|
362
|
-
error: null
|
|
354
|
+
value: "tests4&"
|
|
363
355
|
});
|
|
364
356
|
});
|
|
365
357
|
test("onChange function is called correctly", function () {
|
|
@@ -378,8 +370,7 @@ describe("TextInput component tests", function () {
|
|
|
378
370
|
expect(input.value).toBe("onchange event test");
|
|
379
371
|
expect(onChange).toHaveBeenCalled();
|
|
380
372
|
expect(onChange).toHaveBeenCalledWith({
|
|
381
|
-
value: "onchange event test"
|
|
382
|
-
error: null
|
|
373
|
+
value: "onchange event test"
|
|
383
374
|
});
|
|
384
375
|
});
|
|
385
376
|
test("onBlur function is called correctly", function () {
|
|
@@ -405,8 +396,7 @@ describe("TextInput component tests", function () {
|
|
|
405
396
|
|
|
406
397
|
expect(onBlur).toHaveBeenCalled();
|
|
407
398
|
expect(onBlur).toHaveBeenCalledWith({
|
|
408
|
-
value: "Blur test"
|
|
409
|
-
error: null
|
|
399
|
+
value: "Blur test"
|
|
410
400
|
});
|
|
411
401
|
});
|
|
412
402
|
test("Clear action's tooltip is correct", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
@@ -638,7 +628,7 @@ describe("TextInput component tests", function () {
|
|
|
638
628
|
expect(input.getAttribute("aria-expanded")).toBe("true");
|
|
639
629
|
expect(list.getAttribute("aria-label")).toBe("Autocomplete Countries");
|
|
640
630
|
var options = getAllByRole("option");
|
|
641
|
-
expect(options[0].getAttribute("aria-selected")).
|
|
631
|
+
expect(options[0].getAttribute("aria-selected")).toBeNull();
|
|
642
632
|
});
|
|
643
633
|
});
|
|
644
634
|
describe("TextInput component synchronous autosuggest tests", function () {
|
|
@@ -944,8 +934,7 @@ describe("TextInput component synchronous autosuggest tests", function () {
|
|
|
944
934
|
_userEvent["default"].click(getByRole("option"));
|
|
945
935
|
|
|
946
936
|
expect(onChange).toHaveBeenCalledWith({
|
|
947
|
-
value: "Andorra"
|
|
948
|
-
error: null
|
|
937
|
+
value: "Andorra"
|
|
949
938
|
});
|
|
950
939
|
expect(queryByRole("listbox")).toBeFalsy();
|
|
951
940
|
|
|
@@ -1291,7 +1280,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1291
1280
|
resolve(newValue ? countries.filter(function (option) {
|
|
1292
1281
|
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1293
1282
|
}) : countries);
|
|
1294
|
-
},
|
|
1283
|
+
}, 100);
|
|
1295
1284
|
});
|
|
1296
1285
|
return result;
|
|
1297
1286
|
});
|
|
@@ -1363,7 +1352,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1363
1352
|
resolve(newValue ? countries.filter(function (option) {
|
|
1364
1353
|
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1365
1354
|
}) : countries);
|
|
1366
|
-
},
|
|
1355
|
+
}, 100);
|
|
1367
1356
|
});
|
|
1368
1357
|
return result;
|
|
1369
1358
|
});
|
|
@@ -1412,7 +1401,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1412
1401
|
resolve(newValue ? countries.filter(function (option) {
|
|
1413
1402
|
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1414
1403
|
}) : countries);
|
|
1415
|
-
},
|
|
1404
|
+
}, 100);
|
|
1416
1405
|
});
|
|
1417
1406
|
return result;
|
|
1418
1407
|
});
|
|
@@ -1481,7 +1470,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1481
1470
|
resolve(newValue ? countries.filter(function (option) {
|
|
1482
1471
|
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1483
1472
|
}) : countries);
|
|
1484
|
-
},
|
|
1473
|
+
}, 100);
|
|
1485
1474
|
});
|
|
1486
1475
|
return result;
|
|
1487
1476
|
});
|
|
@@ -1508,8 +1497,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1508
1497
|
_userEvent["default"].click(getByRole("option"));
|
|
1509
1498
|
|
|
1510
1499
|
expect(onChange).toHaveBeenCalledWith({
|
|
1511
|
-
value: "Denmark"
|
|
1512
|
-
error: null
|
|
1500
|
+
value: "Denmark"
|
|
1513
1501
|
});
|
|
1514
1502
|
expect(input.value).toBe("Denmark");
|
|
1515
1503
|
|
|
@@ -1533,7 +1521,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1533
1521
|
resolve(newValue ? countries.filter(function (option) {
|
|
1534
1522
|
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1535
1523
|
}) : countries);
|
|
1536
|
-
},
|
|
1524
|
+
}, 100);
|
|
1537
1525
|
});
|
|
1538
1526
|
return result;
|
|
1539
1527
|
});
|
|
@@ -1560,8 +1548,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1560
1548
|
_userEvent["default"].click(getByRole("option"));
|
|
1561
1549
|
|
|
1562
1550
|
expect(onChange).toHaveBeenCalledWith({
|
|
1563
|
-
value: "Denmark"
|
|
1564
|
-
error: null
|
|
1551
|
+
value: "Denmark"
|
|
1565
1552
|
});
|
|
1566
1553
|
expect(queryByRole("listbox")).toBeFalsy();
|
|
1567
1554
|
|
|
@@ -1585,7 +1572,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1585
1572
|
resolve(newValue ? countries.filter(function (option) {
|
|
1586
1573
|
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1587
1574
|
}) : countries);
|
|
1588
|
-
},
|
|
1575
|
+
}, 100);
|
|
1589
1576
|
});
|
|
1590
1577
|
return result;
|
|
1591
1578
|
});
|
|
@@ -1629,7 +1616,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1629
1616
|
resolve(newValue ? countries.filter(function (option) {
|
|
1630
1617
|
return option.toUpperCase().includes(newValue.toUpperCase());
|
|
1631
1618
|
}) : countries);
|
|
1632
|
-
},
|
|
1619
|
+
}, 100);
|
|
1633
1620
|
});
|
|
1634
1621
|
return result;
|
|
1635
1622
|
});
|
|
@@ -1693,7 +1680,7 @@ describe("TextInput component asynchronous autosuggest tests", function () {
|
|
|
1693
1680
|
var result = new Promise(function (resolve, reject) {
|
|
1694
1681
|
return setTimeout(function () {
|
|
1695
1682
|
reject("err");
|
|
1696
|
-
},
|
|
1683
|
+
}, 100);
|
|
1697
1684
|
});
|
|
1698
1685
|
return result;
|
|
1699
1686
|
});
|
package/text-input/types.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ declare type Margin = {
|
|
|
6
6
|
left?: Space;
|
|
7
7
|
right?: Space;
|
|
8
8
|
};
|
|
9
|
-
declare type SVG = React.
|
|
9
|
+
declare type SVG = React.ReactNode & React.SVGProps<SVGSVGElement>;
|
|
10
10
|
declare type Action = {
|
|
11
11
|
/**
|
|
12
12
|
* This function will be called when the user clicks the action.
|
|
@@ -78,26 +78,29 @@ declare type Props = {
|
|
|
78
78
|
* This function will be called when the user types within the input
|
|
79
79
|
* element of the component. An object including the current value and
|
|
80
80
|
* the error (if the value entered is not valid) will be passed to this
|
|
81
|
-
* function. If there is no error, error will be
|
|
81
|
+
* function. If there is no error, error will not be defined.
|
|
82
82
|
*/
|
|
83
83
|
onChange?: (val: {
|
|
84
84
|
value: string;
|
|
85
|
-
error
|
|
85
|
+
error?: string;
|
|
86
86
|
}) => void;
|
|
87
87
|
/**
|
|
88
88
|
* This function will be called when the input element loses the focus.
|
|
89
89
|
* An object including the input value and the error (if the value
|
|
90
90
|
* entered is not valid) will be passed to this function. If there is no error,
|
|
91
|
-
* error will be
|
|
91
|
+
* error will not be defined.
|
|
92
92
|
*/
|
|
93
93
|
onBlur?: (val: {
|
|
94
94
|
value: string;
|
|
95
|
-
error
|
|
95
|
+
error?: string;
|
|
96
96
|
}) => void;
|
|
97
97
|
/**
|
|
98
|
-
* If it is defined
|
|
99
|
-
* the error below the input component. If
|
|
100
|
-
*
|
|
98
|
+
* If it is a defined value and also a truthy string, the component will
|
|
99
|
+
* change its appearance, showing the error below the input component. If
|
|
100
|
+
* the defined value is an empty string, it will reserve a space below
|
|
101
|
+
* the component for a future error, but it would not change its look. In
|
|
102
|
+
* case of being undefined or null, both the appearance and the space for
|
|
103
|
+
* the error message would not be modified.
|
|
101
104
|
*/
|
|
102
105
|
error?: string;
|
|
103
106
|
/**
|
|
@@ -114,7 +117,7 @@ declare type Props = {
|
|
|
114
117
|
* pattern, the onBlur and onChange functions will be called with the
|
|
115
118
|
* current value and an internal error informing that this value does not
|
|
116
119
|
* match the pattern. If the pattern is met, the error parameter of both
|
|
117
|
-
* events will be
|
|
120
|
+
* events will not be defined.
|
|
118
121
|
*/
|
|
119
122
|
pattern?: string;
|
|
120
123
|
/**
|
|
@@ -124,7 +127,7 @@ declare type Props = {
|
|
|
124
127
|
* comply the minimum length, the onBlur and onChange functions will be called
|
|
125
128
|
* with the current value and an internal error informing that the value
|
|
126
129
|
* length does not comply the specified range. If a valid length is
|
|
127
|
-
* reached, the error parameter of both events will be
|
|
130
|
+
* reached, the error parameter of both events will not be defined.
|
|
128
131
|
*/
|
|
129
132
|
minLength?: number;
|
|
130
133
|
/**
|
|
@@ -134,7 +137,7 @@ declare type Props = {
|
|
|
134
137
|
* comply the maximum length, the onBlur and onChange functions will be called
|
|
135
138
|
* with the current value and an internal error informing that the value
|
|
136
139
|
* length does not comply the specified range. If a valid length is
|
|
137
|
-
* reached, the error parameter of both events will be
|
|
140
|
+
* reached, the error parameter of both events will not be defined.
|
|
138
141
|
*/
|
|
139
142
|
maxLength?: number;
|
|
140
143
|
/**
|
|
@@ -148,7 +151,7 @@ declare type Props = {
|
|
|
148
151
|
*/
|
|
149
152
|
margin?: Space | Margin;
|
|
150
153
|
/**
|
|
151
|
-
* Size of the component
|
|
154
|
+
* Size of the component.
|
|
152
155
|
*/
|
|
153
156
|
size?: "small" | "medium" | "large" | "fillParent";
|
|
154
157
|
/**
|
|
@@ -160,4 +163,16 @@ declare type Props = {
|
|
|
160
163
|
* Reference to the component.
|
|
161
164
|
*/
|
|
162
165
|
export declare type RefType = HTMLDivElement;
|
|
166
|
+
/**
|
|
167
|
+
* Single suggestion of the Autosuggest Text Input component.
|
|
168
|
+
*/
|
|
169
|
+
export declare type SuggestionProps = {
|
|
170
|
+
id: string;
|
|
171
|
+
value: string;
|
|
172
|
+
onClick: () => void;
|
|
173
|
+
suggestion: string;
|
|
174
|
+
isLast: boolean;
|
|
175
|
+
visuallyFocused: boolean;
|
|
176
|
+
highlighted: boolean;
|
|
177
|
+
};
|
|
163
178
|
export default Props;
|