UNPKG

@coreui/react-pro

Version:

UI Components Library for React.js

30 lines (27 loc) 1.31 kB
import { __rest } from '../../node_modules/tslib/tslib.es6.js'; import React, { forwardRef } from 'react'; import PropTypes from 'prop-types'; import classNames from '../../_virtual/index.js'; const CLink = forwardRef((_a, ref) => { var { children, active, as: Component = 'a', className, disabled } = _a, rest = __rest(_a, ["children", "active", "as", "className", "disabled"]); return (React.createElement(Component // TODO: remove duplicated classes ex. `active active` in `<CListGroupItem>` , Object.assign({ // TODO: remove duplicated classes ex. `active active` in `<CListGroupItem>` className: classNames(className, { active, disabled }) }, (active && { 'aria-current': 'page' }), (Component === 'a' && disabled && { 'aria-disabled': true, tabIndex: -1 }), ((Component === 'a' || Component === 'button') && { onClick: (event) => { event.preventDefault; !disabled && rest.onClick && rest.onClick(event); }, }), { disabled: disabled }, rest, { ref: ref }), children)); }); CLink.propTypes = { active: PropTypes.bool, as: PropTypes.elementType, children: PropTypes.node, className: PropTypes.string, disabled: PropTypes.bool, }; CLink.displayName = 'CLink'; export { CLink }; //# sourceMappingURL=CLink.js.map