UNPKG

@trail-ui/react

Version:
67 lines (63 loc) 2.62 kB
"use strict"; 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/alert/index.ts var alert_exports = {}; __export(alert_exports, { Alert: () => _Alert, AlertIcon: () => AlertIcon }); module.exports = __toCommonJS(alert_exports); // src/alert/alert.tsx var import_theme = require("@trail-ui/theme"); var import_react = require("react"); var import_jsx_runtime = require("react/jsx-runtime"); function Alert(props, ref) { const { className, variant, color, radius, children, ...rest } = props; const styles = (0, import_react.useMemo)( () => (0, import_theme.alert)({ variant, color, radius, className }), [className, color, radius, variant] ); return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { role: "alert", ...rest, ref, className: styles, children }); } var _Alert = (0, import_react.forwardRef)(Alert); // src/alert/alert-icon.tsx var import_icons = require("@trail-ui/icons"); var import_shared_utils = require("@trail-ui/shared-utils"); var import_jsx_runtime2 = require("react/jsx-runtime"); var ICONS = { info: { outline: import_icons.InfoIcon, filled: import_icons.InfoFilledIcon }, yellow: { outline: import_icons.ExclamationCircleIcon, filled: import_icons.ExclamationCircleFilledIcon }, green: { outline: import_icons.CheckCircleIcon, filled: import_icons.CheckCircleFilledIcon }, error: { outline: import_icons.CloseCircleIcon, filled: import_icons.XCircleFilledIcon } }; var AlertIcon = (props) => { const { type = "info", filled = false, className, ...rest } = props; const Icon = filled ? ICONS[type].filled : ICONS[type].outline; return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { className: (0, import_shared_utils.clsx)("h-6 w-6 shrink-0", className), ...rest }); }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Alert, AlertIcon });