@kaizen/components 2.2.3 → 2.3.0
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 +107 -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 +44 -14
- package/dist/cjs/src/MenuV1/index.cjs +4 -3
- package/dist/cjs/src/TitleBlock/TitleBlock.cjs +26 -36
- package/dist/cjs/src/TitleBlock/TitleBlock.module.scss.cjs +3 -0
- package/dist/cjs/src/TitleBlock/subcomponents/MainActions.cjs +90 -45
- package/dist/cjs/src/TitleBlock/subcomponents/MainActions.module.scss.cjs +3 -1
- package/dist/cjs/src/TitleBlock/subcomponents/SecondaryActions.cjs +51 -14
- package/dist/esm/src/MenuV1/index.mjs +5 -3
- package/dist/esm/src/TitleBlock/TitleBlock.mjs +27 -37
- package/dist/esm/src/TitleBlock/TitleBlock.module.scss.mjs +3 -0
- package/dist/esm/src/TitleBlock/subcomponents/MainActions.mjs +92 -47
- package/dist/esm/src/TitleBlock/subcomponents/MainActions.module.scss.mjs +3 -1
- package/dist/esm/src/TitleBlock/subcomponents/SecondaryActions.mjs +51 -14
- package/dist/styles.css +51 -201
- package/dist/types/TitleBlock/TitleBlock.d.ts +1 -1
- package/dist/types/TitleBlock/subcomponents/MainActions.d.ts +4 -3
- package/package.json +1 -1
- package/src/TitleBlock/TitleBlock.module.scss +28 -10
- package/src/TitleBlock/TitleBlock.spec.tsx +33 -461
- package/src/TitleBlock/TitleBlock.tsx +4 -24
- package/src/TitleBlock/_docs/TitleBlock.stories.tsx +25 -5
- package/src/TitleBlock/_mixins.scss +6 -0
- package/src/TitleBlock/subcomponents/MainActions.module.scss +27 -2
- package/src/TitleBlock/subcomponents/MainActions.tsx +127 -70
- package/src/TitleBlock/subcomponents/SecondaryActions.tsx +105 -45
- package/src/TitleBlock/subcomponents/Toolbar.tsx +1 -0
- package/dist/cjs/src/MenuV1/subcomponents/MenuHeading/MenuHeading.cjs +0 -27
- package/dist/cjs/src/MenuV1/subcomponents/MenuHeading/MenuHeading.module.scss.cjs +0 -6
- package/dist/cjs/src/TitleBlock/subcomponents/MobileActions.cjs +0 -306
- package/dist/cjs/src/TitleBlock/subcomponents/MobileActions.module.scss.cjs +0 -16
- package/dist/esm/src/MenuV1/subcomponents/MenuHeading/MenuHeading.mjs +0 -21
- package/dist/esm/src/MenuV1/subcomponents/MenuHeading/MenuHeading.module.scss.mjs +0 -4
- package/dist/esm/src/TitleBlock/subcomponents/MobileActions.mjs +0 -300
- package/dist/esm/src/TitleBlock/subcomponents/MobileActions.module.scss.mjs +0 -14
- package/dist/types/TitleBlock/subcomponents/MobileActions.d.ts +0 -14
- package/src/TitleBlock/subcomponents/MobileActions.module.scss +0 -208
- package/src/TitleBlock/subcomponents/MobileActions.spec.tsx +0 -210
- package/src/TitleBlock/subcomponents/MobileActions.tsx +0 -472
|
@@ -8,7 +8,6 @@ import { Select } from '~components/Select'
|
|
|
8
8
|
import { Tag } from '~components/Tag'
|
|
9
9
|
import { useMediaQueries } from '~components/utils/useMediaQueries'
|
|
10
10
|
import { MainActions } from './subcomponents/MainActions'
|
|
11
|
-
import { MobileActions } from './subcomponents/MobileActions'
|
|
12
11
|
import { SecondaryActions } from './subcomponents/SecondaryActions'
|
|
13
12
|
import {
|
|
14
13
|
type NavigationTabs,
|
|
@@ -18,7 +17,7 @@ import {
|
|
|
18
17
|
type TitleBlockProps,
|
|
19
18
|
type TitleBlockVariant,
|
|
20
19
|
} from './types'
|
|
21
|
-
import {
|
|
20
|
+
import { isReversed } from './utils'
|
|
22
21
|
import styles from './TitleBlock.module.scss'
|
|
23
22
|
|
|
24
23
|
const renderTag = (surveyStatus: SurveyStatus): ReactNode => {
|
|
@@ -258,7 +257,6 @@ export const TitleBlock = ({
|
|
|
258
257
|
sectionTitleDescriptionAutomationId = 'TitleBlock__SectionTitleDescription',
|
|
259
258
|
breadcrumbAutomationId = 'TitleBlock__Breadcrumb',
|
|
260
259
|
breadcrumbTextAutomationId = 'TitleBlock__BreadcrumbText',
|
|
261
|
-
autoHideMobileActionsMenu = false,
|
|
262
260
|
}: TitleBlockProps): JSX.Element => {
|
|
263
261
|
const hasNavigationTabs = navigationTabs && navigationTabs.length > 0
|
|
264
262
|
const collapseNavigationArea =
|
|
@@ -343,19 +341,13 @@ export const TitleBlock = ({
|
|
|
343
341
|
</>
|
|
344
342
|
</div>
|
|
345
343
|
</div>
|
|
346
|
-
{(primaryAction ??
|
|
347
|
-
defaultAction ??
|
|
348
|
-
secondaryActions ??
|
|
349
|
-
secondaryOverflowMenuItems) && (
|
|
344
|
+
{(primaryAction ?? defaultAction ?? secondaryActions) && (
|
|
350
345
|
<MainActions
|
|
351
346
|
primaryAction={primaryAction}
|
|
352
347
|
defaultAction={defaultAction}
|
|
348
|
+
secondaryActions={secondaryActions}
|
|
349
|
+
secondaryOverflowMenuItems={secondaryOverflowMenuItems}
|
|
353
350
|
reversed={isReversed(variant)}
|
|
354
|
-
overflowMenuItems={createTabletOverflowMenuItems(
|
|
355
|
-
secondaryActions,
|
|
356
|
-
secondaryOverflowMenuItems,
|
|
357
|
-
)}
|
|
358
|
-
showOverflowMenu={isSmallOrMediumViewport}
|
|
359
351
|
/>
|
|
360
352
|
)}
|
|
361
353
|
</div>
|
|
@@ -395,18 +387,6 @@ export const TitleBlock = ({
|
|
|
395
387
|
</div>
|
|
396
388
|
</div>
|
|
397
389
|
</div>
|
|
398
|
-
<MobileActions
|
|
399
|
-
primaryAction={primaryAction}
|
|
400
|
-
defaultAction={defaultAction}
|
|
401
|
-
secondaryActions={secondaryActions}
|
|
402
|
-
secondaryOverflowMenuItems={secondaryOverflowMenuItems}
|
|
403
|
-
drawerHandleLabelIconPosition={
|
|
404
|
-
primaryAction && 'iconPosition' in primaryAction
|
|
405
|
-
? primaryAction.iconPosition
|
|
406
|
-
: undefined
|
|
407
|
-
}
|
|
408
|
-
autoHide={autoHideMobileActionsMenu}
|
|
409
|
-
/>
|
|
410
390
|
</div>
|
|
411
391
|
</>
|
|
412
392
|
)
|
|
@@ -116,7 +116,7 @@ export const Viewports: Story = {
|
|
|
116
116
|
},
|
|
117
117
|
chromatic: {
|
|
118
118
|
disable: false,
|
|
119
|
-
viewports: [1079, 1365, 1366],
|
|
119
|
+
viewports: [1079, 1365, 1366, 360, 320],
|
|
120
120
|
},
|
|
121
121
|
},
|
|
122
122
|
}
|
|
@@ -156,21 +156,41 @@ export const LightVariant: Story = {
|
|
|
156
156
|
viewport: {
|
|
157
157
|
viewports: {
|
|
158
158
|
default: {
|
|
159
|
-
name: '
|
|
159
|
+
name: 'desktop (above or equal to 1366)',
|
|
160
160
|
styles: { width: '1366px', height: '800px' },
|
|
161
161
|
type: 'desktop',
|
|
162
162
|
},
|
|
163
|
-
|
|
164
|
-
name: '
|
|
163
|
+
desktopSm: {
|
|
164
|
+
name: 'desktop-sm (1024 - 1365)',
|
|
165
165
|
styles: { width: '1365px', height: '800px' },
|
|
166
166
|
type: 'desktop',
|
|
167
167
|
},
|
|
168
|
+
tablet: {
|
|
169
|
+
name: 'tablet (672 - 1023)',
|
|
170
|
+
styles: { width: '1023px', height: '800px' },
|
|
171
|
+
type: 'desktop',
|
|
172
|
+
},
|
|
173
|
+
mobileResponsive: {
|
|
174
|
+
name: 'mobile-responsive (512 - 671)',
|
|
175
|
+
styles: { width: '671px', height: '800px' },
|
|
176
|
+
type: 'desktop',
|
|
177
|
+
},
|
|
178
|
+
mobile: {
|
|
179
|
+
name: 'mobile (361 - 512)',
|
|
180
|
+
styles: { width: '511px', height: '800px' },
|
|
181
|
+
type: 'desktop',
|
|
182
|
+
},
|
|
183
|
+
mobileXs: {
|
|
184
|
+
name: 'mobile (under 360)',
|
|
185
|
+
styles: { width: '360px', height: '800px' },
|
|
186
|
+
type: 'desktop',
|
|
187
|
+
},
|
|
168
188
|
},
|
|
169
189
|
defaultViewport: 'default',
|
|
170
190
|
},
|
|
171
191
|
chromatic: {
|
|
172
192
|
disable: false,
|
|
173
|
-
viewports: [1365, 1366],
|
|
193
|
+
viewports: [1079, 1365, 1366, 360, 320],
|
|
174
194
|
},
|
|
175
195
|
},
|
|
176
196
|
args: {
|
|
@@ -9,10 +9,35 @@
|
|
|
9
9
|
flex-grow: 1;
|
|
10
10
|
flex-shrink: 0;
|
|
11
11
|
|
|
12
|
+
.defaultActionButtonMinimized {
|
|
13
|
+
display: none;
|
|
14
|
+
margin-inline-end: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
@include ca-margin($start: calc(#{$ca-grid} / 2));
|
|
13
18
|
|
|
14
|
-
@include title-block-
|
|
15
|
-
|
|
19
|
+
@include title-block-xsmall {
|
|
20
|
+
padding-top: 12px;
|
|
21
|
+
justify-content: flex-start;
|
|
22
|
+
padding-left: 1.25rem;
|
|
23
|
+
|
|
24
|
+
@media (max-width: 511px) {
|
|
25
|
+
padding-top: 0;
|
|
26
|
+
padding-left: 3.375rem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@media (max-width: 360px) {
|
|
30
|
+
.defaultActionButton {
|
|
31
|
+
display: none;
|
|
32
|
+
margin-inline-end: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.defaultActionButtonMinimized {
|
|
36
|
+
display: flex;
|
|
37
|
+
margin-inline-end: 3px;
|
|
38
|
+
margin-left: -0.5rem;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
16
41
|
}
|
|
17
42
|
}
|
|
18
43
|
}
|
|
@@ -2,13 +2,14 @@ import React from 'react'
|
|
|
2
2
|
import { Button, IconButton } from '~components/ButtonV1'
|
|
3
3
|
import { Icon } from '~components/Icon'
|
|
4
4
|
import { Menu, MenuList } from '~components/MenuV1'
|
|
5
|
-
import { TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID } from '
|
|
5
|
+
import { TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID } from '~components/TitleBlock'
|
|
6
6
|
import {
|
|
7
7
|
type DefaultActionProps,
|
|
8
8
|
type PrimaryActionProps,
|
|
9
|
+
type SecondaryActionsProps,
|
|
9
10
|
type TitleBlockMenuItemProps,
|
|
10
11
|
} from '../types'
|
|
11
|
-
import { isMenuGroupNotButton } from '../utils'
|
|
12
|
+
import { createTabletOverflowMenuItems, isMenuGroupNotButton } from '../utils'
|
|
12
13
|
import { TitleBlockMenuItem } from './TitleBlockMenuItem'
|
|
13
14
|
import { Toolbar } from './Toolbar'
|
|
14
15
|
import styles from './MainActions.module.scss'
|
|
@@ -17,18 +18,135 @@ type MainActionsProps = {
|
|
|
17
18
|
primaryAction?: PrimaryActionProps
|
|
18
19
|
defaultAction?: DefaultActionProps
|
|
19
20
|
reversed?: boolean
|
|
20
|
-
|
|
21
|
+
secondaryActions?: SecondaryActionsProps
|
|
22
|
+
secondaryOverflowMenuItems?: TitleBlockMenuItemProps[]
|
|
21
23
|
showOverflowMenu?: boolean
|
|
22
24
|
}
|
|
23
25
|
|
|
26
|
+
const renderSecondaryAndOverflowMenu = (
|
|
27
|
+
secondaryOverflowMenuItems?: TitleBlockMenuItemProps[],
|
|
28
|
+
reversed?: boolean,
|
|
29
|
+
): JSX.Element | undefined => {
|
|
30
|
+
if (!secondaryOverflowMenuItems) return undefined
|
|
31
|
+
return (
|
|
32
|
+
<Menu
|
|
33
|
+
align="right"
|
|
34
|
+
button={
|
|
35
|
+
<IconButton
|
|
36
|
+
label={'Open secondary and overflow menu'}
|
|
37
|
+
reversed={reversed}
|
|
38
|
+
icon={<Icon name="more_horiz" isPresentational />}
|
|
39
|
+
id={TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID}
|
|
40
|
+
classNameOverride={styles.overflowMenuButton}
|
|
41
|
+
/>
|
|
42
|
+
}
|
|
43
|
+
>
|
|
44
|
+
<MenuList>
|
|
45
|
+
{secondaryOverflowMenuItems.map((menuItem, i) => (
|
|
46
|
+
<TitleBlockMenuItem key={i} {...menuItem} />
|
|
47
|
+
))}
|
|
48
|
+
</MenuList>
|
|
49
|
+
</Menu>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
24
53
|
export const MainActions = ({
|
|
25
54
|
primaryAction,
|
|
26
55
|
defaultAction,
|
|
56
|
+
secondaryActions,
|
|
57
|
+
secondaryOverflowMenuItems,
|
|
27
58
|
reversed = false,
|
|
28
|
-
overflowMenuItems,
|
|
29
|
-
showOverflowMenu = false,
|
|
30
59
|
}: MainActionsProps): JSX.Element => {
|
|
31
60
|
let items
|
|
61
|
+
|
|
62
|
+
// Build combined secondary + overflow menu items once, to be spread into the toolbar items
|
|
63
|
+
const secondaryAndOverflowMenu: { key: string; node: JSX.Element }[] = []
|
|
64
|
+
|
|
65
|
+
// Convert defaultAction to menu item format and prepend to combined list
|
|
66
|
+
let defaultActionMenuItem: TitleBlockMenuItemProps | undefined
|
|
67
|
+
if (defaultAction) {
|
|
68
|
+
if ('component' in defaultAction) {
|
|
69
|
+
defaultActionMenuItem = defaultAction
|
|
70
|
+
} else if ('onClick' in defaultAction) {
|
|
71
|
+
defaultActionMenuItem = {
|
|
72
|
+
label: defaultAction.label,
|
|
73
|
+
icon: defaultAction.icon,
|
|
74
|
+
onClick: defaultAction.onClick,
|
|
75
|
+
disabled: defaultAction.disabled,
|
|
76
|
+
}
|
|
77
|
+
} else if ('href' in defaultAction) {
|
|
78
|
+
defaultActionMenuItem = {
|
|
79
|
+
label: defaultAction.label,
|
|
80
|
+
icon: defaultAction.icon,
|
|
81
|
+
href: defaultAction.href,
|
|
82
|
+
disabled: defaultAction.disabled,
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const combinedSecondaryOverflowItems = createTabletOverflowMenuItems(
|
|
88
|
+
secondaryActions,
|
|
89
|
+
secondaryOverflowMenuItems,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
// Prepend defaultAction to the combined list if it exists
|
|
93
|
+
const allMenuItems = defaultActionMenuItem
|
|
94
|
+
? [defaultActionMenuItem, ...combinedSecondaryOverflowItems]
|
|
95
|
+
: combinedSecondaryOverflowItems
|
|
96
|
+
|
|
97
|
+
if (allMenuItems.length > 0) {
|
|
98
|
+
secondaryAndOverflowMenu.push({
|
|
99
|
+
key: 'overflowMenu',
|
|
100
|
+
node: renderSecondaryAndOverflowMenu(allMenuItems, reversed)!,
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const defaultActionItem = defaultAction
|
|
105
|
+
? [
|
|
106
|
+
{
|
|
107
|
+
key: 'defaultAction',
|
|
108
|
+
node: (
|
|
109
|
+
<Button
|
|
110
|
+
classNameOverride={styles.defaultActionButton}
|
|
111
|
+
{...{
|
|
112
|
+
...defaultAction,
|
|
113
|
+
reversed: defaultAction.reversed ?? reversed,
|
|
114
|
+
}}
|
|
115
|
+
data-automation-id="title-block-default-action-button"
|
|
116
|
+
data-testid="title-block-default-action-button"
|
|
117
|
+
/>
|
|
118
|
+
),
|
|
119
|
+
},
|
|
120
|
+
]
|
|
121
|
+
: []
|
|
122
|
+
|
|
123
|
+
const defaultActionItemMinimized = defaultAction
|
|
124
|
+
? [
|
|
125
|
+
{
|
|
126
|
+
key: 'defaultActionMinimized',
|
|
127
|
+
node: (
|
|
128
|
+
<div className={styles.defaultActionButtonMinimized}>
|
|
129
|
+
<Menu
|
|
130
|
+
align="right"
|
|
131
|
+
button={
|
|
132
|
+
<IconButton
|
|
133
|
+
label={'Open default action overflow menu'}
|
|
134
|
+
reversed={reversed}
|
|
135
|
+
icon={<Icon name="more_horiz" isPresentational />}
|
|
136
|
+
id={TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID}
|
|
137
|
+
/>
|
|
138
|
+
}
|
|
139
|
+
>
|
|
140
|
+
<MenuList>
|
|
141
|
+
{defaultActionMenuItem && <TitleBlockMenuItem {...defaultActionMenuItem} />}
|
|
142
|
+
</MenuList>
|
|
143
|
+
</Menu>
|
|
144
|
+
</div>
|
|
145
|
+
),
|
|
146
|
+
},
|
|
147
|
+
]
|
|
148
|
+
: []
|
|
149
|
+
|
|
32
150
|
if (primaryAction && isMenuGroupNotButton(primaryAction)) {
|
|
33
151
|
const menuContent = primaryAction.menuItems.map((item, idx) => (
|
|
34
152
|
<TitleBlockMenuItem
|
|
@@ -40,23 +158,8 @@ export const MainActions = ({
|
|
|
40
158
|
))
|
|
41
159
|
|
|
42
160
|
items = [
|
|
43
|
-
...
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
key: 'defaultAction',
|
|
47
|
-
node: (
|
|
48
|
-
<Button
|
|
49
|
-
{...{
|
|
50
|
-
...defaultAction,
|
|
51
|
-
reversed: defaultAction.reversed ?? reversed,
|
|
52
|
-
}}
|
|
53
|
-
data-automation-id="title-block-default-action-button"
|
|
54
|
-
data-testid="title-block-default-action-button"
|
|
55
|
-
/>
|
|
56
|
-
),
|
|
57
|
-
},
|
|
58
|
-
]
|
|
59
|
-
: []),
|
|
161
|
+
...defaultActionItem,
|
|
162
|
+
...defaultActionItemMinimized,
|
|
60
163
|
...(primaryAction
|
|
61
164
|
? [
|
|
62
165
|
{
|
|
@@ -93,23 +196,8 @@ export const MainActions = ({
|
|
|
93
196
|
]
|
|
94
197
|
} else {
|
|
95
198
|
items = [
|
|
96
|
-
...
|
|
97
|
-
|
|
98
|
-
{
|
|
99
|
-
key: 'defaultAction',
|
|
100
|
-
node: (
|
|
101
|
-
<Button
|
|
102
|
-
{...{
|
|
103
|
-
...defaultAction,
|
|
104
|
-
reversed: defaultAction.reversed ?? reversed,
|
|
105
|
-
}}
|
|
106
|
-
data-automation-id="title-block-default-action-button"
|
|
107
|
-
data-testid="title-block-default-action-button"
|
|
108
|
-
/>
|
|
109
|
-
),
|
|
110
|
-
},
|
|
111
|
-
]
|
|
112
|
-
: []),
|
|
199
|
+
...defaultActionItem,
|
|
200
|
+
...defaultActionItemMinimized,
|
|
113
201
|
...(primaryAction
|
|
114
202
|
? [
|
|
115
203
|
{
|
|
@@ -139,37 +227,6 @@ export const MainActions = ({
|
|
|
139
227
|
]
|
|
140
228
|
}
|
|
141
229
|
|
|
142
|
-
if (overflowMenuItems && showOverflowMenu && overflowMenuItems.length > 0) {
|
|
143
|
-
items = [
|
|
144
|
-
{
|
|
145
|
-
key: 'overflowMenu',
|
|
146
|
-
node: (
|
|
147
|
-
<Menu
|
|
148
|
-
align="right"
|
|
149
|
-
button={
|
|
150
|
-
<IconButton
|
|
151
|
-
id={TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID}
|
|
152
|
-
label="Open secondary menu"
|
|
153
|
-
reversed={reversed}
|
|
154
|
-
icon={<Icon name="more_horiz" isPresentational />}
|
|
155
|
-
/>
|
|
156
|
-
}
|
|
157
|
-
>
|
|
158
|
-
<MenuList>
|
|
159
|
-
{overflowMenuItems.map((menuItem, idx) => (
|
|
160
|
-
<TitleBlockMenuItem
|
|
161
|
-
{...menuItem}
|
|
162
|
-
key={`main-action-overflow-item-menu-item-${idx}`}
|
|
163
|
-
/>
|
|
164
|
-
))}
|
|
165
|
-
</MenuList>
|
|
166
|
-
</Menu>
|
|
167
|
-
),
|
|
168
|
-
},
|
|
169
|
-
...items,
|
|
170
|
-
]
|
|
171
|
-
}
|
|
172
|
-
|
|
173
230
|
return (
|
|
174
231
|
<div className={styles.mainActionsContainer}>
|
|
175
232
|
<Toolbar
|
|
@@ -5,6 +5,7 @@ import { Menu, MenuList } from '~components/MenuV1'
|
|
|
5
5
|
import styles from '../TitleBlock.module.scss'
|
|
6
6
|
import { TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID } from '../constants'
|
|
7
7
|
import { type SecondaryActionsProps, type TitleBlockMenuItemProps } from '../types'
|
|
8
|
+
import { convertSecondaryActionsToMenuItems } from '../utils'
|
|
8
9
|
import { TitleBlockMenuItem } from './TitleBlockMenuItem'
|
|
9
10
|
import { Toolbar } from './Toolbar'
|
|
10
11
|
|
|
@@ -18,25 +19,67 @@ const renderSecondaryOverflowMenu = (
|
|
|
18
19
|
secondaryOverflowMenuItems?: TitleBlockMenuItemProps[],
|
|
19
20
|
reversed?: boolean,
|
|
20
21
|
): JSX.Element | undefined => {
|
|
21
|
-
if (!secondaryOverflowMenuItems) return undefined
|
|
22
|
+
if (!secondaryOverflowMenuItems || secondaryOverflowMenuItems.length === 0) return undefined
|
|
22
23
|
return (
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
<div className={styles.secondaryOverflowMenu}>
|
|
25
|
+
<Menu
|
|
26
|
+
align="right"
|
|
27
|
+
button={
|
|
28
|
+
<Button
|
|
29
|
+
secondary
|
|
30
|
+
reversed={reversed}
|
|
31
|
+
label="Menu"
|
|
32
|
+
data-automation-id={TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID}
|
|
33
|
+
data-testid={TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID}
|
|
34
|
+
icon={<Icon name="keyboard_arrow_down" isPresentational />}
|
|
35
|
+
iconPosition={'end'}
|
|
36
|
+
/>
|
|
37
|
+
}
|
|
38
|
+
>
|
|
39
|
+
<MenuList>
|
|
40
|
+
{secondaryOverflowMenuItems.map((menuItem, i) => (
|
|
41
|
+
<TitleBlockMenuItem key={i} {...menuItem} />
|
|
42
|
+
))}
|
|
43
|
+
</MenuList>
|
|
44
|
+
</Menu>
|
|
45
|
+
</div>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// New: combined overflow menu (secondary actions converted + overflow menu items)
|
|
50
|
+
const renderCombinedSecondaryOverflowMenu = (
|
|
51
|
+
secondaryActions?: SecondaryActionsProps,
|
|
52
|
+
secondaryOverflowMenuItems?: TitleBlockMenuItemProps[],
|
|
53
|
+
reversed?: boolean,
|
|
54
|
+
): JSX.Element | undefined => {
|
|
55
|
+
const secondaryConverted = secondaryActions
|
|
56
|
+
? convertSecondaryActionsToMenuItems(secondaryActions)
|
|
57
|
+
: []
|
|
58
|
+
const overflowItems = secondaryOverflowMenuItems ?? []
|
|
59
|
+
|
|
60
|
+
if (secondaryConverted.length === 0 && overflowItems.length === 0) return undefined
|
|
61
|
+
const combined = [...secondaryConverted, ...overflowItems]
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div className={styles.secondaryOverflowCombinedMenu}>
|
|
65
|
+
<Menu
|
|
66
|
+
align="right"
|
|
67
|
+
button={
|
|
68
|
+
<IconButton
|
|
69
|
+
label="Open combined secondary + overflow menu"
|
|
70
|
+
reversed={reversed}
|
|
71
|
+
icon={<Icon name="more_horiz" isPresentational />}
|
|
72
|
+
id={`${TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID}__combined`}
|
|
73
|
+
/>
|
|
74
|
+
}
|
|
75
|
+
>
|
|
76
|
+
<MenuList>
|
|
77
|
+
{combined.map((menuItem, i) => (
|
|
78
|
+
<TitleBlockMenuItem key={i} {...menuItem} />
|
|
79
|
+
))}
|
|
80
|
+
</MenuList>
|
|
81
|
+
</Menu>
|
|
82
|
+
</div>
|
|
40
83
|
)
|
|
41
84
|
}
|
|
42
85
|
|
|
@@ -55,26 +98,28 @@ export const SecondaryActions = ({
|
|
|
55
98
|
? secondaryActions.map((action, i) => {
|
|
56
99
|
if ('menuItems' in action) {
|
|
57
100
|
return {
|
|
58
|
-
key:
|
|
101
|
+
key: `titleblock_secondary_action_${i}`,
|
|
59
102
|
node: (
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
103
|
+
<div className={styles.secondaryButtonContainer}>
|
|
104
|
+
<Menu
|
|
105
|
+
align="right"
|
|
106
|
+
button={
|
|
107
|
+
<Button
|
|
108
|
+
secondary
|
|
109
|
+
label={action.label}
|
|
110
|
+
reversed={reversed}
|
|
111
|
+
icon={<Icon name="keyboard_arrow_down" isPresentational />}
|
|
112
|
+
iconPosition="end"
|
|
113
|
+
/>
|
|
114
|
+
}
|
|
115
|
+
>
|
|
116
|
+
<MenuList>
|
|
117
|
+
{action.menuItems.map((menuItem, i2) => (
|
|
118
|
+
<TitleBlockMenuItem key={i2} {...menuItem} />
|
|
119
|
+
))}
|
|
120
|
+
</MenuList>
|
|
121
|
+
</Menu>
|
|
122
|
+
</div>
|
|
78
123
|
),
|
|
79
124
|
}
|
|
80
125
|
} else {
|
|
@@ -86,15 +131,17 @@ export const SecondaryActions = ({
|
|
|
86
131
|
)
|
|
87
132
|
}
|
|
88
133
|
return {
|
|
89
|
-
key: `${i}`,
|
|
134
|
+
key: `${i}`,
|
|
90
135
|
node: (
|
|
91
|
-
<
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
136
|
+
<div className={styles.secondaryButtonContainer}>
|
|
137
|
+
<Button
|
|
138
|
+
secondary
|
|
139
|
+
reversed={reversed}
|
|
140
|
+
{...action}
|
|
141
|
+
data-automation-id="title-block-secondary-actions-button"
|
|
142
|
+
data-testid="title-block-secondary-actions-button"
|
|
143
|
+
/>
|
|
144
|
+
</div>
|
|
98
145
|
),
|
|
99
146
|
}
|
|
100
147
|
}
|
|
@@ -102,6 +149,11 @@ export const SecondaryActions = ({
|
|
|
102
149
|
: []
|
|
103
150
|
|
|
104
151
|
const overflowMenu = renderSecondaryOverflowMenu(secondaryOverflowMenuItems, reversed)
|
|
152
|
+
const combinedOverflowMenu = renderCombinedSecondaryOverflowMenu(
|
|
153
|
+
secondaryActions,
|
|
154
|
+
secondaryOverflowMenuItems,
|
|
155
|
+
reversed,
|
|
156
|
+
)
|
|
105
157
|
|
|
106
158
|
const toolbarItems = [
|
|
107
159
|
...secondaryActionsAsToolbarItems,
|
|
@@ -113,6 +165,14 @@ export const SecondaryActions = ({
|
|
|
113
165
|
},
|
|
114
166
|
]
|
|
115
167
|
: []),
|
|
168
|
+
...(combinedOverflowMenu
|
|
169
|
+
? [
|
|
170
|
+
{
|
|
171
|
+
key: 'combinedOverflowMenu',
|
|
172
|
+
node: combinedOverflowMenu,
|
|
173
|
+
},
|
|
174
|
+
]
|
|
175
|
+
: []),
|
|
116
176
|
]
|
|
117
177
|
|
|
118
178
|
return (
|
|
@@ -21,6 +21,7 @@ export const Toolbar = ({ items, noGap = false, automationId }: ToolbarProps): J
|
|
|
21
21
|
if (!items || items?.length === 0) {
|
|
22
22
|
return <></>
|
|
23
23
|
}
|
|
24
|
+
|
|
24
25
|
return (
|
|
25
26
|
<div className={styles.toolbar} data-automation-id={automationId} data-testid={automationId}>
|
|
26
27
|
{items.map((item) => (
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var tslib = require('tslib');
|
|
4
|
-
var React = require('react');
|
|
5
|
-
var classnames = require('classnames');
|
|
6
|
-
var Heading = require('../../../Heading/Heading.cjs');
|
|
7
|
-
var MenuHeading_module = require('./MenuHeading.module.scss.cjs');
|
|
8
|
-
function _interopDefault(e) {
|
|
9
|
-
return e && e.__esModule ? e : {
|
|
10
|
-
default: e
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
14
|
-
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
15
|
-
var MenuHeading = function (_a) {
|
|
16
|
-
var id = _a.id,
|
|
17
|
-
classNameOverride = _a.classNameOverride,
|
|
18
|
-
restProps = tslib.__rest(_a, ["id", "classNameOverride"]);
|
|
19
|
-
return React__default.default.createElement(Heading.Heading, tslib.__assign({
|
|
20
|
-
id: id,
|
|
21
|
-
variant: "heading-6",
|
|
22
|
-
tag: "span",
|
|
23
|
-
classNameOverride: classnames__default.default(MenuHeading_module.heading, classNameOverride)
|
|
24
|
-
}, restProps));
|
|
25
|
-
};
|
|
26
|
-
MenuHeading.displayName = 'MenuHeading';
|
|
27
|
-
exports.MenuHeading = MenuHeading;
|