@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
25 lines • 2.08 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LinkStandAlone = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = __importDefault(require("react"));
const text_1 = require("../../components/text/text");
const aria_1 = require("../../utils/aria/aria");
const elementOrIcon_1 = require("../elementOrIcon/elementOrIcon");
// styles
const link_styled_1 = require("./link.styled");
const state_1 = require("./types/state");
const LinkStandAloneComponent = ({ dataTestId = 'link', url, ...props }, ref) => {
const ariaProps = (0, aria_1.pickAriaProps)(props);
return ((0, jsx_runtime_1.jsx)(link_styled_1.TextStyledExtended, { ...ariaProps, ref: ref, alignCenter: props.alignCenter, as: text_1.Text, color: props.color, component: props.component, dataTestId: dataTestId, decoration: props.decoration, draggable: props.draggable, isDisabled: props.state === state_1.LinkStateType.DISABLED, linkStyles: props.styles, target: props.target, textStyles: props.textStyles, weight: props.weight,
//We have to make this because even it was disabled, you could access to onClick by arrows
onClick: props.state !== state_1.LinkStateType.DISABLED ? props.onClick : undefined, ...(props.state !== state_1.LinkStateType.DISABLED && { url }), role: props.role, children: props.icon ? ((0, jsx_runtime_1.jsx)(link_styled_1.LabelIconWrapper, { iconPosition: props.iconPosition, styles: props.styles?.[props.state], children: [
(0, jsx_runtime_1.jsx)(elementOrIcon_1.ElementOrIcon, { color: props.styles?.[props.state]?.icon?.color, height: props.styles?.[props.state]?.icon?.height, width: props.styles?.[props.state]?.icon?.width, ...props.icon }, "icon"),
props.children,
] })) : (props.children) }));
};
exports.LinkStandAlone = react_1.default.forwardRef(LinkStandAloneComponent);
//# sourceMappingURL=linkStandAlone.js.map