@laerdal/life-react-components 1.10.3-dev.20 → 1.10.3-dev.21

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.
@@ -9,6 +9,10 @@ Object.defineProperty(exports, "__esModule", {
9
9
  });
10
10
  exports.default = void 0;
11
11
 
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
+
12
16
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
17
 
14
18
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
@@ -35,12 +39,18 @@ var _common = require("../../common");
35
39
 
36
40
  var _jsxRuntime = require("react/jsx-runtime");
37
41
 
42
+ var _excluded = ["icon", "to", "exact", "disabled", "external", "action", "label", "note", "pinned"];
43
+
38
44
  var _templateObject, _templateObject2, _templateObject3, _templateObject4;
39
45
 
40
46
  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); }
41
47
 
42
48
  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; }
43
49
 
50
+ 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; }
51
+
52
+ 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; }
53
+
44
54
  var NavContainer = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: none;\n justify-content: center;\n align-items: center;\n\n ", " {\n display: flex;\n }\n\n a {\n text-decoration: none;\n }\n"])), _styles.BREAKPOINTS.MEDIUM);
45
55
 
46
56
  var NavButton = _styledComponents.default.button(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n background: ", ";\n border: 0;\n"])), _styles.COLORS.white);
@@ -109,28 +119,43 @@ var MainMenu = function MainMenu(_ref) {
109
119
  React.useEffect(function () {
110
120
  recalculateNumberOfItemsAllowed();
111
121
  }, [items.length]);
122
+
123
+ var renderItem = function renderItem(item, index) {
124
+ if (index > numberOfItemsAllowed - 2) return null;
125
+ var icon = item.icon,
126
+ to = item.to,
127
+ exact = item.exact,
128
+ disabled = item.disabled,
129
+ external = item.external,
130
+ action = item.action,
131
+ label = item.label,
132
+ note = item.note,
133
+ pinned = item.pinned,
134
+ rest = (0, _objectWithoutProperties2.default)(item, _excluded);
135
+ return item !== null && item !== void 0 && item.disabled ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_NavItem.NavItem, {
136
+ as: NavButton,
137
+ exact: item.exact,
138
+ className: "disabled",
139
+ onMouseDown: _common.defaultOnMouseDownHandler,
140
+ children: item === null || item === void 0 ? void 0 : item.label
141
+ }, item.label) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_NavItem.NavItem, _objectSpread(_objectSpread({
142
+ as: _reactRouterDom.NavLink,
143
+ exact: item.exact,
144
+ to: item.to || '',
145
+ onMouseDown: _common.defaultOnMouseDownHandler,
146
+ onClick: function onClick(e) {
147
+ return item.action && item.action(e);
148
+ }
149
+ }, rest), {}, {
150
+ children: item === null || item === void 0 ? void 0 : item.label
151
+ }), item.label);
152
+ };
153
+
112
154
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(NavContainer, {
113
155
  className: "GlobalNavigationMainMenu",
114
156
  ref: mainMenuRef,
115
157
  open: showExtendedMenu,
116
- children: [items === null || items === void 0 ? void 0 : items.map(function (no, index) {
117
- return index > numberOfItemsAllowed - 2 ? null : no !== null && no !== void 0 && no.disabled ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_NavItem.NavItem, {
118
- as: NavButton,
119
- exact: no.exact,
120
- className: "disabled",
121
- onMouseDown: _common.defaultOnMouseDownHandler,
122
- children: no === null || no === void 0 ? void 0 : no.label
123
- }, no.label) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_NavItem.NavItem, {
124
- as: _reactRouterDom.NavLink,
125
- exact: no.exact,
126
- to: no.to || '',
127
- onMouseDown: _common.defaultOnMouseDownHandler,
128
- onClick: function onClick(e) {
129
- return no.action && no.action(e);
130
- },
131
- children: no === null || no === void 0 ? void 0 : no.label
132
- }, no.label);
133
- }), items.length + 1 > numberOfItemsAllowed && /*#__PURE__*/(0, _jsxRuntime.jsxs)(ExtendedSection, {
158
+ children: [items === null || items === void 0 ? void 0 : items.map(renderItem), items.length + 1 > numberOfItemsAllowed && /*#__PURE__*/(0, _jsxRuntime.jsxs)(ExtendedSection, {
134
159
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, {
135
160
  ref: menuButtonRef,
136
161
  variant: 'secondary',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/GlobalNavigationBar/desktop/MainMenu.tsx"],"names":["NavContainer","styled","div","BREAKPOINTS","MEDIUM","NavButton","button","COLORS","white","ExtendedMenuWrapper","props","floatRight","ExtendedSection","MainMenu","items","rightSideRef","React","useState","showExtendedMenu","setShowExtendedMenu","extendedMenuRef","useRef","menuButtonRef","mainMenuRef","numberOfItemsAllowed","setNumberOfItemsAllowed","widthOfItem","recalculateNumberOfItemsAllowed","current","number","Math","floor","offsetLeft","handleClickExtendedMenuAction","handleClickOutside","e","contains","target","useEffect","document","addEventListener","window","removeEventListener","length","map","no","index","disabled","exact","defaultOnMouseDownHandler","label","NavLink","to","action","slice"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAGA,IAAMA,YAAY,GAAGC,0BAAOC,GAAV,2OAKdC,oBAAYC,MALE,CAAlB;;AAcA,IAAMC,SAAS,GAAGJ,0BAAOK,MAAV,2HACCC,eAAOC,KADR,CAAf;;AASA,IAAMC,mBAAmB,GAAGR,0BAAOC,GAAV,wTAER,UAAAQ,KAAK;AAAA,SAAKA,KAAK,CAACC,UAAN,GAAmB,MAAnB,GAA4B,OAAjC;AAAA,CAFG,EAePJ,eAAOC,KAfA,CAAzB;;AAmBA,IAAMI,eAAe,GAAGX,0BAAOC,GAAV,8GAArB;;AASA,IAAMW,QAAQ,GAAG,SAAXA,QAAW,OAA6D;AAAA,MAA3DC,KAA2D,QAA3DA,KAA2D;AAAA,MAApDC,YAAoD,QAApDA,YAAoD;;AAC5E,wBAAgDC,KAAK,CAACC,QAAN,CAAe,KAAf,CAAhD;AAAA;AAAA,MAAOC,gBAAP;AAAA,MAAyBC,mBAAzB;;AACA,MAAMC,eAAe,GAAGJ,KAAK,CAACK,MAAN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AC,gBAAD;AAAS,QAAA,EAAE,EAAEC,uBAAb;AACS,QAAA,KAAK,EAAEN,EAAE,CAACG,KADnB;AAES,QAAA,EAAE,EAAEH,EAAE,CAACO,EAAH,IAAS,EAFtB;AAIS,QAAA,WAAW,EAAEH,iCAJtB;AAKS,QAAA,OAAO,EAAE,iBAACd,CAAD;AAAA,iBAAyBU,EAAE,CAACQ,MAAH,IAAaR,EAAE,CAACQ,MAAH,CAAUlB,CAAV,CAAtC;AAAA,SALlB;AAAA,kBAMGU,EANH,aAMGA,EANH,uBAMGA,EAAE,CAAEK;AANP,SAGcL,EAAE,CAACK,KAHjB,CAVQ;AAAA,KAAX,CADH,EAqBGpC,KAAK,CAAC6B,MAAN,GAAe,CAAf,GAAmBnB,oBAAnB,iBACC,sBAAC,eAAD;AAAA,8BACE,qBAAC,kBAAD;AACE,QAAA,GAAG,EAAEF,aADP;AAEE,QAAA,OAAO,EAAE,WAFX;AAGE,QAAA,KAAK,EAAE,UAHT;AAIE,QAAA,MAAM,EAAE,kBAAM;AACZH,UAAAA,mBAAmB,CAAC,CAACD,gBAAF,CAAnB;AACD,SANH;AAAA,+BAOE,qBAAC,2BAAD;AAAgB,UAAA,IAAI,EAAC;AAArB;AAPF,QADF,eAUE,qBAAC,mBAAD;AAAqB,QAAA,GAAG,EAAEE,eAA1B;AAA2C,QAAA,SAAS,EAAEF,gBAAgB,GAAG,MAAH,GAAY,EAAlF;AAAsF,QAAA,UAAU,EAAE,KAAlG;AAAA,+BACE,qBAAC,yBAAD;AAAkB,UAAA,eAAe,EAAEe,6BAAnC;AACkB,UAAA,iBAAiB,EAAEnB,KAAK,CAACwC,KAAN,CAAY9B,oBAAoB,GAAG,CAAnC;AADrC;AADF,QAVF;AAAA,MAtBJ;AAAA,IADF;AAyCD,CApFD;;;AAJEV,EAAAA,K;;eA0FaD,Q","sourcesContent":["import * as React from 'react';\nimport {NavLink} from 'react-router-dom';\nimport styled from 'styled-components';\n\nimport {NavItem} from '../../NavItem';\nimport {MoreHorizontal} from '../../icons/systemicons/SystemIcons';\nimport {COLORS, BREAKPOINTS} from '../../styles';\nimport ExtendedMainMenu from './ExtendedMainMenu';\nimport {IconButton} from '../../Button';\nimport {defaultOnMouseDownHandler} from '../../common';\nimport {MenuNavigationItemTypeItem} from '../types';\n\nconst NavContainer = styled.div<{ open: boolean }>`\n display: none;\n justify-content: center;\n align-items: center;\n\n ${BREAKPOINTS.MEDIUM} {\n display: flex;\n }\n\n a {\n text-decoration: none;\n }\n`;\n\nconst NavButton = styled.button`\n background: ${COLORS.white};\n border: 0;\n`;\n\ninterface ExtendedMenuWrapperProps {\n floatRight: boolean;\n}\n\nconst ExtendedMenuWrapper = styled.div<ExtendedMenuWrapperProps>`\n display: flex;\n margin-left: ${props => (props.floatRight ? 'auto' : 'unset')};\n\n position: absolute;\n flex-direction: column;\n left: 290px;\n top: 22px;\n\n height: 0;\n width: 0;\n\n &:focus-within,\n &:hover,\n &.open {\n background: ${COLORS.white};\n }\n`;\n\nconst ExtendedSection = styled.div`\n position: relative;\n`;\n\ntype Props = {\n items: MenuNavigationItemTypeItem[];\n rightSideRef?: React.RefObject<HTMLDivElement> | null | undefined;\n};\n\nconst MainMenu = ({items, rightSideRef}: Props): React.ReactElement<Props> => {\n const [showExtendedMenu, setShowExtendedMenu] = React.useState(false);\n const extendedMenuRef = React.useRef<any>(null);\n const menuButtonRef = React.useRef<HTMLButtonElement>(null);\n const mainMenuRef: React.RefObject<HTMLDivElement> | null | undefined = React.useRef(null);\n const [numberOfItemsAllowed, setNumberOfItemsAllowed] = React.useState<number>(1);\n\n const widthOfItem = 150;\n const recalculateNumberOfItemsAllowed = () => {\n if (rightSideRef?.current && mainMenuRef?.current) {\n const number = Math.floor((rightSideRef?.current?.offsetLeft - mainMenuRef?.current?.offsetLeft) / widthOfItem);\n if (number !== numberOfItemsAllowed) {\n setNumberOfItemsAllowed(number);\n }\n }\n };\n\n const handleClickExtendedMenuAction = () => {\n setShowExtendedMenu(false);\n };\n\n const handleClickOutside = (e: any) => {\n if (!extendedMenuRef?.current?.contains(e.target) && !menuButtonRef?.current?.contains(e.target)) {\n setShowExtendedMenu(false);\n }\n };\n\n React.useEffect(() => {\n recalculateNumberOfItemsAllowed();\n // Bind the event listener\n document.addEventListener('click', handleClickOutside);\n window.addEventListener('resize', recalculateNumberOfItemsAllowed);\n return () => {\n // Unbind the event listener on clean up\n document.removeEventListener('click', handleClickOutside);\n window.removeEventListener('resize', recalculateNumberOfItemsAllowed);\n };\n }, []);\n\n React.useEffect(() => {\n recalculateNumberOfItemsAllowed();\n }, [items.length])\n\n return (\n <NavContainer className=\"GlobalNavigationMainMenu\" ref={mainMenuRef} open={showExtendedMenu}>\n {items?.map((no: MenuNavigationItemTypeItem, index: number) =>\n index > numberOfItemsAllowed - 2 ? null : no?.disabled ? (\n <NavItem as={NavButton}\n exact={no.exact}\n className=\"disabled\"\n key={no.label}\n onMouseDown={defaultOnMouseDownHandler}>\n {no?.label}\n </NavItem>\n ) : (\n <NavItem as={NavLink}\n exact={no.exact}\n to={no.to || ''}\n key={no.label}\n onMouseDown={defaultOnMouseDownHandler}\n onClick={(e: React.MouseEvent) => no.action && no.action(e)}>\n {no?.label}\n </NavItem>\n ),\n )}\n {items.length + 1 > numberOfItemsAllowed && (\n <ExtendedSection>\n <IconButton\n ref={menuButtonRef}\n variant={'secondary'}\n shape={'circular'}\n action={() => {\n setShowExtendedMenu(!showExtendedMenu)\n }}>\n <MoreHorizontal size=\"24px\"/>\n </IconButton>\n <ExtendedMenuWrapper ref={extendedMenuRef} className={showExtendedMenu ? 'open' : ''} floatRight={false}>\n <ExtendedMainMenu clickMenuAction={handleClickExtendedMenuAction}\n navigationOptions={items.slice(numberOfItemsAllowed - 1)}/>\n </ExtendedMenuWrapper>\n </ExtendedSection>\n )}\n </NavContainer>\n );\n};\n\nexport default MainMenu;\n"],"file":"MainMenu.cjs"}
1
+ {"version":3,"sources":["../../../src/GlobalNavigationBar/desktop/MainMenu.tsx"],"names":["NavContainer","styled","div","BREAKPOINTS","MEDIUM","NavButton","button","COLORS","white","ExtendedMenuWrapper","props","floatRight","ExtendedSection","MainMenu","items","rightSideRef","React","useState","showExtendedMenu","setShowExtendedMenu","extendedMenuRef","useRef","menuButtonRef","mainMenuRef","numberOfItemsAllowed","setNumberOfItemsAllowed","widthOfItem","recalculateNumberOfItemsAllowed","current","number","Math","floor","offsetLeft","handleClickExtendedMenuAction","handleClickOutside","e","contains","target","useEffect","document","addEventListener","window","removeEventListener","length","renderItem","item","index","icon","to","exact","disabled","external","action","label","note","pinned","rest","defaultOnMouseDownHandler","NavLink","map","slice"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;AAGA,IAAMA,YAAY,GAAGC,0BAAOC,GAAV,2OAKdC,oBAAYC,MALE,CAAlB;;AAcA,IAAMC,SAAS,GAAGJ,0BAAOK,MAAV,2HACCC,eAAOC,KADR,CAAf;;AASA,IAAMC,mBAAmB,GAAGR,0BAAOC,GAAV,wTAER,UAAAQ,KAAK;AAAA,SAAKA,KAAK,CAACC,UAAN,GAAmB,MAAnB,GAA4B,OAAjC;AAAA,CAFG,EAePJ,eAAOC,KAfA,CAAzB;;AAmBA,IAAMI,eAAe,GAAGX,0BAAOC,GAAV,8GAArB;;AASA,IAAMW,QAAQ,GAAG,SAAXA,QAAW,OAA6D;AAAA,MAA3DC,KAA2D,QAA3DA,KAA2D;AAAA,MAApDC,YAAoD,QAApDA,YAAoD;;AAC5E,wBAAgDC,KAAK,CAACC,QAAN,CAAe,KAAf,CAAhD;AAAA;AAAA,MAAOC,gBAAP;AAAA,MAAyBC,mBAAzB;;AACA,MAAMC,eAAe,GAAGJ,KAAK,CAACK,MAAN,CAAkB,IAAlB,CAAxB;AACA,MAAMC,aAAa,GAAGN,KAAK,CAACK,MAAN,CAAgC,IAAhC,CAAtB;AACA,MAAME,WAA+D,GAAGP,KAAK,CAAC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UE,qBAAC,mBAAD;AAAqB,QAAA,GAAG,EAAEE,eAA1B;AAA2C,QAAA,SAAS,EAAEF,gBAAgB,GAAG,MAAH,GAAY,EAAlF;AAAsF,QAAA,UAAU,EAAE,KAAlG;AAAA,+BACE,qBAAC,yBAAD;AAAkB,UAAA,eAAe,EAAEe,6BAAnC;AACkB,UAAA,iBAAiB,EAAEnB,KAAK,CAAC8C,KAAN,CAAYpC,oBAAoB,GAAG,CAAnC;AADrC;AADF,QAVF;AAAA,MAHJ;AAAA,IADF;AAsBD,CA1FD;;;AAJEV,EAAAA,K;;eAgGaD,Q","sourcesContent":["import * as React from 'react';\nimport {NavLink} from 'react-router-dom';\nimport styled from 'styled-components';\n\nimport {NavItem} from '../../NavItem';\nimport {MoreHorizontal} from '../../icons/systemicons/SystemIcons';\nimport {COLORS, BREAKPOINTS} from '../../styles';\nimport ExtendedMainMenu from './ExtendedMainMenu';\nimport {IconButton} from '../../Button';\nimport {defaultOnMouseDownHandler} from '../../common';\nimport {MenuNavigationItemTypeItem} from '../types';\n\nconst NavContainer = styled.div<{ open: boolean }>`\n display: none;\n justify-content: center;\n align-items: center;\n\n ${BREAKPOINTS.MEDIUM} {\n display: flex;\n }\n\n a {\n text-decoration: none;\n }\n`;\n\nconst NavButton = styled.button`\n background: ${COLORS.white};\n border: 0;\n`;\n\ninterface ExtendedMenuWrapperProps {\n floatRight: boolean;\n}\n\nconst ExtendedMenuWrapper = styled.div<ExtendedMenuWrapperProps>`\n display: flex;\n margin-left: ${props => (props.floatRight ? 'auto' : 'unset')};\n\n position: absolute;\n flex-direction: column;\n left: 290px;\n top: 22px;\n\n height: 0;\n width: 0;\n\n &:focus-within,\n &:hover,\n &.open {\n background: ${COLORS.white};\n }\n`;\n\nconst ExtendedSection = styled.div`\n position: relative;\n`;\n\ntype Props = {\n items: MenuNavigationItemTypeItem[];\n rightSideRef?: React.RefObject<HTMLDivElement> | null | undefined;\n};\n\nconst MainMenu = ({items, rightSideRef}: Props): React.ReactElement<Props> => {\n const [showExtendedMenu, setShowExtendedMenu] = React.useState(false);\n const extendedMenuRef = React.useRef<any>(null);\n const menuButtonRef = React.useRef<HTMLButtonElement>(null);\n const mainMenuRef: React.RefObject<HTMLDivElement> | null | undefined = React.useRef(null);\n const [numberOfItemsAllowed, setNumberOfItemsAllowed] = React.useState<number>(1);\n\n const widthOfItem = 150;\n const recalculateNumberOfItemsAllowed = () => {\n if (rightSideRef?.current && mainMenuRef?.current) {\n const number = Math.floor((rightSideRef?.current?.offsetLeft - mainMenuRef?.current?.offsetLeft) / widthOfItem);\n if (number !== numberOfItemsAllowed) {\n setNumberOfItemsAllowed(number);\n }\n }\n };\n\n const handleClickExtendedMenuAction = () => {\n setShowExtendedMenu(false);\n };\n\n const handleClickOutside = (e: any) => {\n if (!extendedMenuRef?.current?.contains(e.target) && !menuButtonRef?.current?.contains(e.target)) {\n setShowExtendedMenu(false);\n }\n };\n\n React.useEffect(() => {\n recalculateNumberOfItemsAllowed();\n // Bind the event listener\n document.addEventListener('click', handleClickOutside);\n window.addEventListener('resize', recalculateNumberOfItemsAllowed);\n return () => {\n // Unbind the event listener on clean up\n document.removeEventListener('click', handleClickOutside);\n window.removeEventListener('resize', recalculateNumberOfItemsAllowed);\n };\n }, []);\n\n React.useEffect(() => {\n recalculateNumberOfItemsAllowed();\n }, [items.length])\n\n const renderItem = (item: MenuNavigationItemTypeItem, index: number) => {\n\n if (index > numberOfItemsAllowed - 2) return null\n\n const {icon, to, exact, disabled, external, action, label, note, pinned, ...rest} = item;\n\n return item?.disabled\n ? <NavItem as={NavButton}\n exact={item.exact}\n className=\"disabled\"\n key={item.label}\n onMouseDown={defaultOnMouseDownHandler}>\n {item?.label}\n </NavItem>\n : <NavItem as={NavLink}\n exact={item.exact}\n to={item.to || ''}\n key={item.label}\n onMouseDown={defaultOnMouseDownHandler}\n onClick={(e: React.MouseEvent) => item.action && item.action(e)}\n {...rest}>\n {item?.label}\n </NavItem>\n }\n\n return (\n <NavContainer className=\"GlobalNavigationMainMenu\" ref={mainMenuRef} open={showExtendedMenu}>\n {items?.map(renderItem)}\n {items.length + 1 > numberOfItemsAllowed && (\n <ExtendedSection>\n <IconButton\n ref={menuButtonRef}\n variant={'secondary'}\n shape={'circular'}\n action={() => {\n setShowExtendedMenu(!showExtendedMenu)\n }}>\n <MoreHorizontal size=\"24px\"/>\n </IconButton>\n <ExtendedMenuWrapper ref={extendedMenuRef} className={showExtendedMenu ? 'open' : ''} floatRight={false}>\n <ExtendedMainMenu clickMenuAction={handleClickExtendedMenuAction}\n navigationOptions={items.slice(numberOfItemsAllowed - 1)}/>\n </ExtendedMenuWrapper>\n </ExtendedSection>\n )}\n </NavContainer>\n );\n};\n\nexport default MainMenu;\n"],"file":"MainMenu.cjs"}
@@ -1,9 +1,16 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
1
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
4
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
3
5
  import _pt from "prop-types";
6
+ var _excluded = ["icon", "to", "exact", "disabled", "external", "action", "label", "note", "pinned"];
4
7
 
5
8
  var _templateObject, _templateObject2, _templateObject3, _templateObject4;
6
9
 
10
+ 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; }
11
+
12
+ 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; }
13
+
7
14
  import * as React from 'react';
8
15
  import { NavLink } from 'react-router-dom';
9
16
  import styled from 'styled-components';
@@ -80,28 +87,45 @@ var MainMenu = function MainMenu(_ref) {
80
87
  React.useEffect(function () {
81
88
  recalculateNumberOfItemsAllowed();
82
89
  }, [items.length]);
90
+
91
+ var renderItem = function renderItem(item, index) {
92
+ if (index > numberOfItemsAllowed - 2) return null;
93
+
94
+ var icon = item.icon,
95
+ to = item.to,
96
+ exact = item.exact,
97
+ disabled = item.disabled,
98
+ external = item.external,
99
+ action = item.action,
100
+ label = item.label,
101
+ note = item.note,
102
+ pinned = item.pinned,
103
+ rest = _objectWithoutProperties(item, _excluded);
104
+
105
+ return item !== null && item !== void 0 && item.disabled ? /*#__PURE__*/_jsx(NavItem, {
106
+ as: NavButton,
107
+ exact: item.exact,
108
+ className: "disabled",
109
+ onMouseDown: defaultOnMouseDownHandler,
110
+ children: item === null || item === void 0 ? void 0 : item.label
111
+ }, item.label) : /*#__PURE__*/_jsx(NavItem, _objectSpread(_objectSpread({
112
+ as: NavLink,
113
+ exact: item.exact,
114
+ to: item.to || '',
115
+ onMouseDown: defaultOnMouseDownHandler,
116
+ onClick: function onClick(e) {
117
+ return item.action && item.action(e);
118
+ }
119
+ }, rest), {}, {
120
+ children: item === null || item === void 0 ? void 0 : item.label
121
+ }), item.label);
122
+ };
123
+
83
124
  return /*#__PURE__*/_jsxs(NavContainer, {
84
125
  className: "GlobalNavigationMainMenu",
85
126
  ref: mainMenuRef,
86
127
  open: showExtendedMenu,
87
- children: [items === null || items === void 0 ? void 0 : items.map(function (no, index) {
88
- return index > numberOfItemsAllowed - 2 ? null : no !== null && no !== void 0 && no.disabled ? /*#__PURE__*/_jsx(NavItem, {
89
- as: NavButton,
90
- exact: no.exact,
91
- className: "disabled",
92
- onMouseDown: defaultOnMouseDownHandler,
93
- children: no === null || no === void 0 ? void 0 : no.label
94
- }, no.label) : /*#__PURE__*/_jsx(NavItem, {
95
- as: NavLink,
96
- exact: no.exact,
97
- to: no.to || '',
98
- onMouseDown: defaultOnMouseDownHandler,
99
- onClick: function onClick(e) {
100
- return no.action && no.action(e);
101
- },
102
- children: no === null || no === void 0 ? void 0 : no.label
103
- }, no.label);
104
- }), items.length + 1 > numberOfItemsAllowed && /*#__PURE__*/_jsxs(ExtendedSection, {
128
+ children: [items === null || items === void 0 ? void 0 : items.map(renderItem), items.length + 1 > numberOfItemsAllowed && /*#__PURE__*/_jsxs(ExtendedSection, {
105
129
  children: [/*#__PURE__*/_jsx(IconButton, {
106
130
  ref: menuButtonRef,
107
131
  variant: 'secondary',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/GlobalNavigationBar/desktop/MainMenu.tsx"],"names":["React","NavLink","styled","NavItem","MoreHorizontal","COLORS","BREAKPOINTS","ExtendedMainMenu","IconButton","defaultOnMouseDownHandler","NavContainer","div","MEDIUM","NavButton","button","white","ExtendedMenuWrapper","props","floatRight","ExtendedSection","MainMenu","items","rightSideRef","useState","showExtendedMenu","setShowExtendedMenu","extendedMenuRef","useRef","menuButtonRef","mainMenuRef","numberOfItemsAllowed","setNumberOfItemsAllowed","widthOfItem","recalculateNumberOfItemsAllowed","current","number","Math","floor","offsetLeft","handleClickExtendedMenuAction","handleClickOutside","e","contains","target","useEffect","document","addEventListener","window","removeEventListener","length","map","no","index","disabled","exact","label","to","action","slice"],"mappings":";;;;;;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAAQC,OAAR,QAAsB,kBAAtB;AACA,OAAOC,MAAP,MAAmB,mBAAnB;AAEA,SAAQC,OAAR,QAAsB,eAAtB;AACA,SAAQC,cAAR,QAA6B,qCAA7B;AACA,SAAQC,MAAR,EAAgBC,WAAhB,QAAkC,cAAlC;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AACA,SAAQC,UAAR,QAAyB,cAAzB;AACA,SAAQC,yBAAR,QAAwC,cAAxC;;;AAGA,I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QAAA,KAAK,EAAE,UAHT;AAIE,QAAA,MAAM,EAAE,kBAAM;AACZH,UAAAA,mBAAmB,CAAC,CAACD,gBAAF,CAAnB;AACD,SANH;AAAA,+BAOE,KAAC,cAAD;AAAgB,UAAA,IAAI,EAAC;AAArB;AAPF,QADF,eAUE,KAAC,mBAAD;AAAqB,QAAA,GAAG,EAAEE,eAA1B;AAA2C,QAAA,SAAS,EAAEF,gBAAgB,GAAG,MAAH,GAAY,EAAlF;AAAsF,QAAA,UAAU,EAAE,KAAlG;AAAA,+BACE,KAAC,gBAAD;AAAkB,UAAA,eAAe,EAAEe,6BAAnC;AACkB,UAAA,iBAAiB,EAAElB,KAAK,CAACqC,KAAN,CAAY5B,oBAAoB,GAAG,CAAnC;AADrC;AADF,QAVF;AAAA,MAtBJ;AAAA,IADF;AAyCD,CApFD;;;AAJET,EAAAA,K;;AA0FF,eAAeD,QAAf","sourcesContent":["import * as React from 'react';\nimport {NavLink} from 'react-router-dom';\nimport styled from 'styled-components';\n\nimport {NavItem} from '../../NavItem';\nimport {MoreHorizontal} from '../../icons/systemicons/SystemIcons';\nimport {COLORS, BREAKPOINTS} from '../../styles';\nimport ExtendedMainMenu from './ExtendedMainMenu';\nimport {IconButton} from '../../Button';\nimport {defaultOnMouseDownHandler} from '../../common';\nimport {MenuNavigationItemTypeItem} from '../types';\n\nconst NavContainer = styled.div<{ open: boolean }>`\n display: none;\n justify-content: center;\n align-items: center;\n\n ${BREAKPOINTS.MEDIUM} {\n display: flex;\n }\n\n a {\n text-decoration: none;\n }\n`;\n\nconst NavButton = styled.button`\n background: ${COLORS.white};\n border: 0;\n`;\n\ninterface ExtendedMenuWrapperProps {\n floatRight: boolean;\n}\n\nconst ExtendedMenuWrapper = styled.div<ExtendedMenuWrapperProps>`\n display: flex;\n margin-left: ${props => (props.floatRight ? 'auto' : 'unset')};\n\n position: absolute;\n flex-direction: column;\n left: 290px;\n top: 22px;\n\n height: 0;\n width: 0;\n\n &:focus-within,\n &:hover,\n &.open {\n background: ${COLORS.white};\n }\n`;\n\nconst ExtendedSection = styled.div`\n position: relative;\n`;\n\ntype Props = {\n items: MenuNavigationItemTypeItem[];\n rightSideRef?: React.RefObject<HTMLDivElement> | null | undefined;\n};\n\nconst MainMenu = ({items, rightSideRef}: Props): React.ReactElement<Props> => {\n const [showExtendedMenu, setShowExtendedMenu] = React.useState(false);\n const extendedMenuRef = React.useRef<any>(null);\n const menuButtonRef = React.useRef<HTMLButtonElement>(null);\n const mainMenuRef: React.RefObject<HTMLDivElement> | null | undefined = React.useRef(null);\n const [numberOfItemsAllowed, setNumberOfItemsAllowed] = React.useState<number>(1);\n\n const widthOfItem = 150;\n const recalculateNumberOfItemsAllowed = () => {\n if (rightSideRef?.current && mainMenuRef?.current) {\n const number = Math.floor((rightSideRef?.current?.offsetLeft - mainMenuRef?.current?.offsetLeft) / widthOfItem);\n if (number !== numberOfItemsAllowed) {\n setNumberOfItemsAllowed(number);\n }\n }\n };\n\n const handleClickExtendedMenuAction = () => {\n setShowExtendedMenu(false);\n };\n\n const handleClickOutside = (e: any) => {\n if (!extendedMenuRef?.current?.contains(e.target) && !menuButtonRef?.current?.contains(e.target)) {\n setShowExtendedMenu(false);\n }\n };\n\n React.useEffect(() => {\n recalculateNumberOfItemsAllowed();\n // Bind the event listener\n document.addEventListener('click', handleClickOutside);\n window.addEventListener('resize', recalculateNumberOfItemsAllowed);\n return () => {\n // Unbind the event listener on clean up\n document.removeEventListener('click', handleClickOutside);\n window.removeEventListener('resize', recalculateNumberOfItemsAllowed);\n };\n }, []);\n\n React.useEffect(() => {\n recalculateNumberOfItemsAllowed();\n }, [items.length])\n\n return (\n <NavContainer className=\"GlobalNavigationMainMenu\" ref={mainMenuRef} open={showExtendedMenu}>\n {items?.map((no: MenuNavigationItemTypeItem, index: number) =>\n index > numberOfItemsAllowed - 2 ? null : no?.disabled ? (\n <NavItem as={NavButton}\n exact={no.exact}\n className=\"disabled\"\n key={no.label}\n onMouseDown={defaultOnMouseDownHandler}>\n {no?.label}\n </NavItem>\n ) : (\n <NavItem as={NavLink}\n exact={no.exact}\n to={no.to || ''}\n key={no.label}\n onMouseDown={defaultOnMouseDownHandler}\n onClick={(e: React.MouseEvent) => no.action && no.action(e)}>\n {no?.label}\n </NavItem>\n ),\n )}\n {items.length + 1 > numberOfItemsAllowed && (\n <ExtendedSection>\n <IconButton\n ref={menuButtonRef}\n variant={'secondary'}\n shape={'circular'}\n action={() => {\n setShowExtendedMenu(!showExtendedMenu)\n }}>\n <MoreHorizontal size=\"24px\"/>\n </IconButton>\n <ExtendedMenuWrapper ref={extendedMenuRef} className={showExtendedMenu ? 'open' : ''} floatRight={false}>\n <ExtendedMainMenu clickMenuAction={handleClickExtendedMenuAction}\n navigationOptions={items.slice(numberOfItemsAllowed - 1)}/>\n </ExtendedMenuWrapper>\n </ExtendedSection>\n )}\n </NavContainer>\n );\n};\n\nexport default MainMenu;\n"],"file":"MainMenu.js"}
1
+ {"version":3,"sources":["../../../src/GlobalNavigationBar/desktop/MainMenu.tsx"],"names":["React","NavLink","styled","NavItem","MoreHorizontal","COLORS","BREAKPOINTS","ExtendedMainMenu","IconButton","defaultOnMouseDownHandler","NavContainer","div","MEDIUM","NavButton","button","white","ExtendedMenuWrapper","props","floatRight","ExtendedSection","MainMenu","items","rightSideRef","useState","showExtendedMenu","setShowExtendedMenu","extendedMenuRef","useRef","menuButtonRef","mainMenuRef","numberOfItemsAllowed","setNumberOfItemsAllowed","widthOfItem","recalculateNumberOfItemsAllowed","current","number","Math","floor","offsetLeft","handleClickExtendedMenuAction","handleClickOutside","e","contains","target","useEffect","document","addEventListener","window","removeEventListener","length","renderItem","item","index","icon","to","exact","disabled","external","action","label","note","pinned","rest","map","slice"],"mappings":";;;;;;;;;;;;;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAAQC,OAAR,QAAsB,kBAAtB;AACA,OAAOC,MAAP,MAAmB,mBAAnB;AAEA,SAAQC,OAAR,QAAsB,eAAtB;AACA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CAAnC;AADrC;AADF,QAVF;AAAA,MAHJ;AAAA,IADF;AAsBD,CA1FD;;;AAJET,EAAAA,K;;AAgGF,eAAeD,QAAf","sourcesContent":["import * as React from 'react';\nimport {NavLink} from 'react-router-dom';\nimport styled from 'styled-components';\n\nimport {NavItem} from '../../NavItem';\nimport {MoreHorizontal} from '../../icons/systemicons/SystemIcons';\nimport {COLORS, BREAKPOINTS} from '../../styles';\nimport ExtendedMainMenu from './ExtendedMainMenu';\nimport {IconButton} from '../../Button';\nimport {defaultOnMouseDownHandler} from '../../common';\nimport {MenuNavigationItemTypeItem} from '../types';\n\nconst NavContainer = styled.div<{ open: boolean }>`\n display: none;\n justify-content: center;\n align-items: center;\n\n ${BREAKPOINTS.MEDIUM} {\n display: flex;\n }\n\n a {\n text-decoration: none;\n }\n`;\n\nconst NavButton = styled.button`\n background: ${COLORS.white};\n border: 0;\n`;\n\ninterface ExtendedMenuWrapperProps {\n floatRight: boolean;\n}\n\nconst ExtendedMenuWrapper = styled.div<ExtendedMenuWrapperProps>`\n display: flex;\n margin-left: ${props => (props.floatRight ? 'auto' : 'unset')};\n\n position: absolute;\n flex-direction: column;\n left: 290px;\n top: 22px;\n\n height: 0;\n width: 0;\n\n &:focus-within,\n &:hover,\n &.open {\n background: ${COLORS.white};\n }\n`;\n\nconst ExtendedSection = styled.div`\n position: relative;\n`;\n\ntype Props = {\n items: MenuNavigationItemTypeItem[];\n rightSideRef?: React.RefObject<HTMLDivElement> | null | undefined;\n};\n\nconst MainMenu = ({items, rightSideRef}: Props): React.ReactElement<Props> => {\n const [showExtendedMenu, setShowExtendedMenu] = React.useState(false);\n const extendedMenuRef = React.useRef<any>(null);\n const menuButtonRef = React.useRef<HTMLButtonElement>(null);\n const mainMenuRef: React.RefObject<HTMLDivElement> | null | undefined = React.useRef(null);\n const [numberOfItemsAllowed, setNumberOfItemsAllowed] = React.useState<number>(1);\n\n const widthOfItem = 150;\n const recalculateNumberOfItemsAllowed = () => {\n if (rightSideRef?.current && mainMenuRef?.current) {\n const number = Math.floor((rightSideRef?.current?.offsetLeft - mainMenuRef?.current?.offsetLeft) / widthOfItem);\n if (number !== numberOfItemsAllowed) {\n setNumberOfItemsAllowed(number);\n }\n }\n };\n\n const handleClickExtendedMenuAction = () => {\n setShowExtendedMenu(false);\n };\n\n const handleClickOutside = (e: any) => {\n if (!extendedMenuRef?.current?.contains(e.target) && !menuButtonRef?.current?.contains(e.target)) {\n setShowExtendedMenu(false);\n }\n };\n\n React.useEffect(() => {\n recalculateNumberOfItemsAllowed();\n // Bind the event listener\n document.addEventListener('click', handleClickOutside);\n window.addEventListener('resize', recalculateNumberOfItemsAllowed);\n return () => {\n // Unbind the event listener on clean up\n document.removeEventListener('click', handleClickOutside);\n window.removeEventListener('resize', recalculateNumberOfItemsAllowed);\n };\n }, []);\n\n React.useEffect(() => {\n recalculateNumberOfItemsAllowed();\n }, [items.length])\n\n const renderItem = (item: MenuNavigationItemTypeItem, index: number) => {\n\n if (index > numberOfItemsAllowed - 2) return null\n\n const {icon, to, exact, disabled, external, action, label, note, pinned, ...rest} = item;\n\n return item?.disabled\n ? <NavItem as={NavButton}\n exact={item.exact}\n className=\"disabled\"\n key={item.label}\n onMouseDown={defaultOnMouseDownHandler}>\n {item?.label}\n </NavItem>\n : <NavItem as={NavLink}\n exact={item.exact}\n to={item.to || ''}\n key={item.label}\n onMouseDown={defaultOnMouseDownHandler}\n onClick={(e: React.MouseEvent) => item.action && item.action(e)}\n {...rest}>\n {item?.label}\n </NavItem>\n }\n\n return (\n <NavContainer className=\"GlobalNavigationMainMenu\" ref={mainMenuRef} open={showExtendedMenu}>\n {items?.map(renderItem)}\n {items.length + 1 > numberOfItemsAllowed && (\n <ExtendedSection>\n <IconButton\n ref={menuButtonRef}\n variant={'secondary'}\n shape={'circular'}\n action={() => {\n setShowExtendedMenu(!showExtendedMenu)\n }}>\n <MoreHorizontal size=\"24px\"/>\n </IconButton>\n <ExtendedMenuWrapper ref={extendedMenuRef} className={showExtendedMenu ? 'open' : ''} floatRight={false}>\n <ExtendedMainMenu clickMenuAction={handleClickExtendedMenuAction}\n navigationOptions={items.slice(numberOfItemsAllowed - 1)}/>\n </ExtendedMenuWrapper>\n </ExtendedSection>\n )}\n </NavContainer>\n );\n};\n\nexport default MainMenu;\n"],"file":"MainMenu.js"}
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = exports.MobileMenuHeaderWrapper = exports.MobileMenuHeaderActions = void 0;
9
9
 
10
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
+
10
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
13
 
12
14
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
@@ -29,6 +31,10 @@ var _ProfileButton = require("../../ProfileButton");
29
31
 
30
32
  var _jsxRuntime = require("react/jsx-runtime");
31
33
 
34
+ var _excluded = ["placement", "type", "action"],
35
+ _excluded2 = ["placement", "type", "icon", "menu"],
36
+ _excluded3 = ["placement", "type", "icon", "action"];
37
+
32
38
  var _templateObject, _templateObject2, _templateObject3;
33
39
 
34
40
  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; }
@@ -79,42 +85,65 @@ var MobileMenuHeader = function MobileMenuHeader(_ref) {
79
85
  };
80
86
 
81
87
  var renderItem = function renderItem(item, index) {
82
- var _profile$user$firstNa, _profile$user, _profile$user$firstNa2, _profile$user$lastNam, _profile$user2, _profile$user2$lastNa;
83
-
84
88
  switch (item.type) {
85
89
  case 'profile':
86
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProfileButton.ProfileButton, {
87
- onClick: function onClick(e) {
88
- e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
89
- item.action ? item.action(e === null || e === void 0 ? void 0 : e.target) && onClose() : onSubMenuOpen && onSubMenuOpen(buildProfileSubMenu());
90
- },
91
- icon: !profile && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SystemIcons.User, {}),
92
- 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 : '')
93
- }, index);
90
+ {
91
+ var _profile$user$firstNa, _profile$user, _profile$user$firstNa2, _profile$user$lastNam, _profile$user2, _profile$user2$lastNa;
92
+
93
+ var placement = item.placement,
94
+ type = item.type,
95
+ action = item.action,
96
+ rest = (0, _objectWithoutProperties2.default)(item, _excluded);
97
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ProfileButton.ProfileButton, _objectSpread({
98
+ onClick: function onClick(e) {
99
+ e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
100
+ item.action ? item.action(e === null || e === void 0 ? void 0 : e.target) && onClose() : onSubMenuOpen && onSubMenuOpen(buildProfileSubMenu());
101
+ },
102
+ icon: !profile && /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.SystemIcons.User, {}),
103
+ 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 : '')
104
+ }, rest), index);
105
+ }
94
106
 
95
107
  case 'submenu':
96
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, {
97
- disabled: item.disabled,
98
- variant: 'secondary',
99
- shape: 'circular',
100
- action: function action(e) {
101
- e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
102
- onSubMenuOpen && onSubMenuOpen(item.menu);
103
- },
104
- children: item.icon
105
- }, index);
108
+ {
109
+ var _placement = item.placement,
110
+ _type = item.type,
111
+ icon = item.icon,
112
+ menu = item.menu,
113
+ _rest = (0, _objectWithoutProperties2.default)(item, _excluded2);
114
+
115
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, _objectSpread(_objectSpread({
116
+ variant: 'secondary',
117
+ shape: 'circular',
118
+ action: function action(e) {
119
+ e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
120
+ onSubMenuOpen && onSubMenuOpen(item.menu);
121
+ }
122
+ }, _rest), {}, {
123
+ children: item.icon
124
+ }), index);
125
+ }
106
126
 
107
127
  case 'action':
108
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, {
109
- disabled: item.disabled,
110
- variant: 'secondary',
111
- shape: 'circular',
112
- action: function action(e) {
113
- e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
114
- item.action && item.action(e === null || e === void 0 ? void 0 : e.target) && onClose();
115
- },
116
- children: item.icon
117
- }, index);
128
+ {
129
+ var _placement2 = item.placement,
130
+ _type2 = item.type,
131
+ _icon = item.icon,
132
+ _action = item.action,
133
+ _rest2 = (0, _objectWithoutProperties2.default)(item, _excluded3);
134
+
135
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.IconButton, _objectSpread(_objectSpread({
136
+ disabled: item.disabled,
137
+ variant: 'secondary',
138
+ shape: 'circular',
139
+ action: function action(e) {
140
+ e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
141
+ item.action && item.action(e === null || e === void 0 ? void 0 : e.target) && onClose();
142
+ }
143
+ }, _rest2), {}, {
144
+ children: item.icon
145
+ }), index);
146
+ }
118
147
  }
119
148
  };
120
149
 
@@ -1 +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;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEO,IAAMA,uBAAuB,GAAGC,0BAAOC,GAAV,yKAA7B;;;;AAMP,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;;AAOO,IAAMG,uBAAuB,GAAGT,0BAAOC,GAAV,0PAMhCS,qBAAYF,KANoB,EAUhCE,qBAAYC,MAVoB,CAA7B;;;;AA2BP,IAAMC,gBAAgE,G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C,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,qBAAC,kBAAD;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,qBAAC,kBAAD,CAAa,KAAb;AANF;AADF,QAPJ;AAAA,MAnBF;AAAA,IADF;AA0CD,CAvGD;;;AAXED,EAAAA,Q;AACAC,EAAAA,O;AACAC,EAAAA,K;AAGAE,EAAAA,O;AAEAC,EAAAA,a;;eA8GaN,gB","sourcesContent":["import React from 'react';\nimport {\n MobileMenuButtonTypes,\n MenuNavigationItemTypeGroup,\n 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\nexport const 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\nexport const 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 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"}
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","placement","rest","e","nativeEvent","stopImmediatePropagation","target","charAt","menu","filter","marginLeft"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;AAEO,IAAMA,uBAAuB,GAAGC,0BAAOC,GAAV,yKAA7B;;;;AAMP,IAAMC,qBAAqB,GAAGF,0BAAOC,GAAV,yHACvB,gCAAmBE,2BAAmBC,IAAtC,EAA4CC,eAAOC,WAAnD,CADuB,EAEvBC,oBAAYC,KAFW,EAGrB,+BAAkBL,2BAAmBC,IAArC,EAA2CC,eAAOC,WAAlD,CAHqB,CAA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ACR,WAJb;AAKY,UAAA,KAAK,EAAE,UALnB;AAAA,iCAME,qBAAC,kBAAD,CAAa,KAAb;AANF;AADF,QAPJ;AAAA,MAnBF;AAAA,IADF;AA0CD,CAhHD;;;AAXED,EAAAA,Q;AACAC,EAAAA,O;AACAC,EAAAA,K;AAGAE,EAAAA,O;AAEAC,EAAAA,a;;eAuHaN,gB","sourcesContent":["import React from 'react';\nimport {\n MobileMenuButtonTypes,\n MenuNavigationItemTypeGroup,\n 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\nexport const 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\nexport const 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 const renderItem = (item: MobileMenuButtonTypes, index: number) => {\n switch (item.type) {\n case 'profile': {\n const {placement, type, action, ...rest} = item;\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 {...rest}/>\n }\n case 'submenu': {\n const {placement, type, icon, menu, ...rest} = item;\n\n return <IconButton key={index}\n variant={'secondary'}\n shape={'circular'}\n action={e => {\n e?.nativeEvent.stopImmediatePropagation();\n onSubMenuOpen && onSubMenuOpen(item.menu)\n }}\n {...rest}>\n {item.icon}\n </IconButton>\n }\n case 'action': {\n const {placement, type, icon, action, ...rest} = item;\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 {...rest}>\n {item.icon}\n </IconButton>\n }\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"}
@@ -1,6 +1,10 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
1
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
3
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
3
4
  import _pt from "prop-types";
5
+ var _excluded = ["placement", "type", "action"],
6
+ _excluded2 = ["placement", "type", "icon", "menu"],
7
+ _excluded3 = ["placement", "type", "icon", "action"];
4
8
 
5
9
  var _templateObject, _templateObject2, _templateObject3;
6
10
 
@@ -55,42 +59,66 @@ var MobileMenuHeader = function MobileMenuHeader(_ref) {
55
59
  };
56
60
 
57
61
  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
62
  switch (item.type) {
61
63
  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);
64
+ {
65
+ var _profile$user$firstNa, _profile$user, _profile$user$firstNa2, _profile$user$lastNam, _profile$user2, _profile$user2$lastNa;
66
+
67
+ var placement = item.placement,
68
+ type = item.type,
69
+ action = item.action,
70
+ rest = _objectWithoutProperties(item, _excluded);
71
+
72
+ return /*#__PURE__*/_jsx(ProfileButton, _objectSpread({
73
+ onClick: function onClick(e) {
74
+ e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
75
+ item.action ? item.action(e === null || e === void 0 ? void 0 : e.target) && onClose() : onSubMenuOpen && onSubMenuOpen(buildProfileSubMenu());
76
+ },
77
+ icon: !profile && /*#__PURE__*/_jsx(SystemIcons.User, {}),
78
+ 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 : '')
79
+ }, rest), index);
80
+ }
70
81
 
71
82
  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);
83
+ {
84
+ var _placement = item.placement,
85
+ _type = item.type,
86
+ icon = item.icon,
87
+ menu = item.menu,
88
+ _rest = _objectWithoutProperties(item, _excluded2);
89
+
90
+ return /*#__PURE__*/_jsx(IconButton, _objectSpread(_objectSpread({
91
+ variant: 'secondary',
92
+ shape: 'circular',
93
+ action: function action(e) {
94
+ e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
95
+ onSubMenuOpen && onSubMenuOpen(item.menu);
96
+ }
97
+ }, _rest), {}, {
98
+ children: item.icon
99
+ }), index);
100
+ }
82
101
 
83
102
  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);
103
+ {
104
+ var _placement2 = item.placement,
105
+ _type2 = item.type,
106
+ _icon = item.icon,
107
+ _action = item.action,
108
+ _rest2 = _objectWithoutProperties(item, _excluded3);
109
+
110
+ return /*#__PURE__*/_jsx(IconButton, _objectSpread(_objectSpread({
111
+ disabled: item.disabled,
112
+ variant: 'secondary',
113
+ shape: 'circular',
114
+ action: function action(e) {
115
+ e === null || e === void 0 ? void 0 : e.nativeEvent.stopImmediatePropagation();
116
+ item.action && item.action(e === null || e === void 0 ? void 0 : e.target) && onClose();
117
+ }
118
+ }, _rest2), {}, {
119
+ children: item.icon
120
+ }), index);
121
+ }
94
122
  }
95
123
  };
96
124