fe-fabric-react 0.0.1-security → 2.864.3
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.
Potentially problematic release.
This version of fe-fabric-react might be problematic. Click here for more details.
- package/build.js +40 -0
- package/lib/core/FontAwesomeContext.js +126 -0
- package/lib/core/components/FeAppLogo.js +54 -0
- package/lib/core/components/FeAvatar.js +314 -0
- package/lib/core/components/FeBadge.js +177 -0
- package/lib/core/components/FeBreadcrumb.js +205 -0
- package/lib/core/components/FeButton.js +185 -0
- package/lib/core/components/FeCheckbox.js +91 -0
- package/lib/core/components/FeCogButton.js +204 -0
- package/lib/core/components/FeDefaultLink.js +108 -0
- package/lib/core/components/FeDropdown.js +677 -0
- package/lib/core/components/FeFormGroup.js +245 -0
- package/lib/core/components/FeIcon.js +52 -0
- package/lib/core/components/FeIconStack.js +26 -0
- package/lib/core/components/FeInputField.js +500 -0
- package/lib/core/components/FeLabel.js +142 -0
- package/lib/core/components/FeListItem.js +719 -0
- package/lib/core/components/FeListItemGroup.js +364 -0
- package/lib/core/components/FeLoader.js +69 -0
- package/lib/core/components/FeNotification.js +351 -0
- package/lib/core/components/FePillBox.js +353 -0
- package/lib/core/components/FeProgressBar.js +282 -0
- package/lib/core/components/FeRadioButton.js +234 -0
- package/lib/core/components/FeSearchField.js +322 -0
- package/lib/core/components/FeSelfContainedInput.js +215 -0
- package/lib/core/components/FeTableCell.js +27 -0
- package/lib/core/components/FeTableHeaderCell.js +273 -0
- package/lib/core/components/FeTableRow.js +24 -0
- package/lib/core/components/FeTextEnrichment.js +78 -0
- package/lib/core/components/FeToggle.js +69 -0
- package/lib/core/index.js +243 -0
- package/lib/core/utils/aria-role.js +11 -0
- package/lib/core/utils/fe-filter.js +157 -0
- package/lib/core/utils/helper.js +11 -0
- package/lib/core/utils/index.js +268 -0
- package/lib/customPropTypes.js +51 -0
- package/lib/fe-filter/FeFilter.js +1312 -0
- package/lib/fe-filter/index.js +17 -0
- package/lib/fe-footer/FeFooter.js +81 -0
- package/lib/fe-footer/index.js +17 -0
- package/lib/fe-hero/FeHero.js +192 -0
- package/lib/fe-hero/index.js +17 -0
- package/lib/fe-modal/FeModal.js +409 -0
- package/lib/fe-modal/index.js +17 -0
- package/lib/fe-notifications/FeNotifications.js +235 -0
- package/lib/fe-notifications/index.js +17 -0
- package/lib/fe-pagination/FePagination.js +688 -0
- package/lib/fe-pagination/index.js +17 -0
- package/lib/fe-panel/FePanel.js +282 -0
- package/lib/fe-panel/index.js +17 -0
- package/lib/fe-sidenav/FeSideNav.js +78 -0
- package/lib/fe-sidenav/FeSideNavList.js +346 -0
- package/lib/fe-sidenav/index.js +17 -0
- package/lib/fe-table/FeTable.js +703 -0
- package/lib/fe-table/index.js +17 -0
- package/lib/fe-topnav/FeTopNav.js +110 -0
- package/lib/fe-topnav/FeTopNavList.js +401 -0
- package/lib/fe-topnav/index.js +17 -0
- package/lib/index.js +129 -0
- package/lib/layout/Col.js +187 -0
- package/lib/layout/Container.js +97 -0
- package/lib/layout/Row.js +99 -0
- package/lib/layout/index.js +35 -0
- package/package.json +42 -4
- package/README.md +0 -5
@@ -0,0 +1,719 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
9
|
+
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
11
|
+
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
13
|
+
|
14
|
+
var _toNumber = _interopRequireDefault(require("lodash/toNumber"));
|
15
|
+
|
16
|
+
var _helper = require("../utils/helper");
|
17
|
+
|
18
|
+
var _ariaRole = require("../utils/aria-role");
|
19
|
+
|
20
|
+
var _utils = require("../utils");
|
21
|
+
|
22
|
+
var _FeIcon = _interopRequireDefault(require("./FeIcon"));
|
23
|
+
|
24
|
+
var _FeBadge = _interopRequireDefault(require("./FeBadge"));
|
25
|
+
|
26
|
+
var _FeListItemGroup = _interopRequireDefault(require("./FeListItemGroup"));
|
27
|
+
|
28
|
+
var _FeDefaultLink = _interopRequireDefault(require("./FeDefaultLink"));
|
29
|
+
|
30
|
+
function _interopRequireDefault(obj) {
|
31
|
+
return obj && obj.__esModule ? obj : {
|
32
|
+
default: obj
|
33
|
+
};
|
34
|
+
}
|
35
|
+
|
36
|
+
function _interopRequireWildcard(obj) {
|
37
|
+
if (obj && obj.__esModule) {
|
38
|
+
return obj;
|
39
|
+
} else {
|
40
|
+
var newObj = {};
|
41
|
+
|
42
|
+
if (obj != null) {
|
43
|
+
for (var key in obj) {
|
44
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
45
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
46
|
+
|
47
|
+
if (desc.get || desc.set) {
|
48
|
+
Object.defineProperty(newObj, key, desc);
|
49
|
+
} else {
|
50
|
+
newObj[key] = obj[key];
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
newObj.default = obj;
|
57
|
+
return newObj;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
function _typeof(obj) {
|
62
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
63
|
+
_typeof = function _typeof(obj) {
|
64
|
+
return typeof obj;
|
65
|
+
};
|
66
|
+
} else {
|
67
|
+
_typeof = function _typeof(obj) {
|
68
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
69
|
+
};
|
70
|
+
}
|
71
|
+
|
72
|
+
return _typeof(obj);
|
73
|
+
}
|
74
|
+
|
75
|
+
function _extends() {
|
76
|
+
_extends = Object.assign || function (target) {
|
77
|
+
for (var i = 1; i < arguments.length; i++) {
|
78
|
+
var source = arguments[i];
|
79
|
+
|
80
|
+
for (var key in source) {
|
81
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
82
|
+
target[key] = source[key];
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
return target;
|
88
|
+
};
|
89
|
+
|
90
|
+
return _extends.apply(this, arguments);
|
91
|
+
}
|
92
|
+
|
93
|
+
function _defineProperty(obj, key, value) {
|
94
|
+
if (key in obj) {
|
95
|
+
Object.defineProperty(obj, key, {
|
96
|
+
value: value,
|
97
|
+
enumerable: true,
|
98
|
+
configurable: true,
|
99
|
+
writable: true
|
100
|
+
});
|
101
|
+
} else {
|
102
|
+
obj[key] = value;
|
103
|
+
}
|
104
|
+
|
105
|
+
return obj;
|
106
|
+
}
|
107
|
+
|
108
|
+
function _classCallCheck(instance, Constructor) {
|
109
|
+
if (!(instance instanceof Constructor)) {
|
110
|
+
throw new TypeError("Cannot call a class as a function");
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
function _defineProperties(target, props) {
|
115
|
+
for (var i = 0; i < props.length; i++) {
|
116
|
+
var descriptor = props[i];
|
117
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
118
|
+
descriptor.configurable = true;
|
119
|
+
if ("value" in descriptor) descriptor.writable = true;
|
120
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
125
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
126
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
127
|
+
return Constructor;
|
128
|
+
}
|
129
|
+
|
130
|
+
function _possibleConstructorReturn(self, call) {
|
131
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
132
|
+
return call;
|
133
|
+
}
|
134
|
+
|
135
|
+
return _assertThisInitialized(self);
|
136
|
+
}
|
137
|
+
|
138
|
+
function _getPrototypeOf(o) {
|
139
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
140
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
141
|
+
};
|
142
|
+
return _getPrototypeOf(o);
|
143
|
+
}
|
144
|
+
|
145
|
+
function _assertThisInitialized(self) {
|
146
|
+
if (self === void 0) {
|
147
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
148
|
+
}
|
149
|
+
|
150
|
+
return self;
|
151
|
+
}
|
152
|
+
|
153
|
+
function _inherits(subClass, superClass) {
|
154
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
155
|
+
throw new TypeError("Super expression must either be null or a function");
|
156
|
+
}
|
157
|
+
|
158
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
159
|
+
constructor: {
|
160
|
+
value: subClass,
|
161
|
+
writable: true,
|
162
|
+
configurable: true
|
163
|
+
}
|
164
|
+
});
|
165
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
166
|
+
}
|
167
|
+
|
168
|
+
function _setPrototypeOf(o, p) {
|
169
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
170
|
+
o.__proto__ = p;
|
171
|
+
return o;
|
172
|
+
};
|
173
|
+
|
174
|
+
return _setPrototypeOf(o, p);
|
175
|
+
}
|
176
|
+
|
177
|
+
var FeListItem =
|
178
|
+
/*#__PURE__*/
|
179
|
+
function (_Component) {
|
180
|
+
_inherits(FeListItem, _Component);
|
181
|
+
|
182
|
+
function FeListItem(props) {
|
183
|
+
var _this;
|
184
|
+
|
185
|
+
_classCallCheck(this, FeListItem);
|
186
|
+
|
187
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(FeListItem).call(this, props));
|
188
|
+
_this.onClickHandler = _this.onClickHandler.bind(_assertThisInitialized(_this));
|
189
|
+
_this.onIconRighClickHandler = _this.onIconRighClickHandler.bind(_assertThisInitialized(_this));
|
190
|
+
_this.onMouseEnterHandler = _this.onMouseEnterHandler.bind(_assertThisInitialized(_this));
|
191
|
+
_this.onMouseLeaveHandler = _this.onMouseLeaveHandler.bind(_assertThisInitialized(_this));
|
192
|
+
_this.onSubItemClickHandler = _this.onSubItemClickHandler.bind(_assertThisInitialized(_this));
|
193
|
+
_this.onSubItemIconRighClickHandler = _this.onSubItemIconRighClickHandler.bind(_assertThisInitialized(_this));
|
194
|
+
_this.onSubItemHoverHandler = _this.onSubItemHoverHandler.bind(_assertThisInitialized(_this));
|
195
|
+
return _this;
|
196
|
+
}
|
197
|
+
|
198
|
+
_createClass(FeListItem, [{
|
199
|
+
key: "getBadgeCount",
|
200
|
+
value: function getBadgeCount() {
|
201
|
+
//badge value is getting calculated for one level deep.
|
202
|
+
var count = this.props.badgeLabel || 0;
|
203
|
+
|
204
|
+
if (!count && this.props.list) {
|
205
|
+
this.props.list.forEach(function (_ref) {
|
206
|
+
var badgeLabel = _ref.badgeLabel,
|
207
|
+
disabled = _ref.disabled;
|
208
|
+
|
209
|
+
if (!disabled && (0, _toNumber.default)(badgeLabel)) {
|
210
|
+
count += (0, _toNumber.default)(badgeLabel);
|
211
|
+
}
|
212
|
+
});
|
213
|
+
}
|
214
|
+
|
215
|
+
return count ? count : null;
|
216
|
+
}
|
217
|
+
}, {
|
218
|
+
key: "isActive",
|
219
|
+
value: function isActive() {
|
220
|
+
var _this2 = this;
|
221
|
+
|
222
|
+
var active = this.props.active;
|
223
|
+
|
224
|
+
if (!active && this.props.activeId) {
|
225
|
+
active = this.props[this.props.idAttribute] === this.props.activeId;
|
226
|
+
}
|
227
|
+
|
228
|
+
if (!active && this.props.activeIds) {
|
229
|
+
var index; //check for item id
|
230
|
+
|
231
|
+
if (this.props[this.props.idAttribute]) {
|
232
|
+
index = this.props.activeIds.indexOf(this.props[this.props.idAttribute]);
|
233
|
+
|
234
|
+
if (index < 0 && this.props.list.length) {
|
235
|
+
//check for subitems
|
236
|
+
this.props.list.forEach(function (item) {
|
237
|
+
index = _this2.props.activeIds.indexOf(item[_this2.props.idAttribute]);
|
238
|
+
|
239
|
+
if (index > -1) {
|
240
|
+
return;
|
241
|
+
}
|
242
|
+
});
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
active = index > -1;
|
247
|
+
}
|
248
|
+
|
249
|
+
return active;
|
250
|
+
}
|
251
|
+
}, {
|
252
|
+
key: "getLeftContent",
|
253
|
+
value: function getLeftContent() {
|
254
|
+
return _react.default.createElement("span", {
|
255
|
+
className: "fe-".concat(this.props.feStyle, "__item-link-left-section")
|
256
|
+
}, _react.default.createElement(_FeIcon.default, {
|
257
|
+
family: this.props.iconFamily,
|
258
|
+
icon: this.props.icon
|
259
|
+
}));
|
260
|
+
}
|
261
|
+
}, {
|
262
|
+
key: "getLabel",
|
263
|
+
value: function getLabel() {
|
264
|
+
if (!this.props.disabled && this.props.textHighlight) {
|
265
|
+
var label = (0, _utils.textHighlight)(this.props.textHighlight, this.props.label);
|
266
|
+
return _react.default.createElement("span", {
|
267
|
+
className: "fe-".concat(this.props.feStyle, "__item-link-text"),
|
268
|
+
dangerouslySetInnerHTML: {
|
269
|
+
__html: label
|
270
|
+
}
|
271
|
+
});
|
272
|
+
}
|
273
|
+
|
274
|
+
return _react.default.createElement("span", {
|
275
|
+
className: "fe-".concat(this.props.feStyle, "__item-link-text")
|
276
|
+
}, this.props.label);
|
277
|
+
}
|
278
|
+
}, {
|
279
|
+
key: "getRightContent",
|
280
|
+
value: function getRightContent() {
|
281
|
+
var _this3 = this;
|
282
|
+
|
283
|
+
var badgeCount = !this.props.disabled && this.getBadgeCount();
|
284
|
+
var iconRight = this.props.iconRight;
|
285
|
+
|
286
|
+
if (this.props.list && this.props.list.length && this.props.withDropIcon) {
|
287
|
+
iconRight = this.props.expanded ? this.props.iconExpand : this.props.iconCollapse;
|
288
|
+
}
|
289
|
+
|
290
|
+
if (!badgeCount && !iconRight) {
|
291
|
+
return null;
|
292
|
+
}
|
293
|
+
|
294
|
+
var className = (0, _classnames.default)("fe-".concat(this.props.feStyle, "__icon-gutter"), _defineProperty({}, "fe-".concat(this.props.feStyle, "__icon-multilevel"), this.props.list.length > 0));
|
295
|
+
var iconRightAttributes = {};
|
296
|
+
|
297
|
+
if (this.props.onIconRighClick) {
|
298
|
+
iconRightAttributes = {
|
299
|
+
role: 'button',
|
300
|
+
tabIndex: '-1',
|
301
|
+
onClick: this.onIconRighClickHandler,
|
302
|
+
onKeyDown: function onKeyDown(event) {
|
303
|
+
if (event.keyCode === 13) {
|
304
|
+
//Enter
|
305
|
+
_this3.onIconRighClickHandler(event);
|
306
|
+
}
|
307
|
+
}
|
308
|
+
};
|
309
|
+
}
|
310
|
+
|
311
|
+
return _react.default.createElement("span", {
|
312
|
+
className: "fe-".concat(this.props.feStyle, "__item-link-right-section")
|
313
|
+
}, _react.default.createElement(_FeBadge.default, {
|
314
|
+
feStyle: this.props.badgeStyle,
|
315
|
+
label: "".concat(badgeCount || ''),
|
316
|
+
max: this.props.badgeMax
|
317
|
+
}), _react.default.createElement("span", _extends({
|
318
|
+
className: className
|
319
|
+
}, iconRightAttributes), _react.default.createElement(_FeIcon.default, {
|
320
|
+
family: this.props.iconRightFamily,
|
321
|
+
icon: iconRight
|
322
|
+
})));
|
323
|
+
}
|
324
|
+
}, {
|
325
|
+
key: "getMainItem",
|
326
|
+
value: function getMainItem() {
|
327
|
+
var _classNames2;
|
328
|
+
|
329
|
+
var className = (0, _classnames.default)("fe-".concat(this.props.feStyle, "__item-link"), (_classNames2 = {}, _defineProperty(_classNames2, "fe-".concat(this.props.feStyle, "__item-link--active"), this.isActive()), _defineProperty(_classNames2, "fe-".concat(this.props.feStyle, "__item-link--has-sub-item"), this.props.list && this.props.list.length), _defineProperty(_classNames2, "fe-".concat(this.props.feStyle, "__item-link--expanded"), this.props.expanded), _defineProperty(_classNames2, "fe-".concat(this.props.feStyle, "__item-link--disabled"), this.props.disabled), _classNames2));
|
330
|
+
var leftContent = this.props.icon && this.getLeftContent();
|
331
|
+
var label = !this.props.children && this.getLabel();
|
332
|
+
var rightContent = this.getRightContent(); //Aria attributes
|
333
|
+
|
334
|
+
var ariaProps = {};
|
335
|
+
var id = this.props.id || this.props.idAttribute && this.props[this.props.idAttribute] || null;
|
336
|
+
|
337
|
+
if (id) {
|
338
|
+
ariaProps['id'] = id;
|
339
|
+
}
|
340
|
+
|
341
|
+
if (this.props.list && this.props.list.length) {
|
342
|
+
ariaProps['aria-haspopup'] = 'true';
|
343
|
+
}
|
344
|
+
|
345
|
+
if (this.props.list && this.props.list.length && this.props.expanded) {
|
346
|
+
ariaProps['aria-expanded'] = 'true';
|
347
|
+
}
|
348
|
+
|
349
|
+
if (this.props.feStyle === 'dropdown') {
|
350
|
+
ariaProps['tabIndex'] = '-1';
|
351
|
+
ariaProps['role'] = this.props.role || 'option';
|
352
|
+
} //Other attributes
|
353
|
+
|
354
|
+
|
355
|
+
var wrapperProps = Object.assign({}, this.props);
|
356
|
+
delete wrapperProps.label;
|
357
|
+
delete wrapperProps.icon;
|
358
|
+
delete wrapperProps.iconRight;
|
359
|
+
delete wrapperProps.iconCollapse;
|
360
|
+
delete wrapperProps.iconExpand;
|
361
|
+
delete wrapperProps.badgeLabel;
|
362
|
+
delete wrapperProps.badgeStyle;
|
363
|
+
delete wrapperProps.badgeMax;
|
364
|
+
delete wrapperProps.textHighlight;
|
365
|
+
delete wrapperProps.list;
|
366
|
+
delete wrapperProps.isHashRoute;
|
367
|
+
delete wrapperProps.idAttribute;
|
368
|
+
delete wrapperProps.itemIndex;
|
369
|
+
delete wrapperProps.isSectioned;
|
370
|
+
delete wrapperProps.activeId;
|
371
|
+
delete wrapperProps.activeIds;
|
372
|
+
delete wrapperProps.active;
|
373
|
+
delete wrapperProps.activeItemIndex;
|
374
|
+
delete wrapperProps.expanded;
|
375
|
+
delete wrapperProps.onClick;
|
376
|
+
delete wrapperProps.onIconRighClick;
|
377
|
+
delete wrapperProps.onMouseEnter;
|
378
|
+
delete wrapperProps.groupClickHandler;
|
379
|
+
delete wrapperProps.groupIconRighClickHandler;
|
380
|
+
delete wrapperProps.groupHoverHandler;
|
381
|
+
delete wrapperProps.withDropIcon;
|
382
|
+
return _react.default.createElement(Wrapper, _extends({}, wrapperProps, ariaProps, {
|
383
|
+
className: className,
|
384
|
+
onClick: this.onClickHandler,
|
385
|
+
onMouseEnter: this.onMouseEnterHandler,
|
386
|
+
onMouseLeave: this.onMouseLeaveHandler
|
387
|
+
}), leftContent, label, this.props.children, rightContent);
|
388
|
+
}
|
389
|
+
}, {
|
390
|
+
key: "getSectionedItem",
|
391
|
+
value: function getSectionedItem() {
|
392
|
+
var _classNames3;
|
393
|
+
|
394
|
+
var className = (0, _classnames.default)("fe-".concat(this.props.feStyle, "__item-link"), (_classNames3 = {}, _defineProperty(_classNames3, "fe-".concat(this.props.feStyle, "__item-link--active"), this.isActive()), _defineProperty(_classNames3, "fe-".concat(this.props.feStyle, "__item-link--expanded"), this.props.expanded), _defineProperty(_classNames3, "fe-".concat(this.props.feStyle, "__item-link--disabled"), this.props.disabled), _defineProperty(_classNames3, "fe-".concat(this.props.feStyle, "__item-link-header"), this.props.isSectioned), _classNames3)); //Aria attributes
|
395
|
+
|
396
|
+
var ariaProps = {
|
397
|
+
'aria-haspopup': 'true',
|
398
|
+
'aria-expanded': "".concat(this.props.expanded ? true : false)
|
399
|
+
};
|
400
|
+
var id = this.props.id || this.props.idAttribute && this.props[this.props.idAttribute] || null;
|
401
|
+
|
402
|
+
if (id) {
|
403
|
+
ariaProps['id'] = id;
|
404
|
+
}
|
405
|
+
|
406
|
+
return _react.default.createElement("a", _extends({}, ariaProps, {
|
407
|
+
className: className
|
408
|
+
}), _react.default.createElement("span", {
|
409
|
+
className: "fe-".concat(this.props.feStyle, "__item-link-text")
|
410
|
+
}, this.props.label));
|
411
|
+
}
|
412
|
+
}, {
|
413
|
+
key: "getSublists",
|
414
|
+
value: function getSublists() {
|
415
|
+
//Aria attributes
|
416
|
+
var ariaProps = {
|
417
|
+
'role': (0, _ariaRole.getRole)(this.props.role) || 'listbox'
|
418
|
+
};
|
419
|
+
var id = this.props.id || this.props.idAttribute && this.props[this.props.idAttribute] || null;
|
420
|
+
|
421
|
+
if (id) {
|
422
|
+
ariaProps['aria-labelledby'] = id;
|
423
|
+
} else {
|
424
|
+
ariaProps['aria-label'] = this.props.label;
|
425
|
+
}
|
426
|
+
|
427
|
+
return _react.default.createElement(_FeListItemGroup.default, _extends({}, ariaProps, {
|
428
|
+
iconRight: this.props.iconRight,
|
429
|
+
feStyle: this.props.feStyle,
|
430
|
+
isSublist: true,
|
431
|
+
activeParent: this.isActive(),
|
432
|
+
activeItemIndex: this.props.activeItemIndex,
|
433
|
+
list: this.props.list,
|
434
|
+
activeId: this.props.activeId,
|
435
|
+
activeIds: this.props.activeIds,
|
436
|
+
idAttribute: this.props.idAttribute,
|
437
|
+
onItemClick: this.onSubItemClickHandler,
|
438
|
+
textHighlight: this.props.textHighlight,
|
439
|
+
onIconRighClick: this.onSubItemIconRighClickHandler,
|
440
|
+
onItemHover: this.onSubItemHoverHandler,
|
441
|
+
customRenderLink: this.props.customRenderLink
|
442
|
+
}));
|
443
|
+
}
|
444
|
+
}, {
|
445
|
+
key: "onClickHandler",
|
446
|
+
value: function onClickHandler(event) {
|
447
|
+
if (this.props.onClick) {
|
448
|
+
this.props.onClick({
|
449
|
+
originalEvent: event,
|
450
|
+
itemIndex: this.props.itemIndex,
|
451
|
+
item: this.props.id || this.props.idAttribute && this.props[this.props.idAttribute],
|
452
|
+
hasSubItems: this.props.list.length > 0
|
453
|
+
});
|
454
|
+
}
|
455
|
+
|
456
|
+
if (this.props.groupClickHandler) {
|
457
|
+
this.props.groupClickHandler({
|
458
|
+
originalEvent: event,
|
459
|
+
itemIndex: this.props.itemIndex,
|
460
|
+
item: this.props.id || this.props.idAttribute && this.props[this.props.idAttribute],
|
461
|
+
hasSubItems: this.props.list.length > 0
|
462
|
+
});
|
463
|
+
}
|
464
|
+
}
|
465
|
+
}, {
|
466
|
+
key: "onIconRighClickHandler",
|
467
|
+
value: function onIconRighClickHandler(event) {
|
468
|
+
(0, _helper.stopPropagation)(event);
|
469
|
+
|
470
|
+
if (this.props.onIconRighClick) {
|
471
|
+
this.props.onIconRighClick({
|
472
|
+
originalEvent: event,
|
473
|
+
itemIndex: this.props.itemIndex,
|
474
|
+
item: this.props.id || this.props.idAttribute && this.props[this.props.idAttribute],
|
475
|
+
hasSubItems: this.props.list.length > 0
|
476
|
+
});
|
477
|
+
}
|
478
|
+
|
479
|
+
if (this.props.groupIconRighClickHandler) {
|
480
|
+
this.props.groupIconRighClickHandler({
|
481
|
+
originalEvent: event,
|
482
|
+
itemIndex: this.props.itemIndex,
|
483
|
+
item: this.props.id || this.props.idAttribute && this.props[this.props.idAttribute],
|
484
|
+
hasSubItems: this.props.list.length > 0
|
485
|
+
});
|
486
|
+
}
|
487
|
+
}
|
488
|
+
}, {
|
489
|
+
key: "onMouseEnterHandler",
|
490
|
+
value: function onMouseEnterHandler(event) {
|
491
|
+
if (this.props.onMouseEnter) {
|
492
|
+
this.props.onMouseEnter({
|
493
|
+
originalEvent: event,
|
494
|
+
itemIndex: this.props.itemIndex,
|
495
|
+
hasSubItems: this.props.list.length > 0
|
496
|
+
});
|
497
|
+
}
|
498
|
+
|
499
|
+
if (this.props.groupHoverHandler) {
|
500
|
+
this.props.groupHoverHandler({
|
501
|
+
originalEvent: event,
|
502
|
+
eventType: 'mouseenter',
|
503
|
+
itemIndex: this.props.itemIndex,
|
504
|
+
hasSubItems: this.props.list.length > 0
|
505
|
+
});
|
506
|
+
}
|
507
|
+
}
|
508
|
+
}, {
|
509
|
+
key: "onMouseLeaveHandler",
|
510
|
+
value: function onMouseLeaveHandler(event) {
|
511
|
+
if (this.props.onMouseLeave) {
|
512
|
+
this.props.onMouseEnter({
|
513
|
+
originalEvent: event,
|
514
|
+
itemIndex: this.props.itemIndex,
|
515
|
+
hasSubItems: this.props.list.length > 0
|
516
|
+
});
|
517
|
+
}
|
518
|
+
|
519
|
+
if (this.props.groupHoverHandler) {
|
520
|
+
this.props.groupHoverHandler({
|
521
|
+
originalEvent: event,
|
522
|
+
eventType: 'mouseleave',
|
523
|
+
itemIndex: this.props.itemIndex,
|
524
|
+
hasSubItems: this.props.list.length > 0
|
525
|
+
});
|
526
|
+
}
|
527
|
+
}
|
528
|
+
}, {
|
529
|
+
key: "onSubItemClickHandler",
|
530
|
+
value: function onSubItemClickHandler(event) {
|
531
|
+
var originalEvent = event.originalEvent,
|
532
|
+
itemIndex = event.itemIndex,
|
533
|
+
item = event.item;
|
534
|
+
|
535
|
+
if (this.props.groupClickHandler) {
|
536
|
+
this.props.groupClickHandler({
|
537
|
+
originalEvent: originalEvent,
|
538
|
+
item: item,
|
539
|
+
itemIndex: this.props.itemIndex,
|
540
|
+
subItemIndex: itemIndex
|
541
|
+
});
|
542
|
+
}
|
543
|
+
}
|
544
|
+
}, {
|
545
|
+
key: "onSubItemIconRighClickHandler",
|
546
|
+
value: function onSubItemIconRighClickHandler(event) {
|
547
|
+
var originalEvent = event.originalEvent,
|
548
|
+
itemIndex = event.itemIndex,
|
549
|
+
item = event.item;
|
550
|
+
|
551
|
+
if (this.props.groupIconRighClickHandler) {
|
552
|
+
this.props.groupIconRighClickHandler({
|
553
|
+
originalEvent: originalEvent,
|
554
|
+
item: item,
|
555
|
+
itemIndex: this.props.itemIndex,
|
556
|
+
subItemIndex: itemIndex
|
557
|
+
});
|
558
|
+
}
|
559
|
+
}
|
560
|
+
}, {
|
561
|
+
key: "onSubItemHoverHandler",
|
562
|
+
value: function onSubItemHoverHandler(event) {
|
563
|
+
var originalEvent = event.originalEvent,
|
564
|
+
eventType = event.eventType,
|
565
|
+
itemIndex = event.itemIndex;
|
566
|
+
|
567
|
+
if (this.props.groupHoverHandler) {
|
568
|
+
this.props.groupHoverHandler({
|
569
|
+
originalEvent: originalEvent,
|
570
|
+
eventType: eventType,
|
571
|
+
itemIndex: this.props.itemIndex,
|
572
|
+
subItemIndex: itemIndex
|
573
|
+
});
|
574
|
+
}
|
575
|
+
}
|
576
|
+
}, {
|
577
|
+
key: "render",
|
578
|
+
value: function render() {
|
579
|
+
/** Minimum condition required to render*/
|
580
|
+
if (!this.props.label && !this.props.children) {
|
581
|
+
return null;
|
582
|
+
}
|
583
|
+
/** Rendering of component */
|
584
|
+
|
585
|
+
|
586
|
+
var className = (0, _classnames.default)("fe-".concat(this.props.feStyle, "__item"), _defineProperty({}, "fe-".concat(this.props.feStyle, "__item-section-header"), this.props.isSectioned), this.props.className);
|
587
|
+
var mainItem = this.props.isSectioned && this.props.list.length ? this.getSectionedItem() : this.getMainItem();
|
588
|
+
var subLists = !(this.props.feStyle === 'dropdown' && !this.props.isSectioned) && this.props.list && this.getSublists();
|
589
|
+
return _react.default.createElement("li", {
|
590
|
+
className: className
|
591
|
+
}, mainItem, subLists);
|
592
|
+
}
|
593
|
+
}]);
|
594
|
+
|
595
|
+
return FeListItem;
|
596
|
+
}(_react.Component);
|
597
|
+
|
598
|
+
var Wrapper = function Wrapper(props) {
|
599
|
+
var buttonProps = Object.assign({}, props);
|
600
|
+
delete buttonProps.href;
|
601
|
+
delete buttonProps.route;
|
602
|
+
delete buttonProps.feStyle;
|
603
|
+
delete buttonProps.customRenderLink;
|
604
|
+
|
605
|
+
if ((props.route || props.href) && !props.disabled) {
|
606
|
+
var Link = props.customRenderLink || _FeDefaultLink.default;
|
607
|
+
return _react.default.createElement(Link, {
|
608
|
+
route: props.route,
|
609
|
+
isNavLink: true,
|
610
|
+
href: props.href,
|
611
|
+
additionalProps: buttonProps,
|
612
|
+
activeClassName: "fe-".concat(props.feStyle, "__item-link--active")
|
613
|
+
}, props.children);
|
614
|
+
} else {
|
615
|
+
if (props.disabled) {
|
616
|
+
delete buttonProps.onClick;
|
617
|
+
delete buttonProps.onMouseEnter;
|
618
|
+
delete buttonProps.onMouseLeave;
|
619
|
+
}
|
620
|
+
|
621
|
+
return _react.default.createElement("button", _extends({
|
622
|
+
type: "button"
|
623
|
+
}, buttonProps), props.children);
|
624
|
+
}
|
625
|
+
};
|
626
|
+
|
627
|
+
FeListItem.defaultProps = {
|
628
|
+
feStyle: 'list',
|
629
|
+
label: null,
|
630
|
+
route: null,
|
631
|
+
href: null,
|
632
|
+
isHashRoute: false,
|
633
|
+
badgeLabel: null,
|
634
|
+
badgeStyle: 'alert',
|
635
|
+
badgeMax: null,
|
636
|
+
textHighlight: null,
|
637
|
+
idAttribute: 'id',
|
638
|
+
list: [],
|
639
|
+
activeId: null,
|
640
|
+
activeIds: null,
|
641
|
+
activeItemIndex: null,
|
642
|
+
withDropIcon: false,
|
643
|
+
active: false,
|
644
|
+
disabled: false,
|
645
|
+
onIconRighClick: null,
|
646
|
+
customRenderLink: null
|
647
|
+
};
|
648
|
+
FeListItem.propTypes = {
|
649
|
+
/** Provide list variants like "list" or "dropdown"*/
|
650
|
+
feStyle: _propTypes.default.oneOf(['list', 'dropdown']),
|
651
|
+
|
652
|
+
/** Provide label for list item*/
|
653
|
+
label: _propTypes.default.string.isRequired,
|
654
|
+
|
655
|
+
/** Provide route for list item*/
|
656
|
+
route: _propTypes.default.string,
|
657
|
+
|
658
|
+
/** Provide href for list item*/
|
659
|
+
href: _propTypes.default.string,
|
660
|
+
|
661
|
+
/** set true/false if href/route contains hash value*/
|
662
|
+
isHashRoute: _propTypes.default.bool,
|
663
|
+
|
664
|
+
/** Provide icon name for the left icon*/
|
665
|
+
icon: _propTypes.default.string,
|
666
|
+
|
667
|
+
/** Provide icon family for the left icon*/
|
668
|
+
iconFamily: _propTypes.default.string,
|
669
|
+
|
670
|
+
/** Provide icon class for the right icon */
|
671
|
+
iconRight: _propTypes.default.string,
|
672
|
+
|
673
|
+
/** Provide icon family for the right icon */
|
674
|
+
iconRightFamily: _propTypes.default.string,
|
675
|
+
|
676
|
+
/** Provide badge label*/
|
677
|
+
badgeLabel: _propTypes.default.string,
|
678
|
+
|
679
|
+
/** Provide badge variants like 'default', 'alert', 'count-only', 'inline-count'*/
|
680
|
+
badgeStyle: _propTypes.default.oneOf(['default', 'alert', 'count-only', 'inline-count']),
|
681
|
+
|
682
|
+
/** Provide max count for badge*/
|
683
|
+
badgeMax: _propTypes.default.number,
|
684
|
+
|
685
|
+
/** Provide substring to highlight*/
|
686
|
+
textHighlight: _propTypes.default.string,
|
687
|
+
|
688
|
+
/** Provide idAttribute for list item if id attributes is not passes and other attribute can be assumed as id and same for subitems*/
|
689
|
+
idAttribute: _propTypes.default.string,
|
690
|
+
|
691
|
+
/** Provide subitem list*/
|
692
|
+
list: _propTypes.default.arrayOf(_propTypes.default.object),
|
693
|
+
|
694
|
+
/** Provide active id*/
|
695
|
+
activeId: _propTypes.default.string,
|
696
|
+
|
697
|
+
/** Provide active ids*/
|
698
|
+
activeIds: _propTypes.default.array,
|
699
|
+
|
700
|
+
/** Provide subitem index to set active*/
|
701
|
+
activeItemIndex: _propTypes.default.string,
|
702
|
+
|
703
|
+
/** Set true/false to change list item active state*/
|
704
|
+
active: _propTypes.default.bool,
|
705
|
+
|
706
|
+
/** Set true/false to change list item disabled state*/
|
707
|
+
disabled: _propTypes.default.bool,
|
708
|
+
|
709
|
+
/** Provide handler for right icon click*/
|
710
|
+
onIconRighClick: _propTypes.default.func,
|
711
|
+
|
712
|
+
/** A function that returns a react element to render the wrapping link.
|
713
|
+
* Will receive url, className, and children props
|
714
|
+
*/
|
715
|
+
customRenderLink: _propTypes.default.func
|
716
|
+
};
|
717
|
+
FeListItem.displayName = 'FeListItem';
|
718
|
+
var _default = FeListItem;
|
719
|
+
exports.default = _default;
|