Files
2026-04-05 16:14:49 -04:00

141 lines
6.8 KiB
JavaScript

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _screenReaderStyles = require('./screen-reader-styles');
var _screenReaderStyles2 = _interopRequireDefault(_screenReaderStyles);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
* A React component for the font-awesome icon library.
*
* @param {String} [ariaLabel] An extra accessibility label to put on the icon
* @param {Boolean} [border=false] Whether or not to show a border radius
* @param {String} [className] An extra set of CSS classes to add to the component
* @param {Object} [cssModule] Option to pass FontAwesome CSS as a module
* @param {Boolean} [fixedWidth=false] Make buttons fixed width
* @param {String} [flip=false] Flip the icon's orientation.
* @param {Boolean} [inverse=false]Inverse the icon's color
* @param {String} name Name of the icon to use
* @param {Boolean} [pulse=false] Rotate icon with 8 steps, rather than smoothly
* @param {Number} [rotate] The degress to rotate the icon by
* @param {String} [size] The icon scaling size
* @param {Boolean} [spin=false] Spin the icon
* @param {String} [stack] Stack an icon on top of another
* @param {String} [tag=span] The HTML tag to use as a string, eg 'i' or 'em'
* @module FontAwesome
* @type {ReactClass}
*/
var FontAwesome = function (_React$Component) {
_inherits(FontAwesome, _React$Component);
function FontAwesome() {
_classCallCheck(this, FontAwesome);
var _this = _possibleConstructorReturn(this, (FontAwesome.__proto__ || Object.getPrototypeOf(FontAwesome)).call(this));
_this.displayName = 'FontAwesome';
return _this;
}
_createClass(FontAwesome, [{
key: 'render',
value: function render() {
var _props = this.props,
border = _props.border,
cssModule = _props.cssModule,
className = _props.className,
fixedWidth = _props.fixedWidth,
flip = _props.flip,
inverse = _props.inverse,
name = _props.name,
pulse = _props.pulse,
rotate = _props.rotate,
size = _props.size,
spin = _props.spin,
stack = _props.stack,
_props$tag = _props.tag,
tag = _props$tag === undefined ? 'span' : _props$tag,
ariaLabel = _props.ariaLabel,
props = _objectWithoutProperties(_props, ['border', 'cssModule', 'className', 'fixedWidth', 'flip', 'inverse', 'name', 'pulse', 'rotate', 'size', 'spin', 'stack', 'tag', 'ariaLabel']);
var classNames = [];
if (cssModule) {
classNames.push(cssModule['fa']);
classNames.push(cssModule['fa-' + name]);
size && classNames.push(cssModule['fa-' + size]);
spin && classNames.push(cssModule['fa-spin']);
pulse && classNames.push(cssModule['fa-pulse']);
border && classNames.push(cssModule['fa-border']);
fixedWidth && classNames.push(cssModule['fa-fw']);
inverse && classNames.push(cssModule['fa-inverse']);
flip && classNames.push(cssModule['fa-flip-' + flip]);
rotate && classNames.push(cssModule['fa-rotate-' + rotate]);
stack && classNames.push(cssModule['fa-stack-' + stack]);
} else {
classNames.push('fa');
classNames.push('fa-' + name);
size && classNames.push('fa-' + size);
spin && classNames.push('fa-spin');
pulse && classNames.push('fa-pulse');
border && classNames.push('fa-border');
fixedWidth && classNames.push('fa-fw');
inverse && classNames.push('fa-inverse');
flip && classNames.push('fa-flip-' + flip);
rotate && classNames.push('fa-rotate-' + rotate);
stack && classNames.push('fa-stack-' + stack);
}
// Add any custom class names at the end.
className && classNames.push(className);
return _react2.default.createElement(tag, _extends({}, props, { 'aria-hidden': true, className: classNames.join(' ') }), ariaLabel ? _react2.default.createElement('span', { style: _screenReaderStyles2.default }, ariaLabel) : null);
}
}]);
return FontAwesome;
}(_react2.default.Component);
FontAwesome.propTypes = {
ariaLabel: _propTypes2.default.string,
border: _propTypes2.default.bool,
className: _propTypes2.default.string,
cssModule: _propTypes2.default.object,
fixedWidth: _propTypes2.default.bool,
flip: _propTypes2.default.oneOf(['horizontal', 'vertical']),
inverse: _propTypes2.default.bool,
name: _propTypes2.default.string.isRequired,
pulse: _propTypes2.default.bool,
rotate: _propTypes2.default.oneOf([90, 180, 270]),
size: _propTypes2.default.oneOf(['lg', '2x', '3x', '4x', '5x']),
spin: _propTypes2.default.bool,
stack: _propTypes2.default.oneOf(['1x', '2x']),
tag: _propTypes2.default.string
};
exports.default = FontAwesome;
module.exports = exports['default'];