@pdftron/webviewer-react-toolkit
Version:
A React component library for integrating with PDFTron WebViewer API.
18 lines (17 loc) • 867 B
JavaScript
import { __assign, __rest } from "tslib";
import classnames from 'classnames';
import React, { forwardRef, useMemo } from 'react';
import * as icons from './../../icons';
export var Icon = forwardRef(function (_a, ref) {
var icon = _a.icon, svgProps = _a.svgProps, className = _a.className, children = _a.children, props = __rest(_a, ["icon", "svgProps", "className", "children"]);
var iconClass = classnames('ui__base ui__icon', className);
var child = useMemo(function () {
if (children !== undefined)
return children;
if (icons === undefined)
return undefined;
var IconChild = icons[icon];
return React.createElement(IconChild, __assign({}, svgProps));
}, [children, icon, svgProps]);
return (React.createElement("i", __assign({}, props, { className: iconClass, ref: ref }), child));
});