@targetprocess/menu 12.27.4 → 12.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Menu.jsx CHANGED
@@ -231,7 +231,7 @@ export class Menu extends React.Component {
231
231
  onOuterAction = () => this.props.closeOnOuterAction && this.setOpened(false)
232
232
 
233
233
  prepareTrigger = menuChildren => {
234
- const {isLeftOpen, navigationState} = this.props
234
+ const {isLeftOpen, isAnchoredBottom, navigationState} = this.props
235
235
  const isOpen = this.isControlledMode() ? this.props.open : this.state.open
236
236
  const menuTrigger = menuChildren.find(element => element.type === MenuTrigger)
237
237
  if (!menuTrigger) {
@@ -251,11 +251,11 @@ export class Menu extends React.Component {
251
251
 
252
252
  const trigger = typeof children === 'function' ? children(renderCallbackArgs) : children
253
253
 
254
- const getPopoverPosition =
255
- typeof this.props.getPopoverPosition === 'undefined'
256
- ? hostRect =>
257
- isLeftOpen ? {right: hostRect.width, top: 0} : {left: hostRect.width, top: 0}
258
- : this.props.getPopoverPosition
254
+ const getPopoverPosition = menuGetPosition(
255
+ this.props.getPopoverPosition,
256
+ isLeftOpen,
257
+ isAnchoredBottom
258
+ )
259
259
 
260
260
  return {trigger, getPopoverPosition}
261
261
  }
@@ -277,7 +277,6 @@ export class Menu extends React.Component {
277
277
  inline={this.props.appendInline}
278
278
  relativeToParent={this.props.relativeToParent}
279
279
  getPopoverPosition={getPopoverPosition}
280
- getContainerElement={this.props.getContainerElement}
281
280
  >
282
281
  {trigger}
283
282
  </Popover>
@@ -285,6 +284,19 @@ export class Menu extends React.Component {
285
284
  }
286
285
  }
287
286
 
287
+ export function menuGetPosition(getPopoverPosition, isLeftOpen, isAnchoredBottom) {
288
+ const result =
289
+ typeof getPopoverPosition === 'undefined'
290
+ ? hostRect => {
291
+ if (isAnchoredBottom) {
292
+ return isLeftOpen ? {right: 0, top: hostRect.height} : {left: 0, top: hostRect.height}
293
+ }
294
+ return isLeftOpen ? {right: hostRect.width, top: 0} : {left: hostRect.width, top: 0}
295
+ }
296
+ : getPopoverPosition
297
+ return result
298
+ }
299
+
288
300
  Menu.propTypes = {
289
301
  open: PropTypes.bool,
290
302
  /** Indicates that submenu will be inserted into DOM as siblings to menu trigger */
@@ -303,6 +315,7 @@ Menu.propTypes = {
303
315
  * (This option may override `Trigger` offset option)
304
316
  */
305
317
  isLeftOpen: PropTypes.bool,
318
+ isAnchoredBottom: PropTypes.bool,
306
319
  closeOnOuterAction: PropTypes.bool,
307
320
  /**
308
321
  * Naviagtion` state represent set of characterisics
@@ -321,8 +334,7 @@ Menu.propTypes = {
321
334
  isOpenMenu: PropTypes.bool,
322
335
  currentEvent: PropTypes.string,
323
336
  onChangeMenuState: PropTypes.func
324
- }),
325
- getContainerElement: Popover.propTypes && Popover.propTypes.getContainerElement
337
+ })
326
338
  }
327
339
 
328
340
  Menu.defaultProps = {
@@ -1,9 +1,30 @@
1
1
  /* eslint-env jest */
2
2
  import React from 'react'
3
- import {shallow} from 'enzyme'
3
+ import {shallow, mount} from 'enzyme'
4
4
  import {Menu} from '../index'
5
+ import {menuGetPosition} from '../Menu'
5
6
  import {CaretIcon} from '@targetprocess/icons'
6
7
 
8
+ describe('Menu', () => {
9
+ it('should render trigger', () => {
10
+ const props = {}
11
+ const wrapper = mount(
12
+ <Menu {...props}>
13
+ <Menu.Trigger>
14
+ {({setOpened, isOpen}) => (
15
+ <button className="testTrigger" onClick={() => setOpened(!isOpen)}>
16
+ testButton
17
+ </button>
18
+ )}
19
+ </Menu.Trigger>
20
+ </Menu>
21
+ )
22
+ expect(
23
+ wrapper.containsMatchingElement(<button className="testTrigger">testButton</button>)
24
+ ).toBeTruthy()
25
+ })
26
+ })
27
+
7
28
  describe('MenuItem', () => {
8
29
  it('should render item', () => {
9
30
  const wrapper = shallow(<Menu.Item>Test Menu Item</Menu.Item>)
@@ -94,3 +115,27 @@ describe('MenuSeparator', () => {
94
115
  expect(title.text()).toEqual('test')
95
116
  })
96
117
  })
118
+
119
+ describe('menuGetPosition', () => {
120
+ it('should return getPopoverPosition if getPopoverPosition is provided', () => {
121
+ const getPopoverPosition = 'top'
122
+ const result = menuGetPosition(getPopoverPosition, false, false)
123
+
124
+ expect(result).toBe(getPopoverPosition)
125
+ })
126
+
127
+ test.each([
128
+ [false, false, {left: 222, top: 0}],
129
+ [false, true, {left: 0, top: 111}],
130
+ [true, false, {right: 222, top: 0}],
131
+ [true, true, {right: 0, top: 111}]
132
+ ])(
133
+ 'should return correct value in case of getPopoverPosition is undefiend and isLeftOpen:%s isAnchoredBottom:%s',
134
+ (isLeftOpen, isAnchoredBottom, expected) => {
135
+ const result = menuGetPosition(undefined, isLeftOpen, isAnchoredBottom)
136
+
137
+ const position = result({height: 111, width: 222})
138
+ expect(position).toEqual(expected)
139
+ }
140
+ )
141
+ })
package/dist/menu.es.js CHANGED
@@ -166,8 +166,8 @@ function styleInject(css, ref) {
166
166
  }
167
167
  }
168
168
 
169
- var css = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.menu__menu__12-27-4 {\n -webkit-transition-property: opacity !important;\n transition-property: opacity !important;\n -webkit-transform: none !important;\n transform: none !important;\n padding: 0;\n}\n.menu__item__menu__12-27-4 {\n font-size: var(--FontSizeDefault, 13px);\n position: relative;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px);\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n }\n.menu__item__content__menu__12-27-4 {\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n }\n.menu__item__content--left__menu__12-27-4 {\n padding-left: var(--IconsSizeDefault, 16px);\n }\n.menu__item__menu__12-27-4 .submenu-icon__menu__12-27-4 {\n -webkit-box-flex: 0;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n }\n.menu__item__menu__12-27-4 .submenu-icon--left__menu__12-27-4 {\n margin-right: var(--SpaceS, 8px);\n }\n.menu__item__menu__12-27-4 .submenu-icon--right__menu__12-27-4 {\n margin-left: var(--SpaceS, 8px);\n }\n.menu__item__menu__12-27-4:not(.menu__item--disabled__menu__12-27-4):hover {\n cursor: pointer;\n }\n.menu__item--disabled__menu__12-27-4 {\n opacity: var(--ControlDisabledOpacity, 0.5);\n cursor: not-allowed;\n }\n.menu__item--danger__menu__12-27-4 {\n color: var(--ActionColorDelete, #AE304A);\n }\n.menu__item--danger__menu__12-27-4:not(.menu__item--disabled__menu__12-27-4):hover {\n background-color: var(--ActionBackgroundDelete, #F3E0E4);\n }\n.menu__item--current__menu__12-27-4 {\n background-color: var(--HighlightBlockBackground, #F5F6F6); /* keyboard current background */\n }\n.menu__item--selected__menu__12-27-4:not(.menu__item--danger__menu__12-27-4) {\n background-color: var(--ActionBackgroundSelected, #F1CE4A);\n }\n.menu__item__menu__12-27-4:not(.menu__item--danger__menu__12-27-4):not(.menu__item--disabled__menu__12-27-4):not(.menu__item--selected__menu__12-27-4):hover {\n background-color: var(--ActionBackgroundHover, #F9E9AE);\n }\n.menu__item__menu__12-27-4:last-child {\n border-radius: 0 0 var(--BorderRadiusDefault, 3px) var(--BorderRadiusDefault, 3px);\n }\n.menu__separator__menu__12-27-4 {\n margin: var(--SpaceXS, 4px) 0;\n border-top: solid 1px var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n }\n.menu__separator__title__menu__12-27-4 {\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px) var(--SpaceXS, 4px) var(--SpaceSM, 12px);\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n font-size: var(--FontSizeLabel, 11px);\n line-height: 1.3;\n font-weight: var(--FontWeightSemibold, 600);\n text-transform: uppercase;\n color: var(--FontColorGray, rgba(0, 0, 0, 0.7));\n letter-spacing: 0.4px;\n }\n";
170
- var styles = {"menu":"menu__menu__12-27-4","menu__item":"menu__item__menu__12-27-4","menu__item__content":"menu__item__content__menu__12-27-4","menu__item__content--left":"menu__item__content--left__menu__12-27-4","submenu-icon":"submenu-icon__menu__12-27-4","submenu-icon--left":"submenu-icon--left__menu__12-27-4","submenu-icon--right":"submenu-icon--right__menu__12-27-4","menu__item--disabled":"menu__item--disabled__menu__12-27-4","menu__item--danger":"menu__item--danger__menu__12-27-4","menu__item--current":"menu__item--current__menu__12-27-4","menu__item--selected":"menu__item--selected__menu__12-27-4","menu__separator":"menu__separator__menu__12-27-4","menu__separator__title":"menu__separator__title__menu__12-27-4"};
169
+ var css = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.menu__menu__12-28-0 {\n -webkit-transition-property: opacity !important;\n transition-property: opacity !important;\n -webkit-transform: none !important;\n transform: none !important;\n padding: 0;\n}\n.menu__item__menu__12-28-0 {\n font-size: var(--FontSizeDefault, 13px);\n position: relative;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px);\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n }\n.menu__item__content__menu__12-28-0 {\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n }\n.menu__item__content--left__menu__12-28-0 {\n padding-left: var(--IconsSizeDefault, 16px);\n }\n.menu__item__menu__12-28-0 .submenu-icon__menu__12-28-0 {\n -webkit-box-flex: 0;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n }\n.menu__item__menu__12-28-0 .submenu-icon--left__menu__12-28-0 {\n margin-right: var(--SpaceS, 8px);\n }\n.menu__item__menu__12-28-0 .submenu-icon--right__menu__12-28-0 {\n margin-left: var(--SpaceS, 8px);\n }\n.menu__item__menu__12-28-0:not(.menu__item--disabled__menu__12-28-0):hover {\n cursor: pointer;\n }\n.menu__item--disabled__menu__12-28-0 {\n opacity: var(--ControlDisabledOpacity, 0.5);\n cursor: not-allowed;\n }\n.menu__item--danger__menu__12-28-0 {\n color: var(--ActionColorDelete, #AE304A);\n }\n.menu__item--danger__menu__12-28-0:not(.menu__item--disabled__menu__12-28-0):hover {\n background-color: var(--ActionBackgroundDelete, #F3E0E4);\n }\n.menu__item--current__menu__12-28-0 {\n background-color: var(--HighlightBlockBackground, #F5F6F6); /* keyboard current background */\n }\n.menu__item--selected__menu__12-28-0:not(.menu__item--danger__menu__12-28-0) {\n background-color: var(--ActionBackgroundSelected, #F1CE4A);\n }\n.menu__item__menu__12-28-0:not(.menu__item--danger__menu__12-28-0):not(.menu__item--disabled__menu__12-28-0):not(.menu__item--selected__menu__12-28-0):hover {\n background-color: var(--ActionBackgroundHover, #F9E9AE);\n }\n.menu__item__menu__12-28-0:last-child {\n border-radius: 0 0 var(--BorderRadiusDefault, 3px) var(--BorderRadiusDefault, 3px);\n }\n.menu__separator__menu__12-28-0 {\n margin: var(--SpaceXS, 4px) 0;\n border-top: solid 1px var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n }\n.menu__separator__title__menu__12-28-0 {\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px) var(--SpaceXS, 4px) var(--SpaceSM, 12px);\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n font-size: var(--FontSizeLabel, 11px);\n line-height: 1.3;\n font-weight: var(--FontWeightSemibold, 600);\n text-transform: uppercase;\n color: var(--FontColorGray, rgba(0, 0, 0, 0.7));\n letter-spacing: 0.4px;\n }\n";
170
+ var styles = {"menu":"menu__menu__12-28-0","menu__item":"menu__item__menu__12-28-0","menu__item__content":"menu__item__content__menu__12-28-0","menu__item__content--left":"menu__item__content--left__menu__12-28-0","submenu-icon":"submenu-icon__menu__12-28-0","submenu-icon--left":"submenu-icon--left__menu__12-28-0","submenu-icon--right":"submenu-icon--right__menu__12-28-0","menu__item--disabled":"menu__item--disabled__menu__12-28-0","menu__item--danger":"menu__item--danger__menu__12-28-0","menu__item--current":"menu__item--current__menu__12-28-0","menu__item--selected":"menu__item--selected__menu__12-28-0","menu__separator":"menu__separator__menu__12-28-0","menu__separator__title":"menu__separator__title__menu__12-28-0"};
171
171
  styleInject(css);
172
172
 
173
173
  /**
@@ -389,6 +389,7 @@ var Menu = /*#__PURE__*/function (_React$Component) {
389
389
  _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "prepareTrigger", function (menuChildren) {
390
390
  var _this$props2 = _this.props,
391
391
  isLeftOpen = _this$props2.isLeftOpen,
392
+ isAnchoredBottom = _this$props2.isAnchoredBottom,
392
393
  navigationState = _this$props2.navigationState;
393
394
  var isOpen = _this.isControlledMode() ? _this.props.open : _this.state.open;
394
395
  var menuTrigger = menuChildren.find(function (element) {
@@ -406,15 +407,7 @@ var Menu = /*#__PURE__*/function (_React$Component) {
406
407
  setOpened: _this.setOpened
407
408
  };
408
409
  var trigger = typeof children === 'function' ? children(renderCallbackArgs) : children;
409
- var getPopoverPosition = typeof _this.props.getPopoverPosition === 'undefined' ? function (hostRect) {
410
- return isLeftOpen ? {
411
- right: hostRect.width,
412
- top: 0
413
- } : {
414
- left: hostRect.width,
415
- top: 0
416
- };
417
- } : _this.props.getPopoverPosition;
410
+ var getPopoverPosition = menuGetPosition(_this.props.getPopoverPosition, isLeftOpen, isAnchoredBottom);
418
411
  return {
419
412
  trigger: trigger,
420
413
  getPopoverPosition: getPopoverPosition
@@ -567,13 +560,33 @@ var Menu = /*#__PURE__*/function (_React$Component) {
567
560
  body: renderBody(menuItems),
568
561
  inline: this.props.appendInline,
569
562
  relativeToParent: this.props.relativeToParent,
570
- getPopoverPosition: getPopoverPosition,
571
- getContainerElement: this.props.getContainerElement
563
+ getPopoverPosition: getPopoverPosition
572
564
  }, trigger);
573
565
  }
574
566
  }]);
575
567
  return Menu;
576
568
  }(React.Component);
569
+ function menuGetPosition(getPopoverPosition, isLeftOpen, isAnchoredBottom) {
570
+ var result = typeof getPopoverPosition === 'undefined' ? function (hostRect) {
571
+ if (isAnchoredBottom) {
572
+ return isLeftOpen ? {
573
+ right: 0,
574
+ top: hostRect.height
575
+ } : {
576
+ left: 0,
577
+ top: hostRect.height
578
+ };
579
+ }
580
+ return isLeftOpen ? {
581
+ right: hostRect.width,
582
+ top: 0
583
+ } : {
584
+ left: hostRect.width,
585
+ top: 0
586
+ };
587
+ } : getPopoverPosition;
588
+ return result;
589
+ }
577
590
  Menu.defaultProps = {
578
591
  closeOnOuterAction: true,
579
592
  navigationState: {}
package/dist/menu.js CHANGED
@@ -172,8 +172,8 @@ function styleInject(css, ref) {
172
172
  }
173
173
  }
174
174
 
175
- var css = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.menu__menu__12-27-4 {\n -webkit-transition-property: opacity !important;\n transition-property: opacity !important;\n -webkit-transform: none !important;\n transform: none !important;\n padding: 0;\n}\n.menu__item__menu__12-27-4 {\n font-size: var(--FontSizeDefault, 13px);\n position: relative;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px);\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n }\n.menu__item__content__menu__12-27-4 {\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n }\n.menu__item__content--left__menu__12-27-4 {\n padding-left: var(--IconsSizeDefault, 16px);\n }\n.menu__item__menu__12-27-4 .submenu-icon__menu__12-27-4 {\n -webkit-box-flex: 0;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n }\n.menu__item__menu__12-27-4 .submenu-icon--left__menu__12-27-4 {\n margin-right: var(--SpaceS, 8px);\n }\n.menu__item__menu__12-27-4 .submenu-icon--right__menu__12-27-4 {\n margin-left: var(--SpaceS, 8px);\n }\n.menu__item__menu__12-27-4:not(.menu__item--disabled__menu__12-27-4):hover {\n cursor: pointer;\n }\n.menu__item--disabled__menu__12-27-4 {\n opacity: var(--ControlDisabledOpacity, 0.5);\n cursor: not-allowed;\n }\n.menu__item--danger__menu__12-27-4 {\n color: var(--ActionColorDelete, #AE304A);\n }\n.menu__item--danger__menu__12-27-4:not(.menu__item--disabled__menu__12-27-4):hover {\n background-color: var(--ActionBackgroundDelete, #F3E0E4);\n }\n.menu__item--current__menu__12-27-4 {\n background-color: var(--HighlightBlockBackground, #F5F6F6); /* keyboard current background */\n }\n.menu__item--selected__menu__12-27-4:not(.menu__item--danger__menu__12-27-4) {\n background-color: var(--ActionBackgroundSelected, #F1CE4A);\n }\n.menu__item__menu__12-27-4:not(.menu__item--danger__menu__12-27-4):not(.menu__item--disabled__menu__12-27-4):not(.menu__item--selected__menu__12-27-4):hover {\n background-color: var(--ActionBackgroundHover, #F9E9AE);\n }\n.menu__item__menu__12-27-4:last-child {\n border-radius: 0 0 var(--BorderRadiusDefault, 3px) var(--BorderRadiusDefault, 3px);\n }\n.menu__separator__menu__12-27-4 {\n margin: var(--SpaceXS, 4px) 0;\n border-top: solid 1px var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n }\n.menu__separator__title__menu__12-27-4 {\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px) var(--SpaceXS, 4px) var(--SpaceSM, 12px);\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n font-size: var(--FontSizeLabel, 11px);\n line-height: 1.3;\n font-weight: var(--FontWeightSemibold, 600);\n text-transform: uppercase;\n color: var(--FontColorGray, rgba(0, 0, 0, 0.7));\n letter-spacing: 0.4px;\n }\n";
176
- var styles = {"menu":"menu__menu__12-27-4","menu__item":"menu__item__menu__12-27-4","menu__item__content":"menu__item__content__menu__12-27-4","menu__item__content--left":"menu__item__content--left__menu__12-27-4","submenu-icon":"submenu-icon__menu__12-27-4","submenu-icon--left":"submenu-icon--left__menu__12-27-4","submenu-icon--right":"submenu-icon--right__menu__12-27-4","menu__item--disabled":"menu__item--disabled__menu__12-27-4","menu__item--danger":"menu__item--danger__menu__12-27-4","menu__item--current":"menu__item--current__menu__12-27-4","menu__item--selected":"menu__item--selected__menu__12-27-4","menu__separator":"menu__separator__menu__12-27-4","menu__separator__title":"menu__separator__title__menu__12-27-4"};
175
+ var css = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.menu__menu__12-28-0 {\n -webkit-transition-property: opacity !important;\n transition-property: opacity !important;\n -webkit-transform: none !important;\n transform: none !important;\n padding: 0;\n}\n.menu__item__menu__12-28-0 {\n font-size: var(--FontSizeDefault, 13px);\n position: relative;\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px);\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n }\n.menu__item__content__menu__12-28-0 {\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n -webkit-box-flex: 1;\n -ms-flex: 1 1 auto;\n flex: 1 1 auto;\n }\n.menu__item__content--left__menu__12-28-0 {\n padding-left: var(--IconsSizeDefault, 16px);\n }\n.menu__item__menu__12-28-0 .submenu-icon__menu__12-28-0 {\n -webkit-box-flex: 0;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n }\n.menu__item__menu__12-28-0 .submenu-icon--left__menu__12-28-0 {\n margin-right: var(--SpaceS, 8px);\n }\n.menu__item__menu__12-28-0 .submenu-icon--right__menu__12-28-0 {\n margin-left: var(--SpaceS, 8px);\n }\n.menu__item__menu__12-28-0:not(.menu__item--disabled__menu__12-28-0):hover {\n cursor: pointer;\n }\n.menu__item--disabled__menu__12-28-0 {\n opacity: var(--ControlDisabledOpacity, 0.5);\n cursor: not-allowed;\n }\n.menu__item--danger__menu__12-28-0 {\n color: var(--ActionColorDelete, #AE304A);\n }\n.menu__item--danger__menu__12-28-0:not(.menu__item--disabled__menu__12-28-0):hover {\n background-color: var(--ActionBackgroundDelete, #F3E0E4);\n }\n.menu__item--current__menu__12-28-0 {\n background-color: var(--HighlightBlockBackground, #F5F6F6); /* keyboard current background */\n }\n.menu__item--selected__menu__12-28-0:not(.menu__item--danger__menu__12-28-0) {\n background-color: var(--ActionBackgroundSelected, #F1CE4A);\n }\n.menu__item__menu__12-28-0:not(.menu__item--danger__menu__12-28-0):not(.menu__item--disabled__menu__12-28-0):not(.menu__item--selected__menu__12-28-0):hover {\n background-color: var(--ActionBackgroundHover, #F9E9AE);\n }\n.menu__item__menu__12-28-0:last-child {\n border-radius: 0 0 var(--BorderRadiusDefault, 3px) var(--BorderRadiusDefault, 3px);\n }\n.menu__separator__menu__12-28-0 {\n margin: var(--SpaceXS, 4px) 0;\n border-top: solid 1px var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\n }\n.menu__separator__title__menu__12-28-0 {\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px) var(--SpaceXS, 4px) var(--SpaceSM, 12px);\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n font-size: var(--FontSizeLabel, 11px);\n line-height: 1.3;\n font-weight: var(--FontWeightSemibold, 600);\n text-transform: uppercase;\n color: var(--FontColorGray, rgba(0, 0, 0, 0.7));\n letter-spacing: 0.4px;\n }\n";
176
+ var styles = {"menu":"menu__menu__12-28-0","menu__item":"menu__item__menu__12-28-0","menu__item__content":"menu__item__content__menu__12-28-0","menu__item__content--left":"menu__item__content--left__menu__12-28-0","submenu-icon":"submenu-icon__menu__12-28-0","submenu-icon--left":"submenu-icon--left__menu__12-28-0","submenu-icon--right":"submenu-icon--right__menu__12-28-0","menu__item--disabled":"menu__item--disabled__menu__12-28-0","menu__item--danger":"menu__item--danger__menu__12-28-0","menu__item--current":"menu__item--current__menu__12-28-0","menu__item--selected":"menu__item--selected__menu__12-28-0","menu__separator":"menu__separator__menu__12-28-0","menu__separator__title":"menu__separator__title__menu__12-28-0"};
177
177
  styleInject(css);
178
178
 
179
179
  /**
@@ -395,6 +395,7 @@ var Menu = /*#__PURE__*/function (_React$Component) {
395
395
  _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "prepareTrigger", function (menuChildren) {
396
396
  var _this$props2 = _this.props,
397
397
  isLeftOpen = _this$props2.isLeftOpen,
398
+ isAnchoredBottom = _this$props2.isAnchoredBottom,
398
399
  navigationState = _this$props2.navigationState;
399
400
  var isOpen = _this.isControlledMode() ? _this.props.open : _this.state.open;
400
401
  var menuTrigger = menuChildren.find(function (element) {
@@ -412,15 +413,7 @@ var Menu = /*#__PURE__*/function (_React$Component) {
412
413
  setOpened: _this.setOpened
413
414
  };
414
415
  var trigger = typeof children === 'function' ? children(renderCallbackArgs) : children;
415
- var getPopoverPosition = typeof _this.props.getPopoverPosition === 'undefined' ? function (hostRect) {
416
- return isLeftOpen ? {
417
- right: hostRect.width,
418
- top: 0
419
- } : {
420
- left: hostRect.width,
421
- top: 0
422
- };
423
- } : _this.props.getPopoverPosition;
416
+ var getPopoverPosition = menuGetPosition(_this.props.getPopoverPosition, isLeftOpen, isAnchoredBottom);
424
417
  return {
425
418
  trigger: trigger,
426
419
  getPopoverPosition: getPopoverPosition
@@ -573,13 +566,33 @@ var Menu = /*#__PURE__*/function (_React$Component) {
573
566
  body: renderBody(menuItems),
574
567
  inline: this.props.appendInline,
575
568
  relativeToParent: this.props.relativeToParent,
576
- getPopoverPosition: getPopoverPosition,
577
- getContainerElement: this.props.getContainerElement
569
+ getPopoverPosition: getPopoverPosition
578
570
  }, trigger);
579
571
  }
580
572
  }]);
581
573
  return Menu;
582
574
  }(React.Component);
575
+ function menuGetPosition(getPopoverPosition, isLeftOpen, isAnchoredBottom) {
576
+ var result = typeof getPopoverPosition === 'undefined' ? function (hostRect) {
577
+ if (isAnchoredBottom) {
578
+ return isLeftOpen ? {
579
+ right: 0,
580
+ top: hostRect.height
581
+ } : {
582
+ left: 0,
583
+ top: hostRect.height
584
+ };
585
+ }
586
+ return isLeftOpen ? {
587
+ right: hostRect.width,
588
+ top: 0
589
+ } : {
590
+ left: hostRect.width,
591
+ top: 0
592
+ };
593
+ } : getPopoverPosition;
594
+ return result;
595
+ }
583
596
  Menu.defaultProps = {
584
597
  closeOnOuterAction: true,
585
598
  navigationState: {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@targetprocess/menu",
3
- "version": "12.27.4",
3
+ "version": "12.28.0",
4
4
  "description": "",
5
5
  "main": "dist/menu.js",
6
6
  "module": "dist/menu.es.js",
@@ -10,8 +10,8 @@
10
10
  "prepack": "node -r ../../.ts-node.js ../../config/rollup.config.js ."
11
11
  },
12
12
  "dependencies": {
13
- "@targetprocess/icons": "^12.27.4",
14
- "@targetprocess/popover": "^12.27.4",
13
+ "@targetprocess/icons": "^12.25.4",
14
+ "@targetprocess/popover": "^12.25.4",
15
15
  "classnames": "^2.2.5",
16
16
  "prop-types": "^15.6.0",
17
17
  "react": "^16.7.0",
@@ -21,5 +21,5 @@
21
21
  "access": "public"
22
22
  },
23
23
  "sideEffects": false,
24
- "gitHead": "d651f7c71f39fec22aa1b55b180d62ccdb8a1b21"
24
+ "gitHead": "dcac07e0b38f166a45df5244bbc1161af4d9d1e3"
25
25
  }