@dhis2-ui/menu 9.10.3 → 9.11.1-beta.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 (65) hide show
  1. package/build/cjs/flyout-menu/__tests__/flyout-menu.test.js +44 -0
  2. package/build/cjs/flyout-menu/features/accepts_children/index.js +0 -1
  3. package/build/cjs/flyout-menu/features/position/index.js +4 -4
  4. package/build/cjs/flyout-menu/features/toggles_submenus/index.js +0 -1
  5. package/build/cjs/flyout-menu/{flyout-menu.stories.e2e.js → flyout-menu.e2e.stories.js} +2 -20
  6. package/build/cjs/flyout-menu/flyout-menu.js +37 -19
  7. package/build/cjs/flyout-menu/{flyout-menu.stories.js → flyout-menu.prod.stories.js} +28 -38
  8. package/build/cjs/flyout-menu/index.js +0 -1
  9. package/build/cjs/index.js +0 -5
  10. package/build/cjs/menu/__tests__/menu.test.js +11 -50
  11. package/build/cjs/menu/features/accepts_children/index.js +0 -1
  12. package/build/cjs/menu/helpers.js +2 -10
  13. package/build/cjs/menu/index.js +0 -1
  14. package/build/cjs/menu/menu.e2e.stories.js +14 -0
  15. package/build/cjs/menu/menu.js +12 -20
  16. package/build/cjs/menu/{menu.stories.js → menu.prod.stories.js} +18 -17
  17. package/build/cjs/menu/use-menu.js +12 -20
  18. package/build/cjs/menu-divider/index.js +0 -1
  19. package/build/cjs/menu-divider/menu-divider.js +3 -11
  20. package/build/cjs/menu-divider/{menu-divider.stories.js → menu-divider.prod.stories.js} +11 -15
  21. package/build/cjs/menu-item/__tests__/menu-item.test.js +1 -5
  22. package/build/cjs/menu-item/features/accepts_href/index.js +1 -2
  23. package/build/cjs/menu-item/features/accepts_icon/index.js +0 -1
  24. package/build/cjs/menu-item/features/accepts_label/index.js +1 -2
  25. package/build/cjs/menu-item/features/accepts_suffix/index.js +0 -1
  26. package/build/cjs/menu-item/features/accepts_target/index.js +1 -2
  27. package/build/cjs/menu-item/features/is_clickable/index.js +0 -1
  28. package/build/cjs/menu-item/index.js +0 -1
  29. package/build/cjs/menu-item/{menu-item.stories.e2e.js → menu-item.e2e.stories.js} +2 -20
  30. package/build/cjs/menu-item/menu-item.js +48 -38
  31. package/build/cjs/menu-item/{menu-item.stories.js → menu-item.prod.stories.js} +22 -46
  32. package/build/cjs/menu-item/menu-item.styles.js +2 -5
  33. package/build/cjs/menu-section-header/features/accepts_label/index.js +1 -2
  34. package/build/cjs/menu-section-header/index.js +0 -1
  35. package/build/cjs/menu-section-header/{menu-section-header.stories.e2e.js → menu-section-header.e2e.stories.js} +2 -10
  36. package/build/cjs/menu-section-header/menu-section-header.js +3 -12
  37. package/build/cjs/menu-section-header/{menu-section-header.stories.js → menu-section-header.prod.stories.js} +11 -19
  38. package/build/es/flyout-menu/__tests__/flyout-menu.test.js +41 -0
  39. package/build/es/flyout-menu/features/position/index.js +4 -3
  40. package/build/es/flyout-menu/{flyout-menu.stories.e2e.js → flyout-menu.e2e.stories.js} +0 -2
  41. package/build/es/flyout-menu/flyout-menu.js +35 -9
  42. package/build/es/flyout-menu/{flyout-menu.stories.js → flyout-menu.prod.stories.js} +28 -13
  43. package/build/es/menu/__tests__/menu.test.js +10 -8
  44. package/build/es/menu/helpers.js +2 -6
  45. package/build/es/menu/menu.e2e.stories.js +6 -0
  46. package/build/es/menu/menu.js +9 -9
  47. package/build/es/menu/{menu.stories.js → menu.prod.stories.js} +18 -1
  48. package/build/es/menu/use-menu.js +12 -16
  49. package/build/es/menu-divider/menu-divider.js +2 -4
  50. package/build/es/menu-divider/{menu-divider.stories.js → menu-divider.prod.stories.js} +7 -3
  51. package/build/es/menu-item/features/accepts_href/index.js +1 -1
  52. package/build/es/menu-item/features/accepts_label/index.js +1 -1
  53. package/build/es/menu-item/features/accepts_target/index.js +1 -1
  54. package/build/es/menu-item/menu-item.js +46 -24
  55. package/build/es/menu-item/{menu-item.stories.js → menu-item.prod.stories.js} +14 -9
  56. package/build/es/menu-item/menu-item.styles.js +1 -1
  57. package/build/es/menu-section-header/features/accepts_label/index.js +1 -1
  58. package/build/es/menu-section-header/menu-section-header.js +2 -4
  59. package/build/es/menu-section-header/{menu-section-header.stories.js → menu-section-header.prod.stories.js} +7 -3
  60. package/package.json +11 -11
  61. package/types/index.d.ts +4 -0
  62. package/build/cjs/menu/menu.stories.e2e.js +0 -11
  63. package/build/es/menu/menu.stories.e2e.js +0 -4
  64. /package/build/es/menu-item/{menu-item.stories.e2e.js → menu-item.e2e.stories.js} +0 -0
  65. /package/build/es/menu-section-header/{menu-section-header.stories.e2e.js → menu-section-header.e2e.stories.js} +0 -0
@@ -1,15 +1,13 @@
1
1
  import _JSXStyle from "styled-jsx/style";
2
+ import { IconChevronRight24 } from '@dhis2/ui-icons';
2
3
  import { Popper } from '@dhis2-ui/popper';
3
4
  import { Portal } from '@dhis2-ui/portal';
4
- import { IconChevronRight24 } from '@dhis2/ui-icons';
5
5
  import cx from 'classnames';
6
6
  import PropTypes from 'prop-types';
7
- import React, { useRef } from 'react';
8
- import { FlyoutMenu } from '../index.js';
7
+ import React, { useEffect, useRef, useState } from 'react';
8
+ import { FlyoutMenu } from '../flyout-menu/index.js';
9
9
  import styles from './menu-item.styles.js';
10
-
11
10
  const isModifiedEvent = evt => evt.metaKey || evt.altKey || evt.ctrlKey || evt.shiftKey;
12
-
13
11
  const createOnClickHandler = _ref => {
14
12
  let {
15
13
  onClick,
@@ -21,7 +19,6 @@ const createOnClickHandler = _ref => {
21
19
  if (isLink && isModifiedEvent(evt) || !(onClick || toggleSubMenu)) {
22
20
  return;
23
21
  }
24
-
25
22
  evt.preventDefault();
26
23
  evt.stopPropagation();
27
24
  onClick && onClick({
@@ -30,7 +27,6 @@ const createOnClickHandler = _ref => {
30
27
  toggleSubMenu && toggleSubMenu();
31
28
  };
32
29
  };
33
-
34
30
  const MenuItem = _ref2 => {
35
31
  let {
36
32
  href,
@@ -55,12 +51,49 @@ const MenuItem = _ref2 => {
55
51
  tabIndex
56
52
  } = _ref2;
57
53
  const menuItemRef = useRef();
54
+ const [openSubMenus, setOpenSubMenus] = useState([]);
55
+ useEffect(() => {
56
+ // track open submenus
57
+ setOpenSubMenus(document.querySelectorAll('[data-submenu-open=true]'));
58
+ }, []);
59
+ useEffect(() => {
60
+ if (!menuItemRef.current) {
61
+ return;
62
+ }
63
+ const menuItem = menuItemRef.current;
64
+ const handleKeyDown = event => {
65
+ var _openSubMenus, _openSubMenus2;
66
+ const firstChild = event.target.children[0];
67
+ const hasSubMenu = firstChild === null || firstChild === void 0 ? void 0 : firstChild.getAttribute('aria-haspopup');
68
+ switch (event.key) {
69
+ // for submenus
70
+ case 'ArrowRight':
71
+ event.preventDefault();
72
+ if (hasSubMenu) {
73
+ firstChild.click();
74
+ }
75
+ break;
76
+ case 'ArrowLeft':
77
+ case 'Escape':
78
+ // close flyout menu
79
+ event.preventDefault();
80
+ (_openSubMenus = openSubMenus[openSubMenus.length - 1]) === null || _openSubMenus === void 0 ? void 0 : _openSubMenus.focus();
81
+ (_openSubMenus2 = openSubMenus[openSubMenus.length - 1]) === null || _openSubMenus2 === void 0 ? void 0 : _openSubMenus2.children[0].click();
82
+ break;
83
+ }
84
+ };
85
+ menuItem.addEventListener('keydown', handleKeyDown);
86
+ return () => {
87
+ menuItem.removeEventListener('keydown', handleKeyDown);
88
+ };
89
+ }, [openSubMenus]);
58
90
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("li", {
59
91
  ref: menuItemRef,
60
92
  "data-test": dataTest,
61
93
  role: "presentation",
62
94
  tabIndex: tabIndex,
63
- className: "jsx-".concat(styles.__hash) + " " + (cx(className, {
95
+ "data-submenu-open": children && showSubMenu,
96
+ className: `jsx-${styles.__hash}` + " " + (cx(className, {
64
97
  destructive,
65
98
  disabled,
66
99
  dense,
@@ -82,15 +115,15 @@ const MenuItem = _ref2 => {
82
115
  "aria-haspopup": children && 'menu',
83
116
  "aria-expanded": showSubMenu,
84
117
  "aria-label": label,
85
- className: "jsx-".concat(styles.__hash)
118
+ className: `jsx-${styles.__hash}`
86
119
  }, icon && /*#__PURE__*/React.createElement("span", {
87
- className: "jsx-".concat(styles.__hash) + " " + "icon"
120
+ className: `jsx-${styles.__hash}` + " " + "icon"
88
121
  }, icon), /*#__PURE__*/React.createElement("span", {
89
- className: "jsx-".concat(styles.__hash) + " " + "label"
122
+ className: `jsx-${styles.__hash}` + " " + "label"
90
123
  }, label), suffix && /*#__PURE__*/React.createElement("span", {
91
- className: "jsx-".concat(styles.__hash) + " " + "suffix"
124
+ className: `jsx-${styles.__hash}` + " " + "suffix"
92
125
  }, suffix), (chevron || children) && /*#__PURE__*/React.createElement("span", {
93
- className: "jsx-".concat(styles.__hash) + " " + "chevron"
126
+ className: `jsx-${styles.__hash}` + " " + "chevron"
94
127
  }, /*#__PURE__*/React.createElement(IconChevronRight24, null))), /*#__PURE__*/React.createElement(_JSXStyle, {
95
128
  id: styles.__hash
96
129
  }, styles)), children && showSubMenu && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(Popper, {
@@ -100,7 +133,6 @@ const MenuItem = _ref2 => {
100
133
  dense: dense
101
134
  }, children))));
102
135
  };
103
-
104
136
  MenuItem.defaultProps = {
105
137
  dataTest: 'dhis2-uicore-menuitem'
106
138
  };
@@ -109,7 +141,6 @@ MenuItem.propTypes = {
109
141
  checkbox: PropTypes.bool,
110
142
  checked: PropTypes.bool,
111
143
  chevron: PropTypes.bool,
112
-
113
144
  /**
114
145
  * Nested menu items can become submenus.
115
146
  * See `showSubMenu` and `toggleSubMenu` props, and 'Children' demo
@@ -120,32 +151,23 @@ MenuItem.propTypes = {
120
151
  dense: PropTypes.bool,
121
152
  destructive: PropTypes.bool,
122
153
  disabled: PropTypes.bool,
123
-
124
154
  /** For using menu item as a link */
125
155
  href: PropTypes.string,
126
-
127
156
  /** An icon for the left side of the menu item */
128
157
  icon: PropTypes.node,
129
-
130
158
  /** Text in the menu item */
131
159
  label: PropTypes.node,
132
-
133
160
  /** When true, nested menu items are shown in a Popper */
134
161
  showSubMenu: PropTypes.bool,
135
-
136
162
  /** A supporting element shown at the end of the menu item */
137
163
  suffix: PropTypes.node,
138
164
  tabIndex: PropTypes.number,
139
-
140
165
  /** For using menu item as a link */
141
166
  target: PropTypes.string,
142
-
143
167
  /** On click, this function is called (without args) */
144
168
  toggleSubMenu: PropTypes.func,
145
-
146
169
  /** Value associated with item. Passed as an argument to onClick handler. */
147
170
  value: PropTypes.string,
148
-
149
171
  /** Click handler called with signature `({ value: string }, event)` */
150
172
  onClick: PropTypes.func
151
173
  };
@@ -1,12 +1,23 @@
1
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
2
  import { Tag } from '@dhis2/ui';
4
3
  import { colors } from '@dhis2/ui-constants';
5
4
  import { IconApps24, IconVisualizationColumn24, IconLaunch16 } from '@dhis2/ui-icons';
6
5
  import React, { useState } from 'react';
7
6
  import { Menu } from '../index.js';
8
7
  import { MenuItem } from './menu-item.js';
9
- const description = "\nMenu Items are intended to be children of Menu and Flyout Menu components. They can be nested to create submenus.\n\nSplitting menus into several levels with child menus makes sense when there are a lot of options that can be grouped together. An example may be an option in level 1 menu of 'Download' that has several different download formats as child menu items. Make sure that child menu items relate to their parent item, otherwise a user will struggle to discover them. A menu item with children is not selectable/actionable itself, it serves only as a container for the child elements. Try to keep menus to a maximum of 1, 2 or 3 levels, anything more than this can easily confuse the user.\n\nThere is no enforced ordering of menu items, they should be presented in order of relevance. Put the most commonly used items at the top of the menu for easy discovery and access.\n\nSee the [design system](https://github.com/dhis2/design-system/blob/master/molecules/menu.md) for more information about menus.\n\n```js\nimport { MenuItem } from '@dhis2/ui'\n```\n";
8
+ const description = `
9
+ Menu Items are intended to be children of Menu and Flyout Menu components. They can be nested to create submenus.
10
+
11
+ Splitting menus into several levels with child menus makes sense when there are a lot of options that can be grouped together. An example may be an option in level 1 menu of 'Download' that has several different download formats as child menu items. Make sure that child menu items relate to their parent item, otherwise a user will struggle to discover them. A menu item with children is not selectable/actionable itself, it serves only as a container for the child elements. Try to keep menus to a maximum of 1, 2 or 3 levels, anything more than this can easily confuse the user.
12
+
13
+ There is no enforced ordering of menu items, they should be presented in order of relevance. Put the most commonly used items at the top of the menu for easy discovery and access.
14
+
15
+ See the [design system](https://github.com/dhis2/design-system/blob/master/molecules/menu.md) for more information about menus.
16
+
17
+ \`\`\`js
18
+ import { MenuItem } from '@dhis2/ui'
19
+ \`\`\`
20
+ `;
10
21
  export default {
11
22
  title: 'Menu Item',
12
23
  component: MenuItem,
@@ -21,9 +32,7 @@ export default {
21
32
  }
22
33
  }
23
34
  };
24
-
25
35
  const Template = args => /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(MenuItem, args));
26
-
27
36
  export const Default = Template.bind({});
28
37
  export const Active = Template.bind({});
29
38
  Active.args = {
@@ -121,9 +130,7 @@ OnClick.args = {
121
130
  };
122
131
  export const ToggleMenuItem = args => {
123
132
  const [on, setOn] = useState(false);
124
-
125
133
  const toggleOn = () => setOn(!on);
126
-
127
134
  const checkMarkStyle = {
128
135
  fontSize: '24px',
129
136
  lineHeight: '24px'
@@ -148,9 +155,7 @@ ToggleMenuItem.parameters = {
148
155
  };
149
156
  export const SubMenus = args => {
150
157
  const [showSubMenu, setShowSubMenu] = React.useState(false);
151
-
152
158
  const toggleSubMenu = () => setShowSubMenu(!showSubMenu);
153
-
154
159
  return /*#__PURE__*/React.createElement(Menu, null, /*#__PURE__*/React.createElement(MenuItem, _extends({
155
160
  showSubMenu: showSubMenu,
156
161
  toggleSubMenu: toggleSubMenu
@@ -1,4 +1,4 @@
1
1
  import { colors, spacers, theme } from '@dhis2/ui-constants';
2
- const _defaultExport = ["li.jsx-3192368000{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;padding:0;cursor:pointer;list-style:none;background-color:".concat(colors.white, ";color:").concat(colors.grey900, ";fill:").concat(colors.grey900, ";font-size:14px;line-height:16px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"), "li.jsx-3192368000:hover{background-color:".concat(colors.grey200, ";}"), "li.jsx-3192368000:active,li.active.jsx-3192368000{background-color:".concat(colors.grey300, ";}"), "li.destructive.jsx-3192368000{color:".concat(colors.red700, ";fill:").concat(colors.red600, ";}"), "li.destructive.jsx-3192368000:hover{background-color:".concat(colors.red050, ";}"), "li.destructive.jsx-3192368000:active,li.destructive.active.jsx-3192368000{background-color:".concat(colors.red100, ";}"), "li.disabled.jsx-3192368000{cursor:not-allowed;color:".concat(colors.grey500, ";fill:").concat(colors.grey500, ";}"), "li.disabled.jsx-3192368000:hover{background-color:".concat(colors.white, ";}"), "a.jsx-3192368000{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:0 ".concat(spacers.dp16, ";min-height:40px;-webkit-text-decoration:none;text-decoration:none;color:inherit;}"), "a.jsx-3192368000:focus{outline:3px solid ".concat(theme.focus, ";outline-offset:-3px;}"), "a.jsx-3192368000:focus.jsx-3192368000:not(:focus-visible){outline:none;}", "li.with-chevron.jsx-3192368000 a.jsx-3192368000{padding-inline-end:".concat(spacers.dp8, ";}"), "li.dense.jsx-3192368000 a.jsx-3192368000{padding:0 ".concat(spacers.dp12, ";min-height:32px;}"), "li.with-chevron.dense.jsx-3192368000 a.jsx-3192368000{padding-inline-end:".concat(spacers.dp4, ";}"), ".label.jsx-3192368000{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;padding:".concat(spacers.dp12, " 0;}"), "li.dense.jsx-3192368000 .label.jsx-3192368000{padding:".concat(spacers.dp8, " 0;}"), ".icon.jsx-3192368000{-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;margin-inline-end:".concat(spacers.dp12, ";width:24px;height:24px;}"), ".suffix.jsx-3192368000{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin-inline-start:".concat(spacers.dp8, ";}"), ".chevron.jsx-3192368000{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;margin-inline-start:".concat(spacers.dp24, ";}"), ".chevron.jsx-3192368000:dir(rtl){-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg);}", "li.dense.jsx-3192368000 .icon.jsx-3192368000{margin-inline-end:".concat(spacers.dp8, ";width:16px;height:16px;}"), "li.jsx-3192368000 .icon.jsx-3192368000>svg{width:24px;height:24px;}", "li.dense.jsx-3192368000 .icon.jsx-3192368000>svg,li.jsx-3192368000 .chevron.jsx-3192368000>svg{width:16px;height:16px;}"];
2
+ const _defaultExport = [`li.jsx-3192368000{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:stretch;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch;padding:0;cursor:pointer;list-style:none;background-color:${colors.white};color:${colors.grey900};fill:${colors.grey900};font-size:14px;line-height:16px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}`, `li.jsx-3192368000:hover{background-color:${colors.grey200};}`, `li.jsx-3192368000:active,li.active.jsx-3192368000{background-color:${colors.grey300};}`, `li.destructive.jsx-3192368000{color:${colors.red700};fill:${colors.red600};}`, `li.destructive.jsx-3192368000:hover{background-color:${colors.red050};}`, `li.destructive.jsx-3192368000:active,li.destructive.active.jsx-3192368000{background-color:${colors.red100};}`, `li.disabled.jsx-3192368000{cursor:not-allowed;color:${colors.grey500};fill:${colors.grey500};}`, `li.disabled.jsx-3192368000:hover{background-color:${colors.white};}`, `a.jsx-3192368000{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:0 ${spacers.dp16};min-height:40px;-webkit-text-decoration:none;text-decoration:none;color:inherit;}`, `a.jsx-3192368000:focus{outline:3px solid ${theme.focus};outline-offset:-3px;}`, "a.jsx-3192368000:focus.jsx-3192368000:not(:focus-visible){outline:none;}", `li.with-chevron.jsx-3192368000 a.jsx-3192368000{padding-inline-end:${spacers.dp8};}`, `li.dense.jsx-3192368000 a.jsx-3192368000{padding:0 ${spacers.dp12};min-height:32px;}`, `li.with-chevron.dense.jsx-3192368000 a.jsx-3192368000{padding-inline-end:${spacers.dp4};}`, `.label.jsx-3192368000{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;padding:${spacers.dp12} 0;}`, `li.dense.jsx-3192368000 .label.jsx-3192368000{padding:${spacers.dp8} 0;}`, `.icon.jsx-3192368000{-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;margin-inline-end:${spacers.dp12};width:24px;height:24px;}`, `.suffix.jsx-3192368000{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin-inline-start:${spacers.dp8};}`, `.chevron.jsx-3192368000{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;margin-inline-start:${spacers.dp24};}`, ".chevron.jsx-3192368000:dir(rtl){-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg);}", `li.dense.jsx-3192368000 .icon.jsx-3192368000{margin-inline-end:${spacers.dp8};width:16px;height:16px;}`, "li.jsx-3192368000 .icon.jsx-3192368000>svg{width:24px;height:24px;}", "li.dense.jsx-3192368000 .icon.jsx-3192368000>svg,li.jsx-3192368000 .chevron.jsx-3192368000>svg{width:16px;height:16px;}"];
3
3
  _defaultExport.__hash = "3192368000";
4
4
  export default _defaultExport;
@@ -4,5 +4,5 @@ Given('a MenuSectionHeader supplied with a label is rendered', () => {
4
4
  cy.get('[data-test="dhis2-uicore-menusectionheader"]').should('be.visible');
5
5
  });
6
6
  Then('the label is visible', () => {
7
- cy.contains('label').should('be.visible');
7
+ cy.get(':contains("label")').should('be.visible');
8
8
  });
@@ -1,10 +1,9 @@
1
1
  import _JSXStyle from "styled-jsx/style";
2
- import { Divider } from '@dhis2-ui/divider';
3
2
  import { colors, spacers } from '@dhis2/ui-constants';
3
+ import { Divider } from '@dhis2-ui/divider';
4
4
  import cx from 'classnames';
5
5
  import PropTypes from 'prop-types';
6
6
  import React from 'react';
7
-
8
7
  const MenuSectionHeader = _ref => {
9
8
  let {
10
9
  className,
@@ -25,9 +24,8 @@ const MenuSectionHeader = _ref => {
25
24
  }, label), /*#__PURE__*/React.createElement(_JSXStyle, {
26
25
  id: "1160864328",
27
26
  dynamic: [colors.white, spacers.dp8, spacers.dp16, spacers.dp8, spacers.dp16, colors.grey700, spacers.dp8, spacers.dp12, spacers.dp4, spacers.dp12]
28
- }, ["li.__jsx-style-dynamic-selector{list-style:none;background-color:".concat(colors.white, ";-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;padding:0;line-height:0;}"), "h6.__jsx-style-dynamic-selector{margin:0;padding:".concat(spacers.dp8, " ").concat(spacers.dp16, " ").concat(spacers.dp8, " ").concat(spacers.dp16, ";font-size:13px;line-height:16px;font-weight:500;color:").concat(colors.grey700, ";}"), "li.dense.__jsx-style-dynamic-selector h6.__jsx-style-dynamic-selector{padding:".concat(spacers.dp8, " ").concat(spacers.dp12, " ").concat(spacers.dp4, " ").concat(spacers.dp12, ";}")]));
27
+ }, [`li.__jsx-style-dynamic-selector{list-style:none;background-color:${colors.white};-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;padding:0;line-height:0;}`, `h6.__jsx-style-dynamic-selector{margin:0;padding:${spacers.dp8} ${spacers.dp16} ${spacers.dp8} ${spacers.dp16};font-size:13px;line-height:16px;font-weight:500;color:${colors.grey700};}`, `li.dense.__jsx-style-dynamic-selector h6.__jsx-style-dynamic-selector{padding:${spacers.dp8} ${spacers.dp12} ${spacers.dp4} ${spacers.dp12};}`]));
29
28
  };
30
-
31
29
  MenuSectionHeader.defaultProps = {
32
30
  dataTest: 'dhis2-uicore-menusectionheader'
33
31
  };
@@ -2,7 +2,13 @@ import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import { Menu, MenuItem } from '../index.js';
4
4
  import { MenuSectionHeader } from './menu-section-header.js';
5
- const description = "\nItems in a menu can be split into separate sections by using Dividers. Group relevant menu items together to help the user understand the options quickly. A Divider can be used alone. If using a Menu Section Header, a divider will be automatically included. Try not to group single menu items together. An exception to this is a critical destructive menu item, like 'Delete', which can be separated from other menu items.\n\n```js\nimport { MenuSectionHeader } from '@dhis2/ui'\n```\n";
5
+ const description = `
6
+ Items in a menu can be split into separate sections by using Dividers. Group relevant menu items together to help the user understand the options quickly. A Divider can be used alone. If using a Menu Section Header, a divider will be automatically included. Try not to group single menu items together. An exception to this is a critical destructive menu item, like 'Delete', which can be separated from other menu items.
7
+
8
+ \`\`\`js
9
+ import { MenuSectionHeader } from '@dhis2/ui'
10
+ \`\`\`
11
+ `;
6
12
  export default {
7
13
  title: 'Menu Section Header',
8
14
  component: MenuSectionHeader,
@@ -17,7 +23,6 @@ export default {
17
23
  }
18
24
  }
19
25
  };
20
-
21
26
  const Template = _ref => {
22
27
  let {
23
28
  menuArgs,
@@ -29,7 +34,6 @@ const Template = _ref => {
29
34
  label: "Menu item below"
30
35
  }));
31
36
  };
32
-
33
37
  Template.propTypes = {
34
38
  menuArgs: PropTypes.shape()
35
39
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/menu",
3
- "version": "9.10.3",
3
+ "version": "9.11.1-beta.1",
4
4
  "description": "UI Menu",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,24 +22,24 @@
22
22
  "access": "public"
23
23
  },
24
24
  "scripts": {
25
- "start": "start-storybook -c ../../storybook/config --port 5000",
25
+ "start": "storybook dev -c ../../storybook/config --port 5000",
26
26
  "build": "d2-app-scripts build",
27
27
  "test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
28
28
  },
29
29
  "peerDependencies": {
30
- "react": "^16.8",
31
- "react-dom": "^16.8",
30
+ "react": "^16.13",
31
+ "react-dom": "^16.13",
32
32
  "styled-jsx": "^4"
33
33
  },
34
34
  "dependencies": {
35
35
  "@dhis2/prop-types": "^3.1.2",
36
- "@dhis2-ui/card": "9.10.3",
37
- "@dhis2-ui/divider": "9.10.3",
38
- "@dhis2-ui/layer": "9.10.3",
39
- "@dhis2-ui/popper": "9.10.3",
40
- "@dhis2-ui/portal": "9.10.3",
41
- "@dhis2/ui-constants": "9.10.3",
42
- "@dhis2/ui-icons": "9.10.3",
36
+ "@dhis2-ui/card": "9.11.1-beta.1",
37
+ "@dhis2-ui/divider": "9.11.1-beta.1",
38
+ "@dhis2-ui/layer": "9.11.1-beta.1",
39
+ "@dhis2-ui/popper": "9.11.1-beta.1",
40
+ "@dhis2-ui/portal": "9.11.1-beta.1",
41
+ "@dhis2/ui-constants": "9.11.1-beta.1",
42
+ "@dhis2/ui-icons": "9.11.1-beta.1",
43
43
  "classnames": "^2.3.1",
44
44
  "prop-types": "^15.7.2"
45
45
  },
package/types/index.d.ts CHANGED
@@ -6,6 +6,10 @@ export interface FlyoutMenuProps {
6
6
  */
7
7
  children?: React.ReactNode
8
8
  className?: string
9
+ /**
10
+ * On Escape key press, this function is called
11
+ */
12
+ closeMenu?: () => void
9
13
  dataTest?: string
10
14
  /**
11
15
  * Menu uses smaller dimensions
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- var _react = require("@storybook/react");
4
-
5
- var _react2 = _interopRequireDefault(require("react"));
6
-
7
- var _index = require("./index.js");
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
- (0, _react.storiesOf)('Menu', module).add('With children', () => /*#__PURE__*/_react2.default.createElement(_index.Menu, null, "I am a child"));
@@ -1,4 +0,0 @@
1
- import { storiesOf } from '@storybook/react';
2
- import React from 'react';
3
- import { Menu } from './index.js';
4
- storiesOf('Menu', module).add('With children', () => /*#__PURE__*/React.createElement(Menu, null, "I am a child"));