@momentum-ui/react-collaboration
Version:
Cisco Momentum UI Framework for React Collaboration Applications
46 lines • 3.02 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 './Icon.style.scss';
import { DEFAULTS, STYLE } from './Icon.constants';
import classnames from 'classnames';
import { getResolvedSVGName } from './Icon.utils';
import Tooltip from '../Tooltip';
import { Icon as MdcIcon } from '@momentum-design/components/dist/react';
/**
* Icon component that can dynamically display SVG icons with a valid name.
* @deprecated Use the equivalent from momentum.design (NPM: `@momentum-design/components/dist/react`)
*/
var Icon = function (props) {
var autoScale = props.autoScale, className = props.className, id = props.id, name = props.name, scale = props.scale, style = props.style, title = props.title, weight = props.weight, _a = props.weightless, weightless = _a === void 0 ? DEFAULTS.WEIGHTLESS : _a, ariaLabel = props.ariaLabel, tooltipProps = props.tooltipProps, fillColor = props.fillColor, otherProps = __rest(props, ["autoScale", "className", "id", "name", "scale", "style", "title", "weight", "weightless", "ariaLabel", "tooltipProps", "fillColor"]);
var resolvedSVGName = getResolvedSVGName(name, weight, weightless);
var accessibleName = ariaLabel || otherProps['aria-label'] || title;
delete otherProps['aria-label'];
var isTooltipWrapped = tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.children;
var fillColorStyle = fillColor ? { '--mdc-icon-fill-color': fillColor } : {};
var content = (React.createElement(MdcIcon, __assign({ className: classnames(STYLE.wrapper, STYLE.autoScales, STYLE.scales, STYLE.noShrink, className), "data-test": name, "data-scale": !autoScale && scale, "data-autoscale": autoScale || DEFAULTS.AUTO_SCALE, name: resolvedSVGName, "aria-label": isTooltipWrapped ? undefined : accessibleName, tabIndex: isTooltipWrapped ? 0 : undefined, style: __assign(__assign({}, fillColorStyle), style), id: id }, otherProps)));
return isTooltipWrapped ? (React.createElement(Tooltip, __assign({ placement: "top", strategy: "fixed", type: "label", triggerComponent: content }, tooltipProps))) : (content);
};
Icon.displayName = 'Mrv2Icon';
export default Icon;
//# sourceMappingURL=Icon.js.map