@kaizen/components 2.2.4 → 2.3.1

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 (37) hide show
  1. package/dist/cjs/src/MenuV1/index.cjs +4 -3
  2. package/dist/cjs/src/TitleBlock/TitleBlock.cjs +26 -36
  3. package/dist/cjs/src/TitleBlock/TitleBlock.module.scss.cjs +3 -0
  4. package/dist/cjs/src/TitleBlock/subcomponents/MainActions.cjs +90 -45
  5. package/dist/cjs/src/TitleBlock/subcomponents/MainActions.module.scss.cjs +3 -1
  6. package/dist/cjs/src/TitleBlock/subcomponents/SecondaryActions.cjs +51 -14
  7. package/dist/esm/src/MenuV1/index.mjs +5 -3
  8. package/dist/esm/src/TitleBlock/TitleBlock.mjs +27 -37
  9. package/dist/esm/src/TitleBlock/TitleBlock.module.scss.mjs +3 -0
  10. package/dist/esm/src/TitleBlock/subcomponents/MainActions.mjs +92 -47
  11. package/dist/esm/src/TitleBlock/subcomponents/MainActions.module.scss.mjs +3 -1
  12. package/dist/esm/src/TitleBlock/subcomponents/SecondaryActions.mjs +51 -14
  13. package/dist/styles.css +78 -207
  14. package/dist/types/TitleBlock/TitleBlock.d.ts +1 -1
  15. package/dist/types/TitleBlock/subcomponents/MainActions.d.ts +4 -3
  16. package/package.json +1 -1
  17. package/src/TitleBlock/TitleBlock.module.scss +51 -14
  18. package/src/TitleBlock/TitleBlock.spec.tsx +33 -461
  19. package/src/TitleBlock/TitleBlock.tsx +4 -24
  20. package/src/TitleBlock/_docs/TitleBlock.stories.tsx +78 -100
  21. package/src/TitleBlock/_mixins.scss +6 -0
  22. package/src/TitleBlock/subcomponents/MainActions.module.scss +27 -2
  23. package/src/TitleBlock/subcomponents/MainActions.tsx +127 -70
  24. package/src/TitleBlock/subcomponents/SecondaryActions.tsx +105 -45
  25. package/src/TitleBlock/subcomponents/Toolbar.tsx +1 -0
  26. package/dist/cjs/src/MenuV1/subcomponents/MenuHeading/MenuHeading.cjs +0 -27
  27. package/dist/cjs/src/MenuV1/subcomponents/MenuHeading/MenuHeading.module.scss.cjs +0 -6
  28. package/dist/cjs/src/TitleBlock/subcomponents/MobileActions.cjs +0 -306
  29. package/dist/cjs/src/TitleBlock/subcomponents/MobileActions.module.scss.cjs +0 -16
  30. package/dist/esm/src/MenuV1/subcomponents/MenuHeading/MenuHeading.mjs +0 -21
  31. package/dist/esm/src/MenuV1/subcomponents/MenuHeading/MenuHeading.module.scss.mjs +0 -4
  32. package/dist/esm/src/TitleBlock/subcomponents/MobileActions.mjs +0 -300
  33. package/dist/esm/src/TitleBlock/subcomponents/MobileActions.module.scss.mjs +0 -14
  34. package/dist/types/TitleBlock/subcomponents/MobileActions.d.ts +0 -14
  35. package/src/TitleBlock/subcomponents/MobileActions.module.scss +0 -208
  36. package/src/TitleBlock/subcomponents/MobileActions.spec.tsx +0 -210
  37. package/src/TitleBlock/subcomponents/MobileActions.tsx +0 -472
@@ -1,25 +1,105 @@
1
- import { __assign, __spreadArray } from 'tslib';
1
+ import { __spreadArray, __assign } 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';
7
9
  import { TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID } from '../constants.mjs';
8
- import { isMenuGroupNotButton } from '../utils.mjs';
10
+ import { createTabletOverflowMenuItems, isMenuGroupNotButton } from '../utils.mjs';
9
11
  import { TitleBlockMenuItem } from './TitleBlockMenuItem.mjs';
10
12
  import { Toolbar } from './Toolbar.mjs';
11
13
  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
+ };
12
34
  const MainActions = /*#__PURE__*/function () {
13
35
  const MainActions = function (_a) {
14
- var _b, _c, _d, _e;
36
+ var _b, _c, _d;
15
37
  var primaryAction = _a.primaryAction,
16
38
  defaultAction = _a.defaultAction,
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;
39
+ secondaryActions = _a.secondaryActions,
40
+ secondaryOverflowMenuItems = _a.secondaryOverflowMenuItems,
41
+ _e = _a.reversed,
42
+ reversed = _e === void 0 ? false : _e;
22
43
  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
+ }] : [];
23
103
  if (primaryAction && isMenuGroupNotButton(primaryAction)) {
24
104
  var menuContent = primaryAction.menuItems.map(function (item, idx) {
25
105
  return /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({}, item, {
@@ -28,14 +108,7 @@ const MainActions = /*#__PURE__*/function () {
28
108
  "data-testid": "main-action-primary-menu-item-".concat(idx)
29
109
  }));
30
110
  });
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 ? [{
111
+ items = __spreadArray(__spreadArray(__spreadArray([], defaultActionItem, true), defaultActionItemMinimized, true), primaryAction ? [{
39
112
  key: 'primaryAction',
40
113
  node: (/*#__PURE__*/React.createElement(Menu, {
41
114
  align: "right",
@@ -57,18 +130,11 @@ const MainActions = /*#__PURE__*/function () {
57
130
  }, /*#__PURE__*/React.createElement(MenuList, null, menuContent)))
58
131
  }] : [], true);
59
132
  } else {
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 ? [{
133
+ items = __spreadArray(__spreadArray(__spreadArray([], defaultActionItem, true), defaultActionItemMinimized, true), primaryAction ? [{
68
134
  key: 'primaryAction',
69
135
  node: (/*#__PURE__*/React.createElement(Button, __assign({}, primaryAction, {
70
- primary: (_d = primaryAction.primary) !== null && _d !== void 0 ? _d : true,
71
- reversed: (_e = primaryAction.reversed) !== null && _e !== void 0 ? _e : reversed,
136
+ primary: (_c = primaryAction.primary) !== null && _c !== void 0 ? _c : true,
137
+ reversed: (_d = primaryAction.reversed) !== null && _d !== void 0 ? _d : reversed,
72
138
  "data-automation-id": "title-block-primary-action-button",
73
139
  "data-testid": "title-block-primary-action-button",
74
140
  badge: primaryAction.badge ? __assign(__assign({}, primaryAction.badge), {
@@ -77,27 +143,6 @@ const MainActions = /*#__PURE__*/function () {
77
143
  })))
78
144
  }] : [], true);
79
145
  }
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
- }
101
146
  return /*#__PURE__*/React.createElement("div", {
102
147
  className: styles.mainActionsContainer
103
148
  }, /*#__PURE__*/React.createElement(Toolbar, {
@@ -1,4 +1,6 @@
1
1
  var styles = {
2
- "mainActionsContainer": "MainActions-module_mainActionsContainer__pk-78"
2
+ "mainActionsContainer": "MainActions-module_mainActionsContainer__pk-78",
3
+ "defaultActionButtonMinimized": "MainActions-module_defaultActionButtonMinimized__XePRS",
4
+ "defaultActionButton": "MainActions-module_defaultActionButton__VbER1"
3
5
  };
4
6
  export { styles as default };
@@ -6,26 +6,57 @@ 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';
9
10
  import { TitleBlockMenuItem } from './TitleBlockMenuItem.mjs';
10
11
  import { Toolbar } from './Toolbar.mjs';
11
12
  var renderSecondaryOverflowMenu = function (secondaryOverflowMenuItems, reversed) {
12
- if (!secondaryOverflowMenuItems) return undefined;
13
- return /*#__PURE__*/React.createElement(Menu, {
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
+ var secondaryConverted = secondaryActions ? convertSecondaryActionsToMenuItems(secondaryActions) : [];
39
+ var overflowItems = secondaryOverflowMenuItems !== null && secondaryOverflowMenuItems !== void 0 ? secondaryOverflowMenuItems : [];
40
+ if (secondaryConverted.length === 0 && overflowItems.length === 0) return undefined;
41
+ var combined = __spreadArray(__spreadArray([], secondaryConverted, true), overflowItems, true);
42
+ return /*#__PURE__*/React.createElement("div", {
43
+ className: styles.secondaryOverflowCombinedMenu
44
+ }, /*#__PURE__*/React.createElement(Menu, {
14
45
  align: "right",
15
46
  button: /*#__PURE__*/React.createElement(IconButton, {
16
- label: "Open secondary menu",
47
+ label: "Open combined secondary + overflow menu",
17
48
  reversed: reversed,
18
49
  icon: /*#__PURE__*/React.createElement(Icon, {
19
50
  name: "more_horiz",
20
51
  isPresentational: true
21
52
  }),
22
- id: TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID
53
+ id: "".concat(TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID, "__combined")
23
54
  })
24
- }, /*#__PURE__*/React.createElement(MenuList, null, secondaryOverflowMenuItems.map(function (menuItem, i) {
55
+ }, /*#__PURE__*/React.createElement(MenuList, null, combined.map(function (menuItem, i) {
25
56
  return /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({
26
57
  key: i
27
58
  }, menuItem));
28
- })));
59
+ }))));
29
60
  };
30
61
  // Unfortunately, you'll notice below, that I needed to use the array index,
31
62
  // against react best practices (https://reactjs.org/docs/lists-and-keys.html)
@@ -40,9 +71,10 @@ const SecondaryActions = /*#__PURE__*/function () {
40
71
  var secondaryActionsAsToolbarItems = secondaryActions ? secondaryActions.map(function (action, i) {
41
72
  if ('menuItems' in action) {
42
73
  return {
43
- key: "".concat(i),
44
- // We shouldn't use an index here, see note above
45
- node: (/*#__PURE__*/React.createElement(Menu, {
74
+ key: "titleblock_secondary_action_".concat(i),
75
+ node: (/*#__PURE__*/React.createElement("div", {
76
+ className: styles.secondaryButtonContainer
77
+ }, /*#__PURE__*/React.createElement(Menu, {
46
78
  align: "right",
47
79
  button: /*#__PURE__*/React.createElement(Button, {
48
80
  secondary: true,
@@ -58,7 +90,7 @@ const SecondaryActions = /*#__PURE__*/function () {
58
90
  return /*#__PURE__*/React.createElement(TitleBlockMenuItem, __assign({
59
91
  key: i2
60
92
  }, menuItem));
61
- }))))
93
+ })))))
62
94
  };
63
95
  } else {
64
96
  if ('onClick' in action && 'href' in action) {
@@ -67,21 +99,26 @@ const SecondaryActions = /*#__PURE__*/function () {
67
99
  }
68
100
  return {
69
101
  key: "".concat(i),
70
- // We shouldn't use an index here, see note above
71
- node: (/*#__PURE__*/React.createElement(Button, __assign({
102
+ node: (/*#__PURE__*/React.createElement("div", {
103
+ className: styles.secondaryButtonContainer
104
+ }, /*#__PURE__*/React.createElement(Button, __assign({
72
105
  secondary: true,
73
106
  reversed: reversed
74
107
  }, action, {
75
108
  "data-automation-id": "title-block-secondary-actions-button",
76
109
  "data-testid": "title-block-secondary-actions-button"
77
- })))
110
+ }))))
78
111
  };
79
112
  }
80
113
  }) : [];
81
114
  var overflowMenu = renderSecondaryOverflowMenu(secondaryOverflowMenuItems, reversed);
82
- var toolbarItems = __spreadArray(__spreadArray([], secondaryActionsAsToolbarItems, true), overflowMenu ? [{
115
+ var combinedOverflowMenu = renderCombinedSecondaryOverflowMenu(secondaryActions, secondaryOverflowMenuItems, reversed);
116
+ var toolbarItems = __spreadArray(__spreadArray(__spreadArray([], secondaryActionsAsToolbarItems, true), overflowMenu ? [{
83
117
  key: 'overflowMenu',
84
118
  node: overflowMenu
119
+ }] : [], true), combinedOverflowMenu ? [{
120
+ key: 'combinedOverflowMenu',
121
+ node: combinedOverflowMenu
85
122
  }] : [], true);
86
123
  return /*#__PURE__*/React.createElement("div", {
87
124
  className: styles.secondaryActionsContainer