UNPKG

welcome-ui

Version:

Customizable design system with react, typescript, tailwindcss and ariakit.

73 lines (72 loc) 2.5 kB
"use client"; import './Link.css'; import { jsxs as d, jsx as n } from "react/jsx-runtime"; import l from "react"; import { Icon as u } from "./Icon.js"; import { c as v } from "./index-B6iGEm-i.js"; import { f as w } from "./forwardRefWithAs-8eP3ZN15.js"; const E = "_root_1xbep_2", M = "_isExternal_1xbep_14", W = "_isMultiline_1xbep_134", L = { root: E, isExternal: M, "wui-text": "_wui-text_1xbep_17", "variant-primary": "_variant-primary_1xbep_21", "variant-secondary": "_variant-secondary_1xbep_28", "size-xs": "_size-xs_1xbep_102", "size-sm": "_size-sm_1xbep_107", "size-md": "_size-md_1xbep_113", "size-lg": "_size-lg_1xbep_118", isMultiline: W, "icon-disabled": "_icon-disabled_1xbep_137" }, r = v(L), p = ({ children: e, isExternal: a, size: s }) => /* @__PURE__ */ d("span", { className: r("wui-text"), children: [ e, a ? /* @__PURE__ */ n(u, { name: "external-link-alt", size: s }) : null ] }); p.displayName = "Link.Wrapper"; const c = (e, a, s) => typeof e == "string" ? /* @__PURE__ */ n(p, { isExternal: s, size: a, children: e }) : l.isValidElement(e) && (e.type === "span" || e.props.as === "span" || // FormattedMessage from react-intl has a span tag by default e.props.tagName === "span" || e.props["data-wui-link"] === !0 || typeof e.props.children == "string") ? s ? /* @__PURE__ */ n(p, { isExternal: s, size: a, children: e }) : ( // If it is not external, we just need to add wui-text className to the child as we don't need to wrap it to display the icon l.cloneElement(e, { className: r("wui-text", e.props.className) }) ) : e, j = w((e, a) => { const { as: s, children: i, className: b, disabled: t, isExternal: o, multiline: f, size: m = "md", target: _, variant: y = "primary", ...z } = e, N = s || "a", x = m === "xs" ? "sm" : "md", k = typeof i == "string" ? c(i, x, o) : l.Children.map(i, (g) => c(g, x, o)); return /* @__PURE__ */ d( N, { "aria-disabled": t, className: r( "root", `variant-${y}`, `size-${m}`, o && "isExternal", f && "isMultiline", b ), ref: a, rel: _ === "_blank" ? "noopener noreferrer" : void 0, tabIndex: t ? -1 : 0, target: _, ...z, children: [ t ? /* @__PURE__ */ n(u, { className: r("icon-disabled"), name: "ban", size: "md" }) : null, k ] } ); }); j.displayName = "Link"; export { j as Link, L as linkClasses };