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,500 @@
|
|
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 _feFilter = _interopRequireDefault(require("../utils/fe-filter"));
|
17
|
+
|
18
|
+
var _FeIcon = _interopRequireDefault(require("./FeIcon"));
|
19
|
+
|
20
|
+
var _FeListItemGroup = _interopRequireDefault(require("./FeListItemGroup"));
|
21
|
+
|
22
|
+
function _interopRequireDefault(obj) {
|
23
|
+
return obj && obj.__esModule ? obj : {
|
24
|
+
default: obj
|
25
|
+
};
|
26
|
+
}
|
27
|
+
|
28
|
+
function _interopRequireWildcard(obj) {
|
29
|
+
if (obj && obj.__esModule) {
|
30
|
+
return obj;
|
31
|
+
} else {
|
32
|
+
var newObj = {};
|
33
|
+
|
34
|
+
if (obj != null) {
|
35
|
+
for (var key in obj) {
|
36
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
37
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
38
|
+
|
39
|
+
if (desc.get || desc.set) {
|
40
|
+
Object.defineProperty(newObj, key, desc);
|
41
|
+
} else {
|
42
|
+
newObj[key] = obj[key];
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
newObj.default = obj;
|
49
|
+
return newObj;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
function _typeof(obj) {
|
54
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
55
|
+
_typeof = function _typeof(obj) {
|
56
|
+
return typeof obj;
|
57
|
+
};
|
58
|
+
} else {
|
59
|
+
_typeof = function _typeof(obj) {
|
60
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
61
|
+
};
|
62
|
+
}
|
63
|
+
|
64
|
+
return _typeof(obj);
|
65
|
+
}
|
66
|
+
|
67
|
+
function _extends() {
|
68
|
+
_extends = Object.assign || function (target) {
|
69
|
+
for (var i = 1; i < arguments.length; i++) {
|
70
|
+
var source = arguments[i];
|
71
|
+
|
72
|
+
for (var key in source) {
|
73
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
74
|
+
target[key] = source[key];
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
return target;
|
80
|
+
};
|
81
|
+
|
82
|
+
return _extends.apply(this, arguments);
|
83
|
+
}
|
84
|
+
|
85
|
+
function _classCallCheck(instance, Constructor) {
|
86
|
+
if (!(instance instanceof Constructor)) {
|
87
|
+
throw new TypeError("Cannot call a class as a function");
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
function _defineProperties(target, props) {
|
92
|
+
for (var i = 0; i < props.length; i++) {
|
93
|
+
var descriptor = props[i];
|
94
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
95
|
+
descriptor.configurable = true;
|
96
|
+
if ("value" in descriptor) descriptor.writable = true;
|
97
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
102
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
103
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
104
|
+
return Constructor;
|
105
|
+
}
|
106
|
+
|
107
|
+
function _possibleConstructorReturn(self, call) {
|
108
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
109
|
+
return call;
|
110
|
+
}
|
111
|
+
|
112
|
+
return _assertThisInitialized(self);
|
113
|
+
}
|
114
|
+
|
115
|
+
function _getPrototypeOf(o) {
|
116
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
117
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
118
|
+
};
|
119
|
+
return _getPrototypeOf(o);
|
120
|
+
}
|
121
|
+
|
122
|
+
function _assertThisInitialized(self) {
|
123
|
+
if (self === void 0) {
|
124
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
125
|
+
}
|
126
|
+
|
127
|
+
return self;
|
128
|
+
}
|
129
|
+
|
130
|
+
function _inherits(subClass, superClass) {
|
131
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
132
|
+
throw new TypeError("Super expression must either be null or a function");
|
133
|
+
}
|
134
|
+
|
135
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
136
|
+
constructor: {
|
137
|
+
value: subClass,
|
138
|
+
writable: true,
|
139
|
+
configurable: true
|
140
|
+
}
|
141
|
+
});
|
142
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
143
|
+
}
|
144
|
+
|
145
|
+
function _setPrototypeOf(o, p) {
|
146
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
147
|
+
o.__proto__ = p;
|
148
|
+
return o;
|
149
|
+
};
|
150
|
+
|
151
|
+
return _setPrototypeOf(o, p);
|
152
|
+
}
|
153
|
+
|
154
|
+
var FeInputField =
|
155
|
+
/*#__PURE__*/
|
156
|
+
function (_Component) {
|
157
|
+
_inherits(FeInputField, _Component);
|
158
|
+
|
159
|
+
function FeInputField(props) {
|
160
|
+
var _this;
|
161
|
+
|
162
|
+
_classCallCheck(this, FeInputField);
|
163
|
+
|
164
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(FeInputField).call(this, props));
|
165
|
+
_this.state = {
|
166
|
+
inputValue: null,
|
167
|
+
icon: null,
|
168
|
+
messageType: null,
|
169
|
+
message: null,
|
170
|
+
isListOpen: false
|
171
|
+
};
|
172
|
+
_this.onChangeHandler = _this.onChangeHandler.bind(_assertThisInitialized(_this));
|
173
|
+
_this.onItemClickHandler = _this.onItemClickHandler.bind(_assertThisInitialized(_this));
|
174
|
+
_this.checkDocumentKeyDown = _this.checkDocumentKeyDown.bind(_assertThisInitialized(_this));
|
175
|
+
_this.handleOutsideClick = _this.handleOutsideClick.bind(_assertThisInitialized(_this));
|
176
|
+
return _this;
|
177
|
+
}
|
178
|
+
|
179
|
+
_createClass(FeInputField, [{
|
180
|
+
key: "componentDidMount",
|
181
|
+
value: function componentDidMount() {
|
182
|
+
if (this.props.isTypeahead) {
|
183
|
+
document.addEventListener('keydown', this.checkDocumentKeyDown, false);
|
184
|
+
document.addEventListener('click', this.handleOutsideClick, false);
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}, {
|
188
|
+
key: "componentWillUnmount",
|
189
|
+
value: function componentWillUnmount() {
|
190
|
+
if (this.props.isTypeahead) {
|
191
|
+
document.removeEventListener('keydown', this.checkDocumentKeyDown);
|
192
|
+
document.removeEventListener('click', this.handleOutsideClick);
|
193
|
+
}
|
194
|
+
}
|
195
|
+
}, {
|
196
|
+
key: "handleOutsideClick",
|
197
|
+
value: function handleOutsideClick(event) {
|
198
|
+
if (this.state.isListOpen && !this.node.contains(event.target)) {
|
199
|
+
this.setState({
|
200
|
+
isListOpen: false
|
201
|
+
});
|
202
|
+
}
|
203
|
+
}
|
204
|
+
}, {
|
205
|
+
key: "checkDocumentKeyDown",
|
206
|
+
value: function checkDocumentKeyDown(event) {
|
207
|
+
if (!this.listContainer || !this.state.isListOpen) {
|
208
|
+
return null;
|
209
|
+
}
|
210
|
+
|
211
|
+
if (event.keyCode === 27) {
|
212
|
+
//Escape
|
213
|
+
this.setState({
|
214
|
+
isListOpen: false
|
215
|
+
});
|
216
|
+
this.restoreFocus();
|
217
|
+
} else if (event.keyCode === 9) {
|
218
|
+
//Tab
|
219
|
+
this.setState({
|
220
|
+
isListOpen: false
|
221
|
+
});
|
222
|
+
} else if (event.keyCode === 40 || event.keyCode === 38) {
|
223
|
+
//ArrowDown || ArrowUp
|
224
|
+
(0, _utils.trapFocus)(event, this.listContainer, true);
|
225
|
+
}
|
226
|
+
}
|
227
|
+
}, {
|
228
|
+
key: "onChangeHandler",
|
229
|
+
value: function onChangeHandler(event) {
|
230
|
+
var inputValue = event.currentTarget.value;
|
231
|
+
|
232
|
+
if (inputValue && this.props.isTypeahead) {
|
233
|
+
this.setState({
|
234
|
+
inputValue: inputValue,
|
235
|
+
isListOpen: true
|
236
|
+
});
|
237
|
+
} else {
|
238
|
+
if (inputValue && this.props.validate) {
|
239
|
+
var _this$props$validate = this.props.validate(inputValue),
|
240
|
+
messageType = _this$props$validate.messageType,
|
241
|
+
message = _this$props$validate.message;
|
242
|
+
|
243
|
+
var icon;
|
244
|
+
|
245
|
+
if (messageType === 'error') {
|
246
|
+
icon = this.props.iconError;
|
247
|
+
} else if (messageType === 'warning') {
|
248
|
+
icon = this.props.iconWarning;
|
249
|
+
} else if (messageType === 'success') {
|
250
|
+
icon = this.props.iconSuccess;
|
251
|
+
} else {
|
252
|
+
messageType = null;
|
253
|
+
message = null;
|
254
|
+
icon = null;
|
255
|
+
}
|
256
|
+
|
257
|
+
this.setState({
|
258
|
+
inputValue: inputValue,
|
259
|
+
messageType: messageType,
|
260
|
+
message: message,
|
261
|
+
icon: icon
|
262
|
+
});
|
263
|
+
} else if (inputValue) {
|
264
|
+
this.setState({
|
265
|
+
inputValue: inputValue
|
266
|
+
});
|
267
|
+
} else {
|
268
|
+
this.setState({
|
269
|
+
messageType: null,
|
270
|
+
message: null,
|
271
|
+
icon: null,
|
272
|
+
inputValue: null,
|
273
|
+
isListOpen: false
|
274
|
+
});
|
275
|
+
}
|
276
|
+
}
|
277
|
+
|
278
|
+
if (this.props.onChange) {
|
279
|
+
this.props.onChange(event);
|
280
|
+
}
|
281
|
+
}
|
282
|
+
}, {
|
283
|
+
key: "onItemClickHandler",
|
284
|
+
value: function onItemClickHandler(event) {
|
285
|
+
var filteredList = this.filterList(this.state.inputValue, this.props.list);
|
286
|
+
var inputValue = filteredList[event.itemIndex]['label'];
|
287
|
+
this.inputNode.value = inputValue;
|
288
|
+
this.restoreFocus();
|
289
|
+
this.setState({
|
290
|
+
inputValue: inputValue,
|
291
|
+
isListOpen: false
|
292
|
+
});
|
293
|
+
}
|
294
|
+
}, {
|
295
|
+
key: "restoreFocus",
|
296
|
+
value: function restoreFocus() {
|
297
|
+
var _this2 = this;
|
298
|
+
|
299
|
+
setTimeout(function () {
|
300
|
+
_this2.inputNode && _this2.inputNode.focus();
|
301
|
+
}, 100);
|
302
|
+
}
|
303
|
+
}, {
|
304
|
+
key: "filterList",
|
305
|
+
value: function filterList(subStr, list) {
|
306
|
+
var config = {
|
307
|
+
queryAt: 'label',
|
308
|
+
isMultiLevel: true,
|
309
|
+
multiLevelKey: 'list'
|
310
|
+
};
|
311
|
+
|
312
|
+
var filteredList = _feFilter.default.filter(subStr, list, config);
|
313
|
+
|
314
|
+
if (filteredList.length === 0) {
|
315
|
+
filteredList = [{
|
316
|
+
label: 'No results found',
|
317
|
+
disabled: true
|
318
|
+
}];
|
319
|
+
}
|
320
|
+
|
321
|
+
return filteredList;
|
322
|
+
}
|
323
|
+
}, {
|
324
|
+
key: "getLabel",
|
325
|
+
value: function getLabel() {
|
326
|
+
return _react.default.createElement("label", {
|
327
|
+
htmlFor: this.props.id,
|
328
|
+
className: "fe-input-label caption"
|
329
|
+
}, this.props.label);
|
330
|
+
}
|
331
|
+
}, {
|
332
|
+
key: "getInput",
|
333
|
+
value: function getInput(filteredList) {
|
334
|
+
var _this3 = this;
|
335
|
+
|
336
|
+
var inputProps = Object.assign({}, this.props);
|
337
|
+
delete inputProps.label;
|
338
|
+
delete inputProps.hint;
|
339
|
+
delete inputProps.isInline;
|
340
|
+
delete inputProps.validate;
|
341
|
+
delete inputProps.onIconClick;
|
342
|
+
delete inputProps.isTypeahead;
|
343
|
+
delete inputProps.list;
|
344
|
+
delete inputProps.listStyle;
|
345
|
+
delete inputProps.icon;
|
346
|
+
delete inputProps.iconError;
|
347
|
+
delete inputProps.iconWarning;
|
348
|
+
delete inputProps.iconSuccess;
|
349
|
+
delete inputProps.className;
|
350
|
+
return _react.default.createElement("input", _extends({
|
351
|
+
type: "text"
|
352
|
+
}, inputProps, {
|
353
|
+
onChange: this.onChangeHandler,
|
354
|
+
className: "fe-input",
|
355
|
+
ref: function ref(node) {
|
356
|
+
return _this3.inputNode = node;
|
357
|
+
}
|
358
|
+
}));
|
359
|
+
}
|
360
|
+
}, {
|
361
|
+
key: "getMessage",
|
362
|
+
value: function getMessage() {
|
363
|
+
var message = this.state.message || this.props.hint;
|
364
|
+
|
365
|
+
if (!message) {
|
366
|
+
return null;
|
367
|
+
}
|
368
|
+
|
369
|
+
return _react.default.createElement("span", {
|
370
|
+
className: "fe-input-hint-text"
|
371
|
+
}, message);
|
372
|
+
}
|
373
|
+
}, {
|
374
|
+
key: "getList",
|
375
|
+
value: function getList(list) {
|
376
|
+
return _react.default.createElement(_FeListItemGroup.default, {
|
377
|
+
feStyle: "dropdown",
|
378
|
+
isSectioned: this.props.listStyle === 'sectioned',
|
379
|
+
textHighlight: this.state.inputValue,
|
380
|
+
list: list,
|
381
|
+
onItemClick: this.onItemClickHandler
|
382
|
+
});
|
383
|
+
}
|
384
|
+
}, {
|
385
|
+
key: "render",
|
386
|
+
value: function render() {
|
387
|
+
var _this4 = this;
|
388
|
+
/** Minimum condition required to render*/
|
389
|
+
|
390
|
+
/** Rendering of component */
|
391
|
+
|
392
|
+
|
393
|
+
var wrapperClass = (0, _classnames.default)({
|
394
|
+
'fe-form__input-wrapper--has-success': this.state.messageType === 'success',
|
395
|
+
'fe-form__input-wrapper--has-warning': this.state.messageType === 'warning',
|
396
|
+
'fe-form__input-wrapper--has-error': this.state.messageType === 'error'
|
397
|
+
}, this.props.className);
|
398
|
+
var filteredList = null;
|
399
|
+
|
400
|
+
if (this.props.isTypeahead && this.state.inputValue && this.state.isListOpen) {
|
401
|
+
filteredList = this.filterList(this.state.inputValue, this.props.list);
|
402
|
+
}
|
403
|
+
|
404
|
+
var label = this.props.label && this.getLabel();
|
405
|
+
var input = this.getInput(filteredList);
|
406
|
+
var message = this.getMessage();
|
407
|
+
var list = filteredList && this.getList(filteredList);
|
408
|
+
var icon = this.state.icon || this.props.icon;
|
409
|
+
|
410
|
+
if (this.props.isTypeahead) {
|
411
|
+
icon = filteredList ? 'chevron-up' : 'chevron-down';
|
412
|
+
}
|
413
|
+
|
414
|
+
return _react.default.createElement("div", {
|
415
|
+
className: wrapperClass,
|
416
|
+
ref: function ref(node) {
|
417
|
+
return _this4.node = node;
|
418
|
+
}
|
419
|
+
}, label, _react.default.createElement("div", {
|
420
|
+
className: "fe-form__input-wrapper--has-icon"
|
421
|
+
}, input, icon ? _react.default.createElement("span", {
|
422
|
+
className: "fe-input-icon",
|
423
|
+
onClick: this.props.onIconClick
|
424
|
+
}, _react.default.createElement(_FeIcon.default, {
|
425
|
+
family: "light",
|
426
|
+
icon: icon
|
427
|
+
})) : null, list && this.props.isTypeahead ? _react.default.createElement("div", {
|
428
|
+
className: "fe-dropdown__list-container fe-dropdown__list--open-bottom-left",
|
429
|
+
ref: function ref(node) {
|
430
|
+
return _this4.listContainer = node;
|
431
|
+
}
|
432
|
+
}, list) : null), message);
|
433
|
+
}
|
434
|
+
}]);
|
435
|
+
|
436
|
+
return FeInputField;
|
437
|
+
}(_react.Component);
|
438
|
+
|
439
|
+
FeInputField.defaultProps = {
|
440
|
+
id: null,
|
441
|
+
label: null,
|
442
|
+
placeholder: '',
|
443
|
+
hint: null,
|
444
|
+
list: null,
|
445
|
+
listStyle: 'multilevel',
|
446
|
+
icon: null,
|
447
|
+
iconError: 'fas fa-exclamation-circle',
|
448
|
+
iconWarning: 'fas fa-exclamation-circle',
|
449
|
+
iconSuccess: 'fas fa-check-circle',
|
450
|
+
isTypeahead: false,
|
451
|
+
validate: null,
|
452
|
+
onIconClick: null,
|
453
|
+
disabled: false
|
454
|
+
};
|
455
|
+
FeInputField.propTypes = {
|
456
|
+
/** Provide id for input field*/
|
457
|
+
id: _propTypes.default.string.isRequired,
|
458
|
+
|
459
|
+
/** Provide label for input field*/
|
460
|
+
label: _propTypes.default.string,
|
461
|
+
|
462
|
+
/** Provide placeholder text for input field*/
|
463
|
+
placeholder: _propTypes.default.string,
|
464
|
+
|
465
|
+
/** Provide hint text*/
|
466
|
+
hint: _propTypes.default.string,
|
467
|
+
|
468
|
+
/** Provide suggestion list[{`FeListItem` props}]*/
|
469
|
+
list: _propTypes.default.array,
|
470
|
+
|
471
|
+
/** Provide list style like 'sectioned' or 'multilevel'*/
|
472
|
+
listStyle: _propTypes.default.oneOf(['sectioned', 'multilevel']),
|
473
|
+
|
474
|
+
/** Provide icon class*/
|
475
|
+
icon: _propTypes.default.string,
|
476
|
+
|
477
|
+
/** Provide icon class for error*/
|
478
|
+
iconError: _propTypes.default.string,
|
479
|
+
|
480
|
+
/** Provide icon class for warning*/
|
481
|
+
iconWarning: _propTypes.default.string,
|
482
|
+
|
483
|
+
/** Provide icon class for success*/
|
484
|
+
iconSuccess: _propTypes.default.string,
|
485
|
+
|
486
|
+
/** set true/false to make typeahead input field*/
|
487
|
+
isTypeahead: _propTypes.default.bool,
|
488
|
+
|
489
|
+
/** Provide handler to validate input*/
|
490
|
+
validate: _propTypes.default.func,
|
491
|
+
|
492
|
+
/** Provide handler on icon clicked*/
|
493
|
+
onIconClick: _propTypes.default.func,
|
494
|
+
|
495
|
+
/** Set true/false to change button disabled state*/
|
496
|
+
disabled: _propTypes.default.bool
|
497
|
+
};
|
498
|
+
FeInputField.displayName = 'FeInputField';
|
499
|
+
var _default = FeInputField;
|
500
|
+
exports.default = _default;
|
@@ -0,0 +1,142 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
9
|
+
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
11
|
+
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
13
|
+
|
14
|
+
var _customPropTypes = require("../../customPropTypes");
|
15
|
+
|
16
|
+
var _FeIcon = _interopRequireDefault(require("./FeIcon"));
|
17
|
+
|
18
|
+
function _interopRequireDefault(obj) {
|
19
|
+
return obj && obj.__esModule ? obj : {
|
20
|
+
default: obj
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
function _objectSpread(target) {
|
25
|
+
for (var i = 1; i < arguments.length; i++) {
|
26
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
27
|
+
var ownKeys = Object.keys(source);
|
28
|
+
|
29
|
+
if (typeof Object.getOwnPropertySymbols === 'function') {
|
30
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
|
31
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
32
|
+
}));
|
33
|
+
}
|
34
|
+
|
35
|
+
ownKeys.forEach(function (key) {
|
36
|
+
_defineProperty(target, key, source[key]);
|
37
|
+
});
|
38
|
+
}
|
39
|
+
|
40
|
+
return target;
|
41
|
+
}
|
42
|
+
|
43
|
+
function _defineProperty(obj, key, value) {
|
44
|
+
if (key in obj) {
|
45
|
+
Object.defineProperty(obj, key, {
|
46
|
+
value: value,
|
47
|
+
enumerable: true,
|
48
|
+
configurable: true,
|
49
|
+
writable: true
|
50
|
+
});
|
51
|
+
} else {
|
52
|
+
obj[key] = value;
|
53
|
+
}
|
54
|
+
|
55
|
+
return obj;
|
56
|
+
}
|
57
|
+
|
58
|
+
function _objectWithoutProperties(source, excluded) {
|
59
|
+
if (source == null) return {};
|
60
|
+
|
61
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
62
|
+
|
63
|
+
var key, i;
|
64
|
+
|
65
|
+
if (Object.getOwnPropertySymbols) {
|
66
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
67
|
+
|
68
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
69
|
+
key = sourceSymbolKeys[i];
|
70
|
+
if (excluded.indexOf(key) >= 0) continue;
|
71
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
72
|
+
target[key] = source[key];
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
return target;
|
77
|
+
}
|
78
|
+
|
79
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
80
|
+
if (source == null) return {};
|
81
|
+
var target = {};
|
82
|
+
var sourceKeys = Object.keys(source);
|
83
|
+
var key, i;
|
84
|
+
|
85
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
86
|
+
key = sourceKeys[i];
|
87
|
+
if (excluded.indexOf(key) >= 0) continue;
|
88
|
+
target[key] = source[key];
|
89
|
+
}
|
90
|
+
|
91
|
+
return target;
|
92
|
+
}
|
93
|
+
|
94
|
+
var FeLabel = function FeLabel(_ref) {
|
95
|
+
var children = _ref.children,
|
96
|
+
icon = _ref.icon,
|
97
|
+
isTransparent = _ref.isTransparent,
|
98
|
+
onClick = _ref.onClick,
|
99
|
+
className = _ref.className,
|
100
|
+
options = _objectWithoutProperties(_ref, ["children", "icon", "isTransparent", "onClick", "className"]);
|
101
|
+
|
102
|
+
var classes = (0, _classnames.default)('fe-label', {
|
103
|
+
'fe-label--icon': icon,
|
104
|
+
'fe-label--background': !isTransparent,
|
105
|
+
'fe-btn': onClick
|
106
|
+
}, className);
|
107
|
+
|
108
|
+
var labelProps = _objectSpread({}, options, {
|
109
|
+
className: classes,
|
110
|
+
onClick: onClick,
|
111
|
+
role: onClick ? 'button' : undefined,
|
112
|
+
tabIndex: onClick ? 0 : undefined
|
113
|
+
});
|
114
|
+
|
115
|
+
return _react.default.createElement("div", labelProps, icon && _react.default.createElement(_FeIcon.default, {
|
116
|
+
icon: icon.name,
|
117
|
+
family: icon.family,
|
118
|
+
className: "fe-label__icon fe-icon--left"
|
119
|
+
}), children);
|
120
|
+
};
|
121
|
+
|
122
|
+
FeLabel.defaultProps = {
|
123
|
+
isTransparent: false
|
124
|
+
};
|
125
|
+
FeLabel.propTypes = {
|
126
|
+
/** The contents for the label (required) */
|
127
|
+
children: _propTypes.default.node.isRequired,
|
128
|
+
|
129
|
+
/** Provide the icon name and family in shape of { name: 'name', family: 'solid' }*/
|
130
|
+
icon: _customPropTypes.iconPropType,
|
131
|
+
|
132
|
+
/** Set true/false to make transparent background*/
|
133
|
+
isTransparent: _propTypes.default.bool,
|
134
|
+
|
135
|
+
/** click event handler */
|
136
|
+
onClick: _propTypes.default.func,
|
137
|
+
|
138
|
+
/** Optional additional CSS classes */
|
139
|
+
className: _propTypes.default.string
|
140
|
+
};
|
141
|
+
var _default = FeLabel;
|
142
|
+
exports.default = _default;
|