@dxc-technology/halstack-react 0.0.0-2b773b3 → 0.0.0-2bca710
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 -1
- package/HalstackContext.d.ts +1348 -0
- package/HalstackContext.js +335 -0
- package/README.md +47 -0
- package/accordion/Accordion.d.ts +1 -1
- package/accordion/Accordion.js +108 -134
- package/accordion/Accordion.stories.tsx +108 -118
- package/accordion/Accordion.test.js +10 -11
- package/accordion/types.d.ts +1 -12
- package/accordion-group/AccordionGroup.d.ts +4 -3
- package/accordion-group/AccordionGroup.js +25 -65
- package/accordion-group/AccordionGroup.stories.tsx +93 -66
- package/accordion-group/AccordionGroup.test.js +27 -62
- package/accordion-group/AccordionGroupAccordion.d.ts +4 -0
- package/accordion-group/AccordionGroupAccordion.js +43 -0
- package/accordion-group/types.d.ts +7 -12
- package/alert/Alert.js +9 -10
- package/alert/Alert.stories.tsx +28 -0
- package/alert/Alert.test.js +1 -1
- package/badge/Badge.d.ts +1 -1
- package/badge/Badge.js +5 -3
- package/badge/types.d.ts +1 -0
- package/bleed/Bleed.js +1 -34
- package/bleed/Bleed.stories.tsx +95 -95
- package/bleed/types.d.ts +1 -1
- package/box/Box.d.ts +1 -1
- package/box/Box.js +19 -48
- package/box/Box.stories.tsx +38 -51
- package/box/Box.test.js +1 -1
- package/box/types.d.ts +0 -11
- package/bulleted-list/BulletedList.d.ts +7 -0
- package/bulleted-list/BulletedList.js +125 -0
- package/bulleted-list/BulletedList.stories.tsx +206 -0
- package/bulleted-list/types.d.ts +38 -0
- package/button/Button.d.ts +1 -1
- package/button/Button.js +44 -71
- package/button/Button.stories.tsx +159 -8
- package/button/Button.test.js +12 -1
- package/button/types.d.ts +9 -5
- package/card/Card.d.ts +1 -1
- package/card/Card.js +37 -58
- package/card/Card.stories.tsx +12 -42
- package/card/Card.test.js +1 -1
- package/card/types.d.ts +1 -6
- package/checkbox/Checkbox.d.ts +2 -2
- package/checkbox/Checkbox.js +104 -101
- package/checkbox/Checkbox.stories.tsx +198 -130
- package/checkbox/Checkbox.test.js +94 -17
- package/checkbox/types.d.ts +7 -3
- package/chip/Chip.js +28 -49
- package/chip/Chip.stories.tsx +121 -26
- package/chip/Chip.test.js +3 -5
- package/chip/types.d.ts +1 -1
- package/common/OpenSans.css +68 -80
- package/common/coreTokens.d.ts +146 -0
- package/common/coreTokens.js +167 -0
- package/common/utils.d.ts +1 -0
- package/common/utils.js +4 -4
- package/common/variables.d.ts +1494 -0
- package/common/variables.js +1111 -1111
- package/date-input/Calendar.d.ts +4 -0
- package/date-input/Calendar.js +258 -0
- package/date-input/DateInput.js +140 -238
- package/date-input/DateInput.stories.tsx +209 -33
- package/date-input/DateInput.test.js +519 -149
- package/date-input/DatePicker.d.ts +4 -0
- package/date-input/DatePicker.js +146 -0
- package/date-input/Icons.d.ts +6 -0
- package/date-input/Icons.js +75 -0
- package/date-input/YearPicker.d.ts +4 -0
- package/date-input/YearPicker.js +126 -0
- package/date-input/types.d.ts +55 -0
- package/dialog/Dialog.d.ts +1 -1
- package/dialog/Dialog.js +68 -103
- package/dialog/Dialog.stories.tsx +154 -171
- package/dialog/Dialog.test.js +334 -5
- package/dialog/types.d.ts +0 -12
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +246 -253
- package/dropdown/Dropdown.stories.tsx +245 -56
- package/dropdown/Dropdown.test.js +507 -110
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +74 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +79 -0
- package/dropdown/types.d.ts +23 -3
- package/file-input/FileInput.d.ts +2 -2
- package/file-input/FileInput.js +180 -223
- package/file-input/FileInput.stories.tsx +122 -11
- package/file-input/FileInput.test.js +14 -14
- package/file-input/FileItem.d.ts +4 -14
- package/file-input/FileItem.js +44 -66
- package/file-input/types.d.ts +18 -1
- package/flex/Flex.d.ts +4 -0
- package/flex/Flex.js +71 -0
- package/flex/Flex.stories.tsx +112 -0
- package/flex/types.d.ts +97 -0
- package/footer/Footer.d.ts +1 -1
- package/footer/Footer.js +49 -142
- package/footer/Footer.stories.tsx +41 -19
- package/footer/Footer.test.js +16 -26
- package/footer/Icons.js +1 -1
- package/footer/types.d.ts +11 -12
- package/grid/Grid.d.ts +7 -0
- package/grid/Grid.js +91 -0
- package/grid/Grid.stories.tsx +219 -0
- package/grid/types.d.ts +115 -0
- package/header/Header.d.ts +4 -3
- package/header/Header.js +102 -150
- package/header/Header.stories.tsx +152 -63
- package/header/Header.test.js +20 -4
- package/header/Icons.js +2 -2
- package/header/types.d.ts +0 -13
- package/heading/Heading.js +1 -1
- package/heading/Heading.test.js +1 -1
- 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.js +1 -34
- package/inset/Inset.stories.tsx +37 -36
- package/inset/types.d.ts +1 -1
- package/layout/ApplicationLayout.d.ts +16 -6
- package/layout/ApplicationLayout.js +81 -138
- package/layout/ApplicationLayout.stories.tsx +85 -94
- package/layout/Icons.d.ts +8 -0
- package/layout/Icons.js +52 -45
- package/layout/SidenavContext.d.ts +5 -0
- package/layout/SidenavContext.js +19 -0
- package/layout/types.d.ts +19 -35
- package/link/Link.d.ts +3 -2
- package/link/Link.js +60 -77
- package/link/Link.stories.tsx +155 -53
- package/link/Link.test.js +9 -19
- package/link/types.d.ts +5 -21
- package/main.d.ts +9 -10
- package/main.js +55 -57
- package/nav-tabs/NavTabs.d.ts +8 -0
- package/nav-tabs/NavTabs.js +122 -0
- package/nav-tabs/NavTabs.stories.tsx +274 -0
- package/nav-tabs/NavTabs.test.js +82 -0
- package/nav-tabs/Tab.d.ts +4 -0
- package/nav-tabs/Tab.js +146 -0
- package/nav-tabs/types.d.ts +52 -0
- package/number-input/NumberInput.d.ts +7 -0
- package/number-input/NumberInput.js +6 -4
- package/number-input/NumberInput.test.js +319 -102
- package/number-input/types.d.ts +13 -10
- package/package.json +19 -23
- package/paginator/Icons.d.ts +5 -0
- package/paginator/Icons.js +16 -28
- package/paginator/Paginator.js +20 -49
- package/paginator/Paginator.stories.tsx +24 -0
- package/paginator/Paginator.test.js +91 -39
- package/paragraph/Paragraph.d.ts +5 -0
- package/paragraph/Paragraph.js +38 -0
- package/paragraph/Paragraph.stories.tsx +44 -0
- package/password-input/Icons.d.ts +6 -0
- package/password-input/Icons.js +39 -0
- package/password-input/PasswordInput.js +36 -80
- package/password-input/PasswordInput.stories.tsx +1 -0
- package/password-input/PasswordInput.test.js +36 -45
- package/password-input/types.d.ts +14 -11
- package/progress-bar/ProgressBar.js +61 -55
- package/progress-bar/ProgressBar.stories.jsx +47 -12
- package/progress-bar/ProgressBar.test.js +68 -23
- package/quick-nav/QuickNav.js +77 -26
- package/quick-nav/QuickNav.stories.tsx +145 -26
- package/quick-nav/types.d.ts +4 -4
- package/radio-group/Radio.d.ts +1 -1
- package/radio-group/Radio.js +46 -31
- package/radio-group/RadioGroup.js +37 -36
- package/radio-group/RadioGroup.stories.tsx +132 -18
- package/radio-group/RadioGroup.test.js +124 -97
- package/radio-group/types.d.ts +2 -2
- package/resultsetTable/Icons.d.ts +7 -0
- package/resultsetTable/Icons.js +51 -0
- package/resultsetTable/ResultsetTable.js +49 -108
- package/resultsetTable/ResultsetTable.stories.tsx +50 -25
- package/resultsetTable/ResultsetTable.test.js +61 -42
- package/resultsetTable/types.d.ts +1 -1
- package/select/Listbox.d.ts +4 -0
- package/select/Listbox.js +169 -0
- package/select/Option.js +11 -24
- package/select/Select.js +148 -214
- package/select/Select.stories.tsx +525 -136
- package/select/Select.test.js +478 -307
- package/select/types.d.ts +20 -4
- package/sidenav/Icons.d.ts +7 -0
- package/sidenav/Icons.js +51 -0
- package/sidenav/Sidenav.d.ts +6 -5
- package/sidenav/Sidenav.js +146 -44
- package/sidenav/Sidenav.stories.tsx +251 -151
- package/sidenav/Sidenav.test.js +25 -37
- package/sidenav/types.d.ts +52 -26
- package/slider/Slider.d.ts +2 -2
- package/slider/Slider.js +121 -97
- package/slider/Slider.stories.tsx +64 -1
- package/slider/Slider.test.js +122 -22
- package/slider/types.d.ts +4 -0
- package/spinner/Spinner.js +18 -24
- package/spinner/Spinner.stories.jsx +53 -27
- package/spinner/Spinner.test.js +1 -1
- package/switch/Switch.d.ts +2 -2
- package/switch/Switch.js +138 -68
- package/switch/Switch.stories.tsx +49 -38
- package/switch/Switch.test.js +145 -18
- package/switch/types.d.ts +6 -2
- package/table/Table.js +3 -3
- package/table/Table.stories.jsx +80 -1
- package/table/Table.test.js +2 -2
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +132 -0
- package/tabs/Tabs.js +358 -108
- package/tabs/Tabs.stories.tsx +119 -11
- package/tabs/Tabs.test.js +220 -10
- package/tabs/types.d.ts +13 -3
- package/tag/Tag.js +12 -17
- package/tag/Tag.stories.tsx +14 -1
- package/tag/Tag.test.js +1 -1
- package/tag/types.d.ts +1 -1
- package/text-input/Icons.d.ts +8 -0
- package/text-input/Icons.js +60 -0
- package/text-input/Suggestion.d.ts +4 -0
- package/text-input/Suggestion.js +84 -0
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +134 -0
- package/text-input/TextInput.js +260 -399
- package/text-input/TextInput.stories.tsx +319 -185
- package/text-input/TextInput.test.js +846 -759
- package/text-input/types.d.ts +50 -12
- package/textarea/Textarea.js +37 -45
- package/textarea/Textarea.stories.jsx +68 -1
- package/textarea/Textarea.test.js +61 -19
- package/textarea/types.d.ts +14 -7
- package/toggle-group/ToggleGroup.d.ts +2 -2
- package/toggle-group/ToggleGroup.js +85 -59
- package/toggle-group/ToggleGroup.stories.tsx +48 -3
- package/toggle-group/ToggleGroup.test.js +38 -24
- package/toggle-group/types.d.ts +23 -14
- package/typography/Typography.d.ts +4 -0
- package/typography/Typography.js +32 -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 +1246 -1
- package/useTheme.js +3 -3
- package/useTranslatedLabels.d.ts +85 -0
- package/useTranslatedLabels.js +20 -0
- package/utils/BaseTypography.d.ts +21 -0
- package/utils/BaseTypography.js +108 -0
- package/utils/FocusLock.d.ts +13 -0
- package/utils/FocusLock.js +138 -0
- package/wizard/Wizard.js +44 -45
- package/wizard/Wizard.stories.tsx +40 -1
- package/wizard/Wizard.test.js +1 -1
- package/wizard/types.d.ts +3 -3
- package/ThemeContext.d.ts +0 -10
- package/ThemeContext.js +0 -243
- package/card/ice-cream.jpg +0 -0
- package/common/RequiredComponent.js +0 -32
- package/list/List.d.ts +0 -4
- package/list/List.js +0 -47
- package/list/List.stories.tsx +0 -95
- package/list/types.d.ts +0 -7
- package/number-input/NumberInputContext.d.ts +0 -4
- package/number-input/NumberInputContext.js +0 -19
- package/number-input/numberInputContextTypes.d.ts +0 -19
- package/radio/Radio.d.ts +0 -4
- package/radio/Radio.js +0 -174
- package/radio/Radio.stories.tsx +0 -192
- package/radio/Radio.test.js +0 -71
- package/radio/types.d.ts +0 -54
- package/row/Row.d.ts +0 -3
- package/row/Row.js +0 -127
- package/row/Row.stories.tsx +0 -237
- package/row/types.d.ts +0 -28
- package/stack/Stack.d.ts +0 -3
- package/stack/Stack.js +0 -97
- package/stack/Stack.stories.tsx +0 -164
- package/stack/types.d.ts +0 -24
- package/text/Text.d.ts +0 -7
- package/text/Text.js +0 -30
- package/text/Text.stories.tsx +0 -19
- /package/{list → bulleted-list}/types.js +0 -0
- /package/{radio → flex}/types.js +0 -0
- /package/{row → grid}/types.js +0 -0
- /package/{stack → image}/types.js +0 -0
- /package/{number-input/numberInputContextTypes.js → nav-tabs/types.js} +0 -0
|
@@ -2,14 +2,63 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
6
|
+
|
|
7
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
8
|
+
|
|
5
9
|
var _react = _interopRequireDefault(require("react"));
|
|
6
10
|
|
|
7
11
|
var _react2 = require("@testing-library/react");
|
|
8
12
|
|
|
9
13
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
10
14
|
|
|
11
|
-
var _Paginator = _interopRequireDefault(require("./Paginator"));
|
|
12
|
-
|
|
15
|
+
var _Paginator = _interopRequireDefault(require("./Paginator.tsx"));
|
|
16
|
+
|
|
17
|
+
// Mocking DOMRect for Radix Primitive Popover
|
|
18
|
+
global.globalThis = global;
|
|
19
|
+
global.DOMRect = {
|
|
20
|
+
fromRect: function fromRect() {
|
|
21
|
+
return {
|
|
22
|
+
top: 0,
|
|
23
|
+
left: 0,
|
|
24
|
+
bottom: 0,
|
|
25
|
+
right: 0,
|
|
26
|
+
width: 0,
|
|
27
|
+
height: 0
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
global.ResizeObserver = /*#__PURE__*/function () {
|
|
33
|
+
function ResizeObserver() {
|
|
34
|
+
(0, _classCallCheck2["default"])(this, ResizeObserver);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
(0, _createClass2["default"])(ResizeObserver, [{
|
|
38
|
+
key: "observe",
|
|
39
|
+
value: function observe() {}
|
|
40
|
+
}, {
|
|
41
|
+
key: "unobserve",
|
|
42
|
+
value: function unobserve() {}
|
|
43
|
+
}, {
|
|
44
|
+
key: "disconnect",
|
|
45
|
+
value: function disconnect() {}
|
|
46
|
+
}]);
|
|
47
|
+
return ResizeObserver;
|
|
48
|
+
}();
|
|
49
|
+
|
|
50
|
+
global.DOMRect = {
|
|
51
|
+
fromRect: function fromRect() {
|
|
52
|
+
return {
|
|
53
|
+
top: 0,
|
|
54
|
+
left: 0,
|
|
55
|
+
bottom: 0,
|
|
56
|
+
right: 0,
|
|
57
|
+
width: 0,
|
|
58
|
+
height: 0
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
13
62
|
describe("Paginator component tests", function () {
|
|
14
63
|
test("Paginator renders with default values", function () {
|
|
15
64
|
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], null)),
|
|
@@ -35,47 +84,38 @@ describe("Paginator component tests", function () {
|
|
|
35
84
|
})),
|
|
36
85
|
getByText = _render3.getByText;
|
|
37
86
|
|
|
38
|
-
expect(getByText("Items per page")).toBeTruthy();
|
|
39
|
-
});
|
|
40
|
-
test("Paginator renders with itemsPerPageOptions", function () {
|
|
41
|
-
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
42
|
-
currentPage: 1,
|
|
43
|
-
itemsPerPage: 10,
|
|
44
|
-
totalItems: 20
|
|
45
|
-
})),
|
|
46
|
-
getByText = _render4.getByText;
|
|
47
|
-
|
|
87
|
+
expect(getByText("Items per page:")).toBeTruthy();
|
|
48
88
|
expect(getByText("1 to 10 of 20")).toBeTruthy();
|
|
49
89
|
expect(getByText("Page: 1 of 2")).toBeTruthy();
|
|
50
90
|
});
|
|
51
91
|
test("Paginator renders with totalItems", function () {
|
|
52
|
-
var
|
|
92
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
53
93
|
totalItems: 20
|
|
54
94
|
})),
|
|
55
|
-
getByText =
|
|
95
|
+
getByText = _render4.getByText;
|
|
56
96
|
|
|
57
97
|
expect(getByText("1 to 5 of 20")).toBeTruthy();
|
|
58
98
|
expect(getByText("Page: 1 of 4")).toBeTruthy();
|
|
59
99
|
});
|
|
60
100
|
test("Paginator renders with correct text in second page", function () {
|
|
61
|
-
var
|
|
101
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
62
102
|
currentPage: 2,
|
|
63
103
|
itemsPerPage: 10,
|
|
64
104
|
totalItems: 20
|
|
65
105
|
})),
|
|
66
|
-
getByText =
|
|
106
|
+
getByText = _render5.getByText;
|
|
67
107
|
|
|
68
108
|
expect(getByText("11 to 20 of 20")).toBeTruthy();
|
|
69
109
|
expect(getByText("Page: 2 of 2")).toBeTruthy();
|
|
70
110
|
});
|
|
71
111
|
test("Paginator renders goToPage select", function () {
|
|
72
|
-
var
|
|
112
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
73
113
|
currentPage: 2,
|
|
74
114
|
showGoToPage: true,
|
|
75
115
|
itemsPerPage: 10,
|
|
76
116
|
totalItems: 20
|
|
77
117
|
})),
|
|
78
|
-
getByText =
|
|
118
|
+
getByText = _render6.getByText;
|
|
79
119
|
|
|
80
120
|
expect(getByText("Go to page:")).toBeTruthy();
|
|
81
121
|
});
|
|
@@ -86,16 +126,15 @@ describe("Paginator component tests", function () {
|
|
|
86
126
|
|
|
87
127
|
window.HTMLElement.prototype.scrollTo = function () {};
|
|
88
128
|
|
|
89
|
-
var
|
|
129
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
90
130
|
currentPage: 1,
|
|
91
131
|
itemsPerPage: 10,
|
|
92
132
|
totalItems: 27,
|
|
93
133
|
showGoToPage: true,
|
|
94
134
|
onPageChange: onClick
|
|
95
135
|
})),
|
|
96
|
-
getByText =
|
|
97
|
-
getAllByRole =
|
|
98
|
-
getByRole = _render8.getByRole;
|
|
136
|
+
getByText = _render7.getByText,
|
|
137
|
+
getAllByRole = _render7.getAllByRole;
|
|
99
138
|
|
|
100
139
|
var goToPageSelect = getAllByRole("combobox")[0];
|
|
101
140
|
(0, _react2.act)(function () {
|
|
@@ -110,13 +149,13 @@ describe("Paginator component tests", function () {
|
|
|
110
149
|
test("Call correct goToPageFunction", function () {
|
|
111
150
|
var onClick = jest.fn();
|
|
112
151
|
|
|
113
|
-
var
|
|
152
|
+
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
114
153
|
onPageChange: onClick,
|
|
115
154
|
currentPage: 1,
|
|
116
155
|
itemsPerPage: 10,
|
|
117
156
|
totalItems: 20
|
|
118
157
|
})),
|
|
119
|
-
getAllByRole =
|
|
158
|
+
getAllByRole = _render8.getAllByRole;
|
|
120
159
|
|
|
121
160
|
var nextButton = getAllByRole("button")[2];
|
|
122
161
|
|
|
@@ -131,15 +170,15 @@ describe("Paginator component tests", function () {
|
|
|
131
170
|
|
|
132
171
|
window.HTMLElement.prototype.scrollTo = function () {};
|
|
133
172
|
|
|
134
|
-
var
|
|
173
|
+
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
135
174
|
currentPage: 1,
|
|
136
175
|
itemsPerPage: 10,
|
|
137
176
|
itemsPerPageOptions: [10, 15],
|
|
138
177
|
itemsPerPageFunction: onClick,
|
|
139
178
|
totalItems: 20
|
|
140
179
|
})),
|
|
141
|
-
getAllByText =
|
|
142
|
-
getByText =
|
|
180
|
+
getAllByText = _render9.getAllByText,
|
|
181
|
+
getByText = _render9.getByText;
|
|
143
182
|
|
|
144
183
|
var select = getAllByText("10")[0];
|
|
145
184
|
(0, _react2.act)(function () {
|
|
@@ -154,13 +193,13 @@ describe("Paginator component tests", function () {
|
|
|
154
193
|
test("Next button is disable in last page", function () {
|
|
155
194
|
var onClick = jest.fn();
|
|
156
195
|
|
|
157
|
-
var
|
|
196
|
+
var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
158
197
|
onPageChange: onClick,
|
|
159
198
|
currentPage: 2,
|
|
160
199
|
itemsPerPage: 10,
|
|
161
200
|
totalItems: 20
|
|
162
201
|
})),
|
|
163
|
-
getAllByRole =
|
|
202
|
+
getAllByRole = _render10.getAllByRole;
|
|
164
203
|
|
|
165
204
|
var nextButton = getAllByRole("button")[2];
|
|
166
205
|
expect(nextButton.hasAttribute("disabled")).toBeTruthy();
|
|
@@ -172,13 +211,13 @@ describe("Paginator component tests", function () {
|
|
|
172
211
|
test("Last button is disable in last page", function () {
|
|
173
212
|
var onClick = jest.fn();
|
|
174
213
|
|
|
175
|
-
var
|
|
214
|
+
var _render11 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
176
215
|
onPageChange: onClick,
|
|
177
216
|
currentPage: 2,
|
|
178
217
|
itemsPerPage: 10,
|
|
179
218
|
totalItems: 20
|
|
180
219
|
})),
|
|
181
|
-
getAllByRole =
|
|
220
|
+
getAllByRole = _render11.getAllByRole;
|
|
182
221
|
|
|
183
222
|
var lastButton = getAllByRole("button")[3];
|
|
184
223
|
expect(lastButton.hasAttribute("disabled")).toBeTruthy();
|
|
@@ -190,13 +229,13 @@ describe("Paginator component tests", function () {
|
|
|
190
229
|
test("First button is disable in first page", function () {
|
|
191
230
|
var onClick = jest.fn();
|
|
192
231
|
|
|
193
|
-
var
|
|
232
|
+
var _render12 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
194
233
|
onPageChange: onClick,
|
|
195
234
|
currentPage: 1,
|
|
196
235
|
itemsPerPage: 10,
|
|
197
236
|
totalItems: 20
|
|
198
237
|
})),
|
|
199
|
-
getAllByRole =
|
|
238
|
+
getAllByRole = _render12.getAllByRole;
|
|
200
239
|
|
|
201
240
|
var lastButton = getAllByRole("button")[0];
|
|
202
241
|
expect(lastButton.hasAttribute("disabled")).toBeTruthy();
|
|
@@ -208,13 +247,13 @@ describe("Paginator component tests", function () {
|
|
|
208
247
|
test("Previous button is disable in first page", function () {
|
|
209
248
|
var onClick = jest.fn();
|
|
210
249
|
|
|
211
|
-
var
|
|
250
|
+
var _render13 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
212
251
|
onPageChange: onClick,
|
|
213
252
|
currentPage: 1,
|
|
214
253
|
itemsPerPage: 10,
|
|
215
254
|
totalItems: 20
|
|
216
255
|
})),
|
|
217
|
-
getAllByRole =
|
|
256
|
+
getAllByRole = _render13.getAllByRole;
|
|
218
257
|
|
|
219
258
|
var lastButton = getAllByRole("button")[1];
|
|
220
259
|
expect(lastButton.hasAttribute("disabled")).toBeTruthy();
|
|
@@ -226,13 +265,13 @@ describe("Paginator component tests", function () {
|
|
|
226
265
|
test("Last and next buttons are disable in last page", function () {
|
|
227
266
|
var onClick = jest.fn();
|
|
228
267
|
|
|
229
|
-
var
|
|
268
|
+
var _render14 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
230
269
|
onPageChange: onClick,
|
|
231
270
|
currentPage: 2,
|
|
232
271
|
itemsPerPage: 10,
|
|
233
272
|
totalItems: 20
|
|
234
273
|
})),
|
|
235
|
-
getAllByRole =
|
|
274
|
+
getAllByRole = _render14.getAllByRole;
|
|
236
275
|
|
|
237
276
|
var firstButton = getAllByRole("button")[0];
|
|
238
277
|
var prevButton = getAllByRole("button")[1];
|
|
@@ -246,13 +285,13 @@ describe("Paginator component tests", function () {
|
|
|
246
285
|
test("First and previous buttons are disable in first page", function () {
|
|
247
286
|
var onClick = jest.fn();
|
|
248
287
|
|
|
249
|
-
var
|
|
288
|
+
var _render15 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
250
289
|
onPageChange: onClick,
|
|
251
290
|
currentPage: 1,
|
|
252
291
|
itemsPerPage: 10,
|
|
253
292
|
totalItems: 20
|
|
254
293
|
})),
|
|
255
|
-
getAllByRole =
|
|
294
|
+
getAllByRole = _render15.getAllByRole;
|
|
256
295
|
|
|
257
296
|
var firstButton = getAllByRole("button")[0];
|
|
258
297
|
var prevButton = getAllByRole("button")[1];
|
|
@@ -263,4 +302,17 @@ describe("Paginator component tests", function () {
|
|
|
263
302
|
expect(nextButton.hasAttribute("disabled")).toBeFalsy();
|
|
264
303
|
expect(lastButton.hasAttribute("disabled")).toBeFalsy();
|
|
265
304
|
});
|
|
305
|
+
test("itemsPerPage is 0 and showGoToPage is true", function () {
|
|
306
|
+
var _render16 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Paginator["default"], {
|
|
307
|
+
itemsPerPage: 0,
|
|
308
|
+
itemsPerPageOptions: [5, 10, 15],
|
|
309
|
+
totalItems: 27,
|
|
310
|
+
showGoToPage: true
|
|
311
|
+
})),
|
|
312
|
+
getByText = _render16.getByText,
|
|
313
|
+
getAllByRole = _render16.getAllByRole;
|
|
314
|
+
|
|
315
|
+
expect(getByText("Items per page:")).toBeTruthy();
|
|
316
|
+
expect(getAllByRole("combobox")).toBeTruthy();
|
|
317
|
+
});
|
|
266
318
|
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = void 0;
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _BackgroundColorContext = _interopRequireDefault(require("../BackgroundColorContext"));
|
|
15
|
+
|
|
16
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
17
|
+
|
|
18
|
+
var _BaseTypography = _interopRequireDefault(require("../utils/BaseTypography"));
|
|
19
|
+
|
|
20
|
+
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); }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
var DxcParagraph = function DxcParagraph(_ref) {
|
|
25
|
+
var children = _ref.children;
|
|
26
|
+
var colorsTheme = (0, _useTheme["default"])();
|
|
27
|
+
var backgroundType = (0, _react.useContext)(_BackgroundColorContext["default"]);
|
|
28
|
+
return /*#__PURE__*/_react["default"].createElement(_BaseTypography["default"], {
|
|
29
|
+
as: "p",
|
|
30
|
+
display: colorsTheme.paragraph.display,
|
|
31
|
+
fontSize: colorsTheme.paragraph.fontSize,
|
|
32
|
+
fontWeight: colorsTheme.paragraph.fontWeight,
|
|
33
|
+
color: backgroundType && backgroundType === "dark" ? colorsTheme.paragraph.fontColorOnDark : colorsTheme.paragraph.fontColor
|
|
34
|
+
}, children);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
var _default = DxcParagraph;
|
|
38
|
+
exports["default"] = _default;
|
|
@@ -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
|
+
);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var icons = {
|
|
13
|
+
showPassword: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
14
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15
|
+
height: "24px",
|
|
16
|
+
viewBox: "0 0 24 24",
|
|
17
|
+
width: "24px",
|
|
18
|
+
fill: "currentColor"
|
|
19
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
20
|
+
d: "M0 0h24v24H0V0z",
|
|
21
|
+
fill: "none"
|
|
22
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
23
|
+
d: "M12 6c3.79 0 7.17 2.13 8.82 5.5C19.17 14.87 15.79 17 12 17s-7.17-2.13-8.82-5.5C4.83 8.13 8.21 6 12 6m0-2C7 4 2.73 7.11 1 11.5 2.73 15.89 7 19 12 19s9.27-3.11 11-7.5C21.27 7.11 17 4 12 4zm0 5c1.38 0 2.5 1.12 2.5 2.5S13.38 14 12 14s-2.5-1.12-2.5-2.5S10.62 9 12 9m0-2c-2.48 0-4.5 2.02-4.5 4.5S9.52 16 12 16s4.5-2.02 4.5-4.5S14.48 7 12 7z"
|
|
24
|
+
})),
|
|
25
|
+
hidePassword: /*#__PURE__*/_react["default"].createElement("svg", {
|
|
26
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
27
|
+
height: "24px",
|
|
28
|
+
viewBox: "0 0 24 24",
|
|
29
|
+
width: "24px",
|
|
30
|
+
fill: "currentColor"
|
|
31
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
32
|
+
d: "M0 0h24v24H0V0zm0 0h24v24H0V0zm0 0h24v24H0V0zm0 0h24v24H0V0z",
|
|
33
|
+
fill: "none"
|
|
34
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
35
|
+
d: "M12 6c3.79 0 7.17 2.13 8.82 5.5-.59 1.22-1.42 2.27-2.41 3.12l1.41 1.41c1.39-1.23 2.49-2.77 3.18-4.53C21.27 7.11 17 4 12 4c-1.27 0-2.49.2-3.64.57l1.65 1.65C10.66 6.09 11.32 6 12 6zm-1.07 1.14L13 9.21c.57.25 1.03.71 1.28 1.28l2.07 2.07c.08-.34.14-.7.14-1.07C16.5 9.01 14.48 7 12 7c-.37 0-.72.05-1.07.14zM2.01 3.87l2.68 2.68C3.06 7.83 1.77 9.53 1 11.5 2.73 15.89 7 19 12 19c1.52 0 2.98-.29 4.32-.82l3.42 3.42 1.41-1.41L3.42 2.45 2.01 3.87zm7.5 7.5l2.61 2.61c-.04.01-.08.02-.12.02-1.38 0-2.5-1.12-2.5-2.5 0-.05.01-.08.01-.13zm-3.4-3.4l1.75 1.75c-.23.55-.36 1.15-.36 1.78 0 2.48 2.02 4.5 4.5 4.5.63 0 1.23-.13 1.77-.36l.98.98c-.88.24-1.8.38-2.75.38-3.79 0-7.17-2.13-8.82-5.5.7-1.43 1.72-2.61 2.93-3.53z"
|
|
36
|
+
}))
|
|
37
|
+
};
|
|
38
|
+
var _default = icons;
|
|
39
|
+
exports["default"] = _default;
|
|
@@ -19,12 +19,26 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
19
19
|
|
|
20
20
|
var _TextInput = _interopRequireDefault(require("../text-input/TextInput"));
|
|
21
21
|
|
|
22
|
+
var _useTranslatedLabels2 = _interopRequireDefault(require("../useTranslatedLabels"));
|
|
23
|
+
|
|
24
|
+
var _Icons = _interopRequireDefault(require("./Icons"));
|
|
25
|
+
|
|
22
26
|
var _templateObject;
|
|
23
27
|
|
|
24
28
|
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
29
|
|
|
26
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; }
|
|
27
31
|
|
|
32
|
+
var setInputType = function setInputType(type, element) {
|
|
33
|
+
element === null || element === void 0 ? void 0 : element.getElementsByTagName("input")[0].setAttribute("type", type);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var setAriaAttributes = function setAriaAttributes(ariaExpanded, ariaLabel, element) {
|
|
37
|
+
var inputElement = element === null || element === void 0 ? void 0 : element.getElementsByTagName("input")[0];
|
|
38
|
+
inputElement === null || inputElement === void 0 ? void 0 : inputElement.setAttribute("aria-expanded", ariaExpanded);
|
|
39
|
+
inputElement === null || inputElement === void 0 ? void 0 : inputElement.setAttribute("aria-label", ariaLabel);
|
|
40
|
+
};
|
|
41
|
+
|
|
28
42
|
var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
29
43
|
var label = _ref.label,
|
|
30
44
|
_ref$name = _ref.name,
|
|
@@ -54,95 +68,36 @@ var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
54
68
|
|
|
55
69
|
var inputRef = (0, _react.useRef)(null);
|
|
56
70
|
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
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
|
-
};
|
|
62
|
-
|
|
63
|
-
var setAriaAttributes = function setAriaAttributes(ariaExpanded, ariaLabel) {
|
|
64
|
-
var inputIndex = label && helperText ? 2 : label || helperText ? 1 : 0;
|
|
65
|
-
|
|
66
|
-
if (error && clearable && value) {
|
|
67
|
-
var _inputRef$current2, _inputRef$current2$ch, _inputRef$current2$ch2, _inputRef$current3, _inputRef$current3$ch, _inputRef$current3$ch2;
|
|
68
|
-
|
|
69
|
-
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
|
-
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
|
-
} else if (error || clearable && !value) {
|
|
72
|
-
var _inputRef$current4, _inputRef$current4$ch, _inputRef$current4$ch2, _inputRef$current5, _inputRef$current5$ch, _inputRef$current5$ch2;
|
|
73
|
-
|
|
74
|
-
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
|
-
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
|
-
} else {
|
|
77
|
-
var _inputRef$current6, _inputRef$current6$ch, _inputRef$current6$ch2, _inputRef$current7, _inputRef$current7$ch, _inputRef$current7$ch2;
|
|
78
|
-
|
|
79
|
-
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
|
-
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
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
var getIconTitle = function getIconTitle() {
|
|
85
|
-
return isPasswordVisible ? "Hide password" : "Show password";
|
|
86
|
-
};
|
|
71
|
+
var _useTranslatedLabels = (0, _useTranslatedLabels2["default"])(),
|
|
72
|
+
passwordInput = _useTranslatedLabels.passwordInput;
|
|
87
73
|
|
|
88
74
|
(0, _react.useEffect)(function () {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
}, [isPasswordVisible]);
|
|
99
|
-
|
|
100
|
-
var viewPassword = function viewPassword() {
|
|
101
|
-
setInputType("text");
|
|
102
|
-
setIsPasswordVisible(true);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
var hidePassword = function hidePassword() {
|
|
106
|
-
setInputType("password");
|
|
107
|
-
setIsPasswordVisible(false);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
var action = {
|
|
111
|
-
onClick: isPasswordVisible ? hidePassword : viewPassword,
|
|
112
|
-
icon: isPasswordVisible ? /*#__PURE__*/_react["default"].createElement("svg", {
|
|
113
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
114
|
-
height: "24px",
|
|
115
|
-
viewBox: "0 0 24 24",
|
|
116
|
-
width: "24px",
|
|
117
|
-
fill: "currentColor"
|
|
118
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
119
|
-
d: "M0 0h24v24H0V0zm0 0h24v24H0V0zm0 0h24v24H0V0zm0 0h24v24H0V0z",
|
|
120
|
-
fill: "none"
|
|
121
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
122
|
-
d: "M12 6c3.79 0 7.17 2.13 8.82 5.5-.59 1.22-1.42 2.27-2.41 3.12l1.41 1.41c1.39-1.23 2.49-2.77 3.18-4.53C21.27 7.11 17 4 12 4c-1.27 0-2.49.2-3.64.57l1.65 1.65C10.66 6.09 11.32 6 12 6zm-1.07 1.14L13 9.21c.57.25 1.03.71 1.28 1.28l2.07 2.07c.08-.34.14-.7.14-1.07C16.5 9.01 14.48 7 12 7c-.37 0-.72.05-1.07.14zM2.01 3.87l2.68 2.68C3.06 7.83 1.77 9.53 1 11.5 2.73 15.89 7 19 12 19c1.52 0 2.98-.29 4.32-.82l3.42 3.42 1.41-1.41L3.42 2.45 2.01 3.87zm7.5 7.5l2.61 2.61c-.04.01-.08.02-.12.02-1.38 0-2.5-1.12-2.5-2.5 0-.05.01-.08.01-.13zm-3.4-3.4l1.75 1.75c-.23.55-.36 1.15-.36 1.78 0 2.48 2.02 4.5 4.5 4.5.63 0 1.23-.13 1.77-.36l.98.98c-.88.24-1.8.38-2.75.38-3.79 0-7.17-2.13-8.82-5.5.7-1.43 1.72-2.61 2.93-3.53z"
|
|
123
|
-
})) : /*#__PURE__*/_react["default"].createElement("svg", {
|
|
124
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
125
|
-
height: "24px",
|
|
126
|
-
viewBox: "0 0 24 24",
|
|
127
|
-
width: "24px",
|
|
128
|
-
fill: "currentColor"
|
|
129
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
130
|
-
d: "M0 0h24v24H0V0z",
|
|
131
|
-
fill: "none"
|
|
132
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
133
|
-
d: "M12 6c3.79 0 7.17 2.13 8.82 5.5C19.17 14.87 15.79 17 12 17s-7.17-2.13-8.82-5.5C4.83 8.13 8.21 6 12 6m0-2C7 4 2.73 7.11 1 11.5 2.73 15.89 7 19 12 19s9.27-3.11 11-7.5C21.27 7.11 17 4 12 4zm0 5c1.38 0 2.5 1.12 2.5 2.5S13.38 14 12 14s-2.5-1.12-2.5-2.5S10.62 9 12 9m0-2c-2.48 0-4.5 2.02-4.5 4.5S9.52 16 12 16s4.5-2.02 4.5-4.5S14.48 7 12 7z"
|
|
134
|
-
})),
|
|
135
|
-
title: getIconTitle()
|
|
136
|
-
};
|
|
75
|
+
(function () {
|
|
76
|
+
if (isPasswordVisible) {
|
|
77
|
+
setInputType("text", inputRef.current);
|
|
78
|
+
setAriaAttributes("true", passwordInput.inputHidePasswordTitle, inputRef.current);
|
|
79
|
+
} else {
|
|
80
|
+
setInputType("password", inputRef.current);
|
|
81
|
+
setAriaAttributes("false", passwordInput.inputShowPasswordTitle, inputRef.current);
|
|
82
|
+
}
|
|
83
|
+
})();
|
|
84
|
+
}, [isPasswordVisible, passwordInput]);
|
|
137
85
|
return /*#__PURE__*/_react["default"].createElement(PasswordInput, {
|
|
138
86
|
ref: ref
|
|
139
87
|
}, /*#__PURE__*/_react["default"].createElement(_TextInput["default"], {
|
|
140
|
-
ref: inputRef,
|
|
141
88
|
label: label,
|
|
142
89
|
name: name,
|
|
143
90
|
value: value,
|
|
144
91
|
helperText: helperText,
|
|
145
|
-
action:
|
|
92
|
+
action: {
|
|
93
|
+
onClick: function onClick() {
|
|
94
|
+
setIsPasswordVisible(function (isPasswordVisible) {
|
|
95
|
+
return !isPasswordVisible;
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
icon: isPasswordVisible ? _Icons["default"].hidePassword : _Icons["default"].showPassword,
|
|
99
|
+
title: isPasswordVisible ? passwordInput.inputHidePasswordTitle : passwordInput.inputShowPasswordTitle
|
|
100
|
+
},
|
|
146
101
|
error: error,
|
|
147
102
|
clearable: clearable,
|
|
148
103
|
onChange: onChange,
|
|
@@ -153,6 +108,7 @@ var DxcPasswordInput = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
153
108
|
minLength: minLength,
|
|
154
109
|
maxLength: maxLength,
|
|
155
110
|
autocomplete: autocomplete,
|
|
111
|
+
ref: inputRef,
|
|
156
112
|
tabIndex: tabIndex
|
|
157
113
|
}));
|
|
158
114
|
});
|