@dxc-technology/halstack-react 9.1.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HalstackContext.d.ts +11 -6
- package/HalstackContext.js +1 -1
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +2 -14
- package/accordion/Accordion.stories.tsx +2 -100
- package/accordion/types.d.ts +0 -12
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +21 -42
- package/accordion-group/AccordionGroup.stories.tsx +77 -76
- package/accordion-group/AccordionGroup.test.js +6 -16
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +0 -12
- package/alert/Alert.js +1 -3
- package/box/Box.d.ts +1 -1
- package/box/Box.js +5 -22
- package/box/Box.stories.tsx +25 -53
- package/box/types.d.ts +0 -12
- package/bulleted-list/BulletedList.js +4 -2
- package/bulleted-list/BulletedList.stories.tsx +7 -1
- package/bulleted-list/types.d.ts +31 -4
- package/button/Button.d.ts +1 -1
- package/button/Button.js +45 -54
- package/button/Button.stories.tsx +3 -3
- package/button/Button.test.js +11 -0
- package/button/types.d.ts +4 -0
- package/card/Card.d.ts +1 -1
- package/card/Card.js +18 -35
- package/card/Card.stories.tsx +0 -29
- package/card/types.d.ts +1 -7
- package/chip/Chip.js +23 -36
- package/chip/Chip.stories.tsx +25 -17
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +167 -0
- package/common/variables.d.ts +9 -144
- package/common/variables.js +960 -1095
- package/date-input/Calendar.js +2 -2
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +4 -22
- package/dialog/Dialog.stories.tsx +52 -176
- package/dialog/types.d.ts +0 -13
- package/dropdown/DropdownMenu.js +5 -1
- package/file-input/FileItem.js +2 -2
- package/file-input/types.d.ts +1 -1
- package/flex/Flex.js +4 -2
- package/flex/Flex.stories.tsx +24 -10
- package/flex/types.d.ts +70 -5
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +43 -61
- package/footer/Footer.stories.tsx +19 -95
- package/footer/Footer.test.js +3 -1
- package/footer/types.d.ts +10 -12
- package/grid/Grid.d.ts +1 -1
- package/grid/Grid.js +1 -1
- package/grid/Grid.stories.tsx +38 -38
- package/header/Header.d.ts +1 -1
- package/header/Header.js +3 -30
- package/header/Header.stories.tsx +7 -71
- package/header/types.d.ts +0 -14
- package/image/Image.d.ts +4 -0
- package/image/Image.js +85 -0
- package/image/Image.stories.tsx +127 -0
- package/image/types.d.ts +72 -0
- package/inset/Inset.stories.tsx +1 -1
- package/layout/ApplicationLayout.d.ts +2 -2
- package/layout/ApplicationLayout.js +14 -11
- package/layout/ApplicationLayout.stories.tsx +1 -1
- package/layout/Icons.d.ts +7 -4
- package/layout/Icons.js +52 -56
- package/link/Link.js +1 -1
- package/main.d.ts +2 -1
- package/main.js +8 -0
- package/nav-tabs/NavTabs.d.ts +2 -2
- package/nav-tabs/NavTabs.js +7 -10
- package/nav-tabs/NavTabs.stories.tsx +14 -0
- package/nav-tabs/Tab.js +22 -26
- package/nav-tabs/types.d.ts +8 -9
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +6 -4
- package/number-input/NumberInput.test.js +278 -95
- package/package.json +2 -2
- package/paginator/Paginator.js +1 -1
- package/paginator/Paginator.test.js +13 -0
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +39 -0
- package/password-input/PasswordInput.js +35 -82
- package/password-input/PasswordInput.stories.tsx +1 -0
- package/password-input/PasswordInput.test.js +27 -34
- package/radio-group/Radio.js +10 -10
- package/radio-group/RadioGroup.js +8 -10
- package/select/Select.stories.tsx +3 -3
- package/select/Select.test.js +4 -4
- package/sidenav/Sidenav.js +21 -23
- package/text-input/TextInput.js +62 -78
- package/text-input/TextInput.stories.tsx +1 -1
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +79 -56
- package/toggle-group/ToggleGroup.stories.tsx +6 -3
- package/toggle-group/ToggleGroup.test.js +37 -23
- package/toggle-group/types.d.ts +22 -13
- package/useTheme.d.ts +9 -1
- package/utils/FocusLock.js +2 -3
- package/card/ice-cream.jpg +0 -0
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- /package/{number-input/numberInputContextTypes.js → image/types.js} +0 -0
package/sidenav/Sidenav.js
CHANGED
|
@@ -54,9 +54,7 @@ var DxcSidenav = function DxcSidenav(_ref) {
|
|
|
54
54
|
}, title, /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
|
|
55
55
|
direction: "column",
|
|
56
56
|
gap: "1rem"
|
|
57
|
-
},
|
|
58
|
-
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, child, index !== _react["default"].Children.count(children) - 1 && /*#__PURE__*/_react["default"].createElement(Divider, null));
|
|
59
|
-
})))));
|
|
57
|
+
}, children))));
|
|
60
58
|
};
|
|
61
59
|
|
|
62
60
|
var Title = function Title(_ref2) {
|
|
@@ -68,11 +66,11 @@ var Title = function Title(_ref2) {
|
|
|
68
66
|
|
|
69
67
|
var Section = function Section(_ref3) {
|
|
70
68
|
var children = _ref3.children;
|
|
71
|
-
return /*#__PURE__*/_react["default"].createElement(_Bleed["default"], {
|
|
69
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Bleed["default"], {
|
|
72
70
|
horizontal: "1rem"
|
|
73
71
|
}, /*#__PURE__*/_react["default"].createElement(_Flex["default"], {
|
|
74
72
|
direction: "column"
|
|
75
|
-
}, children));
|
|
73
|
+
}, children)), /*#__PURE__*/_react["default"].createElement(Divider, null));
|
|
76
74
|
};
|
|
77
75
|
|
|
78
76
|
var GroupContext = /*#__PURE__*/_react["default"].createContext(null);
|
|
@@ -152,15 +150,15 @@ var Link = /*#__PURE__*/(0, _react.forwardRef)(function (_ref5, ref) {
|
|
|
152
150
|
}) : icon, children), newWindow && _Icons["default"].externalLinkIcon);
|
|
153
151
|
});
|
|
154
152
|
|
|
155
|
-
var SidenavContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n
|
|
153
|
+
var SidenavContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n width: 280px;\n @media (max-width: ", "rem) {\n width: 100vw;\n }\n padding: 2rem 1rem;\n background-color: ", ";\n\n overflow-y: auto;\n overflow-x: hidden;\n ::-webkit-scrollbar {\n width: 2px;\n }\n ::-webkit-scrollbar-track {\n background-color: ", ";\n border-radius: 3px;\n }\n ::-webkit-scrollbar-thumb {\n background-color: ", ";\n border-radius: 3px;\n }\n"])), _variables.responsiveSizes.medium, function (props) {
|
|
156
154
|
return props.theme.backgroundColor;
|
|
157
|
-
},
|
|
155
|
+
}, function (props) {
|
|
158
156
|
return props.theme.scrollBarTrackColor;
|
|
159
157
|
}, function (props) {
|
|
160
158
|
return props.theme.scrollBarThumbColor;
|
|
161
159
|
});
|
|
162
160
|
|
|
163
|
-
var SidenavTitle = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n padding: 0.5rem 1.2rem;\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n font-size: ", ";\n color: ", ";\n
|
|
161
|
+
var SidenavTitle = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n padding: 0.5rem 1.2rem;\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n font-size: ", ";\n color: ", ";\n letter-spacing: ", ";\n text-transform: ", ";\n"])), function (props) {
|
|
164
162
|
return props.theme.titleFontFamily;
|
|
165
163
|
}, function (props) {
|
|
166
164
|
return props.theme.titleFontStyle;
|
|
@@ -170,15 +168,15 @@ var SidenavTitle = _styledComponents["default"].div(_templateObject2 || (_templa
|
|
|
170
168
|
return props.theme.titleFontSize;
|
|
171
169
|
}, function (props) {
|
|
172
170
|
return props.theme.titleFontColor;
|
|
173
|
-
}, function (props) {
|
|
174
|
-
return props.theme.titleFontTextTransform;
|
|
175
171
|
}, function (props) {
|
|
176
172
|
return props.theme.titleFontLetterSpacing;
|
|
173
|
+
}, function (props) {
|
|
174
|
+
return props.theme.titleFontTextTransform;
|
|
177
175
|
});
|
|
178
176
|
|
|
179
|
-
var Divider = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n width: 100%;\n height: 1px;\n background-color: #999999;\n"])));
|
|
177
|
+
var Divider = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n width: 100%;\n height: 1px;\n background-color: #999999;\n\n &:last-child {\n display: none;\n }\n"])));
|
|
180
178
|
|
|
181
|
-
var SidenavGroup = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
179
|
+
var SidenavGroup = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n a {\n padding: 0.5rem 1.2rem 0.5rem 2.25rem;\n }\n"])));
|
|
182
180
|
|
|
183
181
|
var SidenavGroupTitle = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.5rem 1.2rem;\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n font-size: ", ";\n\n img,\n svg {\n height: 16px;\n width: 16px;\n }\n"])), function (props) {
|
|
184
182
|
return props.theme.groupTitleFontFamily;
|
|
@@ -190,7 +188,7 @@ var SidenavGroupTitle = _styledComponents["default"].span(_templateObject5 || (_
|
|
|
190
188
|
return props.theme.groupTitleFontSize;
|
|
191
189
|
});
|
|
192
190
|
|
|
193
|
-
var SidenavGroupTitleButton = _styledComponents["default"].button(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n all: unset;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n padding: 0.5rem 1.2rem;\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n font-size: ", ";\n cursor: pointer;\n\n ", "\n\n &:focus, &:focus-visible {\n outline: 2px solid ", ";\n outline-offset: -2px;\n }\n &:hover {\n ", "\n }\n &:active {\n
|
|
191
|
+
var SidenavGroupTitleButton = _styledComponents["default"].button(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n all: unset;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n padding: 0.5rem 1.2rem;\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n font-size: ", ";\n cursor: pointer;\n\n ", "\n\n &:focus, &:focus-visible {\n outline: 2px solid ", ";\n outline-offset: -2px;\n }\n &:hover {\n ", "\n }\n &:active {\n color: #fff;\n background-color: ", ";\n }\n\n img,\n svg {\n height: 16px;\n width: 16px;\n }\n"])), function (props) {
|
|
194
192
|
return props.theme.groupTitleFontFamily;
|
|
195
193
|
}, function (props) {
|
|
196
194
|
return props.theme.groupTitleFontStyle;
|
|
@@ -205,18 +203,10 @@ var SidenavGroupTitleButton = _styledComponents["default"].button(_templateObjec
|
|
|
205
203
|
}, function (props) {
|
|
206
204
|
return props.selectedGroup ? "color: ".concat(props.theme.groupTitleSelectedHoverFontColor, "; background-color: ").concat(props.theme.groupTitleSelectedHoverBackgroundColor, ";") : "color: ".concat(props.theme.groupTitleFontColor, "; background-color: ").concat(props.theme.groupTitleHoverBackgroundColor, ";");
|
|
207
205
|
}, function (props) {
|
|
208
|
-
return props.theme.groupTitleActiveBackgroundColor;
|
|
209
|
-
}, function (props) {
|
|
210
|
-
return props.theme.groupTitleFontColor;
|
|
206
|
+
return props.selectedGroup ? "#333" : props.theme.groupTitleActiveBackgroundColor;
|
|
211
207
|
});
|
|
212
208
|
|
|
213
|
-
var SidenavLink = _styledComponents["default"].a(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n padding: 0.5rem 1.2rem;\n box-shadow: 0 0 0 2px transparent;\n
|
|
214
|
-
return props.theme.linkFontLetterSpacing;
|
|
215
|
-
}, function (props) {
|
|
216
|
-
return props.theme.linkFontTextTransform;
|
|
217
|
-
}, function (props) {
|
|
218
|
-
return props.theme.linkTextDecoration;
|
|
219
|
-
}, function (props) {
|
|
209
|
+
var SidenavLink = _styledComponents["default"].a(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 0.5rem;\n padding: 0.5rem 1.2rem;\n box-shadow: 0 0 0 2px transparent;\n font-family: ", ";\n font-style: ", ";\n font-weight: ", ";\n font-size: ", ";\n letter-spacing: ", ";\n text-transform: ", ";\n text-decoration: ", ";\n cursor: pointer;\n\n ", "\n\n &:focus, &:focus-visible {\n outline: 2px solid ", ";\n outline-offset: -2px;\n }\n &:hover {\n ", "\n }\n &:active {\n color: #fff;\n background-color: ", ";\n outline: 2px solid #0095ff;\n outline-offset: -2px;\n }\n\n img,\n svg {\n height: 16px;\n width: 16px;\n }\n"])), function (props) {
|
|
220
210
|
return props.theme.linkFontFamily;
|
|
221
211
|
}, function (props) {
|
|
222
212
|
return props.theme.linkFontStyle;
|
|
@@ -224,12 +214,20 @@ var SidenavLink = _styledComponents["default"].a(_templateObject7 || (_templateO
|
|
|
224
214
|
return props.theme.linkFontWeight;
|
|
225
215
|
}, function (props) {
|
|
226
216
|
return props.theme.linkFontSize;
|
|
217
|
+
}, function (props) {
|
|
218
|
+
return props.theme.linkFontLetterSpacing;
|
|
219
|
+
}, function (props) {
|
|
220
|
+
return props.theme.linkFontTextTransform;
|
|
221
|
+
}, function (props) {
|
|
222
|
+
return props.theme.linkTextDecoration;
|
|
227
223
|
}, function (props) {
|
|
228
224
|
return props.selected ? "color: ".concat(props.theme.linkSelectedFontColor, "; background-color: ").concat(props.theme.linkSelectedBackgroundColor, ";") : "color: ".concat(props.theme.linkFontColor, "; background-color: transparent;");
|
|
229
225
|
}, function (props) {
|
|
230
226
|
return props.theme.linkFocusColor;
|
|
231
227
|
}, function (props) {
|
|
232
228
|
return props.selected ? "color: ".concat(props.theme.linkSelectedHoverFontColor, "; background-color: ").concat(props.theme.linkSelectedHoverBackgroundColor, ";") : "color: ".concat(props.theme.linkFontColor, "; background-color: ").concat(props.theme.linkHoverBackgroundColor, ";");
|
|
229
|
+
}, function (props) {
|
|
230
|
+
return props.selected ? "#333" : "#4d4d4d";
|
|
233
231
|
});
|
|
234
232
|
|
|
235
233
|
DxcSidenav.Section = Section;
|
package/text-input/TextInput.js
CHANGED
|
@@ -29,7 +29,7 @@ var _utils = require("../common/utils");
|
|
|
29
29
|
|
|
30
30
|
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _NumberInput = require("../number-input/NumberInput");
|
|
33
33
|
|
|
34
34
|
var _Suggestions = _interopRequireDefault(require("./Suggestions"));
|
|
35
35
|
|
|
@@ -88,20 +88,20 @@ var hasSuggestions = function hasSuggestions(suggestions) {
|
|
|
88
88
|
return typeof suggestions === "function" || (suggestions === null || suggestions === void 0 ? void 0 : suggestions.length) > 0;
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
var
|
|
91
|
+
var isRequired = function isRequired(value, optional) {
|
|
92
92
|
return value === "" && !optional;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
var isLengthIncorrect = function isLengthIncorrect(value, minLength, maxLength) {
|
|
96
|
-
return value
|
|
96
|
+
return value != null && (value.length < minLength || value.length > maxLength);
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
var isNumberIncorrect = function isNumberIncorrect(value, minNumber, maxNumber) {
|
|
100
|
-
return
|
|
100
|
+
return value < minNumber || value > maxNumber;
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
-
var
|
|
104
|
-
return pattern && !new RegExp(pattern).test(value);
|
|
103
|
+
var patternMismatch = function patternMismatch(pattern, value) {
|
|
104
|
+
return pattern != null && !new RegExp(pattern).test(value);
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
@@ -182,10 +182,10 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
182
182
|
var colorsTheme = (0, _useTheme["default"])();
|
|
183
183
|
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
184
184
|
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
185
|
-
var numberInputContext = (0, _react.useContext)(
|
|
185
|
+
var numberInputContext = (0, _react.useContext)(_NumberInput.NumberInputContext);
|
|
186
186
|
|
|
187
187
|
var getNumberErrorMessage = function getNumberErrorMessage(value) {
|
|
188
|
-
if (
|
|
188
|
+
if (value < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) return translatedLabels.numberInput.valueGreaterThanOrEqualToErrorMessage(numberInputContext.minNumber);else if (value > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) return translatedLabels.numberInput.valueLessThanOrEqualToErrorMessage(numberInputContext.maxNumber);
|
|
189
189
|
};
|
|
190
190
|
|
|
191
191
|
var getTextInputWidth = (0, _react.useCallback)(function () {
|
|
@@ -207,22 +207,22 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
207
207
|
};
|
|
208
208
|
|
|
209
209
|
var changeValue = function changeValue(newValue) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (
|
|
213
|
-
value:
|
|
210
|
+
var formattedValue = typeof newValue === "number" ? newValue.toString() : newValue;
|
|
211
|
+
value !== null && value !== void 0 ? value : setInnerValue(formattedValue);
|
|
212
|
+
if (isRequired(formattedValue, optional)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
213
|
+
value: formattedValue,
|
|
214
214
|
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
215
|
-
});else if (isLengthIncorrect(
|
|
216
|
-
value:
|
|
215
|
+
});else if (isLengthIncorrect(formattedValue, minLength, maxLength)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
216
|
+
value: formattedValue,
|
|
217
217
|
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
218
|
-
});else if (
|
|
219
|
-
value:
|
|
218
|
+
});else if (patternMismatch(pattern, formattedValue)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
219
|
+
value: formattedValue,
|
|
220
220
|
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
221
|
-
});else if (isNumberIncorrect(newValue, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
222
|
-
value:
|
|
223
|
-
error: getNumberErrorMessage(newValue)
|
|
221
|
+
});else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && isNumberIncorrect(Number(newValue), numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
222
|
+
value: formattedValue,
|
|
223
|
+
error: getNumberErrorMessage(Number(newValue))
|
|
224
224
|
});else onChange === null || onChange === void 0 ? void 0 : onChange({
|
|
225
|
-
value:
|
|
225
|
+
value: formattedValue
|
|
226
226
|
});
|
|
227
227
|
};
|
|
228
228
|
|
|
@@ -242,18 +242,18 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
242
242
|
|
|
243
243
|
var handleInputOnBlur = function handleInputOnBlur(event) {
|
|
244
244
|
closeSuggestions();
|
|
245
|
-
if (
|
|
245
|
+
if (isRequired(event.target.value, optional)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
246
246
|
value: event.target.value,
|
|
247
247
|
error: translatedLabels.formFields.requiredValueErrorMessage
|
|
248
248
|
});else if (isLengthIncorrect(event.target.value, minLength, maxLength)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
249
249
|
value: event.target.value,
|
|
250
250
|
error: translatedLabels.formFields.lengthErrorMessage(minLength, maxLength)
|
|
251
|
-
});else if (
|
|
251
|
+
});else if (patternMismatch(pattern, event.target.value)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
252
252
|
value: event.target.value,
|
|
253
253
|
error: translatedLabels.formFields.formatRequestedErrorMessage
|
|
254
|
-
});else if (isNumberIncorrect(event.target.value, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
254
|
+
});else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && isNumberIncorrect(Number(event.target.value), numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber, numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
255
255
|
value: event.target.value,
|
|
256
|
-
error: getNumberErrorMessage(event.target.value)
|
|
256
|
+
error: getNumberErrorMessage(Number(event.target.value))
|
|
257
257
|
});else onBlur === null || onBlur === void 0 ? void 0 : onBlur({
|
|
258
258
|
value: event.target.value
|
|
259
259
|
});
|
|
@@ -338,49 +338,33 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
338
338
|
var setNumberProps = function setNumberProps(type, min, max, step) {
|
|
339
339
|
var _inputRef$current2, _inputRef$current3, _inputRef$current4, _inputRef$current5;
|
|
340
340
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
341
|
+
min && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : _inputRef$current2.setAttribute("min", min));
|
|
342
|
+
max && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.setAttribute("max", max));
|
|
343
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.setAttribute("step", step);
|
|
344
|
+
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : _inputRef$current5.setAttribute("type", type);
|
|
345
345
|
};
|
|
346
346
|
|
|
347
347
|
var decrementNumber = function decrementNumber() {
|
|
348
|
-
var
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);
|
|
354
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && (parseInt(numberValue) === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || numberValue === "" || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && parseInt(numberValue) - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber))) {
|
|
355
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);
|
|
356
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.minNumber && parseInt(numberValue) - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) >= (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue !== "") {
|
|
357
|
-
changeValue(parseInt(numberValue) - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
358
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue == "") {
|
|
359
|
-
changeValue(-(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
360
|
-
} else if (numberValue === "") {
|
|
361
|
-
changeValue(-1);
|
|
348
|
+
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
349
|
+
var numberValue = Number(currentValue);
|
|
350
|
+
var steppedValue = Math.round((numberValue - (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) + Number.EPSILON) * 100) / 100;
|
|
351
|
+
|
|
352
|
+
if (currentValue !== "") {
|
|
353
|
+
if (numberValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) || steppedValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberValue);else if (numberValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else if (numberValue === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else changeValue(steppedValue);
|
|
362
354
|
} else {
|
|
363
|
-
changeValue(
|
|
355
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) >= 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) < 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(-numberInputContext.stepNumber);
|
|
364
356
|
}
|
|
365
357
|
};
|
|
366
358
|
|
|
367
359
|
var incrementNumber = function incrementNumber() {
|
|
368
|
-
var
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);
|
|
374
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.maxNumber && (parseInt(numberValue) === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && parseInt(numberValue) + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber))) {
|
|
375
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);
|
|
376
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.maxNumber && parseInt(numberValue) + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) <= (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) || numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue !== "") {
|
|
377
|
-
changeValue(parseInt(numberValue) + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber));
|
|
378
|
-
} else if (numberInputContext !== null && numberInputContext !== void 0 && numberInputContext.stepNumber && numberValue == "") {
|
|
379
|
-
changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber);
|
|
380
|
-
} else if (numberValue === "") {
|
|
381
|
-
changeValue(1);
|
|
360
|
+
var currentValue = value !== null && value !== void 0 ? value : innerValue;
|
|
361
|
+
var numberValue = Number(currentValue);
|
|
362
|
+
var steppedValue = Math.round((numberValue + (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.stepNumber) + Number.EPSILON) * 100) / 100;
|
|
363
|
+
|
|
364
|
+
if (currentValue !== "") {
|
|
365
|
+
if (numberValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) || steppedValue > (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberValue);else if (numberValue < (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if (numberValue === (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber)) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(steppedValue);
|
|
382
366
|
} else {
|
|
383
|
-
changeValue(
|
|
367
|
+
if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber) > 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.minNumber);else if ((numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber) <= 0) changeValue(numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.maxNumber);else changeValue(numberInputContext.stepNumber);
|
|
384
368
|
}
|
|
385
369
|
};
|
|
386
370
|
|
|
@@ -410,7 +394,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
410
394
|
changeVisualFocusIndex(-1);
|
|
411
395
|
}
|
|
412
396
|
|
|
413
|
-
|
|
397
|
+
numberInputContext != null && setNumberProps(numberInputContext.typeNumber, numberInputContext.minNumber, numberInputContext.maxNumber, numberInputContext.stepNumber);
|
|
414
398
|
}, [value, innerValue, suggestions, numberInputContext]);
|
|
415
399
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
416
400
|
theme: colorsTheme.textInput
|
|
@@ -502,51 +486,51 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
502
486
|
backgroundType: backgroundType,
|
|
503
487
|
"aria-label": "Error"
|
|
504
488
|
}, _Icons["default"].error), !disabled && clearable && (value !== null && value !== void 0 ? value : innerValue).length > 0 && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
489
|
+
"aria-label": translatedLabels.textInput.clearFieldActionTitle,
|
|
505
490
|
onClick: handleClearActionOnClick,
|
|
506
491
|
onMouseDown: function onMouseDown(event) {
|
|
507
492
|
event.stopPropagation();
|
|
508
493
|
},
|
|
509
|
-
backgroundType: backgroundType,
|
|
510
494
|
tabIndex: tabIndex,
|
|
511
495
|
title: translatedLabels.textInput.clearFieldActionTitle,
|
|
512
|
-
"
|
|
513
|
-
|
|
496
|
+
type: "button",
|
|
497
|
+
backgroundType: backgroundType
|
|
514
498
|
}, _Icons["default"].clear), (numberInputContext === null || numberInputContext === void 0 ? void 0 : numberInputContext.typeNumber) === "number" && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(Action, {
|
|
515
|
-
|
|
499
|
+
"aria-label": translatedLabels.numberInput.decrementValueTitle,
|
|
516
500
|
disabled: disabled,
|
|
517
501
|
onClick: handleDecrementActionOnClick,
|
|
518
502
|
onMouseDown: function onMouseDown(event) {
|
|
519
503
|
event.stopPropagation();
|
|
520
504
|
},
|
|
521
|
-
|
|
505
|
+
ref: actionRef,
|
|
522
506
|
tabIndex: tabIndex,
|
|
523
507
|
title: translatedLabels.numberInput.decrementValueTitle,
|
|
524
|
-
"
|
|
525
|
-
|
|
508
|
+
type: "button",
|
|
509
|
+
backgroundType: backgroundType
|
|
526
510
|
}, _Icons["default"].decrement), /*#__PURE__*/_react["default"].createElement(Action, {
|
|
527
|
-
|
|
511
|
+
"aria-label": translatedLabels.numberInput.incrementValueTitle,
|
|
528
512
|
disabled: disabled,
|
|
529
513
|
onClick: handleIncrementActionOnClick,
|
|
530
514
|
onMouseDown: function onMouseDown(event) {
|
|
531
515
|
event.stopPropagation();
|
|
532
516
|
},
|
|
533
|
-
|
|
517
|
+
ref: actionRef,
|
|
534
518
|
tabIndex: tabIndex,
|
|
535
519
|
title: translatedLabels.numberInput.incrementValueTitle,
|
|
536
|
-
"
|
|
537
|
-
|
|
520
|
+
type: "button",
|
|
521
|
+
backgroundType: backgroundType
|
|
538
522
|
}, _Icons["default"].increment)), action && /*#__PURE__*/_react["default"].createElement(Action, {
|
|
539
|
-
|
|
523
|
+
"aria-label": action.title,
|
|
540
524
|
disabled: disabled,
|
|
541
525
|
onClick: action.onClick,
|
|
542
526
|
onMouseDown: function onMouseDown(event) {
|
|
543
527
|
event.stopPropagation();
|
|
544
528
|
},
|
|
545
|
-
|
|
546
|
-
"aria-label": action.title,
|
|
547
|
-
backgroundType: backgroundType,
|
|
529
|
+
ref: actionRef,
|
|
548
530
|
tabIndex: tabIndex,
|
|
549
|
-
|
|
531
|
+
title: action.title,
|
|
532
|
+
type: "button",
|
|
533
|
+
backgroundType: backgroundType
|
|
550
534
|
}, typeof action.icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
551
535
|
src: action.icon
|
|
552
536
|
}) : action.icon), suffix && /*#__PURE__*/_react["default"].createElement(Suffix, {
|
|
@@ -559,7 +543,7 @@ var DxcTextInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, re
|
|
|
559
543
|
}, error)));
|
|
560
544
|
});
|
|
561
545
|
|
|
562
|
-
var TextInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n
|
|
546
|
+
var TextInputContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n width: ", ";\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
563
547
|
return calculateWidth(props.margin, props.size);
|
|
564
548
|
}, function (props) {
|
|
565
549
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -607,7 +591,7 @@ var HelperText = _styledComponents["default"].span(_templateObject4 || (_templat
|
|
|
607
591
|
return props.theme.helperTextLineHeight;
|
|
608
592
|
});
|
|
609
593
|
|
|
610
|
-
var InputContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n
|
|
594
|
+
var InputContainer = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n position: relative;\n display: flex;\n align-items: center;\n height: calc(2.5rem - 2px);\n padding: 0 0.5rem;\n\n ", "\n box-shadow: 0 0 0 2px transparent;\n border-radius: 4px;\n border: 1px solid\n ", ";\n ", "\n ", ";\n\n ", ";\n"])), function (props) {
|
|
611
595
|
if (props.disabled) return props.backgroundType === "dark" ? "background-color: ".concat(props.theme.disabledContainerFillColorOnDark, ";") : "background-color: ".concat(props.theme.disabledContainerFillColor, ";");
|
|
612
596
|
}, function (props) {
|
|
613
597
|
if (props.disabled) return props.backgroundType === "dark" ? props.theme.disabledBorderColorOnDark : props.theme.disabledBorderColor;else return props.backgroundType === "dark" ? props.theme.enabledBorderColorOnDark : props.theme.enabledBorderColor;
|
|
@@ -642,7 +626,7 @@ var Action = _styledComponents["default"].button(_templateObject7 || (_templateO
|
|
|
642
626
|
}, function (props) {
|
|
643
627
|
return props.disabled ? props.backgroundType === "dark" ? props.theme.disabledActionIconColorOnDark : props.theme.disabledActionIconColor : props.backgroundType === "dark" ? props.theme.actionIconColorOnDark : props.theme.actionIconColor;
|
|
644
628
|
}, function (props) {
|
|
645
|
-
return !props.disabled && "\n &:focus
|
|
629
|
+
return !props.disabled && "\n &:focus, \n &:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px ".concat(props.backgroundType === "dark" ? props.theme.focusActionBorderColorOnDark : props.theme.focusActionBorderColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.focusActionIconColorOnDark : props.theme.focusActionIconColor, ";\n }\n &:hover {\n background-color: ").concat(props.backgroundType === "dark" ? props.theme.hoverActionBackgroundColorOnDark : props.theme.hoverActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.hoverActionIconColorOnDark : props.theme.hoverActionIconColor, ";\n }\n &:active {\n background-color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionBackgroundColorOnDark : props.theme.activeActionBackgroundColor, ";\n color: ").concat(props.backgroundType === "dark" ? props.theme.activeActionIconColorOnDark : props.theme.activeActionIconColor, ";\n }\n ");
|
|
646
630
|
});
|
|
647
631
|
|
|
648
632
|
var Prefix = _styledComponents["default"].span(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n height: 1.5rem;\n line-height: 1.5rem;\n margin-left: 0.25rem;\n padding: 0 0.5rem 0 0;\n ", ";\n font-family: ", ";\n font-size: 1rem;\n pointer-events: none;\n"])), function (props) {
|
|
@@ -522,7 +522,7 @@ const DarkAutosuggestListbox = () => {
|
|
|
522
522
|
<Title title="Dark theme" theme="dark" level={2} />
|
|
523
523
|
<ExampleContainer>
|
|
524
524
|
<Title title="Default with opened suggestions" theme="dark" level={3} />
|
|
525
|
-
<DxcFlex direction="column" gap="
|
|
525
|
+
<DxcFlex direction="column" gap="5rem">
|
|
526
526
|
<DxcTextInput label="Label" suggestions={countries} optional placeholder="Choose an option" />
|
|
527
527
|
<DxcCheckbox
|
|
528
528
|
label="You understand the selection and give your consent"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
declare const DxcToggleGroup: ({ label, helperText, defaultValue, value, onChange, disabled, options, margin, multiple, tabIndex, }:
|
|
2
|
+
import ToggleGroupPropsType from "./types";
|
|
3
|
+
declare const DxcToggleGroup: ({ label, helperText, defaultValue, value, onChange, disabled, options, margin, multiple, tabIndex, }: ToggleGroupPropsType) => JSX.Element;
|
|
4
4
|
export default DxcToggleGroup;
|