@dhis2-ui/menu 8.1.10 → 8.2.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 (29) hide show
  1. package/build/cjs/flyout-menu/features/position/index.js +8 -4
  2. package/build/cjs/flyout-menu/flyout-menu.js +10 -9
  3. package/build/cjs/flyout-menu/flyout-menu.stories.e2e.js +1 -1
  4. package/build/cjs/flyout-menu/flyout-menu.stories.js +12 -30
  5. package/build/cjs/index.js +10 -10
  6. package/build/cjs/menu/menu.js +17 -14
  7. package/build/cjs/menu/menu.stories.js +3 -20
  8. package/build/cjs/menu-divider/menu-divider.js +16 -13
  9. package/build/cjs/menu-divider/menu-divider.stories.js +3 -9
  10. package/build/cjs/menu-item/menu-item.js +42 -38
  11. package/build/cjs/menu-item/menu-item.stories.e2e.js +1 -1
  12. package/build/cjs/menu-item/menu-item.stories.js +3 -15
  13. package/build/cjs/menu-item/menu-item.styles.js +1 -1
  14. package/build/cjs/menu-section-header/menu-section-header.js +22 -19
  15. package/build/cjs/menu-section-header/menu-section-header.stories.e2e.js +1 -1
  16. package/build/cjs/menu-section-header/menu-section-header.stories.js +14 -17
  17. package/build/es/flyout-menu/features/position/index.js +8 -4
  18. package/build/es/flyout-menu/flyout-menu.js +10 -9
  19. package/build/es/flyout-menu/flyout-menu.stories.js +11 -29
  20. package/build/es/menu/menu.js +17 -14
  21. package/build/es/menu/menu.stories.js +2 -19
  22. package/build/es/menu-divider/menu-divider.js +16 -13
  23. package/build/es/menu-divider/menu-divider.stories.js +2 -8
  24. package/build/es/menu-item/menu-item.js +42 -38
  25. package/build/es/menu-item/menu-item.stories.js +2 -14
  26. package/build/es/menu-item/menu-item.styles.js +1 -1
  27. package/build/es/menu-section-header/menu-section-header.js +22 -19
  28. package/build/es/menu-section-header/menu-section-header.stories.js +13 -16
  29. package/package.json +8 -8
@@ -16,23 +16,27 @@ const CLOSE_TO_DELTA = 1;
16
16
  cy.get('[data-test="dhis2-uicore-menuitem"]').click();
17
17
  });
18
18
  (0, _steps.Then)('the right of the MenuItem is aligned with the left of the SubMenu', () => {
19
- getMenuItemAndSubMenuRects().should(([menuItemRect, subMenuRect]) => {
19
+ getMenuItemAndSubMenuRects().should(_ref => {
20
+ let [menuItemRect, subMenuRect] = _ref;
20
21
  expect(menuItemRect.right).to.closeTo(subMenuRect.left, CLOSE_TO_DELTA);
21
22
  });
22
23
  });
23
24
  (0, _steps.Then)('the left of the MenuItem is aligned with the right of the SubMenu', () => {
24
- getMenuItemAndSubMenuRects().should(([menuItemRect, subMenuRect]) => {
25
+ getMenuItemAndSubMenuRects().should(_ref2 => {
26
+ let [menuItemRect, subMenuRect] = _ref2;
25
27
  expect(menuItemRect.left).to.closeTo(subMenuRect.right, CLOSE_TO_DELTA);
26
28
  });
27
29
  });
28
30
  (0, _steps.Then)('the SubMenu is rendered on top of the MenuItem', () => {
29
- getMenuItemAndSubMenuRects().should(([menuItemRect, subMenuRect]) => {
31
+ getMenuItemAndSubMenuRects().should(_ref3 => {
32
+ let [menuItemRect, subMenuRect] = _ref3;
30
33
  expect(subMenuRect.left).to.be.at.most(menuItemRect.left);
31
34
  expect(subMenuRect.right).to.be.at.least(menuItemRect.right);
32
35
  });
33
36
  });
34
37
  (0, _steps.Then)('the top of the MenuItem is aligned with the top of the SubMenu wrapper', () => {
35
- cy.getPositionsBySelectors('[data-test="dhis2-uicore-menuitem"]', '[data-test="dhis2-uicore-popper"]').should(([menuItemRect, popperRect]) => {
38
+ cy.getPositionsBySelectors('[data-test="dhis2-uicore-menuitem"]', '[data-test="dhis2-uicore-popper"]').should(_ref4 => {
39
+ let [menuItemRect, popperRect] = _ref4;
36
40
  expect(menuItemRect.top).to.closeTo(popperRect.top, CLOSE_TO_DELTA);
37
41
  });
38
42
  });
@@ -21,14 +21,15 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
21
21
 
22
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
23
 
24
- const FlyoutMenu = ({
25
- children,
26
- className,
27
- dataTest,
28
- dense,
29
- maxHeight,
30
- maxWidth
31
- }) => {
24
+ const FlyoutMenu = _ref => {
25
+ let {
26
+ children,
27
+ className,
28
+ dataTest,
29
+ dense,
30
+ maxHeight,
31
+ maxWidth
32
+ } = _ref;
32
33
  const [openedSubMenu, setOpenedSubMenu] = (0, _react.useState)(null);
33
34
 
34
35
  const toggleSubMenu = index => {
@@ -47,7 +48,7 @@ const FlyoutMenu = ({
47
48
  }) : child)), /*#__PURE__*/_react.default.createElement(_style.default, {
48
49
  id: "52281811",
49
50
  dynamic: [_uiConstants.colors.white, _uiConstants.colors.grey200, _uiConstants.elevations.e300, dense ? '128' : '180', maxWidth, maxHeight, _uiConstants.spacers.dp4]
50
- }, [`div.__jsx-style-dynamic-selector{background:${_uiConstants.colors.white};border:1px solid ${_uiConstants.colors.grey200};border-radius:3px;box-shadow:${_uiConstants.elevations.e300};display:inline-block;min-width:${dense ? '128' : '180'}px;max-width:${maxWidth};max-height:${maxHeight};padding:${_uiConstants.spacers.dp4} 0;}`]));
51
+ }, ["div.__jsx-style-dynamic-selector{background:".concat(_uiConstants.colors.white, ";border:1px solid ").concat(_uiConstants.colors.grey200, ";border-radius:3px;box-shadow:").concat(_uiConstants.elevations.e300, ";display:inline-block;min-width:").concat(dense ? '128' : '180', "px;max-width:").concat(maxWidth, ";max-height:").concat(maxHeight, ";padding:").concat(_uiConstants.spacers.dp4, " 0;}")]));
51
52
  };
52
53
 
53
54
  exports.FlyoutMenu = FlyoutMenu;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.ShiftIntoView = exports.FlippedPosition = exports.DefaultPosition = exports.TogglesSubMenus = exports.WithChildren = exports.default = void 0;
6
+ exports.default = exports.WithChildren = exports.TogglesSubMenus = exports.ShiftIntoView = exports.FlippedPosition = exports.DefaultPosition = void 0;
7
7
 
8
8
  var _style = _interopRequireDefault(require("styled-jsx/style"));
9
9
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WithCustomMenuItem = exports.DropDownMenu = exports.WithVariousChildren = exports.WithSubMenus = exports.MaxWidth = exports.MaxHeight = exports.Dense = exports.Default = exports.default = void 0;
6
+ exports.default = exports.WithVariousChildren = exports.WithSubMenus = exports.WithCustomMenuItem = exports.MaxWidth = exports.MaxHeight = exports.DropDownMenu = exports.Dense = exports.Default = void 0;
7
7
 
8
8
  var _layer = require("@dhis2-ui/layer");
9
9
 
@@ -23,26 +23,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
23
23
 
24
24
  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); }
25
25
 
26
- const description = `
27
- Use menus to provide access to options and actions where space is limited and displaying all the options would be impractical. For example, providing access to a range of actions for every dashboard item displayed. Containing all those actions in menus keeps the page manageable.
28
-
29
- The menu component is flexible in where it can be used and its contents can be flexible too. However, the most common use case is a menu containing menu items.
30
-
31
- Make sure the menu item labels are short and easy to understand. One word is often enough to describe an action or option. Do not use sentences as labels. Some examples of good menu item labels:
32
-
33
- - "Save"
34
- - "Open as map"
35
- - "Export PDF"
36
- - "Duplicate"
37
-
38
- See more about how to use menus at the [design system](https://github.com/dhis2/design-system/blob/master/molecules/menu.md).
39
-
40
- \`\`\`js
41
- import { FlyoutMenu } from 'dhis2/ui'
42
- \`\`\`
43
- `;
26
+ const description = "\nUse menus to provide access to options and actions where space is limited and displaying all the options would be impractical. For example, providing access to a range of actions for every dashboard item displayed. Containing all those actions in menus keeps the page manageable.\n\nThe menu component is flexible in where it can be used and its contents can be flexible too. However, the most common use case is a menu containing menu items.\n\nMake sure the menu item labels are short and easy to understand. One word is often enough to describe an action or option. Do not use sentences as labels. Some examples of good menu item labels:\n\n- \"Save\"\n- \"Open as map\"\n- \"Export PDF\"\n- \"Duplicate\"\n\nSee more about how to use menus at the [design system](https://github.com/dhis2/design-system/blob/master/molecules/menu.md).\n\n```js\nimport { FlyoutMenu } from 'dhis2/ui'\n```\n";
44
27
  var _default = {
45
- title: 'Actions/Menu/Flyout Menu',
28
+ title: 'Flyout Menu',
46
29
  component: _flyoutMenu.FlyoutMenu,
47
30
  parameters: {
48
31
  docs: {
@@ -103,11 +86,9 @@ const MaxWidth = args => /*#__PURE__*/_react.default.createElement(_react.defaul
103
86
  }), /*#__PURE__*/_react.default.createElement(_menu.MenuItem, {
104
87
  label: "Item 2 - with a lot of text and using a default maxWidth value of 380px"
105
88
  })), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(_flyoutMenu.FlyoutMenu, args, /*#__PURE__*/_react.default.createElement(_menu.MenuItem, {
106
- label: `Item 1 - with a lot of text and using a custom maxWidth value of
107
- ${args.maxWidth}`
89
+ label: "Item 1 - with a lot of text and using a custom maxWidth value of\n ".concat(args.maxWidth)
108
90
  }), /*#__PURE__*/_react.default.createElement(_menu.MenuItem, {
109
- label: `Item 2 - with a lot of text and using a custom maxWidth value of
110
- ${args.maxWidth}`
91
+ label: "Item 2 - with a lot of text and using a custom maxWidth value of\n ".concat(args.maxWidth)
111
92
  })));
112
93
 
113
94
  exports.MaxWidth = MaxWidth;
@@ -243,17 +224,18 @@ DropDownMenu.parameters = {
243
224
  const WithCustomMenuItem = args => {
244
225
  // You should not create custom components in the render cycle
245
226
  // this is just for demo purposes
246
- const PopupWindowMenuItem = ({
247
- to,
248
- children,
249
- ...rest
250
- }) => {
227
+ const PopupWindowMenuItem = _ref => {
228
+ let {
229
+ to,
230
+ children,
231
+ ...rest
232
+ } = _ref;
251
233
  const HEIGHT = 1000;
252
234
  const WIDTH = 1400;
253
235
  const centerY = (window.screen.height - HEIGHT) / 2;
254
236
  const centerX = (window.screen.width - WIDTH) / 2;
255
237
 
256
- const onClick = () => window.open(to, 'Popup', ['menubar=no', 'location=no', 'resizable=no', 'scrollbars=no', 'status=no', `width=${WIDTH}`, `height=${HEIGHT}`, `top=${centerY}`, `left=${centerX}`].join());
238
+ const onClick = () => window.open(to, 'Popup', ['menubar=no', 'location=no', 'resizable=no', 'scrollbars=no', 'status=no', "width=".concat(WIDTH), "height=".concat(HEIGHT), "top=".concat(centerY), "left=".concat(centerX)].join());
257
239
 
258
240
  return /*#__PURE__*/_react.default.createElement(_menu.MenuItem, _extends({
259
241
  onClick: onClick,
@@ -3,34 +3,34 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "MenuDivider", {
6
+ Object.defineProperty(exports, "FlyoutMenu", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _index.MenuDivider;
9
+ return _index5.FlyoutMenu;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "MenuItem", {
12
+ Object.defineProperty(exports, "Menu", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _index2.MenuItem;
15
+ return _index4.Menu;
16
16
  }
17
17
  });
18
- Object.defineProperty(exports, "MenuSectionHeader", {
18
+ Object.defineProperty(exports, "MenuDivider", {
19
19
  enumerable: true,
20
20
  get: function () {
21
- return _index3.MenuSectionHeader;
21
+ return _index.MenuDivider;
22
22
  }
23
23
  });
24
- Object.defineProperty(exports, "Menu", {
24
+ Object.defineProperty(exports, "MenuItem", {
25
25
  enumerable: true,
26
26
  get: function () {
27
- return _index4.Menu;
27
+ return _index2.MenuItem;
28
28
  }
29
29
  });
30
- Object.defineProperty(exports, "FlyoutMenu", {
30
+ Object.defineProperty(exports, "MenuSectionHeader", {
31
31
  enumerable: true,
32
32
  get: function () {
33
- return _index5.FlyoutMenu;
33
+ return _index3.MenuSectionHeader;
34
34
  }
35
35
  });
36
36
 
@@ -17,20 +17,23 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
- const Menu = ({
21
- children,
22
- className,
23
- dataTest,
24
- dense
25
- }) => /*#__PURE__*/_react.default.createElement("ul", {
26
- "data-test": dataTest,
27
- className: "jsx-3549878755" + " " + (className || "")
28
- }, _react.Children.map(children, (child, index) => /*#__PURE__*/(0, _react.isValidElement)(child) ? /*#__PURE__*/(0, _react.cloneElement)(child, {
29
- dense: typeof child.props.dense === 'boolean' ? child.props.dense : dense,
30
- hideDivider: typeof child.props.hideDivider !== 'boolean' && index === 0 ? true : child.props.hideDivider
31
- }) : child), /*#__PURE__*/_react.default.createElement(_style.default, {
32
- id: "3549878755"
33
- }, ["ul.jsx-3549878755{display:block;position:relative;width:100%;margin:0;padding:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"]));
20
+ const Menu = _ref => {
21
+ let {
22
+ children,
23
+ className,
24
+ dataTest,
25
+ dense
26
+ } = _ref;
27
+ return /*#__PURE__*/_react.default.createElement("ul", {
28
+ "data-test": dataTest,
29
+ className: "jsx-3549878755" + " " + (className || "")
30
+ }, _react.Children.map(children, (child, index) => /*#__PURE__*/(0, _react.isValidElement)(child) ? /*#__PURE__*/(0, _react.cloneElement)(child, {
31
+ dense: typeof child.props.dense === 'boolean' ? child.props.dense : dense,
32
+ hideDivider: typeof child.props.hideDivider !== 'boolean' && index === 0 ? true : child.props.hideDivider
33
+ }) : child), /*#__PURE__*/_react.default.createElement(_style.default, {
34
+ id: "3549878755"
35
+ }, ["ul.jsx-3549878755{display:block;position:relative;width:100%;margin:0;padding:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"]));
36
+ };
34
37
 
35
38
  exports.Menu = Menu;
36
39
  Menu.defaultProps = {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SideBarMenu = exports.AutoHideFirstSectionHeaderDivider = exports.Dense = exports.Default = exports.default = void 0;
6
+ exports.default = exports.SideBarMenu = exports.Dense = exports.Default = exports.AutoHideFirstSectionHeaderDivider = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
@@ -13,26 +13,9 @@ var _index2 = require("./index.js");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- const description = `
17
- Use menus to provide access to options and actions where space is limited and displaying all the options would be impractical. For example, providing access to a range of actions for every dashboard item displayed. Containing all those actions in menus keeps the page manageable.
18
-
19
- The menu component is flexible in where it can be used and its contents can be flexible too. However, the most common use case is a menu containing menu items.
20
-
21
- Make sure the menu item labels are short and easy to understand. One word is often enough to describe an action or option. Do not use sentences as labels. Some examples of good menu item labels:
22
-
23
- - "Save"
24
- - "Open as map"
25
- - "Export PDF"
26
- - "Duplicate"
27
-
28
- Typical children are Menu Items, Menu Dividers, and Menu Section Headers.
29
-
30
- \`\`\`js
31
- import { Menu } from '@dhis2/ui'
32
- \`\`\`
33
- `;
16
+ const description = "\nUse menus to provide access to options and actions where space is limited and displaying all the options would be impractical. For example, providing access to a range of actions for every dashboard item displayed. Containing all those actions in menus keeps the page manageable.\n\nThe menu component is flexible in where it can be used and its contents can be flexible too. However, the most common use case is a menu containing menu items.\n\nMake sure the menu item labels are short and easy to understand. One word is often enough to describe an action or option. Do not use sentences as labels. Some examples of good menu item labels:\n\n- \"Save\"\n- \"Open as map\"\n- \"Export PDF\"\n- \"Duplicate\"\n\nTypical children are Menu Items, Menu Dividers, and Menu Section Headers.\n\n```js\nimport { Menu } from '@dhis2/ui'\n```\n";
34
17
  var _default = {
35
- title: 'Actions/Menu/Menu',
18
+ title: 'Menu',
36
19
  component: _index2.Menu,
37
20
  parameters: {
38
21
  docs: {
@@ -17,19 +17,22 @@ var _react = _interopRequireDefault(require("react"));
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
19
 
20
- const MenuDivider = ({
21
- className,
22
- dataTest,
23
- dense
24
- }) => /*#__PURE__*/_react.default.createElement("li", {
25
- "data-test": dataTest,
26
- className: _style.default.dynamic([["591815244", [_uiConstants.colors.white]]]) + " " + (className || "")
27
- }, /*#__PURE__*/_react.default.createElement(_divider.Divider, {
28
- dense: dense
29
- }), /*#__PURE__*/_react.default.createElement(_style.default, {
30
- id: "591815244",
31
- dynamic: [_uiConstants.colors.white]
32
- }, [`li.__jsx-style-dynamic-selector{list-style:none;background-color:${_uiConstants.colors.white};-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;padding:0;line-height:0;}`]));
20
+ const MenuDivider = _ref => {
21
+ let {
22
+ className,
23
+ dataTest,
24
+ dense
25
+ } = _ref;
26
+ return /*#__PURE__*/_react.default.createElement("li", {
27
+ "data-test": dataTest,
28
+ className: _style.default.dynamic([["591815244", [_uiConstants.colors.white]]]) + " " + (className || "")
29
+ }, /*#__PURE__*/_react.default.createElement(_divider.Divider, {
30
+ dense: dense
31
+ }), /*#__PURE__*/_react.default.createElement(_style.default, {
32
+ id: "591815244",
33
+ dynamic: [_uiConstants.colors.white]
34
+ }, ["li.__jsx-style-dynamic-selector{list-style:none;background-color:".concat(_uiConstants.colors.white, ";-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;padding:0;line-height:0;}")]));
35
+ };
33
36
 
34
37
  exports.MenuDivider = MenuDivider;
35
38
  MenuDivider.defaultProps = {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Dense = exports.Default = exports.default = void 0;
6
+ exports.default = exports.Dense = exports.Default = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
@@ -13,15 +13,9 @@ var _menuDivider = require("./menu-divider.js");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- const description = `
17
- 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 MenuSectionHeader, 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.
18
-
19
- \`\`\`js
20
- import { MenuDivider } from '@dhis2/ui'
21
- \`\`\`
22
- `;
16
+ 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 MenuSectionHeader, 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 { MenuDivider } from '@dhis2/ui'\n```\n";
23
17
  var _default = {
24
- title: 'Actions/Menu/Menu Divider',
18
+ title: 'Menu Divider',
25
19
  component: _menuDivider.MenuDivider,
26
20
  parameters: {
27
21
  docs: {
@@ -31,47 +31,51 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
31
31
 
32
32
  const isModifiedEvent = evt => evt.metaKey || evt.altKey || evt.ctrlKey || evt.shiftKey;
33
33
 
34
- const createOnClickHandler = ({
35
- onClick,
36
- toggleSubMenu,
37
- isLink,
38
- value
39
- }) => evt => {
40
- if (isLink && isModifiedEvent(evt) || !(onClick || toggleSubMenu)) {
41
- return;
42
- }
43
-
44
- evt.preventDefault();
45
- evt.stopPropagation();
46
- onClick && onClick({
34
+ const createOnClickHandler = _ref => {
35
+ let {
36
+ onClick,
37
+ toggleSubMenu,
38
+ isLink,
47
39
  value
48
- }, evt);
49
- toggleSubMenu && toggleSubMenu();
40
+ } = _ref;
41
+ return evt => {
42
+ if (isLink && isModifiedEvent(evt) || !(onClick || toggleSubMenu)) {
43
+ return;
44
+ }
45
+
46
+ evt.preventDefault();
47
+ evt.stopPropagation();
48
+ onClick && onClick({
49
+ value
50
+ }, evt);
51
+ toggleSubMenu && toggleSubMenu();
52
+ };
50
53
  };
51
54
 
52
- const MenuItem = ({
53
- href,
54
- onClick,
55
- children,
56
- target,
57
- icon,
58
- className,
59
- destructive,
60
- disabled,
61
- dense,
62
- active,
63
- dataTest,
64
- chevron,
65
- value,
66
- label,
67
- showSubMenu,
68
- toggleSubMenu
69
- }) => {
55
+ const MenuItem = _ref2 => {
56
+ let {
57
+ href,
58
+ onClick,
59
+ children,
60
+ target,
61
+ icon,
62
+ className,
63
+ destructive,
64
+ disabled,
65
+ dense,
66
+ active,
67
+ dataTest,
68
+ chevron,
69
+ value,
70
+ label,
71
+ showSubMenu,
72
+ toggleSubMenu
73
+ } = _ref2;
70
74
  const menuItemRef = (0, _react.useRef)();
71
75
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("li", {
72
76
  ref: menuItemRef,
73
77
  "data-test": dataTest,
74
- className: `jsx-${_menuItemStyles.default.__hash}` + " " + ((0, _classnames.default)(className, {
78
+ className: "jsx-".concat(_menuItemStyles.default.__hash) + " " + ((0, _classnames.default)(className, {
75
79
  destructive,
76
80
  disabled,
77
81
  dense,
@@ -87,13 +91,13 @@ const MenuItem = ({
87
91
  isLink: !!href,
88
92
  value
89
93
  }) : undefined,
90
- className: `jsx-${_menuItemStyles.default.__hash}`
94
+ className: "jsx-".concat(_menuItemStyles.default.__hash)
91
95
  }, icon && /*#__PURE__*/_react.default.createElement("span", {
92
- className: `jsx-${_menuItemStyles.default.__hash}` + " " + "icon"
96
+ className: "jsx-".concat(_menuItemStyles.default.__hash) + " " + "icon"
93
97
  }, icon), /*#__PURE__*/_react.default.createElement("span", {
94
- className: `jsx-${_menuItemStyles.default.__hash}` + " " + "label"
98
+ className: "jsx-".concat(_menuItemStyles.default.__hash) + " " + "label"
95
99
  }, label), (chevron || children) && /*#__PURE__*/_react.default.createElement("span", {
96
- className: `jsx-${_menuItemStyles.default.__hash}` + " " + "chevron"
100
+ className: "jsx-".concat(_menuItemStyles.default.__hash) + " " + "chevron"
97
101
  }, /*#__PURE__*/_react.default.createElement(_uiIcons.IconChevronRight24, null))), /*#__PURE__*/_react.default.createElement(_style.default, {
98
102
  id: _menuItemStyles.default.__hash
99
103
  }, _menuItemStyles.default)), children && showSubMenu && /*#__PURE__*/_react.default.createElement(_portal.Portal, null, /*#__PURE__*/_react.default.createElement(_popper.Popper, {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WithIcon = exports.WithTarget = exports.WithHref = exports.WithOnClickAndValue = exports.WithLabel = exports.default = void 0;
6
+ exports.default = exports.WithTarget = exports.WithOnClickAndValue = exports.WithLabel = exports.WithIcon = exports.WithHref = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SubMenus = exports.ToggleMenuItem = exports.OnClick = exports.Icon = exports.Link = exports.Disabled = exports.Destructive = exports.Dense = exports.Chevron = exports.Active = exports.Default = exports.default = void 0;
6
+ exports.default = exports.ToggleMenuItem = exports.SubMenus = exports.OnClick = exports.Link = exports.Icon = exports.Disabled = exports.Destructive = exports.Dense = exports.Default = exports.Chevron = exports.Active = void 0;
7
7
 
8
8
  var _uiIcons = require("@dhis2/ui-icons");
9
9
 
@@ -19,21 +19,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
19
19
 
20
20
  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); }
21
21
 
22
- const description = `
23
- Menu Items are intended to be children of Menu and Flyout Menu components. They can be nested to create submenus.
24
-
25
- 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.
26
-
27
- 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.
28
-
29
- See the [design system](https://github.com/dhis2/design-system/blob/master/molecules/menu.md) for more information about menus.
30
-
31
- \`\`\`js
32
- import { MenuItem } from '@dhis2/ui'
33
- \`\`\`
34
- `;
22
+ 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";
35
23
  var _default = {
36
- title: 'Actions/Menu/Menu Item',
24
+ title: 'Menu Item',
37
25
  component: _menuItem.MenuItem,
38
26
  args: {
39
27
  label: 'Menu item'
@@ -7,7 +7,7 @@ exports.default = void 0;
7
7
 
8
8
  var _uiConstants = require("@dhis2/ui-constants");
9
9
 
10
- const _defaultExport = [`li.jsx-3508410433{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;-webkit-transition:background-color 150ms ease-in-out;transition:background-color 150ms ease-in-out;background-color:${_uiConstants.colors.white};color:${_uiConstants.colors.grey900};fill:${_uiConstants.colors.grey900};font-size:15px;line-height:18px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}`, "li.dense.jsx-3508410433{font-size:14px;line-height:16px;}", `li.jsx-3508410433:hover{background-color:${_uiConstants.colors.grey200};}`, `li.jsx-3508410433:active,li.active.jsx-3508410433{background-color:${_uiConstants.colors.grey400};}`, `li.destructive.jsx-3508410433{color:${_uiConstants.colors.red700};fill:${_uiConstants.colors.red600};}`, `li.destructive.jsx-3508410433:hover{background-color:${_uiConstants.colors.red050};}`, `li.destructive.jsx-3508410433:active,li.destructive.active.jsx-3508410433{background-color:${_uiConstants.colors.red100};}`, `li.disabled.jsx-3508410433{cursor:not-allowed;color:${_uiConstants.colors.grey500};fill:${_uiConstants.colors.grey500};}`, `li.disabled.jsx-3508410433:hover{background-color:${_uiConstants.colors.white};}`, `a.jsx-3508410433{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 ${_uiConstants.spacers.dp24};min-height:48px;-webkit-text-decoration:none;text-decoration:none;color:inherit;}`, `a.jsx-3508410433:focus{outline:3px solid ${_uiConstants.theme.focus};outline-offset:-3px;}`, "a.jsx-3508410433:focus.jsx-3508410433:not(:focus-visible){outline:none;}", `li.with-chevron.jsx-3508410433 a.jsx-3508410433{padding-right:${_uiConstants.spacers.dp8};}`, `li.dense.jsx-3508410433 a.jsx-3508410433{padding:0 ${_uiConstants.spacers.dp12};min-height:32px;}`, `li.with-chevron.dense.jsx-3508410433 a.jsx-3508410433{padding-right:${_uiConstants.spacers.dp4};}`, ".label.jsx-3508410433{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;padding:15px 0;}", "li.dense.jsx-3508410433 .label.jsx-3508410433{padding:8px 0;}", `.icon.jsx-3508410433{-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;margin-right:${_uiConstants.spacers.dp16};width:24px;height:24px;}`, `.chevron.jsx-3508410433{-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;margin-left:${_uiConstants.spacers.dp48};}`, `li.dense.jsx-3508410433 .icon.jsx-3508410433{margin-right:${_uiConstants.spacers.dp8};width:16px;height:16px;}`, "li.jsx-3508410433 .icon.jsx-3508410433>svg{width:24px;height:24px;}", "li.dense.jsx-3508410433 .icon.jsx-3508410433>svg,li.jsx-3508410433 .chevron.jsx-3508410433>svg{width:16px;height:16px;}"];
10
+ const _defaultExport = ["li.jsx-3508410433{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;-webkit-transition:background-color 150ms ease-in-out;transition:background-color 150ms ease-in-out;background-color:".concat(_uiConstants.colors.white, ";color:").concat(_uiConstants.colors.grey900, ";fill:").concat(_uiConstants.colors.grey900, ";font-size:15px;line-height:18px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"), "li.dense.jsx-3508410433{font-size:14px;line-height:16px;}", "li.jsx-3508410433:hover{background-color:".concat(_uiConstants.colors.grey200, ";}"), "li.jsx-3508410433:active,li.active.jsx-3508410433{background-color:".concat(_uiConstants.colors.grey400, ";}"), "li.destructive.jsx-3508410433{color:".concat(_uiConstants.colors.red700, ";fill:").concat(_uiConstants.colors.red600, ";}"), "li.destructive.jsx-3508410433:hover{background-color:".concat(_uiConstants.colors.red050, ";}"), "li.destructive.jsx-3508410433:active,li.destructive.active.jsx-3508410433{background-color:".concat(_uiConstants.colors.red100, ";}"), "li.disabled.jsx-3508410433{cursor:not-allowed;color:".concat(_uiConstants.colors.grey500, ";fill:").concat(_uiConstants.colors.grey500, ";}"), "li.disabled.jsx-3508410433:hover{background-color:".concat(_uiConstants.colors.white, ";}"), "a.jsx-3508410433{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(_uiConstants.spacers.dp24, ";min-height:48px;-webkit-text-decoration:none;text-decoration:none;color:inherit;}"), "a.jsx-3508410433:focus{outline:3px solid ".concat(_uiConstants.theme.focus, ";outline-offset:-3px;}"), "a.jsx-3508410433:focus.jsx-3508410433:not(:focus-visible){outline:none;}", "li.with-chevron.jsx-3508410433 a.jsx-3508410433{padding-right:".concat(_uiConstants.spacers.dp8, ";}"), "li.dense.jsx-3508410433 a.jsx-3508410433{padding:0 ".concat(_uiConstants.spacers.dp12, ";min-height:32px;}"), "li.with-chevron.dense.jsx-3508410433 a.jsx-3508410433{padding-right:".concat(_uiConstants.spacers.dp4, ";}"), ".label.jsx-3508410433{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;padding:15px 0;}", "li.dense.jsx-3508410433 .label.jsx-3508410433{padding:8px 0;}", ".icon.jsx-3508410433{-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;margin-right:".concat(_uiConstants.spacers.dp16, ";width:24px;height:24px;}"), ".chevron.jsx-3508410433{-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;margin-left:".concat(_uiConstants.spacers.dp48, ";}"), "li.dense.jsx-3508410433 .icon.jsx-3508410433{margin-right:".concat(_uiConstants.spacers.dp8, ";width:16px;height:16px;}"), "li.jsx-3508410433 .icon.jsx-3508410433>svg{width:24px;height:24px;}", "li.dense.jsx-3508410433 .icon.jsx-3508410433>svg,li.jsx-3508410433 .chevron.jsx-3508410433>svg{width:16px;height:16px;}"];
11
11
  _defaultExport.__hash = "3508410433";
12
12
  var _default = _defaultExport;
13
13
  exports.default = _default;
@@ -19,25 +19,28 @@ var _react = _interopRequireDefault(require("react"));
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
 
22
- const MenuSectionHeader = ({
23
- className,
24
- dataTest,
25
- dense,
26
- hideDivider,
27
- label
28
- }) => /*#__PURE__*/_react.default.createElement("li", {
29
- "data-test": dataTest,
30
- className: _style.default.dynamic([["954853487", [_uiConstants.colors.white, _uiConstants.spacers.dp8, _uiConstants.spacers.dp24, _uiConstants.spacers.dp12, _uiConstants.spacers.dp24, _uiConstants.colors.grey600, _uiConstants.spacers.dp8, _uiConstants.spacers.dp12, _uiConstants.spacers.dp12]]]) + " " + ((0, _classnames.default)(className, {
31
- dense
32
- }) || "")
33
- }, !hideDivider && /*#__PURE__*/_react.default.createElement(_divider.Divider, {
34
- dense: dense
35
- }), /*#__PURE__*/_react.default.createElement("h6", {
36
- className: _style.default.dynamic([["954853487", [_uiConstants.colors.white, _uiConstants.spacers.dp8, _uiConstants.spacers.dp24, _uiConstants.spacers.dp12, _uiConstants.spacers.dp24, _uiConstants.colors.grey600, _uiConstants.spacers.dp8, _uiConstants.spacers.dp12, _uiConstants.spacers.dp12]]])
37
- }, label), /*#__PURE__*/_react.default.createElement(_style.default, {
38
- id: "954853487",
39
- dynamic: [_uiConstants.colors.white, _uiConstants.spacers.dp8, _uiConstants.spacers.dp24, _uiConstants.spacers.dp12, _uiConstants.spacers.dp24, _uiConstants.colors.grey600, _uiConstants.spacers.dp8, _uiConstants.spacers.dp12, _uiConstants.spacers.dp12]
40
- }, [`li.__jsx-style-dynamic-selector{list-style:none;background-color:${_uiConstants.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:${_uiConstants.spacers.dp8} ${_uiConstants.spacers.dp24} ${_uiConstants.spacers.dp12} ${_uiConstants.spacers.dp24};font-size:15px;line-height:16px;font-weight:500;color:${_uiConstants.colors.grey600};}`, `li.dense.__jsx-style-dynamic-selector h6.__jsx-style-dynamic-selector{font-size:14px;line-height:16px;padding:${_uiConstants.spacers.dp8} ${_uiConstants.spacers.dp12} 6px ${_uiConstants.spacers.dp12};}`]));
22
+ const MenuSectionHeader = _ref => {
23
+ let {
24
+ className,
25
+ dataTest,
26
+ dense,
27
+ hideDivider,
28
+ label
29
+ } = _ref;
30
+ return /*#__PURE__*/_react.default.createElement("li", {
31
+ "data-test": dataTest,
32
+ className: _style.default.dynamic([["954853487", [_uiConstants.colors.white, _uiConstants.spacers.dp8, _uiConstants.spacers.dp24, _uiConstants.spacers.dp12, _uiConstants.spacers.dp24, _uiConstants.colors.grey600, _uiConstants.spacers.dp8, _uiConstants.spacers.dp12, _uiConstants.spacers.dp12]]]) + " " + ((0, _classnames.default)(className, {
33
+ dense
34
+ }) || "")
35
+ }, !hideDivider && /*#__PURE__*/_react.default.createElement(_divider.Divider, {
36
+ dense: dense
37
+ }), /*#__PURE__*/_react.default.createElement("h6", {
38
+ className: _style.default.dynamic([["954853487", [_uiConstants.colors.white, _uiConstants.spacers.dp8, _uiConstants.spacers.dp24, _uiConstants.spacers.dp12, _uiConstants.spacers.dp24, _uiConstants.colors.grey600, _uiConstants.spacers.dp8, _uiConstants.spacers.dp12, _uiConstants.spacers.dp12]]])
39
+ }, label), /*#__PURE__*/_react.default.createElement(_style.default, {
40
+ id: "954853487",
41
+ dynamic: [_uiConstants.colors.white, _uiConstants.spacers.dp8, _uiConstants.spacers.dp24, _uiConstants.spacers.dp12, _uiConstants.spacers.dp24, _uiConstants.colors.grey600, _uiConstants.spacers.dp8, _uiConstants.spacers.dp12, _uiConstants.spacers.dp12]
42
+ }, ["li.__jsx-style-dynamic-selector{list-style:none;background-color:".concat(_uiConstants.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(_uiConstants.spacers.dp8, " ").concat(_uiConstants.spacers.dp24, " ").concat(_uiConstants.spacers.dp12, " ").concat(_uiConstants.spacers.dp24, ";font-size:15px;line-height:16px;font-weight:500;color:").concat(_uiConstants.colors.grey600, ";}"), "li.dense.__jsx-style-dynamic-selector h6.__jsx-style-dynamic-selector{font-size:14px;line-height:16px;padding:".concat(_uiConstants.spacers.dp8, " ").concat(_uiConstants.spacers.dp12, " 6px ").concat(_uiConstants.spacers.dp12, ";}")]));
43
+ };
41
44
 
42
45
  exports.MenuSectionHeader = MenuSectionHeader;
43
46
  MenuSectionHeader.defaultProps = {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WithLabel = exports.default = void 0;
6
+ exports.default = exports.WithLabel = void 0;
7
7
 
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TopOfList = exports.WithoutDivider = exports.Dense = exports.Default = exports.default = void 0;
6
+ exports.default = exports.WithoutDivider = exports.TopOfList = exports.Dense = exports.Default = void 0;
7
7
 
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
 
@@ -15,15 +15,9 @@ var _menuSectionHeader = require("./menu-section-header.js");
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- const description = `
19
- 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.
20
-
21
- \`\`\`js
22
- import { MenuSectionHeader } from '@dhis2/ui'
23
- \`\`\`
24
- `;
18
+ 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";
25
19
  var _default = {
26
- title: 'Actions/Menu/Menu Section Header',
20
+ title: 'Menu Section Header',
27
21
  component: _menuSectionHeader.MenuSectionHeader,
28
22
  args: {
29
23
  label: 'Section header'
@@ -38,14 +32,17 @@ var _default = {
38
32
  };
39
33
  exports.default = _default;
40
34
 
41
- const Template = ({
42
- menuArgs,
43
- ...args
44
- }) => /*#__PURE__*/_react.default.createElement(_index.Menu, menuArgs, /*#__PURE__*/_react.default.createElement(_index.MenuItem, {
45
- label: "Menu item above"
46
- }), /*#__PURE__*/_react.default.createElement(_menuSectionHeader.MenuSectionHeader, args), /*#__PURE__*/_react.default.createElement(_index.MenuItem, {
47
- label: "Menu item below"
48
- }));
35
+ const Template = _ref => {
36
+ let {
37
+ menuArgs,
38
+ ...args
39
+ } = _ref;
40
+ return /*#__PURE__*/_react.default.createElement(_index.Menu, menuArgs, /*#__PURE__*/_react.default.createElement(_index.MenuItem, {
41
+ label: "Menu item above"
42
+ }), /*#__PURE__*/_react.default.createElement(_menuSectionHeader.MenuSectionHeader, args), /*#__PURE__*/_react.default.createElement(_index.MenuItem, {
43
+ label: "Menu item below"
44
+ }));
45
+ };
49
46
 
50
47
  Template.propTypes = {
51
48
  menuArgs: _propTypes.default.shape()
@@ -13,23 +13,27 @@ When('the user clicks on the MenuItem', () => {
13
13
  cy.get('[data-test="dhis2-uicore-menuitem"]').click();
14
14
  });
15
15
  Then('the right of the MenuItem is aligned with the left of the SubMenu', () => {
16
- getMenuItemAndSubMenuRects().should(([menuItemRect, subMenuRect]) => {
16
+ getMenuItemAndSubMenuRects().should(_ref => {
17
+ let [menuItemRect, subMenuRect] = _ref;
17
18
  expect(menuItemRect.right).to.closeTo(subMenuRect.left, CLOSE_TO_DELTA);
18
19
  });
19
20
  });
20
21
  Then('the left of the MenuItem is aligned with the right of the SubMenu', () => {
21
- getMenuItemAndSubMenuRects().should(([menuItemRect, subMenuRect]) => {
22
+ getMenuItemAndSubMenuRects().should(_ref2 => {
23
+ let [menuItemRect, subMenuRect] = _ref2;
22
24
  expect(menuItemRect.left).to.closeTo(subMenuRect.right, CLOSE_TO_DELTA);
23
25
  });
24
26
  });
25
27
  Then('the SubMenu is rendered on top of the MenuItem', () => {
26
- getMenuItemAndSubMenuRects().should(([menuItemRect, subMenuRect]) => {
28
+ getMenuItemAndSubMenuRects().should(_ref3 => {
29
+ let [menuItemRect, subMenuRect] = _ref3;
27
30
  expect(subMenuRect.left).to.be.at.most(menuItemRect.left);
28
31
  expect(subMenuRect.right).to.be.at.least(menuItemRect.right);
29
32
  });
30
33
  });
31
34
  Then('the top of the MenuItem is aligned with the top of the SubMenu wrapper', () => {
32
- cy.getPositionsBySelectors('[data-test="dhis2-uicore-menuitem"]', '[data-test="dhis2-uicore-popper"]').should(([menuItemRect, popperRect]) => {
35
+ cy.getPositionsBySelectors('[data-test="dhis2-uicore-menuitem"]', '[data-test="dhis2-uicore-popper"]').should(_ref4 => {
36
+ let [menuItemRect, popperRect] = _ref4;
33
37
  expect(menuItemRect.top).to.closeTo(popperRect.top, CLOSE_TO_DELTA);
34
38
  });
35
39
  });
@@ -4,14 +4,15 @@ import PropTypes from 'prop-types';
4
4
  import React, { Children, cloneElement, isValidElement, useState } from 'react';
5
5
  import { Menu } from '../index.js';
6
6
 
7
- const FlyoutMenu = ({
8
- children,
9
- className,
10
- dataTest,
11
- dense,
12
- maxHeight,
13
- maxWidth
14
- }) => {
7
+ const FlyoutMenu = _ref => {
8
+ let {
9
+ children,
10
+ className,
11
+ dataTest,
12
+ dense,
13
+ maxHeight,
14
+ maxWidth
15
+ } = _ref;
15
16
  const [openedSubMenu, setOpenedSubMenu] = useState(null);
16
17
 
17
18
  const toggleSubMenu = index => {
@@ -30,7 +31,7 @@ const FlyoutMenu = ({
30
31
  }) : child)), /*#__PURE__*/React.createElement(_JSXStyle, {
31
32
  id: "52281811",
32
33
  dynamic: [colors.white, colors.grey200, elevations.e300, dense ? '128' : '180', maxWidth, maxHeight, spacers.dp4]
33
- }, [`div.__jsx-style-dynamic-selector{background:${colors.white};border:1px solid ${colors.grey200};border-radius:3px;box-shadow:${elevations.e300};display:inline-block;min-width:${dense ? '128' : '180'}px;max-width:${maxWidth};max-height:${maxHeight};padding:${spacers.dp4} 0;}`]));
34
+ }, ["div.__jsx-style-dynamic-selector{background:".concat(colors.white, ";border:1px solid ").concat(colors.grey200, ";border-radius:3px;box-shadow:").concat(elevations.e300, ";display:inline-block;min-width:").concat(dense ? '128' : '180', "px;max-width:").concat(maxWidth, ";max-height:").concat(maxHeight, ";padding:").concat(spacers.dp4, " 0;}")]));
34
35
  };
35
36
 
36
37
  FlyoutMenu.defaultProps = {
@@ -6,26 +6,9 @@ import { Popper } from '@dhis2-ui/popper';
6
6
  import { IconChevronDown16 } from '@dhis2/ui-icons';
7
7
  import React, { useState, useRef } from 'react';
8
8
  import { FlyoutMenu } from './flyout-menu.js';
9
- const description = `
10
- Use menus to provide access to options and actions where space is limited and displaying all the options would be impractical. For example, providing access to a range of actions for every dashboard item displayed. Containing all those actions in menus keeps the page manageable.
11
-
12
- The menu component is flexible in where it can be used and its contents can be flexible too. However, the most common use case is a menu containing menu items.
13
-
14
- Make sure the menu item labels are short and easy to understand. One word is often enough to describe an action or option. Do not use sentences as labels. Some examples of good menu item labels:
15
-
16
- - "Save"
17
- - "Open as map"
18
- - "Export PDF"
19
- - "Duplicate"
20
-
21
- See more about how to use menus at the [design system](https://github.com/dhis2/design-system/blob/master/molecules/menu.md).
22
-
23
- \`\`\`js
24
- import { FlyoutMenu } from 'dhis2/ui'
25
- \`\`\`
26
- `;
9
+ const description = "\nUse menus to provide access to options and actions where space is limited and displaying all the options would be impractical. For example, providing access to a range of actions for every dashboard item displayed. Containing all those actions in menus keeps the page manageable.\n\nThe menu component is flexible in where it can be used and its contents can be flexible too. However, the most common use case is a menu containing menu items.\n\nMake sure the menu item labels are short and easy to understand. One word is often enough to describe an action or option. Do not use sentences as labels. Some examples of good menu item labels:\n\n- \"Save\"\n- \"Open as map\"\n- \"Export PDF\"\n- \"Duplicate\"\n\nSee more about how to use menus at the [design system](https://github.com/dhis2/design-system/blob/master/molecules/menu.md).\n\n```js\nimport { FlyoutMenu } from 'dhis2/ui'\n```\n";
27
10
  export default {
28
- title: 'Actions/Menu/Flyout Menu',
11
+ title: 'Flyout Menu',
29
12
  component: FlyoutMenu,
30
13
  parameters: {
31
14
  docs: {
@@ -77,11 +60,9 @@ export const MaxWidth = args => /*#__PURE__*/React.createElement(React.Fragment,
77
60
  }), /*#__PURE__*/React.createElement(MenuItem, {
78
61
  label: "Item 2 - with a lot of text and using a default maxWidth value of 380px"
79
62
  })), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(FlyoutMenu, args, /*#__PURE__*/React.createElement(MenuItem, {
80
- label: `Item 1 - with a lot of text and using a custom maxWidth value of
81
- ${args.maxWidth}`
63
+ label: "Item 1 - with a lot of text and using a custom maxWidth value of\n ".concat(args.maxWidth)
82
64
  }), /*#__PURE__*/React.createElement(MenuItem, {
83
- label: `Item 2 - with a lot of text and using a custom maxWidth value of
84
- ${args.maxWidth}`
65
+ label: "Item 2 - with a lot of text and using a custom maxWidth value of\n ".concat(args.maxWidth)
85
66
  })));
86
67
  MaxWidth.args = {
87
68
  maxWidth: '300px'
@@ -205,17 +186,18 @@ DropDownMenu.parameters = {
205
186
  export const WithCustomMenuItem = args => {
206
187
  // You should not create custom components in the render cycle
207
188
  // this is just for demo purposes
208
- const PopupWindowMenuItem = ({
209
- to,
210
- children,
211
- ...rest
212
- }) => {
189
+ const PopupWindowMenuItem = _ref => {
190
+ let {
191
+ to,
192
+ children,
193
+ ...rest
194
+ } = _ref;
213
195
  const HEIGHT = 1000;
214
196
  const WIDTH = 1400;
215
197
  const centerY = (window.screen.height - HEIGHT) / 2;
216
198
  const centerX = (window.screen.width - WIDTH) / 2;
217
199
 
218
- const onClick = () => window.open(to, 'Popup', ['menubar=no', 'location=no', 'resizable=no', 'scrollbars=no', 'status=no', `width=${WIDTH}`, `height=${HEIGHT}`, `top=${centerY}`, `left=${centerX}`].join());
200
+ const onClick = () => window.open(to, 'Popup', ['menubar=no', 'location=no', 'resizable=no', 'scrollbars=no', 'status=no', "width=".concat(WIDTH), "height=".concat(HEIGHT), "top=".concat(centerY), "left=".concat(centerX)].join());
219
201
 
220
202
  return /*#__PURE__*/React.createElement(MenuItem, _extends({
221
203
  onClick: onClick,
@@ -2,20 +2,23 @@ import _JSXStyle from "styled-jsx/style";
2
2
  import PropTypes from 'prop-types';
3
3
  import React, { Children, cloneElement, isValidElement } from 'react';
4
4
 
5
- const Menu = ({
6
- children,
7
- className,
8
- dataTest,
9
- dense
10
- }) => /*#__PURE__*/React.createElement("ul", {
11
- "data-test": dataTest,
12
- className: "jsx-3549878755" + " " + (className || "")
13
- }, Children.map(children, (child, index) => /*#__PURE__*/isValidElement(child) ? /*#__PURE__*/cloneElement(child, {
14
- dense: typeof child.props.dense === 'boolean' ? child.props.dense : dense,
15
- hideDivider: typeof child.props.hideDivider !== 'boolean' && index === 0 ? true : child.props.hideDivider
16
- }) : child), /*#__PURE__*/React.createElement(_JSXStyle, {
17
- id: "3549878755"
18
- }, ["ul.jsx-3549878755{display:block;position:relative;width:100%;margin:0;padding:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"]));
5
+ const Menu = _ref => {
6
+ let {
7
+ children,
8
+ className,
9
+ dataTest,
10
+ dense
11
+ } = _ref;
12
+ return /*#__PURE__*/React.createElement("ul", {
13
+ "data-test": dataTest,
14
+ className: "jsx-3549878755" + " " + (className || "")
15
+ }, Children.map(children, (child, index) => /*#__PURE__*/isValidElement(child) ? /*#__PURE__*/cloneElement(child, {
16
+ dense: typeof child.props.dense === 'boolean' ? child.props.dense : dense,
17
+ hideDivider: typeof child.props.hideDivider !== 'boolean' && index === 0 ? true : child.props.hideDivider
18
+ }) : child), /*#__PURE__*/React.createElement(_JSXStyle, {
19
+ id: "3549878755"
20
+ }, ["ul.jsx-3549878755{display:block;position:relative;width:100%;margin:0;padding:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"]));
21
+ };
19
22
 
20
23
  Menu.defaultProps = {
21
24
  dataTest: 'dhis2-uicore-menulist'
@@ -1,26 +1,9 @@
1
1
  import React from 'react';
2
2
  import { MenuItem, MenuSectionHeader } from '../index.js';
3
3
  import { Menu } from './index.js';
4
- const description = `
5
- Use menus to provide access to options and actions where space is limited and displaying all the options would be impractical. For example, providing access to a range of actions for every dashboard item displayed. Containing all those actions in menus keeps the page manageable.
6
-
7
- The menu component is flexible in where it can be used and its contents can be flexible too. However, the most common use case is a menu containing menu items.
8
-
9
- Make sure the menu item labels are short and easy to understand. One word is often enough to describe an action or option. Do not use sentences as labels. Some examples of good menu item labels:
10
-
11
- - "Save"
12
- - "Open as map"
13
- - "Export PDF"
14
- - "Duplicate"
15
-
16
- Typical children are Menu Items, Menu Dividers, and Menu Section Headers.
17
-
18
- \`\`\`js
19
- import { Menu } from '@dhis2/ui'
20
- \`\`\`
21
- `;
4
+ const description = "\nUse menus to provide access to options and actions where space is limited and displaying all the options would be impractical. For example, providing access to a range of actions for every dashboard item displayed. Containing all those actions in menus keeps the page manageable.\n\nThe menu component is flexible in where it can be used and its contents can be flexible too. However, the most common use case is a menu containing menu items.\n\nMake sure the menu item labels are short and easy to understand. One word is often enough to describe an action or option. Do not use sentences as labels. Some examples of good menu item labels:\n\n- \"Save\"\n- \"Open as map\"\n- \"Export PDF\"\n- \"Duplicate\"\n\nTypical children are Menu Items, Menu Dividers, and Menu Section Headers.\n\n```js\nimport { Menu } from '@dhis2/ui'\n```\n";
22
5
  export default {
23
- title: 'Actions/Menu/Menu',
6
+ title: 'Menu',
24
7
  component: Menu,
25
8
  parameters: {
26
9
  docs: {
@@ -4,19 +4,22 @@ import { colors } from '@dhis2/ui-constants';
4
4
  import PropTypes from 'prop-types';
5
5
  import React from 'react';
6
6
 
7
- const MenuDivider = ({
8
- className,
9
- dataTest,
10
- dense
11
- }) => /*#__PURE__*/React.createElement("li", {
12
- "data-test": dataTest,
13
- className: _JSXStyle.dynamic([["591815244", [colors.white]]]) + " " + (className || "")
14
- }, /*#__PURE__*/React.createElement(Divider, {
15
- dense: dense
16
- }), /*#__PURE__*/React.createElement(_JSXStyle, {
17
- id: "591815244",
18
- dynamic: [colors.white]
19
- }, [`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;}`]));
7
+ const MenuDivider = _ref => {
8
+ let {
9
+ className,
10
+ dataTest,
11
+ dense
12
+ } = _ref;
13
+ return /*#__PURE__*/React.createElement("li", {
14
+ "data-test": dataTest,
15
+ className: _JSXStyle.dynamic([["591815244", [colors.white]]]) + " " + (className || "")
16
+ }, /*#__PURE__*/React.createElement(Divider, {
17
+ dense: dense
18
+ }), /*#__PURE__*/React.createElement(_JSXStyle, {
19
+ id: "591815244",
20
+ dynamic: [colors.white]
21
+ }, ["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;}")]));
22
+ };
20
23
 
21
24
  MenuDivider.defaultProps = {
22
25
  dataTest: 'dhis2-uicore-menudivider'
@@ -1,15 +1,9 @@
1
1
  import React from 'react';
2
2
  import { Menu, MenuItem } from '../index.js';
3
3
  import { MenuDivider } from './menu-divider.js';
4
- const description = `
5
- 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 MenuSectionHeader, 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.
6
-
7
- \`\`\`js
8
- import { MenuDivider } from '@dhis2/ui'
9
- \`\`\`
10
- `;
4
+ 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 MenuSectionHeader, 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 { MenuDivider } from '@dhis2/ui'\n```\n";
11
5
  export default {
12
- title: 'Actions/Menu/Menu Divider',
6
+ title: 'Menu Divider',
13
7
  component: MenuDivider,
14
8
  parameters: {
15
9
  docs: {
@@ -10,47 +10,51 @@ import styles from './menu-item.styles.js';
10
10
 
11
11
  const isModifiedEvent = evt => evt.metaKey || evt.altKey || evt.ctrlKey || evt.shiftKey;
12
12
 
13
- const createOnClickHandler = ({
14
- onClick,
15
- toggleSubMenu,
16
- isLink,
17
- value
18
- }) => evt => {
19
- if (isLink && isModifiedEvent(evt) || !(onClick || toggleSubMenu)) {
20
- return;
21
- }
22
-
23
- evt.preventDefault();
24
- evt.stopPropagation();
25
- onClick && onClick({
13
+ const createOnClickHandler = _ref => {
14
+ let {
15
+ onClick,
16
+ toggleSubMenu,
17
+ isLink,
26
18
  value
27
- }, evt);
28
- toggleSubMenu && toggleSubMenu();
19
+ } = _ref;
20
+ return evt => {
21
+ if (isLink && isModifiedEvent(evt) || !(onClick || toggleSubMenu)) {
22
+ return;
23
+ }
24
+
25
+ evt.preventDefault();
26
+ evt.stopPropagation();
27
+ onClick && onClick({
28
+ value
29
+ }, evt);
30
+ toggleSubMenu && toggleSubMenu();
31
+ };
29
32
  };
30
33
 
31
- const MenuItem = ({
32
- href,
33
- onClick,
34
- children,
35
- target,
36
- icon,
37
- className,
38
- destructive,
39
- disabled,
40
- dense,
41
- active,
42
- dataTest,
43
- chevron,
44
- value,
45
- label,
46
- showSubMenu,
47
- toggleSubMenu
48
- }) => {
34
+ const MenuItem = _ref2 => {
35
+ let {
36
+ href,
37
+ onClick,
38
+ children,
39
+ target,
40
+ icon,
41
+ className,
42
+ destructive,
43
+ disabled,
44
+ dense,
45
+ active,
46
+ dataTest,
47
+ chevron,
48
+ value,
49
+ label,
50
+ showSubMenu,
51
+ toggleSubMenu
52
+ } = _ref2;
49
53
  const menuItemRef = useRef();
50
54
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("li", {
51
55
  ref: menuItemRef,
52
56
  "data-test": dataTest,
53
- className: `jsx-${styles.__hash}` + " " + (cx(className, {
57
+ className: "jsx-".concat(styles.__hash) + " " + (cx(className, {
54
58
  destructive,
55
59
  disabled,
56
60
  dense,
@@ -66,13 +70,13 @@ const MenuItem = ({
66
70
  isLink: !!href,
67
71
  value
68
72
  }) : undefined,
69
- className: `jsx-${styles.__hash}`
73
+ className: "jsx-".concat(styles.__hash)
70
74
  }, icon && /*#__PURE__*/React.createElement("span", {
71
- className: `jsx-${styles.__hash}` + " " + "icon"
75
+ className: "jsx-".concat(styles.__hash) + " " + "icon"
72
76
  }, icon), /*#__PURE__*/React.createElement("span", {
73
- className: `jsx-${styles.__hash}` + " " + "label"
77
+ className: "jsx-".concat(styles.__hash) + " " + "label"
74
78
  }, label), (chevron || children) && /*#__PURE__*/React.createElement("span", {
75
- className: `jsx-${styles.__hash}` + " " + "chevron"
79
+ className: "jsx-".concat(styles.__hash) + " " + "chevron"
76
80
  }, /*#__PURE__*/React.createElement(IconChevronRight24, null))), /*#__PURE__*/React.createElement(_JSXStyle, {
77
81
  id: styles.__hash
78
82
  }, styles)), children && showSubMenu && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(Popper, {
@@ -4,21 +4,9 @@ import { IconApps24 } from '@dhis2/ui-icons';
4
4
  import React, { useState } from 'react';
5
5
  import { Menu } from '../index.js';
6
6
  import { MenuItem } from './menu-item.js';
7
- const description = `
8
- Menu Items are intended to be children of Menu and Flyout Menu components. They can be nested to create submenus.
9
-
10
- 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.
11
-
12
- 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.
13
-
14
- See the [design system](https://github.com/dhis2/design-system/blob/master/molecules/menu.md) for more information about menus.
15
-
16
- \`\`\`js
17
- import { MenuItem } from '@dhis2/ui'
18
- \`\`\`
19
- `;
7
+ 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";
20
8
  export default {
21
- title: 'Actions/Menu/Menu Item',
9
+ title: 'Menu Item',
22
10
  component: MenuItem,
23
11
  args: {
24
12
  label: 'Menu item'
@@ -1,4 +1,4 @@
1
1
  import { colors, spacers, theme } from '@dhis2/ui-constants';
2
- const _defaultExport = [`li.jsx-3508410433{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;-webkit-transition:background-color 150ms ease-in-out;transition:background-color 150ms ease-in-out;background-color:${colors.white};color:${colors.grey900};fill:${colors.grey900};font-size:15px;line-height:18px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}`, "li.dense.jsx-3508410433{font-size:14px;line-height:16px;}", `li.jsx-3508410433:hover{background-color:${colors.grey200};}`, `li.jsx-3508410433:active,li.active.jsx-3508410433{background-color:${colors.grey400};}`, `li.destructive.jsx-3508410433{color:${colors.red700};fill:${colors.red600};}`, `li.destructive.jsx-3508410433:hover{background-color:${colors.red050};}`, `li.destructive.jsx-3508410433:active,li.destructive.active.jsx-3508410433{background-color:${colors.red100};}`, `li.disabled.jsx-3508410433{cursor:not-allowed;color:${colors.grey500};fill:${colors.grey500};}`, `li.disabled.jsx-3508410433:hover{background-color:${colors.white};}`, `a.jsx-3508410433{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.dp24};min-height:48px;-webkit-text-decoration:none;text-decoration:none;color:inherit;}`, `a.jsx-3508410433:focus{outline:3px solid ${theme.focus};outline-offset:-3px;}`, "a.jsx-3508410433:focus.jsx-3508410433:not(:focus-visible){outline:none;}", `li.with-chevron.jsx-3508410433 a.jsx-3508410433{padding-right:${spacers.dp8};}`, `li.dense.jsx-3508410433 a.jsx-3508410433{padding:0 ${spacers.dp12};min-height:32px;}`, `li.with-chevron.dense.jsx-3508410433 a.jsx-3508410433{padding-right:${spacers.dp4};}`, ".label.jsx-3508410433{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;padding:15px 0;}", "li.dense.jsx-3508410433 .label.jsx-3508410433{padding:8px 0;}", `.icon.jsx-3508410433{-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;margin-right:${spacers.dp16};width:24px;height:24px;}`, `.chevron.jsx-3508410433{-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;margin-left:${spacers.dp48};}`, `li.dense.jsx-3508410433 .icon.jsx-3508410433{margin-right:${spacers.dp8};width:16px;height:16px;}`, "li.jsx-3508410433 .icon.jsx-3508410433>svg{width:24px;height:24px;}", "li.dense.jsx-3508410433 .icon.jsx-3508410433>svg,li.jsx-3508410433 .chevron.jsx-3508410433>svg{width:16px;height:16px;}"];
2
+ const _defaultExport = ["li.jsx-3508410433{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;-webkit-transition:background-color 150ms ease-in-out;transition:background-color 150ms ease-in-out;background-color:".concat(colors.white, ";color:").concat(colors.grey900, ";fill:").concat(colors.grey900, ";font-size:15px;line-height:18px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"), "li.dense.jsx-3508410433{font-size:14px;line-height:16px;}", "li.jsx-3508410433:hover{background-color:".concat(colors.grey200, ";}"), "li.jsx-3508410433:active,li.active.jsx-3508410433{background-color:".concat(colors.grey400, ";}"), "li.destructive.jsx-3508410433{color:".concat(colors.red700, ";fill:").concat(colors.red600, ";}"), "li.destructive.jsx-3508410433:hover{background-color:".concat(colors.red050, ";}"), "li.destructive.jsx-3508410433:active,li.destructive.active.jsx-3508410433{background-color:".concat(colors.red100, ";}"), "li.disabled.jsx-3508410433{cursor:not-allowed;color:".concat(colors.grey500, ";fill:").concat(colors.grey500, ";}"), "li.disabled.jsx-3508410433:hover{background-color:".concat(colors.white, ";}"), "a.jsx-3508410433{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.dp24, ";min-height:48px;-webkit-text-decoration:none;text-decoration:none;color:inherit;}"), "a.jsx-3508410433:focus{outline:3px solid ".concat(theme.focus, ";outline-offset:-3px;}"), "a.jsx-3508410433:focus.jsx-3508410433:not(:focus-visible){outline:none;}", "li.with-chevron.jsx-3508410433 a.jsx-3508410433{padding-right:".concat(spacers.dp8, ";}"), "li.dense.jsx-3508410433 a.jsx-3508410433{padding:0 ".concat(spacers.dp12, ";min-height:32px;}"), "li.with-chevron.dense.jsx-3508410433 a.jsx-3508410433{padding-right:".concat(spacers.dp4, ";}"), ".label.jsx-3508410433{-webkit-box-flex:1;-webkit-flex-grow:1;-ms-flex-positive:1;flex-grow:1;padding:15px 0;}", "li.dense.jsx-3508410433 .label.jsx-3508410433{padding:8px 0;}", ".icon.jsx-3508410433{-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;margin-right:".concat(spacers.dp16, ";width:24px;height:24px;}"), ".chevron.jsx-3508410433{-webkit-box-flex:0;-webkit-flex-grow:0;-ms-flex-positive:0;flex-grow:0;margin-left:".concat(spacers.dp48, ";}"), "li.dense.jsx-3508410433 .icon.jsx-3508410433{margin-right:".concat(spacers.dp8, ";width:16px;height:16px;}"), "li.jsx-3508410433 .icon.jsx-3508410433>svg{width:24px;height:24px;}", "li.dense.jsx-3508410433 .icon.jsx-3508410433>svg,li.jsx-3508410433 .chevron.jsx-3508410433>svg{width:16px;height:16px;}"];
3
3
  _defaultExport.__hash = "3508410433";
4
4
  export default _defaultExport;
@@ -5,25 +5,28 @@ import cx from 'classnames';
5
5
  import PropTypes from 'prop-types';
6
6
  import React from 'react';
7
7
 
8
- const MenuSectionHeader = ({
9
- className,
10
- dataTest,
11
- dense,
12
- hideDivider,
13
- label
14
- }) => /*#__PURE__*/React.createElement("li", {
15
- "data-test": dataTest,
16
- className: _JSXStyle.dynamic([["954853487", [colors.white, spacers.dp8, spacers.dp24, spacers.dp12, spacers.dp24, colors.grey600, spacers.dp8, spacers.dp12, spacers.dp12]]]) + " " + (cx(className, {
17
- dense
18
- }) || "")
19
- }, !hideDivider && /*#__PURE__*/React.createElement(Divider, {
20
- dense: dense
21
- }), /*#__PURE__*/React.createElement("h6", {
22
- className: _JSXStyle.dynamic([["954853487", [colors.white, spacers.dp8, spacers.dp24, spacers.dp12, spacers.dp24, colors.grey600, spacers.dp8, spacers.dp12, spacers.dp12]]])
23
- }, label), /*#__PURE__*/React.createElement(_JSXStyle, {
24
- id: "954853487",
25
- dynamic: [colors.white, spacers.dp8, spacers.dp24, spacers.dp12, spacers.dp24, colors.grey600, spacers.dp8, spacers.dp12, spacers.dp12]
26
- }, [`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.dp24} ${spacers.dp12} ${spacers.dp24};font-size:15px;line-height:16px;font-weight:500;color:${colors.grey600};}`, `li.dense.__jsx-style-dynamic-selector h6.__jsx-style-dynamic-selector{font-size:14px;line-height:16px;padding:${spacers.dp8} ${spacers.dp12} 6px ${spacers.dp12};}`]));
8
+ const MenuSectionHeader = _ref => {
9
+ let {
10
+ className,
11
+ dataTest,
12
+ dense,
13
+ hideDivider,
14
+ label
15
+ } = _ref;
16
+ return /*#__PURE__*/React.createElement("li", {
17
+ "data-test": dataTest,
18
+ className: _JSXStyle.dynamic([["954853487", [colors.white, spacers.dp8, spacers.dp24, spacers.dp12, spacers.dp24, colors.grey600, spacers.dp8, spacers.dp12, spacers.dp12]]]) + " " + (cx(className, {
19
+ dense
20
+ }) || "")
21
+ }, !hideDivider && /*#__PURE__*/React.createElement(Divider, {
22
+ dense: dense
23
+ }), /*#__PURE__*/React.createElement("h6", {
24
+ className: _JSXStyle.dynamic([["954853487", [colors.white, spacers.dp8, spacers.dp24, spacers.dp12, spacers.dp24, colors.grey600, spacers.dp8, spacers.dp12, spacers.dp12]]])
25
+ }, label), /*#__PURE__*/React.createElement(_JSXStyle, {
26
+ id: "954853487",
27
+ dynamic: [colors.white, spacers.dp8, spacers.dp24, spacers.dp12, spacers.dp24, colors.grey600, spacers.dp8, spacers.dp12, 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.dp24, " ").concat(spacers.dp12, " ").concat(spacers.dp24, ";font-size:15px;line-height:16px;font-weight:500;color:").concat(colors.grey600, ";}"), "li.dense.__jsx-style-dynamic-selector h6.__jsx-style-dynamic-selector{font-size:14px;line-height:16px;padding:".concat(spacers.dp8, " ").concat(spacers.dp12, " 6px ").concat(spacers.dp12, ";}")]));
29
+ };
27
30
 
28
31
  MenuSectionHeader.defaultProps = {
29
32
  dataTest: 'dhis2-uicore-menusectionheader'
@@ -2,15 +2,9 @@ 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 = `
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
- `;
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";
12
6
  export default {
13
- title: 'Actions/Menu/Menu Section Header',
7
+ title: 'Menu Section Header',
14
8
  component: MenuSectionHeader,
15
9
  args: {
16
10
  label: 'Section header'
@@ -24,14 +18,17 @@ export default {
24
18
  }
25
19
  };
26
20
 
27
- const Template = ({
28
- menuArgs,
29
- ...args
30
- }) => /*#__PURE__*/React.createElement(Menu, menuArgs, /*#__PURE__*/React.createElement(MenuItem, {
31
- label: "Menu item above"
32
- }), /*#__PURE__*/React.createElement(MenuSectionHeader, args), /*#__PURE__*/React.createElement(MenuItem, {
33
- label: "Menu item below"
34
- }));
21
+ const Template = _ref => {
22
+ let {
23
+ menuArgs,
24
+ ...args
25
+ } = _ref;
26
+ return /*#__PURE__*/React.createElement(Menu, menuArgs, /*#__PURE__*/React.createElement(MenuItem, {
27
+ label: "Menu item above"
28
+ }), /*#__PURE__*/React.createElement(MenuSectionHeader, args), /*#__PURE__*/React.createElement(MenuItem, {
29
+ label: "Menu item below"
30
+ }));
31
+ };
35
32
 
36
33
  Template.propTypes = {
37
34
  menuArgs: PropTypes.shape()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/menu",
3
- "version": "8.1.10",
3
+ "version": "8.2.1",
4
4
  "description": "UI Menu",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,13 +32,13 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@dhis2/prop-types": "^3.0.0-beta.1",
35
- "@dhis2-ui/card": "8.1.10",
36
- "@dhis2-ui/divider": "8.1.10",
37
- "@dhis2-ui/layer": "8.1.10",
38
- "@dhis2-ui/popper": "8.1.10",
39
- "@dhis2-ui/portal": "8.1.10",
40
- "@dhis2/ui-constants": "8.1.10",
41
- "@dhis2/ui-icons": "8.1.10",
35
+ "@dhis2-ui/card": "8.2.1",
36
+ "@dhis2-ui/divider": "8.2.1",
37
+ "@dhis2-ui/layer": "8.2.1",
38
+ "@dhis2-ui/popper": "8.2.1",
39
+ "@dhis2-ui/portal": "8.2.1",
40
+ "@dhis2/ui-constants": "8.2.1",
41
+ "@dhis2/ui-icons": "8.2.1",
42
42
  "classnames": "^2.3.1",
43
43
  "prop-types": "^15.7.2"
44
44
  },