welcome-ui
Version:
Customizable design system with react • styled-components • styled-system and ariakit.
82 lines (77 loc) • 2.48 kB
JavaScript
"use client";
import { j as s } from "./jsx-runtime-Bqq1Hxg9.mjs";
import h from "react";
import "./Icon.mjs";
import { E as f } from "./index-CwnxYrRd.mjs";
import { shouldForwardProp as g, forwardRef as y } from "./System.mjs";
import k, { system as $, th as i, typography as w, css as j } from "@xstyled/styled-components";
import { UniversalLink as E } from "./UniversalLink.mjs";
const L = k(E).withConfig({ shouldForwardProp: g })(
({ isExternal: t, variant: n = "primary" }) => j`
display: inline-flex;
flex-direction: row;
align-items: center;
opacity: 1;
line-height: 1.5;
text-decoration: none;
cursor: pointer;
${$}
> .wui-text {
margin-right: -2px;
margin-left: -2px;
padding-left: 2px;
padding-right: 2px;
${i("underline.default")};
${i("links.default")};
${i(`links.${n}.default`)};
${t && i("links.withExternalLink")};
${w};
}
&:hover,
&:focus {
> .wui-text {
${i("underline.hover")};
${i(`links.${n}.hover`)};
outline: none !important;
}
}
&[disabled] {
> .wui-text {
${i("links.disabled")};
}
pointer-events: none;
}
& > *:not(:only-child):not(:last-child) {
margin-right: xs;
}
`
), W = (t) => {
var n, r, e;
return (
// <span />
(t == null ? void 0 : t.type) === "span" || // <Box as="span" />
((n = t == null ? void 0 : t.props) == null ? void 0 : n.as) === "span" || // <FormattedMessage />
((r = t == null ? void 0 : t.props) == null ? void 0 : r.tagName) === "span" || ((e = t == null ? void 0 : t.props) == null ? void 0 : e["data-wui-link"]) === !0
);
}, d = (t) => typeof t == "object" ? W(t) : typeof t == "string", m = ({ children: t, isExternal: n }) => /* @__PURE__ */ s.jsxs("span", { className: "wui-text", children: [
t,
n ? /* @__PURE__ */ s.jsx(f, { mb: "-2px", ml: "sm", size: "sm" }) : null
] }), b = y((t, n) => {
const { children: r, dataTestId: e, disabled: a, isExternal: o, variant: x = "primary", ...l } = t, c = d(r) ? /* @__PURE__ */ s.jsx(m, { isExternal: o, children: r }) : h.Children.map(r, (p) => d(p) ? /* @__PURE__ */ s.jsx(m, { isExternal: o, children: p }) : p);
return /* @__PURE__ */ s.jsx(
L,
{
"data-testid": e,
disabled: a,
isExternal: o,
ref: n,
variant: x,
...l,
children: c
}
);
});
b.displayName = "Link";
export {
b as Link
};