@eccenca/gui-elements
Version:
GUI elements based on other libraries, usable in React application, written in Typescript.
44 lines • 2.49 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
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 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import React from "react";
import { CLASSPREFIX as eccgui } from "../../configuration/constants.js";
import Tooltip from "./../Tooltip/Tooltip.js";
/**
* The base icon provides the basic functionality that is necessary to wrap the Carbon icon component.
*/
function BaseIcon(_a) {
var iconComponent = _a.iconComponent, _b = _a.className, className = _b === void 0 ? "" : _b, _c = _a.large, large = _c === void 0 ? false : _c, _d = _a.small, small = _d === void 0 ? false : _d, tooltipText = _a.tooltipText, tooltipProps = _a.tooltipProps, intent = _a.intent, tabIndex = _a.tabIndex, restProps = __rest(_a, ["iconComponent", "className", "large", "small", "tooltipText", "tooltipProps", "intent", "tabIndex"]);
var sizeConfig = { height: 20, width: 20, size: 20 };
if (small)
sizeConfig = { height: 16, width: 16, size: 16 };
if (large)
sizeConfig = { height: 32, width: 32, size: 32 };
var CarbonIconNamed = iconComponent;
var icon = (React.createElement(CarbonIconNamed, __assign({}, restProps, sizeConfig, { className: "".concat(eccgui, "-icon") + (intent ? " ".concat(eccgui, "-intent--").concat(intent) : "") + (className ? " ".concat(className) : ""),
// @ts-ignore tabIndex is number but internally Carbon defined it as string propType.
tabIndex: typeof tabIndex !== "undefined" ? tabIndex.toString() : undefined })));
return tooltipText ? (React.createElement(Tooltip, __assign({ content: tooltipText }, tooltipProps),
React.createElement("span", null, icon))) : (icon);
}
export default BaseIcon;
//# sourceMappingURL=BaseIcon.js.map