@laerdal/life-react-components 1.8.0-dev.19.full → 1.8.0-dev.20
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/dist/GlobalNavigationBar/GlobalNavigationBar.cjs +107 -176
- package/dist/GlobalNavigationBar/GlobalNavigationBar.cjs.map +1 -1
- package/dist/GlobalNavigationBar/GlobalNavigationBar.d.ts +13 -27
- package/dist/GlobalNavigationBar/GlobalNavigationBar.js +106 -176
- package/dist/GlobalNavigationBar/GlobalNavigationBar.js.map +1 -1
- package/dist/GlobalNavigationBar/Logo.cjs +3 -5
- package/dist/GlobalNavigationBar/Logo.cjs.map +1 -1
- package/dist/GlobalNavigationBar/Logo.js +1 -1
- package/dist/GlobalNavigationBar/Logo.js.map +1 -1
- package/dist/GlobalNavigationBar/NavigationHelper.cjs +38 -0
- package/dist/GlobalNavigationBar/NavigationHelper.cjs.map +1 -0
- package/dist/GlobalNavigationBar/NavigationHelper.d.ts +4 -0
- package/dist/GlobalNavigationBar/NavigationHelper.js +27 -0
- package/dist/GlobalNavigationBar/NavigationHelper.js.map +1 -0
- package/dist/GlobalNavigationBar/desktop/DesktopActions.cjs +127 -0
- package/dist/GlobalNavigationBar/desktop/DesktopActions.cjs.map +1 -0
- package/dist/GlobalNavigationBar/desktop/DesktopActions.d.ts +15 -0
- package/dist/GlobalNavigationBar/desktop/DesktopActions.js +98 -0
- package/dist/GlobalNavigationBar/desktop/DesktopActions.js.map +1 -0
- package/dist/GlobalNavigationBar/{ExtendedMainMenu.cjs → desktop/ExtendedMainMenu.cjs} +7 -9
- package/dist/GlobalNavigationBar/desktop/ExtendedMainMenu.cjs.map +1 -0
- package/dist/GlobalNavigationBar/{ExtendedMainMenu.d.ts → desktop/ExtendedMainMenu.d.ts} +2 -2
- package/dist/GlobalNavigationBar/{ExtendedMainMenu.js → desktop/ExtendedMainMenu.js} +6 -6
- package/dist/GlobalNavigationBar/desktop/ExtendedMainMenu.js.map +1 -0
- package/dist/GlobalNavigationBar/{MainMenu.cjs → desktop/MainMenu.cjs} +17 -21
- package/dist/GlobalNavigationBar/desktop/MainMenu.cjs.map +1 -0
- package/dist/GlobalNavigationBar/desktop/MainMenu.d.ts +8 -0
- package/dist/GlobalNavigationBar/{MainMenu.js → desktop/MainMenu.js} +17 -21
- package/dist/GlobalNavigationBar/desktop/MainMenu.js.map +1 -0
- package/dist/GlobalNavigationBar/{RightSideNav.cjs → desktop/RightSideNav.cjs} +22 -26
- package/dist/GlobalNavigationBar/desktop/RightSideNav.cjs.map +1 -0
- package/dist/GlobalNavigationBar/desktop/RightSideNav.d.ts +8 -0
- package/dist/GlobalNavigationBar/desktop/RightSideNav.js +59 -0
- package/dist/GlobalNavigationBar/desktop/RightSideNav.js.map +1 -0
- package/dist/GlobalNavigationBar/desktop/UserMenu.cjs +204 -0
- package/dist/GlobalNavigationBar/desktop/UserMenu.cjs.map +1 -0
- package/dist/GlobalNavigationBar/desktop/UserMenu.d.ts +7 -0
- package/dist/GlobalNavigationBar/desktop/UserMenu.js +163 -0
- package/dist/GlobalNavigationBar/desktop/UserMenu.js.map +1 -0
- package/dist/GlobalNavigationBar/index.cjs +15 -18
- package/dist/GlobalNavigationBar/index.cjs.map +1 -1
- package/dist/GlobalNavigationBar/index.d.ts +2 -2
- package/dist/GlobalNavigationBar/index.js +2 -2
- package/dist/GlobalNavigationBar/index.js.map +1 -1
- package/dist/GlobalNavigationBar/mobile/CommonStyles.cjs +15 -21
- package/dist/GlobalNavigationBar/mobile/CommonStyles.cjs.map +1 -1
- package/dist/GlobalNavigationBar/mobile/CommonStyles.d.ts +3 -6
- package/dist/GlobalNavigationBar/mobile/CommonStyles.js +14 -15
- package/dist/GlobalNavigationBar/mobile/CommonStyles.js.map +1 -1
- package/dist/GlobalNavigationBar/mobile/MobileMenu.cjs +114 -221
- package/dist/GlobalNavigationBar/mobile/MobileMenu.cjs.map +1 -1
- package/dist/GlobalNavigationBar/mobile/MobileMenu.d.ts +6 -25
- package/dist/GlobalNavigationBar/mobile/MobileMenu.js +113 -216
- package/dist/GlobalNavigationBar/mobile/MobileMenu.js.map +1 -1
- package/dist/GlobalNavigationBar/mobile/MobileMenuContent.cjs +221 -0
- package/dist/GlobalNavigationBar/mobile/MobileMenuContent.cjs.map +1 -0
- package/dist/GlobalNavigationBar/mobile/MobileMenuContent.d.ts +11 -0
- package/dist/GlobalNavigationBar/mobile/MobileMenuContent.js +184 -0
- package/dist/GlobalNavigationBar/mobile/MobileMenuContent.js.map +1 -0
- package/dist/GlobalNavigationBar/mobile/MobileMenuHeader.cjs +160 -0
- package/dist/GlobalNavigationBar/mobile/MobileMenuHeader.cjs.map +1 -0
- package/dist/GlobalNavigationBar/mobile/MobileMenuHeader.d.ts +12 -0
- package/dist/GlobalNavigationBar/mobile/MobileMenuHeader.js +139 -0
- package/dist/GlobalNavigationBar/mobile/MobileMenuHeader.js.map +1 -0
- package/dist/GlobalNavigationBar/types.cjs +6 -0
- package/dist/GlobalNavigationBar/types.cjs.map +1 -0
- package/dist/GlobalNavigationBar/types.d.ts +120 -0
- package/dist/GlobalNavigationBar/types.js +2 -0
- package/dist/GlobalNavigationBar/types.js.map +1 -0
- package/dist/MenuItem/MenuItem.cjs +16 -10
- package/dist/MenuItem/MenuItem.cjs.map +1 -1
- package/dist/MenuItem/MenuItem.d.ts +3 -3
- package/dist/MenuItem/MenuItem.js +14 -8
- package/dist/MenuItem/MenuItem.js.map +1 -1
- package/dist/ProfileButton/ProfileButton.cjs +20 -11
- package/dist/ProfileButton/ProfileButton.cjs.map +1 -1
- package/dist/ProfileButton/ProfileButton.d.ts +3 -1
- package/dist/ProfileButton/ProfileButton.js +18 -10
- package/dist/ProfileButton/ProfileButton.js.map +1 -1
- package/dist/Switcher/MobileSwitcherMenu.cjs +24 -78
- package/dist/Switcher/MobileSwitcherMenu.cjs.map +1 -1
- package/dist/Switcher/MobileSwitcherMenu.d.ts +6 -5
- package/dist/Switcher/MobileSwitcherMenu.js +26 -70
- package/dist/Switcher/MobileSwitcherMenu.js.map +1 -1
- package/dist/common/StackState.cjs +47 -0
- package/dist/common/StackState.cjs.map +1 -0
- package/dist/common/StackState.d.ts +7 -0
- package/dist/common/StackState.js +30 -0
- package/dist/common/StackState.js.map +1 -0
- package/dist/hooks/useClickOutside.cjs +6 -2
- package/dist/hooks/useClickOutside.cjs.map +1 -1
- package/dist/hooks/useClickOutside.d.ts +1 -1
- package/dist/hooks/useClickOutside.js +6 -2
- package/dist/hooks/useClickOutside.js.map +1 -1
- package/dist/index.cjs +8 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +0 -32
- package/dist/types.js.map +1 -1
- package/package.json +10 -8
- package/dist/GlobalNavigationBar/Actions.cjs +0 -185
- package/dist/GlobalNavigationBar/Actions.cjs.map +0 -1
- package/dist/GlobalNavigationBar/Actions.d.ts +0 -13
- package/dist/GlobalNavigationBar/Actions.js +0 -160
- package/dist/GlobalNavigationBar/Actions.js.map +0 -1
- package/dist/GlobalNavigationBar/Avatar.cjs +0 -104
- package/dist/GlobalNavigationBar/Avatar.cjs.map +0 -1
- package/dist/GlobalNavigationBar/Avatar.d.ts +0 -15
- package/dist/GlobalNavigationBar/Avatar.js +0 -77
- package/dist/GlobalNavigationBar/Avatar.js.map +0 -1
- package/dist/GlobalNavigationBar/ExtendedMainMenu.cjs.map +0 -1
- package/dist/GlobalNavigationBar/ExtendedMainMenu.js.map +0 -1
- package/dist/GlobalNavigationBar/MainMenu.cjs.map +0 -1
- package/dist/GlobalNavigationBar/MainMenu.d.ts +0 -8
- package/dist/GlobalNavigationBar/MainMenu.js.map +0 -1
- package/dist/GlobalNavigationBar/RightSideNav.cjs.map +0 -1
- package/dist/GlobalNavigationBar/RightSideNav.d.ts +0 -8
- package/dist/GlobalNavigationBar/RightSideNav.js +0 -61
- package/dist/GlobalNavigationBar/RightSideNav.js.map +0 -1
- package/dist/GlobalNavigationBar/UserMenu/MenuLink.cjs +0 -112
- package/dist/GlobalNavigationBar/UserMenu/MenuLink.cjs.map +0 -1
- package/dist/GlobalNavigationBar/UserMenu/MenuLink.d.ts +0 -11
- package/dist/GlobalNavigationBar/UserMenu/MenuLink.js +0 -86
- package/dist/GlobalNavigationBar/UserMenu/MenuLink.js.map +0 -1
- package/dist/GlobalNavigationBar/UserMenu/MobileUserMenu.cjs +0 -178
- package/dist/GlobalNavigationBar/UserMenu/MobileUserMenu.cjs.map +0 -1
- package/dist/GlobalNavigationBar/UserMenu/MobileUserMenu.d.ts +0 -16
- package/dist/GlobalNavigationBar/UserMenu/MobileUserMenu.js +0 -146
- package/dist/GlobalNavigationBar/UserMenu/MobileUserMenu.js.map +0 -1
- package/dist/GlobalNavigationBar/UserMenu/UserMenu.cjs +0 -168
- package/dist/GlobalNavigationBar/UserMenu/UserMenu.cjs.map +0 -1
- package/dist/GlobalNavigationBar/UserMenu/UserMenu.d.ts +0 -15
- package/dist/GlobalNavigationBar/UserMenu/UserMenu.js +0 -135
- package/dist/GlobalNavigationBar/UserMenu/UserMenu.js.map +0 -1
- package/dist/GlobalNavigationBar/mobile/ExitMenuButton.cjs +0 -49
- package/dist/GlobalNavigationBar/mobile/ExitMenuButton.cjs.map +0 -1
- package/dist/GlobalNavigationBar/mobile/ExitMenuButton.d.ts +0 -6
- package/dist/GlobalNavigationBar/mobile/ExitMenuButton.js +0 -27
- package/dist/GlobalNavigationBar/mobile/ExitMenuButton.js.map +0 -1
- package/dist/GlobalNavigationBar/mobile/MobileActionMenu.cjs +0 -91
- package/dist/GlobalNavigationBar/mobile/MobileActionMenu.cjs.map +0 -1
- package/dist/GlobalNavigationBar/mobile/MobileActionMenu.d.ts +0 -13
- package/dist/GlobalNavigationBar/mobile/MobileActionMenu.js +0 -70
- package/dist/GlobalNavigationBar/mobile/MobileActionMenu.js.map +0 -1
|
@@ -0,0 +1,160 @@
|
|
|
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
+
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
|
+
|
|
18
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
19
|
+
|
|
20
|
+
var _breakpoints = _interopRequireDefault(require("../../styles/breakpoints"));
|
|
21
|
+
|
|
22
|
+
var _Button = require("../../Button");
|
|
23
|
+
|
|
24
|
+
var _icons = require("../../icons");
|
|
25
|
+
|
|
26
|
+
var _styles = require("../../styles");
|
|
27
|
+
|
|
28
|
+
var _ProfileButton = require("../../ProfileButton");
|
|
29
|
+
|
|
30
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
31
|
+
|
|
32
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
33
|
+
|
|
34
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
35
|
+
|
|
36
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
37
|
+
|
|
38
|
+
var MobileMenuHeaderActions = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n flex: 1;\n justify-content: flex-end;\n display: flex;\n flex-direction: row;\n"])));
|
|
39
|
+
|
|
40
|
+
var MobileMenuHeaderLabel = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n ", " {\n ", "\n }\n"])), (0, _styles.ComponentXSStyling)(_styles.ComponentTextStyle.Bold, _styles.COLORS.neutral_600), _styles.BREAKPOINTS.SMALL, (0, _styles.ComponentSStyling)(_styles.ComponentTextStyle.Bold, _styles.COLORS.neutral_600));
|
|
41
|
+
|
|
42
|
+
var MobileMenuHeaderWrapper = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 0 4px;\n\n ", " {\n padding: 4px 8px;\n }\n\n ", " {\n display: none;\n }\n"])), _breakpoints.default.SMALL, _breakpoints.default.MEDIUM);
|
|
43
|
+
|
|
44
|
+
var MobileMenuHeader = function MobileMenuHeader(_ref) {
|
|
45
|
+
var onGoBack = _ref.onGoBack,
|
|
46
|
+
onClose = _ref.onClose,
|
|
47
|
+
label = _ref.label,
|
|
48
|
+
profile = _ref.profile,
|
|
49
|
+
buttons = _ref.buttons,
|
|
50
|
+
onSubMenuOpen = _ref.onSubMenuOpen;
|
|
51
|
+
|
|
52
|
+
var buildProfileSubMenu = function buildProfileSubMenu() {
|
|
53
|
+
var _profile$signOut, _profile$signOut2, _profile$signOut3, _profile$signOut4;
|
|
54
|
+
|
|
55
|
+
return !!profile ? {
|
|
56
|
+
type: 'group',
|
|
57
|
+
label: profile.label,
|
|
58
|
+
header: {
|
|
59
|
+
header: profile.user.firstName + ' ' + profile.user.lastName,
|
|
60
|
+
note: profile.user.email,
|
|
61
|
+
link: profile.user.link
|
|
62
|
+
},
|
|
63
|
+
action: {
|
|
64
|
+
label: (_profile$signOut = profile.signOut) === null || _profile$signOut === void 0 ? void 0 : _profile$signOut.label,
|
|
65
|
+
action: (_profile$signOut2 = profile.signOut) === null || _profile$signOut2 === void 0 ? void 0 : _profile$signOut2.action,
|
|
66
|
+
icon: (_profile$signOut3 = profile.signOut) === null || _profile$signOut3 === void 0 ? void 0 : _profile$signOut3.icon,
|
|
67
|
+
disabled: (_profile$signOut4 = profile.signOut) === null || _profile$signOut4 === void 0 ? void 0 : _profile$signOut4.disabled
|
|
68
|
+
},
|
|
69
|
+
items: profile.sections.map(function (a) {
|
|
70
|
+
return _objectSpread(_objectSpread({}, a), {}, {
|
|
71
|
+
type: 'section'
|
|
72
|
+
});
|
|
73
|
+
})
|
|
74
|
+
} : undefined;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var renderItem = function renderItem(item, index) {
|
|
78
|
+
var _profile$user$firstNa, _profile$user, _profile$user$firstNa2, _profile$user$lastNam, _profile$user2, _profile$user2$lastNa;
|
|
79
|
+
|
|
80
|
+
switch (item.type) {
|
|
81
|
+
case 'profile':
|
|
82
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProfileButton.ProfileButton, {
|
|
83
|
+
onClick: function onClick(e) {
|
|
84
|
+
e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
|
|
85
|
+
item.action ? item.action(e === null || e === void 0 ? void 0 : e.target) && onClose() : onSubMenuOpen && onSubMenuOpen(buildProfileSubMenu());
|
|
86
|
+
},
|
|
87
|
+
icon: !profile && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SystemIcons.User, {}),
|
|
88
|
+
initials: ((_profile$user$firstNa = profile === null || profile === void 0 ? void 0 : (_profile$user = profile.user) === null || _profile$user === void 0 ? void 0 : (_profile$user$firstNa2 = _profile$user.firstName) === null || _profile$user$firstNa2 === void 0 ? void 0 : _profile$user$firstNa2.charAt(0)) !== null && _profile$user$firstNa !== void 0 ? _profile$user$firstNa : '') + ((_profile$user$lastNam = profile === null || profile === void 0 ? void 0 : (_profile$user2 = profile.user) === null || _profile$user2 === void 0 ? void 0 : (_profile$user2$lastNa = _profile$user2.lastName) === null || _profile$user2$lastNa === void 0 ? void 0 : _profile$user2$lastNa.charAt(0)) !== null && _profile$user$lastNam !== void 0 ? _profile$user$lastNam : '')
|
|
89
|
+
}, index);
|
|
90
|
+
|
|
91
|
+
case 'submenu':
|
|
92
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, {
|
|
93
|
+
disabled: item.disabled,
|
|
94
|
+
variant: 'secondary',
|
|
95
|
+
shape: 'circular',
|
|
96
|
+
action: function action(e) {
|
|
97
|
+
e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
|
|
98
|
+
onSubMenuOpen && onSubMenuOpen(item.menu);
|
|
99
|
+
},
|
|
100
|
+
children: item.icon
|
|
101
|
+
}, index);
|
|
102
|
+
|
|
103
|
+
case 'action':
|
|
104
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, {
|
|
105
|
+
disabled: item.disabled,
|
|
106
|
+
variant: 'secondary',
|
|
107
|
+
shape: 'circular',
|
|
108
|
+
action: function action(e) {
|
|
109
|
+
e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
|
|
110
|
+
item.action && item.action(e === null || e === void 0 ? void 0 : e.target) && onClose();
|
|
111
|
+
},
|
|
112
|
+
children: item.icon
|
|
113
|
+
}, index);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(MobileMenuHeaderWrapper, {
|
|
118
|
+
children: [onGoBack && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, {
|
|
119
|
+
action: function action(e) {
|
|
120
|
+
e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
|
|
121
|
+
onGoBack();
|
|
122
|
+
},
|
|
123
|
+
variant: 'secondary',
|
|
124
|
+
shape: 'circular',
|
|
125
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SystemIcons.ArrowLineLeft, {})
|
|
126
|
+
}), buttons === null || buttons === void 0 ? void 0 : buttons.filter(function (a) {
|
|
127
|
+
return a.placement === 'left';
|
|
128
|
+
}).map(renderItem), label && /*#__PURE__*/(0, _jsxRuntime.jsx)(MobileMenuHeaderLabel, {
|
|
129
|
+
children: label
|
|
130
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(MobileMenuHeaderActions, {
|
|
131
|
+
children: [buttons === null || buttons === void 0 ? void 0 : buttons.filter(function (a) {
|
|
132
|
+
return a.placement !== 'left';
|
|
133
|
+
}).map(renderItem), onClose && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
134
|
+
style: {
|
|
135
|
+
marginLeft: '8px'
|
|
136
|
+
},
|
|
137
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, {
|
|
138
|
+
variant: 'secondary',
|
|
139
|
+
action: function action(e) {
|
|
140
|
+
e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
|
|
141
|
+
onClose();
|
|
142
|
+
},
|
|
143
|
+
shape: 'circular',
|
|
144
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SystemIcons.Close, {})
|
|
145
|
+
})
|
|
146
|
+
})]
|
|
147
|
+
})]
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
MobileMenuHeader.propTypes = {
|
|
152
|
+
onGoBack: _propTypes.default.func,
|
|
153
|
+
onClose: _propTypes.default.func.isRequired,
|
|
154
|
+
label: _propTypes.default.string,
|
|
155
|
+
buttons: _propTypes.default.array,
|
|
156
|
+
onSubMenuOpen: _propTypes.default.func
|
|
157
|
+
};
|
|
158
|
+
var _default = MobileMenuHeader;
|
|
159
|
+
exports.default = _default;
|
|
160
|
+
//# sourceMappingURL=MobileMenuHeader.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/GlobalNavigationBar/mobile/MobileMenuHeader.tsx"],"names":["MobileMenuHeaderActions","styled","div","MobileMenuHeaderLabel","ComponentTextStyle","Bold","COLORS","neutral_600","BREAKPOINTS","SMALL","MobileMenuHeaderWrapper","Breakpoints","MEDIUM","MobileMenuHeader","onGoBack","onClose","label","profile","buttons","onSubMenuOpen","buildProfileSubMenu","type","header","user","firstName","lastName","note","email","link","action","signOut","icon","disabled","items","sections","map","a","undefined","renderItem","item","index","e","nativeEvent","stopImmediatePropagation","target","charAt","menu","filter","placement","marginLeft"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,uBAAuB,GAAGC,0BAAOC,GAAV,yKAA7B;;AAMA,IAAMC,qBAAqB,GAAGF,0BAAOC,GAAV,yHACvB,gCAAmBE,2BAAmBC,IAAtC,EAA4CC,eAAOC,WAAnD,CADuB,EAEvBC,oBAAYC,KAFW,EAGrB,+BAAkBL,2BAAmBC,IAArC,EAA2CC,eAAOC,WAAlD,CAHqB,CAA3B;;AAOA,IAAMG,uBAAuB,GAAGT,0BAAOC,GAAV,0PAMzBS,qBAAYF,KANa,EAUzBE,qBAAYC,MAVa,CAA7B;;AA2BA,IAAMC,gBAAgE,GAAG,SAAnEA,gBAAmE,OAOO;AAAA,MANJC,QAMI,QANJA,QAMI;AAAA,MALJC,OAKI,QALJA,OAKI;AAAA,MAJJC,KAII,QAJJA,KAII;AAAA,MAHJC,OAGI,QAHJA,OAGI;AAAA,MAFJC,OAEI,QAFJA,OAEI;AAAA,MADJC,aACI,QADJA,aACI;;AAE9E,MAAMC,mBAAmB,GAAG,SAAtBA,mBAAsB;AAAA;;AAAA,WAAM,CAAC,CAACH,OAAF,GA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CAAC,WAAD,YAAAA,CAAC,CAAEC,WAAH,CAAeC,wBAAf;AACA5B,YAAAA,OAAO;AACR,WAJb;AAKY,UAAA,KAAK,EAAE,UALnB;AAAA,iCAME,qBAAC,kBAAD,CAAa,KAAb;AANF;AADF,QAPJ;AAAA,MAnBF;AAAA,IADF;AA0CD,CAxGD;;;AAXED,EAAAA,Q;AACAC,EAAAA,O;AACAC,EAAAA,K;AAGAE,EAAAA,O;AAEAC,EAAAA,a;;eA+GaN,gB","sourcesContent":["import React, {useImperativeHandle} from 'react';\nimport {\n MenuAccountInfo, MobileMenuButtonTypes,\n MenuIconButton,\n MenuIconSubMenuButton,\n MenuNavigationItemTypeGroup,\n MenuProfileButton, ProfileMenu, MenuNavigationCustomSubMenu\n} from '../types';\nimport styled from 'styled-components';\nimport Breakpoints from '../../styles/breakpoints';\nimport {IconButton} from '../../Button';\nimport {SystemIcons} from '../../icons';\nimport {BREAKPOINTS, COLORS, ComponentSStyling, ComponentTextStyle, ComponentXSStyling} from '../../styles';\nimport {ProfileButton} from '../../ProfileButton';\n\nconst MobileMenuHeaderActions = styled.div`\n flex: 1;\n justify-content: flex-end;\n display: flex;\n flex-direction: row;\n`;\nconst MobileMenuHeaderLabel = styled.div`\n ${ComponentXSStyling(ComponentTextStyle.Bold, COLORS.neutral_600)}\n ${BREAKPOINTS.SMALL} {\n ${ComponentSStyling(ComponentTextStyle.Bold, COLORS.neutral_600)}\n }\n`;\n\nconst MobileMenuHeaderWrapper = styled.div`\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 0 4px;\n\n ${Breakpoints.SMALL} {\n padding: 4px 8px;\n }\n\n ${Breakpoints.MEDIUM} {\n display: none;\n }\n`\n\ninterface MobileMenuHeaderProps {\n onGoBack?: () => void;\n onClose: () => void;\n label?: string;\n\n profile?: ProfileMenu\n buttons?: MobileMenuButtonTypes[];\n\n onSubMenuOpen?: (item?: MenuNavigationItemTypeGroup | MenuNavigationCustomSubMenu) => void;\n}\n\n\nconst MobileMenuHeader: React.FunctionComponent<MobileMenuHeaderProps> = ({\n onGoBack,\n onClose,\n label,\n profile,\n buttons,\n onSubMenuOpen\n }) => {\n\n const buildProfileSubMenu = () => !!profile ? {\n type: 'group',\n label: profile.label,\n header: {\n header: profile.user.firstName + ' ' + profile.user.lastName,\n note: profile.user.email,\n link: profile.user.link\n },\n action: {\n label: profile.signOut?.label,\n action: profile.signOut?.action,\n icon: profile.signOut?.icon,\n disabled: profile.signOut?.disabled\n },\n items: profile.sections.map(a => ({...a, type: 'section'}))\n } as MenuNavigationItemTypeGroup : undefined\n\n\n const renderItem = (item: MobileMenuButtonTypes, index: number) => {\n switch (item.type) {\n case 'profile':\n return <ProfileButton key={index}\n onClick={e => {\n e?.nativeEvent.stopImmediatePropagation();\n item.action ? item.action(e?.target) && onClose() : onSubMenuOpen && onSubMenuOpen(buildProfileSubMenu())\n }}\n icon={!profile && <SystemIcons.User/>}\n initials={(profile?.user?.firstName?.charAt(0) ?? '') + (profile?.user?.lastName?.charAt(0) ?? '')}/>\n case 'submenu':\n return <IconButton key={index}\n disabled={item.disabled}\n variant={'secondary'}\n shape={'circular'}\n action={e => {\n e?.nativeEvent.stopImmediatePropagation();\n onSubMenuOpen && onSubMenuOpen(item.menu)\n }}>\n {item.icon}\n </IconButton>\n case 'action':\n return <IconButton key={index}\n disabled={item.disabled}\n variant={'secondary'}\n shape={'circular'}\n action={e => {\n e?.nativeEvent.stopImmediatePropagation();\n item.action && item.action(e?.target) && onClose();\n }}>\n {item.icon}\n </IconButton>\n }\n }\n\n return (\n <MobileMenuHeaderWrapper>\n {\n onGoBack &&\n <IconButton action={e => {\n e?.nativeEvent.stopImmediatePropagation();\n onGoBack();\n }}\n variant={'secondary'}\n shape={'circular'}>\n <SystemIcons.ArrowLineLeft/>\n </IconButton>\n }\n {\n buttons?.filter(a => a.placement === 'left').map(renderItem)\n }\n {\n label &&\n <MobileMenuHeaderLabel>{label}</MobileMenuHeaderLabel>\n }\n <MobileMenuHeaderActions>\n {\n buttons?.filter(a => a.placement !== 'left').map(renderItem)\n }\n\n {\n onClose &&\n <div style={{marginLeft: '8px'}}>\n <IconButton variant={'secondary'}\n action={e => {\n e?.nativeEvent.stopImmediatePropagation();\n onClose();\n }}\n shape={'circular'}>\n <SystemIcons.Close/>\n </IconButton>\n </div>\n }\n </MobileMenuHeaderActions>\n\n </MobileMenuHeaderWrapper>\n )\n};\n\n\nexport default MobileMenuHeader;\n"],"file":"MobileMenuHeader.cjs"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MobileMenuButtonTypes, MenuNavigationItemTypeGroup, ProfileMenu, MenuNavigationCustomSubMenu } from '../types';
|
|
3
|
+
interface MobileMenuHeaderProps {
|
|
4
|
+
onGoBack?: () => void;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
label?: string;
|
|
7
|
+
profile?: ProfileMenu;
|
|
8
|
+
buttons?: MobileMenuButtonTypes[];
|
|
9
|
+
onSubMenuOpen?: (item?: MenuNavigationItemTypeGroup | MenuNavigationCustomSubMenu) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const MobileMenuHeader: React.FunctionComponent<MobileMenuHeaderProps>;
|
|
12
|
+
export default MobileMenuHeader;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
3
|
+
import _pt from "prop-types";
|
|
4
|
+
|
|
5
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
6
|
+
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
+
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import styled from 'styled-components';
|
|
13
|
+
import Breakpoints from '../../styles/breakpoints';
|
|
14
|
+
import { IconButton } from '../../Button';
|
|
15
|
+
import { SystemIcons } from '../../icons';
|
|
16
|
+
import { BREAKPOINTS, COLORS, ComponentSStyling, ComponentTextStyle, ComponentXSStyling } from '../../styles';
|
|
17
|
+
import { ProfileButton } from '../../ProfileButton';
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
|
+
var MobileMenuHeaderActions = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n flex: 1;\n justify-content: flex-end;\n display: flex;\n flex-direction: row;\n"])));
|
|
21
|
+
var MobileMenuHeaderLabel = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n ", " {\n ", "\n }\n"])), ComponentXSStyling(ComponentTextStyle.Bold, COLORS.neutral_600), BREAKPOINTS.SMALL, ComponentSStyling(ComponentTextStyle.Bold, COLORS.neutral_600));
|
|
22
|
+
var MobileMenuHeaderWrapper = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 0 4px;\n\n ", " {\n padding: 4px 8px;\n }\n\n ", " {\n display: none;\n }\n"])), Breakpoints.SMALL, Breakpoints.MEDIUM);
|
|
23
|
+
|
|
24
|
+
var MobileMenuHeader = function MobileMenuHeader(_ref) {
|
|
25
|
+
var onGoBack = _ref.onGoBack,
|
|
26
|
+
onClose = _ref.onClose,
|
|
27
|
+
label = _ref.label,
|
|
28
|
+
profile = _ref.profile,
|
|
29
|
+
buttons = _ref.buttons,
|
|
30
|
+
onSubMenuOpen = _ref.onSubMenuOpen;
|
|
31
|
+
|
|
32
|
+
var buildProfileSubMenu = function buildProfileSubMenu() {
|
|
33
|
+
var _profile$signOut, _profile$signOut2, _profile$signOut3, _profile$signOut4;
|
|
34
|
+
|
|
35
|
+
return !!profile ? {
|
|
36
|
+
type: 'group',
|
|
37
|
+
label: profile.label,
|
|
38
|
+
header: {
|
|
39
|
+
header: profile.user.firstName + ' ' + profile.user.lastName,
|
|
40
|
+
note: profile.user.email,
|
|
41
|
+
link: profile.user.link
|
|
42
|
+
},
|
|
43
|
+
action: {
|
|
44
|
+
label: (_profile$signOut = profile.signOut) === null || _profile$signOut === void 0 ? void 0 : _profile$signOut.label,
|
|
45
|
+
action: (_profile$signOut2 = profile.signOut) === null || _profile$signOut2 === void 0 ? void 0 : _profile$signOut2.action,
|
|
46
|
+
icon: (_profile$signOut3 = profile.signOut) === null || _profile$signOut3 === void 0 ? void 0 : _profile$signOut3.icon,
|
|
47
|
+
disabled: (_profile$signOut4 = profile.signOut) === null || _profile$signOut4 === void 0 ? void 0 : _profile$signOut4.disabled
|
|
48
|
+
},
|
|
49
|
+
items: profile.sections.map(function (a) {
|
|
50
|
+
return _objectSpread(_objectSpread({}, a), {}, {
|
|
51
|
+
type: 'section'
|
|
52
|
+
});
|
|
53
|
+
})
|
|
54
|
+
} : undefined;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var renderItem = function renderItem(item, index) {
|
|
58
|
+
var _profile$user$firstNa, _profile$user, _profile$user$firstNa2, _profile$user$lastNam, _profile$user2, _profile$user2$lastNa;
|
|
59
|
+
|
|
60
|
+
switch (item.type) {
|
|
61
|
+
case 'profile':
|
|
62
|
+
return /*#__PURE__*/_jsx(ProfileButton, {
|
|
63
|
+
onClick: function onClick(e) {
|
|
64
|
+
e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
|
|
65
|
+
item.action ? item.action(e === null || e === void 0 ? void 0 : e.target) && onClose() : onSubMenuOpen && onSubMenuOpen(buildProfileSubMenu());
|
|
66
|
+
},
|
|
67
|
+
icon: !profile && /*#__PURE__*/_jsx(SystemIcons.User, {}),
|
|
68
|
+
initials: ((_profile$user$firstNa = profile === null || profile === void 0 ? void 0 : (_profile$user = profile.user) === null || _profile$user === void 0 ? void 0 : (_profile$user$firstNa2 = _profile$user.firstName) === null || _profile$user$firstNa2 === void 0 ? void 0 : _profile$user$firstNa2.charAt(0)) !== null && _profile$user$firstNa !== void 0 ? _profile$user$firstNa : '') + ((_profile$user$lastNam = profile === null || profile === void 0 ? void 0 : (_profile$user2 = profile.user) === null || _profile$user2 === void 0 ? void 0 : (_profile$user2$lastNa = _profile$user2.lastName) === null || _profile$user2$lastNa === void 0 ? void 0 : _profile$user2$lastNa.charAt(0)) !== null && _profile$user$lastNam !== void 0 ? _profile$user$lastNam : '')
|
|
69
|
+
}, index);
|
|
70
|
+
|
|
71
|
+
case 'submenu':
|
|
72
|
+
return /*#__PURE__*/_jsx(IconButton, {
|
|
73
|
+
disabled: item.disabled,
|
|
74
|
+
variant: 'secondary',
|
|
75
|
+
shape: 'circular',
|
|
76
|
+
action: function action(e) {
|
|
77
|
+
e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
|
|
78
|
+
onSubMenuOpen && onSubMenuOpen(item.menu);
|
|
79
|
+
},
|
|
80
|
+
children: item.icon
|
|
81
|
+
}, index);
|
|
82
|
+
|
|
83
|
+
case 'action':
|
|
84
|
+
return /*#__PURE__*/_jsx(IconButton, {
|
|
85
|
+
disabled: item.disabled,
|
|
86
|
+
variant: 'secondary',
|
|
87
|
+
shape: 'circular',
|
|
88
|
+
action: function action(e) {
|
|
89
|
+
e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
|
|
90
|
+
item.action && item.action(e === null || e === void 0 ? void 0 : e.target) && onClose();
|
|
91
|
+
},
|
|
92
|
+
children: item.icon
|
|
93
|
+
}, index);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return /*#__PURE__*/_jsxs(MobileMenuHeaderWrapper, {
|
|
98
|
+
children: [onGoBack && /*#__PURE__*/_jsx(IconButton, {
|
|
99
|
+
action: function action(e) {
|
|
100
|
+
e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
|
|
101
|
+
onGoBack();
|
|
102
|
+
},
|
|
103
|
+
variant: 'secondary',
|
|
104
|
+
shape: 'circular',
|
|
105
|
+
children: /*#__PURE__*/_jsx(SystemIcons.ArrowLineLeft, {})
|
|
106
|
+
}), buttons === null || buttons === void 0 ? void 0 : buttons.filter(function (a) {
|
|
107
|
+
return a.placement === 'left';
|
|
108
|
+
}).map(renderItem), label && /*#__PURE__*/_jsx(MobileMenuHeaderLabel, {
|
|
109
|
+
children: label
|
|
110
|
+
}), /*#__PURE__*/_jsxs(MobileMenuHeaderActions, {
|
|
111
|
+
children: [buttons === null || buttons === void 0 ? void 0 : buttons.filter(function (a) {
|
|
112
|
+
return a.placement !== 'left';
|
|
113
|
+
}).map(renderItem), onClose && /*#__PURE__*/_jsx("div", {
|
|
114
|
+
style: {
|
|
115
|
+
marginLeft: '8px'
|
|
116
|
+
},
|
|
117
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
|
118
|
+
variant: 'secondary',
|
|
119
|
+
action: function action(e) {
|
|
120
|
+
e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
|
|
121
|
+
onClose();
|
|
122
|
+
},
|
|
123
|
+
shape: 'circular',
|
|
124
|
+
children: /*#__PURE__*/_jsx(SystemIcons.Close, {})
|
|
125
|
+
})
|
|
126
|
+
})]
|
|
127
|
+
})]
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
MobileMenuHeader.propTypes = {
|
|
132
|
+
onGoBack: _pt.func,
|
|
133
|
+
onClose: _pt.func.isRequired,
|
|
134
|
+
label: _pt.string,
|
|
135
|
+
buttons: _pt.array,
|
|
136
|
+
onSubMenuOpen: _pt.func
|
|
137
|
+
};
|
|
138
|
+
export default MobileMenuHeader;
|
|
139
|
+
//# sourceMappingURL=MobileMenuHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/GlobalNavigationBar/mobile/MobileMenuHeader.tsx"],"names":["React","styled","Breakpoints","IconButton","SystemIcons","BREAKPOINTS","COLORS","ComponentSStyling","ComponentTextStyle","ComponentXSStyling","ProfileButton","MobileMenuHeaderActions","div","MobileMenuHeaderLabel","Bold","neutral_600","SMALL","MobileMenuHeaderWrapper","MEDIUM","MobileMenuHeader","onGoBack","onClose","label","profile","buttons","onSubMenuOpen","buildProfileSubMenu","type","header","user","firstName","lastName","note","email","link","action","signOut","icon","disabled","items","sections","map","a","undefined","renderItem","item","index","e","nativeEvent","stopImmediatePropagation","target","charAt","menu","filter","placement","marginLeft"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAP,MAAyC,OAAzC;AAQA,OAAOC,MAAP,MAAmB,mBAAnB;AACA,OAAOC,WAAP,MAAwB,0BAAxB;AACA,SAAQC,UAAR,QAAyB,cAAzB;AACA,SAAQC,WAAR,QAA0B,aAA1B;AACA,SAAQC,WAAR,EAAqBC,MAArB,EAA6BC,iBAA7B,EAAgDC,kBAAhD,EAAoEC,kBAApE,QAA6F,cAA7F;AACA,SAAQC,aAAR,QAA4B,qBAA5B;;;AAEA,IAAMC,uBAAuB,GAAGV,MAAM,CAACW,GAAV,2JAA7B;AAMA,IAAMC,qBAAqB,GAAGZ,MAAM,CAACW,GAAV,2GACvBH,kBAAkB,CAACD,kBAAkB,CAACM,IAApB,EAA0BR,MAAM,CAACS,WAAjC,CADK,EAEvBV,WAAW,CAACW,KAFW,EAGrBT,iBAAiB,CAACC,kBAAkB,CAACM,IAApB,EAA0BR,MAAM,CAACS,WAAjC,C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BJ,eAmBE,MAAC,uBAAD;AAAA,iBAEIE,OAFJ,aAEIA,OAFJ,uBAEIA,OAAO,CAAE6B,MAAT,CAAgB,UAAAX,CAAC;AAAA,eAAIA,CAAC,CAACY,SAAF,KAAgB,MAApB;AAAA,OAAjB,EAA6Cb,GAA7C,CAAiDG,UAAjD,CAFJ,EAMIvB,OAAO,iBACP;AAAK,QAAA,KAAK,EAAE;AAACkC,UAAAA,UAAU,EAAE;AAAb,SAAZ;AAAA,+BACE,KAAC,UAAD;AAAY,UAAA,OAAO,EAAE,WAArB;AACY,UAAA,MAAM,EAAE,gBAAAR,CAAC,EAAI;AACXA,YAAAA,CAAC,SAAD,IAAAA,CAAC,WAAD,YAAAA,CAAC,CAAEC,WAAH,CAAeC,wBAAf;AACA5B,YAAAA,OAAO;AACR,WAJb;AAKY,UAAA,KAAK,EAAE,UALnB;AAAA,iCAME,KAAC,WAAD,CAAa,KAAb;AANF;AADF,QAPJ;AAAA,MAnBF;AAAA,IADF;AA0CD,CAxGD;;;AAXED,EAAAA,Q;AACAC,EAAAA,O;AACAC,EAAAA,K;AAGAE,EAAAA,O;AAEAC,EAAAA,a;;AA+GF,eAAeN,gBAAf","sourcesContent":["import React, {useImperativeHandle} from 'react';\nimport {\n MenuAccountInfo, MobileMenuButtonTypes,\n MenuIconButton,\n MenuIconSubMenuButton,\n MenuNavigationItemTypeGroup,\n MenuProfileButton, ProfileMenu, MenuNavigationCustomSubMenu\n} from '../types';\nimport styled from 'styled-components';\nimport Breakpoints from '../../styles/breakpoints';\nimport {IconButton} from '../../Button';\nimport {SystemIcons} from '../../icons';\nimport {BREAKPOINTS, COLORS, ComponentSStyling, ComponentTextStyle, ComponentXSStyling} from '../../styles';\nimport {ProfileButton} from '../../ProfileButton';\n\nconst MobileMenuHeaderActions = styled.div`\n flex: 1;\n justify-content: flex-end;\n display: flex;\n flex-direction: row;\n`;\nconst MobileMenuHeaderLabel = styled.div`\n ${ComponentXSStyling(ComponentTextStyle.Bold, COLORS.neutral_600)}\n ${BREAKPOINTS.SMALL} {\n ${ComponentSStyling(ComponentTextStyle.Bold, COLORS.neutral_600)}\n }\n`;\n\nconst MobileMenuHeaderWrapper = styled.div`\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 0 4px;\n\n ${Breakpoints.SMALL} {\n padding: 4px 8px;\n }\n\n ${Breakpoints.MEDIUM} {\n display: none;\n }\n`\n\ninterface MobileMenuHeaderProps {\n onGoBack?: () => void;\n onClose: () => void;\n label?: string;\n\n profile?: ProfileMenu\n buttons?: MobileMenuButtonTypes[];\n\n onSubMenuOpen?: (item?: MenuNavigationItemTypeGroup | MenuNavigationCustomSubMenu) => void;\n}\n\n\nconst MobileMenuHeader: React.FunctionComponent<MobileMenuHeaderProps> = ({\n onGoBack,\n onClose,\n label,\n profile,\n buttons,\n onSubMenuOpen\n }) => {\n\n const buildProfileSubMenu = () => !!profile ? {\n type: 'group',\n label: profile.label,\n header: {\n header: profile.user.firstName + ' ' + profile.user.lastName,\n note: profile.user.email,\n link: profile.user.link\n },\n action: {\n label: profile.signOut?.label,\n action: profile.signOut?.action,\n icon: profile.signOut?.icon,\n disabled: profile.signOut?.disabled\n },\n items: profile.sections.map(a => ({...a, type: 'section'}))\n } as MenuNavigationItemTypeGroup : undefined\n\n\n const renderItem = (item: MobileMenuButtonTypes, index: number) => {\n switch (item.type) {\n case 'profile':\n return <ProfileButton key={index}\n onClick={e => {\n e?.nativeEvent.stopImmediatePropagation();\n item.action ? item.action(e?.target) && onClose() : onSubMenuOpen && onSubMenuOpen(buildProfileSubMenu())\n }}\n icon={!profile && <SystemIcons.User/>}\n initials={(profile?.user?.firstName?.charAt(0) ?? '') + (profile?.user?.lastName?.charAt(0) ?? '')}/>\n case 'submenu':\n return <IconButton key={index}\n disabled={item.disabled}\n variant={'secondary'}\n shape={'circular'}\n action={e => {\n e?.nativeEvent.stopImmediatePropagation();\n onSubMenuOpen && onSubMenuOpen(item.menu)\n }}>\n {item.icon}\n </IconButton>\n case 'action':\n return <IconButton key={index}\n disabled={item.disabled}\n variant={'secondary'}\n shape={'circular'}\n action={e => {\n e?.nativeEvent.stopImmediatePropagation();\n item.action && item.action(e?.target) && onClose();\n }}>\n {item.icon}\n </IconButton>\n }\n }\n\n return (\n <MobileMenuHeaderWrapper>\n {\n onGoBack &&\n <IconButton action={e => {\n e?.nativeEvent.stopImmediatePropagation();\n onGoBack();\n }}\n variant={'secondary'}\n shape={'circular'}>\n <SystemIcons.ArrowLineLeft/>\n </IconButton>\n }\n {\n buttons?.filter(a => a.placement === 'left').map(renderItem)\n }\n {\n label &&\n <MobileMenuHeaderLabel>{label}</MobileMenuHeaderLabel>\n }\n <MobileMenuHeaderActions>\n {\n buttons?.filter(a => a.placement !== 'left').map(renderItem)\n }\n\n {\n onClose &&\n <div style={{marginLeft: '8px'}}>\n <IconButton variant={'secondary'}\n action={e => {\n e?.nativeEvent.stopImmediatePropagation();\n onClose();\n }}\n shape={'circular'}>\n <SystemIcons.Close/>\n </IconButton>\n </div>\n }\n </MobileMenuHeaderActions>\n\n </MobileMenuHeaderWrapper>\n )\n};\n\n\nexport default MobileMenuHeader;\n"],"file":"MobileMenuHeader.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"types.cjs"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { HyperlinkProps } from '../HyperLink/HyperLink';
|
|
3
|
+
export interface MenuHyperLinkProps extends Pick<HyperlinkProps, 'id' | 'href' | 'onClick' | 'target'> {
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: React.ReactElement;
|
|
6
|
+
}
|
|
7
|
+
export interface MenuButton {
|
|
8
|
+
label: string;
|
|
9
|
+
icon?: React.ReactNode;
|
|
10
|
+
action: () => void;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface MenuGroupFooter {
|
|
14
|
+
header: string;
|
|
15
|
+
note?: string;
|
|
16
|
+
link?: MenuHyperLinkProps;
|
|
17
|
+
}
|
|
18
|
+
export interface MenuGroupHeader {
|
|
19
|
+
header: string;
|
|
20
|
+
note?: string;
|
|
21
|
+
link?: MenuHyperLinkProps;
|
|
22
|
+
}
|
|
23
|
+
export interface MenuAccountInfo {
|
|
24
|
+
firstName: string;
|
|
25
|
+
lastName: string;
|
|
26
|
+
email: string;
|
|
27
|
+
link?: MenuHyperLinkProps;
|
|
28
|
+
}
|
|
29
|
+
export interface ProfileMenu {
|
|
30
|
+
label?: string;
|
|
31
|
+
user: MenuAccountInfo;
|
|
32
|
+
sections: MenuNavigationSection[];
|
|
33
|
+
signOut?: MenuButton;
|
|
34
|
+
}
|
|
35
|
+
export interface MenuIconSubMenuButton {
|
|
36
|
+
type: 'submenu';
|
|
37
|
+
icon: React.ReactNode;
|
|
38
|
+
menu: MenuNavigationItemTypeGroup | MenuNavigationCustomSubMenu;
|
|
39
|
+
placement?: 'left' | 'right';
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface MenuIconButton {
|
|
43
|
+
type: 'action';
|
|
44
|
+
icon: React.ReactNode;
|
|
45
|
+
action: (button?: EventTarget) => boolean | void;
|
|
46
|
+
placement?: 'left' | 'right';
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface MenuProfileButton {
|
|
50
|
+
type: 'profile';
|
|
51
|
+
action?: (button?: EventTarget) => boolean | void;
|
|
52
|
+
placement?: 'left' | 'right';
|
|
53
|
+
disabled?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface MenuSwitcherButton {
|
|
56
|
+
type: 'switcher';
|
|
57
|
+
placement?: 'left' | 'right';
|
|
58
|
+
disabled?: boolean;
|
|
59
|
+
action?: (button?: EventTarget) => boolean | void;
|
|
60
|
+
}
|
|
61
|
+
export declare type DesktopMenuButtonTypes = MenuIconButton | MenuProfileButton | MenuSwitcherButton;
|
|
62
|
+
export declare type MobileMenuButtonTypes = MenuIconSubMenuButton | MenuIconButton | MenuProfileButton | MenuSwitcherButton;
|
|
63
|
+
export interface MobileNavigationMenuProps {
|
|
64
|
+
label?: string;
|
|
65
|
+
buttons?: MobileMenuButtonTypes[];
|
|
66
|
+
header?: MenuGroupHeader;
|
|
67
|
+
items?: (MenuNavigationItemTypeItem | MenuNavigationItemTypeGroup)[];
|
|
68
|
+
footer?: MenuGroupFooter;
|
|
69
|
+
action?: MenuButton;
|
|
70
|
+
}
|
|
71
|
+
export interface DesktopNavigationMenuProps {
|
|
72
|
+
buttons?: DesktopMenuButtonTypes[];
|
|
73
|
+
items: MenuNavigationItemTypeItem[];
|
|
74
|
+
action?: MenuButton;
|
|
75
|
+
reverseRightSideOrder?: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface MenuNavigationGroup<T = (MenuNavigationItem | MenuNavigationSection | MenuNavigationGroup)> {
|
|
78
|
+
label: string;
|
|
79
|
+
note?: string;
|
|
80
|
+
buttons?: MobileMenuButtonTypes[];
|
|
81
|
+
header?: MenuGroupHeader;
|
|
82
|
+
items: T[];
|
|
83
|
+
footer?: MenuGroupFooter;
|
|
84
|
+
action?: MenuButton;
|
|
85
|
+
}
|
|
86
|
+
export declare type MenuNavigationItem = {
|
|
87
|
+
icon?: React.ReactNode;
|
|
88
|
+
to: string;
|
|
89
|
+
exact?: boolean;
|
|
90
|
+
disabled?: boolean;
|
|
91
|
+
external?: boolean;
|
|
92
|
+
action?: () => void;
|
|
93
|
+
label: string;
|
|
94
|
+
note?: string;
|
|
95
|
+
pinned?: boolean;
|
|
96
|
+
};
|
|
97
|
+
export interface MenuNavigationSection<T = MenuNavigationItem> {
|
|
98
|
+
divider?: boolean;
|
|
99
|
+
pinned?: boolean;
|
|
100
|
+
label?: string;
|
|
101
|
+
items: T[];
|
|
102
|
+
}
|
|
103
|
+
export declare type MenuNavigationItemTypeItem = MenuNavigationItem & {
|
|
104
|
+
type?: 'item';
|
|
105
|
+
};
|
|
106
|
+
export declare type MenuNavigationItemTypeGroup = MenuNavigationGroup<MenuNavigationItemTypeItem | MenuNavigationItemTypeGroup | MenuNavigationItemTypeSection> & {
|
|
107
|
+
type: 'group';
|
|
108
|
+
icon?: React.ReactNode;
|
|
109
|
+
pinned?: boolean;
|
|
110
|
+
disabled?: boolean;
|
|
111
|
+
};
|
|
112
|
+
export declare type MenuNavigationItemTypeSection = MenuNavigationSection<MenuNavigationItemTypeItem> & {
|
|
113
|
+
type: 'section';
|
|
114
|
+
};
|
|
115
|
+
export declare type MenuNavigationCustomSubMenu = {
|
|
116
|
+
type: 'custom';
|
|
117
|
+
label?: string;
|
|
118
|
+
buttons?: MobileMenuButtonTypes[];
|
|
119
|
+
custom: () => React.ReactNode;
|
|
120
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"types.js"}
|
|
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.default = exports.
|
|
10
|
+
exports.default = exports.ItemLabel = exports.ItemIconRight = exports.ItemIcon = exports.ItemContent = exports.DropdownButtonCSS = exports.DropdownButton = void 0;
|
|
11
11
|
|
|
12
12
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
13
|
|
|
@@ -49,11 +49,11 @@ var ItemIcon = _styledComponents.default.div(_templateObject3 || (_templateObjec
|
|
|
49
49
|
|
|
50
50
|
exports.ItemIcon = ItemIcon;
|
|
51
51
|
|
|
52
|
-
var
|
|
52
|
+
var ItemIconRight = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n align-items: center;\n display: flex;\n"])));
|
|
53
53
|
|
|
54
|
-
exports.
|
|
54
|
+
exports.ItemIconRight = ItemIconRight;
|
|
55
55
|
|
|
56
|
-
var ItemContent = _styledComponents.default.div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n margin: auto 0 auto 16px;\n display: flex;\n align-items: center;\n flex-grow: 2;\n\n ", " {\n flex: 1 0 calc(100% - 40px);\n display: flex;\n flex-direction: row;\n align-items: center;\n }\n\n ", " {\n margin-right: 6px;\n svg {\n display: block;\n margin: auto;\n }\n }\n\n ", " {\n flex-grow: 2;\n\n .extraMargin {\n margin-left: calc(100% - 24px);\n }\n }\n"])), ItemLabel, ItemIcon,
|
|
56
|
+
var ItemContent = _styledComponents.default.div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n margin: auto 0 auto 16px;\n display: flex;\n align-items: center;\n flex-grow: 2;\n\n ", " {\n flex: 1 0 calc(100% - 40px);\n display: flex;\n flex-direction: row;\n align-items: center;\n }\n\n ", " {\n margin-right: 6px;\n svg {\n display: block;\n margin: auto;\n }\n }\n\n ", " {\n flex-grow: 2;\n\n .extraMargin {\n margin-left: calc(100% - 24px);\n }\n }\n"])), ItemLabel, ItemIcon, ItemIconRight);
|
|
57
57
|
|
|
58
58
|
exports.ItemContent = ItemContent;
|
|
59
59
|
|
|
@@ -68,10 +68,11 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
68
68
|
var active = _ref.active,
|
|
69
69
|
item = _ref.item,
|
|
70
70
|
onClickHandler = _ref.onClickHandler,
|
|
71
|
-
|
|
72
|
-
size = _ref.size,
|
|
71
|
+
_ref$size = _ref.size,
|
|
72
|
+
size = _ref$size === void 0 ? _types.Size.Medium : _ref$size,
|
|
73
73
|
className = _ref.className,
|
|
74
74
|
tabIndex = _ref.tabIndex,
|
|
75
|
+
iconRight = _ref.iconRight,
|
|
75
76
|
id = _ref.id;
|
|
76
77
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(DropdownButton, {
|
|
77
78
|
type: "button",
|
|
@@ -99,24 +100,29 @@ var MenuItem = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
99
100
|
},
|
|
100
101
|
children: item.noteLabel
|
|
101
102
|
})]
|
|
102
|
-
}), item.locked && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
103
|
+
}), item.locked && /*#__PURE__*/(0, _jsxRuntime.jsx)(ItemIconRight, {
|
|
103
104
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SystemIcons.LockedOn, {
|
|
104
105
|
color: _styles.COLORS.neutral_400,
|
|
105
106
|
className: "extraMargin",
|
|
106
107
|
size: "24px"
|
|
107
108
|
})
|
|
109
|
+
}), !item.locked && !!iconRight && /*#__PURE__*/(0, _jsxRuntime.jsx)(ItemIconRight, {
|
|
110
|
+
children: /*#__PURE__*/React.cloneElement(iconRight, {
|
|
111
|
+
className: 'extraMargin',
|
|
112
|
+
size: '24px'
|
|
113
|
+
})
|
|
108
114
|
})]
|
|
109
115
|
})]
|
|
110
116
|
})]
|
|
111
|
-
}
|
|
117
|
+
});
|
|
112
118
|
});
|
|
113
119
|
MenuItem.propTypes = {
|
|
114
120
|
onClickHandler: _propTypes.default.func.isRequired,
|
|
115
121
|
active: _propTypes.default.bool.isRequired,
|
|
116
122
|
id: _propTypes.default.string.isRequired,
|
|
117
|
-
key: _propTypes.default.string.isRequired,
|
|
118
123
|
className: _propTypes.default.string,
|
|
119
|
-
tabIndex: _propTypes.default.number
|
|
124
|
+
tabIndex: _propTypes.default.number,
|
|
125
|
+
iconRight: _propTypes.default.element
|
|
120
126
|
};
|
|
121
127
|
var _default = MenuItem;
|
|
122
128
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/MenuItem/MenuItem.tsx"],"names":["DropdownButton","styled","button","props","DropdownButtonCSS","size","ItemLabel","div","ItemIcon","
|
|
1
|
+
{"version":3,"sources":["../../src/MenuItem/MenuItem.tsx"],"names":["DropdownButton","styled","button","props","DropdownButtonCSS","size","ItemLabel","div","ItemIcon","ItemIconRight","ItemContent","css","Size","Small","ComponentTextStyle","Regular","COLORS","neutral_600","Medium","Large","white","CommonInteractionStyling","neutral_20","primary_500","neutral_500","primary_20","primary_600","primary_100","primary_800","neutral_200","MenuItem","React","forwardRef","ref","active","item","onClickHandler","className","tabIndex","iconRight","id","disabled","locked","defaultOnMouseDownHandler","showDividerAbove","icon","displayLabel","value","noteLabel","fontSize","lineHeight","neutral_400","cloneElement"],"mappings":";;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;AAaO,IAAMA,cAAc,GAAGC,0BAAOC,MAAV,8FACvB,UAACC,KAAD;AAAA,SAAWC,iBAAiB,CAACD,KAAK,CAACE,IAAP,CAA5B;AAAA,CADuB,CAApB;;;;AAIA,IAAMC,SAAS,GAAGL,0BAAOM,GAAV,qFAAf;;;;AACA,IAAMC,QAAQ,GAAGP,0BAAOM,GAAV,qFAAd;;;;AACA,IAAME,aAAa,GAAGR,0BAAOM,GAAV,iIAAnB;;;;AAKA,IAAMG,WAAW,GAAGT,0BAAOM,GAAV,wiBAMlBD,SANkB,EAalBE,QAbkB,EAqBlBC,aArBkB,CAAjB;;;;AA+BA,IAAML,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,IAAD,EAAiB;AAChD,aAAOM,qBAAP,6/CACIN,IAAI,IAAIO,YAAKC,KAAb,IAAsB,mCAAkBC,2BAAmBC,OAArC,EAA8CC,eAAOC,WAArD,CAD1B,EAEIZ,IAAI,IAAIO,YAAKM,MAAb,IAAuB,mCAAkBJ,2BAAmBC,OAArC,EAA8CC,eAAOC,WAArD,CAF3B,EAGIZ,IAAI,IAAIO,YAAKO,KAAb,IAAsB,mCAAkBL,2BAAmBC,OAArC,EAA8CC,eAAOC,WAArD,CAH1B,EAUgBZ,IAAI,IAAIO,YAAKO,KAAb,GAAqB,MAArB,GAA8Bd,IAAI,IAAIO,YAAKM,MAAb,GAAsB,MAAtB,GAA+B,MAV7E,EAWsBF,eAAOI,KAX7B,EAuBIC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AAG,QAAH,GAAc,EAAzI,CARhB;AASI,IAAA,EAAE,EAAEM,EATR;AAAA,eAUKL,IAAI,CAACS,gBAAL,iBAAyB;AAAK,MAAA,SAAS,EAAC;AAAf,MAV9B,eAWI,sBAAC,WAAD;AAAA,iBACGT,IAAI,CAACU,IAAL,iBAAa,qBAAC,QAAD;AAAA,kBAAWV,IAAI,CAACU;AAAhB,QADhB,eAEE,sBAAC,SAAD;AAAA,gCACI;AAAA,kCACE;AAAA,4CAAMV,IAAI,CAACW,YAAX,mEAA2BX,IAAI,CAACY;AAAhC,YADF,EAEGZ,IAAI,CAACa,SAAL,iBAAkB;AAAK,YAAA,KAAK,EAAE;AAAEC,cAAAA,QAAQ,EAAE,MAAZ;AAAoBC,cAAAA,UAAU,EAAE;AAAhC,aAAZ;AAAA,sBAAuDf,IAAI,CAACa;AAA5D,YAFrB;AAAA,UADJ,EAMIb,IAAI,CAACO,MAAL,iBACA,qBAAC,aAAD;AAAA,iCACE,qBAAC,qBAAD;AAAU,YAAA,KAAK,EAAE1B,eAAOmC,WAAxB;AAAqC,YAAA,SAAS,EAAC,aAA/C;AAA6D,YAAA,IAAI,EAAC;AAAlE;AADF,UAPJ,EAYI,CAAChB,IAAI,CAACO,MAAN,IAAgB,CAAC,CAACH,SAAlB,iBACA,qBAAC,aAAD;AAAA,iCACGR,KAAK,CAACqB,YAAN,CAAmBb,SAAnB,EAA8B;AAACF,YAAAA,SAAS,EAAE,aAAZ;AAA2BhC,YAAAA,IAAI,EAAE;AAAjC,WAA9B;AADH,UAbJ;AAAA,QAFF;AAAA,MAXJ;AAAA,IADF;AAoCD,CA7CgB,CAAjB;;AAzIG+B,EAAAA,c;AACAF,EAAAA,M;AACAM,EAAAA,E;AAEAH,EAAAA,S;AACAC,EAAAA,Q;AACAC,EAAAA,S;;eAkLYT,Q","sourcesContent":["import * as React from 'react';\nimport {Link} from 'react-router-dom';\nimport styled, { css } from 'styled-components';\nimport {BREAKPOINTS, COLORS, ComponentTextStyle} from '../styles';\nimport {ChevronRight, LockedOn} from '../icons/systemicons/SystemIcons';\nimport {Product, Size} from '../types';\nimport {ComponentLStyling, ComponentMStyling, ComponentSStyling} from '../styles/typography';\nimport { DropdownItem } from '../Dropdown/DropdownContent';\nimport {CommonInteractionStyling, defaultOnMouseDownHandler} from '../common';\n\nexport interface MenuItemProps {\n item: DropdownItem;\n onClickHandler: (e: React.MouseEvent) => void;\n active: boolean;\n id: string;\n size?: Size;\n className?: string;\n tabIndex?: number;\n iconRight?: React.ReactElement;\n}\n\nexport const DropdownButton = styled.button<{ size?: Size }>`\n ${(props) => DropdownButtonCSS(props.size)}\n`;\n\nexport const ItemLabel = styled.div``;\nexport const ItemIcon = styled.div``;\nexport const ItemIconRight = styled.div`\n align-items: center;\n display: flex;\n`;\n\nexport const ItemContent = styled.div`\n margin: auto 0 auto 16px;\n display: flex;\n align-items: center;\n flex-grow: 2;\n\n ${ItemLabel} {\n flex: 1 0 calc(100% - 40px);\n display: flex;\n flex-direction: row;\n align-items: center;\n }\n\n ${ItemIcon} {\n margin-right: 6px;\n svg {\n display: block;\n margin: auto;\n }\n }\n\n ${ItemIconRight} {\n flex-grow: 2;\n\n .extraMargin {\n margin-left: calc(100% - 24px);\n }\n }\n`;\n\n\nexport const DropdownButtonCSS = (size?: Size) => {\n return css`\n ${size == Size.Small && ComponentSStyling(ComponentTextStyle.Regular, COLORS.neutral_600)}\n ${size == Size.Medium && ComponentMStyling(ComponentTextStyle.Regular, COLORS.neutral_600)}\n ${size == Size.Large && ComponentLStyling(ComponentTextStyle.Regular, COLORS.neutral_600)}\n\n position: relative;\n text-decoration: none;\n display: flex;\n flex-direction: row;\n align-items: center;\n min-height: ${size == Size.Large ? '64px' : size == Size.Medium ? '56px' : '48px'};\n background-color: ${COLORS.white};\n border: none;\n cursor: pointer;\n background: transparent;\n width: 100%;\n text-align: left;\n\n span {\n margin: auto 0 auto 16px;\n line-height: 48px;\n }\n\n ${CommonInteractionStyling};\n\n &.active {\n background: ${COLORS.neutral_20};\n\n &::after {\n position: absolute;\n content: ' ';\n width: 4px;\n top: 6px;\n bottom: 6px;\n left: 4px;\n background-color: ${COLORS.primary_500};\n\n border-radius: 4px;\n }\n }\n\n\n &.locked {\n background-color: transparent;\n cursor: not-allowed;\n color: ${COLORS.neutral_500};\n }\n\n &.active:hover, &.active-hover-state {\n background-color: ${COLORS.primary_20};\n\n svg {\n color: ${COLORS.primary_600};\n }\n\n &::after {\n background-color: ${COLORS.primary_500};\n }\n }\n\n &.active:active, &.active-active-state {\n background-color: ${COLORS.primary_100};\n\n svg {\n color: ${COLORS.primary_800};\n }\n\n &::after {\n background-color: ${COLORS.primary_500};\n }\n }\n\n &:disabled, &.disabled-state {\n background-color: transparent !important;\n cursor: not-allowed;\n color: ${COLORS.neutral_200} !important;\n }\n\n &.dropdown-hover:not(:disabled) {\n background-color: ${COLORS.primary_20};\n color: ${COLORS.primary_600};\n }\n `;\n};\n\nconst MenuItem = React.forwardRef<HTMLButtonElement, MenuItemProps>(({\n active,\n item,\n onClickHandler,\n size = Size.Medium,\n className,\n tabIndex,\n iconRight,\n id }: MenuItemProps, ref) => {\n return (\n <DropdownButton\n type=\"button\"\n size={size}\n disabled={item.disabled || item.locked}\n tabIndex={tabIndex}\n onMouseDown={defaultOnMouseDownHandler}\n ref={ref}\n onClick={onClickHandler}\n className={ className + ' ' + (item.locked ? 'locked' : '') + ' ' + (item.showDividerAbove ? 'show-divider-above' : '') + ' ' + (active ? 'active' : '')}\n id={id}>\n {item.showDividerAbove && <div className=\"divider\" />}\n <ItemContent>\n {item.icon && <ItemIcon>{item.icon}</ItemIcon>}\n <ItemLabel>\n <div>\n <div>{item.displayLabel ?? item.value}</div>\n {item.noteLabel && <div style={{ fontSize: '12px', lineHeight: '16px' }}>{item.noteLabel}</div>}\n </div>\n {\n item.locked &&\n <ItemIconRight>\n <LockedOn color={COLORS.neutral_400} className=\"extraMargin\" size=\"24px\"/>\n </ItemIconRight>\n }\n {\n !item.locked && !!iconRight &&\n <ItemIconRight>\n {React.cloneElement(iconRight, {className: 'extraMargin', size: '24px',})}\n </ItemIconRight>\n }\n\n </ItemLabel>\n </ItemContent>\n </DropdownButton>\n );\n});\n\nexport default MenuItem;\n"],"file":"MenuItem.cjs"}
|