Repository URL to install this package:
|
Version:
4.0.76 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const exotic_1 = require("exotic");
class Vector extends react_1.default.PureComponent {
render() {
const _a = this.props,
{
children,
//
title,
description,
//
namespace,
vectorClassName,
className,
//
height,
width,
viewBox,
isDynamicViewBox,
dataQa,
ariaHidden
} = _a,
passthroughProps = tslib_1.__rest(_a, ["children", "title", "description", "namespace", "vectorClassName", "className", "height", "width", "viewBox", "isDynamicViewBox", "dataQa", "ariaHidden"]); // dynamically set viewBox with width & height
const shouldUseDynamicViewBox = (viewBox === undefined || isDynamicViewBox === true) && width !== undefined && height !== undefined;
const computedViewBox = shouldUseDynamicViewBox ? `0 0 ${width} ${height}` : viewBox; // @todo @remove
const computedClassName = exotic_1.isString(vectorClassName) ? 'svg-icon-' + vectorClassName + ' ' + vectorClassName : vectorClassName;
const classNamed = classnames_1.default('svg-icon', computedClassName, className); // props
const attributes = {
className: classNamed,
viewBox: computedViewBox,
'aria-hidden': ariaHidden,
// @note
'data-qa': dataQa,
height,
width
};
const namespaceArray = exotic_1.isString(namespace) ? namespace.split(' ') : '';
if (exotic_1.isString(title)) {
attributes['aria-labelledby'] = namespaceArray[0];
attributes['aria-label'] = title;
attributes.alt = title;
} else {
attributes.alt = 'svg icon';
} // accessibility
const titleView = exotic_1.isString(title) && react_1.default.createElement("title", {
id: namespaceArray[0]
}, title);
const descriptionView = exotic_1.isString(description) && react_1.default.createElement("desc", null, description);
return react_1.default.createElement("svg", Object.assign({
xmlns: "http://www.w3.org/2000/svg",
version: "1.1",
role: "img"
}, attributes, passthroughProps), titleView, descriptionView, children);
}
}
Vector.defaultProps = {
className: '',
isDynamicViewBox: false
};
exports.Vector = Vector;
exports.default = Vector; //# sourceMappingURL=Vector.js.map