Repository URL to install this package:
|
Version:
2.0.2 ▾
|
"use strict";
var __rest = this && this.__rest || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]];
return t;
};
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", {
value: true
});
const react_1 = __importDefault(require("react"));
const classnames_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
} = _a,
passthroughProps = __rest(_a, ["children", "title", "description", "namespace", "vectorClassName", "className", "height", "width", "viewBox", "isDynamicViewBox", "dataQa"]); // 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,
// @note
'data-qa': dataQa,
height,
width
};
if (exotic_1.isString(title)) {
attributes['aria-labelledby'] = namespace;
} // accessibility
const titleView = exotic_1.isString(title) && react_1.default.createElement("title", {
id: namespace
}, 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