react-suitcssify
Version:
A React component utility to generate CSS class names that conform to SUIT CSS naming conventions.
44 lines (34 loc) • 1.72 kB
JavaScript
;
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 _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _utility = require('./utility');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var mixin = {
propTypes: {
className: _propTypes2.default.string,
utilities: _propTypes2.default.string
},
getClassName: function getClassName() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var options = _extends({}, config);
if (!options.hasOwnProperty('className')) {
options.className = this && (config.descendantName ? null : this.props && this.props.hasOwnProperty('className') && this.props.className) || null;
}
if (!(options.hasOwnProperty('baseComponentName') || options.hasOwnProperty('componentName'))) {
options.componentName = this && (this.constructor.displayName || this.constructor.name) || 'Undefined';
}
if (!options.hasOwnProperty('namespace')) {
options.namespace = this && this.namespace || null;
}
if (!options.hasOwnProperty('utilities')) {
options.utilities = this && (config.descendantName ? null : this.props && this.props.hasOwnProperty('utilities') && this.props.utilities) || null;
}
return (0, _utility.getClassName)(options);
}
};
exports.default = mixin;
//# sourceMappingURL=mixin.js.map