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,351 @@
|
|
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 _FeIcon = _interopRequireDefault(require("./FeIcon"));
|
15
|
+
|
16
|
+
function _interopRequireDefault(obj) {
|
17
|
+
return obj && obj.__esModule ? obj : {
|
18
|
+
default: obj
|
19
|
+
};
|
20
|
+
}
|
21
|
+
|
22
|
+
function _interopRequireWildcard(obj) {
|
23
|
+
if (obj && obj.__esModule) {
|
24
|
+
return obj;
|
25
|
+
} else {
|
26
|
+
var newObj = {};
|
27
|
+
|
28
|
+
if (obj != null) {
|
29
|
+
for (var key in obj) {
|
30
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
31
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
32
|
+
|
33
|
+
if (desc.get || desc.set) {
|
34
|
+
Object.defineProperty(newObj, key, desc);
|
35
|
+
} else {
|
36
|
+
newObj[key] = obj[key];
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
newObj.default = obj;
|
43
|
+
return newObj;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
function _typeof(obj) {
|
48
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
49
|
+
_typeof = function _typeof(obj) {
|
50
|
+
return typeof obj;
|
51
|
+
};
|
52
|
+
} else {
|
53
|
+
_typeof = function _typeof(obj) {
|
54
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
55
|
+
};
|
56
|
+
}
|
57
|
+
|
58
|
+
return _typeof(obj);
|
59
|
+
}
|
60
|
+
|
61
|
+
function _extends() {
|
62
|
+
_extends = Object.assign || function (target) {
|
63
|
+
for (var i = 1; i < arguments.length; i++) {
|
64
|
+
var source = arguments[i];
|
65
|
+
|
66
|
+
for (var key in source) {
|
67
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
68
|
+
target[key] = source[key];
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
return target;
|
74
|
+
};
|
75
|
+
|
76
|
+
return _extends.apply(this, arguments);
|
77
|
+
}
|
78
|
+
|
79
|
+
function _classCallCheck(instance, Constructor) {
|
80
|
+
if (!(instance instanceof Constructor)) {
|
81
|
+
throw new TypeError("Cannot call a class as a function");
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
function _defineProperties(target, props) {
|
86
|
+
for (var i = 0; i < props.length; i++) {
|
87
|
+
var descriptor = props[i];
|
88
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
89
|
+
descriptor.configurable = true;
|
90
|
+
if ("value" in descriptor) descriptor.writable = true;
|
91
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
96
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
97
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
98
|
+
return Constructor;
|
99
|
+
}
|
100
|
+
|
101
|
+
function _possibleConstructorReturn(self, call) {
|
102
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
103
|
+
return call;
|
104
|
+
}
|
105
|
+
|
106
|
+
return _assertThisInitialized(self);
|
107
|
+
}
|
108
|
+
|
109
|
+
function _getPrototypeOf(o) {
|
110
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
111
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
112
|
+
};
|
113
|
+
return _getPrototypeOf(o);
|
114
|
+
}
|
115
|
+
|
116
|
+
function _assertThisInitialized(self) {
|
117
|
+
if (self === void 0) {
|
118
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
119
|
+
}
|
120
|
+
|
121
|
+
return self;
|
122
|
+
}
|
123
|
+
|
124
|
+
function _inherits(subClass, superClass) {
|
125
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
126
|
+
throw new TypeError("Super expression must either be null or a function");
|
127
|
+
}
|
128
|
+
|
129
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
130
|
+
constructor: {
|
131
|
+
value: subClass,
|
132
|
+
writable: true,
|
133
|
+
configurable: true
|
134
|
+
}
|
135
|
+
});
|
136
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
137
|
+
}
|
138
|
+
|
139
|
+
function _setPrototypeOf(o, p) {
|
140
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
141
|
+
o.__proto__ = p;
|
142
|
+
return o;
|
143
|
+
};
|
144
|
+
|
145
|
+
return _setPrototypeOf(o, p);
|
146
|
+
}
|
147
|
+
|
148
|
+
var FeNotification =
|
149
|
+
/*#__PURE__*/
|
150
|
+
function (_Component) {
|
151
|
+
_inherits(FeNotification, _Component);
|
152
|
+
|
153
|
+
function FeNotification(props) {
|
154
|
+
var _this;
|
155
|
+
|
156
|
+
_classCallCheck(this, FeNotification);
|
157
|
+
|
158
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(FeNotification).call(this, props));
|
159
|
+
_this.state = {
|
160
|
+
dismissed: false
|
161
|
+
};
|
162
|
+
_this.unmount = _this.unmount.bind(_assertThisInitialized(_this));
|
163
|
+
return _this;
|
164
|
+
}
|
165
|
+
|
166
|
+
_createClass(FeNotification, [{
|
167
|
+
key: "unmount",
|
168
|
+
value: function unmount() {
|
169
|
+
var _this2 = this;
|
170
|
+
|
171
|
+
this.setState({
|
172
|
+
dismissed: true
|
173
|
+
}, function () {
|
174
|
+
if (_this2.props.onDismiss) {
|
175
|
+
_this2.props.onDismiss(_this2.props.index || _this2.props);
|
176
|
+
}
|
177
|
+
});
|
178
|
+
|
179
|
+
if (this.timerNode) {
|
180
|
+
this.timerNode.removeEventListener('animationend', this.unmount);
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}, {
|
184
|
+
key: "componentDidMount",
|
185
|
+
value: function componentDidMount() {
|
186
|
+
if (this.props.feStyle === 'default' && this.props.autoDismiss) {
|
187
|
+
this.timerNode.style.animationDuration = "".concat(this.props.autoDismissTimeout, "s");
|
188
|
+
this.timerNode.addEventListener('animationend', this.unmount, false);
|
189
|
+
}
|
190
|
+
}
|
191
|
+
}, {
|
192
|
+
key: "render",
|
193
|
+
value: function render() {
|
194
|
+
var _this3 = this;
|
195
|
+
/** Minimum condition required to render*/
|
196
|
+
|
197
|
+
|
198
|
+
if (!this.props.message || this.state.dismissed) {
|
199
|
+
return null;
|
200
|
+
}
|
201
|
+
/** Rendering of component */
|
202
|
+
|
203
|
+
|
204
|
+
var className = (0, _classnames.default)("fe".concat(this.props.feStyle === 'list' ? '-list' : '', "-notice"), "fe".concat(this.props.feStyle === 'list' ? '-list' : '', "-notice--").concat(this.props.feType), {
|
205
|
+
'fe-notice--auto-dismiss': this.props.feStyle === 'default' && this.props.autoDismiss,
|
206
|
+
'fe-list-notice--unread': this.props.feStyle === 'list' && !this.props.isRead
|
207
|
+
}, this.props.className);
|
208
|
+
var otherProps = Object.assign({}, this.props);
|
209
|
+
delete otherProps.label;
|
210
|
+
delete otherProps.message;
|
211
|
+
delete otherProps.feStyle;
|
212
|
+
delete otherProps.feType;
|
213
|
+
delete otherProps.withIcon;
|
214
|
+
delete otherProps.autoDismiss;
|
215
|
+
delete otherProps.autoDismissTimeout;
|
216
|
+
delete otherProps.timestamp;
|
217
|
+
delete otherProps.iconInfo;
|
218
|
+
delete otherProps.iconSuccess;
|
219
|
+
delete otherProps.iconWarning;
|
220
|
+
delete otherProps.iconError;
|
221
|
+
delete otherProps.isRead;
|
222
|
+
delete otherProps.onDismiss;
|
223
|
+
delete otherProps.optionalComponent;
|
224
|
+
delete otherProps.className;
|
225
|
+
return _react.default.createElement("div", _extends({
|
226
|
+
className: className
|
227
|
+
}, otherProps), this.props.feStyle === 'default' && this.props.autoDismiss ? _react.default.createElement("div", {
|
228
|
+
ref: function ref(node) {
|
229
|
+
return _this3.timerNode = node;
|
230
|
+
},
|
231
|
+
className: "fe-notice__dismiss-timer"
|
232
|
+
}) : null, this.props.feStyle === 'default' ? _react.default.createElement(DefaultNotification, _extends({}, this.props, {
|
233
|
+
unmount: this.unmount
|
234
|
+
})) : _react.default.createElement(ListNotification, this.props));
|
235
|
+
}
|
236
|
+
}]);
|
237
|
+
|
238
|
+
return FeNotification;
|
239
|
+
}(_react.Component);
|
240
|
+
|
241
|
+
var DefaultNotification = function DefaultNotification(props) {
|
242
|
+
var indicatorClass = (0, _classnames.default)('fe-notice__indicator', {
|
243
|
+
'fe-notice__indicator--icon': props.withIcon
|
244
|
+
});
|
245
|
+
var iconClass = props.withIcon && (0, _classnames.default)({
|
246
|
+
'info-circle': props.feType === 'info',
|
247
|
+
'check-circle': props.feType === 'success',
|
248
|
+
'exclamation-circle': props.feType === 'warning',
|
249
|
+
'exclamation-triangle': props.feType === 'error'
|
250
|
+
});
|
251
|
+
return _react.default.createElement(_react.Fragment, null, _react.default.createElement("button", {
|
252
|
+
type: "button",
|
253
|
+
name: "button",
|
254
|
+
className: "fe-notice__close",
|
255
|
+
onClick: props.unmount
|
256
|
+
}, _react.default.createElement(_FeIcon.default, {
|
257
|
+
family: "light",
|
258
|
+
icon: "times"
|
259
|
+
})), _react.default.createElement("div", {
|
260
|
+
className: indicatorClass
|
261
|
+
}, props.withIcon ? _react.default.createElement(_FeIcon.default, {
|
262
|
+
family: "light",
|
263
|
+
icon: iconClass
|
264
|
+
}) : null), _react.default.createElement("div", {
|
265
|
+
className: "fe-notice__message"
|
266
|
+
}, props.label ? _react.default.createElement("p", {
|
267
|
+
className: "fe-notice__label"
|
268
|
+
}, props.label) : null, _react.default.createElement("p", {
|
269
|
+
className: "fe-notice__text"
|
270
|
+
}, props.message), props.optionalComponent ? _react.default.createElement("p", {
|
271
|
+
className: "fe-notice__actions"
|
272
|
+
}, props.optionalComponent) : null));
|
273
|
+
};
|
274
|
+
|
275
|
+
var ListNotification = function ListNotification(props) {
|
276
|
+
var iconClass = props.withIcon && (0, _classnames.default)({
|
277
|
+
'info-circle': props.feType === 'info',
|
278
|
+
'check-circle': props.feType === 'success',
|
279
|
+
'exclamation-circle': props.feType === 'warning',
|
280
|
+
'exclamation-triangle': props.feType === 'error'
|
281
|
+
});
|
282
|
+
return _react.default.createElement(_react.Fragment, null, _react.default.createElement("div", {
|
283
|
+
className: "fe-list-notice__indicator"
|
284
|
+
}), _react.default.createElement("div", {
|
285
|
+
className: "fe-list-notice__container"
|
286
|
+
}, _react.default.createElement("p", {
|
287
|
+
className: "fe-list-notice__label clearfix"
|
288
|
+
}, props.label, props.timestamp ? _react.default.createElement("span", {
|
289
|
+
className: "fe-list-notice__timestamp pull-right"
|
290
|
+
}, props.timestamp) : null), _react.default.createElement("div", {
|
291
|
+
className: "fe-list-notice__message"
|
292
|
+
}, props.withIcon ? _react.default.createElement("span", {
|
293
|
+
className: "fe-list-notice__icon"
|
294
|
+
}, _react.default.createElement(_FeIcon.default, {
|
295
|
+
family: "light",
|
296
|
+
icon: iconClass
|
297
|
+
})) : null, _react.default.createElement("p", {
|
298
|
+
className: "fe-list-notice__text"
|
299
|
+
}, props.message))));
|
300
|
+
};
|
301
|
+
|
302
|
+
FeNotification.defaultProps = {
|
303
|
+
label: null,
|
304
|
+
message: null,
|
305
|
+
feStyle: 'default',
|
306
|
+
feType: 'info',
|
307
|
+
withIcon: false,
|
308
|
+
autoDismiss: false,
|
309
|
+
autoDismissTimeout: 5,
|
310
|
+
timestamp: null,
|
311
|
+
isRead: false,
|
312
|
+
onDismiss: null,
|
313
|
+
optionalComponent: null
|
314
|
+
};
|
315
|
+
FeNotification.propTypes = {
|
316
|
+
/** Provide notification label*/
|
317
|
+
label: _propTypes.default.string,
|
318
|
+
|
319
|
+
/** Provide notification message*/
|
320
|
+
message: _propTypes.default.string,
|
321
|
+
|
322
|
+
/** Provide style like 'default' or 'list'*/
|
323
|
+
feStyle: _propTypes.default.oneOf(['default', 'list']),
|
324
|
+
|
325
|
+
/** Provide type like 'info', 'success', 'warning' or 'error'*/
|
326
|
+
feType: _propTypes.default.oneOf(['info', 'success', 'warning', 'error']),
|
327
|
+
|
328
|
+
/** Set true/false to add/remove type icon*/
|
329
|
+
withIcon: _propTypes.default.bool,
|
330
|
+
|
331
|
+
/** Set true/false to make auto dismissable*/
|
332
|
+
autoDismiss: _propTypes.default.bool,
|
333
|
+
|
334
|
+
/** Provide auto dismissable timeout*/
|
335
|
+
autoDismissTimeout: _propTypes.default.number,
|
336
|
+
|
337
|
+
/** Provide timestamp for notification generated*/
|
338
|
+
timestamp: _propTypes.default.string,
|
339
|
+
|
340
|
+
/** Set true/false to make it read or unread*/
|
341
|
+
isRead: _propTypes.default.bool,
|
342
|
+
|
343
|
+
/** Provide handler on dismiss of notification*/
|
344
|
+
onDismiss: _propTypes.default.func,
|
345
|
+
|
346
|
+
/** Provide optional component*/
|
347
|
+
optionalComponent: _propTypes.default.element
|
348
|
+
};
|
349
|
+
FeNotification.displayName = 'FeNotification';
|
350
|
+
var _default = FeNotification;
|
351
|
+
exports.default = _default;
|
@@ -0,0 +1,353 @@
|
|
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 _FeIcon = _interopRequireDefault(require("./FeIcon"));
|
15
|
+
|
16
|
+
function _interopRequireDefault(obj) {
|
17
|
+
return obj && obj.__esModule ? obj : {
|
18
|
+
default: obj
|
19
|
+
};
|
20
|
+
}
|
21
|
+
|
22
|
+
function _interopRequireWildcard(obj) {
|
23
|
+
if (obj && obj.__esModule) {
|
24
|
+
return obj;
|
25
|
+
} else {
|
26
|
+
var newObj = {};
|
27
|
+
|
28
|
+
if (obj != null) {
|
29
|
+
for (var key in obj) {
|
30
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
31
|
+
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
|
32
|
+
|
33
|
+
if (desc.get || desc.set) {
|
34
|
+
Object.defineProperty(newObj, key, desc);
|
35
|
+
} else {
|
36
|
+
newObj[key] = obj[key];
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
newObj.default = obj;
|
43
|
+
return newObj;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
function _typeof(obj) {
|
48
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
49
|
+
_typeof = function _typeof(obj) {
|
50
|
+
return typeof obj;
|
51
|
+
};
|
52
|
+
} else {
|
53
|
+
_typeof = function _typeof(obj) {
|
54
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
55
|
+
};
|
56
|
+
}
|
57
|
+
|
58
|
+
return _typeof(obj);
|
59
|
+
}
|
60
|
+
|
61
|
+
function _objectWithoutProperties(source, excluded) {
|
62
|
+
if (source == null) return {};
|
63
|
+
|
64
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
65
|
+
|
66
|
+
var key, i;
|
67
|
+
|
68
|
+
if (Object.getOwnPropertySymbols) {
|
69
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
70
|
+
|
71
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
72
|
+
key = sourceSymbolKeys[i];
|
73
|
+
if (excluded.indexOf(key) >= 0) continue;
|
74
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
75
|
+
target[key] = source[key];
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
return target;
|
80
|
+
}
|
81
|
+
|
82
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
83
|
+
if (source == null) return {};
|
84
|
+
var target = {};
|
85
|
+
var sourceKeys = Object.keys(source);
|
86
|
+
var key, i;
|
87
|
+
|
88
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
89
|
+
key = sourceKeys[i];
|
90
|
+
if (excluded.indexOf(key) >= 0) continue;
|
91
|
+
target[key] = source[key];
|
92
|
+
}
|
93
|
+
|
94
|
+
return target;
|
95
|
+
}
|
96
|
+
|
97
|
+
function _classCallCheck(instance, Constructor) {
|
98
|
+
if (!(instance instanceof Constructor)) {
|
99
|
+
throw new TypeError("Cannot call a class as a function");
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
function _defineProperties(target, props) {
|
104
|
+
for (var i = 0; i < props.length; i++) {
|
105
|
+
var descriptor = props[i];
|
106
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
107
|
+
descriptor.configurable = true;
|
108
|
+
if ("value" in descriptor) descriptor.writable = true;
|
109
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
|
113
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
114
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
115
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
116
|
+
return Constructor;
|
117
|
+
}
|
118
|
+
|
119
|
+
function _possibleConstructorReturn(self, call) {
|
120
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
121
|
+
return call;
|
122
|
+
}
|
123
|
+
|
124
|
+
return _assertThisInitialized(self);
|
125
|
+
}
|
126
|
+
|
127
|
+
function _getPrototypeOf(o) {
|
128
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
129
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
130
|
+
};
|
131
|
+
return _getPrototypeOf(o);
|
132
|
+
}
|
133
|
+
|
134
|
+
function _assertThisInitialized(self) {
|
135
|
+
if (self === void 0) {
|
136
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
137
|
+
}
|
138
|
+
|
139
|
+
return self;
|
140
|
+
}
|
141
|
+
|
142
|
+
function _inherits(subClass, superClass) {
|
143
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
144
|
+
throw new TypeError("Super expression must either be null or a function");
|
145
|
+
}
|
146
|
+
|
147
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
148
|
+
constructor: {
|
149
|
+
value: subClass,
|
150
|
+
writable: true,
|
151
|
+
configurable: true
|
152
|
+
}
|
153
|
+
});
|
154
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
155
|
+
}
|
156
|
+
|
157
|
+
function _setPrototypeOf(o, p) {
|
158
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
159
|
+
o.__proto__ = p;
|
160
|
+
return o;
|
161
|
+
};
|
162
|
+
|
163
|
+
return _setPrototypeOf(o, p);
|
164
|
+
}
|
165
|
+
|
166
|
+
function _extends() {
|
167
|
+
_extends = Object.assign || function (target) {
|
168
|
+
for (var i = 1; i < arguments.length; i++) {
|
169
|
+
var source = arguments[i];
|
170
|
+
|
171
|
+
for (var key in source) {
|
172
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
173
|
+
target[key] = source[key];
|
174
|
+
}
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
return target;
|
179
|
+
};
|
180
|
+
|
181
|
+
return _extends.apply(this, arguments);
|
182
|
+
}
|
183
|
+
|
184
|
+
var FePillBoxIcon = function FePillBoxIcon(_ref) {
|
185
|
+
var onIconClick = _ref.onIconClick,
|
186
|
+
feType = _ref.feType,
|
187
|
+
iconClear = _ref.iconClear,
|
188
|
+
iconAdd = _ref.iconAdd;
|
189
|
+
var iconAttributes = {
|
190
|
+
role: 'button',
|
191
|
+
tabIndex: '0',
|
192
|
+
onClick: onIconClick,
|
193
|
+
onKeyDown: function onKeyDown(event) {
|
194
|
+
if (event.keyCode === 13) {
|
195
|
+
//Enter
|
196
|
+
onIconClick(event);
|
197
|
+
}
|
198
|
+
}
|
199
|
+
};
|
200
|
+
|
201
|
+
if (feType === 'clear') {
|
202
|
+
return _react.default.createElement("a", _extends({}, iconAttributes, {
|
203
|
+
"aria-label": "clear"
|
204
|
+
}), _react.default.createElement(_FeIcon.default, {
|
205
|
+
family: "solid",
|
206
|
+
icon: "times-circle",
|
207
|
+
className: "close"
|
208
|
+
}));
|
209
|
+
} else if (feType === 'add') {
|
210
|
+
return _react.default.createElement("a", _extends({}, iconAttributes, {
|
211
|
+
"aria-label": "add"
|
212
|
+
}), _react.default.createElement(_FeIcon.default, {
|
213
|
+
family: "solid",
|
214
|
+
icon: "plus-circle",
|
215
|
+
className: "add"
|
216
|
+
}));
|
217
|
+
}
|
218
|
+
|
219
|
+
return null;
|
220
|
+
};
|
221
|
+
|
222
|
+
var FePillBox =
|
223
|
+
/*#__PURE__*/
|
224
|
+
function (_Component) {
|
225
|
+
_inherits(FePillBox, _Component);
|
226
|
+
|
227
|
+
function FePillBox(props) {
|
228
|
+
var _this;
|
229
|
+
|
230
|
+
_classCallCheck(this, FePillBox);
|
231
|
+
|
232
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(FePillBox).call(this, props));
|
233
|
+
_this.onButtonClick = _this.onButtonClick.bind(_assertThisInitialized(_this));
|
234
|
+
_this.onIconClick = _this.onIconClick.bind(_assertThisInitialized(_this));
|
235
|
+
return _this;
|
236
|
+
}
|
237
|
+
|
238
|
+
_createClass(FePillBox, [{
|
239
|
+
key: "onButtonClick",
|
240
|
+
value: function onButtonClick(event) {
|
241
|
+
if (this.props.onClick) {
|
242
|
+
this.props.onClick({
|
243
|
+
originalEvent: event,
|
244
|
+
buttonClick: true,
|
245
|
+
props: this.props
|
246
|
+
});
|
247
|
+
}
|
248
|
+
}
|
249
|
+
}, {
|
250
|
+
key: "onIconClick",
|
251
|
+
value: function onIconClick(event) {
|
252
|
+
event.stopPropagation();
|
253
|
+
|
254
|
+
if (this.props.onClick) {
|
255
|
+
this.props.onClick({
|
256
|
+
originalEvent: event,
|
257
|
+
iconClick: true,
|
258
|
+
props: this.props
|
259
|
+
});
|
260
|
+
}
|
261
|
+
}
|
262
|
+
}, {
|
263
|
+
key: "render",
|
264
|
+
value: function render() {
|
265
|
+
var _this$props = this.props,
|
266
|
+
feType = _this$props.feType,
|
267
|
+
iconClear = _this$props.iconClear,
|
268
|
+
iconAdd = _this$props.iconAdd,
|
269
|
+
disabled = _this$props.disabled,
|
270
|
+
active = _this$props.active,
|
271
|
+
feKey = _this$props.feKey,
|
272
|
+
feValue = _this$props.feValue,
|
273
|
+
label = _this$props.label,
|
274
|
+
pillBoxProps = _objectWithoutProperties(_this$props, ["feType", "iconClear", "iconAdd", "disabled", "active", "feKey", "feValue", "label"]);
|
275
|
+
|
276
|
+
var isKeyValueAvailable = !!feKey && !!feValue;
|
277
|
+
var isLabelAvailable = !!label;
|
278
|
+
|
279
|
+
if (!isKeyValueAvailable && !isLabelAvailable) {
|
280
|
+
return null;
|
281
|
+
}
|
282
|
+
|
283
|
+
var Tag = this.props.href ? 'a' : 'button';
|
284
|
+
var className = (0, _classnames.default)('fe-pill-box', {
|
285
|
+
'with-icon clear': !disabled && feType === 'clear',
|
286
|
+
'with-icon create': !disabled && feType === 'add',
|
287
|
+
'active': active,
|
288
|
+
'disabled': disabled
|
289
|
+
}, this.props.className);
|
290
|
+
|
291
|
+
var key = isKeyValueAvailable && _react.default.createElement("span", {
|
292
|
+
className: "key"
|
293
|
+
}, "".concat(feKey, ": "));
|
294
|
+
|
295
|
+
var value = isKeyValueAvailable && _react.default.createElement("span", {
|
296
|
+
className: "value"
|
297
|
+
}, feValue);
|
298
|
+
|
299
|
+
var pillBoxLabel = !isKeyValueAvailable && isLabelAvailable && _react.default.createElement("span", {
|
300
|
+
className: "label"
|
301
|
+
}, label);
|
302
|
+
|
303
|
+
var icon = !disabled && _react.default.createElement(FePillBoxIcon, {
|
304
|
+
onIconClick: this.onIconClick,
|
305
|
+
feType: feType,
|
306
|
+
iconClear: iconClear,
|
307
|
+
iconAdd: iconAdd
|
308
|
+
});
|
309
|
+
|
310
|
+
return _react.default.createElement(Tag, _extends({}, pillBoxProps, {
|
311
|
+
className: className,
|
312
|
+
disabled: disabled,
|
313
|
+
onClick: this.onButtonClick
|
314
|
+
}), key, value, pillBoxLabel, icon);
|
315
|
+
}
|
316
|
+
}]);
|
317
|
+
|
318
|
+
return FePillBox;
|
319
|
+
}(_react.Component);
|
320
|
+
|
321
|
+
FePillBox.defaultProps = {
|
322
|
+
label: null,
|
323
|
+
feKey: null,
|
324
|
+
feValue: null,
|
325
|
+
feType: 'default',
|
326
|
+
active: false,
|
327
|
+
disabled: false
|
328
|
+
};
|
329
|
+
FePillBox.propTypes = {
|
330
|
+
/** Provide label attribute*/
|
331
|
+
label: _propTypes.default.string,
|
332
|
+
|
333
|
+
/** Provide key attribute*/
|
334
|
+
feKey: _propTypes.default.string,
|
335
|
+
|
336
|
+
/** Provide value attribute*/
|
337
|
+
feValue: _propTypes.default.string,
|
338
|
+
|
339
|
+
/** Render the PillBox as an HTML Anchor with the provided HREF **/
|
340
|
+
href: _propTypes.default.string,
|
341
|
+
|
342
|
+
/** Provide type for pillbox like 'default', 'clear', 'add'*/
|
343
|
+
feType: _propTypes.default.oneOf(['default', 'clear', 'add']),
|
344
|
+
|
345
|
+
/** Set true/false to change active state*/
|
346
|
+
active: _propTypes.default.bool,
|
347
|
+
|
348
|
+
/** Set true/false to change disabled state*/
|
349
|
+
disabled: _propTypes.default.bool
|
350
|
+
};
|
351
|
+
FePillBox.displayName = 'FePillBox';
|
352
|
+
var _default = FePillBox;
|
353
|
+
exports.default = _default;
|