@dxc-technology/halstack-react 0.0.0-bcc5ff3 → 0.0.0-bd364ae
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 +110 -58
- 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 +31 -32
- package/bleed/types.d.ts +1 -1
- package/box/Box.js +22 -32
- package/card/Card.js +34 -36
- package/checkbox/Checkbox.js +4 -1
- package/common/variables.js +162 -68
- package/date-input/DateInput.js +5 -2
- package/file-input/FileInput.js +9 -6
- package/footer/Footer.js +7 -5
- package/header/Header.js +7 -4
- package/inset/Inset.js +1 -34
- package/inset/Inset.stories.tsx +32 -32
- package/inset/types.d.ts +1 -1
- package/layout/ApplicationLayout.d.ts +4 -3
- package/layout/ApplicationLayout.js +83 -102
- package/layout/ApplicationLayout.stories.tsx +14 -59
- 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 +5 -10
- package/link/Link.d.ts +2 -2
- package/link/Link.js +23 -49
- package/link/types.d.ts +2 -3
- package/main.d.ts +3 -3
- package/main.js +14 -8
- package/package.json +1 -1
- package/paginator/Paginator.js +17 -38
- package/password-input/PasswordInput.js +7 -4
- package/password-input/PasswordInput.test.js +1 -2
- package/progress-bar/ProgressBar.js +1 -1
- package/progress-bar/ProgressBar.stories.jsx +11 -11
- package/quick-nav/QuickNav.js +65 -17
- package/quick-nav/QuickNav.stories.tsx +2 -2
- package/quick-nav/types.d.ts +1 -1
- package/radio-group/Radio.js +1 -1
- package/radio-group/RadioGroup.js +8 -6
- package/select/Listbox.js +4 -1
- package/select/Select.js +37 -47
- package/select/Select.stories.tsx +14 -2
- package/select/Select.test.js +257 -194
- package/sidenav/Sidenav.d.ts +1 -1
- package/sidenav/Sidenav.js +20 -9
- package/spinner/Spinner.js +1 -1
- package/switch/Switch.js +4 -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 +132 -0
- package/tabs-nav/types.d.ts +53 -0
- package/{radio → tabs-nav}/types.js +0 -0
- package/text-input/TextInput.js +19 -20
- package/textarea/Textarea.js +10 -19
- package/useTranslatedLabels.d.ts +2 -0
- package/useTranslatedLabels.js +20 -0
- package/wizard/Wizard.js +27 -25
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -173
- package/radio/Radio.stories.tsx +0 -192
- package/radio/Radio.test.js +0 -71
- package/radio/types.d.ts +0 -54
package/tabs-nav/Tab.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = void 0;
|
|
11
|
+
|
|
12
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
+
|
|
14
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
|
+
|
|
16
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
17
|
+
|
|
18
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
+
|
|
20
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
21
|
+
|
|
22
|
+
var _Badge = _interopRequireDefault(require("../badge/Badge"));
|
|
23
|
+
|
|
24
|
+
var _NavTabs = require("./NavTabs");
|
|
25
|
+
|
|
26
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
27
|
+
|
|
28
|
+
var _excluded = ["href", "active", "icon", "disabled", "notificationNumber", "children"];
|
|
29
|
+
|
|
30
|
+
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); }
|
|
31
|
+
|
|
32
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(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; }
|
|
33
|
+
|
|
34
|
+
var DxcTab = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, _ref2) {
|
|
35
|
+
var href = _ref.href,
|
|
36
|
+
_ref$active = _ref.active,
|
|
37
|
+
active = _ref$active === void 0 ? false : _ref$active,
|
|
38
|
+
icon = _ref.icon,
|
|
39
|
+
_ref$disabled = _ref.disabled,
|
|
40
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
41
|
+
_ref$notificationNumb = _ref.notificationNumber,
|
|
42
|
+
notificationNumber = _ref$notificationNumb === void 0 ? false : _ref$notificationNumb,
|
|
43
|
+
children = _ref.children,
|
|
44
|
+
otherProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
45
|
+
var tabRef = /*#__PURE__*/(0, _react.createRef)();
|
|
46
|
+
|
|
47
|
+
var _useContext = (0, _react.useContext)(_NavTabs.NavTabsContext),
|
|
48
|
+
iconPosition = _useContext.iconPosition,
|
|
49
|
+
tabIndex = _useContext.tabIndex,
|
|
50
|
+
hasIcons = _useContext.hasIcons,
|
|
51
|
+
focusedLabel = _useContext.focusedLabel;
|
|
52
|
+
|
|
53
|
+
(0, _react.useLayoutEffect)(function () {
|
|
54
|
+
var _tabRef$current;
|
|
55
|
+
|
|
56
|
+
focusedLabel === children.toString() && (tabRef === null || tabRef === void 0 ? void 0 : (_tabRef$current = tabRef.current) === null || _tabRef$current === void 0 ? void 0 : _tabRef$current.focus());
|
|
57
|
+
}, [focusedLabel]);
|
|
58
|
+
|
|
59
|
+
var handleOnKeyDown = function handleOnKeyDown(event) {
|
|
60
|
+
var _tabRef$current2;
|
|
61
|
+
|
|
62
|
+
switch (event.keyCode) {
|
|
63
|
+
case 13: // enter
|
|
64
|
+
|
|
65
|
+
case 32:
|
|
66
|
+
// space
|
|
67
|
+
tabRef === null || tabRef === void 0 ? void 0 : (_tabRef$current2 = tabRef.current) === null || _tabRef$current2 === void 0 ? void 0 : _tabRef$current2.click();
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return /*#__PURE__*/_react["default"].createElement(TabContainer, {
|
|
74
|
+
active: active,
|
|
75
|
+
role: "tab",
|
|
76
|
+
"aria-selected": active
|
|
77
|
+
}, /*#__PURE__*/_react["default"].createElement(Tab, (0, _extends2["default"])({
|
|
78
|
+
href: !disabled && href ? href : undefined,
|
|
79
|
+
disabled: disabled,
|
|
80
|
+
iconPosition: iconPosition,
|
|
81
|
+
hasIcon: hasIcons,
|
|
82
|
+
ref: function ref(anchorRef) {
|
|
83
|
+
tabRef.current = anchorRef;
|
|
84
|
+
|
|
85
|
+
if (_ref2) {
|
|
86
|
+
if (typeof _ref2 === "function") _ref2(anchorRef);else {
|
|
87
|
+
_ref2.current = anchorRef;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
onKeyDown: handleOnKeyDown,
|
|
92
|
+
tabIndex: active ? tabIndex : -1
|
|
93
|
+
}, otherProps), icon && /*#__PURE__*/_react["default"].createElement(TabIconContainer, {
|
|
94
|
+
iconPosition: iconPosition
|
|
95
|
+
}, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement(TabIcon, {
|
|
96
|
+
src: icon
|
|
97
|
+
}) : icon), /*#__PURE__*/_react["default"].createElement(LabelContainer, null, children, notificationNumber && /*#__PURE__*/_react["default"].createElement(BadgeContainer, null, /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
98
|
+
notificationText: notificationNumber > 99 ? "+99" : notificationNumber,
|
|
99
|
+
disabled: disabled
|
|
100
|
+
})))));
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
var TabContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n border-bottom: 2px solid ", ";\n"])), function (props) {
|
|
104
|
+
return props.active ? "#6f2c91" : "#0000001a";
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
var Tab = _styledComponents["default"].a(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: ", ";\n justify-content: center;\n align-items: center;\n\n font-family: \"Open Sans\";\n font-style: normal;\n font-weight: 400;\n font-size: 1rem;\n color: ", ";\n text-decoration-color: transparent;\n cursor: ", ";\n\n height: ", ";\n min-width: 164px;\n margin: 0.5rem;\n padding: 0.375rem;\n\n border-radius: 4px;\n\n ", "\n"])), function (props) {
|
|
108
|
+
return props.hasIcon && props.iconPosition === "top" ? "column" : "row";
|
|
109
|
+
}, function (props) {
|
|
110
|
+
return props.disabled ? "#0000004D" : "#333333";
|
|
111
|
+
}, function (props) {
|
|
112
|
+
return props.disabled ? "not-allowed" : "pointer";
|
|
113
|
+
}, function (props) {
|
|
114
|
+
return props.hasIcon && props.iconPosition === "top" ? "66px" : "32px";
|
|
115
|
+
}, function (props) {
|
|
116
|
+
return !props.disabled && ":hover {\n background: #0000000D;\n }\n\n :focus {\n outline: 2px solid #33aaff};\n }\n\n :active {\n background: #0000001A;\n outline: 2px solid #33aaff};\n }";
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
var TabIcon = _styledComponents["default"].img(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])([""])));
|
|
120
|
+
|
|
121
|
+
var TabIconContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: 24px;\n max-width: 24px;\n margin-bottom: ", ";\n margin-right: ", ";\n overflow: hidden;\n display: flex;\n align-items: center;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
|
|
122
|
+
return props.iconPosition === "top" && "0.375rem";
|
|
123
|
+
}, function (props) {
|
|
124
|
+
return props.iconPosition === "left" && "0.625rem";
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
var LabelContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n"])));
|
|
128
|
+
|
|
129
|
+
var BadgeContainer = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: 0.5rem;\n"])));
|
|
130
|
+
|
|
131
|
+
var _default = DxcTab;
|
|
132
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type SVG = React.SVGProps<SVGSVGElement>;
|
|
3
|
+
export declare type TabProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Whether the tab is active or not.
|
|
6
|
+
*/
|
|
7
|
+
active?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the tab is disabled or not.
|
|
10
|
+
*/
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Page to be opened when the user clicks on the tab.
|
|
14
|
+
*/
|
|
15
|
+
href?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Element or path used as the icon that will be displayed in the tab.
|
|
18
|
+
*/
|
|
19
|
+
icon?: string | SVG;
|
|
20
|
+
/**
|
|
21
|
+
* If the value is 'true', an empty badge will appear.
|
|
22
|
+
* If it is 'false', no badge will appear.
|
|
23
|
+
* If a number is put it will be shown as the label of the notification
|
|
24
|
+
* in the tab, taking into account that if that number is greater than 99,
|
|
25
|
+
* it will appear as '+99' in the badge.
|
|
26
|
+
*/
|
|
27
|
+
notificationNumber?: boolean | number;
|
|
28
|
+
/**
|
|
29
|
+
* Content of the tab.
|
|
30
|
+
*/
|
|
31
|
+
children: string;
|
|
32
|
+
};
|
|
33
|
+
export declare type NavTabsProps = {
|
|
34
|
+
/**
|
|
35
|
+
* Whether the icon should appear above or to the left of the label.
|
|
36
|
+
*/
|
|
37
|
+
iconPosition?: "top" | "left";
|
|
38
|
+
/**
|
|
39
|
+
* Value of the tabindex for each tab.
|
|
40
|
+
*/
|
|
41
|
+
tabIndex?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Content of the tabs nav.
|
|
44
|
+
*/
|
|
45
|
+
children: React.ReactNode;
|
|
46
|
+
};
|
|
47
|
+
export declare type NavTabsContextProps = {
|
|
48
|
+
iconPosition: "top" | "left";
|
|
49
|
+
tabIndex: number;
|
|
50
|
+
hasIcons: boolean;
|
|
51
|
+
focusedLabel: string;
|
|
52
|
+
};
|
|
53
|
+
export {};
|
|
File without changes
|
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");
|
|
@@ -207,6 +209,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
207
209
|
var inputRef = (0, _react.useRef)(null);
|
|
208
210
|
var actionRef = (0, _react.useRef)(null);
|
|
209
211
|
var colorsTheme = (0, _useTheme["default"])();
|
|
212
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
210
213
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
211
214
|
var autosuggestId = "".concat(inputId, "-listBox");
|
|
212
215
|
var errorId = "error-".concat(inputId);
|
|
@@ -223,10 +226,6 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
223
226
|
return value && minLength && maxLength && (value.length < minLength || value.length > maxLength);
|
|
224
227
|
};
|
|
225
228
|
|
|
226
|
-
var getLengthErrorMessage = function getLengthErrorMessage() {
|
|
227
|
-
return "Min length ".concat(minLength, ", max length ").concat(maxLength, ".");
|
|
228
|
-
};
|
|
229
|
-
|
|
230
229
|
var isNumberIncorrect = function isNumberIncorrect(value) {
|
|
231
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);
|
|
232
231
|
};
|
|
@@ -238,7 +237,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
238
237
|
};
|
|
239
238
|
|
|
240
239
|
var getNumberErrorMessage = function getNumberErrorMessage(value) {
|
|
241
|
-
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);
|
|
242
241
|
};
|
|
243
242
|
|
|
244
243
|
var hasSuggestions = function hasSuggestions() {
|
|
@@ -259,13 +258,13 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
259
258
|
var changedValue = typeof newValue === "number" ? newValue.toString() : newValue;
|
|
260
259
|
if (isNotOptional(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
261
260
|
value: changedValue,
|
|
262
|
-
error:
|
|
261
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
263
262
|
});else if (isLengthIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
264
263
|
value: changedValue,
|
|
265
|
-
error:
|
|
264
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
266
265
|
});else if (newValue && pattern && !patternMatch(pattern, newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
267
266
|
value: changedValue,
|
|
268
|
-
error:
|
|
267
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
269
268
|
});else if (newValue && isNumberIncorrect(newValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
270
269
|
value: changedValue,
|
|
271
270
|
error: getNumberErrorMessage(newValue)
|
|
@@ -292,13 +291,13 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
292
291
|
suggestions && closeSuggestions();
|
|
293
292
|
if (isNotOptional(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
294
293
|
value: event.target.value,
|
|
295
|
-
error:
|
|
294
|
+
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
296
295
|
});else if (isLengthIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
297
296
|
value: event.target.value,
|
|
298
|
-
error:
|
|
297
|
+
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
299
298
|
});else if (event.target.value && pattern && !patternMatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
300
299
|
value: event.target.value,
|
|
301
|
-
error:
|
|
300
|
+
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
302
301
|
});else if (event.target.value && isNumberIncorrect(event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
303
302
|
value: event.target.value,
|
|
304
303
|
error: getNumberErrorMessage(event.target.value)
|
|
@@ -481,7 +480,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
481
480
|
disabled: disabled,
|
|
482
481
|
backgroundType: backgroundType,
|
|
483
482
|
hasHelperText: helperText ? true : false
|
|
484
|
-
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null,
|
|
483
|
+
}, label, " ", optional && /*#__PURE__*/_react["default"].createElement(OptionalLabel, null, translatedLabels.formFields.optionalLabel)), helperText && /*#__PURE__*/_react["default"].createElement(HelperText, {
|
|
485
484
|
disabled: disabled,
|
|
486
485
|
backgroundType: backgroundType
|
|
487
486
|
}, helperText), /*#__PURE__*/_react["default"].createElement(InputContainer, {
|
|
@@ -536,8 +535,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
536
535
|
},
|
|
537
536
|
backgroundType: backgroundType,
|
|
538
537
|
tabIndex: tabIndex,
|
|
539
|
-
title:
|
|
540
|
-
"aria-label":
|
|
538
|
+
title: translatedLabels.textInput.clearFieldActionTitle,
|
|
539
|
+
"aria-label": translatedLabels.textInput.clearFieldActionTitle
|
|
541
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, {
|
|
542
541
|
ref: actionRef,
|
|
543
542
|
disabled: disabled,
|
|
@@ -549,8 +548,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
549
548
|
},
|
|
550
549
|
backgroundType: backgroundType,
|
|
551
550
|
tabIndex: tabIndex,
|
|
552
|
-
title:
|
|
553
|
-
"aria-label":
|
|
551
|
+
title: translatedLabels.numberInput.decrementValueTitle,
|
|
552
|
+
"aria-label": translatedLabels.numberInput.decrementValueTitle
|
|
554
553
|
}, textInputIcons.decrement), /*#__PURE__*/_react["default"].createElement(Action, {
|
|
555
554
|
ref: actionRef,
|
|
556
555
|
disabled: disabled,
|
|
@@ -562,8 +561,8 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
562
561
|
},
|
|
563
562
|
backgroundType: backgroundType,
|
|
564
563
|
tabIndex: tabIndex,
|
|
565
|
-
title:
|
|
566
|
-
"aria-label":
|
|
564
|
+
title: translatedLabels.numberInput.incrementValueTitle,
|
|
565
|
+
"aria-label": translatedLabels.numberInput.incrementValueTitle
|
|
567
566
|
}, textInputIcons.increment)) : action && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
568
567
|
ref: actionRef,
|
|
569
568
|
disabled: disabled,
|
|
@@ -605,9 +604,9 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref
|
|
|
605
604
|
visuallyFocused: visualFocusedSuggIndex === index,
|
|
606
605
|
highlighted: typeof suggestions === "function"
|
|
607
606
|
});
|
|
608
|
-
}), 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, {
|
|
609
608
|
backgroundType: backgroundType
|
|
610
|
-
}, textInputIcons.error),
|
|
609
|
+
}, textInputIcons.error), translatedLabels.textInput.fetchingDataErrorMessage))), !disabled && typeof error === "string" && /*#__PURE__*/_react["default"].createElement(Error, {
|
|
611
610
|
id: errorId,
|
|
612
611
|
backgroundType: backgroundType,
|
|
613
612
|
"aria-live": error ? "assertive" : "off"
|
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, {
|
|
@@ -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) {
|
package/radio/Radio.d.ts
DELETED