@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
package/dropdown/Dropdown.js
CHANGED
|
@@ -1,42 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof3 = 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 _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
15
|
-
|
|
16
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
19
|
-
|
|
20
13
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
|
-
|
|
22
14
|
var _variables = require("../common/variables");
|
|
23
|
-
|
|
24
15
|
var _utils = require("../common/utils");
|
|
25
|
-
|
|
26
16
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
27
|
-
|
|
28
17
|
var _uuid = require("uuid");
|
|
29
|
-
|
|
30
18
|
var Popover = _interopRequireWildcard(require("@radix-ui/react-popover"));
|
|
31
|
-
|
|
32
19
|
var _DropdownMenu = _interopRequireDefault(require("./DropdownMenu"));
|
|
33
|
-
|
|
34
20
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
35
|
-
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
39
|
-
|
|
21
|
+
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); }
|
|
22
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(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; }
|
|
40
23
|
var upArrowIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
41
24
|
xmlns: "http://www.w3.org/2000/svg",
|
|
42
25
|
width: "24",
|
|
@@ -49,7 +32,6 @@ var upArrowIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
|
49
32
|
d: "M0 0h24v24H0z",
|
|
50
33
|
fill: "none"
|
|
51
34
|
}));
|
|
52
|
-
|
|
53
35
|
var downArrowIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
54
36
|
xmlns: "http://www.w3.org/2000/svg",
|
|
55
37
|
width: "24",
|
|
@@ -62,13 +44,11 @@ var downArrowIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
|
62
44
|
d: "M0 0h24v24H0z",
|
|
63
45
|
fill: "none"
|
|
64
46
|
}));
|
|
65
|
-
|
|
66
47
|
var useWidth = function useWidth(target) {
|
|
67
48
|
var _useState = (0, _react.useState)(0),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
49
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
50
|
+
width = _useState2[0],
|
|
51
|
+
setWidth = _useState2[1];
|
|
72
52
|
(0, _react.useEffect)(function () {
|
|
73
53
|
if (target != null) {
|
|
74
54
|
setWidth(target.getBoundingClientRect().width);
|
|
@@ -84,77 +64,64 @@ var useWidth = function useWidth(target) {
|
|
|
84
64
|
}, [target]);
|
|
85
65
|
return width;
|
|
86
66
|
};
|
|
87
|
-
|
|
88
67
|
var DxcDropdown = function DxcDropdown(_ref) {
|
|
89
68
|
var options = _ref.options,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
69
|
+
_ref$optionsIconPosit = _ref.optionsIconPosition,
|
|
70
|
+
optionsIconPosition = _ref$optionsIconPosit === void 0 ? "before" : _ref$optionsIconPosit,
|
|
71
|
+
icon = _ref.icon,
|
|
72
|
+
_ref$iconPosition = _ref.iconPosition,
|
|
73
|
+
iconPosition = _ref$iconPosition === void 0 ? "before" : _ref$iconPosition,
|
|
74
|
+
_ref$label = _ref.label,
|
|
75
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
76
|
+
_ref$caretHidden = _ref.caretHidden,
|
|
77
|
+
caretHidden = _ref$caretHidden === void 0 ? false : _ref$caretHidden,
|
|
78
|
+
_ref$disabled = _ref.disabled,
|
|
79
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
80
|
+
_ref$expandOnHover = _ref.expandOnHover,
|
|
81
|
+
expandOnHover = _ref$expandOnHover === void 0 ? false : _ref$expandOnHover,
|
|
82
|
+
onSelectOption = _ref.onSelectOption,
|
|
83
|
+
margin = _ref.margin,
|
|
84
|
+
_ref$size = _ref.size,
|
|
85
|
+
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
86
|
+
_ref$tabIndex = _ref.tabIndex,
|
|
87
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
110
88
|
var _useState3 = (0, _react.useState)("trigger-".concat((0, _uuid.v4)())),
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
89
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 1),
|
|
90
|
+
triggerId = _useState4[0];
|
|
114
91
|
var menuId = "menu-".concat(triggerId);
|
|
115
|
-
|
|
116
92
|
var _useState5 = (0, _react.useState)(false),
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
93
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
94
|
+
isOpen = _useState6[0],
|
|
95
|
+
changeIsOpen = _useState6[1];
|
|
121
96
|
var _useState7 = (0, _react.useState)(0),
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
97
|
+
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
98
|
+
visualFocusIndex = _useState8[0],
|
|
99
|
+
setVisualFocusIndex = _useState8[1];
|
|
126
100
|
var colorsTheme = (0, _useTheme["default"])();
|
|
127
101
|
var triggerRef = (0, _react.useRef)(null);
|
|
128
102
|
var menuRef = (0, _react.useRef)(null);
|
|
129
103
|
var width = useWidth(triggerRef.current);
|
|
130
|
-
|
|
131
104
|
var handleOnOpenMenu = function handleOnOpenMenu() {
|
|
132
105
|
changeIsOpen(true);
|
|
133
106
|
};
|
|
134
|
-
|
|
135
107
|
var handleOnCloseMenu = function handleOnCloseMenu() {
|
|
136
108
|
changeIsOpen(false);
|
|
137
109
|
setVisualFocusIndex(0);
|
|
138
110
|
};
|
|
139
|
-
|
|
140
111
|
var handleMenuItemOnClick = (0, _react.useCallback)(function (value) {
|
|
141
112
|
var _triggerRef$current;
|
|
142
|
-
|
|
143
113
|
onSelectOption(value);
|
|
144
114
|
handleOnCloseMenu();
|
|
145
115
|
(_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.focus();
|
|
146
116
|
}, [onSelectOption]);
|
|
147
|
-
|
|
148
117
|
var handleOnBlur = function handleOnBlur(event) {
|
|
149
118
|
!event.currentTarget.contains(event.relatedTarget) && handleOnCloseMenu();
|
|
150
119
|
};
|
|
151
|
-
|
|
152
120
|
var handleTriggerOnClick = function handleTriggerOnClick() {
|
|
153
121
|
changeIsOpen(function (isOpen) {
|
|
154
122
|
return !isOpen;
|
|
155
123
|
});
|
|
156
124
|
};
|
|
157
|
-
|
|
158
125
|
var handleTriggerOnKeyDown = function handleTriggerOnKeyDown(event) {
|
|
159
126
|
switch (event.key) {
|
|
160
127
|
case "Up":
|
|
@@ -163,7 +130,6 @@ var DxcDropdown = function DxcDropdown(_ref) {
|
|
|
163
130
|
setVisualFocusIndex(options.length - 1);
|
|
164
131
|
handleOnOpenMenu();
|
|
165
132
|
break;
|
|
166
|
-
|
|
167
133
|
case " ":
|
|
168
134
|
case "Down":
|
|
169
135
|
case "ArrowDown":
|
|
@@ -173,62 +139,52 @@ var DxcDropdown = function DxcDropdown(_ref) {
|
|
|
173
139
|
break;
|
|
174
140
|
}
|
|
175
141
|
};
|
|
176
|
-
|
|
177
142
|
var setPreviousIndexFocus = function setPreviousIndexFocus() {
|
|
178
143
|
setVisualFocusIndex(function (currentFocusIndex) {
|
|
179
144
|
var index = currentFocusIndex === 0 ? options.length - 1 : currentFocusIndex - 1;
|
|
180
145
|
return index;
|
|
181
146
|
});
|
|
182
147
|
};
|
|
183
|
-
|
|
184
148
|
var setNextIndexFocus = function setNextIndexFocus() {
|
|
185
149
|
setVisualFocusIndex(function (currentFocusIndex) {
|
|
186
150
|
var index = currentFocusIndex === options.length - 1 ? 0 : currentFocusIndex + 1;
|
|
187
151
|
return index;
|
|
188
152
|
});
|
|
189
153
|
};
|
|
190
|
-
|
|
191
154
|
var handleMenuOnKeyDown = (0, _react.useCallback)(function (event) {
|
|
192
155
|
var _triggerRef$current2, _triggerRef$current3;
|
|
193
|
-
|
|
194
156
|
switch (event.key) {
|
|
195
157
|
case "Up":
|
|
196
158
|
case "ArrowUp":
|
|
197
159
|
event.preventDefault();
|
|
198
160
|
setPreviousIndexFocus();
|
|
199
161
|
break;
|
|
200
|
-
|
|
201
162
|
case "Down":
|
|
202
163
|
case "ArrowDown":
|
|
203
164
|
event.preventDefault();
|
|
204
165
|
setNextIndexFocus();
|
|
205
166
|
break;
|
|
206
|
-
|
|
207
167
|
case " ":
|
|
208
168
|
case "Enter":
|
|
209
169
|
event.preventDefault();
|
|
210
170
|
handleMenuItemOnClick(options[visualFocusIndex].value);
|
|
211
171
|
break;
|
|
212
|
-
|
|
213
172
|
case "Esc":
|
|
214
173
|
case "Escape":
|
|
215
174
|
event.preventDefault();
|
|
216
175
|
handleOnCloseMenu();
|
|
217
176
|
(_triggerRef$current2 = triggerRef.current) === null || _triggerRef$current2 === void 0 ? void 0 : _triggerRef$current2.focus();
|
|
218
177
|
break;
|
|
219
|
-
|
|
220
178
|
case "Home":
|
|
221
179
|
case "PageUp":
|
|
222
180
|
event.preventDefault();
|
|
223
181
|
setVisualFocusIndex(0);
|
|
224
182
|
break;
|
|
225
|
-
|
|
226
183
|
case "End":
|
|
227
184
|
case "PageDown":
|
|
228
185
|
event.preventDefault();
|
|
229
186
|
setVisualFocusIndex(options.length - 1);
|
|
230
187
|
break;
|
|
231
|
-
|
|
232
188
|
case "Tab":
|
|
233
189
|
handleOnCloseMenu();
|
|
234
190
|
(_triggerRef$current3 = triggerRef.current) === null || _triggerRef$current3 === void 0 ? void 0 : _triggerRef$current3.focus();
|
|
@@ -237,7 +193,6 @@ var DxcDropdown = function DxcDropdown(_ref) {
|
|
|
237
193
|
}, [onSelectOption, visualFocusIndex, options]);
|
|
238
194
|
(0, _react.useLayoutEffect)(function () {
|
|
239
195
|
var _menuRef$current, _visualFocusedMenuIte;
|
|
240
|
-
|
|
241
196
|
var visualFocusedMenuItem = menuRef === null || menuRef === void 0 ? void 0 : (_menuRef$current = menuRef.current) === null || _menuRef$current === void 0 ? void 0 : _menuRef$current.querySelectorAll("[role='menuitem']")[visualFocusIndex];
|
|
242
197
|
visualFocusedMenuItem === null || visualFocusedMenuItem === void 0 ? void 0 : (_visualFocusedMenuIte = visualFocusedMenuItem.scrollIntoView) === null || _visualFocusedMenuIte === void 0 ? void 0 : _visualFocusedMenuIte.call(visualFocusedMenuItem, {
|
|
243
198
|
block: "nearest",
|
|
@@ -280,9 +235,9 @@ var DxcDropdown = function DxcDropdown(_ref) {
|
|
|
280
235
|
src: icon
|
|
281
236
|
}) : icon), label && iconPosition === "before" && /*#__PURE__*/_react["default"].createElement(DropdownTriggerLabel, null, label)), !caretHidden && /*#__PURE__*/_react["default"].createElement(CaretIcon, {
|
|
282
237
|
disabled: disabled
|
|
283
|
-
}, isOpen ? upArrowIcon : downArrowIcon))), /*#__PURE__*/_react["default"].createElement(Popover.Content, {
|
|
284
|
-
|
|
285
|
-
|
|
238
|
+
}, isOpen ? upArrowIcon : downArrowIcon))), /*#__PURE__*/_react["default"].createElement(Popover.Portal, null, /*#__PURE__*/_react["default"].createElement(Popover.Content, {
|
|
239
|
+
asChild: true,
|
|
240
|
+
sideOffset: 1
|
|
286
241
|
}, /*#__PURE__*/_react["default"].createElement(_DropdownMenu["default"], {
|
|
287
242
|
id: menuId,
|
|
288
243
|
dropdownTriggerId: triggerId,
|
|
@@ -292,12 +247,12 @@ var DxcDropdown = function DxcDropdown(_ref) {
|
|
|
292
247
|
menuItemOnClick: handleMenuItemOnClick,
|
|
293
248
|
onKeyDown: handleMenuOnKeyDown,
|
|
294
249
|
styles: {
|
|
295
|
-
width: width
|
|
250
|
+
width: width,
|
|
251
|
+
zIndex: "2147483647"
|
|
296
252
|
},
|
|
297
253
|
ref: menuRef
|
|
298
|
-
})))));
|
|
254
|
+
}))))));
|
|
299
255
|
};
|
|
300
|
-
|
|
301
256
|
var sizes = {
|
|
302
257
|
small: "60px",
|
|
303
258
|
medium: "240px",
|
|
@@ -305,11 +260,9 @@ var sizes = {
|
|
|
305
260
|
fillParent: "100%",
|
|
306
261
|
fitContent: "fit-content"
|
|
307
262
|
};
|
|
308
|
-
|
|
309
263
|
var calculateWidth = function calculateWidth(margin, size) {
|
|
310
264
|
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
311
265
|
};
|
|
312
|
-
|
|
313
266
|
var DropdownContainer = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-block;\n width: ", ";\n text-overflow: ellipsis;\n overflow: hidden;\n margin: ", ";\n margin-top: ", ";\n margin-right: ", ";\n margin-bottom: ", ";\n margin-left: ", ";\n"])), function (props) {
|
|
314
267
|
return calculateWidth(props.margin, props.size);
|
|
315
268
|
}, function (props) {
|
|
@@ -323,7 +276,6 @@ var DropdownContainer = _styledComponents["default"].div(_templateObject || (_te
|
|
|
323
276
|
}, function (props) {
|
|
324
277
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
325
278
|
});
|
|
326
|
-
|
|
327
279
|
var DropdownTrigger = _styledComponents["default"].button(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: ", ";\n width: 100%;\n min-height: 40px;\n min-width: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n background-color: ", ";\n color: ", ";\n cursor: ", ";\n\n ", ";\n"])), function (props) {
|
|
328
280
|
return props.theme.caretIconSpacing;
|
|
329
281
|
}, function (props) {
|
|
@@ -353,11 +305,9 @@ var DropdownTrigger = _styledComponents["default"].button(_templateObject2 || (_
|
|
|
353
305
|
}, function (props) {
|
|
354
306
|
return !props.disabled && "\n &:focus {\n outline: ".concat(props.theme.focusColor, " solid 2px;\n outline-offset: -2px;\n }\n &:hover {\n background-color: ").concat(props.theme.hoverButtonBackgroundColor, ";\n }\n &:active {\n background-color: ").concat(props.theme.activeButtonBackgroundColor, ";\n }\n ");
|
|
355
307
|
});
|
|
356
|
-
|
|
357
308
|
var DropdownTriggerContent = _styledComponents["default"].span(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n gap: ", ";\n margin-left: 0px;\n margin-right: 0px;\n width: 100%;\n overflow: hidden;\n white-space: nowrap;\n"])), function (props) {
|
|
358
309
|
return props.theme.buttonIconSpacing;
|
|
359
310
|
});
|
|
360
|
-
|
|
361
311
|
var DropdownTriggerLabel = _styledComponents["default"].span(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n text-overflow: ellipsis;\n overflow: hidden;\n"])), function (props) {
|
|
362
312
|
return props.theme.buttonFontFamily;
|
|
363
313
|
}, function (props) {
|
|
@@ -367,7 +317,6 @@ var DropdownTriggerLabel = _styledComponents["default"].span(_templateObject4 ||
|
|
|
367
317
|
}, function (props) {
|
|
368
318
|
return props.theme.buttonFontWeight;
|
|
369
319
|
});
|
|
370
|
-
|
|
371
320
|
var DropdownTriggerIcon = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n color: ", ";\n\n img,\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
|
|
372
321
|
return props.disabled ? props.theme.disabledColor : props.theme.buttonIconColor;
|
|
373
322
|
}, function (props) {
|
|
@@ -375,7 +324,6 @@ var DropdownTriggerIcon = _styledComponents["default"].span(_templateObject5 ||
|
|
|
375
324
|
}, function (props) {
|
|
376
325
|
return props.theme.buttonIconSize;
|
|
377
326
|
});
|
|
378
|
-
|
|
379
327
|
var CaretIcon = _styledComponents["default"].span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n color: ", ";\n\n svg {\n width: ", ";\n height: ", ";\n }\n"])), function (props) {
|
|
380
328
|
return props.disabled ? props.theme.disabledColor : props.theme.caretIconColor;
|
|
381
329
|
}, function (props) {
|
|
@@ -383,6 +331,4 @@ var CaretIcon = _styledComponents["default"].span(_templateObject6 || (_template
|
|
|
383
331
|
}, function (props) {
|
|
384
332
|
return props.theme.caretIconSize;
|
|
385
333
|
});
|
|
386
|
-
|
|
387
|
-
var _default = DxcDropdown;
|
|
388
|
-
exports["default"] = _default;
|
|
334
|
+
var _default = exports["default"] = DxcDropdown;
|