@laerdal/life-react-components 1.8.0-dev.16 → 1.8.0-dev.17

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.
Files changed (163) hide show
  1. package/dist/GlobalNavigationBar/Actions.cjs +185 -0
  2. package/dist/GlobalNavigationBar/Actions.cjs.map +1 -0
  3. package/dist/GlobalNavigationBar/Actions.d.ts +13 -0
  4. package/dist/GlobalNavigationBar/Actions.js +160 -0
  5. package/dist/GlobalNavigationBar/Actions.js.map +1 -0
  6. package/dist/GlobalNavigationBar/Avatar.cjs +104 -0
  7. package/dist/GlobalNavigationBar/Avatar.cjs.map +1 -0
  8. package/dist/GlobalNavigationBar/Avatar.d.ts +15 -0
  9. package/dist/GlobalNavigationBar/Avatar.js +77 -0
  10. package/dist/GlobalNavigationBar/Avatar.js.map +1 -0
  11. package/dist/GlobalNavigationBar/{desktop/ExtendedMainMenu.cjs → ExtendedMainMenu.cjs} +9 -7
  12. package/dist/GlobalNavigationBar/ExtendedMainMenu.cjs.map +1 -0
  13. package/dist/GlobalNavigationBar/{desktop/ExtendedMainMenu.d.ts → ExtendedMainMenu.d.ts} +2 -2
  14. package/dist/GlobalNavigationBar/{desktop/ExtendedMainMenu.js → ExtendedMainMenu.js} +6 -6
  15. package/dist/GlobalNavigationBar/ExtendedMainMenu.js.map +1 -0
  16. package/dist/GlobalNavigationBar/GlobalNavigationBar.cjs +176 -107
  17. package/dist/GlobalNavigationBar/GlobalNavigationBar.cjs.map +1 -1
  18. package/dist/GlobalNavigationBar/GlobalNavigationBar.d.ts +27 -13
  19. package/dist/GlobalNavigationBar/GlobalNavigationBar.js +176 -106
  20. package/dist/GlobalNavigationBar/GlobalNavigationBar.js.map +1 -1
  21. package/dist/GlobalNavigationBar/Logo.cjs +5 -3
  22. package/dist/GlobalNavigationBar/Logo.cjs.map +1 -1
  23. package/dist/GlobalNavigationBar/Logo.js +1 -1
  24. package/dist/GlobalNavigationBar/Logo.js.map +1 -1
  25. package/dist/GlobalNavigationBar/{desktop/MainMenu.cjs → MainMenu.cjs} +21 -17
  26. package/dist/GlobalNavigationBar/MainMenu.cjs.map +1 -0
  27. package/dist/GlobalNavigationBar/MainMenu.d.ts +8 -0
  28. package/dist/GlobalNavigationBar/{desktop/MainMenu.js → MainMenu.js} +21 -17
  29. package/dist/GlobalNavigationBar/MainMenu.js.map +1 -0
  30. package/dist/GlobalNavigationBar/{desktop/RightSideNav.cjs → RightSideNav.cjs} +26 -22
  31. package/dist/GlobalNavigationBar/RightSideNav.cjs.map +1 -0
  32. package/dist/GlobalNavigationBar/RightSideNav.d.ts +8 -0
  33. package/dist/GlobalNavigationBar/RightSideNav.js +61 -0
  34. package/dist/GlobalNavigationBar/RightSideNav.js.map +1 -0
  35. package/dist/GlobalNavigationBar/UserMenu/MenuLink.cjs +112 -0
  36. package/dist/GlobalNavigationBar/UserMenu/MenuLink.cjs.map +1 -0
  37. package/dist/GlobalNavigationBar/UserMenu/MenuLink.d.ts +11 -0
  38. package/dist/GlobalNavigationBar/UserMenu/MenuLink.js +86 -0
  39. package/dist/GlobalNavigationBar/UserMenu/MenuLink.js.map +1 -0
  40. package/dist/GlobalNavigationBar/UserMenu/MobileUserMenu.cjs +178 -0
  41. package/dist/GlobalNavigationBar/UserMenu/MobileUserMenu.cjs.map +1 -0
  42. package/dist/GlobalNavigationBar/UserMenu/MobileUserMenu.d.ts +16 -0
  43. package/dist/GlobalNavigationBar/UserMenu/MobileUserMenu.js +146 -0
  44. package/dist/GlobalNavigationBar/UserMenu/MobileUserMenu.js.map +1 -0
  45. package/dist/GlobalNavigationBar/UserMenu/UserMenu.cjs +168 -0
  46. package/dist/GlobalNavigationBar/UserMenu/UserMenu.cjs.map +1 -0
  47. package/dist/GlobalNavigationBar/UserMenu/UserMenu.d.ts +15 -0
  48. package/dist/GlobalNavigationBar/UserMenu/UserMenu.js +135 -0
  49. package/dist/GlobalNavigationBar/UserMenu/UserMenu.js.map +1 -0
  50. package/dist/GlobalNavigationBar/index.cjs +18 -15
  51. package/dist/GlobalNavigationBar/index.cjs.map +1 -1
  52. package/dist/GlobalNavigationBar/index.d.ts +2 -2
  53. package/dist/GlobalNavigationBar/index.js +2 -2
  54. package/dist/GlobalNavigationBar/index.js.map +1 -1
  55. package/dist/GlobalNavigationBar/mobile/CommonStyles.cjs +21 -15
  56. package/dist/GlobalNavigationBar/mobile/CommonStyles.cjs.map +1 -1
  57. package/dist/GlobalNavigationBar/mobile/CommonStyles.d.ts +6 -3
  58. package/dist/GlobalNavigationBar/mobile/CommonStyles.js +15 -14
  59. package/dist/GlobalNavigationBar/mobile/CommonStyles.js.map +1 -1
  60. package/dist/GlobalNavigationBar/mobile/ExitMenuButton.cjs +49 -0
  61. package/dist/GlobalNavigationBar/mobile/ExitMenuButton.cjs.map +1 -0
  62. package/dist/GlobalNavigationBar/mobile/ExitMenuButton.d.ts +6 -0
  63. package/dist/GlobalNavigationBar/mobile/ExitMenuButton.js +27 -0
  64. package/dist/GlobalNavigationBar/mobile/ExitMenuButton.js.map +1 -0
  65. package/dist/GlobalNavigationBar/mobile/MobileActionMenu.cjs +91 -0
  66. package/dist/GlobalNavigationBar/mobile/MobileActionMenu.cjs.map +1 -0
  67. package/dist/GlobalNavigationBar/mobile/MobileActionMenu.d.ts +13 -0
  68. package/dist/GlobalNavigationBar/mobile/MobileActionMenu.js +70 -0
  69. package/dist/GlobalNavigationBar/mobile/MobileActionMenu.js.map +1 -0
  70. package/dist/GlobalNavigationBar/mobile/MobileMenu.cjs +221 -114
  71. package/dist/GlobalNavigationBar/mobile/MobileMenu.cjs.map +1 -1
  72. package/dist/GlobalNavigationBar/mobile/MobileMenu.d.ts +25 -6
  73. package/dist/GlobalNavigationBar/mobile/MobileMenu.js +216 -113
  74. package/dist/GlobalNavigationBar/mobile/MobileMenu.js.map +1 -1
  75. package/dist/MenuItem/MenuItem.cjs +10 -16
  76. package/dist/MenuItem/MenuItem.cjs.map +1 -1
  77. package/dist/MenuItem/MenuItem.d.ts +3 -3
  78. package/dist/MenuItem/MenuItem.js +8 -14
  79. package/dist/MenuItem/MenuItem.js.map +1 -1
  80. package/dist/ProfileButton/ProfileButton.cjs +11 -20
  81. package/dist/ProfileButton/ProfileButton.cjs.map +1 -1
  82. package/dist/ProfileButton/ProfileButton.d.ts +1 -3
  83. package/dist/ProfileButton/ProfileButton.js +10 -18
  84. package/dist/ProfileButton/ProfileButton.js.map +1 -1
  85. package/dist/Switcher/MobileSwitcherMenu.cjs +78 -24
  86. package/dist/Switcher/MobileSwitcherMenu.cjs.map +1 -1
  87. package/dist/Switcher/MobileSwitcherMenu.d.ts +5 -6
  88. package/dist/Switcher/MobileSwitcherMenu.js +70 -26
  89. package/dist/Switcher/MobileSwitcherMenu.js.map +1 -1
  90. package/dist/Tile/TileBody.cjs +1 -1
  91. package/dist/Tile/TileBody.cjs.map +1 -1
  92. package/dist/Tile/TileBody.js +1 -1
  93. package/dist/Tile/TileBody.js.map +1 -1
  94. package/dist/Tile/TileCommonItems.cjs +1 -1
  95. package/dist/Tile/TileCommonItems.cjs.map +1 -1
  96. package/dist/Tile/TileCommonItems.js +1 -1
  97. package/dist/Tile/TileCommonItems.js.map +1 -1
  98. package/dist/Tile/TileFooter.cjs +1 -1
  99. package/dist/Tile/TileFooter.cjs.map +1 -1
  100. package/dist/Tile/TileFooter.js +1 -1
  101. package/dist/Tile/TileFooter.js.map +1 -1
  102. package/dist/Tile/TileHeader.cjs +1 -1
  103. package/dist/Tile/TileHeader.cjs.map +1 -1
  104. package/dist/Tile/TileHeader.js +2 -2
  105. package/dist/Tile/TileHeader.js.map +1 -1
  106. package/dist/hooks/useClickOutside.cjs +2 -6
  107. package/dist/hooks/useClickOutside.cjs.map +1 -1
  108. package/dist/hooks/useClickOutside.d.ts +1 -1
  109. package/dist/hooks/useClickOutside.js +2 -6
  110. package/dist/hooks/useClickOutside.js.map +1 -1
  111. package/dist/index.cjs +8 -8
  112. package/dist/index.cjs.map +1 -1
  113. package/dist/index.d.ts +1 -1
  114. package/dist/index.js +1 -1
  115. package/dist/index.js.map +1 -1
  116. package/dist/types.cjs.map +1 -1
  117. package/dist/types.d.ts +32 -0
  118. package/dist/types.js.map +1 -1
  119. package/package.json +8 -10
  120. package/dist/GlobalNavigationBar/NavigationHelper.cjs +0 -38
  121. package/dist/GlobalNavigationBar/NavigationHelper.cjs.map +0 -1
  122. package/dist/GlobalNavigationBar/NavigationHelper.d.ts +0 -4
  123. package/dist/GlobalNavigationBar/NavigationHelper.js +0 -27
  124. package/dist/GlobalNavigationBar/NavigationHelper.js.map +0 -1
  125. package/dist/GlobalNavigationBar/desktop/DesktopActions.cjs +0 -127
  126. package/dist/GlobalNavigationBar/desktop/DesktopActions.cjs.map +0 -1
  127. package/dist/GlobalNavigationBar/desktop/DesktopActions.d.ts +0 -15
  128. package/dist/GlobalNavigationBar/desktop/DesktopActions.js +0 -98
  129. package/dist/GlobalNavigationBar/desktop/DesktopActions.js.map +0 -1
  130. package/dist/GlobalNavigationBar/desktop/ExtendedMainMenu.cjs.map +0 -1
  131. package/dist/GlobalNavigationBar/desktop/ExtendedMainMenu.js.map +0 -1
  132. package/dist/GlobalNavigationBar/desktop/MainMenu.cjs.map +0 -1
  133. package/dist/GlobalNavigationBar/desktop/MainMenu.d.ts +0 -8
  134. package/dist/GlobalNavigationBar/desktop/MainMenu.js.map +0 -1
  135. package/dist/GlobalNavigationBar/desktop/RightSideNav.cjs.map +0 -1
  136. package/dist/GlobalNavigationBar/desktop/RightSideNav.d.ts +0 -8
  137. package/dist/GlobalNavigationBar/desktop/RightSideNav.js +0 -59
  138. package/dist/GlobalNavigationBar/desktop/RightSideNav.js.map +0 -1
  139. package/dist/GlobalNavigationBar/desktop/UserMenu.cjs +0 -204
  140. package/dist/GlobalNavigationBar/desktop/UserMenu.cjs.map +0 -1
  141. package/dist/GlobalNavigationBar/desktop/UserMenu.d.ts +0 -7
  142. package/dist/GlobalNavigationBar/desktop/UserMenu.js +0 -163
  143. package/dist/GlobalNavigationBar/desktop/UserMenu.js.map +0 -1
  144. package/dist/GlobalNavigationBar/mobile/MobileMenuContent.cjs +0 -221
  145. package/dist/GlobalNavigationBar/mobile/MobileMenuContent.cjs.map +0 -1
  146. package/dist/GlobalNavigationBar/mobile/MobileMenuContent.d.ts +0 -11
  147. package/dist/GlobalNavigationBar/mobile/MobileMenuContent.js +0 -184
  148. package/dist/GlobalNavigationBar/mobile/MobileMenuContent.js.map +0 -1
  149. package/dist/GlobalNavigationBar/mobile/MobileMenuHeader.cjs +0 -160
  150. package/dist/GlobalNavigationBar/mobile/MobileMenuHeader.cjs.map +0 -1
  151. package/dist/GlobalNavigationBar/mobile/MobileMenuHeader.d.ts +0 -12
  152. package/dist/GlobalNavigationBar/mobile/MobileMenuHeader.js +0 -139
  153. package/dist/GlobalNavigationBar/mobile/MobileMenuHeader.js.map +0 -1
  154. package/dist/GlobalNavigationBar/types.cjs +0 -6
  155. package/dist/GlobalNavigationBar/types.cjs.map +0 -1
  156. package/dist/GlobalNavigationBar/types.d.ts +0 -120
  157. package/dist/GlobalNavigationBar/types.js +0 -2
  158. package/dist/GlobalNavigationBar/types.js.map +0 -1
  159. package/dist/common/StackState.cjs +0 -47
  160. package/dist/common/StackState.cjs.map +0 -1
  161. package/dist/common/StackState.d.ts +0 -7
  162. package/dist/common/StackState.js +0 -30
  163. package/dist/common/StackState.js.map +0 -1
@@ -1,160 +0,0 @@
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
@@ -1 +0,0 @@
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","st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Q;AACT,OAHD;AAIY,MAAA,OAAO,EAAE,WAJrB;AAKY,MAAA,KAAK,EAAE,UALnB;AAAA,6BAME,qBAAC,kBAAD,CAAa,aAAb;AANF,MAHJ,EAaII,OAbJ,aAaIA,OAbJ,uBAaIA,OAAO,CAAE6B,MAAT,CAAgB,UAAAX,CAAC;AAAA,aAAIA,CAAC,CAACY,SAAF,KAAgB,MAApB;AAAA,KAAjB,EAA6Cb,GAA7C,CAAiDG,UAAjD,CAbJ,EAgBItB,KAAK,iBACL,qBAAC,qBAAD;AAAA,gBAAwBA;AAAxB,MAjBJ,eAmBE,sBAAC,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,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,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"}
@@ -1,12 +0,0 @@
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;
@@ -1,139 +0,0 @@
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
@@ -1 +0,0 @@
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,CAHI,CAA3B;AAOA,IAAME,uBAAuB,GAAGhB,MAAM,CAACW,GAAV,4OAMzBV,WAAW,CAACc,KANa,EAUzBd,WAAW,CAACgB,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,GAAY;AAC5CI,MAAAA,IAAI,EAAE,OADsC;AAE5CL,MAAAA,KA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R,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"}
@@ -1,6 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- //# sourceMappingURL=types.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"types.cjs"}
@@ -1,120 +0,0 @@
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
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"types.js"}
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.useStackState = void 0;
9
-
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
- var _react = _interopRequireDefault(require("react"));
13
-
14
- var useStackState = function useStackState(initial) {
15
- var _React$useState = _react.default.useState(initial ? [initial] : []),
16
- _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
17
- state = _React$useState2[0],
18
- setState = _React$useState2[1];
19
-
20
- var reset = _react.default.useCallback(function (value) {
21
- return setState(!!value || !!initial ? [value !== null && value !== void 0 ? value : initial] : []);
22
- }, [initial]);
23
-
24
- var peek = _react.default.useCallback(function () {
25
- return !!state.length ? state[state.length - 1] : undefined;
26
- }, [state]);
27
-
28
- var push = _react.default.useCallback(function (value) {
29
- return setState(state.concat(value));
30
- }, [state]);
31
-
32
- var pop = _react.default.useCallback(function () {
33
- return setState(state.slice(0, -1));
34
- }, [state]);
35
-
36
- var length = state.length;
37
- return {
38
- peek: peek,
39
- push: push,
40
- pop: pop,
41
- reset: reset,
42
- length: length
43
- };
44
- };
45
-
46
- exports.useStackState = useStackState;
47
- //# sourceMappingURL=StackState.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/common/StackState.ts"],"names":["useStackState","initial","React","useState","state","setState","reset","useCallback","value","peek","length","undefined","push","concat","pop","slice"],"mappings":";;;;;;;;;;;AAAA;;AAGO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAAIC,OAAJ,EAAoB;AAC/C,wBAA0BC,eAAMC,QAAN,CAAkCF,OAAO,GAAG,CAACA,OAAD,CAAH,GAAe,EAAxD,CAA1B;AAAA;AAAA,MAAOG,KAAP;AAAA,MAAcC,QAAd;;AAEA,MAAMC,KAAK,GAAGJ,eAAMK,WAAN,CAAkB,UAACC,KAAD;AAAA,WAAeH,QAAQ,CAAC,CAAC,CAACG,KAAF,IAAW,CAAC,CAACP,OAAb,GAAuB,CAACO,KAAD,aAACA,KAAD,cAACA,KAAD,GAAUP,OAAV,CAAvB,GAA4C,EAA7C,CAAvB;AAAA,GAAlB,EAA2F,CAACA,OAAD,CAA3F,CAAd;;AACA,MAAMQ,IAAI,GAAGP,eAAMK,WAAN,CAAkB;AAAA,WAAM,CAAC,CAACH,KAAK,CAACM,MAAR,GAAiBN,KAAK,CAACA,KAAK,CAACM,MAAN,GAAe,CAAhB,CAAtB,GAA2CC,SAAjD;AAAA,GAAlB,EAA8E,CAACP,KAAD,CAA9E,CAAb;;AACA,MAAMQ,IAAI,GAAGV,eAAMK,WAAN,CAAkB,UAACC,KAAD;AAAA,WAAcH,QAAQ,CAACD,KAAK,CAACS,MAAN,CAAaL,KAAb,CAAD,CAAtB;AAAA,GAAlB,EAA+D,CAACJ,KAAD,CAA/D,CAAb;;AACA,MAAMU,GAAG,GAAGZ,eAAMK,WAAN,CAAkB;AAAA,WAAMF,QAAQ,CAACD,KAAK,CAACW,KAAN,CAAY,CAAZ,EAAe,CAAC,CAAhB,CAAD,CAAd;AAAA,GAAlB,EAAsD,CAACX,KAAD,CAAtD,CAAZ;;AACA,MAAMM,MAAM,GAAGN,KAAK,CAACM,MAArB;AAEA,SAAO;AAACD,IAAAA,IAAI,EAAJA,IAAD;AAAOG,IAAAA,IAAI,EAAJA,IAAP;AAAaE,IAAAA,GAAG,EAAHA,GAAb;AAAkBR,IAAAA,KAAK,EAALA,KAAlB;AAAyBI,IAAAA,MAAM,EAANA;AAAzB,GAAP;AACD,CAVM","sourcesContent":["import React from 'react';\n\n\nexport const useStackState = <T>(initial?: T) => {\n const [state, setState] = React.useState<(T | undefined)[]>(initial ? [initial] : []);\n\n const reset = React.useCallback((value?: T) => setState(!!value || !!initial ? [value ?? initial] : []), [initial]);\n const peek = React.useCallback(() => !!state.length ? state[state.length - 1] : undefined, [state]);\n const push = React.useCallback((value: T) => setState(state.concat(value)), [state]);\n const pop = React.useCallback(() => setState(state.slice(0, -1)), [state]);\n const length = state.length;\n\n return {peek, push, pop, reset, length};\n};\n"],"file":"StackState.cjs"}
@@ -1,7 +0,0 @@
1
- export declare const useStackState: <T>(initial?: T | undefined) => {
2
- peek: () => T | undefined;
3
- push: (value: T) => void;
4
- pop: () => void;
5
- reset: (value?: T | undefined) => void;
6
- length: number;
7
- };
@@ -1,30 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import React from 'react';
3
- export var useStackState = function useStackState(initial) {
4
- var _React$useState = React.useState(initial ? [initial] : []),
5
- _React$useState2 = _slicedToArray(_React$useState, 2),
6
- state = _React$useState2[0],
7
- setState = _React$useState2[1];
8
-
9
- var reset = React.useCallback(function (value) {
10
- return setState(!!value || !!initial ? [value !== null && value !== void 0 ? value : initial] : []);
11
- }, [initial]);
12
- var peek = React.useCallback(function () {
13
- return !!state.length ? state[state.length - 1] : undefined;
14
- }, [state]);
15
- var push = React.useCallback(function (value) {
16
- return setState(state.concat(value));
17
- }, [state]);
18
- var pop = React.useCallback(function () {
19
- return setState(state.slice(0, -1));
20
- }, [state]);
21
- var length = state.length;
22
- return {
23
- peek: peek,
24
- push: push,
25
- pop: pop,
26
- reset: reset,
27
- length: length
28
- };
29
- };
30
- //# sourceMappingURL=StackState.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/common/StackState.ts"],"names":["React","useStackState","initial","useState","state","setState","reset","useCallback","value","peek","length","undefined","push","concat","pop","slice"],"mappings":";AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,OAAO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAAIC,OAAJ,EAAoB;AAC/C,wBAA0BF,KAAK,CAACG,QAAN,CAAkCD,OAAO,GAAG,CAACA,OAAD,CAAH,GAAe,EAAxD,CAA1B;AAAA;AAAA,MAAOE,KAAP;AAAA,MAAcC,QAAd;;AAEA,MAAMC,KAAK,GAAGN,KAAK,CAACO,WAAN,CAAkB,UAACC,KAAD;AAAA,WAAeH,QAAQ,CAAC,CAAC,CAACG,KAAF,IAAW,CAAC,CAACN,OAAb,GAAuB,CAACM,KAAD,aAACA,KAAD,cAACA,KAAD,GAAUN,OAAV,CAAvB,GAA4C,EAA7C,CAAvB;AAAA,GAAlB,EAA2F,CAACA,OAAD,CAA3F,CAAd;AACA,MAAMO,IAAI,GAAGT,KAAK,CAACO,WAAN,CAAkB;AAAA,WAAM,CAAC,CAACH,KAAK,CAACM,MAAR,GAAiBN,KAAK,CAACA,KAAK,CAACM,MAAN,GAAe,CAAhB,CAAtB,GAA2CC,SAAjD;AAAA,GAAlB,EAA8E,CAACP,KAAD,CAA9E,CAAb;AACA,MAAMQ,IAAI,GAAGZ,KAAK,CAACO,WAAN,CAAkB,UAACC,KAAD;AAAA,WAAcH,QAAQ,CAACD,KAAK,CAACS,MAAN,CAAaL,KAAb,CAAD,CAAtB;AAAA,GAAlB,EAA+D,CAACJ,KAAD,CAA/D,CAAb;AACA,MAAMU,GAAG,GAAGd,KAAK,CAACO,WAAN,CAAkB;AAAA,WAAMF,QAAQ,CAACD,KAAK,CAACW,KAAN,CAAY,CAAZ,EAAe,CAAC,CAAhB,CAAD,CAAd;AAAA,GAAlB,EAAsD,CAACX,KAAD,CAAtD,CAAZ;AACA,MAAMM,MAAM,GAAGN,KAAK,CAACM,MAArB;AAEA,SAAO;AAACD,IAAAA,IAAI,EAAJA,IAAD;AAAOG,IAAAA,IAAI,EAAJA,IAAP;AAAaE,IAAAA,GAAG,EAAHA,GAAb;AAAkBR,IAAAA,KAAK,EAALA,KAAlB;AAAyBI,IAAAA,MAAM,EAANA;AAAzB,GAAP;AACD,CAVM","sourcesContent":["import React from 'react';\n\n\nexport const useStackState = <T>(initial?: T) => {\n const [state, setState] = React.useState<(T | undefined)[]>(initial ? [initial] : []);\n\n const reset = React.useCallback((value?: T) => setState(!!value || !!initial ? [value ?? initial] : []), [initial]);\n const peek = React.useCallback(() => !!state.length ? state[state.length - 1] : undefined, [state]);\n const push = React.useCallback((value: T) => setState(state.concat(value)), [state]);\n const pop = React.useCallback(() => setState(state.slice(0, -1)), [state]);\n const length = state.length;\n\n return {peek, push, pop, reset, length};\n};\n"],"file":"StackState.js"}