@dxc-technology/halstack-react 0.0.0-9b45027 → 0.0.0-9bd9511
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/BackgroundColorContext.d.ts +2 -2
- package/BackgroundColorContext.js +1 -11
- package/HalstackContext.d.ts +13 -0
- package/HalstackContext.js +318 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +124 -179
- package/accordion/Accordion.stories.tsx +115 -27
- package/accordion/Accordion.test.js +56 -0
- package/accordion/types.d.ts +12 -11
- package/accordion-group/AccordionGroup.d.ts +1 -1
- package/accordion-group/AccordionGroup.js +28 -77
- package/accordion-group/AccordionGroup.stories.tsx +28 -2
- package/accordion-group/AccordionGroup.test.js +108 -0
- package/accordion-group/types.d.ts +19 -12
- package/alert/Alert.js +18 -46
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +75 -0
- package/alert/types.d.ts +3 -3
- package/badge/Badge.d.ts +4 -0
- package/badge/Badge.js +6 -16
- package/badge/types.d.ts +5 -0
- package/bleed/Bleed.d.ts +2 -2
- package/bleed/Bleed.js +14 -55
- package/bleed/Bleed.stories.tsx +94 -95
- package/bleed/types.d.ts +26 -2
- package/box/Box.js +34 -63
- package/box/Box.stories.tsx +15 -0
- package/box/Box.test.js +13 -0
- package/box/types.d.ts +5 -4
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +98 -0
- package/bulleted-list/BulletedList.stories.tsx +200 -0
- package/bulleted-list/types.d.ts +11 -0
- package/bulleted-list/types.js +5 -0
- package/button/Button.js +61 -100
- package/button/Button.stories.tsx +159 -8
- package/button/Button.test.js +26 -0
- package/button/types.d.ts +8 -8
- package/card/Card.js +44 -70
- package/card/Card.test.js +39 -0
- package/card/types.d.ts +4 -3
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +115 -162
- package/checkbox/Checkbox.stories.tsx +198 -130
- package/checkbox/Checkbox.test.js +128 -0
- package/checkbox/types.d.ts +14 -6
- package/chip/Chip.d.ts +1 -1
- package/chip/Chip.js +29 -91
- package/chip/Chip.stories.tsx +98 -13
- package/chip/Chip.test.js +42 -0
- package/chip/types.d.ts +8 -16
- package/common/utils.js +1 -6
- package/common/variables.d.ts +1431 -0
- package/common/variables.js +480 -554
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +215 -0
- package/date-input/DateInput.js +164 -300
- package/date-input/DateInput.stories.tsx +199 -33
- package/date-input/DateInput.test.js +648 -0
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +116 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +63 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +101 -0
- package/date-input/types.d.ts +71 -13
- package/dialog/Dialog.js +52 -84
- package/dialog/Dialog.stories.tsx +99 -22
- package/dialog/Dialog.test.js +56 -0
- package/dialog/types.d.ts +4 -3
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +240 -323
- package/dropdown/Dropdown.stories.tsx +255 -64
- package/dropdown/Dropdown.test.js +479 -0
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +60 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +70 -0
- package/dropdown/types.d.ts +30 -19
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +224 -351
- package/file-input/FileInput.stories.tsx +122 -11
- package/file-input/FileInput.test.js +445 -0
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +48 -97
- package/file-input/types.d.ts +24 -7
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +57 -0
- package/flex/Flex.stories.tsx +103 -0
- package/flex/types.d.ts +32 -0
- package/flex/types.js +5 -0
- package/footer/Footer.js +36 -143
- package/footer/Footer.stories.tsx +99 -1
- package/footer/Footer.test.js +92 -0
- package/footer/Icons.js +1 -5
- package/footer/types.d.ts +7 -6
- package/header/Header.js +112 -177
- package/header/Header.stories.tsx +189 -36
- package/header/Header.test.js +66 -0
- package/header/Icons.js +2 -6
- package/header/types.d.ts +4 -3
- package/heading/Heading.js +8 -29
- package/heading/Heading.test.js +169 -0
- package/heading/types.d.ts +3 -3
- package/inset/Inset.js +14 -55
- package/inset/Inset.stories.tsx +36 -36
- package/inset/types.d.ts +26 -2
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +71 -164
- package/layout/ApplicationLayout.stories.tsx +84 -93
- package/layout/Icons.d.ts +5 -0
- package/layout/Icons.js +11 -10
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +15 -0
- package/layout/types.d.ts +18 -33
- package/link/Link.d.ts +3 -2
- package/link/Link.js +61 -106
- package/link/Link.stories.tsx +159 -52
- package/link/Link.test.js +65 -0
- package/link/types.d.ts +9 -29
- package/main.d.ts +11 -15
- package/main.js +48 -121
- package/nav-tabs/NavTabs.d.ts +8 -0
- package/nav-tabs/NavTabs.js +95 -0
- package/nav-tabs/NavTabs.stories.tsx +260 -0
- package/nav-tabs/NavTabs.test.js +75 -0
- package/nav-tabs/Tab.d.ts +4 -0
- package/nav-tabs/Tab.js +120 -0
- package/nav-tabs/types.d.ts +53 -0
- package/nav-tabs/types.js +5 -0
- package/number-input/NumberInput.js +21 -38
- package/number-input/NumberInput.stories.tsx +5 -5
- package/number-input/NumberInput.test.js +406 -0
- package/number-input/NumberInputContext.js +0 -5
- package/number-input/numberInputContextTypes.d.ts +1 -1
- package/number-input/types.d.ts +21 -14
- package/package.json +22 -25
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -38
- package/paginator/Paginator.js +31 -82
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +266 -0
- package/paginator/types.d.ts +1 -1
- package/paragraph/Paragraph.d.ts +6 -0
- package/paragraph/Paragraph.js +28 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/password-input/PasswordInput.js +28 -54
- package/password-input/PasswordInput.test.js +138 -0
- package/password-input/types.d.ts +18 -15
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +65 -84
- package/progress-bar/ProgressBar.stories.jsx +47 -12
- package/progress-bar/ProgressBar.test.js +93 -0
- package/progress-bar/types.d.ts +3 -4
- package/quick-nav/QuickNav.d.ts +4 -0
- package/quick-nav/QuickNav.js +95 -0
- package/quick-nav/QuickNav.stories.tsx +356 -0
- package/quick-nav/types.d.ts +21 -0
- package/quick-nav/types.js +5 -0
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +61 -66
- package/radio-group/RadioGroup.js +99 -129
- package/radio-group/RadioGroup.stories.tsx +171 -36
- package/radio-group/RadioGroup.test.js +620 -0
- package/radio-group/types.d.ts +85 -7
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +48 -0
- package/resultsetTable/ResultsetTable.js +66 -157
- package/resultsetTable/ResultsetTable.stories.tsx +50 -25
- package/resultsetTable/ResultsetTable.test.js +292 -0
- package/resultsetTable/types.d.ts +5 -5
- package/select/Icons.d.ts +10 -0
- package/select/Icons.js +90 -0
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +144 -0
- package/select/Option.d.ts +4 -0
- package/select/Option.js +81 -0
- package/select/Select.js +201 -485
- package/select/Select.stories.tsx +600 -201
- package/select/Select.test.js +1845 -0
- package/select/types.d.ts +62 -22
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +164 -74
- package/sidenav/Sidenav.stories.tsx +249 -149
- package/sidenav/Sidenav.test.js +37 -0
- package/sidenav/types.d.ts +50 -27
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +143 -164
- package/slider/Slider.stories.tsx +72 -9
- package/slider/Slider.test.js +222 -0
- package/slider/types.d.ts +11 -3
- package/spinner/Spinner.js +12 -41
- package/spinner/Spinner.stories.jsx +27 -1
- package/spinner/Spinner.test.js +55 -0
- package/spinner/types.d.ts +3 -3
- package/switch/Switch.d.ts +2 -2
- package/switch/Switch.js +148 -107
- package/switch/Switch.stories.tsx +53 -42
- package/switch/Switch.test.js +180 -0
- package/switch/types.d.ts +13 -5
- package/table/Table.js +5 -23
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +21 -0
- package/table/types.d.ts +3 -3
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +115 -0
- package/tabs/Tabs.d.ts +1 -1
- package/tabs/Tabs.js +318 -139
- package/tabs/Tabs.stories.tsx +119 -13
- package/tabs/Tabs.test.js +295 -0
- package/tabs/types.d.ts +21 -7
- package/tag/Tag.d.ts +1 -1
- package/tag/Tag.js +36 -75
- package/tag/Tag.stories.tsx +37 -27
- package/tag/Tag.test.js +49 -0
- package/tag/types.d.ts +25 -16
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +57 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +68 -0
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +109 -0
- package/text-input/TextInput.js +232 -438
- package/text-input/TextInput.stories.tsx +310 -197
- package/text-input/TextInput.test.js +1404 -0
- package/text-input/types.d.ts +55 -17
- package/textarea/Textarea.js +53 -96
- package/textarea/Textarea.stories.jsx +93 -13
- package/textarea/Textarea.test.js +360 -0
- package/textarea/types.d.ts +22 -15
- package/toggle-group/ToggleGroup.d.ts +1 -1
- package/toggle-group/ToggleGroup.js +23 -57
- package/toggle-group/ToggleGroup.stories.tsx +46 -4
- package/toggle-group/ToggleGroup.test.js +124 -0
- package/toggle-group/types.d.ts +19 -11
- package/translatedLabelsType.d.ts +82 -0
- package/translatedLabelsType.js +5 -0
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +119 -0
- package/typography/Typography.stories.tsx +198 -0
- package/typography/types.d.ts +18 -0
- package/typography/types.js +5 -0
- package/useTheme.d.ts +1 -1
- package/useTheme.js +3 -9
- package/useTranslatedLabels.d.ts +3 -0
- package/useTranslatedLabels.js +15 -0
- package/wizard/Wizard.d.ts +1 -1
- package/wizard/Wizard.js +68 -98
- package/wizard/Wizard.stories.tsx +48 -19
- package/wizard/Wizard.test.js +114 -0
- package/wizard/types.d.ts +12 -7
- package/ThemeContext.d.ts +0 -15
- package/ThemeContext.js +0 -243
- package/V3Select/V3Select.js +0 -455
- package/V3Select/index.d.ts +0 -27
- package/V3Textarea/V3Textarea.js +0 -260
- package/V3Textarea/index.d.ts +0 -27
- package/common/RequiredComponent.js +0 -32
- package/date/Date.js +0 -373
- package/date/index.d.ts +0 -27
- package/input-text/Icons.js +0 -22
- package/input-text/InputText.js +0 -611
- package/input-text/index.d.ts +0 -36
- package/list/List.d.ts +0 -8
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/types.d.ts +0 -54
- package/row/Row.d.ts +0 -11
- package/row/Row.js +0 -127
- package/row/Row.stories.tsx +0 -239
- package/stack/Stack.d.ts +0 -10
- package/stack/Stack.js +0 -97
- package/stack/Stack.stories.tsx +0 -166
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
- package/toggle/Toggle.js +0 -186
- package/toggle/index.d.ts +0 -21
- package/upload/Upload.js +0 -201
- package/upload/buttons-upload/ButtonsUpload.js +0 -111
- package/upload/buttons-upload/Icons.js +0 -40
- package/upload/dragAndDropArea/DragAndDropArea.js +0 -225
- package/upload/dragAndDropArea/Icons.js +0 -39
- package/upload/file-upload/FileToUpload.js +0 -115
- package/upload/file-upload/Icons.js +0 -66
- package/upload/files-upload/FilesToUpload.js +0 -109
- package/upload/index.d.ts +0 -15
- package/upload/transaction/Icons.js +0 -160
- package/upload/transaction/Transaction.js +0 -104
- package/upload/transactions/Transactions.js +0 -94
- /package/{radio → badge}/types.js +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Title from "../../.storybook/components/Title";
|
|
3
|
+
import DxcParagraph from "./Paragraph";
|
|
4
|
+
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
5
|
+
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
6
|
+
import DarkContainer from "../../.storybook/components/DarkSection";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: "Paragraph",
|
|
10
|
+
component: DxcParagraph,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const Chromatic = () => (
|
|
14
|
+
<>
|
|
15
|
+
<ExampleContainer>
|
|
16
|
+
<Title title="Default Paragraph" level={4} />
|
|
17
|
+
<DxcParagraph>
|
|
18
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla id tortor sit amet velit auctor cursus id eget
|
|
19
|
+
nisl. Vivamus luctus egestas eros, at mattis libero eleifend ac. Integer vel urna rutrum, pretium arcu
|
|
20
|
+
dignissim, fringilla turpis. Nullam luctus odio quis magna finibus, a pharetra magna euismod. Nullam efficitur
|
|
21
|
+
semper pellentesque. Nulla eget arcu ac diam fringilla vehicula. In imperdiet nisl hendrerit, elementum metus
|
|
22
|
+
eu, ornare risus. Aenean neque nibh, vestibulum vitae elit vel, imperdiet suscipit leo. Curabitur blandit
|
|
23
|
+
iaculis pretium. Fusce id imperdiet dui, ut laoreet justo. Sed maximus sollicitudin ipsum, et varius massa
|
|
24
|
+
condimentum eget. Vivamus id mauris et nisl mattis consequat et id lectus. Quisque mollis lacinia nisl.
|
|
25
|
+
Suspendisse sed quam tincidunt, commodo dolor vel, tincidunt nisl.
|
|
26
|
+
</DxcParagraph>
|
|
27
|
+
</ExampleContainer>
|
|
28
|
+
<BackgroundColorProvider color="#333333">
|
|
29
|
+
<DarkContainer>
|
|
30
|
+
<Title title="Default Paragraph" theme="dark" level={4} />
|
|
31
|
+
<DxcParagraph>
|
|
32
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla id tortor sit amet velit auctor cursus id eget
|
|
33
|
+
nisl. Vivamus luctus egestas eros, at mattis libero eleifend ac. Integer vel urna rutrum, pretium arcu
|
|
34
|
+
dignissim, fringilla turpis. Nullam luctus odio quis magna finibus, a pharetra magna euismod. Nullam efficitur
|
|
35
|
+
semper pellentesque. Nulla eget arcu ac diam fringilla vehicula. In imperdiet nisl hendrerit, elementum metus
|
|
36
|
+
eu, ornare risus. Aenean neque nibh, vestibulum vitae elit vel, imperdiet suscipit leo. Curabitur blandit
|
|
37
|
+
iaculis pretium. Fusce id imperdiet dui, ut laoreet justo. Sed maximus sollicitudin ipsum, et varius massa
|
|
38
|
+
condimentum eget. Vivamus id mauris et nisl mattis consequat et id lectus. Quisque mollis lacinia nisl.
|
|
39
|
+
Suspendisse sed quam tincidunt, commodo dolor vel, tincidunt nisl.
|
|
40
|
+
</DxcParagraph>
|
|
41
|
+
</DarkContainer>
|
|
42
|
+
</BackgroundColorProvider>
|
|
43
|
+
</>
|
|
44
|
+
);
|
|
@@ -1,112 +1,88 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = void 0;
|
|
11
|
-
|
|
12
9
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
-
|
|
14
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
18
12
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
19
|
-
|
|
20
13
|
var _TextInput = _interopRequireDefault(require("../text-input/TextInput"));
|
|
21
|
-
|
|
14
|
+
var _useTranslatedLabels = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
22
15
|
var _templateObject;
|
|
23
|
-
|
|
24
16
|
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); }
|
|
25
|
-
|
|
26
17
|
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; }
|
|
27
|
-
|
|
28
18
|
var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
29
19
|
var label = _ref.label,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
20
|
+
_ref$name = _ref.name,
|
|
21
|
+
name = _ref$name === void 0 ? "" : _ref$name,
|
|
22
|
+
value = _ref.value,
|
|
23
|
+
helperText = _ref.helperText,
|
|
24
|
+
_ref$clearable = _ref.clearable,
|
|
25
|
+
clearable = _ref$clearable === void 0 ? false : _ref$clearable,
|
|
26
|
+
onChange = _ref.onChange,
|
|
27
|
+
onBlur = _ref.onBlur,
|
|
28
|
+
error = _ref.error,
|
|
29
|
+
pattern = _ref.pattern,
|
|
30
|
+
minLength = _ref.minLength,
|
|
31
|
+
maxLength = _ref.maxLength,
|
|
32
|
+
_ref$autocomplete = _ref.autocomplete,
|
|
33
|
+
autocomplete = _ref$autocomplete === void 0 ? "off" : _ref$autocomplete,
|
|
34
|
+
margin = _ref.margin,
|
|
35
|
+
_ref$size = _ref.size,
|
|
36
|
+
size = _ref$size === void 0 ? "medium" : _ref$size,
|
|
37
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
38
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
50
39
|
var _useState = (0, _react.useState)(false),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
41
|
+
isPasswordVisible = _useState2[0],
|
|
42
|
+
setIsPasswordVisible = _useState2[1];
|
|
55
43
|
var inputRef = (0, _react.useRef)(null);
|
|
56
|
-
|
|
44
|
+
var translatedLabels = (0, _useTranslatedLabels["default"])();
|
|
57
45
|
var setInputType = function setInputType(type) {
|
|
58
46
|
var _inputRef$current, _inputRef$current$chi;
|
|
59
|
-
|
|
60
47
|
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : (_inputRef$current$chi = _inputRef$current.children[label && helperText ? 2 : label || helperText ? 1 : 0]) === null || _inputRef$current$chi === void 0 ? void 0 : _inputRef$current$chi.children[0].setAttribute("type", type);
|
|
61
48
|
};
|
|
62
|
-
|
|
63
49
|
var setAriaAttributes = function setAriaAttributes(ariaExpanded, ariaLabel) {
|
|
64
50
|
var inputIndex = label && helperText ? 2 : label || helperText ? 1 : 0;
|
|
65
|
-
|
|
66
51
|
if (error && clearable && value) {
|
|
67
52
|
var _inputRef$current2, _inputRef$current2$ch, _inputRef$current2$ch2, _inputRef$current3, _inputRef$current3$ch, _inputRef$current3$ch2;
|
|
68
|
-
|
|
69
53
|
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : (_inputRef$current2$ch = _inputRef$current2.children[inputIndex]) === null || _inputRef$current2$ch === void 0 ? void 0 : (_inputRef$current2$ch2 = _inputRef$current2$ch.children[3]) === null || _inputRef$current2$ch2 === void 0 ? void 0 : _inputRef$current2$ch2.setAttribute("aria-expanded", ariaExpanded);
|
|
70
54
|
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : (_inputRef$current3$ch = _inputRef$current3.children[inputIndex]) === null || _inputRef$current3$ch === void 0 ? void 0 : (_inputRef$current3$ch2 = _inputRef$current3$ch.children[3]) === null || _inputRef$current3$ch2 === void 0 ? void 0 : _inputRef$current3$ch2.setAttribute("aria-label", ariaLabel);
|
|
71
55
|
} else if (error || clearable && !value) {
|
|
72
56
|
var _inputRef$current4, _inputRef$current4$ch, _inputRef$current4$ch2, _inputRef$current5, _inputRef$current5$ch, _inputRef$current5$ch2;
|
|
73
|
-
|
|
74
57
|
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : (_inputRef$current4$ch = _inputRef$current4.children[inputIndex]) === null || _inputRef$current4$ch === void 0 ? void 0 : (_inputRef$current4$ch2 = _inputRef$current4$ch.children[2]) === null || _inputRef$current4$ch2 === void 0 ? void 0 : _inputRef$current4$ch2.setAttribute("aria-expanded", ariaExpanded);
|
|
75
58
|
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current5 = inputRef.current) === null || _inputRef$current5 === void 0 ? void 0 : (_inputRef$current5$ch = _inputRef$current5.children[inputIndex]) === null || _inputRef$current5$ch === void 0 ? void 0 : (_inputRef$current5$ch2 = _inputRef$current5$ch.children[2]) === null || _inputRef$current5$ch2 === void 0 ? void 0 : _inputRef$current5$ch2.setAttribute("aria-label", ariaLabel);
|
|
76
59
|
} else {
|
|
77
60
|
var _inputRef$current6, _inputRef$current6$ch, _inputRef$current6$ch2, _inputRef$current7, _inputRef$current7$ch, _inputRef$current7$ch2;
|
|
78
|
-
|
|
79
61
|
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current6 = inputRef.current) === null || _inputRef$current6 === void 0 ? void 0 : (_inputRef$current6$ch = _inputRef$current6.children[inputIndex]) === null || _inputRef$current6$ch === void 0 ? void 0 : (_inputRef$current6$ch2 = _inputRef$current6$ch.children[1]) === null || _inputRef$current6$ch2 === void 0 ? void 0 : _inputRef$current6$ch2.setAttribute("aria-expanded", ariaExpanded);
|
|
80
62
|
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current7 = inputRef.current) === null || _inputRef$current7 === void 0 ? void 0 : (_inputRef$current7$ch = _inputRef$current7.children[inputIndex]) === null || _inputRef$current7$ch === void 0 ? void 0 : (_inputRef$current7$ch2 = _inputRef$current7$ch.children[1]) === null || _inputRef$current7$ch2 === void 0 ? void 0 : _inputRef$current7$ch2.setAttribute("aria-label", ariaLabel);
|
|
81
63
|
}
|
|
82
64
|
};
|
|
83
|
-
|
|
84
65
|
var getIconTitle = function getIconTitle() {
|
|
85
|
-
return isPasswordVisible ?
|
|
66
|
+
return isPasswordVisible ? translatedLabels.passwordInput.inputHidePasswordTitle : translatedLabels.passwordInput.inputShowPasswordTitle;
|
|
86
67
|
};
|
|
87
|
-
|
|
88
68
|
(0, _react.useEffect)(function () {
|
|
89
|
-
setAriaAttributes(false,
|
|
90
|
-
|
|
69
|
+
setAriaAttributes(false, translatedLabels.passwordInput.inputShowPasswordTitle);
|
|
91
70
|
if (isPasswordVisible) {
|
|
92
71
|
setInputType("text");
|
|
93
|
-
setAriaAttributes(true,
|
|
72
|
+
setAriaAttributes(true, translatedLabels.passwordInput.inputHidePasswordTitle);
|
|
94
73
|
} else {
|
|
95
74
|
setInputType("password");
|
|
96
|
-
setAriaAttributes(false,
|
|
75
|
+
setAriaAttributes(false, translatedLabels.passwordInput.inputShowPasswordTitle);
|
|
97
76
|
}
|
|
98
77
|
}, [isPasswordVisible]);
|
|
99
|
-
|
|
100
78
|
var viewPassword = function viewPassword() {
|
|
101
79
|
setInputType("text");
|
|
102
80
|
setIsPasswordVisible(true);
|
|
103
81
|
};
|
|
104
|
-
|
|
105
82
|
var hidePassword = function hidePassword() {
|
|
106
83
|
setInputType("password");
|
|
107
84
|
setIsPasswordVisible(false);
|
|
108
85
|
};
|
|
109
|
-
|
|
110
86
|
var action = {
|
|
111
87
|
onClick: isPasswordVisible ? hidePassword : viewPassword,
|
|
112
88
|
icon: isPasswordVisible ? /*#__PURE__*/_react["default"].createElement("svg", {
|
|
@@ -156,8 +132,6 @@ var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
156
132
|
tabIndex: tabIndex
|
|
157
133
|
}));
|
|
158
134
|
});
|
|
159
|
-
|
|
160
135
|
var PasswordInput = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n & ::-ms-reveal {\n display: none;\n }\n"])));
|
|
161
|
-
|
|
162
136
|
var _default = DxcPasswordInput;
|
|
163
137
|
exports["default"] = _default;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
5
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
6
|
+
var _react = _interopRequireDefault(require("react"));
|
|
7
|
+
var _react2 = require("@testing-library/react");
|
|
8
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
9
|
+
var _PasswordInput = _interopRequireDefault(require("./PasswordInput"));
|
|
10
|
+
describe("Password input component tests", function () {
|
|
11
|
+
test("Password input renders with label", function () {
|
|
12
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
13
|
+
label: "Password input label"
|
|
14
|
+
})),
|
|
15
|
+
getByText = _render.getByText;
|
|
16
|
+
expect(getByText("Password input label")).toBeTruthy();
|
|
17
|
+
});
|
|
18
|
+
test("Password input renders with helper text", function () {
|
|
19
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
20
|
+
helperText: "Helper text"
|
|
21
|
+
})),
|
|
22
|
+
getByText = _render2.getByText;
|
|
23
|
+
expect(getByText("Helper text")).toBeTruthy();
|
|
24
|
+
});
|
|
25
|
+
test("Password input renders error", function () {
|
|
26
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
27
|
+
error: "Error message."
|
|
28
|
+
})),
|
|
29
|
+
getByText = _render3.getByText;
|
|
30
|
+
expect(getByText("Error message.")).toBeTruthy();
|
|
31
|
+
});
|
|
32
|
+
test("onChange function is called correctly", function () {
|
|
33
|
+
var onChange = jest.fn();
|
|
34
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
35
|
+
label: "Password input",
|
|
36
|
+
onChange: onChange
|
|
37
|
+
})),
|
|
38
|
+
getByLabelText = _render4.getByLabelText;
|
|
39
|
+
var passwordInput = getByLabelText("Password input");
|
|
40
|
+
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
41
|
+
expect(onChange).toHaveBeenCalledWith({
|
|
42
|
+
value: "P"
|
|
43
|
+
});
|
|
44
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
45
|
+
});
|
|
46
|
+
test("onBlur function is called correctly", function () {
|
|
47
|
+
var onBlur = jest.fn();
|
|
48
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
49
|
+
label: "Password input",
|
|
50
|
+
onBlur: onBlur
|
|
51
|
+
})),
|
|
52
|
+
getByLabelText = _render5.getByLabelText;
|
|
53
|
+
var passwordInput = getByLabelText("Password input");
|
|
54
|
+
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
55
|
+
_react2.fireEvent.blur(passwordInput);
|
|
56
|
+
expect(onBlur).toHaveBeenCalledWith({
|
|
57
|
+
value: "Pa$$w0rd"
|
|
58
|
+
});
|
|
59
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
60
|
+
});
|
|
61
|
+
test("Clear password input value", function () {
|
|
62
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
63
|
+
label: "Password input",
|
|
64
|
+
clearable: true
|
|
65
|
+
})),
|
|
66
|
+
getAllByRole = _render6.getAllByRole,
|
|
67
|
+
getByLabelText = _render6.getByLabelText;
|
|
68
|
+
var passwordInput = getByLabelText("Password input");
|
|
69
|
+
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
70
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
71
|
+
var clearButton = getAllByRole("button")[0];
|
|
72
|
+
_userEvent["default"].click(clearButton);
|
|
73
|
+
expect(passwordInput.value).toBe("");
|
|
74
|
+
});
|
|
75
|
+
test("Non clearable password input has no clear icon", function () {
|
|
76
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
77
|
+
label: "Password input"
|
|
78
|
+
})),
|
|
79
|
+
getAllByRole = _render7.getAllByRole,
|
|
80
|
+
getByLabelText = _render7.getByLabelText;
|
|
81
|
+
var passwordInput = getByLabelText("Password input");
|
|
82
|
+
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
83
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
84
|
+
var buttons = getAllByRole("button");
|
|
85
|
+
expect(buttons.length).toBe(1);
|
|
86
|
+
});
|
|
87
|
+
test("Show/hide password input button works correctly", function () {
|
|
88
|
+
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
89
|
+
label: "Password input",
|
|
90
|
+
clearable: true
|
|
91
|
+
})),
|
|
92
|
+
getAllByRole = _render8.getAllByRole,
|
|
93
|
+
getByLabelText = _render8.getByLabelText;
|
|
94
|
+
var passwordInput = getByLabelText("Password input");
|
|
95
|
+
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
96
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
97
|
+
expect(passwordInput.type).toBe("password");
|
|
98
|
+
var showButton = getAllByRole("button")[1];
|
|
99
|
+
_userEvent["default"].click(showButton);
|
|
100
|
+
expect(passwordInput.type).toBe("text");
|
|
101
|
+
});
|
|
102
|
+
test("Password tooltip is correct", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
103
|
+
var _render9, getAllByRole, getByTitle, queryByTitle, showButton;
|
|
104
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
105
|
+
while (1) switch (_context.prev = _context.next) {
|
|
106
|
+
case 0:
|
|
107
|
+
_render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
108
|
+
label: "Password input",
|
|
109
|
+
clearable: true,
|
|
110
|
+
value: "Password"
|
|
111
|
+
})), getAllByRole = _render9.getAllByRole, getByTitle = _render9.getByTitle, queryByTitle = _render9.queryByTitle;
|
|
112
|
+
showButton = getAllByRole("button")[1];
|
|
113
|
+
_userEvent["default"].hover(showButton);
|
|
114
|
+
expect(getByTitle("Show password")).toBeTruthy();
|
|
115
|
+
_userEvent["default"].unhover(showButton);
|
|
116
|
+
expect(queryByTitle("Hide password")).toBeFalsy();
|
|
117
|
+
case 6:
|
|
118
|
+
case "end":
|
|
119
|
+
return _context.stop();
|
|
120
|
+
}
|
|
121
|
+
}, _callee);
|
|
122
|
+
})));
|
|
123
|
+
test("Password input has correct accesibility attributes", function () {
|
|
124
|
+
var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
125
|
+
label: "Password input"
|
|
126
|
+
})),
|
|
127
|
+
getByRole = _render10.getByRole,
|
|
128
|
+
getByLabelText = _render10.getByLabelText;
|
|
129
|
+
var passwordInput = getByLabelText("Password input");
|
|
130
|
+
expect(passwordInput.getAttribute("aria-autocomplete")).toBeNull();
|
|
131
|
+
expect(passwordInput.getAttribute("aria-controls")).toBeNull();
|
|
132
|
+
expect(passwordInput.getAttribute("aria-expanded")).toBeNull();
|
|
133
|
+
var showButton = getByRole("button");
|
|
134
|
+
expect(showButton.getAttribute("aria-label")).toBe("Show password");
|
|
135
|
+
_userEvent["default"].click(showButton);
|
|
136
|
+
expect(showButton.getAttribute("aria-label")).toBe("Hide password");
|
|
137
|
+
});
|
|
138
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type Space = "xxsmall" | "xsmall" | "small" | "medium" | "large" | "xlarge" | "xxlarge";
|
|
2
|
+
type Margin = {
|
|
3
3
|
top?: Space;
|
|
4
4
|
bottom?: Space;
|
|
5
5
|
left?: Space;
|
|
6
6
|
right?: Space;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type Props = {
|
|
9
9
|
/**
|
|
10
10
|
* Text to be placed above the password.
|
|
11
11
|
*/
|
|
@@ -30,25 +30,28 @@ declare type Props = {
|
|
|
30
30
|
* This function will be called when the user types within the input
|
|
31
31
|
* element of the component. An object including the current value and
|
|
32
32
|
* the error (if the value entered is not valid) will be passed to this
|
|
33
|
-
* function. If there is no error, error will be
|
|
33
|
+
* function. If there is no error, error will not be defined.
|
|
34
34
|
* */
|
|
35
35
|
onChange?: (val: {
|
|
36
36
|
value: string;
|
|
37
|
-
error
|
|
37
|
+
error?: string;
|
|
38
38
|
}) => void;
|
|
39
39
|
/**
|
|
40
40
|
* This function will be called when the input element loses the focus.
|
|
41
41
|
* An object including the input value and the error (if the value entered is
|
|
42
|
-
* not valid) will be passed to this function. If there is no error, error will be
|
|
42
|
+
* not valid) will be passed to this function. If there is no error, error will not be defined.
|
|
43
43
|
*/
|
|
44
44
|
onBlur?: (val: {
|
|
45
45
|
value: string;
|
|
46
|
-
error
|
|
46
|
+
error?: string;
|
|
47
47
|
}) => void;
|
|
48
48
|
/**
|
|
49
|
-
* If it is defined
|
|
50
|
-
* the error below the password input
|
|
51
|
-
*
|
|
49
|
+
* If it is a defined value and also a truthy string, the component will
|
|
50
|
+
* change its appearance, showing the error below the password input
|
|
51
|
+
* component. If the defined value is an empty string, it will reserve a
|
|
52
|
+
* space below the component for a future error, but it would not change
|
|
53
|
+
* its look. In case of being undefined or null, both the appearance and
|
|
54
|
+
* the space for the error message would not be modified.
|
|
52
55
|
*/
|
|
53
56
|
error?: string;
|
|
54
57
|
/**
|
|
@@ -58,7 +61,7 @@ declare type Props = {
|
|
|
58
61
|
* the pattern, the onBlur and onChange functions will be called with the
|
|
59
62
|
* current value and an internal error informing that this value does not
|
|
60
63
|
* match the pattern. If the pattern is met, the error parameter of both
|
|
61
|
-
* events will be
|
|
64
|
+
* events will not be defined.
|
|
62
65
|
*/
|
|
63
66
|
pattern?: string;
|
|
64
67
|
/**
|
|
@@ -68,7 +71,7 @@ declare type Props = {
|
|
|
68
71
|
* comply the minimum length, the onBlur and onChange functions will be called
|
|
69
72
|
* with the current value and an internal error informing that the value
|
|
70
73
|
* length does not comply the specified range. If a valid length is
|
|
71
|
-
* reached, the error parameter of both events will be
|
|
74
|
+
* reached, the error parameter of both events will not be defined.
|
|
72
75
|
*/
|
|
73
76
|
minLength?: number;
|
|
74
77
|
/**
|
|
@@ -78,7 +81,7 @@ declare type Props = {
|
|
|
78
81
|
* comply the maximum length, the onBlur and onChange functions will be called
|
|
79
82
|
* with the current value and an internal error informing that the value
|
|
80
83
|
* length does not comply the specified range. If a valid length is
|
|
81
|
-
* reached, the error parameter of both events will be
|
|
84
|
+
* reached, the error parameter of both events will not be defined.
|
|
82
85
|
*/
|
|
83
86
|
maxLength?: number;
|
|
84
87
|
/**
|
|
@@ -92,7 +95,7 @@ declare type Props = {
|
|
|
92
95
|
*/
|
|
93
96
|
margin?: Space | Margin;
|
|
94
97
|
/**
|
|
95
|
-
* Size of the component
|
|
98
|
+
* Size of the component.
|
|
96
99
|
*/
|
|
97
100
|
size?: "small" | "medium" | "large" | "fillParent";
|
|
98
101
|
/**
|
|
@@ -103,5 +106,5 @@ declare type Props = {
|
|
|
103
106
|
/**
|
|
104
107
|
* Reference to the component.
|
|
105
108
|
*/
|
|
106
|
-
export
|
|
109
|
+
export type RefType = HTMLDivElement;
|
|
107
110
|
export default Props;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import
|
|
3
|
-
declare const DxcProgressBar: ({ label, helperText, overlay, value, showValue, margin, }:
|
|
2
|
+
import { Props } from "./types";
|
|
3
|
+
declare const DxcProgressBar: ({ label, helperText, overlay, value, showValue, margin, }: Props) => JSX.Element;
|
|
4
4
|
export default DxcProgressBar;
|