@dxc-technology/halstack-react 6.0.0 → 6.2.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/Accordion.js +122 -103
- package/accordion/Accordion.stories.tsx +1 -2
- package/accordion/Accordion.test.js +9 -10
- package/accordion/types.d.ts +4 -4
- package/accordion-group/AccordionGroup.js +1 -21
- package/accordion-group/AccordionGroup.stories.tsx +27 -1
- package/accordion-group/AccordionGroup.test.js +20 -45
- package/accordion-group/types.d.ts +9 -3
- package/alert/Alert.js +1 -1
- package/box/Box.js +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/checkbox/Checkbox.js +88 -95
- package/checkbox/Checkbox.test.js +93 -16
- package/checkbox/types.d.ts +2 -2
- package/chip/types.d.ts +1 -1
- package/common/variables.js +23 -10
- 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 +243 -247
- 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/Footer.stories.tsx +8 -1
- package/footer/types.d.ts +1 -1
- package/header/Header.js +74 -72
- package/header/Header.stories.tsx +4 -4
- package/header/Icons.js +2 -2
- package/header/types.d.ts +2 -2
- package/layout/ApplicationLayout.js +3 -3
- package/layout/ApplicationLayout.stories.tsx +1 -0
- package/link/Link.js +1 -1
- package/link/Link.stories.tsx +12 -5
- package/link/types.d.ts +1 -1
- package/package.json +10 -10
- 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 -2
- 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 +114 -93
- package/slider/Slider.stories.tsx +7 -1
- package/slider/Slider.test.js +121 -21
- package/slider/types.d.ts +2 -2
- package/switch/Switch.d.ts +1 -1
- package/switch/Switch.js +111 -55
- package/switch/Switch.stories.tsx +8 -30
- package/switch/Switch.test.js +122 -8
- package/switch/types.d.ts +3 -4
- package/tabs/Tab.d.ts +4 -0
- package/tabs/Tab.js +135 -0
- package/tabs/Tabs.js +360 -104
- package/tabs/Tabs.stories.tsx +74 -0
- package/tabs/Tabs.test.js +217 -6
- package/tabs/types.d.ts +15 -5
- package/tabs-nav/NavTabs.js +5 -5
- package/tabs-nav/Tab.js +3 -5
- package/tabs-nav/types.d.ts +1 -1
- package/tag/Tag.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.js +7 -5
- package/text-input/Suggestions.d.ts +4 -0
- package/text-input/Suggestions.js +134 -0
- package/text-input/TextInput.js +115 -222
- package/text-input/TextInput.stories.tsx +189 -182
- package/text-input/TextInput.test.js +163 -162
- package/text-input/types.d.ts +17 -3
- package/toggle-group/types.d.ts +1 -1
- package/wizard/types.d.ts +1 -1
package/tabs/Tab.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
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 _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
17
|
+
|
|
18
|
+
var _Badge = _interopRequireDefault(require("../badge/Badge"));
|
|
19
|
+
|
|
20
|
+
var _Typography = _interopRequireDefault(require("../typography/Typography"));
|
|
21
|
+
|
|
22
|
+
var _useTheme = _interopRequireDefault(require("../useTheme"));
|
|
23
|
+
|
|
24
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
25
|
+
|
|
26
|
+
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); }
|
|
27
|
+
|
|
28
|
+
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; }
|
|
29
|
+
|
|
30
|
+
var Tab = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
31
|
+
var active = _ref.active,
|
|
32
|
+
tab = _ref.tab,
|
|
33
|
+
tabIndex = _ref.tabIndex,
|
|
34
|
+
hasLabelAndIcon = _ref.hasLabelAndIcon,
|
|
35
|
+
iconPosition = _ref.iconPosition,
|
|
36
|
+
_onClick = _ref.onClick,
|
|
37
|
+
_onMouseEnter = _ref.onMouseEnter,
|
|
38
|
+
_onMouseLeave = _ref.onMouseLeave;
|
|
39
|
+
var colorsTheme = (0, _useTheme["default"])();
|
|
40
|
+
return /*#__PURE__*/_react["default"].createElement(TabContainer, {
|
|
41
|
+
role: "tab",
|
|
42
|
+
type: "button",
|
|
43
|
+
tabIndex: tabIndex,
|
|
44
|
+
disabled: tab.isDisabled,
|
|
45
|
+
"aria-disabled": tab.isDisabled,
|
|
46
|
+
"aria-selected": active,
|
|
47
|
+
hasLabelAndIcon: hasLabelAndIcon,
|
|
48
|
+
iconPosition: iconPosition,
|
|
49
|
+
ref: ref,
|
|
50
|
+
onClick: function onClick() {
|
|
51
|
+
_onClick();
|
|
52
|
+
},
|
|
53
|
+
onMouseEnter: function onMouseEnter() {
|
|
54
|
+
_onMouseEnter();
|
|
55
|
+
},
|
|
56
|
+
onMouseLeave: function onMouseLeave() {
|
|
57
|
+
_onMouseLeave();
|
|
58
|
+
}
|
|
59
|
+
}, /*#__PURE__*/_react["default"].createElement(MainLabelContainer, {
|
|
60
|
+
hasBadge: tab.notificationNumber,
|
|
61
|
+
hasLabelAndIcon: hasLabelAndIcon,
|
|
62
|
+
iconPosition: iconPosition
|
|
63
|
+
}, tab.icon && /*#__PURE__*/_react["default"].createElement(TabIconContainer, {
|
|
64
|
+
hasLabelAndIcon: hasLabelAndIcon,
|
|
65
|
+
iconPosition: iconPosition
|
|
66
|
+
}, typeof tab.icon === "string" ? /*#__PURE__*/_react["default"].createElement(TabIcon, {
|
|
67
|
+
src: tab.icon
|
|
68
|
+
}) : tab.icon), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
69
|
+
color: tab.isDisabled ? colorsTheme.tabs.disabledFontColor : active ? colorsTheme.tabs.selectedFontColor : colorsTheme.tabs.unselectedFontColor,
|
|
70
|
+
fontFamily: colorsTheme.tabs.fontFamily,
|
|
71
|
+
fontSize: colorsTheme.tabs.fontSize,
|
|
72
|
+
fontStyle: tab.isDisabled ? colorsTheme.tabs.disabledFontStyle : colorsTheme.tabs.fontStyle,
|
|
73
|
+
fontWeight: active ? colorsTheme.tabs.pressedFontWeight : colorsTheme.tabs.fontWeight,
|
|
74
|
+
textAlign: "center",
|
|
75
|
+
letterSpacing: "0.025em",
|
|
76
|
+
lineHeight: "1.715em"
|
|
77
|
+
}, tab.label)), tab.notificationNumber && tab.notificationNumber && /*#__PURE__*/_react["default"].createElement(BadgeContainer, {
|
|
78
|
+
hasLabelAndIcon: hasLabelAndIcon,
|
|
79
|
+
iconPosition: iconPosition
|
|
80
|
+
}, /*#__PURE__*/_react["default"].createElement(_Badge["default"], {
|
|
81
|
+
notificationText: tab.notificationNumber > 99 ? "+99" : tab.notificationNumber
|
|
82
|
+
})));
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
var TabContainer = _styledComponents["default"].button(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n text-transform: ", ";\n overflow: hidden;\n flex-shrink: 0;\n border: 0;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n user-select: none;\n vertical-align: middle;\n justify-content: center;\n min-width: 90px;\n max-width: 360px;\n padding: ", ";\n height: ", ";\n min-height: ", ";\n background-color: ", ";\n svg {\n color: ", ";\n }\n\n &:hover {\n background-color: ", ";\n }\n\n &:active {\n background-color: ", ";\n }\n\n &:focus {\n outline: ", " solid 1px;\n outline-offset: -1px;\n }\n\n &[aria-selected=\"true\"] {\n background-color: ", ";\n svg {\n color: ", ";\n }\n opacity: 1;\n }\n\n &[aria-disabled=\"true\"] {\n background-color: ", " !important;\n cursor: not-allowed !important;\n pointer-events: all;\n font-style: ", ";\n svg {\n color: ", ";\n }\n outline: none !important;\n > div {\n opacity: 0.5;\n }\n }\n"])), function (props) {
|
|
86
|
+
return props.theme.fontTextTransform;
|
|
87
|
+
}, function (props) {
|
|
88
|
+
return (!props.hasLabelAndIcon || props.hasLabelAndIcon && props.iconPosition !== "top") && "12px 16px" || "8px 16px";
|
|
89
|
+
}, function (props) {
|
|
90
|
+
return (!props.hasLabelAndIcon || props.hasLabelAndIcon && props.iconPosition !== "top") && "47px" || "71px";
|
|
91
|
+
}, function (props) {
|
|
92
|
+
return (!props.hasLabelAndIcon || props.hasLabelAndIcon && props.iconPosition !== "top") && "47px" || "71px";
|
|
93
|
+
}, function (props) {
|
|
94
|
+
return props.theme.unselectedBackgroundColor;
|
|
95
|
+
}, function (props) {
|
|
96
|
+
return props.theme.unselectedIconColor;
|
|
97
|
+
}, function (props) {
|
|
98
|
+
return "".concat(props.theme.hoverBackgroundColor, " !important");
|
|
99
|
+
}, function (props) {
|
|
100
|
+
return "".concat(props.theme.pressedBackgroundColor, " !important");
|
|
101
|
+
}, function (props) {
|
|
102
|
+
return props.theme.focusOutline;
|
|
103
|
+
}, function (props) {
|
|
104
|
+
return props.theme.selectedBackgroundColor;
|
|
105
|
+
}, function (props) {
|
|
106
|
+
return props.theme.selectedIconColor;
|
|
107
|
+
}, function (props) {
|
|
108
|
+
return props.theme.unselectedBackgroundColor;
|
|
109
|
+
}, function (props) {
|
|
110
|
+
return props.theme.disabledFontStyle;
|
|
111
|
+
}, function (props) {
|
|
112
|
+
return props.theme.disabledIconColor;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
var BadgeContainer = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n margin-left: 12px;\n height: 100%;\n display: flex;\n align-items: ", ";\n"])), function (props) {
|
|
116
|
+
return props.hasLabelAndIcon && props.iconPosition === "top" ? "flex-start" : "center";
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
var MainLabelContainer = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: ", ";\n align-items: center;\n margin-left: ", ";\n"])), function (props) {
|
|
120
|
+
return props.hasLabelAndIcon && props.iconPosition === "top" && "column" || "row";
|
|
121
|
+
}, function (props) {
|
|
122
|
+
return props.hasBadge ? typeof props.hasBadge === "number" ? "calc(".concat(props.theme.badgeWidthWithNotificationNumber, " + 12px)") : "calc(".concat(props.theme.badgeWidth, " + 12px)") : "unset";
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
var TabIconContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n max-height: 22px;\n max-width: 22px;\n margin-bottom: ", ";\n margin-right: ", ";\n overflow: hidden;\n display: flex;\n align-items: center;\n img,\n svg {\n height: 100%;\n width: 100%;\n }\n"])), function (props) {
|
|
126
|
+
return props.hasLabelAndIcon && props.iconPosition === "top" && "8px" || "";
|
|
127
|
+
}, function (props) {
|
|
128
|
+
return props.hasLabelAndIcon && props.iconPosition === "left" && "12px" || "";
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
var TabIcon = _styledComponents["default"].img(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n width: 100%;\n display: inline-flex;\n align-items: center;\n flex-direction: column;\n justify-content: center;\n"])));
|
|
132
|
+
|
|
133
|
+
var _default = /*#__PURE__*/_react["default"].memo(Tab);
|
|
134
|
+
|
|
135
|
+
exports["default"] = _default;
|