@kaizen/components 0.0.0-canary-04-titleblock-logic-20251211225600 → 0.0.0-canary-guidance-block-codemod-20251212045145

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 (44) hide show
  1. package/codemods/migrateGuidanceBlockActionsToActionsSlot/migrateGuidanceBlockActionsToActionsSlot.spec.ts +209 -26
  2. package/codemods/migrateGuidanceBlockActionsToActionsSlot/migrateGuidanceBlockActionsToActionsSlot.ts +24 -1
  3. package/codemods/migrateGuidanceBlockActionsToActionsSlot/transformActionsToActionsSlot.spec.ts +2 -1
  4. package/codemods/migrateGuidanceBlockActionsToActionsSlot/transformActionsToActionsSlot.ts +20 -0
  5. package/codemods/runV1Codemods/__snapshots__/runV1Codemods.spec.ts.snap +2 -3
  6. package/codemods/runV1Codemods/runV1Codemods.spec.ts +2 -3
  7. package/codemods/utils/transformV1ButtonPropsToButtonOrLinkButton.ts +40 -0
  8. package/dist/cjs/src/MenuV1/index.cjs +3 -4
  9. package/dist/cjs/src/MenuV1/subcomponents/MenuHeading/MenuHeading.cjs +27 -0
  10. package/dist/cjs/src/MenuV1/subcomponents/MenuHeading/MenuHeading.module.scss.cjs +6 -0
  11. package/dist/cjs/src/TitleBlock/TitleBlock.cjs +36 -32
  12. package/dist/cjs/src/TitleBlock/TitleBlock.module.scss.cjs +1 -5
  13. package/dist/cjs/src/TitleBlock/subcomponents/MainActions.cjs +45 -90
  14. package/dist/cjs/src/TitleBlock/subcomponents/MainActions.module.scss.cjs +1 -3
  15. package/dist/cjs/src/TitleBlock/subcomponents/MobileActions.cjs +306 -0
  16. package/dist/cjs/src/TitleBlock/subcomponents/MobileActions.module.scss.cjs +16 -0
  17. package/dist/cjs/src/TitleBlock/subcomponents/SecondaryActions.cjs +14 -60
  18. package/dist/esm/src/MenuV1/index.mjs +3 -5
  19. package/dist/esm/src/MenuV1/subcomponents/MenuHeading/MenuHeading.mjs +21 -0
  20. package/dist/esm/src/MenuV1/subcomponents/MenuHeading/MenuHeading.module.scss.mjs +4 -0
  21. package/dist/esm/src/TitleBlock/TitleBlock.mjs +37 -33
  22. package/dist/esm/src/TitleBlock/TitleBlock.module.scss.mjs +1 -5
  23. package/dist/esm/src/TitleBlock/subcomponents/MainActions.mjs +47 -92
  24. package/dist/esm/src/TitleBlock/subcomponents/MainActions.module.scss.mjs +1 -3
  25. package/dist/esm/src/TitleBlock/subcomponents/MobileActions.mjs +300 -0
  26. package/dist/esm/src/TitleBlock/subcomponents/MobileActions.module.scss.mjs +14 -0
  27. package/dist/esm/src/TitleBlock/subcomponents/SecondaryActions.mjs +14 -60
  28. package/dist/styles.css +206 -82
  29. package/dist/types/TitleBlock/TitleBlock.d.ts +1 -1
  30. package/dist/types/TitleBlock/subcomponents/MainActions.d.ts +3 -4
  31. package/dist/types/TitleBlock/subcomponents/MobileActions.d.ts +14 -0
  32. package/package.json +1 -1
  33. package/src/TitleBlock/TitleBlock.module.scss +14 -55
  34. package/src/TitleBlock/TitleBlock.spec.tsx +461 -33
  35. package/src/TitleBlock/TitleBlock.tsx +24 -7
  36. package/src/TitleBlock/_docs/TitleBlock.stories.tsx +5 -25
  37. package/src/TitleBlock/_mixins.scss +0 -6
  38. package/src/TitleBlock/subcomponents/MainActions.module.scss +2 -28
  39. package/src/TitleBlock/subcomponents/MainActions.tsx +70 -127
  40. package/src/TitleBlock/subcomponents/MobileActions.module.scss +208 -0
  41. package/src/TitleBlock/subcomponents/MobileActions.spec.tsx +210 -0
  42. package/src/TitleBlock/subcomponents/MobileActions.tsx +472 -0
  43. package/src/TitleBlock/subcomponents/SecondaryActions.tsx +45 -114
  44. package/src/TitleBlock/subcomponents/Toolbar.tsx +0 -1
@@ -0,0 +1,300 @@
1
+ import { __assign } from 'tslib';
2
+ import React, { useState, useCallback, useEffect } from 'react';
3
+ import classnames from 'classnames';
4
+ import { FocusOn } from 'react-focus-on';
5
+ import { Icon } from '../../Icon/Icon.mjs';
6
+ import { MenuList, MenuHeading, MenuItem } from '../../MenuV1/index.mjs';
7
+ import { TITLE_BLOCK_ZEN_OTHER_ACTIONS_HTML_ID } from '../constants.mjs';
8
+ import { isMenuGroupNotButton, convertSecondaryActionsToMenuItems } from '../utils.mjs';
9
+ import { TitleBlockMenuItem } from './TitleBlockMenuItem.mjs';
10
+ import styles from './MobileActions.module.scss.mjs';
11
+ var menuItemIsLink = function (item) {
12
+ return 'href' in item;
13
+ };
14
+ var defaultActionIsLink = function (action) {
15
+ return 'href' in action;
16
+ };
17
+ var defaultActionIsButton = function (action) {
18
+ return !('href' in action) && 'onClick' in action || 'component' in action;
19
+ };
20
+ var filterActions = function (menuItems, filterType) {
21
+ return menuItems.filter(function (item) {
22
+ return filterType === 'link' ? menuItemIsLink(item) : !menuItemIsLink(item);
23
+ });
24
+ };
25
+ /** Returns a filtered array of TitleBlockMenuItem based on actionType
26
+ * This is use to sort a selectively render the action into a specifc order
27
+ */
28
+ var renderPrimaryActionDrawerContent = function (primaryAction, actionType) {
29
+ if (!primaryAction) return null;
30
+ if (isMenuGroupNotButton(primaryAction)) {
31
+ var filteredActions = filterActions(primaryAction.menuItems, actionType);
32
+ return filteredActions.map(function (item, idx) {
33
+ var itemType = menuItemIsLink(item) ? 'link' : 'action';
34
+ return /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({}, item, {
35
+ key: "title-block-mobile-actions-primary-".concat(itemType, "-").concat(idx),
36
+ "data-automation-id": "title-block-mobile-actions-primary-".concat(itemType, "-").concat(idx),
37
+ "data-testid": "title-block-mobile-actions-primary-".concat(itemType, "-").concat(idx)
38
+ }));
39
+ });
40
+ }
41
+ return null;
42
+ };
43
+ var renderDefaultLink = function (defaultAction) {
44
+ if (!defaultActionIsLink(defaultAction)) return;
45
+ if ('component' in defaultAction) {
46
+ return /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({}, defaultAction, {
47
+ key: "title-block-mobile-actions-default-link",
48
+ "data-automation-id": "title-block-mobile-actions-default-link",
49
+ "data-testid": "title-block-mobile-actions-default-link"
50
+ }));
51
+ }
52
+ return /*#__PURE__*/React.createElement(MenuItem, {
53
+ href: defaultAction.href,
54
+ label: defaultAction.label,
55
+ icon: defaultAction.icon,
56
+ disabled: defaultAction.disabled,
57
+ key: "title-block-mobile-actions-default-link",
58
+ "data-automation-id": "title-block-mobile-actions-default-link",
59
+ "data-testid": "title-block-mobile-actions-default-link",
60
+ id: defaultAction.id
61
+ });
62
+ };
63
+ var renderDefaultAction = function (defaultAction) {
64
+ if (!defaultActionIsLink(defaultAction)) {
65
+ return /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({}, defaultAction, {
66
+ key: "title-block-mobile-actions-default-action",
67
+ "data-automation-id": "title-block-mobile-actions-default-action",
68
+ "data-testid": "title-block-mobile-actions-default-action"
69
+ }));
70
+ }
71
+ return null;
72
+ };
73
+ var renderSecondaryActions = function (secondaryActions) {
74
+ if (!secondaryActions) return null;
75
+ var secondaryActionMenuItems = convertSecondaryActionsToMenuItems(secondaryActions);
76
+ return secondaryActionMenuItems.map(function (item, idx) {
77
+ return /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({}, item, {
78
+ key: "title-block-mobile-actions-secondary-action-".concat(idx),
79
+ "data-testid": "title-block-mobile-actions-secondary-action"
80
+ }));
81
+ });
82
+ };
83
+ var renderSecondaryOverflowMenuItems = function (secondaryOverflowMenuItems) {
84
+ return secondaryOverflowMenuItems.map(function (item, idx) {
85
+ return /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({}, item, {
86
+ key: "title-block-mobile-actions-overflow-menu-item-".concat(idx),
87
+ "data-testid": "title-block-mobile-actions-overflow-menu-item"
88
+ }));
89
+ });
90
+ };
91
+ var DrawerMenuContent = function (_a) {
92
+ var _b, _c, _d;
93
+ var primaryAction = _a.primaryAction,
94
+ defaultAction = _a.defaultAction,
95
+ secondaryActions = _a.secondaryActions,
96
+ secondaryOverflowMenuItems = _a.secondaryOverflowMenuItems;
97
+ var showOtherActionsHeading = (_c = (_b = defaultAction && defaultActionIsButton(defaultAction)) !== null && _b !== void 0 ? _b : secondaryActions) !== null && _c !== void 0 ? _c : secondaryOverflowMenuItems;
98
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MenuList, null, primaryAction && renderPrimaryActionDrawerContent(primaryAction, 'link'), defaultAction && renderDefaultLink(defaultAction), primaryAction && renderPrimaryActionDrawerContent(primaryAction, 'action')), ((_d = defaultAction !== null && defaultAction !== void 0 ? defaultAction : secondaryActions) !== null && _d !== void 0 ? _d : secondaryOverflowMenuItems) && (/*#__PURE__*/React.createElement(MenuList, {
99
+ heading: showOtherActionsHeading ? /*#__PURE__*/React.createElement(MenuHeading, null, "Other actions") : undefined
100
+ }, defaultAction && renderDefaultAction(defaultAction), secondaryActions && renderSecondaryActions(secondaryActions), secondaryOverflowMenuItems && renderSecondaryOverflowMenuItems(secondaryOverflowMenuItems))));
101
+ };
102
+ var renderDrawerHandleLabel = function (label, icon, drawerHandleLabelIconPosition) {
103
+ if (drawerHandleLabelIconPosition === 'end') {
104
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
105
+ className: styles.drawerHandleLabelText,
106
+ "data-testid": "drawer-handle-lable-text"
107
+ }, label), /*#__PURE__*/React.createElement(React.Fragment, null, icon && /*#__PURE__*/React.createElement("span", {
108
+ className: styles.drawerHandleIcon
109
+ }, icon)));
110
+ } else {
111
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(React.Fragment, null, icon && /*#__PURE__*/React.createElement("span", {
112
+ className: styles.drawerHandleIcon
113
+ }, icon)), /*#__PURE__*/React.createElement("span", {
114
+ className: styles.drawerHandleLabelText,
115
+ "data-testid": "drawer-handle-lable-text"
116
+ }, label));
117
+ }
118
+ };
119
+ var ButtonOrLink = function (_a) {
120
+ var action = _a.action,
121
+ children = _a.children;
122
+ if (typeof action === 'object' && 'onClick' in action && 'href' in action) {
123
+ return /*#__PURE__*/React.createElement("a", {
124
+ onClick: action.onClick,
125
+ href: action.href,
126
+ className: classnames(styles.mobileActionsPrimaryLabel, styles.mobileActionsPrimaryButton),
127
+ "data-testid": "title-block-mobile-actions-primary-button"
128
+ }, children);
129
+ }
130
+ if (typeof action === 'function') {
131
+ return /*#__PURE__*/React.createElement("button", {
132
+ type: "button",
133
+ onClick: action,
134
+ className: classnames(styles.mobileActionsPrimaryLabel, styles.mobileActionsPrimaryButton),
135
+ "data-testid": "title-block-mobile-actions-primary-button"
136
+ }, children);
137
+ }
138
+ if (typeof action === 'string') {
139
+ return /*#__PURE__*/React.createElement("a", {
140
+ href: action,
141
+ className: classnames(styles.mobileActionsPrimaryLabel, styles.mobileActionsPrimaryButton),
142
+ "data-testid": "title-block-mobile-actions-primary-button"
143
+ }, children);
144
+ }
145
+ // when there's no action (e.g. primary button is disabled)
146
+ return /*#__PURE__*/React.createElement("button", {
147
+ type: "button",
148
+ className: classnames(styles.mobileActionsPrimaryLabel, styles.mobileActionsPrimaryButton),
149
+ "data-testid": "title-block-mobile-actions-primary-button"
150
+ }, children);
151
+ };
152
+ var getAction = function (primaryAction) {
153
+ if (primaryAction && !primaryAction.disabled) {
154
+ if (primaryAction.onClick && primaryAction.href) {
155
+ return {
156
+ href: primaryAction.href,
157
+ onClick: primaryAction.onClick
158
+ };
159
+ }
160
+ if (primaryAction.onClick) {
161
+ return primaryAction.onClick;
162
+ }
163
+ if (primaryAction.href) {
164
+ return primaryAction.href;
165
+ }
166
+ }
167
+ return undefined;
168
+ };
169
+ var DrawerHandle = function (_a) {
170
+ var _b;
171
+ var primaryAction = _a.primaryAction,
172
+ secondaryActions = _a.secondaryActions,
173
+ defaultAction = _a.defaultAction,
174
+ secondaryOverflowMenuItems = _a.secondaryOverflowMenuItems,
175
+ drawerHandleLabelIconPosition = _a.drawerHandleLabelIconPosition,
176
+ toggleDisplay = _a.toggleDisplay,
177
+ isOpen = _a.isOpen;
178
+ var showDrawer = (_b = defaultAction !== null && defaultAction !== void 0 ? defaultAction : secondaryActions) !== null && _b !== void 0 ? _b : secondaryOverflowMenuItems;
179
+ if (primaryAction) {
180
+ // If the primary action is a menu
181
+ if (isMenuGroupNotButton(primaryAction)) {
182
+ return /*#__PURE__*/React.createElement("div", {
183
+ className: classnames(styles.mobileActionsTopRow, styles.mobileActionsTopRowSingleButton),
184
+ "data-testid": "title-block-mobile-actions-drawer-handle"
185
+ }, /*#__PURE__*/React.createElement("button", {
186
+ type: "button",
187
+ className: classnames(styles.mobileActionsExpandButton, styles.mobileActionsPrimaryLabel),
188
+ onClick: toggleDisplay,
189
+ "aria-expanded": isOpen
190
+ }, primaryAction.label, /*#__PURE__*/React.createElement("span", {
191
+ className: styles.mobileActionsChevronSquare
192
+ }, /*#__PURE__*/React.createElement(Icon, {
193
+ name: isOpen ? 'keyboard_arrow_down' : 'keyboard_arrow_up',
194
+ isPresentational: true
195
+ }))));
196
+ }
197
+ // If the primary action is a button, or has no onClick/href/action
198
+ return /*#__PURE__*/React.createElement("div", {
199
+ className: classnames(styles.mobileActionsTopRow, !showDrawer && styles.mobileActionsTopRowSingleButton),
200
+ "data-testid": "title-block-mobile-actions-drawer-handle"
201
+ }, 'component' in primaryAction ? (/*#__PURE__*/React.createElement(primaryAction.component, __assign({
202
+ className: classnames(styles.mobileActionsPrimaryLabel, styles.mobileActionsPrimaryButton)
203
+ }, primaryAction), primaryAction.label && renderDrawerHandleLabel(primaryAction.label, primaryAction.icon, drawerHandleLabelIconPosition))) : (/*#__PURE__*/React.createElement(ButtonOrLink, {
204
+ action: getAction(primaryAction)
205
+ }, renderDrawerHandleLabel(primaryAction.label, primaryAction.icon, drawerHandleLabelIconPosition))), showDrawer && (/*#__PURE__*/React.createElement("button", {
206
+ type: "button",
207
+ className: styles.mobileActionsExpandButton,
208
+ onClick: toggleDisplay,
209
+ "aria-expanded": isOpen,
210
+ id: TITLE_BLOCK_ZEN_OTHER_ACTIONS_HTML_ID,
211
+ "aria-label": "Other actions"
212
+ }, /*#__PURE__*/React.createElement(Icon, {
213
+ name: isOpen ? 'keyboard_arrow_down' : 'keyboard_arrow_up',
214
+ isPresentational: true
215
+ }))));
216
+ }
217
+ // if there are default/secondary actions but no primary action
218
+ if (showDrawer) {
219
+ return /*#__PURE__*/React.createElement("div", {
220
+ className: classnames(styles.mobileActionsTopRow, styles.mobileActionsTopRowSingleButton),
221
+ "data-testid": "title-block-mobile-actions-drawer-handle"
222
+ }, /*#__PURE__*/React.createElement("button", {
223
+ type: "button",
224
+ className: classnames(styles.mobileActionsExpandButton, styles.mobileActionsPrimaryLabel),
225
+ onClick: toggleDisplay,
226
+ "aria-expanded": isOpen,
227
+ id: TITLE_BLOCK_ZEN_OTHER_ACTIONS_HTML_ID
228
+ }, renderDrawerHandleLabel('Other actions'), /*#__PURE__*/React.createElement("span", {
229
+ className: styles.mobileActionsChevronSquare
230
+ }, /*#__PURE__*/React.createElement(Icon, {
231
+ name: isOpen ? 'keyboard_arrow_down' : 'keyboard_arrow_up',
232
+ isPresentational: true
233
+ }))));
234
+ }
235
+ return null;
236
+ };
237
+ const MobileActions = /*#__PURE__*/function () {
238
+ const MobileActions = function (_a) {
239
+ var _b, _c;
240
+ var primaryAction = _a.primaryAction,
241
+ defaultAction = _a.defaultAction,
242
+ secondaryActions = _a.secondaryActions,
243
+ secondaryOverflowMenuItems = _a.secondaryOverflowMenuItems,
244
+ drawerHandleLabelIconPosition = _a.drawerHandleLabelIconPosition,
245
+ _d = _a.autoHide,
246
+ autoHide = _d === void 0 ? false : _d;
247
+ var _e = useState(false),
248
+ isOpen = _e[0],
249
+ setIsOpen = _e[1];
250
+ var menuContent = /*#__PURE__*/React.createRef();
251
+ var toggleDisplay = function () {
252
+ setIsOpen(!isOpen);
253
+ };
254
+ // This callback handler will not run when autoHide === "off"
255
+ var handleDocumentClickForAutoHide = useCallback(function (e) {
256
+ var _a;
257
+ if (isOpen && e.target instanceof Node && ((_a = menuContent.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
258
+ setIsOpen(false);
259
+ }
260
+ },
261
+ // @todo: Fix if possible - avoiding breaking in eslint upgrade
262
+ // eslint-disable-next-line react-hooks/exhaustive-deps
263
+ [menuContent]);
264
+ useEffect(function () {
265
+ if (autoHide) {
266
+ document.addEventListener('click', handleDocumentClickForAutoHide, true);
267
+ }
268
+ return function () {
269
+ if (autoHide) {
270
+ document.removeEventListener('click', handleDocumentClickForAutoHide, true);
271
+ }
272
+ };
273
+ }, [autoHide, handleDocumentClickForAutoHide]);
274
+ return /*#__PURE__*/React.createElement("div", {
275
+ className: classnames(styles.mobileActionsContainer, isOpen && styles.isOpen)
276
+ }, /*#__PURE__*/React.createElement(FocusOn, {
277
+ enabled: isOpen,
278
+ scrollLock: false
279
+ }, /*#__PURE__*/React.createElement(DrawerHandle, {
280
+ primaryAction: primaryAction,
281
+ secondaryActions: secondaryActions,
282
+ defaultAction: defaultAction,
283
+ secondaryOverflowMenuItems: secondaryOverflowMenuItems,
284
+ drawerHandleLabelIconPosition: drawerHandleLabelIconPosition,
285
+ toggleDisplay: toggleDisplay,
286
+ isOpen: isOpen
287
+ }), ((_c = (_b = defaultAction !== null && defaultAction !== void 0 ? defaultAction : secondaryActions) !== null && _b !== void 0 ? _b : secondaryOverflowMenuItems) !== null && _c !== void 0 ? _c : primaryAction && isMenuGroupNotButton(primaryAction)) && (/*#__PURE__*/React.createElement("div", {
288
+ ref: menuContent,
289
+ className: styles.mobileActionsMenuContainer
290
+ }, /*#__PURE__*/React.createElement(DrawerMenuContent, {
291
+ primaryAction: primaryAction,
292
+ defaultAction: defaultAction,
293
+ secondaryActions: secondaryActions,
294
+ secondaryOverflowMenuItems: secondaryOverflowMenuItems
295
+ })))));
296
+ };
297
+ MobileActions.displayName = 'MobileActions';
298
+ return MobileActions;
299
+ }();
300
+ export { MobileActions };
@@ -0,0 +1,14 @@
1
+ var styles = {
2
+ "mobileActionsContainer": "MobileActions-module_mobileActionsContainer__XoepA",
3
+ "isOpen": "MobileActions-module_isOpen__D40v5",
4
+ "mobileActionsMenuContainer": "MobileActions-module_mobileActionsMenuContainer__x--Eb",
5
+ "mobileActionsTopRow": "MobileActions-module_mobileActionsTopRow__RXNFZ",
6
+ "mobileActionsTopRowSingleButton": "MobileActions-module_mobileActionsTopRowSingleButton__5EjiI",
7
+ "drawerHandleIcon": "MobileActions-module_drawerHandleIcon__q9ewm",
8
+ "drawerHandleLabelText": "MobileActions-module_drawerHandleLabelText__MwJTA",
9
+ "mobileActionsPrimaryLabel": "MobileActions-module_mobileActionsPrimaryLabel__8yfuH",
10
+ "mobileActionsPrimaryButton": "MobileActions-module_mobileActionsPrimaryButton__Xsvo-",
11
+ "mobileActionsExpandButton": "MobileActions-module_mobileActionsExpandButton__XuHNU",
12
+ "mobileActionsChevronSquare": "MobileActions-module_mobileActionsChevronSquare__SPIsI"
13
+ };
14
+ export { styles as default };
@@ -6,64 +6,26 @@ import { Icon } from '../../Icon/Icon.mjs';
6
6
  import { Menu, MenuList } from '../../MenuV1/index.mjs';
7
7
  import styles from '../TitleBlock.module.scss.mjs';
8
8
  import { TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID } from '../constants.mjs';
9
- import { convertSecondaryActionsToMenuItems } from '../utils.mjs';
10
9
  import { TitleBlockMenuItem } from './TitleBlockMenuItem.mjs';
11
10
  import { Toolbar } from './Toolbar.mjs';
12
11
  var renderSecondaryOverflowMenu = function (secondaryOverflowMenuItems, reversed) {
13
- if (!secondaryOverflowMenuItems || secondaryOverflowMenuItems.length === 0) return undefined;
14
- return /*#__PURE__*/React.createElement("div", {
15
- className: styles.secondaryOverflowMenu
16
- }, /*#__PURE__*/React.createElement(Menu, {
17
- align: "right",
18
- button: /*#__PURE__*/React.createElement(Button, {
19
- secondary: true,
20
- reversed: reversed,
21
- label: "Menu",
22
- "data-automation-id": TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID,
23
- "data-testid": TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID,
24
- icon: /*#__PURE__*/React.createElement(Icon, {
25
- name: "keyboard_arrow_down",
26
- isPresentational: true
27
- }),
28
- iconPosition: 'end'
29
- })
30
- }, /*#__PURE__*/React.createElement(MenuList, null, secondaryOverflowMenuItems.map(function (menuItem, i) {
31
- return /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({
32
- key: i
33
- }, menuItem));
34
- }))));
35
- };
36
- // New: combined overflow menu (secondary actions converted + overflow menu items)
37
- var renderCombinedSecondaryOverflowMenu = function (secondaryActions, secondaryOverflowMenuItems, reversed) {
38
- console.log('this is renderCombinedSecondaryOverflowMenu called');
39
- var secondaryConverted = secondaryActions ? convertSecondaryActionsToMenuItems(secondaryActions) : [];
40
- var overflowItems = secondaryOverflowMenuItems !== null && secondaryOverflowMenuItems !== void 0 ? secondaryOverflowMenuItems : [];
41
- console.log('this is secondaryConverted', secondaryConverted);
42
- console.log('this is secondaryConverted:', secondaryConverted);
43
- console.log('this is overflowItems:', overflowItems);
44
- // Only render if we have at least one secondary action AND at least one overflow item to avoid duplicating single menus
45
- // || overflowItems.length === 0
46
- if (secondaryConverted.length === 0) return undefined;
47
- var combined = __spreadArray(__spreadArray([], secondaryConverted, true), overflowItems, true);
48
- console.log('this is combined:', combined);
49
- return /*#__PURE__*/React.createElement("div", {
50
- className: styles.secondaryOverflowCombinedMenu
51
- }, /*#__PURE__*/React.createElement(Menu, {
12
+ if (!secondaryOverflowMenuItems) return undefined;
13
+ return /*#__PURE__*/React.createElement(Menu, {
52
14
  align: "right",
53
15
  button: /*#__PURE__*/React.createElement(IconButton, {
54
- label: "Open combined secondary + overflow menu",
16
+ label: "Open secondary menu",
55
17
  reversed: reversed,
56
18
  icon: /*#__PURE__*/React.createElement(Icon, {
57
19
  name: "more_horiz",
58
20
  isPresentational: true
59
21
  }),
60
- id: "".concat(TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID, "__combined")
22
+ id: TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID
61
23
  })
62
- }, /*#__PURE__*/React.createElement(MenuList, null, combined.map(function (menuItem, i) {
24
+ }, /*#__PURE__*/React.createElement(MenuList, null, secondaryOverflowMenuItems.map(function (menuItem, i) {
63
25
  return /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({
64
26
  key: i
65
27
  }, menuItem));
66
- }))));
28
+ })));
67
29
  };
68
30
  // Unfortunately, you'll notice below, that I needed to use the array index,
69
31
  // against react best practices (https://reactjs.org/docs/lists-and-keys.html)
@@ -78,10 +40,9 @@ const SecondaryActions = /*#__PURE__*/function () {
78
40
  var secondaryActionsAsToolbarItems = secondaryActions ? secondaryActions.map(function (action, i) {
79
41
  if ('menuItems' in action) {
80
42
  return {
81
- key: "titleblock_secondary_action_".concat(i),
82
- node: (/*#__PURE__*/React.createElement("div", {
83
- className: styles.secondaryButtonContainer
84
- }, /*#__PURE__*/React.createElement(Menu, {
43
+ key: "".concat(i),
44
+ // We shouldn't use an index here, see note above
45
+ node: (/*#__PURE__*/React.createElement(Menu, {
85
46
  align: "right",
86
47
  button: /*#__PURE__*/React.createElement(Button, {
87
48
  secondary: true,
@@ -97,7 +58,7 @@ const SecondaryActions = /*#__PURE__*/function () {
97
58
  return /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({
98
59
  key: i2
99
60
  }, menuItem));
100
- })))))
61
+ }))))
101
62
  };
102
63
  } else {
103
64
  if ('onClick' in action && 'href' in action) {
@@ -106,28 +67,21 @@ const SecondaryActions = /*#__PURE__*/function () {
106
67
  }
107
68
  return {
108
69
  key: "".concat(i),
109
- node: (/*#__PURE__*/React.createElement("div", {
110
- className: styles.secondaryButtonContainer
111
- }, /*#__PURE__*/React.createElement(Button, __assign({
70
+ // We shouldn't use an index here, see note above
71
+ node: (/*#__PURE__*/React.createElement(Button, __assign({
112
72
  secondary: true,
113
73
  reversed: reversed
114
74
  }, action, {
115
75
  "data-automation-id": "title-block-secondary-actions-button",
116
76
  "data-testid": "title-block-secondary-actions-button"
117
- }))))
77
+ })))
118
78
  };
119
79
  }
120
80
  }) : [];
121
81
  var overflowMenu = renderSecondaryOverflowMenu(secondaryOverflowMenuItems, reversed);
122
- var combinedOverflowMenu = renderCombinedSecondaryOverflowMenu(secondaryActions, secondaryOverflowMenuItems, reversed);
123
- console.log('SecondaryActions this is overflowMenu:', overflowMenu);
124
- console.log('SecondaryActions this is combinedOverflowMenu :', combinedOverflowMenu);
125
- var toolbarItems = __spreadArray(__spreadArray(__spreadArray([], secondaryActionsAsToolbarItems, true), overflowMenu ? [{
82
+ var toolbarItems = __spreadArray(__spreadArray([], secondaryActionsAsToolbarItems, true), overflowMenu ? [{
126
83
  key: 'overflowMenu',
127
84
  node: overflowMenu
128
- }] : [], true), combinedOverflowMenu ? [{
129
- key: 'combinedOverflowMenu',
130
- node: combinedOverflowMenu
131
85
  }] : [], true);
132
86
  return /*#__PURE__*/React.createElement("div", {
133
87
  className: styles.secondaryActionsContainer