@targetprocess/menu 12.20.1-alpha.2 → 12.20.2-alpha.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/CHANGELOG.md +15 -15
- package/Menu.jsx +329 -329
- package/MenuItem.jsx +129 -129
- package/MenuItemWithSubMenu.jsx +139 -139
- package/MenuSeparator.jsx +20 -20
- package/__tests__/Menu.tests.jsx +96 -96
- package/dist/menu.es.js +42 -39
- package/dist/menu.js +42 -39
- package/index.js +15 -12
- package/package.json +4 -4
- package/style/index.css +93 -90
package/__tests__/Menu.tests.jsx
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
/* eslint-env jest */
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import {shallow} from 'enzyme'
|
|
4
|
-
import {Menu} from '../index'
|
|
5
|
-
import {CaretIcon} from '@targetprocess/icons'
|
|
6
|
-
|
|
7
|
-
describe('MenuItem', () => {
|
|
8
|
-
it('should render item', () => {
|
|
9
|
-
const wrapper = shallow(<Menu.Item>Test Menu Item</Menu.Item>)
|
|
10
|
-
|
|
11
|
-
expect(wrapper.hasClass('menu__item menu__item--default')).toBeTruthy()
|
|
12
|
-
expect(wrapper.text()).toEqual('Test Menu Item')
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('should render custom item content correctly', () => {
|
|
16
|
-
const wrapper = shallow(
|
|
17
|
-
<Menu.Item>
|
|
18
|
-
<div className="foo">Bar</div>
|
|
19
|
-
</Menu.Item>
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
const content = wrapper.find('.foo')
|
|
23
|
-
expect(content).toHaveLength(1)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('should render danger item', () => {
|
|
27
|
-
const wrapper = shallow(<Menu.Item type="danger">Test Menu Item</Menu.Item>)
|
|
28
|
-
|
|
29
|
-
expect(wrapper.hasClass('menu__item--danger')).toBeTruthy()
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
it('should render disabled item', () => {
|
|
33
|
-
const wrapper = shallow(<Menu.Item disabled>Test Menu Item</Menu.Item>)
|
|
34
|
-
|
|
35
|
-
expect(wrapper.hasClass('menu__item--disabled')).toBeTruthy()
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('should render selected item', () => {
|
|
39
|
-
const wrapper = shallow(<Menu.Item selected>Test Menu Item</Menu.Item>)
|
|
40
|
-
|
|
41
|
-
expect(wrapper.hasClass('menu__item--selected')).toBeTruthy()
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
it('should render item with left/right arrow icon', () => {
|
|
45
|
-
const wrapperLeftIcon = shallow(
|
|
46
|
-
<Menu.Item isLeftOpen isParent>
|
|
47
|
-
Left Menu Item
|
|
48
|
-
</Menu.Item>
|
|
49
|
-
)
|
|
50
|
-
const wrapperRightIcon = shallow(<Menu.Item isParent>Right Menu Item</Menu.Item>)
|
|
51
|
-
|
|
52
|
-
expect(wrapperLeftIcon.find('.submenu-icon--left').find(CaretIcon)).toHaveLength(1)
|
|
53
|
-
expect(wrapperRightIcon.find('.submenu-icon--right').find(CaretIcon)).toHaveLength(1)
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
it('pass down item click handler', () => {
|
|
57
|
-
const onClickMock = jest.fn()
|
|
58
|
-
const wrapper = shallow(<Menu.Item onClick={onClickMock}>Test Menu Item</Menu.Item>)
|
|
59
|
-
wrapper.simulate('click')
|
|
60
|
-
expect(onClickMock).toHaveBeenCalled()
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
it('activate item by keyboard navigation', () => {
|
|
64
|
-
const wrapper = shallow(
|
|
65
|
-
<Menu.Item navigationState={{isActive: true}}>Test Menu Item</Menu.Item>
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
expect(wrapper.find('.menu__item--selected')).toBeTruthy()
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it('emulate key press `Enter`(for keyboard navigation)', () => {
|
|
72
|
-
const handlePressEnterKey = jest.fn()
|
|
73
|
-
const payload = {foo: 'bar'}
|
|
74
|
-
shallow(
|
|
75
|
-
<Menu.Item
|
|
76
|
-
payload={payload}
|
|
77
|
-
onItemChoosed={handlePressEnterKey}
|
|
78
|
-
navigationState={{isSubmitted: true}}
|
|
79
|
-
>
|
|
80
|
-
Test Menu Item
|
|
81
|
-
</Menu.Item>
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
expect(handlePressEnterKey.mock.calls[0][0]).toMatchObject(payload)
|
|
85
|
-
})
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
describe('MenuSeparator', () => {
|
|
89
|
-
it('should render separator', () => {
|
|
90
|
-
const wrapper = shallow(<Menu.Separator title="test" />)
|
|
91
|
-
const title = wrapper.find('.menu__separator__title')
|
|
92
|
-
|
|
93
|
-
expect(wrapper.hasClass('menu__separator')).toBeTruthy()
|
|
94
|
-
expect(title.text()).toEqual('test')
|
|
95
|
-
})
|
|
96
|
-
})
|
|
1
|
+
/* eslint-env jest */
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import {shallow} from 'enzyme'
|
|
4
|
+
import {Menu} from '../index'
|
|
5
|
+
import {CaretIcon} from '@targetprocess/icons'
|
|
6
|
+
|
|
7
|
+
describe('MenuItem', () => {
|
|
8
|
+
it('should render item', () => {
|
|
9
|
+
const wrapper = shallow(<Menu.Item>Test Menu Item</Menu.Item>)
|
|
10
|
+
|
|
11
|
+
expect(wrapper.hasClass('menu__item menu__item--default')).toBeTruthy()
|
|
12
|
+
expect(wrapper.text()).toEqual('Test Menu Item')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('should render custom item content correctly', () => {
|
|
16
|
+
const wrapper = shallow(
|
|
17
|
+
<Menu.Item>
|
|
18
|
+
<div className="foo">Bar</div>
|
|
19
|
+
</Menu.Item>
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
const content = wrapper.find('.foo')
|
|
23
|
+
expect(content).toHaveLength(1)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('should render danger item', () => {
|
|
27
|
+
const wrapper = shallow(<Menu.Item type="danger">Test Menu Item</Menu.Item>)
|
|
28
|
+
|
|
29
|
+
expect(wrapper.hasClass('menu__item--danger')).toBeTruthy()
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('should render disabled item', () => {
|
|
33
|
+
const wrapper = shallow(<Menu.Item disabled>Test Menu Item</Menu.Item>)
|
|
34
|
+
|
|
35
|
+
expect(wrapper.hasClass('menu__item--disabled')).toBeTruthy()
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it('should render selected item', () => {
|
|
39
|
+
const wrapper = shallow(<Menu.Item selected>Test Menu Item</Menu.Item>)
|
|
40
|
+
|
|
41
|
+
expect(wrapper.hasClass('menu__item--selected')).toBeTruthy()
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('should render item with left/right arrow icon', () => {
|
|
45
|
+
const wrapperLeftIcon = shallow(
|
|
46
|
+
<Menu.Item isLeftOpen isParent>
|
|
47
|
+
Left Menu Item
|
|
48
|
+
</Menu.Item>
|
|
49
|
+
)
|
|
50
|
+
const wrapperRightIcon = shallow(<Menu.Item isParent>Right Menu Item</Menu.Item>)
|
|
51
|
+
|
|
52
|
+
expect(wrapperLeftIcon.find('.submenu-icon--left').find(CaretIcon)).toHaveLength(1)
|
|
53
|
+
expect(wrapperRightIcon.find('.submenu-icon--right').find(CaretIcon)).toHaveLength(1)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('pass down item click handler', () => {
|
|
57
|
+
const onClickMock = jest.fn()
|
|
58
|
+
const wrapper = shallow(<Menu.Item onClick={onClickMock}>Test Menu Item</Menu.Item>)
|
|
59
|
+
wrapper.simulate('click')
|
|
60
|
+
expect(onClickMock).toHaveBeenCalled()
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it('activate item by keyboard navigation', () => {
|
|
64
|
+
const wrapper = shallow(
|
|
65
|
+
<Menu.Item navigationState={{isActive: true}}>Test Menu Item</Menu.Item>
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
expect(wrapper.find('.menu__item--selected')).toBeTruthy()
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('emulate key press `Enter`(for keyboard navigation)', () => {
|
|
72
|
+
const handlePressEnterKey = jest.fn()
|
|
73
|
+
const payload = {foo: 'bar'}
|
|
74
|
+
shallow(
|
|
75
|
+
<Menu.Item
|
|
76
|
+
payload={payload}
|
|
77
|
+
onItemChoosed={handlePressEnterKey}
|
|
78
|
+
navigationState={{isSubmitted: true}}
|
|
79
|
+
>
|
|
80
|
+
Test Menu Item
|
|
81
|
+
</Menu.Item>
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
expect(handlePressEnterKey.mock.calls[0][0]).toMatchObject(payload)
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
describe('MenuSeparator', () => {
|
|
89
|
+
it('should render separator', () => {
|
|
90
|
+
const wrapper = shallow(<Menu.Separator title="test" />)
|
|
91
|
+
const title = wrapper.find('.menu__separator__title')
|
|
92
|
+
|
|
93
|
+
expect(wrapper.hasClass('menu__separator')).toBeTruthy()
|
|
94
|
+
expect(title.text()).toEqual('test')
|
|
95
|
+
})
|
|
96
|
+
})
|
package/dist/menu.es.js
CHANGED
|
@@ -166,15 +166,15 @@ function styleInject(css, ref) {
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
var css = ".menu__menu__12-20-
|
|
170
|
-
var styles = {"menu":"menu__menu__12-20-
|
|
169
|
+
var css = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.menu__menu__12-20-2-alpha-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-20-2-alpha-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-20-2-alpha-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-20-2-alpha-0 {\n padding-left: var(--IconsSizeDefault, 16px);\n }\n.menu__item__menu__12-20-2-alpha-0 .submenu-icon__menu__12-20-2-alpha-0 {\n -webkit-box-flex: 0;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n }\n.menu__item__menu__12-20-2-alpha-0 .submenu-icon--left__menu__12-20-2-alpha-0 {\n margin-right: var(--SpaceS, 8px);\n }\n.menu__item__menu__12-20-2-alpha-0 .submenu-icon--right__menu__12-20-2-alpha-0 {\n margin-left: var(--SpaceS, 8px);\n }\n.menu__item__menu__12-20-2-alpha-0:not(.menu__item--disabled__menu__12-20-2-alpha-0):hover {\n cursor: pointer;\n }\n.menu__item--disabled__menu__12-20-2-alpha-0 {\n opacity: var(--ControlDisabledOpacity, 0.5);\n cursor: not-allowed;\n }\n.menu__item--danger__menu__12-20-2-alpha-0 {\n color: var(--ActionColorDelete, #AE304A);\n }\n.menu__item--danger__menu__12-20-2-alpha-0:not(.menu__item--disabled__menu__12-20-2-alpha-0):hover {\n background-color: var(--ActionBackgroundDelete, #F3E0E4);\n }\n.menu__item--current__menu__12-20-2-alpha-0 {\n background-color: var(--HighlightBlockBackground, #F5F6F6); /* keyboard current background */\n }\n.menu__item--selected__menu__12-20-2-alpha-0:not(.menu__item--danger__menu__12-20-2-alpha-0) {\n background-color: var(--ActionBackgroundSelected, #F1CE4A);\n }\n.menu__item__menu__12-20-2-alpha-0:not(.menu__item--danger__menu__12-20-2-alpha-0):not(.menu__item--disabled__menu__12-20-2-alpha-0):not(.menu__item--selected__menu__12-20-2-alpha-0):hover {\n background-color: var(--ActionBackgroundHover, #F9E9AE);\n }\n.menu__item__menu__12-20-2-alpha-0:last-child {\n border-radius: 0 0 var(--BorderRadiusDefault, 3px) var(--BorderRadiusDefault, 3px);\n }\n.menu__separator__menu__12-20-2-alpha-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-20-2-alpha-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-20-2-alpha-0","menu__item":"menu__item__menu__12-20-2-alpha-0","menu__item__content":"menu__item__content__menu__12-20-2-alpha-0","menu__item__content--left":"menu__item__content--left__menu__12-20-2-alpha-0","submenu-icon":"submenu-icon__menu__12-20-2-alpha-0","submenu-icon--left":"submenu-icon--left__menu__12-20-2-alpha-0","submenu-icon--right":"submenu-icon--right__menu__12-20-2-alpha-0","menu__item--disabled":"menu__item--disabled__menu__12-20-2-alpha-0","menu__item--danger":"menu__item--danger__menu__12-20-2-alpha-0","menu__item--current":"menu__item--current__menu__12-20-2-alpha-0","menu__item--selected":"menu__item--selected__menu__12-20-2-alpha-0","menu__separator":"menu__separator__menu__12-20-2-alpha-0","menu__separator__title":"menu__separator__title__menu__12-20-2-alpha-0"};
|
|
171
171
|
styleInject(css);
|
|
172
172
|
|
|
173
|
-
/**
|
|
174
|
-
* Separator component that adds a horizontal line to the menu.
|
|
175
|
-
* Line is hidden if the separator appears first in menu item list.
|
|
176
|
-
* Optional `title` prop allows to add any text under the horizontal line,
|
|
177
|
-
* or to the top of the list for first item.
|
|
173
|
+
/**
|
|
174
|
+
* Separator component that adds a horizontal line to the menu.
|
|
175
|
+
* Line is hidden if the separator appears first in menu item list.
|
|
176
|
+
* Optional `title` prop allows to add any text under the horizontal line,
|
|
177
|
+
* or to the top of the list for first item.
|
|
178
178
|
*/
|
|
179
179
|
var MenuSeparator = function MenuSeparator(_ref) {
|
|
180
180
|
var title = _ref.title;
|
|
@@ -191,36 +191,36 @@ var MenuItemTypes = {
|
|
|
191
191
|
UNSTYLED: 'unstyled'
|
|
192
192
|
};
|
|
193
193
|
|
|
194
|
-
/**
|
|
195
|
-
* Menu.Item is a single item within the menu.
|
|
196
|
-
* By default, the item is highlighted on hover, single-line and truncates if
|
|
197
|
-
* the text is too long (i.e. has ellipsis).
|
|
198
|
-
*
|
|
199
|
-
* It is possible to pass any kind of content to the item.
|
|
200
|
-
* If you wish to make an item with icon, don't forget to add appropriate padding
|
|
201
|
-
* and wrap your text in a container with `text-overflow: ellipsis` and `overflow: hidden`:
|
|
202
|
-
*
|
|
203
|
-
* ```jsx
|
|
204
|
-
* <MenuItem type="danger">
|
|
205
|
-
* <div style={{paddingRight: 8}}><TrashIcon color="red" /></div>
|
|
206
|
-
* <div style={{textOverflow: 'ellipsis', overflow: 'hidden'}}>Delete</div>
|
|
207
|
-
* </MenuItem>
|
|
208
|
-
* ```
|
|
209
|
-
*
|
|
210
|
-
* `isParent` adds a caret icon to the end of your item to indicate that it potentially
|
|
211
|
-
* has a submenu.
|
|
212
|
-
*
|
|
213
|
-
* There is also special `type` value `unstyled`. Unstyled `MenuItem`s don't get any
|
|
214
|
-
* styles on hover, ellipsis or anything else, and you're free to style them as you wish.
|
|
215
|
-
* All other modifiers (`disabled`, `isParent`) are ignored with `type="unstyled"`.
|
|
216
|
-
*
|
|
217
|
-
* ```jsx
|
|
218
|
-
* <MenuItem type="unstyled">
|
|
219
|
-
* <div>Anything can be here.</div>
|
|
220
|
-
* <MenuHelpIcon />
|
|
221
|
-
* <p>You can even have paragraphs inside a menu item.</p>
|
|
222
|
-
* </MenuItem>
|
|
223
|
-
* ```
|
|
194
|
+
/**
|
|
195
|
+
* Menu.Item is a single item within the menu.
|
|
196
|
+
* By default, the item is highlighted on hover, single-line and truncates if
|
|
197
|
+
* the text is too long (i.e. has ellipsis).
|
|
198
|
+
*
|
|
199
|
+
* It is possible to pass any kind of content to the item.
|
|
200
|
+
* If you wish to make an item with icon, don't forget to add appropriate padding
|
|
201
|
+
* and wrap your text in a container with `text-overflow: ellipsis` and `overflow: hidden`:
|
|
202
|
+
*
|
|
203
|
+
* ```jsx
|
|
204
|
+
* <MenuItem type="danger">
|
|
205
|
+
* <div style={{paddingRight: 8}}><TrashIcon color="red" /></div>
|
|
206
|
+
* <div style={{textOverflow: 'ellipsis', overflow: 'hidden'}}>Delete</div>
|
|
207
|
+
* </MenuItem>
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* `isParent` adds a caret icon to the end of your item to indicate that it potentially
|
|
211
|
+
* has a submenu.
|
|
212
|
+
*
|
|
213
|
+
* There is also special `type` value `unstyled`. Unstyled `MenuItem`s don't get any
|
|
214
|
+
* styles on hover, ellipsis or anything else, and you're free to style them as you wish.
|
|
215
|
+
* All other modifiers (`disabled`, `isParent`) are ignored with `type="unstyled"`.
|
|
216
|
+
*
|
|
217
|
+
* ```jsx
|
|
218
|
+
* <MenuItem type="unstyled">
|
|
219
|
+
* <div>Anything can be here.</div>
|
|
220
|
+
* <MenuHelpIcon />
|
|
221
|
+
* <p>You can even have paragraphs inside a menu item.</p>
|
|
222
|
+
* </MenuItem>
|
|
223
|
+
* ```
|
|
224
224
|
*/
|
|
225
225
|
|
|
226
226
|
var MenuItem = function MenuItem(_ref) {
|
|
@@ -509,8 +509,8 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
509
509
|
return _this;
|
|
510
510
|
}
|
|
511
511
|
|
|
512
|
-
/**
|
|
513
|
-
* LifeCycle Methods
|
|
512
|
+
/**
|
|
513
|
+
* LifeCycle Methods
|
|
514
514
|
*/
|
|
515
515
|
_createClass(Menu, [{
|
|
516
516
|
key: "componentDidMount",
|
|
@@ -663,6 +663,9 @@ var MenuItemWithSubMenu = function MenuItemWithSubMenu(_ref) {
|
|
|
663
663
|
}), assignKeys(menuItems));
|
|
664
664
|
};
|
|
665
665
|
|
|
666
|
+
/*********************************************************************
|
|
667
|
+
* © Copyright IBM Corp. 2024
|
|
668
|
+
*********************************************************************/
|
|
666
669
|
Menu.Item = MenuItem;
|
|
667
670
|
Menu.Trigger = MenuTrigger;
|
|
668
671
|
Menu.Separator = MenuSeparator;
|
package/dist/menu.js
CHANGED
|
@@ -172,15 +172,15 @@ function styleInject(css, ref) {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
var css = ".menu__menu__12-20-
|
|
176
|
-
var styles = {"menu":"menu__menu__12-20-
|
|
175
|
+
var css = "/*********************************************************************\n* © Copyright IBM Corp. 2024\n*********************************************************************/\n.menu__menu__12-20-2-alpha-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-20-2-alpha-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-20-2-alpha-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-20-2-alpha-0 {\n padding-left: var(--IconsSizeDefault, 16px);\n }\n.menu__item__menu__12-20-2-alpha-0 .submenu-icon__menu__12-20-2-alpha-0 {\n -webkit-box-flex: 0;\n -ms-flex: 0 0 auto;\n flex: 0 0 auto;\n }\n.menu__item__menu__12-20-2-alpha-0 .submenu-icon--left__menu__12-20-2-alpha-0 {\n margin-right: var(--SpaceS, 8px);\n }\n.menu__item__menu__12-20-2-alpha-0 .submenu-icon--right__menu__12-20-2-alpha-0 {\n margin-left: var(--SpaceS, 8px);\n }\n.menu__item__menu__12-20-2-alpha-0:not(.menu__item--disabled__menu__12-20-2-alpha-0):hover {\n cursor: pointer;\n }\n.menu__item--disabled__menu__12-20-2-alpha-0 {\n opacity: var(--ControlDisabledOpacity, 0.5);\n cursor: not-allowed;\n }\n.menu__item--danger__menu__12-20-2-alpha-0 {\n color: var(--ActionColorDelete, #AE304A);\n }\n.menu__item--danger__menu__12-20-2-alpha-0:not(.menu__item--disabled__menu__12-20-2-alpha-0):hover {\n background-color: var(--ActionBackgroundDelete, #F3E0E4);\n }\n.menu__item--current__menu__12-20-2-alpha-0 {\n background-color: var(--HighlightBlockBackground, #F5F6F6); /* keyboard current background */\n }\n.menu__item--selected__menu__12-20-2-alpha-0:not(.menu__item--danger__menu__12-20-2-alpha-0) {\n background-color: var(--ActionBackgroundSelected, #F1CE4A);\n }\n.menu__item__menu__12-20-2-alpha-0:not(.menu__item--danger__menu__12-20-2-alpha-0):not(.menu__item--disabled__menu__12-20-2-alpha-0):not(.menu__item--selected__menu__12-20-2-alpha-0):hover {\n background-color: var(--ActionBackgroundHover, #F9E9AE);\n }\n.menu__item__menu__12-20-2-alpha-0:last-child {\n border-radius: 0 0 var(--BorderRadiusDefault, 3px) var(--BorderRadiusDefault, 3px);\n }\n.menu__separator__menu__12-20-2-alpha-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-20-2-alpha-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-20-2-alpha-0","menu__item":"menu__item__menu__12-20-2-alpha-0","menu__item__content":"menu__item__content__menu__12-20-2-alpha-0","menu__item__content--left":"menu__item__content--left__menu__12-20-2-alpha-0","submenu-icon":"submenu-icon__menu__12-20-2-alpha-0","submenu-icon--left":"submenu-icon--left__menu__12-20-2-alpha-0","submenu-icon--right":"submenu-icon--right__menu__12-20-2-alpha-0","menu__item--disabled":"menu__item--disabled__menu__12-20-2-alpha-0","menu__item--danger":"menu__item--danger__menu__12-20-2-alpha-0","menu__item--current":"menu__item--current__menu__12-20-2-alpha-0","menu__item--selected":"menu__item--selected__menu__12-20-2-alpha-0","menu__separator":"menu__separator__menu__12-20-2-alpha-0","menu__separator__title":"menu__separator__title__menu__12-20-2-alpha-0"};
|
|
177
177
|
styleInject(css);
|
|
178
178
|
|
|
179
|
-
/**
|
|
180
|
-
* Separator component that adds a horizontal line to the menu.
|
|
181
|
-
* Line is hidden if the separator appears first in menu item list.
|
|
182
|
-
* Optional `title` prop allows to add any text under the horizontal line,
|
|
183
|
-
* or to the top of the list for first item.
|
|
179
|
+
/**
|
|
180
|
+
* Separator component that adds a horizontal line to the menu.
|
|
181
|
+
* Line is hidden if the separator appears first in menu item list.
|
|
182
|
+
* Optional `title` prop allows to add any text under the horizontal line,
|
|
183
|
+
* or to the top of the list for first item.
|
|
184
184
|
*/
|
|
185
185
|
var MenuSeparator = function MenuSeparator(_ref) {
|
|
186
186
|
var title = _ref.title;
|
|
@@ -197,36 +197,36 @@ var MenuItemTypes = {
|
|
|
197
197
|
UNSTYLED: 'unstyled'
|
|
198
198
|
};
|
|
199
199
|
|
|
200
|
-
/**
|
|
201
|
-
* Menu.Item is a single item within the menu.
|
|
202
|
-
* By default, the item is highlighted on hover, single-line and truncates if
|
|
203
|
-
* the text is too long (i.e. has ellipsis).
|
|
204
|
-
*
|
|
205
|
-
* It is possible to pass any kind of content to the item.
|
|
206
|
-
* If you wish to make an item with icon, don't forget to add appropriate padding
|
|
207
|
-
* and wrap your text in a container with `text-overflow: ellipsis` and `overflow: hidden`:
|
|
208
|
-
*
|
|
209
|
-
* ```jsx
|
|
210
|
-
* <MenuItem type="danger">
|
|
211
|
-
* <div style={{paddingRight: 8}}><TrashIcon color="red" /></div>
|
|
212
|
-
* <div style={{textOverflow: 'ellipsis', overflow: 'hidden'}}>Delete</div>
|
|
213
|
-
* </MenuItem>
|
|
214
|
-
* ```
|
|
215
|
-
*
|
|
216
|
-
* `isParent` adds a caret icon to the end of your item to indicate that it potentially
|
|
217
|
-
* has a submenu.
|
|
218
|
-
*
|
|
219
|
-
* There is also special `type` value `unstyled`. Unstyled `MenuItem`s don't get any
|
|
220
|
-
* styles on hover, ellipsis or anything else, and you're free to style them as you wish.
|
|
221
|
-
* All other modifiers (`disabled`, `isParent`) are ignored with `type="unstyled"`.
|
|
222
|
-
*
|
|
223
|
-
* ```jsx
|
|
224
|
-
* <MenuItem type="unstyled">
|
|
225
|
-
* <div>Anything can be here.</div>
|
|
226
|
-
* <MenuHelpIcon />
|
|
227
|
-
* <p>You can even have paragraphs inside a menu item.</p>
|
|
228
|
-
* </MenuItem>
|
|
229
|
-
* ```
|
|
200
|
+
/**
|
|
201
|
+
* Menu.Item is a single item within the menu.
|
|
202
|
+
* By default, the item is highlighted on hover, single-line and truncates if
|
|
203
|
+
* the text is too long (i.e. has ellipsis).
|
|
204
|
+
*
|
|
205
|
+
* It is possible to pass any kind of content to the item.
|
|
206
|
+
* If you wish to make an item with icon, don't forget to add appropriate padding
|
|
207
|
+
* and wrap your text in a container with `text-overflow: ellipsis` and `overflow: hidden`:
|
|
208
|
+
*
|
|
209
|
+
* ```jsx
|
|
210
|
+
* <MenuItem type="danger">
|
|
211
|
+
* <div style={{paddingRight: 8}}><TrashIcon color="red" /></div>
|
|
212
|
+
* <div style={{textOverflow: 'ellipsis', overflow: 'hidden'}}>Delete</div>
|
|
213
|
+
* </MenuItem>
|
|
214
|
+
* ```
|
|
215
|
+
*
|
|
216
|
+
* `isParent` adds a caret icon to the end of your item to indicate that it potentially
|
|
217
|
+
* has a submenu.
|
|
218
|
+
*
|
|
219
|
+
* There is also special `type` value `unstyled`. Unstyled `MenuItem`s don't get any
|
|
220
|
+
* styles on hover, ellipsis or anything else, and you're free to style them as you wish.
|
|
221
|
+
* All other modifiers (`disabled`, `isParent`) are ignored with `type="unstyled"`.
|
|
222
|
+
*
|
|
223
|
+
* ```jsx
|
|
224
|
+
* <MenuItem type="unstyled">
|
|
225
|
+
* <div>Anything can be here.</div>
|
|
226
|
+
* <MenuHelpIcon />
|
|
227
|
+
* <p>You can even have paragraphs inside a menu item.</p>
|
|
228
|
+
* </MenuItem>
|
|
229
|
+
* ```
|
|
230
230
|
*/
|
|
231
231
|
|
|
232
232
|
var MenuItem = function MenuItem(_ref) {
|
|
@@ -515,8 +515,8 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
515
515
|
return _this;
|
|
516
516
|
}
|
|
517
517
|
|
|
518
|
-
/**
|
|
519
|
-
* LifeCycle Methods
|
|
518
|
+
/**
|
|
519
|
+
* LifeCycle Methods
|
|
520
520
|
*/
|
|
521
521
|
_createClass(Menu, [{
|
|
522
522
|
key: "componentDidMount",
|
|
@@ -669,6 +669,9 @@ var MenuItemWithSubMenu = function MenuItemWithSubMenu(_ref) {
|
|
|
669
669
|
}), assignKeys(menuItems));
|
|
670
670
|
};
|
|
671
671
|
|
|
672
|
+
/*********************************************************************
|
|
673
|
+
* © Copyright IBM Corp. 2024
|
|
674
|
+
*********************************************************************/
|
|
672
675
|
Menu.Item = MenuItem;
|
|
673
676
|
Menu.Trigger = MenuTrigger;
|
|
674
677
|
Menu.Separator = MenuSeparator;
|
package/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Menu.
|
|
10
|
-
Menu.
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
/*********************************************************************
|
|
2
|
+
* © Copyright IBM Corp. 2024
|
|
3
|
+
*********************************************************************/
|
|
4
|
+
import {Menu, MenuTrigger} from './Menu'
|
|
5
|
+
import {MenuItem} from './MenuItem'
|
|
6
|
+
import {MenuSeparator} from './MenuSeparator'
|
|
7
|
+
import {SubMenu, MenuItemWithSubMenu} from './MenuItemWithSubMenu'
|
|
8
|
+
|
|
9
|
+
Menu.Item = MenuItem
|
|
10
|
+
Menu.Trigger = MenuTrigger
|
|
11
|
+
Menu.Separator = MenuSeparator
|
|
12
|
+
Menu.SubMenu = SubMenu
|
|
13
|
+
Menu.ItemWithSubMenu = MenuItemWithSubMenu
|
|
14
|
+
|
|
15
|
+
export {Menu, MenuTrigger, MenuItem, MenuSeparator, SubMenu, MenuItemWithSubMenu}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@targetprocess/menu",
|
|
3
|
-
"version": "12.20.
|
|
3
|
+
"version": "12.20.2-alpha.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.20.
|
|
14
|
-
"@targetprocess/popover": "^12.20.
|
|
13
|
+
"@targetprocess/icons": "^12.20.2-alpha.0",
|
|
14
|
+
"@targetprocess/popover": "^12.20.2-alpha.0",
|
|
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": "
|
|
24
|
+
"gitHead": "58801cfa426dcee4f34922ebc0e9cfa8fbd52735"
|
|
25
25
|
}
|