@dxc-technology/halstack-react 0.0.0-8b133ff → 0.0.0-8b5e703
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 +4 -2
- package/HalstackContext.js +111 -56
- 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/button/Button.js +3 -1
- package/checkbox/Checkbox.js +4 -1
- package/common/variables.js +177 -64
- package/date-input/DateInput.js +5 -2
- package/file-input/FileInput.js +9 -6
- package/file-input/FileItem.js +7 -5
- package/footer/Footer.js +7 -5
- package/header/Header.js +7 -4
- package/link/Link.d.ts +3 -2
- package/link/Link.js +50 -70
- package/link/Link.stories.tsx +87 -52
- package/link/Link.test.js +7 -15
- package/link/types.d.ts +7 -23
- package/main.d.ts +3 -2
- package/main.js +14 -0
- package/number-input/types.d.ts +1 -1
- package/package.json +2 -1
- package/paginator/Paginator.js +17 -38
- package/password-input/PasswordInput.js +7 -4
- package/password-input/PasswordInput.test.js +1 -2
- package/password-input/types.d.ts +1 -1
- package/progress-bar/ProgressBar.js +1 -1
- package/progress-bar/ProgressBar.stories.jsx +11 -11
- package/quick-nav/QuickNav.js +63 -15
- package/quick-nav/QuickNav.stories.tsx +2 -2
- package/quick-nav/types.d.ts +4 -4
- package/radio-group/Radio.js +1 -1
- package/radio-group/RadioGroup.js +8 -6
- package/select/Listbox.js +5 -1
- package/select/Select.js +37 -47
- package/select/Select.stories.tsx +14 -2
- package/select/Select.test.js +257 -194
- package/spinner/Spinner.js +1 -1
- package/switch/Switch.js +4 -1
- package/tabs/Tabs.stories.tsx +0 -6
- package/tabs-nav/NavTabs.d.ts +7 -0
- package/tabs-nav/NavTabs.js +106 -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 +117 -0
- package/tabs-nav/types.d.ts +51 -0
- package/tabs-nav/types.js +5 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +55 -0
- package/text-input/TextInput.js +46 -72
- package/text-input/TextInput.test.js +1 -1
- package/text-input/types.d.ts +14 -2
- package/textarea/Textarea.js +10 -19
- package/textarea/types.d.ts +1 -1
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.js +27 -25
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
|
|
|
@@ -205,6 +209,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
205
209
|
var inputRef = (0, _react.useRef)(null);
|
|
206
210
|
var actionRef = (0, _react.useRef)(null);
|
|
207
211
|
var colorsTheme = (0, _useTheme["default"])();
|
|
212
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
208
213
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
209
214
|
var autosuggestId = "".concat(inputId, "-listBox");
|
|
210
215
|
var errorId = "error-".concat(inputId);
|
|
@@ -221,10 +226,6 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
221
226
|
return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
|
|
222
227
|
};
|
|
223
228
|
|
|
224
|
-
var getLengthErrorMessage = function getLengthErrorMessage() {
|
|
225
|
-
return "Min length ".concat(minLength, ", max length ").concat(maxLength, ".");
|
|
226
|
-
};
|
|
227
|
-
|
|
228
229
|
var isNumberIncorrect = function isNumberIncorrect(value) {
|
|
229
230
|
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
231
|
};
|
|
@@ -236,7 +237,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
236
237
|
};
|
|
237
238
|
|
|
238
239
|
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
|
|
240
|
+
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
241
|
};
|
|
241
242
|
|
|
242
243
|
var hasSuggestions = function hasSuggestions() {
|
|
@@ -257,13 +258,13 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
257
258
|
var changedValue = typeof newValue === "number" ? newValue.toString() : newValue;
|
|
258
259
|
if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
259
260
|
value: changedValue,
|
|
260
|
-
error:
|
|
261
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
261
262
|
});else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
262
263
|
value: changedValue,
|
|
263
|
-
error:
|
|
264
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
264
265
|
});else if (newValue && pattern && !patternMatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
265
266
|
value: changedValue,
|
|
266
|
-
error:
|
|
267
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
267
268
|
});else if (newValue && isNumberIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
268
269
|
value: changedValue,
|
|
269
270
|
error: getNumberErrorMessage(newValue)
|
|
@@ -290,13 +291,13 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
290
291
|
suggestions && closeSuggestions();
|
|
291
292
|
if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
292
293
|
value: event.target.value,
|
|
293
|
-
error:
|
|
294
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
294
295
|
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
295
296
|
value: event.target.value,
|
|
296
|
-
error:
|
|
297
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
297
298
|
});else if (event.target.value && pattern && !patternMatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
298
299
|
value: event.target.value,
|
|
299
|
-
error:
|
|
300
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
300
301
|
});else if (event.target.value && isNumberIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
301
302
|
value: event.target.value,
|
|
302
303
|
error: getNumberErrorMessage(event.target.value)
|
|
@@ -468,45 +469,22 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
468
469
|
|
|
469
470
|
(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
470
471
|
}, [value, innerValue, suggestions, numberInputContext]);
|
|
471
|
-
|
|
472
|
-
var HighlightedSuggestion = function HighlightedSuggestion(_ref2) {
|
|
473
|
-
var suggestion = _ref2.suggestion,
|
|
474
|
-
index = _ref2.index;
|
|
475
|
-
var regEx = new RegExp(value !== null && value !== void 0 ? value : innerValue, "i");
|
|
476
|
-
var matchedWords = suggestion.match(regEx);
|
|
477
|
-
var noMatchedWords = suggestion.replace(regEx, "");
|
|
478
|
-
var isLastOption = index === lastOptionIndex;
|
|
479
|
-
return /*#__PURE__*/_react["default"].createElement(Suggestion, {
|
|
480
|
-
id: "suggestion-".concat(index),
|
|
481
|
-
onClick: function onClick() {
|
|
482
|
-
changeValue(suggestion);
|
|
483
|
-
closeSuggestions();
|
|
484
|
-
},
|
|
485
|
-
visualFocused: visualFocusedSuggIndex === index,
|
|
486
|
-
role: "option",
|
|
487
|
-
"aria-selected": visualFocusedSuggIndex === index && "true"
|
|
488
|
-
}, /*#__PURE__*/_react["default"].createElement(StyledSuggestion, {
|
|
489
|
-
last: isLastOption,
|
|
490
|
-
visualFocused: visualFocusedSuggIndex === index
|
|
491
|
-
}, typeof suggestions === "function" ? suggestion : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("strong", null, matchedWords), noMatchedWords)));
|
|
492
|
-
};
|
|
493
|
-
|
|
494
472
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
495
473
|
theme: colorsTheme.textInput
|
|
496
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
474
|
+
}, /*#__PURE__*/_react["default"].createElement(TextInputContainer, {
|
|
497
475
|
margin: margin,
|
|
498
|
-
|
|
499
|
-
|
|
476
|
+
size: size,
|
|
477
|
+
ref: ref
|
|
500
478
|
}, label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
501
479
|
htmlFor: inputId,
|
|
502
480
|
disabled: disabled,
|
|
503
481
|
backgroundType: backgroundType,
|
|
504
|
-
helperText:
|
|
505
|
-
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null,
|
|
482
|
+
hasHelperText: helperText ? true : false
|
|
483
|
+
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
506
484
|
disabled: disabled,
|
|
507
485
|
backgroundType: backgroundType
|
|
508
486
|
}, helperText), /*#__PURE__*/_react["default"].createElement(InputContainer, {
|
|
509
|
-
error: error,
|
|
487
|
+
error: error ? true : false,
|
|
510
488
|
disabled: disabled,
|
|
511
489
|
backgroundType: backgroundType,
|
|
512
490
|
onClick: handleInputContainerOnClick,
|
|
@@ -557,8 +535,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
557
535
|
},
|
|
558
536
|
backgroundType: backgroundType,
|
|
559
537
|
tabIndex: tabIndex,
|
|
560
|
-
title:
|
|
561
|
-
"aria-label":
|
|
538
|
+
title: translatedLabels.textInput.clearFieldActionTitle,
|
|
539
|
+
"aria-label": translatedLabels.textInput.clearFieldActionTitle
|
|
562
540
|
}, 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, {
|
|
563
541
|
ref: actionRef,
|
|
564
542
|
disabled: disabled,
|
|
@@ -570,8 +548,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
570
548
|
},
|
|
571
549
|
backgroundType: backgroundType,
|
|
572
550
|
tabIndex: tabIndex,
|
|
573
|
-
title:
|
|
574
|
-
"aria-label":
|
|
551
|
+
title: translatedLabels.numberInput.decrementValueTitle,
|
|
552
|
+
"aria-label": translatedLabels.numberInput.decrementValueTitle
|
|
575
553
|
}, textInputIcons.decrement), /*#__PURE__*/_react["default"].createElement(Action, {
|
|
576
554
|
ref: actionRef,
|
|
577
555
|
disabled: disabled,
|
|
@@ -583,8 +561,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
583
561
|
},
|
|
584
562
|
backgroundType: backgroundType,
|
|
585
563
|
tabIndex: tabIndex,
|
|
586
|
-
title:
|
|
587
|
-
"aria-label":
|
|
564
|
+
title: translatedLabels.numberInput.incrementValueTitle,
|
|
565
|
+
"aria-label": translatedLabels.numberInput.incrementValueTitle
|
|
588
566
|
}, textInputIcons.increment)) : action && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
589
567
|
ref: actionRef,
|
|
590
568
|
disabled: disabled,
|
|
@@ -605,7 +583,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
605
583
|
backgroundType: backgroundType
|
|
606
584
|
}, suffix), isOpen && (filteredSuggestions.length > 0 || isSearching || isAutosuggestError) && /*#__PURE__*/_react["default"].createElement(Suggestions, {
|
|
607
585
|
id: autosuggestId,
|
|
608
|
-
|
|
586
|
+
error: isAutosuggestError ? true : false,
|
|
609
587
|
onMouseDown: function onMouseDown(event) {
|
|
610
588
|
event.preventDefault();
|
|
611
589
|
},
|
|
@@ -613,14 +591,22 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
613
591
|
role: "listbox",
|
|
614
592
|
"aria-label": label
|
|
615
593
|
}, !isSearching && !isAutosuggestError && filteredSuggestions.length > 0 && filteredSuggestions.map(function (suggestion, index) {
|
|
616
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
617
|
-
key: "suggestion-".concat(
|
|
594
|
+
return /*#__PURE__*/_react["default"].createElement(_Suggestion["default"], {
|
|
595
|
+
key: "suggestion-".concat(index),
|
|
596
|
+
id: "suggestion-".concat(index),
|
|
597
|
+
value: value !== null && value !== void 0 ? value : innerValue,
|
|
598
|
+
onClick: function onClick() {
|
|
599
|
+
changeValue(suggestion);
|
|
600
|
+
closeSuggestions();
|
|
601
|
+
},
|
|
618
602
|
suggestion: suggestion,
|
|
619
|
-
|
|
603
|
+
isLast: index === lastOptionIndex,
|
|
604
|
+
visuallyFocused: visualFocusedSuggIndex === index,
|
|
605
|
+
highlighted: typeof suggestions === "function"
|
|
620
606
|
});
|
|
621
|
-
}), isSearching && /*#__PURE__*/_react["default"].createElement(SuggestionsSystemMessage, null,
|
|
607
|
+
}), isSearching && /*#__PURE__*/_react["default"].createElement(SuggestionsSystemMessage, null, translatedLabels.textInput.searchingMessage), isAutosuggestError && /*#__PURE__*/_react["default"].createElement(SuggestionsError, null, /*#__PURE__*/_react["default"].createElement(SuggestionsErrorIcon, {
|
|
622
608
|
backgroundType: backgroundType
|
|
623
|
-
}, textInputIcons.error),
|
|
609
|
+
}, textInputIcons.error), translatedLabels.textInput.fetchingDataErrorMessage))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
624
610
|
id: errorId,
|
|
625
611
|
backgroundType: backgroundType,
|
|
626
612
|
"aria-live": error ? "assertive" : "off"
|
|
@@ -638,7 +624,7 @@ var calculateWidth = function calculateWidth(margin, size) {
|
|
|
638
624
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
639
625
|
};
|
|
640
626
|
|
|
641
|
-
var
|
|
627
|
+
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) {
|
|
642
628
|
return calculateWidth(props.margin, props.size);
|
|
643
629
|
}, function (props) {
|
|
644
630
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -665,7 +651,7 @@ var Label = _styledComponents["default"].label(_templateObject2 || (_templateObj
|
|
|
665
651
|
}, function (props) {
|
|
666
652
|
return props.theme.labelLineHeight;
|
|
667
653
|
}, function (props) {
|
|
668
|
-
return !props.
|
|
654
|
+
return !props.hasHelperText && "margin-bottom: 0.25rem";
|
|
669
655
|
});
|
|
670
656
|
|
|
671
657
|
var OptionalLabel = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n font-weight: ", ";\n"])), function (props) {
|
|
@@ -753,9 +739,9 @@ var Error = _styledComponents["default"].span(_templateObject12 || (_templateObj
|
|
|
753
739
|
});
|
|
754
740
|
|
|
755
741
|
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) {
|
|
756
|
-
return props.
|
|
742
|
+
return props.error ? props.theme.errorListDialogBackgroundColor : props.theme.listDialogBackgroundColor;
|
|
757
743
|
}, function (props) {
|
|
758
|
-
return props.
|
|
744
|
+
return props.error ? props.theme.errorListDialogBorderColor : props.theme.listDialogBorderColor;
|
|
759
745
|
}, function (props) {
|
|
760
746
|
return props.theme.listOptionFontColor;
|
|
761
747
|
}, function (props) {
|
|
@@ -768,27 +754,15 @@ var Suggestions = _styledComponents["default"].ul(_templateObject13 || (_templat
|
|
|
768
754
|
return props.theme.listOptionFontWeight;
|
|
769
755
|
});
|
|
770
756
|
|
|
771
|
-
var
|
|
772
|
-
return props.visualFocused ? props.theme.focusListOptionBorderColor : "transparent";
|
|
773
|
-
}, function (props) {
|
|
774
|
-
return props.theme.hoverListOptionBackgroundColor;
|
|
775
|
-
}, function (props) {
|
|
776
|
-
return props.theme.activeListOptionBackgroundColor;
|
|
777
|
-
});
|
|
778
|
-
|
|
779
|
-
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) {
|
|
780
|
-
return props.last || props.visualFocused ? "border-bottom: 1px solid transparent" : "border-bottom: 1px solid ".concat(props.theme.listOptionDividerColor);
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
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) {
|
|
757
|
+
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) {
|
|
784
758
|
return props.theme.systemMessageFontColor;
|
|
785
759
|
});
|
|
786
760
|
|
|
787
|
-
var SuggestionsErrorIcon = _styledComponents["default"].span(
|
|
761
|
+
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) {
|
|
788
762
|
return props.backgroundType === "dark" ? props.theme.errorIconColorOnDark : props.theme.errorIconColor;
|
|
789
763
|
});
|
|
790
764
|
|
|
791
|
-
var SuggestionsError = _styledComponents["default"].span(
|
|
765
|
+
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) {
|
|
792
766
|
return props.theme.errorListDialogFontColor;
|
|
793
767
|
});
|
|
794
768
|
|
|
@@ -628,7 +628,7 @@ describe("TextInput component tests", function () {
|
|
|
628
628
|
expect(input.getAttribute("aria-expanded")).toBe("true");
|
|
629
629
|
expect(list.getAttribute("aria-label")).toBe("Autocomplete Countries");
|
|
630
630
|
var options = getAllByRole("option");
|
|
631
|
-
expect(options[0].getAttribute("aria-selected")).
|
|
631
|
+
expect(options[0].getAttribute("aria-selected")).toBeNull();
|
|
632
632
|
});
|
|
633
633
|
});
|
|
634
634
|
describe("TextInput component synchronous autosuggest tests", function () {
|
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.SVGProps<SVGSVGElement
|
|
9
|
+
declare type SVG = React.SVGProps<SVGSVGElement>;
|
|
10
10
|
declare type Action = {
|
|
11
11
|
/**
|
|
12
12
|
* This function will be called when the user clicks the action.
|
|
@@ -151,7 +151,7 @@ declare type Props = {
|
|
|
151
151
|
*/
|
|
152
152
|
margin?: Space | Margin;
|
|
153
153
|
/**
|
|
154
|
-
* Size of the component
|
|
154
|
+
* Size of the component.
|
|
155
155
|
*/
|
|
156
156
|
size?: "small" | "medium" | "large" | "fillParent";
|
|
157
157
|
/**
|
|
@@ -163,4 +163,16 @@ declare type Props = {
|
|
|
163
163
|
* Reference to the component.
|
|
164
164
|
*/
|
|
165
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
|
+
};
|
|
166
178
|
export default Props;
|
package/textarea/Textarea.js
CHANGED
|
@@ -23,6 +23,8 @@ var _utils = require("../common/utils.js");
|
|
|
23
23
|
|
|
24
24
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
25
25
|
|
|
26
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
27
|
+
|
|
26
28
|
var _variables = require("../common/variables.js");
|
|
27
29
|
|
|
28
30
|
var _uuid = require("uuid");
|
|
@@ -35,14 +37,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
35
37
|
|
|
36
38
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
39
|
|
|
38
|
-
var getNotOptionalErrorMessage = function getNotOptionalErrorMessage() {
|
|
39
|
-
return "This field is required. Please, enter a value.";
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
var getPatternErrorMessage = function getPatternErrorMessage() {
|
|
43
|
-
return "Please match the format requested.";
|
|
44
|
-
};
|
|
45
|
-
|
|
46
40
|
var patternMatch = function patternMatch(pattern, value) {
|
|
47
41
|
return new RegExp(pattern).test(value);
|
|
48
42
|
};
|
|
@@ -90,13 +84,10 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
90
84
|
|
|
91
85
|
var colorsTheme = (0, _useTheme["default"])();
|
|
92
86
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
87
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
93
88
|
var textareaRef = (0, _react.useRef)(null);
|
|
94
89
|
var errorId = "error-".concat(textareaId);
|
|
95
90
|
|
|
96
|
-
var getLengthErrorMessage = function getLengthErrorMessage() {
|
|
97
|
-
return "Min length ".concat(minLength, ", max length ").concat(maxLength, ".");
|
|
98
|
-
};
|
|
99
|
-
|
|
100
91
|
var isNotOptional = function isNotOptional(value) {
|
|
101
92
|
return value === "" && !optional;
|
|
102
93
|
};
|
|
@@ -109,13 +100,13 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
109
100
|
value !== null && value !== void 0 ? value : setInnerValue(newValue);
|
|
110
101
|
if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
111
102
|
value: newValue,
|
|
112
|
-
error:
|
|
103
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
113
104
|
});else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
114
105
|
value: newValue,
|
|
115
|
-
error:
|
|
106
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
116
107
|
});else if (newValue && pattern && !patternMatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
117
108
|
value: newValue,
|
|
118
|
-
error:
|
|
109
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
119
110
|
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
120
111
|
value: newValue
|
|
121
112
|
});
|
|
@@ -124,13 +115,13 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
124
115
|
var handleTOnBlur = function handleTOnBlur(event) {
|
|
125
116
|
if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
126
117
|
value: event.target.value,
|
|
127
|
-
error:
|
|
118
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
128
119
|
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
129
120
|
value: event.target.value,
|
|
130
|
-
error:
|
|
121
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
131
122
|
});else if (event.target.value && pattern && !patternMatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
132
123
|
value: event.target.value,
|
|
133
|
-
error:
|
|
124
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
134
125
|
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
135
126
|
value: event.target.value
|
|
136
127
|
});
|
|
@@ -160,7 +151,7 @@ var DxcTextarea = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref)
|
|
|
160
151
|
disabled: disabled,
|
|
161
152
|
backgroundType: backgroundType,
|
|
162
153
|
helperText: helperText
|
|
163
|
-
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null,
|
|
154
|
+
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
164
155
|
disabled: disabled,
|
|
165
156
|
backgroundType: backgroundType
|
|
166
157
|
}, helperText), /*#__PURE__*/_react["default"].createElement(Textarea, {
|
package/textarea/types.d.ts
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _variables = require("./common/variables");
|
|
11
|
+
|
|
12
|
+
var _HalstackContext = require("./HalstackContext");
|
|
13
|
+
|
|
14
|
+
var useTranslatedLabels = function useTranslatedLabels() {
|
|
15
|
+
var labels = (0, _react.useContext)(_HalstackContext.HalstackLanguageContext);
|
|
16
|
+
return labels || _variables.defaultTranslatedComponentLabels;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
var _default = useTranslatedLabels;
|
|
20
|
+
exports["default"] = _default;
|
package/wizard/Wizard.js
CHANGED
|
@@ -147,9 +147,11 @@ var DxcWizard = function DxcWizard(_ref) {
|
|
|
147
147
|
disabled: step.disabled,
|
|
148
148
|
current: i === renderedCurrent
|
|
149
149
|
}, i + 1)), step.valid !== undefined && (step.valid ? /*#__PURE__*/_react["default"].createElement(ValidityIconContainer, null, icons.validIcon) : /*#__PURE__*/_react["default"].createElement(ValidityIconContainer, null, icons.invalidIcon))), (step.label || step.description) && /*#__PURE__*/_react["default"].createElement(InfoContainer, null, step.label && /*#__PURE__*/_react["default"].createElement(Label, {
|
|
150
|
+
current: i === renderedCurrent,
|
|
150
151
|
disabled: step.disabled,
|
|
151
152
|
visited: i <= innerCurrent
|
|
152
153
|
}, step.label), step.description && /*#__PURE__*/_react["default"].createElement(Description, {
|
|
154
|
+
current: i === renderedCurrent,
|
|
153
155
|
disabled: step.disabled,
|
|
154
156
|
visited: i <= innerCurrent
|
|
155
157
|
}, step.description))), i === steps.length - 1 ? "" : /*#__PURE__*/_react["default"].createElement(StepSeparator, {
|
|
@@ -200,40 +202,40 @@ var StepHeader = _styledComponents["default"].div(_templateObject4 || (_template
|
|
|
200
202
|
return props.validityIcon && "padding-bottom: 4px;";
|
|
201
203
|
});
|
|
202
204
|
|
|
203
|
-
var IconContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n\n ", "\n ", ";\n\n border-radius: ", ";\n display: flex;\n justify-content: center;\n align-items: center;\n"])), function (props) {
|
|
204
|
-
return props.disabled ? props.theme.
|
|
205
|
+
var IconContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n\n ", "\n ", ";\n\n border-radius: ", ";\n\n display: flex;\n justify-content: center;\n align-items: center;\n"])), function (props) {
|
|
206
|
+
return props.disabled ? props.theme.disabledStepWidth : props.current ? props.theme.selectedStepWidth : props.theme.stepWidth;
|
|
205
207
|
}, function (props) {
|
|
206
|
-
return props.disabled ? props.theme.
|
|
208
|
+
return props.disabled ? props.theme.disabledStepHeight : props.current ? props.theme.selectedStepHeight : props.theme.stepHeight;
|
|
207
209
|
}, function (props) {
|
|
208
|
-
return "\n ".concat(
|
|
210
|
+
return "\n ".concat(props.disabled ? "border: ".concat(props.theme.disabledStepBorderThickness, " ").concat(props.theme.disabledStepBorderStyle, " ").concat(props.theme.disabledStepBorderColor, ";") : props.current ? "border: ".concat(props.theme.selectedStepBorderThickness, " ").concat(props.theme.selectedStepBorderStyle, " ").concat(props.theme.selectedStepBorderColor, ";") : props.visited ? "border: ".concat(props.theme.stepBorderThickness, " ").concat(props.theme.stepBorderStyle, " ").concat(props.theme.visitedStepBorderColor, ";") : "border: ".concat(props.theme.stepBorderThickness, " ").concat(props.theme.stepBorderStyle, " ").concat(props.theme.unvisitedStepBorderColor, ";"), "\n background: ").concat(props.disabled ? "".concat(props.theme.disabledStepBackgroundColor) : props.current ? "".concat(props.theme.selectedStepBackgroundColor) : !props.visited ? "".concat(props.theme.unvisitedStepBackgroundColor) : "".concat(props.theme.visitedStepBackgroundColor), ";\n ");
|
|
209
211
|
}, function (props) {
|
|
210
|
-
return props.disabled ? "color: ".concat(props.theme.
|
|
212
|
+
return props.disabled ? "color: ".concat(props.theme.disabledStepFontColor, ";") : "color: ".concat(props.current ? props.theme.selectedStepFontColor : !props.visited ? props.theme.unvisitedStepFontColor : props.theme.visitedStepFontColor, ";");
|
|
211
213
|
}, function (props) {
|
|
212
|
-
return !props.current && !props.disabled ? props.theme.
|
|
214
|
+
return !props.current && !props.disabled ? props.theme.stepBorderRadius : props.current ? props.theme.selectedStepBorderRadius : props.disabled ? props.theme.disabledStepBorderRadius : "";
|
|
213
215
|
});
|
|
214
216
|
|
|
215
217
|
var Icon = _styledComponents["default"].img(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n"])), function (props) {
|
|
216
|
-
return props.theme.
|
|
218
|
+
return props.theme.stepIconSize;
|
|
217
219
|
}, function (props) {
|
|
218
|
-
return props.theme.
|
|
220
|
+
return props.theme.stepIconSize;
|
|
219
221
|
});
|
|
220
222
|
|
|
221
223
|
var StepIconContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n overflow: hidden;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
|
|
222
|
-
return props.theme.
|
|
224
|
+
return props.theme.stepIconSize;
|
|
223
225
|
}, function (props) {
|
|
224
|
-
return props.theme.
|
|
226
|
+
return props.theme.stepIconSize;
|
|
225
227
|
});
|
|
226
228
|
|
|
227
229
|
var Number = _styledComponents["default"].p(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n font-size: ", ";\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n opacity: 1;\n margin: 0px 0px 0px 1px;\n"])), function (props) {
|
|
228
|
-
return props.theme.
|
|
230
|
+
return props.theme.stepFontSize;
|
|
229
231
|
}, function (props) {
|
|
230
|
-
return props.theme.
|
|
232
|
+
return props.theme.stepFontFamily;
|
|
231
233
|
}, function (props) {
|
|
232
|
-
return props.theme.
|
|
234
|
+
return props.theme.stepFontStyle;
|
|
233
235
|
}, function (props) {
|
|
234
|
-
return props.theme.
|
|
236
|
+
return props.theme.stepFontWeight;
|
|
235
237
|
}, function (props) {
|
|
236
|
-
return props.theme.
|
|
238
|
+
return props.theme.stepFontTracking;
|
|
237
239
|
});
|
|
238
240
|
|
|
239
241
|
var ValidityIconContainer = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n width: 18px;\n height: 18px;\n position: absolute;\n top: 22.5px;\n left: 22.5px;\n"])));
|
|
@@ -251,29 +253,29 @@ var Label = _styledComponents["default"].p(_templateObject11 || (_templateObject
|
|
|
251
253
|
}, function (props) {
|
|
252
254
|
return props.theme.labelFontWeight;
|
|
253
255
|
}, function (props) {
|
|
254
|
-
return props.theme.
|
|
256
|
+
return props.theme.labelFontTracking;
|
|
255
257
|
}, function (props) {
|
|
256
|
-
return props.disabled ? "color: ".concat(props.theme.
|
|
258
|
+
return props.disabled ? "color: ".concat(props.theme.disabledLabelFontColor, ";") : "color: ".concat(!props.visited ? props.theme.unvisitedLabelFontColor : props.current ? props.theme.selectedLabelFontColor : props.theme.visitedLabelFontColor, ";");
|
|
257
259
|
}, function (props) {
|
|
258
260
|
return props.theme.labelFontTextTransform;
|
|
259
261
|
});
|
|
260
262
|
|
|
261
263
|
var Description = _styledComponents["default"].p(_templateObject12 || (_templateObject12 = (0, _taggedTemplateLiteral2["default"])(["\n text-align: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n letter-spacing: ", ";\n text-transform: ", ";\n ", ";\n margin: 0;\n"])), function (props) {
|
|
262
|
-
return props.theme.
|
|
264
|
+
return props.theme.helperTextTextAlign;
|
|
263
265
|
}, function (props) {
|
|
264
|
-
return props.theme.
|
|
266
|
+
return props.theme.helperTextFontFamily;
|
|
265
267
|
}, function (props) {
|
|
266
|
-
return props.theme.
|
|
268
|
+
return props.theme.helperTextFontSize;
|
|
267
269
|
}, function (props) {
|
|
268
|
-
return props.theme.
|
|
270
|
+
return props.theme.helperTextFontStyle;
|
|
269
271
|
}, function (props) {
|
|
270
|
-
return props.theme.
|
|
272
|
+
return props.theme.helperTextFontWeight;
|
|
271
273
|
}, function (props) {
|
|
272
|
-
return props.theme.
|
|
274
|
+
return props.theme.helperTextFontTracking;
|
|
273
275
|
}, function (props) {
|
|
274
|
-
return props.theme.
|
|
276
|
+
return props.theme.helperTextFontTextTransform;
|
|
275
277
|
}, function (props) {
|
|
276
|
-
return props.disabled ? "color: ".concat(props.theme.
|
|
278
|
+
return props.disabled ? "color: ".concat(props.theme.disabledHelperTextFontColor, ";") : "color: ".concat(!props.visited ? props.theme.unvisitedHelperTextFontColor : props.current ? props.theme.selectedHelperTextFontColor : props.theme.visitedHelperTextFontColor, ";");
|
|
277
279
|
});
|
|
278
280
|
|
|
279
281
|
var StepSeparator = _styledComponents["default"].div(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n ", "\n border: ", ";\n opacity: 1;\n flex-grow: 1;\n"])), function (props) {
|