@dxc-technology/halstack-react 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accordion/types.d.ts +1 -1
- package/accordion-group/types.d.ts +1 -1
- package/bulleted-list/types.d.ts +1 -1
- package/button/Button.js +43 -61
- package/button/Button.stories.tsx +9 -0
- package/button/types.d.ts +7 -7
- package/chip/types.d.ts +1 -1
- package/common/variables.js +15 -6
- package/date-input/DateInput.js +3 -3
- package/dialog/Dialog.js +52 -28
- package/dialog/Dialog.stories.tsx +1 -2
- package/dialog/Dialog.test.js +34 -4
- package/dialog/types.d.ts +2 -2
- package/dropdown/Dropdown.d.ts +1 -1
- package/dropdown/Dropdown.js +242 -246
- package/dropdown/Dropdown.stories.tsx +126 -63
- package/dropdown/Dropdown.test.js +510 -108
- package/dropdown/DropdownMenu.d.ts +4 -0
- package/dropdown/DropdownMenu.js +80 -0
- package/dropdown/DropdownMenuItem.d.ts +4 -0
- package/dropdown/DropdownMenuItem.js +92 -0
- package/dropdown/types.d.ts +25 -5
- package/flex/Flex.js +1 -1
- package/flex/types.d.ts +1 -1
- package/footer/types.d.ts +1 -1
- package/header/Header.js +74 -72
- package/header/Icons.js +2 -2
- package/header/types.d.ts +2 -2
- package/layout/ApplicationLayout.js +3 -3
- package/link/Link.js +1 -1
- package/link/Link.stories.tsx +12 -5
- package/link/types.d.ts +1 -1
- package/package.json +7 -7
- package/progress-bar/ProgressBar.d.ts +2 -2
- package/progress-bar/ProgressBar.js +56 -50
- package/progress-bar/ProgressBar.stories.jsx +3 -1
- package/progress-bar/ProgressBar.test.js +67 -22
- package/progress-bar/types.d.ts +3 -4
- package/radio-group/RadioGroup.js +11 -13
- package/select/Listbox.d.ts +1 -1
- package/select/Listbox.js +25 -1
- package/select/Select.js +14 -31
- package/select/Select.stories.tsx +6 -5
- package/select/Select.test.js +63 -50
- package/select/types.d.ts +2 -4
- package/sidenav/Sidenav.js +15 -3
- package/sidenav/types.d.ts +1 -1
- package/slider/Slider.js +3 -3
- package/slider/Slider.test.js +37 -0
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +110 -54
- package/switch/Switch.stories.tsx +8 -30
- package/switch/Switch.test.js +122 -8
- package/switch/types.d.ts +3 -4
- package/tabs/types.d.ts +1 -1
- package/tabs-nav/NavTabs.js +5 -5
- package/tabs-nav/Tab.js +3 -5
- package/tabs-nav/types.d.ts +1 -1
- package/tag/types.d.ts +1 -1
- package/text-input/TextInput.js +12 -21
- package/text-input/TextInput.stories.tsx +1 -2
- package/text-input/types.d.ts +1 -1
- package/toggle-group/types.d.ts +1 -1
- package/wizard/types.d.ts +1 -1
package/dropdown/Dropdown.js
CHANGED
|
@@ -19,30 +19,50 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
19
19
|
|
|
20
20
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
21
21
|
|
|
22
|
-
var _Popper = _interopRequireDefault(require("@material-ui/core/Popper"));
|
|
23
|
-
|
|
24
|
-
var _MenuItem = _interopRequireDefault(require("@material-ui/core/MenuItem"));
|
|
25
|
-
|
|
26
|
-
var _core = require("@material-ui/core");
|
|
27
|
-
|
|
28
|
-
var _Grow = _interopRequireDefault(require("@material-ui/core/Grow"));
|
|
29
|
-
|
|
30
|
-
var _Paper = _interopRequireDefault(require("@material-ui/core/Paper"));
|
|
31
|
-
|
|
32
|
-
var _MenuList = _interopRequireDefault(require("@material-ui/core/MenuList"));
|
|
33
|
-
|
|
34
22
|
var _variables = require("../common/variables.js");
|
|
35
23
|
|
|
36
24
|
var _utils = require("../common/utils.js");
|
|
37
25
|
|
|
38
26
|
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
39
27
|
|
|
40
|
-
var
|
|
28
|
+
var _uuid = require("uuid");
|
|
29
|
+
|
|
30
|
+
var Popover = _interopRequireWildcard(require("@radix-ui/react-popover"));
|
|
31
|
+
|
|
32
|
+
var _DropdownMenu = _interopRequireDefault(require("./DropdownMenu"));
|
|
33
|
+
|
|
34
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
41
35
|
|
|
42
36
|
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); }
|
|
43
37
|
|
|
44
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; }
|
|
45
39
|
|
|
40
|
+
var upArrowIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
41
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
42
|
+
width: "24",
|
|
43
|
+
height: "24",
|
|
44
|
+
viewBox: "0 0 24 24",
|
|
45
|
+
fill: "currentColor"
|
|
46
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
47
|
+
d: "M7 14l5-5 5 5z"
|
|
48
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
49
|
+
d: "M0 0h24v24H0z",
|
|
50
|
+
fill: "none"
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
var downArrowIcon = /*#__PURE__*/_react["default"].createElement("svg", {
|
|
54
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
55
|
+
width: "24",
|
|
56
|
+
height: "24",
|
|
57
|
+
viewBox: "0 0 24 24",
|
|
58
|
+
fill: "currentColor"
|
|
59
|
+
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
60
|
+
d: "M7 10l5 5 5-5z"
|
|
61
|
+
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
62
|
+
d: "M0 0h24v24H0z",
|
|
63
|
+
fill: "none"
|
|
64
|
+
}));
|
|
65
|
+
|
|
46
66
|
var DxcDropdown = function DxcDropdown(_ref) {
|
|
47
67
|
var options = _ref.options,
|
|
48
68
|
_ref$optionsIconPosit = _ref.optionsIconPosition,
|
|
@@ -54,173 +74,227 @@ var DxcDropdown = function DxcDropdown(_ref) {
|
|
|
54
74
|
label = _ref$label === void 0 ? "" : _ref$label,
|
|
55
75
|
_ref$caretHidden = _ref.caretHidden,
|
|
56
76
|
caretHidden = _ref$caretHidden === void 0 ? false : _ref$caretHidden,
|
|
57
|
-
|
|
77
|
+
_ref$disabled = _ref.disabled,
|
|
78
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
58
79
|
_ref$expandOnHover = _ref.expandOnHover,
|
|
59
80
|
expandOnHover = _ref$expandOnHover === void 0 ? false : _ref$expandOnHover,
|
|
81
|
+
onSelectOption = _ref.onSelectOption,
|
|
60
82
|
margin = _ref.margin,
|
|
61
83
|
_ref$size = _ref.size,
|
|
62
84
|
size = _ref$size === void 0 ? "fitContent" : _ref$size,
|
|
63
85
|
_ref$tabIndex = _ref.tabIndex,
|
|
64
|
-
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex
|
|
65
|
-
_ref$disabled = _ref.disabled,
|
|
66
|
-
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
|
86
|
+
tabIndex = _ref$tabIndex === void 0 ? 0 : _ref$tabIndex;
|
|
67
87
|
|
|
68
|
-
var _useState = (0, _react.useState)(),
|
|
69
|
-
_useState2 = (0, _slicedToArray2["default"])(_useState,
|
|
70
|
-
|
|
71
|
-
|
|
88
|
+
var _useState = (0, _react.useState)("trigger-".concat((0, _uuid.v4)())),
|
|
89
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 1),
|
|
90
|
+
triggerId = _useState2[0];
|
|
91
|
+
|
|
92
|
+
var menuId = "menu-".concat(triggerId);
|
|
93
|
+
|
|
94
|
+
var _useState3 = (0, _react.useState)(false),
|
|
95
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
96
|
+
isOpen = _useState4[0],
|
|
97
|
+
changeIsOpen = _useState4[1];
|
|
98
|
+
|
|
99
|
+
var _useState5 = (0, _react.useState)(null),
|
|
100
|
+
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
101
|
+
menuStyles = _useState6[0],
|
|
102
|
+
setMenuStyles = _useState6[1];
|
|
103
|
+
|
|
104
|
+
var _useState7 = (0, _react.useState)(0),
|
|
105
|
+
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
106
|
+
visualFocusIndex = _useState8[0],
|
|
107
|
+
setVisualFocusIndex = _useState8[1];
|
|
72
108
|
|
|
73
109
|
var colorsTheme = (0, _useTheme["default"])();
|
|
74
|
-
var
|
|
110
|
+
var triggerRef = (0, _react.useRef)(null);
|
|
111
|
+
var menuRef = (0, _react.useRef)(null);
|
|
75
112
|
|
|
76
|
-
var
|
|
77
|
-
|
|
113
|
+
var handleOnOpenMenu = function handleOnOpenMenu() {
|
|
114
|
+
changeIsOpen(true);
|
|
78
115
|
};
|
|
79
116
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
117
|
+
var handleOnCloseMenu = function handleOnCloseMenu() {
|
|
118
|
+
changeIsOpen(false);
|
|
119
|
+
setVisualFocusIndex(0);
|
|
120
|
+
};
|
|
85
121
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
89
|
-
}, []);
|
|
122
|
+
var handleMenuItemOnClick = (0, _react.useCallback)(function (value) {
|
|
123
|
+
var _triggerRef$current;
|
|
90
124
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
function
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function handleMenuItemClick(option) {
|
|
101
|
-
setAnchorEl(null);
|
|
102
|
-
onSelectOption(option.value);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function handleClose() {
|
|
106
|
-
setAnchorEl(null);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
var handleCloseOver = expandOnHover ? handleClose : undefined;
|
|
110
|
-
|
|
111
|
-
var UpArrowIcon = function UpArrowIcon() {
|
|
112
|
-
return /*#__PURE__*/_react["default"].createElement("svg", {
|
|
113
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
114
|
-
width: "24",
|
|
115
|
-
height: "24",
|
|
116
|
-
viewBox: "0 0 24 24",
|
|
117
|
-
fill: "currentColor"
|
|
118
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
119
|
-
d: "M7 14l5-5 5 5z"
|
|
120
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
121
|
-
d: "M0 0h24v24H0z",
|
|
122
|
-
fill: "none"
|
|
123
|
-
}));
|
|
125
|
+
onSelectOption(value);
|
|
126
|
+
handleOnCloseMenu();
|
|
127
|
+
(_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.focus();
|
|
128
|
+
}, [onSelectOption]);
|
|
129
|
+
|
|
130
|
+
var handleOnBlur = function handleOnBlur(event) {
|
|
131
|
+
!event.currentTarget.contains(event.relatedTarget) && handleOnCloseMenu();
|
|
124
132
|
};
|
|
125
133
|
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
height: "24",
|
|
131
|
-
viewBox: "0 0 24 24",
|
|
132
|
-
fill: "currentColor"
|
|
133
|
-
}, /*#__PURE__*/_react["default"].createElement("path", {
|
|
134
|
-
d: "M7 10l5 5 5-5z"
|
|
135
|
-
}), /*#__PURE__*/_react["default"].createElement("path", {
|
|
136
|
-
d: "M0 0h24v24H0z",
|
|
137
|
-
fill: "none"
|
|
138
|
-
}));
|
|
134
|
+
var handleTriggerOnClick = function handleTriggerOnClick() {
|
|
135
|
+
changeIsOpen(function (isOpen) {
|
|
136
|
+
return !isOpen;
|
|
137
|
+
});
|
|
139
138
|
};
|
|
140
139
|
|
|
141
|
-
var
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
var handleTriggerOnKeyDown = function handleTriggerOnKeyDown(event) {
|
|
141
|
+
switch (event.key) {
|
|
142
|
+
case "Up":
|
|
143
|
+
case "ArrowUp":
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
setVisualFocusIndex(options.length - 1);
|
|
146
|
+
handleOnOpenMenu();
|
|
147
|
+
break;
|
|
148
|
+
|
|
149
|
+
case "Space":
|
|
150
|
+
case "Down":
|
|
151
|
+
case "ArrowDown":
|
|
152
|
+
case "Enter":
|
|
153
|
+
event.preventDefault();
|
|
154
|
+
handleOnOpenMenu();
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
var setPreviousIndexFocus = function setPreviousIndexFocus() {
|
|
160
|
+
setVisualFocusIndex(function (currentFocusIndex) {
|
|
161
|
+
var index = currentFocusIndex === 0 ? options.length - 1 : currentFocusIndex - 1;
|
|
162
|
+
return index;
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
var setNextIndexFocus = function setNextIndexFocus() {
|
|
167
|
+
setVisualFocusIndex(function (currentFocusIndex) {
|
|
168
|
+
var index = currentFocusIndex === options.length - 1 ? 0 : currentFocusIndex + 1;
|
|
169
|
+
return index;
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
var handleMenuOnKeyDown = (0, _react.useCallback)(function (event) {
|
|
174
|
+
var _triggerRef$current2, _triggerRef$current3;
|
|
175
|
+
|
|
176
|
+
switch (event.key) {
|
|
177
|
+
case "Up":
|
|
178
|
+
case "ArrowUp":
|
|
179
|
+
event.preventDefault();
|
|
180
|
+
setPreviousIndexFocus();
|
|
181
|
+
break;
|
|
182
|
+
|
|
183
|
+
case "Down":
|
|
184
|
+
case "ArrowDown":
|
|
185
|
+
event.preventDefault();
|
|
186
|
+
setNextIndexFocus();
|
|
187
|
+
break;
|
|
188
|
+
|
|
189
|
+
case "Space":
|
|
190
|
+
case "Enter":
|
|
191
|
+
event.preventDefault();
|
|
192
|
+
handleMenuItemOnClick(options[visualFocusIndex].value);
|
|
193
|
+
break;
|
|
194
|
+
|
|
195
|
+
case "Esc":
|
|
196
|
+
case "Escape":
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
handleOnCloseMenu();
|
|
199
|
+
(_triggerRef$current2 = triggerRef.current) === null || _triggerRef$current2 === void 0 ? void 0 : _triggerRef$current2.focus();
|
|
200
|
+
break;
|
|
201
|
+
|
|
202
|
+
case "Home":
|
|
203
|
+
case "PageUp":
|
|
204
|
+
event.preventDefault();
|
|
205
|
+
setVisualFocusIndex(0);
|
|
206
|
+
break;
|
|
207
|
+
|
|
208
|
+
case "End":
|
|
209
|
+
case "PageDown":
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
setVisualFocusIndex(options.length - 1);
|
|
212
|
+
break;
|
|
213
|
+
|
|
214
|
+
case "Tab":
|
|
215
|
+
handleOnCloseMenu();
|
|
216
|
+
(_triggerRef$current3 = triggerRef.current) === null || _triggerRef$current3 === void 0 ? void 0 : _triggerRef$current3.focus();
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
}, [onSelectOption, visualFocusIndex, options]);
|
|
220
|
+
(0, _react.useLayoutEffect)(function () {
|
|
221
|
+
var _menuRef$current, _visualFocusedMenuIte;
|
|
222
|
+
|
|
223
|
+
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];
|
|
224
|
+
visualFocusedMenuItem === null || visualFocusedMenuItem === void 0 ? void 0 : (_visualFocusedMenuIte = visualFocusedMenuItem.scrollIntoView) === null || _visualFocusedMenuIte === void 0 ? void 0 : _visualFocusedMenuIte.call(visualFocusedMenuItem, {
|
|
225
|
+
block: "nearest",
|
|
226
|
+
inline: "start"
|
|
227
|
+
});
|
|
228
|
+
}, [visualFocusIndex]);
|
|
229
|
+
|
|
230
|
+
var handleMenuResize = function handleMenuResize() {
|
|
231
|
+
var _triggerRef$current4;
|
|
232
|
+
|
|
233
|
+
var rect = triggerRef === null || triggerRef === void 0 ? void 0 : (_triggerRef$current4 = triggerRef.current) === null || _triggerRef$current4 === void 0 ? void 0 : _triggerRef$current4.getBoundingClientRect();
|
|
234
|
+
setMenuStyles({
|
|
235
|
+
width: rect === null || rect === void 0 ? void 0 : rect.width
|
|
236
|
+
});
|
|
237
|
+
};
|
|
145
238
|
|
|
239
|
+
(0, _react.useEffect)(function () {
|
|
240
|
+
handleMenuResize();
|
|
241
|
+
window.addEventListener("resize", handleMenuResize);
|
|
242
|
+
return function () {
|
|
243
|
+
window.removeEventListener("resize", handleMenuResize);
|
|
244
|
+
};
|
|
245
|
+
}, []);
|
|
146
246
|
return /*#__PURE__*/_react["default"].createElement(_styledComponents.ThemeProvider, {
|
|
147
247
|
theme: colorsTheme.dropdown
|
|
148
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
248
|
+
}, /*#__PURE__*/_react["default"].createElement(DropdownContainer, {
|
|
249
|
+
onMouseEnter: !disabled && expandOnHover ? handleOnOpenMenu : undefined,
|
|
250
|
+
onMouseLeave: !disabled && expandOnHover ? handleOnCloseMenu : undefined,
|
|
251
|
+
onBlur: !disabled ? handleOnBlur : undefined,
|
|
149
252
|
margin: margin,
|
|
150
|
-
size: size
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
onFocus: handleCloseOver,
|
|
156
|
-
onBlur: handleCloseOver
|
|
253
|
+
size: size
|
|
254
|
+
}, /*#__PURE__*/_react["default"].createElement(Popover.Root, {
|
|
255
|
+
open: isOpen
|
|
256
|
+
}, /*#__PURE__*/_react["default"].createElement(Popover.Trigger, {
|
|
257
|
+
asChild: true
|
|
157
258
|
}, /*#__PURE__*/_react["default"].createElement(DropdownTrigger, {
|
|
158
|
-
opened:
|
|
159
|
-
onClick:
|
|
259
|
+
opened: isOpen,
|
|
260
|
+
onClick: handleTriggerOnClick,
|
|
261
|
+
onKeyDown: handleTriggerOnKeyDown,
|
|
262
|
+
onBlur: function onBlur(event) {
|
|
263
|
+
event.stopPropagation();
|
|
264
|
+
},
|
|
160
265
|
disabled: disabled,
|
|
161
266
|
label: label,
|
|
162
|
-
caretHidden: caretHidden,
|
|
163
267
|
margin: margin,
|
|
164
268
|
size: size,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
269
|
+
id: triggerId,
|
|
270
|
+
"aria-disabled": disabled,
|
|
271
|
+
"aria-haspopup": "true",
|
|
272
|
+
"aria-expanded": isOpen ? true : undefined,
|
|
273
|
+
tabIndex: tabIndex,
|
|
274
|
+
ref: triggerRef
|
|
275
|
+
}, /*#__PURE__*/_react["default"].createElement(DropdownTriggerContent, null, label && iconPosition === "after" && /*#__PURE__*/_react["default"].createElement(DropdownTriggerLabel, null, label), icon && /*#__PURE__*/_react["default"].createElement(DropdownTriggerIcon, {
|
|
170
276
|
label: label,
|
|
171
277
|
iconPosition: iconPosition,
|
|
172
|
-
disabled: disabled
|
|
173
|
-
|
|
278
|
+
disabled: disabled,
|
|
279
|
+
role: typeof icon === "string" ? undefined : "img"
|
|
280
|
+
}, typeof icon === "string" ? /*#__PURE__*/_react["default"].createElement("img", {
|
|
174
281
|
src: icon
|
|
175
|
-
}) : icon), iconPosition === "before" &&
|
|
176
|
-
caretHidden: caretHidden,
|
|
282
|
+
}) : icon), label && iconPosition === "before" && /*#__PURE__*/_react["default"].createElement(DropdownTriggerLabel, null, label)), !caretHidden && /*#__PURE__*/_react["default"].createElement(CaretIcon, {
|
|
177
283
|
disabled: disabled
|
|
178
|
-
},
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
width: width,
|
|
193
|
-
role: undefined,
|
|
194
|
-
transition: true,
|
|
195
|
-
disablePortal: true,
|
|
196
|
-
placement: "bottom-start"
|
|
197
|
-
}, function (_ref2) {
|
|
198
|
-
var TransitionProps = _ref2.TransitionProps;
|
|
199
|
-
return /*#__PURE__*/_react["default"].createElement(_Grow["default"], TransitionProps, /*#__PURE__*/_react["default"].createElement(_Paper["default"], null, /*#__PURE__*/_react["default"].createElement(_core.ClickAwayListener, {
|
|
200
|
-
onClickAway: handleClose
|
|
201
|
-
}, /*#__PURE__*/_react["default"].createElement(_MenuList["default"], {
|
|
202
|
-
autoFocusItem: Boolean(anchorEl),
|
|
203
|
-
id: "menu-list-grow"
|
|
204
|
-
}, options.map(function (option) {
|
|
205
|
-
return /*#__PURE__*/_react["default"].createElement(_MenuItem["default"], {
|
|
206
|
-
key: option.value,
|
|
207
|
-
value: option.value,
|
|
208
|
-
disableRipple: true,
|
|
209
|
-
onClick: function onClick(event) {
|
|
210
|
-
return handleMenuItemClick(option);
|
|
211
|
-
}
|
|
212
|
-
}, optionsIconPosition === "after" && /*#__PURE__*/_react["default"].createElement("span", {
|
|
213
|
-
className: "optionLabel"
|
|
214
|
-
}, option.label), option.icon && /*#__PURE__*/_react["default"].createElement(ListIconContainer, {
|
|
215
|
-
label: option.label,
|
|
216
|
-
iconPosition: optionsIconPosition
|
|
217
|
-
}, typeof option.icon === "string" ? /*#__PURE__*/_react["default"].createElement(ListIcon, {
|
|
218
|
-
src: option.icon
|
|
219
|
-
}) : option.icon), optionsIconPosition === "before" && /*#__PURE__*/_react["default"].createElement("span", {
|
|
220
|
-
className: "optionLabel"
|
|
221
|
-
}, option.label));
|
|
222
|
-
})))));
|
|
223
|
-
}))));
|
|
284
|
+
}, isOpen ? upArrowIcon : downArrowIcon))), /*#__PURE__*/_react["default"].createElement(Popover.Content, {
|
|
285
|
+
sideOffset: 1,
|
|
286
|
+
asChild: true
|
|
287
|
+
}, /*#__PURE__*/_react["default"].createElement(_DropdownMenu["default"], {
|
|
288
|
+
id: menuId,
|
|
289
|
+
dropdownTriggerId: triggerId,
|
|
290
|
+
options: options,
|
|
291
|
+
iconsPosition: optionsIconPosition,
|
|
292
|
+
visualFocusIndex: visualFocusIndex,
|
|
293
|
+
menuItemOnClick: handleMenuItemOnClick,
|
|
294
|
+
onKeyDown: handleMenuOnKeyDown,
|
|
295
|
+
styles: menuStyles,
|
|
296
|
+
ref: menuRef
|
|
297
|
+
})))));
|
|
224
298
|
};
|
|
225
299
|
|
|
226
300
|
var sizes = {
|
|
@@ -232,14 +306,10 @@ var sizes = {
|
|
|
232
306
|
};
|
|
233
307
|
|
|
234
308
|
var calculateWidth = function calculateWidth(margin, size) {
|
|
235
|
-
|
|
236
|
-
return "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")");
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
return sizes[size];
|
|
309
|
+
return size === "fillParent" ? "calc(".concat(sizes[size], " - ").concat((0, _utils.getMargin)(margin, "left"), " - ").concat((0, _utils.getMargin)(margin, "right"), ")") : sizes[size];
|
|
240
310
|
};
|
|
241
311
|
|
|
242
|
-
var
|
|
312
|
+
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) {
|
|
243
313
|
return calculateWidth(props.margin, props.size);
|
|
244
314
|
}, function (props) {
|
|
245
315
|
return props.margin && (0, _typeof2["default"])(props.margin) !== "object" ? _variables.spaces[props.margin] : "0px";
|
|
@@ -253,64 +323,10 @@ var DXCDropdownContainer = _styledComponents["default"].div(_templateObject || (
|
|
|
253
323
|
return props.margin && (0, _typeof2["default"])(props.margin) === "object" && props.margin.left ? _variables.spaces[props.margin.left] : "";
|
|
254
324
|
});
|
|
255
325
|
|
|
256
|
-
var
|
|
257
|
-
return
|
|
258
|
-
}, function (props) {
|
|
259
|
-
return props.theme.optionPaddingTop;
|
|
260
|
-
}, function (props) {
|
|
261
|
-
return props.theme.optionPaddingBottom;
|
|
262
|
-
}, function (props) {
|
|
263
|
-
return props.theme.optionPaddingLeft;
|
|
264
|
-
}, function (props) {
|
|
265
|
-
return props.theme.optionPaddingRight;
|
|
266
|
-
}, function (props) {
|
|
267
|
-
return "".concat(props.width, "px");
|
|
268
|
-
}, function (props) {
|
|
269
|
-
return props.theme.borderThickness;
|
|
270
|
-
}, function (props) {
|
|
271
|
-
return props.theme.borderStyle;
|
|
272
|
-
}, function (props) {
|
|
273
|
-
return props.theme.borderColor;
|
|
274
|
-
}, function (props) {
|
|
275
|
-
return props.theme.borderRadius;
|
|
276
|
-
}, function (props) {
|
|
277
|
-
return props.theme.borderRadius;
|
|
278
|
-
}, function (props) {
|
|
279
|
-
return props.theme.scrollBarTrackColor;
|
|
280
|
-
}, function (props) {
|
|
281
|
-
return props.theme.scrollBarThumbColor;
|
|
282
|
-
}, function (props) {
|
|
283
|
-
return props.theme.optionBackgroundColor;
|
|
284
|
-
}, function (props) {
|
|
285
|
-
return props.theme.optionFontFamily;
|
|
286
|
-
}, function (props) {
|
|
287
|
-
return props.theme.optionFontSize;
|
|
288
|
-
}, function (props) {
|
|
289
|
-
return props.theme.optionFontStyle;
|
|
290
|
-
}, function (props) {
|
|
291
|
-
return props.theme.optionFontWeight;
|
|
292
|
-
}, function (props) {
|
|
293
|
-
return props.theme.optionFontColor;
|
|
294
|
-
}, function (props) {
|
|
295
|
-
return props.theme.focusColor;
|
|
296
|
-
}, function (props) {
|
|
297
|
-
return props.theme.hoverOptionBackgroundColor;
|
|
298
|
-
}, function (props) {
|
|
299
|
-
return props.theme.activeOptionBackgroundColor;
|
|
300
|
-
}, function (props) {
|
|
301
|
-
return props.theme.focusColor;
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
var DropdownTrigger = _styledComponents["default"].button(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: inline-flex;\n justify-content: space-between;\n align-items: center;\n width: 100%;\n height: auto;\n min-height: 40px;\n cursor: ", ";\n font-family: ", ";\n font-size: ", ";\n font-style: ", ";\n font-weight: ", ";\n border-radius: ", ";\n border-width: ", ";\n border-style: ", ";\n border-color: ", ";\n min-width: ", ";\n padding-top: ", ";\n padding-bottom: ", ";\n padding-left: ", ";\n padding-right: ", ";\n background-color: ", ";\n color: ", ";\n border-bottom-right-radius: ", ";\n border-bottom-left-radius: ", ";\n\n ", ";\n"])), function (props) {
|
|
305
|
-
return props.disabled ? "not-allowed" : "pointer";
|
|
306
|
-
}, function (props) {
|
|
307
|
-
return props.theme.buttonFontFamily;
|
|
308
|
-
}, function (props) {
|
|
309
|
-
return props.theme.buttonFontSize;
|
|
310
|
-
}, function (props) {
|
|
311
|
-
return props.theme.buttonFontStyle;
|
|
326
|
+
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) {
|
|
327
|
+
return props.theme.caretIconSpacing;
|
|
312
328
|
}, function (props) {
|
|
313
|
-
return props.
|
|
329
|
+
return props.label === "" ? "0px" : calculateWidth(props.margin, props.size);
|
|
314
330
|
}, function (props) {
|
|
315
331
|
return props.theme.borderRadius;
|
|
316
332
|
}, function (props) {
|
|
@@ -319,8 +335,6 @@ var DropdownTrigger = _styledComponents["default"].button(_templateObject3 || (_
|
|
|
319
335
|
return props.theme.borderStyle;
|
|
320
336
|
}, function (props) {
|
|
321
337
|
return props.disabled ? props.theme.disabledBorderColor : props.theme.borderColor;
|
|
322
|
-
}, function (props) {
|
|
323
|
-
return props.label === "" ? "0px" : calculateWidth(props.margin, props.size);
|
|
324
338
|
}, function (props) {
|
|
325
339
|
return props.theme.buttonPaddingTop;
|
|
326
340
|
}, function (props) {
|
|
@@ -334,52 +348,34 @@ var DropdownTrigger = _styledComponents["default"].button(_templateObject3 || (_
|
|
|
334
348
|
}, function (props) {
|
|
335
349
|
return props.disabled ? props.theme.disabledColor : props.theme.buttonFontColor;
|
|
336
350
|
}, function (props) {
|
|
337
|
-
return props.
|
|
338
|
-
}, function (props) {
|
|
339
|
-
return props.opened ? "0px" : props.theme.borderRadius;
|
|
351
|
+
return props.disabled ? "not-allowed" : "pointer";
|
|
340
352
|
}, function (props) {
|
|
341
|
-
return !props.disabled && "
|
|
353
|
+
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 ");
|
|
342
354
|
});
|
|
343
355
|
|
|
344
|
-
var
|
|
345
|
-
|
|
346
|
-
var DropdownTriggerContainer = _styledComponents["default"].span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n align-items: center;\n margin-left: 0px;\n margin-right: 0px;\n width: ", ";\n white-space: nowrap;\n"])), function (props) {
|
|
347
|
-
return props.caretHidden ? "100%" : "calc(100% - 36px)";
|
|
356
|
+
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) {
|
|
357
|
+
return props.theme.buttonIconSpacing;
|
|
348
358
|
});
|
|
349
359
|
|
|
350
|
-
var
|
|
351
|
-
|
|
352
|
-
var ButtonIconContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n width: ", ";\n height: ", ";\n margin-left: ", ";\n margin-right: ", ";\n color: ", ";\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
|
|
353
|
-
return props.theme.buttonIconSize;
|
|
354
|
-
}, function (props) {
|
|
355
|
-
return props.theme.buttonIconSize;
|
|
360
|
+
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) {
|
|
361
|
+
return props.theme.buttonFontFamily;
|
|
356
362
|
}, function (props) {
|
|
357
|
-
return props.
|
|
363
|
+
return props.theme.buttonFontSize;
|
|
358
364
|
}, function (props) {
|
|
359
|
-
return props.
|
|
365
|
+
return props.theme.buttonFontStyle;
|
|
360
366
|
}, function (props) {
|
|
361
|
-
return props.
|
|
367
|
+
return props.theme.buttonFontWeight;
|
|
362
368
|
});
|
|
363
369
|
|
|
364
|
-
var
|
|
365
|
-
|
|
366
|
-
var ListIconContainer = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n overflow: hidden;\n width: ", ";\n height: ", ";\n margin-left: ", ";\n margin-right: ", ";\n color: ", ";\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
|
|
367
|
-
return props.theme.optionIconSize;
|
|
368
|
-
}, function (props) {
|
|
369
|
-
return props.theme.optionIconSize;
|
|
370
|
-
}, function (props) {
|
|
371
|
-
return props.iconPosition === "after" && props.label !== "" && props.theme.optionIconSpacing || "0px";
|
|
370
|
+
var DropdownTriggerIcon = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n width: ", ";\n height: ", ";\n color: ", ";\n\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
|
|
371
|
+
return props.theme.buttonIconSize;
|
|
372
372
|
}, function (props) {
|
|
373
|
-
return props.
|
|
373
|
+
return props.theme.buttonIconSize;
|
|
374
374
|
}, function (props) {
|
|
375
|
-
return props.theme.
|
|
375
|
+
return props.disabled ? props.theme.disabledColor : props.theme.buttonIconColor;
|
|
376
376
|
});
|
|
377
377
|
|
|
378
|
-
var
|
|
379
|
-
return props.caretHidden ? "none" : "inline-flex";
|
|
380
|
-
}, function (props) {
|
|
381
|
-
return props.theme.caretIconSpacing;
|
|
382
|
-
}, function (props) {
|
|
378
|
+
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) {
|
|
383
379
|
return props.disabled ? props.theme.disabledColor : props.theme.caretIconColor;
|
|
384
380
|
}, function (props) {
|
|
385
381
|
return props.theme.caretIconSize;
|