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,677 @@
|
|
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 _utils = require("../utils");
|
15
|
+
|
16
|
+
var _helper = require("../utils/helper");
|
17
|
+
|
18
|
+
var _FeSearchField = _interopRequireDefault(require("./FeSearchField"));
|
19
|
+
|
20
|
+
var _FeButton = _interopRequireDefault(require("./FeButton"));
|
21
|
+
|
22
|
+
var _FeCogButton = _interopRequireDefault(require("./FeCogButton"));
|
23
|
+
|
24
|
+
var _FeListItemGroup = _interopRequireDefault(require("./FeListItemGroup"));
|
25
|
+
|
26
|
+
function _interopRequireDefault(obj) {
|
27
|
+
return obj && obj.__esModule ? obj : {
|
28
|
+
default: obj
|
29
|
+
};
|
30
|
+
}
|
31
|
+
|
32
|
+
function _interopRequireWildcard(obj) {
|
33
|
+
if (obj && obj.__esModule) {
|
34
|
+
return obj;
|
35
|
+
} else {
|
36
|
+
var newObj = {};
|
37
|
+
|
38
|
+
if (obj != null) {
|
39
|
+
for (var key in obj) {
|
40
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
41
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
42
|
+
|
43
|
+
if (desc.get || desc.set) {
|
44
|
+
Object.defineProperty(newObj, key, desc);
|
45
|
+
} else {
|
46
|
+
newObj[key] = obj[key];
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
newObj.default = obj;
|
53
|
+
return newObj;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
function _typeof(obj) {
|
58
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
59
|
+
_typeof = function _typeof(obj) {
|
60
|
+
return typeof obj;
|
61
|
+
};
|
62
|
+
} else {
|
63
|
+
_typeof = function _typeof(obj) {
|
64
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
65
|
+
};
|
66
|
+
}
|
67
|
+
|
68
|
+
return _typeof(obj);
|
69
|
+
}
|
70
|
+
|
71
|
+
function _defineProperty(obj, key, value) {
|
72
|
+
if (key in obj) {
|
73
|
+
Object.defineProperty(obj, key, {
|
74
|
+
value: value,
|
75
|
+
enumerable: true,
|
76
|
+
configurable: true,
|
77
|
+
writable: true
|
78
|
+
});
|
79
|
+
} else {
|
80
|
+
obj[key] = value;
|
81
|
+
}
|
82
|
+
|
83
|
+
return obj;
|
84
|
+
}
|
85
|
+
|
86
|
+
function _extends() {
|
87
|
+
_extends = Object.assign || function (target) {
|
88
|
+
for (var i = 1; i < arguments.length; i++) {
|
89
|
+
var source = arguments[i];
|
90
|
+
|
91
|
+
for (var key in source) {
|
92
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
93
|
+
target[key] = source[key];
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
return target;
|
99
|
+
};
|
100
|
+
|
101
|
+
return _extends.apply(this, arguments);
|
102
|
+
}
|
103
|
+
|
104
|
+
function _classCallCheck(instance, Constructor) {
|
105
|
+
if (!(instance instanceof Constructor)) {
|
106
|
+
throw new TypeError("Cannot call a class as a function");
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
function _defineProperties(target, props) {
|
111
|
+
for (var i = 0; i < props.length; i++) {
|
112
|
+
var descriptor = props[i];
|
113
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
114
|
+
descriptor.configurable = true;
|
115
|
+
if ("value" in descriptor) descriptor.writable = true;
|
116
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
121
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
122
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
123
|
+
return Constructor;
|
124
|
+
}
|
125
|
+
|
126
|
+
function _possibleConstructorReturn(self, call) {
|
127
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
128
|
+
return call;
|
129
|
+
}
|
130
|
+
|
131
|
+
return _assertThisInitialized(self);
|
132
|
+
}
|
133
|
+
|
134
|
+
function _getPrototypeOf(o) {
|
135
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
136
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
137
|
+
};
|
138
|
+
return _getPrototypeOf(o);
|
139
|
+
}
|
140
|
+
|
141
|
+
function _assertThisInitialized(self) {
|
142
|
+
if (self === void 0) {
|
143
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
144
|
+
}
|
145
|
+
|
146
|
+
return self;
|
147
|
+
}
|
148
|
+
|
149
|
+
function _inherits(subClass, superClass) {
|
150
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
151
|
+
throw new TypeError("Super expression must either be null or a function");
|
152
|
+
}
|
153
|
+
|
154
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
155
|
+
constructor: {
|
156
|
+
value: subClass,
|
157
|
+
writable: true,
|
158
|
+
configurable: true
|
159
|
+
}
|
160
|
+
});
|
161
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
162
|
+
}
|
163
|
+
|
164
|
+
function _setPrototypeOf(o, p) {
|
165
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
166
|
+
o.__proto__ = p;
|
167
|
+
return o;
|
168
|
+
};
|
169
|
+
|
170
|
+
return _setPrototypeOf(o, p);
|
171
|
+
}
|
172
|
+
|
173
|
+
var FeDropdown =
|
174
|
+
/*#__PURE__*/
|
175
|
+
function (_Component) {
|
176
|
+
_inherits(FeDropdown, _Component);
|
177
|
+
|
178
|
+
function FeDropdown(props) {
|
179
|
+
var _this;
|
180
|
+
|
181
|
+
_classCallCheck(this, FeDropdown);
|
182
|
+
|
183
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(FeDropdown).call(this, props));
|
184
|
+
_this.state = {
|
185
|
+
isOpen: false,
|
186
|
+
itemIndex: null,
|
187
|
+
filteredList: null,
|
188
|
+
isSelectBox: _this.props.feType === 'single-select' || _this.props.feType === 'multi-select'
|
189
|
+
};
|
190
|
+
_this.toggleDropdown = _this.toggleDropdown.bind(_assertThisInitialized(_this));
|
191
|
+
_this.onItemClick = _this.onItemClick.bind(_assertThisInitialized(_this));
|
192
|
+
_this.onFilterHandler = _this.onFilterHandler.bind(_assertThisInitialized(_this));
|
193
|
+
_this.onBack = _this.onBack.bind(_assertThisInitialized(_this));
|
194
|
+
_this.handleOutsideClick = _this.handleOutsideClick.bind(_assertThisInitialized(_this));
|
195
|
+
_this.checkDocumentKeyDown = _this.checkDocumentKeyDown.bind(_assertThisInitialized(_this));
|
196
|
+
return _this;
|
197
|
+
}
|
198
|
+
|
199
|
+
_createClass(FeDropdown, [{
|
200
|
+
key: "getCurrentList",
|
201
|
+
value: function getCurrentList() {
|
202
|
+
var itemIndex = this.state.itemIndex;
|
203
|
+
|
204
|
+
if (itemIndex == null) {
|
205
|
+
return this.props.list;
|
206
|
+
} else {
|
207
|
+
return this.props.list[itemIndex]['list'];
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}, {
|
211
|
+
key: "componentDidMount",
|
212
|
+
value: function componentDidMount() {
|
213
|
+
document.addEventListener('click', this.handleOutsideClick, false); //add keydown event
|
214
|
+
|
215
|
+
document.addEventListener('keydown', this.checkDocumentKeyDown);
|
216
|
+
}
|
217
|
+
}, {
|
218
|
+
key: "componentWillUnmount",
|
219
|
+
value: function componentWillUnmount() {
|
220
|
+
document.removeEventListener('click', this.handleOutsideClick, false); //remove keydown event
|
221
|
+
|
222
|
+
document.removeEventListener('keydown', this.checkDocumentKeyDown);
|
223
|
+
}
|
224
|
+
}, {
|
225
|
+
key: "checkDocumentKeyDown",
|
226
|
+
value: function checkDocumentKeyDown(event) {
|
227
|
+
if (!this.state.isOpen) {
|
228
|
+
return false;
|
229
|
+
}
|
230
|
+
|
231
|
+
if (event.keyCode === 27 && this.props.onEscapeClose) {
|
232
|
+
//Escape
|
233
|
+
this.toggleDropdown(event);
|
234
|
+
this.restoreFocus();
|
235
|
+
} else if (event.keyCode === 9) {
|
236
|
+
//Tab
|
237
|
+
this.toggleDropdown(event);
|
238
|
+
} else if (event.keyCode === 40 || event.keyCode === 38) {
|
239
|
+
//ArrowDown || ArrowUp
|
240
|
+
(0, _utils.trapFocus)(event, this.listContainer, true);
|
241
|
+
}
|
242
|
+
}
|
243
|
+
}, {
|
244
|
+
key: "handleOutsideClick",
|
245
|
+
value: function handleOutsideClick(event) {
|
246
|
+
if (this.state.isOpen && !this.node.contains(event.target)) {
|
247
|
+
this.setState({
|
248
|
+
isOpen: false,
|
249
|
+
itemIndex: null,
|
250
|
+
filteredList: null
|
251
|
+
});
|
252
|
+
this.searchField && this.clearSearchField();
|
253
|
+
|
254
|
+
if (this.props.onToggleDropdown) {
|
255
|
+
this.props.onToggleDropdown({
|
256
|
+
originalEvent: event,
|
257
|
+
isOpen: false
|
258
|
+
});
|
259
|
+
}
|
260
|
+
} else {
|
261
|
+
return;
|
262
|
+
}
|
263
|
+
}
|
264
|
+
}, {
|
265
|
+
key: "toggleDropdown",
|
266
|
+
value: function toggleDropdown(event) {
|
267
|
+
var isOpen = this.state.isOpen;
|
268
|
+
this.setState({
|
269
|
+
isOpen: !isOpen,
|
270
|
+
itemIndex: null,
|
271
|
+
filteredList: null
|
272
|
+
});
|
273
|
+
|
274
|
+
if (this.props.onToggleDropdown) {
|
275
|
+
this.props.onToggleDropdown({
|
276
|
+
originalEvent: event,
|
277
|
+
isOpen: !isOpen
|
278
|
+
});
|
279
|
+
}
|
280
|
+
}
|
281
|
+
}, {
|
282
|
+
key: "onBack",
|
283
|
+
value: function onBack(event) {
|
284
|
+
this.setState({
|
285
|
+
itemIndex: null,
|
286
|
+
filteredList: null
|
287
|
+
});
|
288
|
+
this.searchField && this.clearSearchField();
|
289
|
+
}
|
290
|
+
}, {
|
291
|
+
key: "onFilterHandler",
|
292
|
+
value: function onFilterHandler(event) {
|
293
|
+
this.setState({
|
294
|
+
filteredList: event.list
|
295
|
+
});
|
296
|
+
}
|
297
|
+
}, {
|
298
|
+
key: "clearSearchField",
|
299
|
+
value: function clearSearchField() {
|
300
|
+
this.searchField.clear();
|
301
|
+
}
|
302
|
+
}, {
|
303
|
+
key: "onItemClick",
|
304
|
+
value: function onItemClick(event) {
|
305
|
+
(0, _helper.stopPropagation)(event.originalEvent);
|
306
|
+
var hasSubItems = event.hasSubItems,
|
307
|
+
itemIndex = event.itemIndex,
|
308
|
+
subItemIndex = event.subItemIndex,
|
309
|
+
originalEvent = event.originalEvent;
|
310
|
+
var activeIds = this.props.activeIds; //setting item index
|
311
|
+
|
312
|
+
if (this.state.itemIndex) {
|
313
|
+
itemIndex = this.state.itemIndex;
|
314
|
+
subItemIndex = event.itemIndex;
|
315
|
+
}
|
316
|
+
|
317
|
+
var shouldClose = !hasSubItems && !this.state.isSelectBox;
|
318
|
+
var params = Object.assign({}, {
|
319
|
+
originalEvent: originalEvent,
|
320
|
+
itemIndex: itemIndex,
|
321
|
+
subItemIndex: subItemIndex,
|
322
|
+
hasSubItems: hasSubItems
|
323
|
+
});
|
324
|
+
|
325
|
+
if (this.props.feType === 'multi-select') {
|
326
|
+
var item = event.originalEvent.currentTarget.id || this.props.idAttribute && event.originalEvent.currentTarget[this.props.idAttribute];
|
327
|
+
var index = -1;
|
328
|
+
|
329
|
+
if (item && activeIds) {
|
330
|
+
index = activeIds.indexOf(item);
|
331
|
+
}
|
332
|
+
|
333
|
+
if (index < 0 && item) {
|
334
|
+
activeIds = activeIds || [];
|
335
|
+
activeIds.push(item);
|
336
|
+
} else if (index > -1) {
|
337
|
+
activeIds.splice(index, 1);
|
338
|
+
}
|
339
|
+
|
340
|
+
params['activeIds'] = activeIds && activeIds.length ? activeIds : null;
|
341
|
+
}
|
342
|
+
|
343
|
+
if (this.props.feType === 'single-select') {
|
344
|
+
params['activeId'] = event.originalEvent.currentTarget.id || this.props.idAttribute && event.originalEvent.currentTarget[this.props.idAttribute];
|
345
|
+
}
|
346
|
+
|
347
|
+
this.setState({
|
348
|
+
itemIndex: event.hasSubItems ? event.itemIndex : null,
|
349
|
+
filteredList: null,
|
350
|
+
isOpen: !shouldClose
|
351
|
+
});
|
352
|
+
this.searchField && this.clearSearchField();
|
353
|
+
|
354
|
+
if (this.props.onItemClick) {
|
355
|
+
params['otherProps'] = this.getOtherProps();
|
356
|
+
this.props.onItemClick(params);
|
357
|
+
}
|
358
|
+
|
359
|
+
shouldClose && this.restoreFocus(event.originalEvent);
|
360
|
+
}
|
361
|
+
}, {
|
362
|
+
key: "restoreFocus",
|
363
|
+
value: function restoreFocus(event) {
|
364
|
+
var element;
|
365
|
+
|
366
|
+
if (this.props.referId) {
|
367
|
+
element = document.getElementById(this.props.referId);
|
368
|
+
} else {
|
369
|
+
element = this.node.getElementsByClassName('fe-dropdown__toggle')[0];
|
370
|
+
}
|
371
|
+
|
372
|
+
setTimeout(function () {
|
373
|
+
element && element.focus();
|
374
|
+
}, 200);
|
375
|
+
}
|
376
|
+
}, {
|
377
|
+
key: "getSearch",
|
378
|
+
value: function getSearch() {
|
379
|
+
var _this2 = this;
|
380
|
+
|
381
|
+
return _react.default.createElement(_FeSearchField.default, {
|
382
|
+
feBackground: "light",
|
383
|
+
ref: function ref(node) {
|
384
|
+
return _this2.searchField = node;
|
385
|
+
},
|
386
|
+
list: this.getCurrentList(),
|
387
|
+
queryAt: "label",
|
388
|
+
isMultiLevel: this.props.feStyle === 'sectioned',
|
389
|
+
multiLevelKey: "list",
|
390
|
+
onChange: this.onFilterHandler
|
391
|
+
});
|
392
|
+
}
|
393
|
+
}, {
|
394
|
+
key: "getBack",
|
395
|
+
value: function getBack() {
|
396
|
+
var className = (0, _classnames.default)({
|
397
|
+
'hide': this.state.itemIndex == null
|
398
|
+
});
|
399
|
+
var ariaAttributes = {
|
400
|
+
'aria-label': 'back to mainitem'
|
401
|
+
};
|
402
|
+
return _react.default.createElement(_FeButton.default, _extends({
|
403
|
+
type: "button",
|
404
|
+
feStyle: "link",
|
405
|
+
className: className,
|
406
|
+
icon: "arrow-alt-circle-left",
|
407
|
+
iconPosition: "left"
|
408
|
+
}, ariaAttributes, {
|
409
|
+
disabled: this.state.itemIndex == null,
|
410
|
+
onClick: this.onBack
|
411
|
+
}), "Back");
|
412
|
+
}
|
413
|
+
}, {
|
414
|
+
key: "getSelectedLabel",
|
415
|
+
value: function getSelectedLabel() {
|
416
|
+
if (this.props.activeItemIndex && !this.props.activeSubItemIndex) {
|
417
|
+
return this.props.list[this.props.activeItemIndex]['label'] || null;
|
418
|
+
} else if (this.props.activeItemIndex && this.props.activeSubItemIndex) {
|
419
|
+
return this.props.list[this.props.activeItemIndex]['list'][this.props.activeSubItemIndex]['label'] || null;
|
420
|
+
}
|
421
|
+
|
422
|
+
return null;
|
423
|
+
}
|
424
|
+
}, {
|
425
|
+
key: "getOtherProps",
|
426
|
+
value: function getOtherProps() {
|
427
|
+
var params = Object.assign({}, this.props);
|
428
|
+
delete params.referId;
|
429
|
+
delete params.feStyle;
|
430
|
+
delete params.feType;
|
431
|
+
delete params.idAttribute;
|
432
|
+
delete params.buttonStyle;
|
433
|
+
delete params.iconSelect;
|
434
|
+
delete params.iconMultiLevel;
|
435
|
+
delete params.list;
|
436
|
+
delete params.position;
|
437
|
+
delete params.role;
|
438
|
+
delete params.active;
|
439
|
+
delete params.activeId;
|
440
|
+
delete params.activeIds;
|
441
|
+
delete params.activeItemIndex;
|
442
|
+
delete params.activeSubItemIndex;
|
443
|
+
delete params.withSearch;
|
444
|
+
delete params.textHighlight;
|
445
|
+
delete params.isOpen;
|
446
|
+
delete params.onItemClick;
|
447
|
+
delete params.onToggleDropdown;
|
448
|
+
delete params.onIconRighClick;
|
449
|
+
delete params.onEscapeClose;
|
450
|
+
delete params.className;
|
451
|
+
delete params.customRenderLink;
|
452
|
+
delete params.children;
|
453
|
+
delete params.route;
|
454
|
+
delete params.isNavLink;
|
455
|
+
return params;
|
456
|
+
}
|
457
|
+
}, {
|
458
|
+
key: "getLabel",
|
459
|
+
value: function getLabel() {
|
460
|
+
var buttonProps = this.getOtherProps();
|
461
|
+
|
462
|
+
if (this.props.label) {
|
463
|
+
buttonProps.label = this.state.isSelectBox && this.getSelectedLabel() || this.props.label;
|
464
|
+
buttonProps.icon = this.state.isOpen ? 'chevron-up' : 'chevron-down';
|
465
|
+
buttonProps.iconFamily = 'light';
|
466
|
+
buttonProps.iconPosition = 'right';
|
467
|
+
}
|
468
|
+
|
469
|
+
if (this.props.buttonStyle === 'cog') {
|
470
|
+
return _react.default.createElement(_FeCogButton.default, _extends({}, buttonProps, {
|
471
|
+
className: "fe-dropdown__toggle",
|
472
|
+
active: this.props.active || this.state.isOpen,
|
473
|
+
onClick: this.toggleDropdown
|
474
|
+
}));
|
475
|
+
}
|
476
|
+
|
477
|
+
return _react.default.createElement(_FeButton.default, _extends({}, buttonProps, {
|
478
|
+
className: "fe-dropdown__toggle",
|
479
|
+
feStyle: this.props.buttonStyle,
|
480
|
+
active: this.props.active || this.state.isOpen,
|
481
|
+
onClick: this.toggleDropdown
|
482
|
+
}), buttonProps.label);
|
483
|
+
}
|
484
|
+
}, {
|
485
|
+
key: "render",
|
486
|
+
value: function render() {
|
487
|
+
var _this3 = this;
|
488
|
+
/** Minimum condition required to render*/
|
489
|
+
|
490
|
+
|
491
|
+
if (!this.props.list.length && !this.props.children) {
|
492
|
+
return null;
|
493
|
+
}
|
494
|
+
/** Rendering of component */
|
495
|
+
|
496
|
+
|
497
|
+
var dropdownClass = (0, _classnames.default)('fe-dropdown', this.props.className);
|
498
|
+
var containerClassName = (0, _classnames.default)('fe-dropdown__list-container', _defineProperty({}, "fe-dropdown__list--open-".concat(this.props.position), this.props.position && this.state.isOpen));
|
499
|
+
var search = this.props.list.length > 0 && this.props.withSearch && this.getSearch();
|
500
|
+
var button = this.getLabel();
|
501
|
+
var back = this.props.list.length > 0 && this.props.feStyle !== 'sectioned' && this.getBack();
|
502
|
+
var list = this.state.filteredList || this.getCurrentList();
|
503
|
+
var iconRight = this.props.feType === 'menu' || this.state.isSelectBox ? this.props.iconSelect : null;
|
504
|
+
var activeItemIndex = this.state.itemIndex ? this.props.activeSubItemIndex : this.props.activeItemIndex;
|
505
|
+
var wrapperClass = (0, _classnames.default)({
|
506
|
+
'fe-dropdown__list--is-sectioned': this.props.feStyle === 'sectioned' && list.length
|
507
|
+
}); //Aria Attributes
|
508
|
+
|
509
|
+
var ariaAttributes = {};
|
510
|
+
|
511
|
+
if (this.props.id || this.props.referId) {
|
512
|
+
ariaAttributes = {
|
513
|
+
'aria-labelledby': "".concat(this.props.id || this.props.referId),
|
514
|
+
'role': this.props.role
|
515
|
+
};
|
516
|
+
} else {
|
517
|
+
ariaAttributes = {
|
518
|
+
'aria-label': "".concat(this.props.label || 'dropdown', " items"),
|
519
|
+
'role': this.props.role
|
520
|
+
};
|
521
|
+
}
|
522
|
+
|
523
|
+
return _react.default.createElement("div", {
|
524
|
+
className: dropdownClass,
|
525
|
+
ref: function ref(node) {
|
526
|
+
return _this3.node = node;
|
527
|
+
},
|
528
|
+
style: this.props.style
|
529
|
+
}, button, _react.default.createElement("div", {
|
530
|
+
className: containerClassName,
|
531
|
+
ref: function ref(listContainer) {
|
532
|
+
return _this3.listContainer = listContainer;
|
533
|
+
}
|
534
|
+
}, search || back || this.props.children ? _react.default.createElement("div", {
|
535
|
+
className: wrapperClass
|
536
|
+
}, this.props.children, search, back) : null, _react.default.createElement(_FeListItemGroup.default, _extends({
|
537
|
+
feStyle: "dropdown",
|
538
|
+
list: list,
|
539
|
+
iconRight: iconRight,
|
540
|
+
activeItemIndex: this.props.feType !== 'default' ? activeItemIndex : null,
|
541
|
+
iconMultiLevel: this.props.iconMultiLevel,
|
542
|
+
activeSubItemIndex: this.props.feType !== 'default' ? this.props.activeSubItemIndex : null,
|
543
|
+
onItemClick: this.onItemClick,
|
544
|
+
onIconRighClick: this.props.onIconRighClick,
|
545
|
+
isSectioned: this.props.feStyle === 'sectioned',
|
546
|
+
idAttribute: this.props.idAttribute,
|
547
|
+
activeIds: this.props.activeIds,
|
548
|
+
activeId: this.props.activeId,
|
549
|
+
textHighlight: this.props.textHighlight,
|
550
|
+
customRenderLink: this.props.customRenderLink
|
551
|
+
}, ariaAttributes))));
|
552
|
+
}
|
553
|
+
}], [{
|
554
|
+
key: "getDerivedStateFromProps",
|
555
|
+
value: function getDerivedStateFromProps(props, state) {
|
556
|
+
if (props.isOpen !== null) {
|
557
|
+
return {
|
558
|
+
isOpen: props.isOpen,
|
559
|
+
isSelectBox: props.feType === 'single-select' || props.feType === 'multi-select'
|
560
|
+
};
|
561
|
+
}
|
562
|
+
|
563
|
+
return null;
|
564
|
+
}
|
565
|
+
}]);
|
566
|
+
|
567
|
+
return FeDropdown;
|
568
|
+
}(_react.Component);
|
569
|
+
|
570
|
+
FeDropdown.defaultProps = {
|
571
|
+
referId: null,
|
572
|
+
feStyle: 'multilevel',
|
573
|
+
feType: 'default',
|
574
|
+
label: null,
|
575
|
+
idAttribute: null,
|
576
|
+
buttonStyle: 'primary',
|
577
|
+
size: 'md',
|
578
|
+
role: 'listbox',
|
579
|
+
list: [],
|
580
|
+
position: 'bottom-left',
|
581
|
+
iconSelect: 'fas fa-check',
|
582
|
+
iconMultiLevel: 'fa fa-angle-right',
|
583
|
+
active: false,
|
584
|
+
activeItemIndex: null,
|
585
|
+
activeSubItemIndex: null,
|
586
|
+
activeId: null,
|
587
|
+
activeIds: null,
|
588
|
+
textHighlight: null,
|
589
|
+
isOpen: null,
|
590
|
+
onEscapeClose: true,
|
591
|
+
withSearch: false,
|
592
|
+
onItemClick: null,
|
593
|
+
onToggleDropdown: null,
|
594
|
+
onIconRighClick: null,
|
595
|
+
customRenderLink: null
|
596
|
+
};
|
597
|
+
FeDropdown.propTypes = {
|
598
|
+
/** Provide referId if label isn't provided*/
|
599
|
+
referId: _propTypes.default.string,
|
600
|
+
|
601
|
+
/** 'sectioned', 'multilevel'*/
|
602
|
+
feStyle: _propTypes.default.oneOf(['sectioned', 'multilevel']),
|
603
|
+
|
604
|
+
/** 'default', 'menu', 'single-select', 'multi-select'*/
|
605
|
+
feType: _propTypes.default.oneOf(['default', 'menu', 'single-select', 'multi-select']),
|
606
|
+
|
607
|
+
/** Provide idAttribute for dropdown list items*/
|
608
|
+
idAttribute: _propTypes.default.string,
|
609
|
+
|
610
|
+
/** Provide label for dropdown button*/
|
611
|
+
label: _propTypes.default.string,
|
612
|
+
|
613
|
+
/** Provide button variants like 'primary', 'primary-link', 'secondary', 'secondary-link', 'danger', 'danger-link'*/
|
614
|
+
buttonStyle: _propTypes.default.oneOf(['primary', 'primary-danger', 'secondary', 'secondary-danger', 'link', 'link-secondary', 'link-danger', 'cog']),
|
615
|
+
|
616
|
+
/** Provide button size like 'sm', 'md', 'lg' for small, medium and large respectively*/
|
617
|
+
size: _propTypes.default.oneOf(['sm', 'md', 'lg']),
|
618
|
+
|
619
|
+
/** Provide role for dropdown*/
|
620
|
+
role: _propTypes.default.string,
|
621
|
+
|
622
|
+
/** Provide list[{`FeListItem` props}] for dropdown*/
|
623
|
+
list: _propTypes.default.arrayOf(_propTypes.default.object),
|
624
|
+
|
625
|
+
/** Provide popup position*/
|
626
|
+
position: _propTypes.default.string,
|
627
|
+
|
628
|
+
/** Provide icon class*/
|
629
|
+
iconSelect: _propTypes.default.string,
|
630
|
+
|
631
|
+
/** Provide icon class*/
|
632
|
+
iconMultiLevel: _propTypes.default.string,
|
633
|
+
|
634
|
+
/** Provide icon class*/
|
635
|
+
active: _propTypes.default.bool,
|
636
|
+
|
637
|
+
/** Provide item index to set active*/
|
638
|
+
activeItemIndex: _propTypes.default.string,
|
639
|
+
|
640
|
+
/** Provide subitem index to set active*/
|
641
|
+
activeSubItemIndex: _propTypes.default.string,
|
642
|
+
|
643
|
+
/** Provide active ids*/
|
644
|
+
activeId: _propTypes.default.string,
|
645
|
+
|
646
|
+
/** Provide active ids*/
|
647
|
+
activeIds: _propTypes.default.array,
|
648
|
+
|
649
|
+
/** Provide substring to highlight*/
|
650
|
+
textHighlight: _propTypes.default.string,
|
651
|
+
|
652
|
+
/** Set true/false to enable searchField*/
|
653
|
+
withSearch: _propTypes.default.bool,
|
654
|
+
|
655
|
+
/** Set true/false to toggle dropdown*/
|
656
|
+
isOpen: _propTypes.default.bool,
|
657
|
+
|
658
|
+
/** Set true/false to toggle escape close*/
|
659
|
+
onEscapeClose: _propTypes.default.bool,
|
660
|
+
|
661
|
+
/** Provide item click handler for dropdown items*/
|
662
|
+
onItemClick: _propTypes.default.func,
|
663
|
+
|
664
|
+
/** Provide toggle handler for dropdown*/
|
665
|
+
onToggleDropdown: _propTypes.default.func,
|
666
|
+
|
667
|
+
/** Provide icon right click handler for dropdown items*/
|
668
|
+
onIconRighClick: _propTypes.default.func,
|
669
|
+
|
670
|
+
/** A function that returns a react element to render the wrapping link.
|
671
|
+
* Will receive url, className, and children props
|
672
|
+
*/
|
673
|
+
customRenderLink: _propTypes.default.func
|
674
|
+
};
|
675
|
+
FeDropdown.displayName = 'FeDropdown';
|
676
|
+
var _default = FeDropdown;
|
677
|
+
exports.default = _default;
|