welcome-ui
Version:
Customizable design system with react, typescript, tailwindcss and ariakit.
103 lines (102 loc) • 3.59 kB
JavaScript
"use client";
import { jsxs as v, jsx as r } from "react/jsx-runtime";
import C, { forwardRef as I, Children as q, cloneElement as _ } from "react";
import { Button as d } from "./Button.js";
import { CloseButton as R } from "./CloseButton.js";
import { Text as w } from "./Text.js";
import { VariantIcon as S } from "./VariantIcon.js";
import { c as T } from "./index-PAaZGbyz.js";
import { f as y } from "./forwardRefWithAs-8eP3ZN15.js";
const V = "_root_1c0qe_2", $ = "_icon_1c0qe_55", E = "_content_1c0qe_58", O = "_title_1c0qe_88", W = {
root: V,
"size-sm": "_size-sm_1c0qe_16",
"size-md": "_size-md_1c0qe_19",
"variant-ai": "_variant-ai_1c0qe_22",
"variant-beige": "_variant-beige_1c0qe_27",
"variant-danger": "_variant-danger_1c0qe_32",
"variant-info": "_variant-info_1c0qe_37",
"variant-success": "_variant-success_1c0qe_42",
"variant-warning": "_variant-warning_1c0qe_47",
"full-width": "_full-width_1c0qe_52",
icon: $,
content: E,
"content-text": "_content-text_1c0qe_76",
"content-actions": "_content-actions_1c0qe_79",
"variant-icon": "_variant-icon_1c0qe_84",
title: O,
"title-size-sm": "_title-size-sm_1c0qe_93",
"title-size-md": "_title-size-md_1c0qe_96",
"title-close-button": "_title-close-button_1c0qe_99",
"close-button": "_close-button_1c0qe_103"
}, i = T(W), D = I(
({ children: n, className: o, cta: e, handleClose: c, hideIcon: A, isFullWidth: g, size: s = "sm", variant: a, ...B }, z) => {
const h = a === "beige" ? void 0 : a, l = a === "ai", m = !A, j = q.toArray(n).map((t) => t.type === x ? _(t, { hasCloseButton: !!c, variant: s }) : t), u = (t) => {
var p;
if (t) {
if (t.type === b)
return _(t, {
size: s,
variant: l ? "primary-ai" : void 0
});
if (t.type === N)
return _(t, {
size: s,
variant: l ? "tertiary-ai" : void 0
});
if ((p = t.props) != null && p.children)
return _(t, {
...t.props,
children: q.map(
t.props.children,
(k) => u(k)
)
});
}
return t;
}, f = C.isValidElement(e) ? u(e) : e;
return /* @__PURE__ */ v(
"div",
{
className: i(
"root",
g && "full-width",
s && `size-${s}`,
a && `variant-${a}`,
m && "icon",
o
),
ref: z,
...B,
children: [
!!c && /* @__PURE__ */ r(R, { className: i("close-button"), onClick: c, size: "xs" }),
m ? /* @__PURE__ */ r(S, { className: i("variant-icon"), size: s, variant: h }) : null,
/* @__PURE__ */ v("div", { className: i("content"), children: [
/* @__PURE__ */ r(w, { as: "div", className: i("content-text"), children: j }),
!!f && /* @__PURE__ */ r("div", { className: i("content-actions"), children: f })
] })
]
}
);
}
), b = y(
({ variant: n = "secondary", ...o }, e) => /* @__PURE__ */ r(d, { className: "shrink-0 w-fit", ref: e, ...o, variant: n })
), N = y(
({ variant: n = "tertiary", ...o }, e) => /* @__PURE__ */ r(d, { className: "shrink-0 w-fit", ref: e, ...o, variant: n })
), x = ({ children: n, hasCloseButton: o, variant: e, ...c }) => /* @__PURE__ */ r(
w,
{
as: "span",
className: i("title", `title-size-${e}`, o && "title-close-button"),
variant: e,
...c,
children: n
}
), Q = Object.assign(D, {
Button: b,
SecondaryButton: N,
Title: x
});
export {
Q as Alert,
x as AlertTitle
};