analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
157 lines (153 loc) • 5.13 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/components/Alert/Alert.tsx
var Alert_exports = {};
__export(Alert_exports, {
default: () => Alert_default
});
module.exports = __toCommonJS(Alert_exports);
var import_phosphor_react = require("phosphor-react");
// src/utils/utils.ts
var import_clsx = require("clsx");
var import_tailwind_merge = require("tailwind-merge");
function cn(...inputs) {
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
}
// src/components/Text/Text.tsx
var import_jsx_runtime = require("react/jsx-runtime");
var Text = ({
children,
size = "md",
weight = "normal",
color = "text-text-950",
as,
className = "",
...props
}) => {
let sizeClasses = "";
let weightClasses = "";
const sizeClassMap = {
"2xs": "text-2xs",
xs: "text-xs",
sm: "text-sm",
md: "text-md",
lg: "text-lg",
xl: "text-xl",
"2xl": "text-2xl",
"3xl": "text-3xl",
"4xl": "text-4xl",
"5xl": "text-5xl",
"6xl": "text-6xl"
};
sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;
const weightClassMap = {
hairline: "font-hairline",
light: "font-light",
normal: "font-normal",
medium: "font-medium",
semibold: "font-semibold",
bold: "font-bold",
extrabold: "font-extrabold",
black: "font-black"
};
weightClasses = weightClassMap[weight] ?? weightClassMap.normal;
const baseClasses = "font-primary";
const Component = as ?? "p";
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
Component,
{
className: cn(baseClasses, sizeClasses, weightClasses, color, className),
...props,
children
}
);
};
var Text_default = Text;
// src/components/Alert/Alert.tsx
var import_jsx_runtime2 = require("react/jsx-runtime");
var VARIANT_ACTION_CLASSES = {
solid: {
default: "bg-background-50 border-transparent",
info: "bg-info border-transparent",
success: "bg-success border-transparent",
warning: "bg-warning border-transparent",
error: "bg-error border-transparent"
},
outline: {
default: "bg-background border border-border-100",
info: "bg-background border border-border-100",
success: "bg-background border border-border-100",
warning: "bg-background border border-border-100",
error: "bg-background border border-border-100"
}
};
var COLOR_CLASSES = {
default: "text-text-950",
info: "text-info-800",
success: "text-success-800",
warning: "text-warning-800",
error: "text-error-800"
};
var ICONS = {
default: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_phosphor_react.CheckCircle, { size: 18 }),
info: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_phosphor_react.Info, { size: 18 }),
success: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_phosphor_react.CheckCircle, { size: 18 }),
warning: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_phosphor_react.WarningCircle, { size: 18 }),
error: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_phosphor_react.XCircle, { size: 18 })
};
var Alert = ({
variant = "solid",
title,
description,
action = "default",
className,
...props
}) => {
const baseClasses = "alert-wrapper flex items-start gap-2 w-[384px] py-3 px-4 font-inherit rounded-md";
const variantClasses = VARIANT_ACTION_CLASSES[variant][action];
const variantColor = COLOR_CLASSES[action];
const variantIcon = ICONS[action];
const hasHeading = Boolean(title);
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: cn(baseClasses, variantClasses, className), ...props, children: [
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: cn("mt-0.5", variantColor), children: variantIcon }),
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
hasHeading && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
Text_default,
{
size: "md",
weight: "medium",
color: variantColor,
className: "mb-0.5",
children: title
}
),
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
Text_default,
{
size: hasHeading ? "sm" : "md",
weight: "normal",
color: !hasHeading ? variantColor : "text-text-700",
children: description
}
)
] })
] });
};
var Alert_default = Alert;
//# sourceMappingURL=index.js.map