welcome-ui
Version:
Customizable design system with react, typescript, tailwindcss and ariakit.
87 lines (86 loc) • 2.39 kB
JavaScript
"use client";
import { jsxs as p, jsx as e } from "react/jsx-runtime";
import d from "react";
import { Button as h } from "./Button.js";
import "./Icon-BisRi8B3.js";
import { C as z } from "./index-BJLXLdM3.js";
import { c as R } from "./index-PAaZGbyz.js";
import { f as S } from "./forwardRefWithAs-8eP3ZN15.js";
const k = "_root_1xtnl_2", y = "_hasRemoveAction_1xtnl_188", C = "_isSquare_1xtnl_194", q = "_removeButton_1xtnl_199", A = {
root: k,
"variant-primary": "_variant-primary_1xtnl_59",
"variant-info": "_variant-info_1xtnl_67",
"variant-success": "_variant-success_1xtnl_75",
"variant-danger": "_variant-danger_1xtnl_83",
"variant-warning": "_variant-warning_1xtnl_91",
"variant-ai": "_variant-ai_1xtnl_99",
"variant-blue": "_variant-blue_1xtnl_107",
"variant-green": "_variant-green_1xtnl_115",
"variant-orange": "_variant-orange_1xtnl_123",
"variant-pink": "_variant-pink_1xtnl_131",
"variant-teal": "_variant-teal_1xtnl_139",
"variant-violet": "_variant-violet_1xtnl_147",
"size-xs": "_size-xs_1xtnl_155",
"size-sm": "_size-sm_1xtnl_166",
"size-md": "_size-md_1xtnl_177",
hasRemoveAction: y,
isSquare: C,
removeButton: q
}, s = R(A);
function N(t) {
if (typeof t == "string" || typeof t == "number")
return t.toString().length;
if (d.isValidElement(t) && typeof t.props.children == "string")
return t.props.children.length;
}
const I = S((t, o) => {
const {
as: _ = "div",
children: i,
className: l,
icon: v,
onClick: m,
onRemove: a,
removeButtonProps: n,
size: c = "md",
variant: r,
...x
} = t, f = N(i) === 1 && !a, u = (g) => {
n != null && n.onClick && n.onClick(g), a && a();
};
return /* @__PURE__ */ p(
_,
{
className: s(
"root",
r && `variant-${r}`,
`size-${c}`,
!!a && "hasRemoveAction",
f && "isSquare",
l
),
onClick: m,
ref: o,
...x,
children: [
v,
i,
a ? /* @__PURE__ */ e(
h,
{
"aria-label": "remove tag",
...n,
className: s("removeButton", n == null ? void 0 : n.className),
onClick: u,
size: "xs",
variant: "ghost",
children: /* @__PURE__ */ e(z, { size: "xs" })
}
) : null
]
}
);
});
export {
I as Tag
};