@dxc-technology/halstack-react 10.1.0 → 11.0.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/BackgroundColorContext.d.ts +2 -2
- package/BackgroundColorContext.js +5 -17
- package/HalstackContext.d.ts +18 -6
- package/HalstackContext.js +9 -34
- package/accordion/Accordion.js +21 -58
- package/accordion/Accordion.stories.tsx +1 -15
- package/accordion/Accordion.test.js +18 -33
- package/accordion/types.d.ts +5 -5
- package/accordion-group/AccordionGroup.js +15 -42
- package/accordion-group/AccordionGroup.stories.tsx +1 -1
- package/accordion-group/AccordionGroup.test.js +42 -60
- package/accordion-group/AccordionGroupAccordion.js +9 -21
- package/accordion-group/types.d.ts +6 -6
- package/alert/Alert.js +14 -46
- package/alert/Alert.test.js +28 -45
- package/alert/types.d.ts +5 -5
- package/badge/Badge.js +4 -17
- package/badge/types.d.ts +1 -1
- package/bleed/Bleed.js +13 -21
- package/bleed/types.d.ts +2 -2
- package/box/Box.js +10 -29
- package/box/Box.test.js +1 -6
- package/box/types.d.ts +3 -3
- package/bulleted-list/BulletedList.js +7 -33
- package/bulleted-list/BulletedList.stories.tsx +1 -91
- package/bulleted-list/types.d.ts +5 -5
- package/button/Button.js +23 -46
- package/button/Button.stories.tsx +5 -86
- package/button/Button.test.js +11 -21
- package/button/types.d.ts +4 -4
- package/card/Card.js +21 -44
- package/card/Card.test.js +10 -21
- package/card/types.d.ts +5 -5
- package/checkbox/Checkbox.js +81 -111
- package/checkbox/Checkbox.stories.tsx +16 -54
- package/checkbox/Checkbox.test.js +107 -63
- package/checkbox/types.d.ts +8 -4
- package/chip/Chip.js +12 -31
- package/chip/Chip.test.js +15 -28
- package/chip/types.d.ts +4 -4
- package/common/coreTokens.js +1 -2
- package/common/utils.js +2 -8
- package/common/variables.d.ts +15 -6
- package/common/variables.js +17 -15
- package/date-input/Calendar.js +13 -57
- package/date-input/DateInput.js +50 -96
- package/date-input/DateInput.stories.tsx +11 -30
- package/date-input/DateInput.test.js +674 -701
- package/date-input/DatePicker.js +11 -42
- package/date-input/Icons.d.ts +6 -6
- package/date-input/Icons.js +6 -23
- package/date-input/YearPicker.js +8 -34
- package/date-input/types.d.ts +27 -21
- package/dialog/Dialog.js +11 -35
- package/dialog/Dialog.test.js +125 -187
- package/dialog/types.d.ts +18 -13
- package/dropdown/Dropdown.js +39 -93
- package/dropdown/Dropdown.test.js +391 -378
- package/dropdown/DropdownMenu.js +8 -19
- package/dropdown/DropdownMenuItem.js +5 -17
- package/dropdown/types.d.ts +17 -19
- package/file-input/FileInput.js +131 -220
- package/file-input/FileInput.stories.tsx +1 -1
- package/file-input/FileInput.test.js +293 -342
- package/file-input/FileItem.js +12 -39
- package/file-input/types.d.ts +9 -9
- package/flex/Flex.js +25 -39
- package/flex/types.d.ts +6 -6
- package/footer/Footer.js +9 -39
- package/footer/Footer.test.js +18 -32
- package/footer/Icons.d.ts +2 -2
- package/footer/Icons.js +2 -7
- package/footer/types.d.ts +13 -13
- package/grid/Grid.js +1 -16
- package/grid/types.d.ts +10 -10
- package/header/Header.d.ts +1 -1
- package/header/Header.js +19 -64
- package/header/Header.test.js +12 -25
- package/header/Icons.d.ts +2 -2
- package/header/Icons.js +2 -7
- package/header/types.d.ts +5 -7
- package/heading/Heading.js +9 -31
- package/heading/Heading.test.js +70 -87
- package/heading/types.d.ts +7 -7
- package/image/Image.d.ts +2 -2
- package/image/Image.js +17 -32
- package/image/types.d.ts +2 -2
- package/inset/Inset.js +13 -21
- package/inset/types.d.ts +2 -2
- package/layout/ApplicationLayout.d.ts +1 -1
- package/layout/ApplicationLayout.js +14 -54
- package/layout/Icons.d.ts +5 -5
- package/layout/Icons.js +1 -5
- package/layout/SidenavContext.d.ts +1 -1
- package/layout/SidenavContext.js +3 -9
- package/layout/types.d.ts +3 -3
- package/link/Link.js +21 -42
- package/link/Link.test.js +23 -41
- package/link/types.d.ts +14 -14
- package/main.d.ts +1 -1
- package/main.js +3 -52
- package/nav-tabs/NavTabs.js +11 -43
- package/nav-tabs/NavTabs.stories.tsx +1 -1
- package/nav-tabs/NavTabs.test.js +36 -43
- package/nav-tabs/Tab.js +16 -45
- package/nav-tabs/types.d.ts +9 -9
- package/number-input/NumberInput.d.ts +1 -1
- package/number-input/NumberInput.js +24 -35
- package/number-input/NumberInput.stories.tsx +42 -26
- package/number-input/NumberInput.test.js +682 -577
- package/number-input/types.d.ts +11 -5
- package/package.json +27 -25
- package/paginator/Icons.d.ts +5 -5
- package/paginator/Icons.js +5 -19
- package/paginator/Paginator.js +14 -39
- package/paginator/Paginator.test.js +224 -207
- package/paginator/types.d.ts +3 -3
- package/paragraph/Paragraph.js +3 -14
- package/paragraph/Paragraph.stories.tsx +0 -17
- package/password-input/Icons.d.ts +3 -3
- package/password-input/Icons.js +1 -5
- package/password-input/PasswordInput.js +26 -48
- package/password-input/PasswordInput.stories.tsx +1 -33
- package/password-input/PasswordInput.test.js +153 -129
- package/password-input/types.d.ts +8 -7
- package/progress-bar/ProgressBar.js +16 -42
- package/progress-bar/{ProgressBar.stories.jsx → ProgressBar.stories.tsx} +1 -1
- package/progress-bar/ProgressBar.test.js +35 -52
- package/progress-bar/types.d.ts +3 -3
- package/quick-nav/QuickNav.js +4 -27
- package/quick-nav/QuickNav.stories.tsx +1 -1
- package/quick-nav/types.d.ts +10 -10
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +22 -54
- package/radio-group/RadioGroup.js +37 -83
- package/radio-group/RadioGroup.stories.tsx +10 -10
- package/radio-group/RadioGroup.test.js +504 -470
- package/radio-group/types.d.ts +8 -8
- package/resultset-table/Icons.d.ts +7 -0
- package/{resultsetTable → resultset-table}/Icons.js +1 -5
- package/{resultsetTable → resultset-table}/ResultsetTable.js +22 -58
- package/{resultsetTable → resultset-table}/ResultsetTable.test.js +72 -92
- package/{resultsetTable → resultset-table}/types.d.ts +7 -7
- package/select/Icons.d.ts +7 -7
- package/select/Icons.js +1 -5
- package/select/Listbox.js +13 -39
- package/select/Option.js +9 -26
- package/select/Select.js +54 -138
- package/select/Select.test.js +1902 -1796
- package/select/types.d.ts +14 -15
- package/sidenav/Icons.d.ts +4 -4
- package/sidenav/Icons.js +1 -5
- package/sidenav/Sidenav.js +24 -63
- package/sidenav/Sidenav.test.js +3 -10
- package/sidenav/types.d.ts +18 -18
- package/slider/Slider.js +38 -86
- package/slider/Slider.test.js +107 -103
- package/slider/types.d.ts +4 -4
- package/spinner/Spinner.js +10 -40
- package/spinner/Spinner.test.js +25 -34
- package/spinner/types.d.ts +3 -3
- package/switch/Switch.js +26 -69
- package/switch/Switch.stories.tsx +0 -34
- package/switch/Switch.test.js +51 -96
- package/switch/types.d.ts +4 -4
- package/table/Table.js +4 -23
- package/table/Table.test.js +1 -6
- package/table/types.d.ts +8 -8
- package/tabs/Tab.js +10 -29
- package/tabs/Tabs.js +48 -124
- package/tabs/Tabs.test.js +62 -118
- package/tabs/types.d.ts +19 -19
- package/tag/Tag.js +21 -51
- package/tag/Tag.test.js +19 -30
- package/tag/types.d.ts +7 -7
- package/text-input/Icons.d.ts +5 -5
- package/text-input/Icons.js +1 -5
- package/text-input/Suggestion.js +9 -26
- package/text-input/Suggestions.d.ts +1 -1
- package/text-input/Suggestions.js +12 -57
- package/text-input/TextInput.js +128 -193
- package/text-input/TextInput.stories.tsx +48 -152
- package/text-input/TextInput.test.js +1210 -1194
- package/text-input/types.d.ts +25 -17
- package/textarea/Textarea.js +60 -96
- package/textarea/{Textarea.stories.jsx → Textarea.stories.tsx} +58 -99
- package/textarea/Textarea.test.js +150 -179
- package/textarea/types.d.ts +9 -5
- package/toggle-group/ToggleGroup.js +20 -57
- package/toggle-group/ToggleGroup.stories.tsx +1 -1
- package/toggle-group/ToggleGroup.test.js +48 -81
- package/toggle-group/types.d.ts +10 -10
- package/typography/Typography.js +4 -13
- package/typography/types.d.ts +1 -1
- package/useTheme.d.ts +12 -3
- package/useTheme.js +1 -8
- package/useTranslatedLabels.js +1 -7
- package/utils/BaseTypography.d.ts +2 -2
- package/utils/BaseTypography.js +16 -30
- package/utils/FocusLock.js +12 -36
- package/wizard/Wizard.js +14 -49
- package/wizard/Wizard.test.js +53 -80
- package/wizard/types.d.ts +6 -6
- package/resultsetTable/Icons.d.ts +0 -7
- package/slider/Slider.stories.tsx +0 -240
- /package/{resultsetTable → resultset-table}/ResultsetTable.d.ts +0 -0
- /package/{resultsetTable → resultset-table}/ResultsetTable.stories.tsx +0 -0
- /package/{resultsetTable → resultset-table}/types.js +0 -0
- /package/spinner/{Spinner.stories.jsx → Spinner.stories.tsx} +0 -0
- /package/table/{Table.stories.jsx → Table.stories.tsx} +0 -0
|
@@ -1,76 +1,57 @@
|
|
|
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
|
-
|
|
22
14
|
var _useTranslatedLabels2 = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
23
|
-
|
|
24
15
|
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
25
|
-
|
|
26
16
|
var _templateObject;
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
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; }
|
|
31
|
-
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
32
19
|
var setInputType = function setInputType(type, element) {
|
|
33
20
|
element === null || element === void 0 ? void 0 : element.getElementsByTagName("input")[0].setAttribute("type", type);
|
|
34
21
|
};
|
|
35
|
-
|
|
36
22
|
var setAriaAttributes = function setAriaAttributes(ariaExpanded, ariaLabel, element) {
|
|
37
23
|
var inputElement = element === null || element === void 0 ? void 0 : element.getElementsByTagName("input")[0];
|
|
38
24
|
inputElement === null || inputElement === void 0 ? void 0 : inputElement.setAttribute("aria-expanded", ariaExpanded);
|
|
39
25
|
inputElement === null || inputElement === void 0 ? void 0 : inputElement.setAttribute("aria-label", ariaLabel);
|
|
40
26
|
};
|
|
41
|
-
|
|
42
27
|
var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
43
28
|
var label = _ref.label,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
29
|
+
_ref$name = _ref.name,
|
|
30
|
+
name = _ref$name === void 0 ? "" : _ref$name,
|
|
31
|
+
value = _ref.value,
|
|
32
|
+
helperText = _ref.helperText,
|
|
33
|
+
_ref$clearable = _ref.clearable,
|
|
34
|
+
clearable = _ref$clearable === void 0 ? false : _ref$clearable,
|
|
35
|
+
onChange = _ref.onChange,
|
|
36
|
+
onBlur = _ref.onBlur,
|
|
37
|
+
error = _ref.error,
|
|
38
|
+
pattern = _ref.pattern,
|
|
39
|
+
minLength = _ref.minLength,
|
|
40
|
+
maxLength = _ref.maxLength,
|
|
41
|
+
_ref$autocomplete = _ref.autocomplete,
|
|
42
|
+
autocomplete = _ref$autocomplete === void 0 ? "off" : _ref$autocomplete,
|
|
43
|
+
margin = _ref.margin,
|
|
44
|
+
_ref$size = _ref.size,
|
|
45
|
+
size = _ref$size === void 0 ? "medium" : _ref$size,
|
|
46
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
47
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
64
48
|
var _useState = (0, _react.useState)(false),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
49
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
50
|
+
isPasswordVisible = _useState2[0],
|
|
51
|
+
setIsPasswordVisible = _useState2[1];
|
|
69
52
|
var inputRef = (0, _react.useRef)(null);
|
|
70
|
-
|
|
71
53
|
var _useTranslatedLabels = (0, _useTranslatedLabels2["default"])(),
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
passwordInput = _useTranslatedLabels.passwordInput;
|
|
74
55
|
(0, _react.useEffect)(function () {
|
|
75
56
|
(function () {
|
|
76
57
|
if (isPasswordVisible) {
|
|
@@ -112,8 +93,5 @@ var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
112
93
|
tabIndex: tabIndex
|
|
113
94
|
}));
|
|
114
95
|
});
|
|
115
|
-
|
|
116
96
|
var PasswordInput = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n & ::-ms-reveal {\n display: none;\n }\n"])));
|
|
117
|
-
|
|
118
|
-
var _default = DxcPasswordInput;
|
|
119
|
-
exports["default"] = _default;
|
|
97
|
+
var _default = exports["default"] = DxcPasswordInput;
|
|
@@ -4,10 +4,9 @@ import DxcPasswordInput from "./PasswordInput";
|
|
|
4
4
|
import { BackgroundColorProvider } from "../BackgroundColorContext";
|
|
5
5
|
import Title from "../../.storybook/components/Title";
|
|
6
6
|
import ExampleContainer from "../../.storybook/components/ExampleContainer";
|
|
7
|
-
import DarkContainer from "../../.storybook/components/DarkSection";
|
|
8
7
|
|
|
9
8
|
export default {
|
|
10
|
-
title: "Password
|
|
9
|
+
title: "Password Input",
|
|
11
10
|
component: DxcPasswordInput,
|
|
12
11
|
};
|
|
13
12
|
|
|
@@ -37,19 +36,6 @@ export const Chromatic = () => (
|
|
|
37
36
|
<Title title="Invalid" theme="light" level={4} />
|
|
38
37
|
<DxcPasswordInput label="Error password input" error="Error message." />
|
|
39
38
|
</ExampleContainer>
|
|
40
|
-
<BackgroundColorProvider color="#333333">
|
|
41
|
-
<DarkContainer>
|
|
42
|
-
<Title title="Dark" theme="dark" level={2} />
|
|
43
|
-
<ExampleContainer>
|
|
44
|
-
<Title title="With label, helper text and value" theme="dark" level={4} />
|
|
45
|
-
<DxcPasswordInput label="Password input" helperText="Help message" value="Password" />
|
|
46
|
-
</ExampleContainer>
|
|
47
|
-
<ExampleContainer>
|
|
48
|
-
<Title title="With label, helper text, value and error" theme="dark" level={4} />
|
|
49
|
-
<DxcPasswordInput label="Password input" helperText="Help message" error="Error message." value="Password" />
|
|
50
|
-
</ExampleContainer>
|
|
51
|
-
</DarkContainer>
|
|
52
|
-
</BackgroundColorProvider>
|
|
53
39
|
<Title title="Margins" theme="light" level={2} />
|
|
54
40
|
<ExampleContainer>
|
|
55
41
|
<Title title="Xxsmall margin" theme="light" level={4} />
|
|
@@ -106,27 +92,9 @@ const Password = () => (
|
|
|
106
92
|
</ExampleContainer>
|
|
107
93
|
);
|
|
108
94
|
|
|
109
|
-
const PasswordDark = () => (
|
|
110
|
-
<BackgroundColorProvider color="#333333">
|
|
111
|
-
<DarkContainer>
|
|
112
|
-
<ExampleContainer expanded>
|
|
113
|
-
<Title title="Show password" theme="dark" level={4} />
|
|
114
|
-
<DxcPasswordInput label="Password input" value="Password" />
|
|
115
|
-
</ExampleContainer>
|
|
116
|
-
</DarkContainer>
|
|
117
|
-
</BackgroundColorProvider>
|
|
118
|
-
);
|
|
119
|
-
|
|
120
95
|
export const ShowPassword = Password.bind({});
|
|
121
96
|
ShowPassword.play = async ({ canvasElement }) => {
|
|
122
97
|
const canvas = within(canvasElement);
|
|
123
98
|
const passwordBtn = canvas.getByRole("button");
|
|
124
99
|
await userEvent.click(passwordBtn);
|
|
125
100
|
};
|
|
126
|
-
|
|
127
|
-
export const ShowPasswordDark = PasswordDark.bind({});
|
|
128
|
-
ShowPasswordDark.play = async ({ canvasElement }) => {
|
|
129
|
-
const canvas = within(canvasElement);
|
|
130
|
-
const passwordBtn = canvas.getByRole("button");
|
|
131
|
-
await userEvent.click(passwordBtn);
|
|
132
|
-
};
|
|
@@ -1,51 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
-
|
|
7
5
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
-
|
|
6
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
7
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
9
8
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
|
|
11
9
|
var _react2 = require("@testing-library/react");
|
|
12
|
-
|
|
13
10
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
14
|
-
|
|
15
11
|
var _PasswordInput = _interopRequireDefault(require("./PasswordInput.tsx"));
|
|
16
|
-
|
|
12
|
+
// Mocking DOMRect for Radix Primitive Popover
|
|
13
|
+
global.globalThis = global;
|
|
14
|
+
global.DOMRect = {
|
|
15
|
+
fromRect: function fromRect() {
|
|
16
|
+
return {
|
|
17
|
+
top: 0,
|
|
18
|
+
left: 0,
|
|
19
|
+
bottom: 0,
|
|
20
|
+
right: 0,
|
|
21
|
+
width: 0,
|
|
22
|
+
height: 0
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
global.ResizeObserver = /*#__PURE__*/function () {
|
|
27
|
+
function ResizeObserver() {
|
|
28
|
+
(0, _classCallCheck2["default"])(this, ResizeObserver);
|
|
29
|
+
}
|
|
30
|
+
(0, _createClass2["default"])(ResizeObserver, [{
|
|
31
|
+
key: "observe",
|
|
32
|
+
value: function observe() {}
|
|
33
|
+
}, {
|
|
34
|
+
key: "unobserve",
|
|
35
|
+
value: function unobserve() {}
|
|
36
|
+
}, {
|
|
37
|
+
key: "disconnect",
|
|
38
|
+
value: function disconnect() {}
|
|
39
|
+
}]);
|
|
40
|
+
return ResizeObserver;
|
|
41
|
+
}();
|
|
17
42
|
describe("Password input component tests", function () {
|
|
18
43
|
test("Password input renders with label and helper text", function () {
|
|
19
44
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
45
|
+
label: "Password input label",
|
|
46
|
+
helperText: "Helper text"
|
|
47
|
+
})),
|
|
48
|
+
getByText = _render.getByText;
|
|
25
49
|
expect(getByText("Password input label")).toBeTruthy();
|
|
26
50
|
expect(getByText("Helper text")).toBeTruthy();
|
|
27
51
|
});
|
|
28
52
|
test("Password input renders error", function () {
|
|
29
53
|
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
54
|
+
error: "Error message."
|
|
55
|
+
})),
|
|
56
|
+
getByText = _render2.getByText;
|
|
34
57
|
expect(getByText("Error message.")).toBeTruthy();
|
|
35
58
|
});
|
|
36
59
|
test("onChange function is called correctly", function () {
|
|
37
60
|
var onChange = jest.fn();
|
|
38
|
-
|
|
39
61
|
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
62
|
+
label: "Password input",
|
|
63
|
+
onChange: onChange
|
|
64
|
+
})),
|
|
65
|
+
getByLabelText = _render3.getByLabelText;
|
|
45
66
|
var passwordInput = getByLabelText("Password input");
|
|
46
|
-
|
|
47
67
|
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
48
|
-
|
|
49
68
|
expect(onChange).toHaveBeenCalledWith({
|
|
50
69
|
value: "P"
|
|
51
70
|
});
|
|
@@ -53,122 +72,127 @@ describe("Password input component tests", function () {
|
|
|
53
72
|
});
|
|
54
73
|
test("onBlur function is called correctly", function () {
|
|
55
74
|
var onBlur = jest.fn();
|
|
56
|
-
|
|
57
75
|
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
76
|
+
label: "Password input",
|
|
77
|
+
onBlur: onBlur
|
|
78
|
+
})),
|
|
79
|
+
getByLabelText = _render4.getByLabelText;
|
|
63
80
|
var passwordInput = getByLabelText("Password input");
|
|
64
|
-
|
|
65
81
|
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
66
|
-
|
|
67
82
|
_react2.fireEvent.blur(passwordInput);
|
|
68
|
-
|
|
69
83
|
expect(onBlur).toHaveBeenCalledWith({
|
|
70
84
|
value: "Pa$$w0rd"
|
|
71
85
|
});
|
|
72
86
|
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
73
87
|
});
|
|
74
|
-
test("Clear password input value", function () {
|
|
75
|
-
var _render5
|
|
76
|
-
label: "Password input",
|
|
77
|
-
clearable: true
|
|
78
|
-
})),
|
|
79
|
-
getAllByRole = _render5.getAllByRole,
|
|
80
|
-
getByLabelText = _render5.getByLabelText;
|
|
81
|
-
|
|
82
|
-
var passwordInput = getByLabelText("Password input");
|
|
83
|
-
|
|
84
|
-
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
85
|
-
|
|
86
|
-
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
87
|
-
var clearButton = getAllByRole("button")[0];
|
|
88
|
-
|
|
89
|
-
_userEvent["default"].click(clearButton);
|
|
90
|
-
|
|
91
|
-
expect(passwordInput.value).toBe("");
|
|
92
|
-
});
|
|
93
|
-
test("Non clearable password input has no clear icon", function () {
|
|
94
|
-
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
95
|
-
label: "Password input"
|
|
96
|
-
})),
|
|
97
|
-
getAllByRole = _render6.getAllByRole,
|
|
98
|
-
getByLabelText = _render6.getByLabelText;
|
|
99
|
-
|
|
100
|
-
var passwordInput = getByLabelText("Password input");
|
|
101
|
-
|
|
102
|
-
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
103
|
-
|
|
104
|
-
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
105
|
-
var buttons = getAllByRole("button");
|
|
106
|
-
expect(buttons.length).toBe(1);
|
|
107
|
-
});
|
|
108
|
-
test("Show/hide password input button works correctly", function () {
|
|
109
|
-
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
110
|
-
label: "Password input",
|
|
111
|
-
clearable: true
|
|
112
|
-
})),
|
|
113
|
-
getAllByRole = _render7.getAllByRole,
|
|
114
|
-
getByLabelText = _render7.getByLabelText;
|
|
115
|
-
|
|
116
|
-
var passwordInput = getByLabelText("Password input");
|
|
117
|
-
|
|
118
|
-
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
119
|
-
|
|
120
|
-
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
121
|
-
expect(passwordInput.type).toBe("password");
|
|
122
|
-
var showButton = getAllByRole("button")[1];
|
|
123
|
-
|
|
124
|
-
_userEvent["default"].click(showButton);
|
|
125
|
-
|
|
126
|
-
expect(passwordInput.type).toBe("text");
|
|
127
|
-
});
|
|
128
|
-
test("Password tooltip is correct", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
129
|
-
var _render8, getAllByRole, getByTitle, queryByTitle, showButton;
|
|
130
|
-
|
|
88
|
+
test("Clear password input value", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
89
|
+
var _render5, getAllByRole, getByLabelText, passwordInput, clearButton;
|
|
131
90
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
132
|
-
while (1) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
case 6:
|
|
151
|
-
case "end":
|
|
152
|
-
return _context.stop();
|
|
153
|
-
}
|
|
91
|
+
while (1) switch (_context.prev = _context.next) {
|
|
92
|
+
case 0:
|
|
93
|
+
_render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
94
|
+
label: "Password input",
|
|
95
|
+
clearable: true
|
|
96
|
+
})), getAllByRole = _render5.getAllByRole, getByLabelText = _render5.getByLabelText;
|
|
97
|
+
passwordInput = getByLabelText("Password input");
|
|
98
|
+
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
99
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
100
|
+
clearButton = getAllByRole("button")[0];
|
|
101
|
+
_context.next = 7;
|
|
102
|
+
return _userEvent["default"].click(clearButton);
|
|
103
|
+
case 7:
|
|
104
|
+
expect(passwordInput.value).toBe("");
|
|
105
|
+
case 8:
|
|
106
|
+
case "end":
|
|
107
|
+
return _context.stop();
|
|
154
108
|
}
|
|
155
109
|
}, _callee);
|
|
156
110
|
})));
|
|
157
|
-
test("
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
111
|
+
test("Non clearable password input has no clear icon", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
112
|
+
var _render6, getAllByRole, getByLabelText, passwordInput, buttons;
|
|
113
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
114
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
115
|
+
case 0:
|
|
116
|
+
_render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
117
|
+
label: "Password input"
|
|
118
|
+
})), getAllByRole = _render6.getAllByRole, getByLabelText = _render6.getByLabelText;
|
|
119
|
+
passwordInput = getByLabelText("Password input");
|
|
120
|
+
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
121
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
122
|
+
buttons = getAllByRole("button");
|
|
123
|
+
expect(buttons.length).toBe(1);
|
|
124
|
+
case 6:
|
|
125
|
+
case "end":
|
|
126
|
+
return _context2.stop();
|
|
127
|
+
}
|
|
128
|
+
}, _callee2);
|
|
129
|
+
})));
|
|
130
|
+
test("Show/hide password input button works correctly", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
131
|
+
var _render7, getAllByRole, getByLabelText, passwordInput, showButton;
|
|
132
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
133
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
134
|
+
case 0:
|
|
135
|
+
_render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
136
|
+
label: "Password input",
|
|
137
|
+
clearable: true
|
|
138
|
+
})), getAllByRole = _render7.getAllByRole, getByLabelText = _render7.getByLabelText;
|
|
139
|
+
passwordInput = getByLabelText("Password input");
|
|
140
|
+
_userEvent["default"].type(passwordInput, "Pa$$w0rd");
|
|
141
|
+
expect(passwordInput.value).toBe("Pa$$w0rd");
|
|
142
|
+
expect(passwordInput.type).toBe("password");
|
|
143
|
+
showButton = getAllByRole("button")[1];
|
|
144
|
+
_context3.next = 8;
|
|
145
|
+
return _userEvent["default"].click(showButton);
|
|
146
|
+
case 8:
|
|
147
|
+
expect(passwordInput.type).toBe("text");
|
|
148
|
+
case 9:
|
|
149
|
+
case "end":
|
|
150
|
+
return _context3.stop();
|
|
151
|
+
}
|
|
152
|
+
}, _callee3);
|
|
153
|
+
})));
|
|
154
|
+
test("Password tooltip is correct", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
155
|
+
var _render8, getAllByRole, getByTitle, queryByTitle, showButton;
|
|
156
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
157
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
158
|
+
case 0:
|
|
159
|
+
_render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
160
|
+
label: "Password input",
|
|
161
|
+
clearable: true,
|
|
162
|
+
value: "Password"
|
|
163
|
+
})), getAllByRole = _render8.getAllByRole, getByTitle = _render8.getByTitle, queryByTitle = _render8.queryByTitle;
|
|
164
|
+
showButton = getAllByRole("button")[1];
|
|
165
|
+
_userEvent["default"].hover(showButton);
|
|
166
|
+
expect(getByTitle("Show password")).toBeTruthy();
|
|
167
|
+
_userEvent["default"].unhover(showButton);
|
|
168
|
+
expect(queryByTitle("Hide password")).toBeFalsy();
|
|
169
|
+
case 6:
|
|
170
|
+
case "end":
|
|
171
|
+
return _context4.stop();
|
|
172
|
+
}
|
|
173
|
+
}, _callee4);
|
|
174
|
+
})));
|
|
175
|
+
test("Password input has correct accessibility attributes", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
|
|
176
|
+
var _render9, getByRole, getByLabelText, passwordInput, showButton;
|
|
177
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
178
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
179
|
+
case 0:
|
|
180
|
+
_render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_PasswordInput["default"], {
|
|
181
|
+
label: "Password input"
|
|
182
|
+
})), getByRole = _render9.getByRole, getByLabelText = _render9.getByLabelText;
|
|
183
|
+
passwordInput = getByLabelText("Password input");
|
|
184
|
+
showButton = getByRole("button");
|
|
185
|
+
expect(passwordInput.getAttribute("aria-expanded")).toBe("false");
|
|
186
|
+
expect(showButton.getAttribute("aria-label")).toBe("Show password");
|
|
187
|
+
_context5.next = 7;
|
|
188
|
+
return _userEvent["default"].click(showButton);
|
|
189
|
+
case 7:
|
|
190
|
+
expect(passwordInput.getAttribute("aria-expanded")).toBe("true");
|
|
191
|
+
expect(showButton.getAttribute("aria-label")).toBe("Hide password");
|
|
192
|
+
case 9:
|
|
193
|
+
case "end":
|
|
194
|
+
return _context5.stop();
|
|
195
|
+
}
|
|
196
|
+
}, _callee5);
|
|
197
|
+
})));
|
|
174
198
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
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
|
-
* Text to be placed above the password.
|
|
10
|
+
* Text to be placed above the password input.
|
|
11
11
|
*/
|
|
12
12
|
label?: string;
|
|
13
13
|
/**
|
|
@@ -39,7 +39,8 @@ declare type Props = {
|
|
|
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
|
|
42
|
+
* not valid) will be passed to this function. If there is no error, error will
|
|
43
|
+
* not be defined.
|
|
43
44
|
*/
|
|
44
45
|
onBlur?: (val: {
|
|
45
46
|
value: string;
|
|
@@ -65,7 +66,7 @@ declare type Props = {
|
|
|
65
66
|
*/
|
|
66
67
|
pattern?: string;
|
|
67
68
|
/**
|
|
68
|
-
* Specifies the
|
|
69
|
+
* Specifies the minimum length allowed by the password input.
|
|
69
70
|
* This will be checked both when the input element loses the
|
|
70
71
|
* focus and while typing within it. If the string entered does not
|
|
71
72
|
* comply the minimum length, the onBlur and onChange functions will be called
|
|
@@ -106,5 +107,5 @@ declare type Props = {
|
|
|
106
107
|
/**
|
|
107
108
|
* Reference to the component.
|
|
108
109
|
*/
|
|
109
|
-
export
|
|
110
|
+
export type RefType = HTMLDivElement;
|
|
110
111
|
export default Props;
|