@targetprocess/menu 12.18.1 → 12.18.2-alpha.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.
- package/dist/menu.es.js +69 -126
- package/dist/menu.js +69 -126
- package/package.json +4 -4
package/dist/menu.es.js
CHANGED
|
@@ -9,24 +9,25 @@ function _classCallCheck(instance, Constructor) {
|
|
|
9
9
|
throw new TypeError("Cannot call a class as a function");
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
|
|
13
12
|
function _defineProperties(target, props) {
|
|
14
13
|
for (var i = 0; i < props.length; i++) {
|
|
15
14
|
var descriptor = props[i];
|
|
16
15
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
17
16
|
descriptor.configurable = true;
|
|
18
17
|
if ("value" in descriptor) descriptor.writable = true;
|
|
19
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
18
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
24
22
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
25
23
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
24
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
25
|
+
writable: false
|
|
26
|
+
});
|
|
26
27
|
return Constructor;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
29
|
function _defineProperty(obj, key, value) {
|
|
30
|
+
key = _toPropertyKey(key);
|
|
30
31
|
if (key in obj) {
|
|
31
32
|
Object.defineProperty(obj, key, {
|
|
32
33
|
value: value,
|
|
@@ -37,33 +38,26 @@ function _defineProperty(obj, key, value) {
|
|
|
37
38
|
} else {
|
|
38
39
|
obj[key] = value;
|
|
39
40
|
}
|
|
40
|
-
|
|
41
41
|
return obj;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
43
|
function _extends() {
|
|
45
|
-
_extends = Object.assign
|
|
44
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
46
45
|
for (var i = 1; i < arguments.length; i++) {
|
|
47
46
|
var source = arguments[i];
|
|
48
|
-
|
|
49
47
|
for (var key in source) {
|
|
50
48
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
51
49
|
target[key] = source[key];
|
|
52
50
|
}
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
|
-
|
|
56
53
|
return target;
|
|
57
54
|
};
|
|
58
|
-
|
|
59
55
|
return _extends.apply(this, arguments);
|
|
60
56
|
}
|
|
61
|
-
|
|
62
57
|
function _inherits(subClass, superClass) {
|
|
63
58
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
64
59
|
throw new TypeError("Super expression must either be null or a function");
|
|
65
60
|
}
|
|
66
|
-
|
|
67
61
|
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
68
62
|
constructor: {
|
|
69
63
|
value: subClass,
|
|
@@ -71,50 +65,42 @@ function _inherits(subClass, superClass) {
|
|
|
71
65
|
configurable: true
|
|
72
66
|
}
|
|
73
67
|
});
|
|
68
|
+
Object.defineProperty(subClass, "prototype", {
|
|
69
|
+
writable: false
|
|
70
|
+
});
|
|
74
71
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
75
72
|
}
|
|
76
|
-
|
|
77
73
|
function _getPrototypeOf(o) {
|
|
78
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
74
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
79
75
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
80
76
|
};
|
|
81
77
|
return _getPrototypeOf(o);
|
|
82
78
|
}
|
|
83
|
-
|
|
84
79
|
function _setPrototypeOf(o, p) {
|
|
85
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
80
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
86
81
|
o.__proto__ = p;
|
|
87
82
|
return o;
|
|
88
83
|
};
|
|
89
|
-
|
|
90
84
|
return _setPrototypeOf(o, p);
|
|
91
85
|
}
|
|
92
|
-
|
|
93
86
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
94
87
|
if (source == null) return {};
|
|
95
88
|
var target = {};
|
|
96
89
|
var sourceKeys = Object.keys(source);
|
|
97
90
|
var key, i;
|
|
98
|
-
|
|
99
91
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
100
92
|
key = sourceKeys[i];
|
|
101
93
|
if (excluded.indexOf(key) >= 0) continue;
|
|
102
94
|
target[key] = source[key];
|
|
103
95
|
}
|
|
104
|
-
|
|
105
96
|
return target;
|
|
106
97
|
}
|
|
107
|
-
|
|
108
98
|
function _objectWithoutProperties(source, excluded) {
|
|
109
99
|
if (source == null) return {};
|
|
110
|
-
|
|
111
100
|
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
112
|
-
|
|
113
101
|
var key, i;
|
|
114
|
-
|
|
115
102
|
if (Object.getOwnPropertySymbols) {
|
|
116
103
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
117
|
-
|
|
118
104
|
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
119
105
|
key = sourceSymbolKeys[i];
|
|
120
106
|
if (excluded.indexOf(key) >= 0) continue;
|
|
@@ -122,25 +108,36 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
122
108
|
target[key] = source[key];
|
|
123
109
|
}
|
|
124
110
|
}
|
|
125
|
-
|
|
126
111
|
return target;
|
|
127
112
|
}
|
|
128
|
-
|
|
129
113
|
function _assertThisInitialized(self) {
|
|
130
114
|
if (self === void 0) {
|
|
131
115
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
132
116
|
}
|
|
133
|
-
|
|
134
117
|
return self;
|
|
135
118
|
}
|
|
136
|
-
|
|
137
119
|
function _possibleConstructorReturn(self, call) {
|
|
138
120
|
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
139
121
|
return call;
|
|
122
|
+
} else if (call !== void 0) {
|
|
123
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
140
124
|
}
|
|
141
|
-
|
|
142
125
|
return _assertThisInitialized(self);
|
|
143
126
|
}
|
|
127
|
+
function _toPrimitive(input, hint) {
|
|
128
|
+
if (typeof input !== "object" || input === null) return input;
|
|
129
|
+
var prim = input[Symbol.toPrimitive];
|
|
130
|
+
if (prim !== undefined) {
|
|
131
|
+
var res = prim.call(input, hint || "default");
|
|
132
|
+
if (typeof res !== "object") return res;
|
|
133
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
134
|
+
}
|
|
135
|
+
return (hint === "string" ? String : Number)(input);
|
|
136
|
+
}
|
|
137
|
+
function _toPropertyKey(arg) {
|
|
138
|
+
var key = _toPrimitive(arg, "string");
|
|
139
|
+
return typeof key === "symbol" ? key : String(key);
|
|
140
|
+
}
|
|
144
141
|
|
|
145
142
|
function styleInject(css, ref) {
|
|
146
143
|
if ( ref === void 0 ) ref = {};
|
|
@@ -169,8 +166,8 @@ function styleInject(css, ref) {
|
|
|
169
166
|
}
|
|
170
167
|
}
|
|
171
168
|
|
|
172
|
-
var css = ".menu__menu__12-18-1 {\r\n -webkit-transition-property: opacity !important;\r\n transition-property: opacity !important;\r\n -webkit-transform: none !important;\r\n transform: none !important;\r\n padding: 0;\r\n}\r\n\r\n .menu__item__menu__12-18-1 {\r\n font-size: var(--FontSizeDefault, 13px);\r\n position: relative;\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px);\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n }\r\n\r\n .menu__item__content__menu__12-18-1 {\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n -webkit-box-flex: 1;\r\n -ms-flex: 1 1 auto;\r\n flex: 1 1 auto;\r\n }\r\n\r\n .menu__item__content--left__menu__12-18-1 {\r\n padding-left: var(--IconsSizeDefault, 16px);\r\n }\r\n\r\n .menu__item__menu__12-18-1 .submenu-icon__menu__12-18-1 {\r\n -webkit-box-flex: 0;\r\n -ms-flex: 0 0 auto;\r\n flex: 0 0 auto;\r\n }\r\n\r\n .menu__item__menu__12-18-1 .submenu-icon--left__menu__12-18-1 {\r\n margin-right: var(--SpaceS, 8px);\r\n }\r\n\r\n .menu__item__menu__12-18-1 .submenu-icon--right__menu__12-18-1 {\r\n margin-left: var(--SpaceS, 8px);\r\n }\r\n\r\n .menu__item__menu__12-18-1:not(.menu__item--disabled__menu__12-18-1):hover {\r\n cursor: pointer;\r\n }\r\n\r\n .menu__item--disabled__menu__12-18-1 {\r\n opacity: var(--ControlDisabledOpacity, 0.5);\r\n cursor: not-allowed;\r\n }\r\n\r\n .menu__item--danger__menu__12-18-1 {\r\n color: var(--ActionColorDelete, #AE304A);\r\n }\r\n\r\n .menu__item--danger__menu__12-18-1:not(.menu__item--disabled__menu__12-18-1):hover {\r\n background-color: var(--ActionBackgroundDelete, #F3E0E4);\r\n }\r\n\r\n .menu__item--current__menu__12-18-1 {\r\n background-color: var(--HighlightBlockBackground, #F5F6F6); /* keyboard current background */\r\n }\r\n\r\n .menu__item--selected__menu__12-18-1:not(.menu__item--danger__menu__12-18-1) {\r\n background-color: var(--ActionBackgroundSelected, #F1CE4A);\r\n }\r\n\r\n .menu__item__menu__12-18-1:not(.menu__item--danger__menu__12-18-1):not(.menu__item--disabled__menu__12-18-1):not(.menu__item--selected__menu__12-18-1):hover {\r\n background-color: var(--ActionBackgroundHover, #F9E9AE);\r\n }\r\n\r\n .menu__item__menu__12-18-1:last-child {\r\n border-radius: 0 0 var(--BorderRadiusDefault, 3px) var(--BorderRadiusDefault, 3px);\r\n }\r\n\r\n .menu__separator__menu__12-18-1 {\r\n margin: var(--SpaceXS, 4px) 0;\r\n border-top: solid 1px var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n }\r\n\r\n .menu__separator__title__menu__12-18-1 {\r\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px) var(--SpaceXS, 4px) var(--SpaceSM, 12px);\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n font-size: var(--FontSizeLabel, 11px);\r\n line-height: 1.3;\r\n font-weight: var(--FontWeightSemibold, 600);\r\n text-transform: uppercase;\r\n color: var(--FontColorGray, rgba(0, 0, 0, 0.7));\r\n letter-spacing: 0.4px;\r\n }\r\n";
|
|
173
|
-
var styles = {"menu":"menu__menu__12-18-1","menu__item":"menu__item__menu__12-18-1","menu__item__content":"menu__item__content__menu__12-18-1","menu__item__content--left":"menu__item__content--left__menu__12-18-1","submenu-icon":"submenu-icon__menu__12-18-1","submenu-icon--left":"submenu-icon--left__menu__12-18-1","submenu-icon--right":"submenu-icon--right__menu__12-18-1","menu__item--disabled":"menu__item--disabled__menu__12-18-1","menu__item--danger":"menu__item--danger__menu__12-18-1","menu__item--current":"menu__item--current__menu__12-18-1","menu__item--selected":"menu__item--selected__menu__12-18-1","menu__separator":"menu__separator__menu__12-18-1","menu__separator__title":"menu__separator__title__menu__12-18-1"};
|
|
169
|
+
var css = ".menu__menu__12-18-2-alpha-1 {\r\n -webkit-transition-property: opacity !important;\r\n transition-property: opacity !important;\r\n -webkit-transform: none !important;\r\n transform: none !important;\r\n padding: 0;\r\n}\r\n\r\n .menu__item__menu__12-18-2-alpha-1 {\r\n font-size: var(--FontSizeDefault, 13px);\r\n position: relative;\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px);\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n }\r\n\r\n .menu__item__content__menu__12-18-2-alpha-1 {\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n -webkit-box-flex: 1;\r\n -ms-flex: 1 1 auto;\r\n flex: 1 1 auto;\r\n }\r\n\r\n .menu__item__content--left__menu__12-18-2-alpha-1 {\r\n padding-left: var(--IconsSizeDefault, 16px);\r\n }\r\n\r\n .menu__item__menu__12-18-2-alpha-1 .submenu-icon__menu__12-18-2-alpha-1 {\r\n -webkit-box-flex: 0;\r\n -ms-flex: 0 0 auto;\r\n flex: 0 0 auto;\r\n }\r\n\r\n .menu__item__menu__12-18-2-alpha-1 .submenu-icon--left__menu__12-18-2-alpha-1 {\r\n margin-right: var(--SpaceS, 8px);\r\n }\r\n\r\n .menu__item__menu__12-18-2-alpha-1 .submenu-icon--right__menu__12-18-2-alpha-1 {\r\n margin-left: var(--SpaceS, 8px);\r\n }\r\n\r\n .menu__item__menu__12-18-2-alpha-1:not(.menu__item--disabled__menu__12-18-2-alpha-1):hover {\r\n cursor: pointer;\r\n }\r\n\r\n .menu__item--disabled__menu__12-18-2-alpha-1 {\r\n opacity: var(--ControlDisabledOpacity, 0.5);\r\n cursor: not-allowed;\r\n }\r\n\r\n .menu__item--danger__menu__12-18-2-alpha-1 {\r\n color: var(--ActionColorDelete, #AE304A);\r\n }\r\n\r\n .menu__item--danger__menu__12-18-2-alpha-1:not(.menu__item--disabled__menu__12-18-2-alpha-1):hover {\r\n background-color: var(--ActionBackgroundDelete, #F3E0E4);\r\n }\r\n\r\n .menu__item--current__menu__12-18-2-alpha-1 {\r\n background-color: var(--HighlightBlockBackground, #F5F6F6); /* keyboard current background */\r\n }\r\n\r\n .menu__item--selected__menu__12-18-2-alpha-1:not(.menu__item--danger__menu__12-18-2-alpha-1) {\r\n background-color: var(--ActionBackgroundSelected, #F1CE4A);\r\n }\r\n\r\n .menu__item__menu__12-18-2-alpha-1:not(.menu__item--danger__menu__12-18-2-alpha-1):not(.menu__item--disabled__menu__12-18-2-alpha-1):not(.menu__item--selected__menu__12-18-2-alpha-1):hover {\r\n background-color: var(--ActionBackgroundHover, #F9E9AE);\r\n }\r\n\r\n .menu__item__menu__12-18-2-alpha-1:last-child {\r\n border-radius: 0 0 var(--BorderRadiusDefault, 3px) var(--BorderRadiusDefault, 3px);\r\n }\r\n\r\n .menu__separator__menu__12-18-2-alpha-1 {\r\n margin: var(--SpaceXS, 4px) 0;\r\n border-top: solid 1px var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n }\r\n\r\n .menu__separator__title__menu__12-18-2-alpha-1 {\r\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px) var(--SpaceXS, 4px) var(--SpaceSM, 12px);\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n font-size: var(--FontSizeLabel, 11px);\r\n line-height: 1.3;\r\n font-weight: var(--FontWeightSemibold, 600);\r\n text-transform: uppercase;\r\n color: var(--FontColorGray, rgba(0, 0, 0, 0.7));\r\n letter-spacing: 0.4px;\r\n }\r\n";
|
|
170
|
+
var styles = {"menu":"menu__menu__12-18-2-alpha-1","menu__item":"menu__item__menu__12-18-2-alpha-1","menu__item__content":"menu__item__content__menu__12-18-2-alpha-1","menu__item__content--left":"menu__item__content--left__menu__12-18-2-alpha-1","submenu-icon":"submenu-icon__menu__12-18-2-alpha-1","submenu-icon--left":"submenu-icon--left__menu__12-18-2-alpha-1","submenu-icon--right":"submenu-icon--right__menu__12-18-2-alpha-1","menu__item--disabled":"menu__item--disabled__menu__12-18-2-alpha-1","menu__item--danger":"menu__item--danger__menu__12-18-2-alpha-1","menu__item--current":"menu__item--current__menu__12-18-2-alpha-1","menu__item--selected":"menu__item--selected__menu__12-18-2-alpha-1","menu__separator":"menu__separator__menu__12-18-2-alpha-1","menu__separator__title":"menu__separator__title__menu__12-18-2-alpha-1"};
|
|
174
171
|
styleInject(css);
|
|
175
172
|
|
|
176
173
|
/**
|
|
@@ -179,7 +176,6 @@ styleInject(css);
|
|
|
179
176
|
* Optional `title` prop allows to add any text under the horizontal line,
|
|
180
177
|
* or to the top of the list for first item.
|
|
181
178
|
*/
|
|
182
|
-
|
|
183
179
|
var MenuSeparator = function MenuSeparator(_ref) {
|
|
184
180
|
var title = _ref.title;
|
|
185
181
|
return React.createElement("div", {
|
|
@@ -194,6 +190,7 @@ var MenuItemTypes = {
|
|
|
194
190
|
DEFAULT: 'default',
|
|
195
191
|
UNSTYLED: 'unstyled'
|
|
196
192
|
};
|
|
193
|
+
|
|
197
194
|
/**
|
|
198
195
|
* Menu.Item is a single item within the menu.
|
|
199
196
|
* By default, the item is highlighted on hover, single-line and truncates if
|
|
@@ -228,33 +225,29 @@ var MenuItemTypes = {
|
|
|
228
225
|
|
|
229
226
|
var MenuItem = function MenuItem(_ref) {
|
|
230
227
|
var _ref$type = _ref.type,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
228
|
+
type = _ref$type === void 0 ? MenuItemTypes.DEFAULT : _ref$type,
|
|
229
|
+
_ref$isParent = _ref.isParent,
|
|
230
|
+
isParent = _ref$isParent === void 0 ? false : _ref$isParent,
|
|
231
|
+
_ref$selected = _ref.selected,
|
|
232
|
+
selected = _ref$selected === void 0 ? false : _ref$selected,
|
|
233
|
+
disabled = _ref.disabled,
|
|
234
|
+
children = _ref.children,
|
|
235
|
+
className = _ref.className,
|
|
236
|
+
_ref$navigationState = _ref.navigationState,
|
|
237
|
+
navigationState = _ref$navigationState === void 0 ? {} : _ref$navigationState,
|
|
238
|
+
payload = _ref.payload,
|
|
239
|
+
isLeftOpen = _ref.isLeftOpen,
|
|
240
|
+
onItemChoosed = _ref.onItemChoosed,
|
|
241
|
+
otherProps = _objectWithoutProperties(_ref, ["type", "isParent", "selected", "disabled", "children", "className", "navigationState", "payload", "isLeftOpen", "onItemChoosed"]);
|
|
246
242
|
var withArrowChild = type !== MenuItemTypes.UNSTYLED && isParent;
|
|
247
|
-
|
|
248
243
|
var handleSubmit = function handleSubmit(event) {
|
|
249
244
|
return Boolean(onItemChoosed) && Boolean(payload) && onItemChoosed(payload, event);
|
|
250
245
|
};
|
|
251
|
-
|
|
252
246
|
if (navigationState.isSubmitted) {
|
|
253
247
|
handleSubmit({
|
|
254
248
|
code: navigationState.currentEvent
|
|
255
249
|
});
|
|
256
250
|
}
|
|
257
|
-
|
|
258
251
|
return React.createElement("div", _extends({}, otherProps, {
|
|
259
252
|
onClick: function onClick(event) {
|
|
260
253
|
return otherProps.onClick ? otherProps.onClick(payload, event) : handleSubmit(event);
|
|
@@ -289,80 +282,62 @@ var defaultMenuState = {
|
|
|
289
282
|
};
|
|
290
283
|
var Menu = /*#__PURE__*/function (_React$Component) {
|
|
291
284
|
_inherits(Menu, _React$Component);
|
|
292
|
-
|
|
293
285
|
function Menu(_props) {
|
|
294
286
|
var _this;
|
|
295
|
-
|
|
296
287
|
_classCallCheck(this, Menu);
|
|
297
|
-
|
|
298
288
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(Menu).call(this, _props));
|
|
299
|
-
|
|
300
289
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "isParentMenu", function () {
|
|
301
290
|
return _this.props.enableKeyboardNavigation;
|
|
302
291
|
});
|
|
303
|
-
|
|
304
292
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "isControlledMode", function () {
|
|
305
293
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props;
|
|
306
294
|
return typeof props.open !== 'undefined' && props.open !== null;
|
|
307
295
|
});
|
|
308
|
-
|
|
309
296
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleMenuByParent", function (eventCode) {
|
|
310
297
|
return _this.props.navigationState.onChangeMenuState && _this.props.navigationState.onChangeMenuState(eventCode);
|
|
311
298
|
});
|
|
312
|
-
|
|
313
299
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleKeyboard", function (event) {
|
|
314
300
|
var currentMenuState = _this.state.currentMenuState;
|
|
315
301
|
var indexOfLastChildInRow = _this.menuItemsAvailableForNavigation.length - 1;
|
|
316
|
-
|
|
317
302
|
var getNewState = _this.commands(event.code);
|
|
318
|
-
|
|
319
303
|
if (!getNewState || !_this.state.open) {
|
|
320
304
|
return;
|
|
321
305
|
}
|
|
322
|
-
|
|
323
306
|
var newMenuState = getNewState(currentMenuState, {
|
|
324
307
|
minLength: 0,
|
|
325
308
|
maxLength: indexOfLastChildInRow,
|
|
326
309
|
currentEvent: event.code
|
|
327
310
|
});
|
|
328
|
-
|
|
329
311
|
if (!newMenuState || !newMenuState.value) {
|
|
330
312
|
return;
|
|
331
313
|
}
|
|
332
|
-
|
|
333
314
|
_this.setState({
|
|
334
315
|
currentMenuState: newMenuState.value
|
|
335
316
|
}, newMenuState.afterUpdateCallBack);
|
|
336
317
|
});
|
|
337
|
-
|
|
338
318
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getMenuItemsState", function () {
|
|
339
319
|
return React.Children.toArray(_this.props.children).filter(function (_ref) {
|
|
340
320
|
var type = _ref.type;
|
|
341
321
|
return type !== MenuSeparator && type !== MenuTrigger;
|
|
342
322
|
});
|
|
343
323
|
});
|
|
344
|
-
|
|
345
324
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "setOpened", function (open) {
|
|
346
325
|
if (!_this.isControlledMode()) {
|
|
347
326
|
_this.setState({
|
|
348
327
|
open: open
|
|
349
328
|
});
|
|
350
329
|
}
|
|
351
|
-
|
|
352
330
|
if (_this.isParentMenu()) {
|
|
353
331
|
_this.setInitialMenuState(open);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
|
|
332
|
+
}
|
|
333
|
+
// Force clean state, when user navigating by mouse
|
|
357
334
|
if (!open) {
|
|
358
335
|
_this.handleMenuByParent('CloseCurrentMenu');
|
|
359
336
|
}
|
|
360
|
-
|
|
361
337
|
if (_this.props.onSetOpened) {
|
|
362
338
|
_this.props.onSetOpened(open);
|
|
363
339
|
}
|
|
364
340
|
});
|
|
365
|
-
|
|
366
341
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "setInitialMenuState", function (open) {
|
|
367
342
|
return _this.setState(open ? {
|
|
368
343
|
open: open,
|
|
@@ -374,18 +349,15 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
374
349
|
currentMenuState: {}
|
|
375
350
|
});
|
|
376
351
|
});
|
|
377
|
-
|
|
378
352
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getChildren", function () {
|
|
379
353
|
if (!_this.props.enableKeyboardNavigation) {
|
|
380
354
|
return React.Children.toArray(_this.props.children);
|
|
381
355
|
}
|
|
382
|
-
|
|
383
356
|
var counter = 0;
|
|
384
357
|
var currentMenuState = _this.state.currentMenuState;
|
|
385
358
|
var _this$props = _this.props,
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
359
|
+
children = _this$props.children,
|
|
360
|
+
isLeftOpen = _this$props.isLeftOpen;
|
|
389
361
|
var navigationState = _extends({}, currentMenuState, {
|
|
390
362
|
onChangeMenuState: function onChangeMenuState(code) {
|
|
391
363
|
return _this.handleKeyboard({
|
|
@@ -393,16 +365,13 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
393
365
|
});
|
|
394
366
|
}
|
|
395
367
|
});
|
|
396
|
-
|
|
397
368
|
var setAdditionalProps = function setAdditionalProps(element) {
|
|
398
369
|
return isLeftOpen ? React.cloneElement(element, {
|
|
399
370
|
isLeftOpen: isLeftOpen
|
|
400
371
|
}) : element;
|
|
401
372
|
};
|
|
402
|
-
|
|
403
373
|
return React.Children.toArray(children).map(function (child) {
|
|
404
374
|
var element = child;
|
|
405
|
-
|
|
406
375
|
if (child.type !== MenuSeparator && child.type !== MenuTrigger) {
|
|
407
376
|
var isCurrentActiveItem = currentMenuState && currentMenuState.id === counter;
|
|
408
377
|
element = isCurrentActiveItem ? React.cloneElement(child, {
|
|
@@ -411,28 +380,23 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
411
380
|
}) : setAdditionalProps(child);
|
|
412
381
|
counter += 1;
|
|
413
382
|
}
|
|
414
|
-
|
|
415
383
|
return element;
|
|
416
384
|
});
|
|
417
385
|
});
|
|
418
|
-
|
|
419
386
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onOuterAction", function () {
|
|
420
387
|
return _this.props.closeOnOuterAction && _this.setOpened(false);
|
|
421
388
|
});
|
|
422
|
-
|
|
423
389
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "prepareTrigger", function (menuChildren) {
|
|
424
390
|
var _this$props2 = _this.props,
|
|
425
|
-
|
|
426
|
-
|
|
391
|
+
isLeftOpen = _this$props2.isLeftOpen,
|
|
392
|
+
navigationState = _this$props2.navigationState;
|
|
427
393
|
var isOpen = _this.isControlledMode() ? _this.props.open : _this.state.open;
|
|
428
394
|
var menuTrigger = menuChildren.find(function (element) {
|
|
429
395
|
return element.type === MenuTrigger;
|
|
430
396
|
});
|
|
431
|
-
|
|
432
397
|
if (!menuTrigger) {
|
|
433
398
|
throw new Error('Trigger not found in Menu children. Did you forget to add <MenuTrigger> to <Menu> ?');
|
|
434
399
|
}
|
|
435
|
-
|
|
436
400
|
var children = menuTrigger.props.children;
|
|
437
401
|
var renderCallbackArgs = {
|
|
438
402
|
isOpen: isOpen,
|
|
@@ -456,16 +420,13 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
456
420
|
getPopoverPosition: getPopoverPosition
|
|
457
421
|
};
|
|
458
422
|
});
|
|
459
|
-
|
|
460
423
|
_this.menuItemsAvailableForNavigation = [];
|
|
461
424
|
_this.state = {
|
|
462
425
|
open: Boolean(_this.props.isOpenInitially),
|
|
463
426
|
currentMenuState: {}
|
|
464
427
|
};
|
|
465
|
-
|
|
466
428
|
_this.commands = function (eventCode) {
|
|
467
429
|
var _config;
|
|
468
|
-
|
|
469
430
|
var config = (_config = {
|
|
470
431
|
Escape: function Escape() {
|
|
471
432
|
return _this.setOpened(false);
|
|
@@ -486,7 +447,7 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
486
447
|
},
|
|
487
448
|
ArrowDown: function ArrowDown(activeMenuItem, _ref3) {
|
|
488
449
|
var maxLength = _ref3.maxLength,
|
|
489
|
-
|
|
450
|
+
currentEvent = _ref3.currentEvent;
|
|
490
451
|
return {
|
|
491
452
|
value: _extends({}, activeMenuItem.isOpenMenu ? _extends({}, activeMenuItem, {
|
|
492
453
|
currentEvent: currentEvent
|
|
@@ -498,7 +459,7 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
498
459
|
},
|
|
499
460
|
ArrowUp: function ArrowUp(activeMenuItem, _ref4) {
|
|
500
461
|
var minLength = _ref4.minLength,
|
|
501
|
-
|
|
462
|
+
currentEvent = _ref4.currentEvent;
|
|
502
463
|
return {
|
|
503
464
|
value: _extends({}, activeMenuItem.isOpenMenu ? _extends({}, activeMenuItem, {
|
|
504
465
|
currentEvent: currentEvent
|
|
@@ -539,25 +500,23 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
539
500
|
isOpenMenu: false
|
|
540
501
|
})
|
|
541
502
|
};
|
|
542
|
-
}), _config);
|
|
543
|
-
// eslint-disable-next-line security/detect-object-injection
|
|
503
|
+
}), _config);
|
|
544
504
|
|
|
505
|
+
// eventCode generated by library here
|
|
506
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
545
507
|
return config[eventCode];
|
|
546
508
|
};
|
|
547
|
-
|
|
548
509
|
return _this;
|
|
549
510
|
}
|
|
511
|
+
|
|
550
512
|
/**
|
|
551
513
|
* LifeCycle Methods
|
|
552
514
|
*/
|
|
553
|
-
|
|
554
|
-
|
|
555
515
|
_createClass(Menu, [{
|
|
556
516
|
key: "componentDidMount",
|
|
557
517
|
value: function componentDidMount() {
|
|
558
518
|
// Assume that children will be passed in sync manner
|
|
559
519
|
this.menuItemsAvailableForNavigation = this.getMenuItemsState();
|
|
560
|
-
|
|
561
520
|
if (this.props.enableKeyboardNavigation) {
|
|
562
521
|
document.addEventListener('keydown', this.handleKeyboard);
|
|
563
522
|
}
|
|
@@ -566,13 +525,12 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
566
525
|
key: "componentWillReceiveProps",
|
|
567
526
|
value: function componentWillReceiveProps(_ref7) {
|
|
568
527
|
var navigationState = _ref7.navigationState;
|
|
569
|
-
|
|
570
528
|
if (this.props.navigationState.isOpenMenu !== navigationState.isOpenMenu) {
|
|
571
529
|
this.setInitialMenuState(navigationState.isOpenMenu);
|
|
572
|
-
}
|
|
573
|
-
// by dispatching `handleKeyboard` manually
|
|
574
|
-
|
|
530
|
+
}
|
|
575
531
|
|
|
532
|
+
// Transfering of control from parent menu to submenu
|
|
533
|
+
// by dispatching `handleKeyboard` manually
|
|
576
534
|
if (Boolean(navigationState.currentEvent) && navigationState.isOpenMenu && this.props.navigationState !== navigationState) {
|
|
577
535
|
this.handleKeyboard({
|
|
578
536
|
code: navigationState.currentEvent
|
|
@@ -586,7 +544,6 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
586
544
|
document.removeEventListener('keydown', this.handleKeyboard);
|
|
587
545
|
}
|
|
588
546
|
} // Assume that only parent menu have this flag
|
|
589
|
-
|
|
590
547
|
}, {
|
|
591
548
|
key: "render",
|
|
592
549
|
value: function render() {
|
|
@@ -595,17 +552,14 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
595
552
|
var menuItems = children.filter(function (element) {
|
|
596
553
|
return element.type !== MenuTrigger;
|
|
597
554
|
});
|
|
598
|
-
|
|
599
555
|
var _this$prepareTrigger = this.prepareTrigger(children),
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
556
|
+
trigger = _this$prepareTrigger.trigger,
|
|
557
|
+
getPopoverPosition = _this$prepareTrigger.getPopoverPosition;
|
|
603
558
|
var renderBody = this.props.renderBody || function (items) {
|
|
604
559
|
return React.createElement(Popover.Body, {
|
|
605
560
|
noPadding: true
|
|
606
561
|
}, items);
|
|
607
562
|
};
|
|
608
|
-
|
|
609
563
|
return React.createElement(Popover, {
|
|
610
564
|
className: styles['menu'],
|
|
611
565
|
isOpen: isOpen,
|
|
@@ -617,7 +571,6 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
617
571
|
}, trigger);
|
|
618
572
|
}
|
|
619
573
|
}]);
|
|
620
|
-
|
|
621
574
|
return Menu;
|
|
622
575
|
}(React.Component);
|
|
623
576
|
Menu.defaultProps = {
|
|
@@ -635,7 +588,6 @@ var SubMenu = function SubMenu() {
|
|
|
635
588
|
SubMenu.propTypes = {
|
|
636
589
|
children: PropTypes.any.isRequired
|
|
637
590
|
};
|
|
638
|
-
|
|
639
591
|
var assignKeys = function assignKeys() {
|
|
640
592
|
var reactChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
641
593
|
return reactChildren.map(function (item, index) {
|
|
@@ -644,54 +596,45 @@ var assignKeys = function assignKeys() {
|
|
|
644
596
|
}) : item;
|
|
645
597
|
});
|
|
646
598
|
};
|
|
647
|
-
|
|
648
599
|
var MenuItemWithSubMenu = function MenuItemWithSubMenu(_ref) {
|
|
649
600
|
var open = _ref.open,
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
601
|
+
onSetOpened = _ref.onSetOpened,
|
|
602
|
+
_ref$showOn = _ref.showOn,
|
|
603
|
+
showOn = _ref$showOn === void 0 ? 'hover' : _ref$showOn,
|
|
604
|
+
_ref$hideOn = _ref.hideOn,
|
|
605
|
+
hideOn = _ref$hideOn === void 0 ? 'hover' : _ref$hideOn,
|
|
606
|
+
children = _ref.children,
|
|
607
|
+
menuOffset = _ref.menuOffset,
|
|
608
|
+
otherProps = _objectWithoutProperties(_ref, ["open", "onSetOpened", "showOn", "hideOn", "children", "menuOffset"]);
|
|
659
609
|
var menuItems = [];
|
|
660
610
|
var trigger = [];
|
|
661
611
|
React.Children.toArray(children).forEach(function (item) {
|
|
662
612
|
return item.type === SubMenu ? menuItems.push(item.props.children) : trigger.push(item);
|
|
663
613
|
});
|
|
664
|
-
|
|
665
614
|
var _onClick = function onClick(event, setOpened) {
|
|
666
615
|
if (typeof otherProps.onClick === 'function') {
|
|
667
616
|
otherProps.onClick(event);
|
|
668
617
|
}
|
|
669
|
-
|
|
670
618
|
if (showOn === TriggerTypes.CLICK) {
|
|
671
619
|
setOpened(true);
|
|
672
620
|
}
|
|
673
621
|
};
|
|
674
|
-
|
|
675
622
|
var _onMouseEnter = function onMouseEnter(event, setOpened) {
|
|
676
623
|
if (typeof otherProps.onMouseEnter === 'function') {
|
|
677
624
|
otherProps.onMouseEnter(event);
|
|
678
625
|
}
|
|
679
|
-
|
|
680
626
|
if (showOn === 'hover') {
|
|
681
627
|
setOpened(true);
|
|
682
628
|
}
|
|
683
629
|
};
|
|
684
|
-
|
|
685
630
|
var _onMouseLeave = function onMouseLeave(event, setOpened) {
|
|
686
631
|
if (typeof otherProps.onMouseLeave === 'function') {
|
|
687
632
|
otherProps.onMouseLeave(event);
|
|
688
633
|
}
|
|
689
|
-
|
|
690
634
|
if (hideOn === 'hover') {
|
|
691
635
|
setOpened(false);
|
|
692
636
|
}
|
|
693
637
|
};
|
|
694
|
-
|
|
695
638
|
return React.createElement(Menu, _extends({}, otherProps, {
|
|
696
639
|
appendInline: true,
|
|
697
640
|
relativeToParent: true,
|
package/dist/menu.js
CHANGED
|
@@ -15,24 +15,25 @@ function _classCallCheck(instance, Constructor) {
|
|
|
15
15
|
throw new TypeError("Cannot call a class as a function");
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
|
|
19
18
|
function _defineProperties(target, props) {
|
|
20
19
|
for (var i = 0; i < props.length; i++) {
|
|
21
20
|
var descriptor = props[i];
|
|
22
21
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
23
22
|
descriptor.configurable = true;
|
|
24
23
|
if ("value" in descriptor) descriptor.writable = true;
|
|
25
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
24
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
|
|
29
27
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
30
28
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
31
29
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
30
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
31
|
+
writable: false
|
|
32
|
+
});
|
|
32
33
|
return Constructor;
|
|
33
34
|
}
|
|
34
|
-
|
|
35
35
|
function _defineProperty(obj, key, value) {
|
|
36
|
+
key = _toPropertyKey(key);
|
|
36
37
|
if (key in obj) {
|
|
37
38
|
Object.defineProperty(obj, key, {
|
|
38
39
|
value: value,
|
|
@@ -43,33 +44,26 @@ function _defineProperty(obj, key, value) {
|
|
|
43
44
|
} else {
|
|
44
45
|
obj[key] = value;
|
|
45
46
|
}
|
|
46
|
-
|
|
47
47
|
return obj;
|
|
48
48
|
}
|
|
49
|
-
|
|
50
49
|
function _extends() {
|
|
51
|
-
_extends = Object.assign
|
|
50
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
52
51
|
for (var i = 1; i < arguments.length; i++) {
|
|
53
52
|
var source = arguments[i];
|
|
54
|
-
|
|
55
53
|
for (var key in source) {
|
|
56
54
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
57
55
|
target[key] = source[key];
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
|
-
|
|
62
59
|
return target;
|
|
63
60
|
};
|
|
64
|
-
|
|
65
61
|
return _extends.apply(this, arguments);
|
|
66
62
|
}
|
|
67
|
-
|
|
68
63
|
function _inherits(subClass, superClass) {
|
|
69
64
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
70
65
|
throw new TypeError("Super expression must either be null or a function");
|
|
71
66
|
}
|
|
72
|
-
|
|
73
67
|
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
74
68
|
constructor: {
|
|
75
69
|
value: subClass,
|
|
@@ -77,50 +71,42 @@ function _inherits(subClass, superClass) {
|
|
|
77
71
|
configurable: true
|
|
78
72
|
}
|
|
79
73
|
});
|
|
74
|
+
Object.defineProperty(subClass, "prototype", {
|
|
75
|
+
writable: false
|
|
76
|
+
});
|
|
80
77
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
81
78
|
}
|
|
82
|
-
|
|
83
79
|
function _getPrototypeOf(o) {
|
|
84
|
-
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
80
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
|
|
85
81
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
86
82
|
};
|
|
87
83
|
return _getPrototypeOf(o);
|
|
88
84
|
}
|
|
89
|
-
|
|
90
85
|
function _setPrototypeOf(o, p) {
|
|
91
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
86
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
92
87
|
o.__proto__ = p;
|
|
93
88
|
return o;
|
|
94
89
|
};
|
|
95
|
-
|
|
96
90
|
return _setPrototypeOf(o, p);
|
|
97
91
|
}
|
|
98
|
-
|
|
99
92
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
100
93
|
if (source == null) return {};
|
|
101
94
|
var target = {};
|
|
102
95
|
var sourceKeys = Object.keys(source);
|
|
103
96
|
var key, i;
|
|
104
|
-
|
|
105
97
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
106
98
|
key = sourceKeys[i];
|
|
107
99
|
if (excluded.indexOf(key) >= 0) continue;
|
|
108
100
|
target[key] = source[key];
|
|
109
101
|
}
|
|
110
|
-
|
|
111
102
|
return target;
|
|
112
103
|
}
|
|
113
|
-
|
|
114
104
|
function _objectWithoutProperties(source, excluded) {
|
|
115
105
|
if (source == null) return {};
|
|
116
|
-
|
|
117
106
|
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
118
|
-
|
|
119
107
|
var key, i;
|
|
120
|
-
|
|
121
108
|
if (Object.getOwnPropertySymbols) {
|
|
122
109
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
123
|
-
|
|
124
110
|
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
125
111
|
key = sourceSymbolKeys[i];
|
|
126
112
|
if (excluded.indexOf(key) >= 0) continue;
|
|
@@ -128,25 +114,36 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
128
114
|
target[key] = source[key];
|
|
129
115
|
}
|
|
130
116
|
}
|
|
131
|
-
|
|
132
117
|
return target;
|
|
133
118
|
}
|
|
134
|
-
|
|
135
119
|
function _assertThisInitialized(self) {
|
|
136
120
|
if (self === void 0) {
|
|
137
121
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
138
122
|
}
|
|
139
|
-
|
|
140
123
|
return self;
|
|
141
124
|
}
|
|
142
|
-
|
|
143
125
|
function _possibleConstructorReturn(self, call) {
|
|
144
126
|
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
145
127
|
return call;
|
|
128
|
+
} else if (call !== void 0) {
|
|
129
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
146
130
|
}
|
|
147
|
-
|
|
148
131
|
return _assertThisInitialized(self);
|
|
149
132
|
}
|
|
133
|
+
function _toPrimitive(input, hint) {
|
|
134
|
+
if (typeof input !== "object" || input === null) return input;
|
|
135
|
+
var prim = input[Symbol.toPrimitive];
|
|
136
|
+
if (prim !== undefined) {
|
|
137
|
+
var res = prim.call(input, hint || "default");
|
|
138
|
+
if (typeof res !== "object") return res;
|
|
139
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
140
|
+
}
|
|
141
|
+
return (hint === "string" ? String : Number)(input);
|
|
142
|
+
}
|
|
143
|
+
function _toPropertyKey(arg) {
|
|
144
|
+
var key = _toPrimitive(arg, "string");
|
|
145
|
+
return typeof key === "symbol" ? key : String(key);
|
|
146
|
+
}
|
|
150
147
|
|
|
151
148
|
function styleInject(css, ref) {
|
|
152
149
|
if ( ref === void 0 ) ref = {};
|
|
@@ -175,8 +172,8 @@ function styleInject(css, ref) {
|
|
|
175
172
|
}
|
|
176
173
|
}
|
|
177
174
|
|
|
178
|
-
var css = ".menu__menu__12-18-1 {\r\n -webkit-transition-property: opacity !important;\r\n transition-property: opacity !important;\r\n -webkit-transform: none !important;\r\n transform: none !important;\r\n padding: 0;\r\n}\r\n\r\n .menu__item__menu__12-18-1 {\r\n font-size: var(--FontSizeDefault, 13px);\r\n position: relative;\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px);\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n }\r\n\r\n .menu__item__content__menu__12-18-1 {\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n -webkit-box-flex: 1;\r\n -ms-flex: 1 1 auto;\r\n flex: 1 1 auto;\r\n }\r\n\r\n .menu__item__content--left__menu__12-18-1 {\r\n padding-left: var(--IconsSizeDefault, 16px);\r\n }\r\n\r\n .menu__item__menu__12-18-1 .submenu-icon__menu__12-18-1 {\r\n -webkit-box-flex: 0;\r\n -ms-flex: 0 0 auto;\r\n flex: 0 0 auto;\r\n }\r\n\r\n .menu__item__menu__12-18-1 .submenu-icon--left__menu__12-18-1 {\r\n margin-right: var(--SpaceS, 8px);\r\n }\r\n\r\n .menu__item__menu__12-18-1 .submenu-icon--right__menu__12-18-1 {\r\n margin-left: var(--SpaceS, 8px);\r\n }\r\n\r\n .menu__item__menu__12-18-1:not(.menu__item--disabled__menu__12-18-1):hover {\r\n cursor: pointer;\r\n }\r\n\r\n .menu__item--disabled__menu__12-18-1 {\r\n opacity: var(--ControlDisabledOpacity, 0.5);\r\n cursor: not-allowed;\r\n }\r\n\r\n .menu__item--danger__menu__12-18-1 {\r\n color: var(--ActionColorDelete, #AE304A);\r\n }\r\n\r\n .menu__item--danger__menu__12-18-1:not(.menu__item--disabled__menu__12-18-1):hover {\r\n background-color: var(--ActionBackgroundDelete, #F3E0E4);\r\n }\r\n\r\n .menu__item--current__menu__12-18-1 {\r\n background-color: var(--HighlightBlockBackground, #F5F6F6); /* keyboard current background */\r\n }\r\n\r\n .menu__item--selected__menu__12-18-1:not(.menu__item--danger__menu__12-18-1) {\r\n background-color: var(--ActionBackgroundSelected, #F1CE4A);\r\n }\r\n\r\n .menu__item__menu__12-18-1:not(.menu__item--danger__menu__12-18-1):not(.menu__item--disabled__menu__12-18-1):not(.menu__item--selected__menu__12-18-1):hover {\r\n background-color: var(--ActionBackgroundHover, #F9E9AE);\r\n }\r\n\r\n .menu__item__menu__12-18-1:last-child {\r\n border-radius: 0 0 var(--BorderRadiusDefault, 3px) var(--BorderRadiusDefault, 3px);\r\n }\r\n\r\n .menu__separator__menu__12-18-1 {\r\n margin: var(--SpaceXS, 4px) 0;\r\n border-top: solid 1px var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n }\r\n\r\n .menu__separator__title__menu__12-18-1 {\r\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px) var(--SpaceXS, 4px) var(--SpaceSM, 12px);\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n font-size: var(--FontSizeLabel, 11px);\r\n line-height: 1.3;\r\n font-weight: var(--FontWeightSemibold, 600);\r\n text-transform: uppercase;\r\n color: var(--FontColorGray, rgba(0, 0, 0, 0.7));\r\n letter-spacing: 0.4px;\r\n }\r\n";
|
|
179
|
-
var styles = {"menu":"menu__menu__12-18-1","menu__item":"menu__item__menu__12-18-1","menu__item__content":"menu__item__content__menu__12-18-1","menu__item__content--left":"menu__item__content--left__menu__12-18-1","submenu-icon":"submenu-icon__menu__12-18-1","submenu-icon--left":"submenu-icon--left__menu__12-18-1","submenu-icon--right":"submenu-icon--right__menu__12-18-1","menu__item--disabled":"menu__item--disabled__menu__12-18-1","menu__item--danger":"menu__item--danger__menu__12-18-1","menu__item--current":"menu__item--current__menu__12-18-1","menu__item--selected":"menu__item--selected__menu__12-18-1","menu__separator":"menu__separator__menu__12-18-1","menu__separator__title":"menu__separator__title__menu__12-18-1"};
|
|
175
|
+
var css = ".menu__menu__12-18-2-alpha-1 {\r\n -webkit-transition-property: opacity !important;\r\n transition-property: opacity !important;\r\n -webkit-transform: none !important;\r\n transform: none !important;\r\n padding: 0;\r\n}\r\n\r\n .menu__item__menu__12-18-2-alpha-1 {\r\n font-size: var(--FontSizeDefault, 13px);\r\n position: relative;\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n -webkit-box-align: center;\r\n -ms-flex-align: center;\r\n align-items: center;\r\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px);\r\n -webkit-box-sizing: border-box;\r\n box-sizing: border-box;\r\n }\r\n\r\n .menu__item__content__menu__12-18-2-alpha-1 {\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n -webkit-box-flex: 1;\r\n -ms-flex: 1 1 auto;\r\n flex: 1 1 auto;\r\n }\r\n\r\n .menu__item__content--left__menu__12-18-2-alpha-1 {\r\n padding-left: var(--IconsSizeDefault, 16px);\r\n }\r\n\r\n .menu__item__menu__12-18-2-alpha-1 .submenu-icon__menu__12-18-2-alpha-1 {\r\n -webkit-box-flex: 0;\r\n -ms-flex: 0 0 auto;\r\n flex: 0 0 auto;\r\n }\r\n\r\n .menu__item__menu__12-18-2-alpha-1 .submenu-icon--left__menu__12-18-2-alpha-1 {\r\n margin-right: var(--SpaceS, 8px);\r\n }\r\n\r\n .menu__item__menu__12-18-2-alpha-1 .submenu-icon--right__menu__12-18-2-alpha-1 {\r\n margin-left: var(--SpaceS, 8px);\r\n }\r\n\r\n .menu__item__menu__12-18-2-alpha-1:not(.menu__item--disabled__menu__12-18-2-alpha-1):hover {\r\n cursor: pointer;\r\n }\r\n\r\n .menu__item--disabled__menu__12-18-2-alpha-1 {\r\n opacity: var(--ControlDisabledOpacity, 0.5);\r\n cursor: not-allowed;\r\n }\r\n\r\n .menu__item--danger__menu__12-18-2-alpha-1 {\r\n color: var(--ActionColorDelete, #AE304A);\r\n }\r\n\r\n .menu__item--danger__menu__12-18-2-alpha-1:not(.menu__item--disabled__menu__12-18-2-alpha-1):hover {\r\n background-color: var(--ActionBackgroundDelete, #F3E0E4);\r\n }\r\n\r\n .menu__item--current__menu__12-18-2-alpha-1 {\r\n background-color: var(--HighlightBlockBackground, #F5F6F6); /* keyboard current background */\r\n }\r\n\r\n .menu__item--selected__menu__12-18-2-alpha-1:not(.menu__item--danger__menu__12-18-2-alpha-1) {\r\n background-color: var(--ActionBackgroundSelected, #F1CE4A);\r\n }\r\n\r\n .menu__item__menu__12-18-2-alpha-1:not(.menu__item--danger__menu__12-18-2-alpha-1):not(.menu__item--disabled__menu__12-18-2-alpha-1):not(.menu__item--selected__menu__12-18-2-alpha-1):hover {\r\n background-color: var(--ActionBackgroundHover, #F9E9AE);\r\n }\r\n\r\n .menu__item__menu__12-18-2-alpha-1:last-child {\r\n border-radius: 0 0 var(--BorderRadiusDefault, 3px) var(--BorderRadiusDefault, 3px);\r\n }\r\n\r\n .menu__separator__menu__12-18-2-alpha-1 {\r\n margin: var(--SpaceXS, 4px) 0;\r\n border-top: solid 1px var(--HighlightBlockBorderColor, rgba(64, 66, 73, 0.1));\r\n }\r\n\r\n .menu__separator__title__menu__12-18-2-alpha-1 {\r\n padding: var(--SpaceS, 8px) var(--SpaceSM, 12px) var(--SpaceXS, 4px) var(--SpaceSM, 12px);\r\n display: -webkit-box;\r\n display: -ms-flexbox;\r\n display: flex;\r\n font-size: var(--FontSizeLabel, 11px);\r\n line-height: 1.3;\r\n font-weight: var(--FontWeightSemibold, 600);\r\n text-transform: uppercase;\r\n color: var(--FontColorGray, rgba(0, 0, 0, 0.7));\r\n letter-spacing: 0.4px;\r\n }\r\n";
|
|
176
|
+
var styles = {"menu":"menu__menu__12-18-2-alpha-1","menu__item":"menu__item__menu__12-18-2-alpha-1","menu__item__content":"menu__item__content__menu__12-18-2-alpha-1","menu__item__content--left":"menu__item__content--left__menu__12-18-2-alpha-1","submenu-icon":"submenu-icon__menu__12-18-2-alpha-1","submenu-icon--left":"submenu-icon--left__menu__12-18-2-alpha-1","submenu-icon--right":"submenu-icon--right__menu__12-18-2-alpha-1","menu__item--disabled":"menu__item--disabled__menu__12-18-2-alpha-1","menu__item--danger":"menu__item--danger__menu__12-18-2-alpha-1","menu__item--current":"menu__item--current__menu__12-18-2-alpha-1","menu__item--selected":"menu__item--selected__menu__12-18-2-alpha-1","menu__separator":"menu__separator__menu__12-18-2-alpha-1","menu__separator__title":"menu__separator__title__menu__12-18-2-alpha-1"};
|
|
180
177
|
styleInject(css);
|
|
181
178
|
|
|
182
179
|
/**
|
|
@@ -185,7 +182,6 @@ styleInject(css);
|
|
|
185
182
|
* Optional `title` prop allows to add any text under the horizontal line,
|
|
186
183
|
* or to the top of the list for first item.
|
|
187
184
|
*/
|
|
188
|
-
|
|
189
185
|
var MenuSeparator = function MenuSeparator(_ref) {
|
|
190
186
|
var title = _ref.title;
|
|
191
187
|
return React.createElement("div", {
|
|
@@ -200,6 +196,7 @@ var MenuItemTypes = {
|
|
|
200
196
|
DEFAULT: 'default',
|
|
201
197
|
UNSTYLED: 'unstyled'
|
|
202
198
|
};
|
|
199
|
+
|
|
203
200
|
/**
|
|
204
201
|
* Menu.Item is a single item within the menu.
|
|
205
202
|
* By default, the item is highlighted on hover, single-line and truncates if
|
|
@@ -234,33 +231,29 @@ var MenuItemTypes = {
|
|
|
234
231
|
|
|
235
232
|
var MenuItem = function MenuItem(_ref) {
|
|
236
233
|
var _ref$type = _ref.type,
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
234
|
+
type = _ref$type === void 0 ? MenuItemTypes.DEFAULT : _ref$type,
|
|
235
|
+
_ref$isParent = _ref.isParent,
|
|
236
|
+
isParent = _ref$isParent === void 0 ? false : _ref$isParent,
|
|
237
|
+
_ref$selected = _ref.selected,
|
|
238
|
+
selected = _ref$selected === void 0 ? false : _ref$selected,
|
|
239
|
+
disabled = _ref.disabled,
|
|
240
|
+
children = _ref.children,
|
|
241
|
+
className = _ref.className,
|
|
242
|
+
_ref$navigationState = _ref.navigationState,
|
|
243
|
+
navigationState = _ref$navigationState === void 0 ? {} : _ref$navigationState,
|
|
244
|
+
payload = _ref.payload,
|
|
245
|
+
isLeftOpen = _ref.isLeftOpen,
|
|
246
|
+
onItemChoosed = _ref.onItemChoosed,
|
|
247
|
+
otherProps = _objectWithoutProperties(_ref, ["type", "isParent", "selected", "disabled", "children", "className", "navigationState", "payload", "isLeftOpen", "onItemChoosed"]);
|
|
252
248
|
var withArrowChild = type !== MenuItemTypes.UNSTYLED && isParent;
|
|
253
|
-
|
|
254
249
|
var handleSubmit = function handleSubmit(event) {
|
|
255
250
|
return Boolean(onItemChoosed) && Boolean(payload) && onItemChoosed(payload, event);
|
|
256
251
|
};
|
|
257
|
-
|
|
258
252
|
if (navigationState.isSubmitted) {
|
|
259
253
|
handleSubmit({
|
|
260
254
|
code: navigationState.currentEvent
|
|
261
255
|
});
|
|
262
256
|
}
|
|
263
|
-
|
|
264
257
|
return React.createElement("div", _extends({}, otherProps, {
|
|
265
258
|
onClick: function onClick(event) {
|
|
266
259
|
return otherProps.onClick ? otherProps.onClick(payload, event) : handleSubmit(event);
|
|
@@ -295,80 +288,62 @@ var defaultMenuState = {
|
|
|
295
288
|
};
|
|
296
289
|
var Menu = /*#__PURE__*/function (_React$Component) {
|
|
297
290
|
_inherits(Menu, _React$Component);
|
|
298
|
-
|
|
299
291
|
function Menu(_props) {
|
|
300
292
|
var _this;
|
|
301
|
-
|
|
302
293
|
_classCallCheck(this, Menu);
|
|
303
|
-
|
|
304
294
|
_this = _possibleConstructorReturn(this, _getPrototypeOf(Menu).call(this, _props));
|
|
305
|
-
|
|
306
295
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "isParentMenu", function () {
|
|
307
296
|
return _this.props.enableKeyboardNavigation;
|
|
308
297
|
});
|
|
309
|
-
|
|
310
298
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "isControlledMode", function () {
|
|
311
299
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props;
|
|
312
300
|
return typeof props.open !== 'undefined' && props.open !== null;
|
|
313
301
|
});
|
|
314
|
-
|
|
315
302
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleMenuByParent", function (eventCode) {
|
|
316
303
|
return _this.props.navigationState.onChangeMenuState && _this.props.navigationState.onChangeMenuState(eventCode);
|
|
317
304
|
});
|
|
318
|
-
|
|
319
305
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "handleKeyboard", function (event) {
|
|
320
306
|
var currentMenuState = _this.state.currentMenuState;
|
|
321
307
|
var indexOfLastChildInRow = _this.menuItemsAvailableForNavigation.length - 1;
|
|
322
|
-
|
|
323
308
|
var getNewState = _this.commands(event.code);
|
|
324
|
-
|
|
325
309
|
if (!getNewState || !_this.state.open) {
|
|
326
310
|
return;
|
|
327
311
|
}
|
|
328
|
-
|
|
329
312
|
var newMenuState = getNewState(currentMenuState, {
|
|
330
313
|
minLength: 0,
|
|
331
314
|
maxLength: indexOfLastChildInRow,
|
|
332
315
|
currentEvent: event.code
|
|
333
316
|
});
|
|
334
|
-
|
|
335
317
|
if (!newMenuState || !newMenuState.value) {
|
|
336
318
|
return;
|
|
337
319
|
}
|
|
338
|
-
|
|
339
320
|
_this.setState({
|
|
340
321
|
currentMenuState: newMenuState.value
|
|
341
322
|
}, newMenuState.afterUpdateCallBack);
|
|
342
323
|
});
|
|
343
|
-
|
|
344
324
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getMenuItemsState", function () {
|
|
345
325
|
return React.Children.toArray(_this.props.children).filter(function (_ref) {
|
|
346
326
|
var type = _ref.type;
|
|
347
327
|
return type !== MenuSeparator && type !== MenuTrigger;
|
|
348
328
|
});
|
|
349
329
|
});
|
|
350
|
-
|
|
351
330
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "setOpened", function (open) {
|
|
352
331
|
if (!_this.isControlledMode()) {
|
|
353
332
|
_this.setState({
|
|
354
333
|
open: open
|
|
355
334
|
});
|
|
356
335
|
}
|
|
357
|
-
|
|
358
336
|
if (_this.isParentMenu()) {
|
|
359
337
|
_this.setInitialMenuState(open);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
|
|
338
|
+
}
|
|
339
|
+
// Force clean state, when user navigating by mouse
|
|
363
340
|
if (!open) {
|
|
364
341
|
_this.handleMenuByParent('CloseCurrentMenu');
|
|
365
342
|
}
|
|
366
|
-
|
|
367
343
|
if (_this.props.onSetOpened) {
|
|
368
344
|
_this.props.onSetOpened(open);
|
|
369
345
|
}
|
|
370
346
|
});
|
|
371
|
-
|
|
372
347
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "setInitialMenuState", function (open) {
|
|
373
348
|
return _this.setState(open ? {
|
|
374
349
|
open: open,
|
|
@@ -380,18 +355,15 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
380
355
|
currentMenuState: {}
|
|
381
356
|
});
|
|
382
357
|
});
|
|
383
|
-
|
|
384
358
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getChildren", function () {
|
|
385
359
|
if (!_this.props.enableKeyboardNavigation) {
|
|
386
360
|
return React.Children.toArray(_this.props.children);
|
|
387
361
|
}
|
|
388
|
-
|
|
389
362
|
var counter = 0;
|
|
390
363
|
var currentMenuState = _this.state.currentMenuState;
|
|
391
364
|
var _this$props = _this.props,
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
365
|
+
children = _this$props.children,
|
|
366
|
+
isLeftOpen = _this$props.isLeftOpen;
|
|
395
367
|
var navigationState = _extends({}, currentMenuState, {
|
|
396
368
|
onChangeMenuState: function onChangeMenuState(code) {
|
|
397
369
|
return _this.handleKeyboard({
|
|
@@ -399,16 +371,13 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
399
371
|
});
|
|
400
372
|
}
|
|
401
373
|
});
|
|
402
|
-
|
|
403
374
|
var setAdditionalProps = function setAdditionalProps(element) {
|
|
404
375
|
return isLeftOpen ? React.cloneElement(element, {
|
|
405
376
|
isLeftOpen: isLeftOpen
|
|
406
377
|
}) : element;
|
|
407
378
|
};
|
|
408
|
-
|
|
409
379
|
return React.Children.toArray(children).map(function (child) {
|
|
410
380
|
var element = child;
|
|
411
|
-
|
|
412
381
|
if (child.type !== MenuSeparator && child.type !== MenuTrigger) {
|
|
413
382
|
var isCurrentActiveItem = currentMenuState && currentMenuState.id === counter;
|
|
414
383
|
element = isCurrentActiveItem ? React.cloneElement(child, {
|
|
@@ -417,28 +386,23 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
417
386
|
}) : setAdditionalProps(child);
|
|
418
387
|
counter += 1;
|
|
419
388
|
}
|
|
420
|
-
|
|
421
389
|
return element;
|
|
422
390
|
});
|
|
423
391
|
});
|
|
424
|
-
|
|
425
392
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onOuterAction", function () {
|
|
426
393
|
return _this.props.closeOnOuterAction && _this.setOpened(false);
|
|
427
394
|
});
|
|
428
|
-
|
|
429
395
|
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "prepareTrigger", function (menuChildren) {
|
|
430
396
|
var _this$props2 = _this.props,
|
|
431
|
-
|
|
432
|
-
|
|
397
|
+
isLeftOpen = _this$props2.isLeftOpen,
|
|
398
|
+
navigationState = _this$props2.navigationState;
|
|
433
399
|
var isOpen = _this.isControlledMode() ? _this.props.open : _this.state.open;
|
|
434
400
|
var menuTrigger = menuChildren.find(function (element) {
|
|
435
401
|
return element.type === MenuTrigger;
|
|
436
402
|
});
|
|
437
|
-
|
|
438
403
|
if (!menuTrigger) {
|
|
439
404
|
throw new Error('Trigger not found in Menu children. Did you forget to add <MenuTrigger> to <Menu> ?');
|
|
440
405
|
}
|
|
441
|
-
|
|
442
406
|
var children = menuTrigger.props.children;
|
|
443
407
|
var renderCallbackArgs = {
|
|
444
408
|
isOpen: isOpen,
|
|
@@ -462,16 +426,13 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
462
426
|
getPopoverPosition: getPopoverPosition
|
|
463
427
|
};
|
|
464
428
|
});
|
|
465
|
-
|
|
466
429
|
_this.menuItemsAvailableForNavigation = [];
|
|
467
430
|
_this.state = {
|
|
468
431
|
open: Boolean(_this.props.isOpenInitially),
|
|
469
432
|
currentMenuState: {}
|
|
470
433
|
};
|
|
471
|
-
|
|
472
434
|
_this.commands = function (eventCode) {
|
|
473
435
|
var _config;
|
|
474
|
-
|
|
475
436
|
var config = (_config = {
|
|
476
437
|
Escape: function Escape() {
|
|
477
438
|
return _this.setOpened(false);
|
|
@@ -492,7 +453,7 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
492
453
|
},
|
|
493
454
|
ArrowDown: function ArrowDown(activeMenuItem, _ref3) {
|
|
494
455
|
var maxLength = _ref3.maxLength,
|
|
495
|
-
|
|
456
|
+
currentEvent = _ref3.currentEvent;
|
|
496
457
|
return {
|
|
497
458
|
value: _extends({}, activeMenuItem.isOpenMenu ? _extends({}, activeMenuItem, {
|
|
498
459
|
currentEvent: currentEvent
|
|
@@ -504,7 +465,7 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
504
465
|
},
|
|
505
466
|
ArrowUp: function ArrowUp(activeMenuItem, _ref4) {
|
|
506
467
|
var minLength = _ref4.minLength,
|
|
507
|
-
|
|
468
|
+
currentEvent = _ref4.currentEvent;
|
|
508
469
|
return {
|
|
509
470
|
value: _extends({}, activeMenuItem.isOpenMenu ? _extends({}, activeMenuItem, {
|
|
510
471
|
currentEvent: currentEvent
|
|
@@ -545,25 +506,23 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
545
506
|
isOpenMenu: false
|
|
546
507
|
})
|
|
547
508
|
};
|
|
548
|
-
}), _config);
|
|
549
|
-
// eslint-disable-next-line security/detect-object-injection
|
|
509
|
+
}), _config);
|
|
550
510
|
|
|
511
|
+
// eventCode generated by library here
|
|
512
|
+
// eslint-disable-next-line security/detect-object-injection
|
|
551
513
|
return config[eventCode];
|
|
552
514
|
};
|
|
553
|
-
|
|
554
515
|
return _this;
|
|
555
516
|
}
|
|
517
|
+
|
|
556
518
|
/**
|
|
557
519
|
* LifeCycle Methods
|
|
558
520
|
*/
|
|
559
|
-
|
|
560
|
-
|
|
561
521
|
_createClass(Menu, [{
|
|
562
522
|
key: "componentDidMount",
|
|
563
523
|
value: function componentDidMount() {
|
|
564
524
|
// Assume that children will be passed in sync manner
|
|
565
525
|
this.menuItemsAvailableForNavigation = this.getMenuItemsState();
|
|
566
|
-
|
|
567
526
|
if (this.props.enableKeyboardNavigation) {
|
|
568
527
|
document.addEventListener('keydown', this.handleKeyboard);
|
|
569
528
|
}
|
|
@@ -572,13 +531,12 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
572
531
|
key: "componentWillReceiveProps",
|
|
573
532
|
value: function componentWillReceiveProps(_ref7) {
|
|
574
533
|
var navigationState = _ref7.navigationState;
|
|
575
|
-
|
|
576
534
|
if (this.props.navigationState.isOpenMenu !== navigationState.isOpenMenu) {
|
|
577
535
|
this.setInitialMenuState(navigationState.isOpenMenu);
|
|
578
|
-
}
|
|
579
|
-
// by dispatching `handleKeyboard` manually
|
|
580
|
-
|
|
536
|
+
}
|
|
581
537
|
|
|
538
|
+
// Transfering of control from parent menu to submenu
|
|
539
|
+
// by dispatching `handleKeyboard` manually
|
|
582
540
|
if (Boolean(navigationState.currentEvent) && navigationState.isOpenMenu && this.props.navigationState !== navigationState) {
|
|
583
541
|
this.handleKeyboard({
|
|
584
542
|
code: navigationState.currentEvent
|
|
@@ -592,7 +550,6 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
592
550
|
document.removeEventListener('keydown', this.handleKeyboard);
|
|
593
551
|
}
|
|
594
552
|
} // Assume that only parent menu have this flag
|
|
595
|
-
|
|
596
553
|
}, {
|
|
597
554
|
key: "render",
|
|
598
555
|
value: function render() {
|
|
@@ -601,17 +558,14 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
601
558
|
var menuItems = children.filter(function (element) {
|
|
602
559
|
return element.type !== MenuTrigger;
|
|
603
560
|
});
|
|
604
|
-
|
|
605
561
|
var _this$prepareTrigger = this.prepareTrigger(children),
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
562
|
+
trigger = _this$prepareTrigger.trigger,
|
|
563
|
+
getPopoverPosition = _this$prepareTrigger.getPopoverPosition;
|
|
609
564
|
var renderBody = this.props.renderBody || function (items) {
|
|
610
565
|
return React.createElement(popover.Popover.Body, {
|
|
611
566
|
noPadding: true
|
|
612
567
|
}, items);
|
|
613
568
|
};
|
|
614
|
-
|
|
615
569
|
return React.createElement(popover.Popover, {
|
|
616
570
|
className: styles['menu'],
|
|
617
571
|
isOpen: isOpen,
|
|
@@ -623,7 +577,6 @@ var Menu = /*#__PURE__*/function (_React$Component) {
|
|
|
623
577
|
}, trigger);
|
|
624
578
|
}
|
|
625
579
|
}]);
|
|
626
|
-
|
|
627
580
|
return Menu;
|
|
628
581
|
}(React.Component);
|
|
629
582
|
Menu.defaultProps = {
|
|
@@ -641,7 +594,6 @@ var SubMenu = function SubMenu() {
|
|
|
641
594
|
SubMenu.propTypes = {
|
|
642
595
|
children: PropTypes.any.isRequired
|
|
643
596
|
};
|
|
644
|
-
|
|
645
597
|
var assignKeys = function assignKeys() {
|
|
646
598
|
var reactChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
647
599
|
return reactChildren.map(function (item, index) {
|
|
@@ -650,54 +602,45 @@ var assignKeys = function assignKeys() {
|
|
|
650
602
|
}) : item;
|
|
651
603
|
});
|
|
652
604
|
};
|
|
653
|
-
|
|
654
605
|
var MenuItemWithSubMenu = function MenuItemWithSubMenu(_ref) {
|
|
655
606
|
var open = _ref.open,
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
607
|
+
onSetOpened = _ref.onSetOpened,
|
|
608
|
+
_ref$showOn = _ref.showOn,
|
|
609
|
+
showOn = _ref$showOn === void 0 ? 'hover' : _ref$showOn,
|
|
610
|
+
_ref$hideOn = _ref.hideOn,
|
|
611
|
+
hideOn = _ref$hideOn === void 0 ? 'hover' : _ref$hideOn,
|
|
612
|
+
children = _ref.children,
|
|
613
|
+
menuOffset = _ref.menuOffset,
|
|
614
|
+
otherProps = _objectWithoutProperties(_ref, ["open", "onSetOpened", "showOn", "hideOn", "children", "menuOffset"]);
|
|
665
615
|
var menuItems = [];
|
|
666
616
|
var trigger = [];
|
|
667
617
|
React.Children.toArray(children).forEach(function (item) {
|
|
668
618
|
return item.type === SubMenu ? menuItems.push(item.props.children) : trigger.push(item);
|
|
669
619
|
});
|
|
670
|
-
|
|
671
620
|
var _onClick = function onClick(event, setOpened) {
|
|
672
621
|
if (typeof otherProps.onClick === 'function') {
|
|
673
622
|
otherProps.onClick(event);
|
|
674
623
|
}
|
|
675
|
-
|
|
676
624
|
if (showOn === TriggerTypes.CLICK) {
|
|
677
625
|
setOpened(true);
|
|
678
626
|
}
|
|
679
627
|
};
|
|
680
|
-
|
|
681
628
|
var _onMouseEnter = function onMouseEnter(event, setOpened) {
|
|
682
629
|
if (typeof otherProps.onMouseEnter === 'function') {
|
|
683
630
|
otherProps.onMouseEnter(event);
|
|
684
631
|
}
|
|
685
|
-
|
|
686
632
|
if (showOn === 'hover') {
|
|
687
633
|
setOpened(true);
|
|
688
634
|
}
|
|
689
635
|
};
|
|
690
|
-
|
|
691
636
|
var _onMouseLeave = function onMouseLeave(event, setOpened) {
|
|
692
637
|
if (typeof otherProps.onMouseLeave === 'function') {
|
|
693
638
|
otherProps.onMouseLeave(event);
|
|
694
639
|
}
|
|
695
|
-
|
|
696
640
|
if (hideOn === 'hover') {
|
|
697
641
|
setOpened(false);
|
|
698
642
|
}
|
|
699
643
|
};
|
|
700
|
-
|
|
701
644
|
return React.createElement(Menu, _extends({}, otherProps, {
|
|
702
645
|
appendInline: true,
|
|
703
646
|
relativeToParent: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@targetprocess/menu",
|
|
3
|
-
"version": "12.18.1",
|
|
3
|
+
"version": "12.18.2-alpha.1",
|
|
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.18.1",
|
|
14
|
-
"@targetprocess/popover": "^12.
|
|
13
|
+
"@targetprocess/icons": "^12.18.2-alpha.1",
|
|
14
|
+
"@targetprocess/popover": "^12.18.2-alpha.1",
|
|
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": "a0cbd3034253a0be67c3b03434cb8da591701e70"
|
|
25
25
|
}
|