@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.
- package/codemods/migrateGuidanceBlockActionsToActionsSlot/migrateGuidanceBlockActionsToActionsSlot.spec.ts +209 -26
- package/codemods/migrateGuidanceBlockActionsToActionsSlot/migrateGuidanceBlockActionsToActionsSlot.ts +24 -1
- package/codemods/migrateGuidanceBlockActionsToActionsSlot/transformActionsToActionsSlot.spec.ts +2 -1
- package/codemods/migrateGuidanceBlockActionsToActionsSlot/transformActionsToActionsSlot.ts +20 -0
- package/codemods/runV1Codemods/__snapshots__/runV1Codemods.spec.ts.snap +2 -3
- package/codemods/runV1Codemods/runV1Codemods.spec.ts +2 -3
- package/codemods/utils/transformV1ButtonPropsToButtonOrLinkButton.ts +40 -0
- package/dist/cjs/src/MenuV1/index.cjs +3 -4
- package/dist/cjs/src/MenuV1/subcomponents/MenuHeading/MenuHeading.cjs +27 -0
- package/dist/cjs/src/MenuV1/subcomponents/MenuHeading/MenuHeading.module.scss.cjs +6 -0
- package/dist/cjs/src/TitleBlock/TitleBlock.cjs +36 -32
- package/dist/cjs/src/TitleBlock/TitleBlock.module.scss.cjs +1 -5
- package/dist/cjs/src/TitleBlock/subcomponents/MainActions.cjs +45 -90
- package/dist/cjs/src/TitleBlock/subcomponents/MainActions.module.scss.cjs +1 -3
- package/dist/cjs/src/TitleBlock/subcomponents/MobileActions.cjs +306 -0
- package/dist/cjs/src/TitleBlock/subcomponents/MobileActions.module.scss.cjs +16 -0
- package/dist/cjs/src/TitleBlock/subcomponents/SecondaryActions.cjs +14 -60
- package/dist/esm/src/MenuV1/index.mjs +3 -5
- package/dist/esm/src/MenuV1/subcomponents/MenuHeading/MenuHeading.mjs +21 -0
- package/dist/esm/src/MenuV1/subcomponents/MenuHeading/MenuHeading.module.scss.mjs +4 -0
- package/dist/esm/src/TitleBlock/TitleBlock.mjs +37 -33
- package/dist/esm/src/TitleBlock/TitleBlock.module.scss.mjs +1 -5
- package/dist/esm/src/TitleBlock/subcomponents/MainActions.mjs +47 -92
- package/dist/esm/src/TitleBlock/subcomponents/MainActions.module.scss.mjs +1 -3
- package/dist/esm/src/TitleBlock/subcomponents/MobileActions.mjs +300 -0
- package/dist/esm/src/TitleBlock/subcomponents/MobileActions.module.scss.mjs +14 -0
- package/dist/esm/src/TitleBlock/subcomponents/SecondaryActions.mjs +14 -60
- package/dist/styles.css +206 -82
- package/dist/types/TitleBlock/TitleBlock.d.ts +1 -1
- package/dist/types/TitleBlock/subcomponents/MainActions.d.ts +3 -4
- package/dist/types/TitleBlock/subcomponents/MobileActions.d.ts +14 -0
- package/package.json +1 -1
- package/src/TitleBlock/TitleBlock.module.scss +14 -55
- package/src/TitleBlock/TitleBlock.spec.tsx +461 -33
- package/src/TitleBlock/TitleBlock.tsx +24 -7
- package/src/TitleBlock/_docs/TitleBlock.stories.tsx +5 -25
- package/src/TitleBlock/_mixins.scss +0 -6
- package/src/TitleBlock/subcomponents/MainActions.module.scss +2 -28
- package/src/TitleBlock/subcomponents/MainActions.tsx +70 -127
- package/src/TitleBlock/subcomponents/MobileActions.module.scss +208 -0
- package/src/TitleBlock/subcomponents/MobileActions.spec.tsx +210 -0
- package/src/TitleBlock/subcomponents/MobileActions.tsx +472 -0
- package/src/TitleBlock/subcomponents/SecondaryActions.tsx +45 -114
- package/src/TitleBlock/subcomponents/Toolbar.tsx +0 -1
|
@@ -8,7 +8,6 @@ var Icon = require('../../Icon/Icon.cjs');
|
|
|
8
8
|
var index = require('../../MenuV1/index.cjs');
|
|
9
9
|
var TitleBlock_module = require('../TitleBlock.module.scss.cjs');
|
|
10
10
|
var constants = require('../constants.cjs');
|
|
11
|
-
var utils = require('../utils.cjs');
|
|
12
11
|
var TitleBlockMenuItem = require('./TitleBlockMenuItem.cjs');
|
|
13
12
|
var Toolbar = require('./Toolbar.cjs');
|
|
14
13
|
function _interopDefault(e) {
|
|
@@ -18,60 +17,23 @@ function _interopDefault(e) {
|
|
|
18
17
|
}
|
|
19
18
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
20
19
|
var renderSecondaryOverflowMenu = function (secondaryOverflowMenuItems, reversed) {
|
|
21
|
-
if (!secondaryOverflowMenuItems
|
|
22
|
-
return React__default.default.createElement(
|
|
23
|
-
className: TitleBlock_module.secondaryOverflowMenu
|
|
24
|
-
}, React__default.default.createElement(index.Menu, {
|
|
25
|
-
align: "right",
|
|
26
|
-
button: React__default.default.createElement(Button.Button, {
|
|
27
|
-
secondary: true,
|
|
28
|
-
reversed: reversed,
|
|
29
|
-
label: "Menu",
|
|
30
|
-
"data-automation-id": constants.TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID,
|
|
31
|
-
"data-testid": constants.TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID,
|
|
32
|
-
icon: React__default.default.createElement(Icon.Icon, {
|
|
33
|
-
name: "keyboard_arrow_down",
|
|
34
|
-
isPresentational: true
|
|
35
|
-
}),
|
|
36
|
-
iconPosition: 'end'
|
|
37
|
-
})
|
|
38
|
-
}, React__default.default.createElement(index.MenuList, null, secondaryOverflowMenuItems.map(function (menuItem, i) {
|
|
39
|
-
return React__default.default.createElement(TitleBlockMenuItem.TitleBlockMenuItem, tslib.__assign({
|
|
40
|
-
key: i
|
|
41
|
-
}, menuItem));
|
|
42
|
-
}))));
|
|
43
|
-
};
|
|
44
|
-
// New: combined overflow menu (secondary actions converted + overflow menu items)
|
|
45
|
-
var renderCombinedSecondaryOverflowMenu = function (secondaryActions, secondaryOverflowMenuItems, reversed) {
|
|
46
|
-
console.log('this is renderCombinedSecondaryOverflowMenu called');
|
|
47
|
-
var secondaryConverted = secondaryActions ? utils.convertSecondaryActionsToMenuItems(secondaryActions) : [];
|
|
48
|
-
var overflowItems = secondaryOverflowMenuItems !== null && secondaryOverflowMenuItems !== void 0 ? secondaryOverflowMenuItems : [];
|
|
49
|
-
console.log('this is secondaryConverted', secondaryConverted);
|
|
50
|
-
console.log('this is secondaryConverted:', secondaryConverted);
|
|
51
|
-
console.log('this is overflowItems:', overflowItems);
|
|
52
|
-
// Only render if we have at least one secondary action AND at least one overflow item to avoid duplicating single menus
|
|
53
|
-
// || overflowItems.length === 0
|
|
54
|
-
if (secondaryConverted.length === 0) return undefined;
|
|
55
|
-
var combined = tslib.__spreadArray(tslib.__spreadArray([], secondaryConverted, true), overflowItems, true);
|
|
56
|
-
console.log('this is combined:', combined);
|
|
57
|
-
return React__default.default.createElement("div", {
|
|
58
|
-
className: TitleBlock_module.secondaryOverflowCombinedMenu
|
|
59
|
-
}, React__default.default.createElement(index.Menu, {
|
|
20
|
+
if (!secondaryOverflowMenuItems) return undefined;
|
|
21
|
+
return React__default.default.createElement(index.Menu, {
|
|
60
22
|
align: "right",
|
|
61
23
|
button: React__default.default.createElement(IconButton.IconButton, {
|
|
62
|
-
label: "Open
|
|
24
|
+
label: "Open secondary menu",
|
|
63
25
|
reversed: reversed,
|
|
64
26
|
icon: React__default.default.createElement(Icon.Icon, {
|
|
65
27
|
name: "more_horiz",
|
|
66
28
|
isPresentational: true
|
|
67
29
|
}),
|
|
68
|
-
id:
|
|
30
|
+
id: constants.TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID
|
|
69
31
|
})
|
|
70
|
-
}, React__default.default.createElement(index.MenuList, null,
|
|
32
|
+
}, React__default.default.createElement(index.MenuList, null, secondaryOverflowMenuItems.map(function (menuItem, i) {
|
|
71
33
|
return React__default.default.createElement(TitleBlockMenuItem.TitleBlockMenuItem, tslib.__assign({
|
|
72
34
|
key: i
|
|
73
35
|
}, menuItem));
|
|
74
|
-
})))
|
|
36
|
+
})));
|
|
75
37
|
};
|
|
76
38
|
// Unfortunately, you'll notice below, that I needed to use the array index,
|
|
77
39
|
// against react best practices (https://reactjs.org/docs/lists-and-keys.html)
|
|
@@ -85,10 +47,9 @@ var SecondaryActions = function (_a) {
|
|
|
85
47
|
var secondaryActionsAsToolbarItems = secondaryActions ? secondaryActions.map(function (action, i) {
|
|
86
48
|
if ('menuItems' in action) {
|
|
87
49
|
return {
|
|
88
|
-
key: "
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}, React__default.default.createElement(index.Menu, {
|
|
50
|
+
key: "".concat(i),
|
|
51
|
+
// We shouldn't use an index here, see note above
|
|
52
|
+
node: React__default.default.createElement(index.Menu, {
|
|
92
53
|
align: "right",
|
|
93
54
|
button: React__default.default.createElement(Button.Button, {
|
|
94
55
|
secondary: true,
|
|
@@ -104,7 +65,7 @@ var SecondaryActions = function (_a) {
|
|
|
104
65
|
return React__default.default.createElement(TitleBlockMenuItem.TitleBlockMenuItem, tslib.__assign({
|
|
105
66
|
key: i2
|
|
106
67
|
}, menuItem));
|
|
107
|
-
})))
|
|
68
|
+
})))
|
|
108
69
|
};
|
|
109
70
|
} else {
|
|
110
71
|
if ('onClick' in action && 'href' in action) {
|
|
@@ -113,28 +74,21 @@ var SecondaryActions = function (_a) {
|
|
|
113
74
|
}
|
|
114
75
|
return {
|
|
115
76
|
key: "".concat(i),
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}, React__default.default.createElement(Button.Button, tslib.__assign({
|
|
77
|
+
// We shouldn't use an index here, see note above
|
|
78
|
+
node: React__default.default.createElement(Button.Button, tslib.__assign({
|
|
119
79
|
secondary: true,
|
|
120
80
|
reversed: reversed
|
|
121
81
|
}, action, {
|
|
122
82
|
"data-automation-id": "title-block-secondary-actions-button",
|
|
123
83
|
"data-testid": "title-block-secondary-actions-button"
|
|
124
|
-
}))
|
|
84
|
+
}))
|
|
125
85
|
};
|
|
126
86
|
}
|
|
127
87
|
}) : [];
|
|
128
88
|
var overflowMenu = renderSecondaryOverflowMenu(secondaryOverflowMenuItems, reversed);
|
|
129
|
-
var
|
|
130
|
-
console.log('SecondaryActions this is overflowMenu:', overflowMenu);
|
|
131
|
-
console.log('SecondaryActions this is combinedOverflowMenu :', combinedOverflowMenu);
|
|
132
|
-
var toolbarItems = tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray([], secondaryActionsAsToolbarItems, true), overflowMenu ? [{
|
|
89
|
+
var toolbarItems = tslib.__spreadArray(tslib.__spreadArray([], secondaryActionsAsToolbarItems, true), overflowMenu ? [{
|
|
133
90
|
key: 'overflowMenu',
|
|
134
91
|
node: overflowMenu
|
|
135
|
-
}] : [], true), combinedOverflowMenu ? [{
|
|
136
|
-
key: 'combinedOverflowMenu',
|
|
137
|
-
node: combinedOverflowMenu
|
|
138
92
|
}] : [], true);
|
|
139
93
|
return React__default.default.createElement("div", {
|
|
140
94
|
className: TitleBlock_module.secondaryActionsContainer
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { Menu as Menu$1 } from './Menu.mjs';
|
|
2
|
-
import '
|
|
3
|
-
import 'react';
|
|
4
|
-
import 'classnames';
|
|
5
|
-
import '../Heading/Heading.mjs';
|
|
2
|
+
import { MenuHeading as MenuHeading$1 } from './subcomponents/MenuHeading/MenuHeading.mjs';
|
|
6
3
|
import { MenuItem as MenuItem$1 } from './subcomponents/MenuItem/MenuItem.mjs';
|
|
7
4
|
import { MenuList as MenuList$1 } from './subcomponents/MenuList/MenuList.mjs';
|
|
8
5
|
import './subcomponents/StatelessMenu/StatelessMenu.mjs';
|
|
9
6
|
|
|
10
7
|
// Since we can't add a deprecation flag on a * export
|
|
11
8
|
var Menu = Menu$1;
|
|
9
|
+
var MenuHeading = MenuHeading$1;
|
|
12
10
|
var MenuItem = MenuItem$1;
|
|
13
11
|
var MenuList = MenuList$1;
|
|
14
|
-
export { Menu, MenuItem, MenuList };
|
|
12
|
+
export { Menu, MenuHeading, MenuItem, MenuList };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { __rest, __assign } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { Heading } from '../../../Heading/Heading.mjs';
|
|
5
|
+
import styles from './MenuHeading.module.scss.mjs';
|
|
6
|
+
const MenuHeading = /*#__PURE__*/function () {
|
|
7
|
+
const MenuHeading = function (_a) {
|
|
8
|
+
var id = _a.id,
|
|
9
|
+
classNameOverride = _a.classNameOverride,
|
|
10
|
+
restProps = __rest(_a, ["id", "classNameOverride"]);
|
|
11
|
+
return /*#__PURE__*/React.createElement(Heading, __assign({
|
|
12
|
+
id: id,
|
|
13
|
+
variant: "heading-6",
|
|
14
|
+
tag: "span",
|
|
15
|
+
classNameOverride: classnames(styles.heading, classNameOverride)
|
|
16
|
+
}, restProps));
|
|
17
|
+
};
|
|
18
|
+
MenuHeading.displayName = 'MenuHeading';
|
|
19
|
+
return MenuHeading;
|
|
20
|
+
}();
|
|
21
|
+
export { MenuHeading };
|
|
@@ -10,8 +10,9 @@ import { Select } from '../Select/Select.mjs';
|
|
|
10
10
|
import { Tag } from '../Tag/Tag.mjs';
|
|
11
11
|
import { useMediaQueries } from '../utils/useMediaQueries.mjs';
|
|
12
12
|
import { MainActions } from './subcomponents/MainActions.mjs';
|
|
13
|
+
import { MobileActions } from './subcomponents/MobileActions.mjs';
|
|
13
14
|
import { SecondaryActions } from './subcomponents/SecondaryActions.mjs';
|
|
14
|
-
import { isReversed } from './utils.mjs';
|
|
15
|
+
import { isReversed, createTabletOverflowMenuItems } from './utils.mjs';
|
|
15
16
|
import styles from './TitleBlock.module.scss.mjs';
|
|
16
17
|
var renderTag = function (surveyStatus) {
|
|
17
18
|
var tagVariant;
|
|
@@ -107,12 +108,6 @@ var Breadcrumb = function (_a) {
|
|
|
107
108
|
name: "arrow_back",
|
|
108
109
|
isPresentational: true,
|
|
109
110
|
shouldMirrorInRTL: true
|
|
110
|
-
})), /*#__PURE__*/React.createElement("div", {
|
|
111
|
-
className: styles.staticIcon
|
|
112
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
113
|
-
name: "arrow_back",
|
|
114
|
-
isPresentational: true,
|
|
115
|
-
shouldMirrorInRTL: true
|
|
116
111
|
})), /*#__PURE__*/React.createElement("span", {
|
|
117
112
|
className: styles.breadcrumbTextLink,
|
|
118
113
|
"data-automation-id": textAutomationId,
|
|
@@ -169,7 +164,7 @@ var renderNavigationTabs = function (navigationTabs, collapse, ariaLabel) {
|
|
|
169
164
|
*/
|
|
170
165
|
const TitleBlock = /*#__PURE__*/function () {
|
|
171
166
|
const TitleBlock = function (_a) {
|
|
172
|
-
var _b, _c, _d;
|
|
167
|
+
var _b, _c, _d, _e;
|
|
173
168
|
var title = _a.title,
|
|
174
169
|
variant = _a.variant,
|
|
175
170
|
breadcrumb = _a.breadcrumb,
|
|
@@ -185,30 +180,32 @@ const TitleBlock = /*#__PURE__*/function () {
|
|
|
185
180
|
secondaryActions = _a.secondaryActions,
|
|
186
181
|
secondaryOverflowMenuItems = _a.secondaryOverflowMenuItems,
|
|
187
182
|
navigationTabs = _a.navigationTabs,
|
|
188
|
-
|
|
189
|
-
collapseNavigationAreaWhenPossible =
|
|
183
|
+
_f = _a.collapseNavigationAreaWhenPossible,
|
|
184
|
+
collapseNavigationAreaWhenPossible = _f === void 0 ? false : _f,
|
|
190
185
|
textDirection = _a.textDirection,
|
|
191
186
|
surveyStatus = _a.surveyStatus,
|
|
192
187
|
id = _a.id,
|
|
193
|
-
|
|
194
|
-
titleAutomationId =
|
|
195
|
-
|
|
196
|
-
avatarAutomationId =
|
|
197
|
-
|
|
198
|
-
subtitleAutomationId =
|
|
199
|
-
|
|
200
|
-
sectionTitleAutomationId =
|
|
201
|
-
|
|
202
|
-
sectionTitleDescriptionAutomationId =
|
|
203
|
-
|
|
204
|
-
breadcrumbAutomationId =
|
|
205
|
-
|
|
206
|
-
breadcrumbTextAutomationId =
|
|
188
|
+
_g = _a.titleAutomationId,
|
|
189
|
+
titleAutomationId = _g === void 0 ? 'TitleBlock__Title' : _g,
|
|
190
|
+
_h = _a.avatarAutomationId,
|
|
191
|
+
avatarAutomationId = _h === void 0 ? 'TitleBlock__Avatar' : _h,
|
|
192
|
+
_j = _a.subtitleAutomationId,
|
|
193
|
+
subtitleAutomationId = _j === void 0 ? 'TitleBlock__Subtitle' : _j,
|
|
194
|
+
_k = _a.sectionTitleAutomationId,
|
|
195
|
+
sectionTitleAutomationId = _k === void 0 ? 'TitleBlock__SectionTitle' : _k,
|
|
196
|
+
_l = _a.sectionTitleDescriptionAutomationId,
|
|
197
|
+
sectionTitleDescriptionAutomationId = _l === void 0 ? 'TitleBlock__SectionTitleDescription' : _l,
|
|
198
|
+
_m = _a.breadcrumbAutomationId,
|
|
199
|
+
breadcrumbAutomationId = _m === void 0 ? 'TitleBlock__Breadcrumb' : _m,
|
|
200
|
+
_o = _a.breadcrumbTextAutomationId,
|
|
201
|
+
breadcrumbTextAutomationId = _o === void 0 ? 'TitleBlock__BreadcrumbText' : _o,
|
|
202
|
+
_p = _a.autoHideMobileActionsMenu,
|
|
203
|
+
autoHideMobileActionsMenu = _p === void 0 ? false : _p;
|
|
207
204
|
var hasNavigationTabs = navigationTabs && navigationTabs.length > 0;
|
|
208
205
|
var collapseNavigationArea = collapseNavigationAreaWhenPossible && !hasNavigationTabs && secondaryActions === undefined;
|
|
209
|
-
var
|
|
210
|
-
isSmall =
|
|
211
|
-
isMedium =
|
|
206
|
+
var _q = useMediaQueries().queries,
|
|
207
|
+
isSmall = _q.isSmall,
|
|
208
|
+
isMedium = _q.isMedium;
|
|
212
209
|
var isSmallOrMediumViewport = isMedium || isSmall;
|
|
213
210
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
214
211
|
id: id,
|
|
@@ -261,19 +258,19 @@ const TitleBlock = /*#__PURE__*/function () {
|
|
|
261
258
|
variant: "secondary",
|
|
262
259
|
reversed: true,
|
|
263
260
|
fullWidth: true
|
|
264
|
-
}))))))), ((_c = primaryAction !== null && primaryAction !== void 0 ? primaryAction : defaultAction) !== null && _c !== void 0 ? _c : secondaryActions) && (/*#__PURE__*/React.createElement(MainActions, {
|
|
261
|
+
}))))))), ((_d = (_c = primaryAction !== null && primaryAction !== void 0 ? primaryAction : defaultAction) !== null && _c !== void 0 ? _c : secondaryActions) !== null && _d !== void 0 ? _d : secondaryOverflowMenuItems) && (/*#__PURE__*/React.createElement(MainActions, {
|
|
265
262
|
primaryAction: primaryAction,
|
|
266
263
|
defaultAction: defaultAction,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
264
|
+
reversed: isReversed(variant),
|
|
265
|
+
overflowMenuItems: createTabletOverflowMenuItems(secondaryActions, secondaryOverflowMenuItems),
|
|
266
|
+
showOverflowMenu: isSmallOrMediumViewport
|
|
270
267
|
}))))), /*#__PURE__*/React.createElement("div", {
|
|
271
268
|
className: styles.rowBelowSeparator
|
|
272
269
|
}, /*#__PURE__*/React.createElement("div", {
|
|
273
270
|
className: styles.rowBelowSeparatorInner
|
|
274
271
|
}, /*#__PURE__*/React.createElement("div", {
|
|
275
272
|
className: styles.rowBelowSeparatorInnerContent
|
|
276
|
-
}, ((
|
|
273
|
+
}, ((_e = sectionTitle !== null && sectionTitle !== void 0 ? sectionTitle : sectionTitleDescription) !== null && _e !== void 0 ? _e : renderSectionTitle) && (/*#__PURE__*/React.createElement("div", {
|
|
277
274
|
className: styles.sectionTitleContainer
|
|
278
275
|
}, /*#__PURE__*/React.createElement("div", {
|
|
279
276
|
className: styles.sectionTitleInner
|
|
@@ -286,7 +283,14 @@ const TitleBlock = /*#__PURE__*/function () {
|
|
|
286
283
|
secondaryActions: secondaryActions,
|
|
287
284
|
secondaryOverflowMenuItems: secondaryOverflowMenuItems,
|
|
288
285
|
reversed: isReversed(variant)
|
|
289
|
-
})))))
|
|
286
|
+
}))))), /*#__PURE__*/React.createElement(MobileActions, {
|
|
287
|
+
primaryAction: primaryAction,
|
|
288
|
+
defaultAction: defaultAction,
|
|
289
|
+
secondaryActions: secondaryActions,
|
|
290
|
+
secondaryOverflowMenuItems: secondaryOverflowMenuItems,
|
|
291
|
+
drawerHandleLabelIconPosition: primaryAction && 'iconPosition' in primaryAction ? primaryAction.iconPosition : undefined,
|
|
292
|
+
autoHide: autoHideMobileActionsMenu
|
|
293
|
+
})));
|
|
290
294
|
};
|
|
291
295
|
TitleBlock.displayName = 'TitleBlock';
|
|
292
296
|
return TitleBlock;
|
|
@@ -45,13 +45,9 @@ var styles = {
|
|
|
45
45
|
"navigationTabEdgeShadowRight": "TitleBlock-module_navigationTabEdgeShadowRight__xkIWc",
|
|
46
46
|
"navigationTabEdgeShadowLeft": "TitleBlock-module_navigationTabEdgeShadowLeft__9pGhR",
|
|
47
47
|
"secondaryActionsContainer": "TitleBlock-module_secondaryActionsContainer__-4q0l",
|
|
48
|
-
"secondaryOverflowCombinedMenu": "TitleBlock-module_secondaryOverflowCombinedMenu__CTddK",
|
|
49
|
-
"secondaryButtonContainer": "TitleBlock-module_secondaryButtonContainer__xFL9X",
|
|
50
|
-
"secondaryOverflowMenu": "TitleBlock-module_secondaryOverflowMenu__gvmgW",
|
|
51
48
|
"slide-fade": "TitleBlock-module_slide-fade__o5TnP",
|
|
52
49
|
"reverse-slide-fade": "TitleBlock-module_reverse-slide-fade__LZZ98",
|
|
53
50
|
"breadcrumbText": "TitleBlock-module_breadcrumbText__vDi0k",
|
|
54
|
-
"circle": "TitleBlock-module_circle__68z-T"
|
|
55
|
-
"staticIcon": "TitleBlock-module_staticIcon__5jeBS"
|
|
51
|
+
"circle": "TitleBlock-module_circle__68z-T"
|
|
56
52
|
};
|
|
57
53
|
export { styles as default };
|
|
@@ -1,105 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __assign, __spreadArray } from 'tslib';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Button } from '../../ButtonV1/Button/Button.mjs';
|
|
4
4
|
import { IconButton } from '../../ButtonV1/IconButton/IconButton.mjs';
|
|
5
5
|
import { Icon } from '../../Icon/Icon.mjs';
|
|
6
6
|
import { Menu, MenuList } from '../../MenuV1/index.mjs';
|
|
7
|
-
import '../TitleBlock.mjs';
|
|
8
|
-
import './NavigationTabs.mjs';
|
|
9
7
|
import { TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID } from '../constants.mjs';
|
|
10
|
-
import {
|
|
8
|
+
import { isMenuGroupNotButton } from '../utils.mjs';
|
|
11
9
|
import { TitleBlockMenuItem } from './TitleBlockMenuItem.mjs';
|
|
12
10
|
import { Toolbar } from './Toolbar.mjs';
|
|
13
11
|
import styles from './MainActions.module.scss.mjs';
|
|
14
|
-
var renderSecondaryAndOverflowMenu = function (secondaryOverflowMenuItems, reversed) {
|
|
15
|
-
if (!secondaryOverflowMenuItems) return undefined;
|
|
16
|
-
return /*#__PURE__*/React.createElement(Menu, {
|
|
17
|
-
align: "right",
|
|
18
|
-
button: /*#__PURE__*/React.createElement(IconButton, {
|
|
19
|
-
label: 'Open secondary and overflow menu',
|
|
20
|
-
reversed: reversed,
|
|
21
|
-
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
22
|
-
name: "more_horiz",
|
|
23
|
-
isPresentational: true
|
|
24
|
-
}),
|
|
25
|
-
id: TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID,
|
|
26
|
-
classNameOverride: styles.overflowMenuButton
|
|
27
|
-
})
|
|
28
|
-
}, /*#__PURE__*/React.createElement(MenuList, null, secondaryOverflowMenuItems.map(function (menuItem, i) {
|
|
29
|
-
return /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({
|
|
30
|
-
key: i
|
|
31
|
-
}, menuItem));
|
|
32
|
-
})));
|
|
33
|
-
};
|
|
34
12
|
const MainActions = /*#__PURE__*/function () {
|
|
35
13
|
const MainActions = function (_a) {
|
|
36
|
-
var _b, _c, _d;
|
|
14
|
+
var _b, _c, _d, _e;
|
|
37
15
|
var primaryAction = _a.primaryAction,
|
|
38
16
|
defaultAction = _a.defaultAction,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
17
|
+
_f = _a.reversed,
|
|
18
|
+
reversed = _f === void 0 ? false : _f,
|
|
19
|
+
overflowMenuItems = _a.overflowMenuItems,
|
|
20
|
+
_g = _a.showOverflowMenu,
|
|
21
|
+
showOverflowMenu = _g === void 0 ? false : _g;
|
|
43
22
|
var items;
|
|
44
|
-
// Build combined secondary + overflow menu items once, to be spread into the toolbar items
|
|
45
|
-
var secondaryAndOverflowMenu = [];
|
|
46
|
-
// Convert defaultAction to menu item format and prepend to combined list
|
|
47
|
-
var defaultActionMenuItem;
|
|
48
|
-
if (defaultAction) {
|
|
49
|
-
if ('component' in defaultAction) {
|
|
50
|
-
defaultActionMenuItem = defaultAction;
|
|
51
|
-
} else if ('onClick' in defaultAction) {
|
|
52
|
-
defaultActionMenuItem = {
|
|
53
|
-
label: defaultAction.label,
|
|
54
|
-
icon: defaultAction.icon,
|
|
55
|
-
onClick: defaultAction.onClick,
|
|
56
|
-
disabled: defaultAction.disabled
|
|
57
|
-
};
|
|
58
|
-
} else if ('href' in defaultAction) {
|
|
59
|
-
defaultActionMenuItem = {
|
|
60
|
-
label: defaultAction.label,
|
|
61
|
-
icon: defaultAction.icon,
|
|
62
|
-
href: defaultAction.href,
|
|
63
|
-
disabled: defaultAction.disabled
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
var combinedSecondaryOverflowItems = createTabletOverflowMenuItems(secondaryActions, secondaryOverflowMenuItems);
|
|
68
|
-
// Prepend defaultAction to the combined list if it exists
|
|
69
|
-
var allMenuItems = defaultActionMenuItem ? __spreadArray([defaultActionMenuItem], combinedSecondaryOverflowItems, true) : combinedSecondaryOverflowItems;
|
|
70
|
-
if (allMenuItems.length > 0) {
|
|
71
|
-
secondaryAndOverflowMenu.push({
|
|
72
|
-
key: 'overflowMenu',
|
|
73
|
-
node: renderSecondaryAndOverflowMenu(allMenuItems, reversed)
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
var defaultActionItem = defaultAction ? [{
|
|
77
|
-
key: 'defaultAction',
|
|
78
|
-
node: (/*#__PURE__*/React.createElement(Button, __assign({
|
|
79
|
-
classNameOverride: styles.defaultActionButton
|
|
80
|
-
}, defaultAction, {
|
|
81
|
-
reversed: (_b = defaultAction.reversed) !== null && _b !== void 0 ? _b : reversed,
|
|
82
|
-
"data-automation-id": "title-block-default-action-button",
|
|
83
|
-
"data-testid": "title-block-default-action-button"
|
|
84
|
-
})))
|
|
85
|
-
}] : [];
|
|
86
|
-
var defaultActionItemMinimized = defaultAction ? [{
|
|
87
|
-
key: 'defaultActionMinimized',
|
|
88
|
-
node: (/*#__PURE__*/React.createElement("div", {
|
|
89
|
-
className: styles.defaultActionButtonMinimized
|
|
90
|
-
}, /*#__PURE__*/React.createElement(Menu, {
|
|
91
|
-
align: "right",
|
|
92
|
-
button: /*#__PURE__*/React.createElement(IconButton, {
|
|
93
|
-
label: 'Open default action overflow menu',
|
|
94
|
-
reversed: reversed,
|
|
95
|
-
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
96
|
-
name: "more_horiz",
|
|
97
|
-
isPresentational: true
|
|
98
|
-
}),
|
|
99
|
-
id: TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID
|
|
100
|
-
})
|
|
101
|
-
}, /*#__PURE__*/React.createElement(MenuList, null, defaultActionMenuItem && /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({}, defaultActionMenuItem))))))
|
|
102
|
-
}] : [];
|
|
103
23
|
if (primaryAction && isMenuGroupNotButton(primaryAction)) {
|
|
104
24
|
var menuContent = primaryAction.menuItems.map(function (item, idx) {
|
|
105
25
|
return /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({}, item, {
|
|
@@ -108,7 +28,14 @@ const MainActions = /*#__PURE__*/function () {
|
|
|
108
28
|
"data-testid": "main-action-primary-menu-item-".concat(idx)
|
|
109
29
|
}));
|
|
110
30
|
});
|
|
111
|
-
items = __spreadArray(__spreadArray(
|
|
31
|
+
items = __spreadArray(__spreadArray([], defaultAction ? [{
|
|
32
|
+
key: 'defaultAction',
|
|
33
|
+
node: (/*#__PURE__*/React.createElement(Button, __assign({}, defaultAction, {
|
|
34
|
+
reversed: (_b = defaultAction.reversed) !== null && _b !== void 0 ? _b : reversed,
|
|
35
|
+
"data-automation-id": "title-block-default-action-button",
|
|
36
|
+
"data-testid": "title-block-default-action-button"
|
|
37
|
+
})))
|
|
38
|
+
}] : [], true), primaryAction ? [{
|
|
112
39
|
key: 'primaryAction',
|
|
113
40
|
node: (/*#__PURE__*/React.createElement(Menu, {
|
|
114
41
|
align: "right",
|
|
@@ -130,11 +57,18 @@ const MainActions = /*#__PURE__*/function () {
|
|
|
130
57
|
}, /*#__PURE__*/React.createElement(MenuList, null, menuContent)))
|
|
131
58
|
}] : [], true);
|
|
132
59
|
} else {
|
|
133
|
-
items = __spreadArray(__spreadArray(
|
|
60
|
+
items = __spreadArray(__spreadArray([], defaultAction ? [{
|
|
61
|
+
key: 'defaultAction',
|
|
62
|
+
node: (/*#__PURE__*/React.createElement(Button, __assign({}, defaultAction, {
|
|
63
|
+
reversed: (_c = defaultAction.reversed) !== null && _c !== void 0 ? _c : reversed,
|
|
64
|
+
"data-automation-id": "title-block-default-action-button",
|
|
65
|
+
"data-testid": "title-block-default-action-button"
|
|
66
|
+
})))
|
|
67
|
+
}] : [], true), primaryAction ? [{
|
|
134
68
|
key: 'primaryAction',
|
|
135
69
|
node: (/*#__PURE__*/React.createElement(Button, __assign({}, primaryAction, {
|
|
136
|
-
primary: (
|
|
137
|
-
reversed: (
|
|
70
|
+
primary: (_d = primaryAction.primary) !== null && _d !== void 0 ? _d : true,
|
|
71
|
+
reversed: (_e = primaryAction.reversed) !== null && _e !== void 0 ? _e : reversed,
|
|
138
72
|
"data-automation-id": "title-block-primary-action-button",
|
|
139
73
|
"data-testid": "title-block-primary-action-button",
|
|
140
74
|
badge: primaryAction.badge ? __assign(__assign({}, primaryAction.badge), {
|
|
@@ -143,6 +77,27 @@ const MainActions = /*#__PURE__*/function () {
|
|
|
143
77
|
})))
|
|
144
78
|
}] : [], true);
|
|
145
79
|
}
|
|
80
|
+
if (overflowMenuItems && showOverflowMenu && overflowMenuItems.length > 0) {
|
|
81
|
+
items = __spreadArray([{
|
|
82
|
+
key: 'overflowMenu',
|
|
83
|
+
node: (/*#__PURE__*/React.createElement(Menu, {
|
|
84
|
+
align: "right",
|
|
85
|
+
button: /*#__PURE__*/React.createElement(IconButton, {
|
|
86
|
+
id: TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID,
|
|
87
|
+
label: "Open secondary menu",
|
|
88
|
+
reversed: reversed,
|
|
89
|
+
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
90
|
+
name: "more_horiz",
|
|
91
|
+
isPresentational: true
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
}, /*#__PURE__*/React.createElement(MenuList, null, overflowMenuItems.map(function (menuItem, idx) {
|
|
95
|
+
return /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({}, menuItem, {
|
|
96
|
+
key: "main-action-overflow-item-menu-item-".concat(idx)
|
|
97
|
+
}));
|
|
98
|
+
}))))
|
|
99
|
+
}], items, true);
|
|
100
|
+
}
|
|
146
101
|
return /*#__PURE__*/React.createElement("div", {
|
|
147
102
|
className: styles.mainActionsContainer
|
|
148
103
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
var styles = {
|
|
2
|
-
"mainActionsContainer": "MainActions-module_mainActionsContainer__pk-78"
|
|
3
|
-
"defaultActionButtonMinimized": "MainActions-module_defaultActionButtonMinimized__XePRS",
|
|
4
|
-
"defaultActionButton": "MainActions-module_defaultActionButton__VbER1"
|
|
2
|
+
"mainActionsContainer": "MainActions-module_mainActionsContainer__pk-78"
|
|
5
3
|
};
|
|
6
4
|
export { styles as default };
|