@karakuri-ui/react 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/components/ui/accordion.d.mts +49 -0
- package/dist/components/ui/accordion.d.ts +49 -0
- package/dist/components/ui/accordion.js +220 -0
- package/dist/components/ui/accordion.js.map +1 -0
- package/dist/components/ui/accordion.mjs +181 -0
- package/dist/components/ui/accordion.mjs.map +1 -0
- package/dist/components/ui/alert.d.mts +47 -0
- package/dist/components/ui/alert.d.ts +47 -0
- package/dist/components/ui/alert.js +223 -0
- package/dist/components/ui/alert.js.map +1 -0
- package/dist/components/ui/alert.mjs +185 -0
- package/dist/components/ui/alert.mjs.map +1 -0
- package/dist/components/ui/avatar.d.mts +232 -0
- package/dist/components/ui/avatar.d.ts +232 -0
- package/dist/components/ui/avatar.js +250 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/avatar.mjs +209 -0
- package/dist/components/ui/avatar.mjs.map +1 -0
- package/dist/components/ui/badge.d.mts +31 -0
- package/dist/components/ui/badge.d.ts +31 -0
- package/dist/components/ui/badge.js +205 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/badge.mjs +170 -0
- package/dist/components/ui/badge.mjs.map +1 -0
- package/dist/components/ui/breadcrumb.d.mts +57 -0
- package/dist/components/ui/breadcrumb.d.ts +57 -0
- package/dist/components/ui/breadcrumb.js +209 -0
- package/dist/components/ui/breadcrumb.js.map +1 -0
- package/dist/components/ui/breadcrumb.mjs +168 -0
- package/dist/components/ui/breadcrumb.mjs.map +1 -0
- package/dist/components/ui/button-group.d.mts +22 -0
- package/dist/components/ui/button-group.d.ts +22 -0
- package/dist/components/ui/button-group.js +107 -0
- package/dist/components/ui/button-group.js.map +1 -0
- package/dist/components/ui/button-group.mjs +72 -0
- package/dist/components/ui/button-group.mjs.map +1 -0
- package/dist/components/ui/button.d.mts +31 -0
- package/dist/components/ui/button.d.ts +31 -0
- package/dist/components/ui/button.js +176 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/button.mjs +141 -0
- package/dist/components/ui/button.mjs.map +1 -0
- package/dist/components/ui/card.d.mts +77 -0
- package/dist/components/ui/card.d.ts +77 -0
- package/dist/components/ui/card.js +370 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/card.mjs +328 -0
- package/dist/components/ui/card.mjs.map +1 -0
- package/dist/{chart.js → components/ui/chart.js} +29 -39
- package/dist/components/ui/chart.js.map +1 -0
- package/dist/{chart.mjs → components/ui/chart.mjs} +21 -31
- package/dist/components/ui/chart.mjs.map +1 -0
- package/dist/components/ui/checkbox.d.mts +24 -0
- package/dist/components/ui/checkbox.d.ts +24 -0
- package/dist/components/ui/checkbox.js +173 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/checkbox.mjs +138 -0
- package/dist/components/ui/checkbox.mjs.map +1 -0
- package/dist/components/ui/divider.d.mts +27 -0
- package/dist/components/ui/divider.d.ts +27 -0
- package/dist/components/ui/divider.js +147 -0
- package/dist/components/ui/divider.js.map +1 -0
- package/dist/components/ui/divider.mjs +112 -0
- package/dist/components/ui/divider.mjs.map +1 -0
- package/dist/components/ui/drawer.d.mts +51 -0
- package/dist/components/ui/drawer.d.ts +51 -0
- package/dist/components/ui/drawer.js +225 -0
- package/dist/components/ui/drawer.js.map +1 -0
- package/dist/components/ui/drawer.mjs +178 -0
- package/dist/components/ui/drawer.mjs.map +1 -0
- package/dist/components/ui/dropdown.d.mts +59 -0
- package/dist/components/ui/dropdown.d.ts +59 -0
- package/dist/components/ui/dropdown.js +310 -0
- package/dist/components/ui/dropdown.js.map +1 -0
- package/dist/components/ui/dropdown.mjs +263 -0
- package/dist/components/ui/dropdown.mjs.map +1 -0
- package/dist/components/ui/field.d.mts +33 -0
- package/dist/components/ui/field.d.ts +33 -0
- package/dist/components/ui/field.js +146 -0
- package/dist/components/ui/field.js.map +1 -0
- package/dist/components/ui/field.mjs +108 -0
- package/dist/components/ui/field.mjs.map +1 -0
- package/dist/components/ui/icon-button.d.mts +20 -0
- package/dist/components/ui/icon-button.d.ts +20 -0
- package/dist/components/ui/icon-button.js +147 -0
- package/dist/components/ui/icon-button.js.map +1 -0
- package/dist/components/ui/icon-button.mjs +112 -0
- package/dist/components/ui/icon-button.mjs.map +1 -0
- package/dist/components/ui/index.d.mts +55 -0
- package/dist/components/ui/index.d.ts +55 -0
- package/dist/components/ui/index.js +476 -0
- package/dist/components/ui/index.js.map +1 -0
- package/dist/components/ui/index.mjs +246 -0
- package/dist/components/ui/index.mjs.map +1 -0
- package/dist/components/ui/input.d.mts +20 -0
- package/dist/components/ui/input.d.ts +20 -0
- package/dist/components/ui/input.js +250 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/input.mjs +215 -0
- package/dist/components/ui/input.mjs.map +1 -0
- package/dist/components/ui/metric-card.d.mts +53 -0
- package/dist/components/ui/metric-card.d.ts +53 -0
- package/dist/components/ui/metric-card.js +258 -0
- package/dist/components/ui/metric-card.js.map +1 -0
- package/dist/components/ui/metric-card.mjs +217 -0
- package/dist/components/ui/metric-card.mjs.map +1 -0
- package/dist/components/ui/modal.d.mts +77 -0
- package/dist/components/ui/modal.d.ts +77 -0
- package/dist/components/ui/modal.js +396 -0
- package/dist/components/ui/modal.js.map +1 -0
- package/dist/components/ui/modal.mjs +338 -0
- package/dist/components/ui/modal.mjs.map +1 -0
- package/dist/components/ui/navigation-menu.d.mts +139 -0
- package/dist/components/ui/navigation-menu.d.ts +139 -0
- package/dist/components/ui/navigation-menu.js +531 -0
- package/dist/components/ui/navigation-menu.js.map +1 -0
- package/dist/components/ui/navigation-menu.mjs +488 -0
- package/dist/components/ui/navigation-menu.mjs.map +1 -0
- package/dist/components/ui/pagination.d.mts +130 -0
- package/dist/components/ui/pagination.d.ts +130 -0
- package/dist/components/ui/pagination.js +495 -0
- package/dist/components/ui/pagination.js.map +1 -0
- package/dist/components/ui/pagination.mjs +449 -0
- package/dist/components/ui/pagination.mjs.map +1 -0
- package/dist/components/ui/popover.d.mts +41 -0
- package/dist/components/ui/popover.d.ts +41 -0
- package/dist/components/ui/popover.js +175 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/popover.mjs +133 -0
- package/dist/components/ui/popover.mjs.map +1 -0
- package/dist/components/ui/progress.d.mts +35 -0
- package/dist/components/ui/progress.d.ts +35 -0
- package/dist/components/ui/progress.js +194 -0
- package/dist/components/ui/progress.js.map +1 -0
- package/dist/components/ui/progress.mjs +159 -0
- package/dist/components/ui/progress.mjs.map +1 -0
- package/dist/components/ui/radio-group.d.mts +40 -0
- package/dist/components/ui/radio-group.d.ts +40 -0
- package/dist/components/ui/radio-group.js +177 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/radio-group.mjs +140 -0
- package/dist/components/ui/radio-group.mjs.map +1 -0
- package/dist/components/ui/segmented.d.mts +30 -0
- package/dist/components/ui/segmented.d.ts +30 -0
- package/dist/components/ui/segmented.js +241 -0
- package/dist/components/ui/segmented.js.map +1 -0
- package/dist/components/ui/segmented.mjs +204 -0
- package/dist/components/ui/segmented.mjs.map +1 -0
- package/dist/components/ui/select.d.mts +31 -0
- package/dist/components/ui/select.d.ts +31 -0
- package/dist/components/ui/select.js +317 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/select.mjs +276 -0
- package/dist/components/ui/select.mjs.map +1 -0
- package/dist/components/ui/skeleton.d.mts +26 -0
- package/dist/components/ui/skeleton.d.ts +26 -0
- package/dist/components/ui/skeleton.js +144 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/skeleton.mjs +109 -0
- package/dist/components/ui/skeleton.mjs.map +1 -0
- package/dist/components/ui/slider.d.mts +38 -0
- package/dist/components/ui/slider.d.ts +38 -0
- package/dist/components/ui/slider.js +180 -0
- package/dist/components/ui/slider.js.map +1 -0
- package/dist/components/ui/slider.mjs +145 -0
- package/dist/components/ui/slider.mjs.map +1 -0
- package/dist/components/ui/spinner.d.mts +23 -0
- package/dist/components/ui/spinner.d.ts +23 -0
- package/dist/components/ui/spinner.js +471 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/spinner.mjs +436 -0
- package/dist/components/ui/spinner.mjs.map +1 -0
- package/dist/components/ui/switch.d.mts +22 -0
- package/dist/components/ui/switch.d.ts +22 -0
- package/dist/components/ui/switch.js +173 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/switch.mjs +138 -0
- package/dist/components/ui/switch.mjs.map +1 -0
- package/dist/components/ui/table.d.mts +74 -0
- package/dist/components/ui/table.d.ts +74 -0
- package/dist/components/ui/table.js +240 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/table.mjs +199 -0
- package/dist/components/ui/table.mjs.map +1 -0
- package/dist/components/ui/tabs.d.mts +40 -0
- package/dist/components/ui/tabs.d.ts +40 -0
- package/dist/components/ui/tabs.js +238 -0
- package/dist/components/ui/tabs.js.map +1 -0
- package/dist/components/ui/tabs.mjs +199 -0
- package/dist/components/ui/tabs.mjs.map +1 -0
- package/dist/components/ui/textarea.d.mts +19 -0
- package/dist/components/ui/textarea.d.ts +19 -0
- package/dist/components/ui/textarea.js +181 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/textarea.mjs +146 -0
- package/dist/components/ui/textarea.mjs.map +1 -0
- package/dist/components/ui/toast.d.mts +93 -0
- package/dist/components/ui/toast.d.ts +93 -0
- package/dist/components/ui/toast.js +429 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/components/ui/toast.mjs +393 -0
- package/dist/components/ui/toast.mjs.map +1 -0
- package/dist/components/ui/toggle-group.d.mts +47 -0
- package/dist/components/ui/toggle-group.d.ts +47 -0
- package/dist/components/ui/toggle-group.js +186 -0
- package/dist/components/ui/toggle-group.js.map +1 -0
- package/dist/components/ui/toggle-group.mjs +149 -0
- package/dist/components/ui/toggle-group.mjs.map +1 -0
- package/dist/components/ui/toggle.d.mts +19 -0
- package/dist/components/ui/toggle.d.ts +19 -0
- package/dist/components/ui/toggle.js +194 -0
- package/dist/components/ui/toggle.js.map +1 -0
- package/dist/components/ui/toggle.mjs +159 -0
- package/dist/components/ui/toggle.mjs.map +1 -0
- package/dist/components/ui/tooltip.d.mts +37 -0
- package/dist/components/ui/tooltip.d.ts +37 -0
- package/dist/components/ui/tooltip.js +137 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/components/ui/tooltip.mjs +96 -0
- package/dist/components/ui/tooltip.mjs.map +1 -0
- package/dist/lib/utils.d.mts +10 -0
- package/dist/lib/utils.d.ts +10 -0
- package/dist/lib/utils.js +33 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/utils.mjs +9 -0
- package/dist/lib/utils.mjs.map +1 -0
- package/package.json +11 -11
- package/dist/chart.js.map +0 -1
- package/dist/chart.mjs.map +0 -1
- package/dist/index.d.mts +0 -1636
- package/dist/index.d.ts +0 -1636
- package/dist/index.js +0 -7291
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -7048
- package/dist/index.mjs.map +0 -1
- /package/dist/{chart.d.mts → components/ui/chart.d.mts} +0 -0
- /package/dist/{chart.d.ts → components/ui/chart.d.ts} +0 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var avatar_exports = {};
|
|
31
|
+
__export(avatar_exports, {
|
|
32
|
+
Avatar: () => Avatar,
|
|
33
|
+
AvatarFallback: () => AvatarFallback,
|
|
34
|
+
AvatarGroup: () => AvatarGroup,
|
|
35
|
+
AvatarImage: () => AvatarImage,
|
|
36
|
+
avatarColors: () => avatarColors,
|
|
37
|
+
avatarVariants: () => avatarVariants,
|
|
38
|
+
getAvatarColor: () => getAvatarColor,
|
|
39
|
+
getAvatarInitials: () => getAvatarInitials
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(avatar_exports);
|
|
42
|
+
var React = __toESM(require("react"));
|
|
43
|
+
var AvatarPrimitive = __toESM(require("@radix-ui/react-avatar"));
|
|
44
|
+
var import_class_variance_authority = require("class-variance-authority");
|
|
45
|
+
var import_utils = require("../../lib/utils");
|
|
46
|
+
const avatarVariants = (0, import_class_variance_authority.cva)(
|
|
47
|
+
"relative inline-flex items-center justify-center overflow-hidden bg-background-muted select-none",
|
|
48
|
+
{
|
|
49
|
+
variants: {
|
|
50
|
+
size: {
|
|
51
|
+
xs: "w-6 h-6",
|
|
52
|
+
// 24px
|
|
53
|
+
sm: "w-8 h-8",
|
|
54
|
+
// 32px
|
|
55
|
+
default: "w-10 h-10",
|
|
56
|
+
// 40px
|
|
57
|
+
lg: "w-12 h-12",
|
|
58
|
+
// 48px
|
|
59
|
+
xl: "w-16 h-16",
|
|
60
|
+
// 64px
|
|
61
|
+
"2xl": "w-20 h-20"
|
|
62
|
+
// 80px
|
|
63
|
+
},
|
|
64
|
+
shape: {
|
|
65
|
+
circle: "rounded-full",
|
|
66
|
+
square: "rounded-xl"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
defaultVariants: { size: "default", shape: "circle" }
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
const statusDotSizes = {
|
|
73
|
+
xs: "w-1.5 h-1.5",
|
|
74
|
+
sm: "w-2 h-2",
|
|
75
|
+
default: "w-2.5 h-2.5",
|
|
76
|
+
lg: "w-3 h-3",
|
|
77
|
+
xl: "w-3.5 h-3.5",
|
|
78
|
+
"2xl": "w-4 h-4"
|
|
79
|
+
};
|
|
80
|
+
const statusColors = {
|
|
81
|
+
online: "bg-success",
|
|
82
|
+
offline: "bg-text-muted",
|
|
83
|
+
busy: "bg-error",
|
|
84
|
+
away: "bg-warning"
|
|
85
|
+
};
|
|
86
|
+
const fallbackFontSizes = {
|
|
87
|
+
xs: "text-2xs",
|
|
88
|
+
sm: "text-xs",
|
|
89
|
+
default: "text-sm",
|
|
90
|
+
lg: "text-base",
|
|
91
|
+
xl: "text-xl",
|
|
92
|
+
"2xl": "text-2xl"
|
|
93
|
+
};
|
|
94
|
+
const groupNegativeMargins = {
|
|
95
|
+
xs: "-space-x-1.5",
|
|
96
|
+
sm: "-space-x-2",
|
|
97
|
+
default: "-space-x-2.5",
|
|
98
|
+
lg: "-space-x-3",
|
|
99
|
+
xl: "-space-x-4",
|
|
100
|
+
"2xl": "-space-x-5"
|
|
101
|
+
};
|
|
102
|
+
const avatarColors = [
|
|
103
|
+
{ vivid: { bg: "bg-[#DC2626]", text: "text-white" }, soft: { bg: "bg-[#FEE2E2]", text: "text-[#DC2626]" } },
|
|
104
|
+
// red
|
|
105
|
+
{ vivid: { bg: "bg-[#EA580C]", text: "text-white" }, soft: { bg: "bg-[#FFEDD5]", text: "text-[#EA580C]" } },
|
|
106
|
+
// orange
|
|
107
|
+
{ vivid: { bg: "bg-[#D97706]", text: "text-white" }, soft: { bg: "bg-[#FEF3C7]", text: "text-[#B45309]" } },
|
|
108
|
+
// amber
|
|
109
|
+
{ vivid: { bg: "bg-[#CA8A04]", text: "text-white" }, soft: { bg: "bg-[#FEF9C3]", text: "text-[#A16207]" } },
|
|
110
|
+
// yellow
|
|
111
|
+
{ vivid: { bg: "bg-[#059669]", text: "text-white" }, soft: { bg: "bg-[#D1FAE5]", text: "text-[#047857]" } },
|
|
112
|
+
// emerald
|
|
113
|
+
{ vivid: { bg: "bg-[#0D9488]", text: "text-white" }, soft: { bg: "bg-[#CCFBF1]", text: "text-[#0F766E]" } },
|
|
114
|
+
// teal
|
|
115
|
+
{ vivid: { bg: "bg-[#0891B2]", text: "text-white" }, soft: { bg: "bg-[#CFFAFE]", text: "text-[#0E7490]" } },
|
|
116
|
+
// cyan
|
|
117
|
+
{ vivid: { bg: "bg-[#2563EB]", text: "text-white" }, soft: { bg: "bg-[#DBEAFE]", text: "text-[#1D4ED8]" } },
|
|
118
|
+
// blue
|
|
119
|
+
{ vivid: { bg: "bg-[#4F46E5]", text: "text-white" }, soft: { bg: "bg-[#E0E7FF]", text: "text-[#4338CA]" } },
|
|
120
|
+
// indigo
|
|
121
|
+
{ vivid: { bg: "bg-[#7C3AED]", text: "text-white" }, soft: { bg: "bg-[#EDE9FE]", text: "text-[#6D28D9]" } },
|
|
122
|
+
// violet
|
|
123
|
+
{ vivid: { bg: "bg-[#9333EA]", text: "text-white" }, soft: { bg: "bg-[#F3E8FF]", text: "text-[#7E22CE]" } },
|
|
124
|
+
// purple
|
|
125
|
+
{ vivid: { bg: "bg-[#DB2777]", text: "text-white" }, soft: { bg: "bg-[#FCE7F3]", text: "text-[#BE185D]" } }
|
|
126
|
+
// pink
|
|
127
|
+
];
|
|
128
|
+
function getAvatarInitials(name, maxChars = 2) {
|
|
129
|
+
const trimmed = name.trim();
|
|
130
|
+
if (!trimmed) return "";
|
|
131
|
+
const cjkRegex = /[\u3000-\u9fff\uac00-\ud7af\uff00-\uffef]/;
|
|
132
|
+
if (cjkRegex.test(trimmed.charAt(0))) {
|
|
133
|
+
return trimmed.slice(0, maxChars);
|
|
134
|
+
}
|
|
135
|
+
const parts = trimmed.split(/[\s\-_.]+/).filter(Boolean);
|
|
136
|
+
if (parts.length === 1) {
|
|
137
|
+
return parts[0].charAt(0).toUpperCase();
|
|
138
|
+
}
|
|
139
|
+
return (parts[0].charAt(0) + parts[parts.length - 1].charAt(0)).toUpperCase().slice(0, maxChars);
|
|
140
|
+
}
|
|
141
|
+
function getAvatarColor(name, variant = "vivid") {
|
|
142
|
+
let hash = 5381;
|
|
143
|
+
for (let i = 0; i < name.length; i++) {
|
|
144
|
+
hash = (hash << 5) + hash ^ name.charCodeAt(i);
|
|
145
|
+
}
|
|
146
|
+
return avatarColors[(hash >>> 0) % avatarColors.length][variant];
|
|
147
|
+
}
|
|
148
|
+
const AvatarRoot = React.forwardRef(({ className, size, shape, status, children, ...props }, ref) => {
|
|
149
|
+
const resolvedSize = size || "default";
|
|
150
|
+
if (!status) {
|
|
151
|
+
return /* @__PURE__ */ React.createElement(
|
|
152
|
+
AvatarPrimitive.Root,
|
|
153
|
+
{
|
|
154
|
+
ref,
|
|
155
|
+
className: (0, import_utils.cn)(avatarVariants({ size, shape }), className),
|
|
156
|
+
...props
|
|
157
|
+
},
|
|
158
|
+
children
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
return /* @__PURE__ */ React.createElement("span", { className: "relative inline-flex" }, /* @__PURE__ */ React.createElement(
|
|
162
|
+
AvatarPrimitive.Root,
|
|
163
|
+
{
|
|
164
|
+
ref,
|
|
165
|
+
className: (0, import_utils.cn)(avatarVariants({ size, shape }), className),
|
|
166
|
+
...props
|
|
167
|
+
},
|
|
168
|
+
children
|
|
169
|
+
), /* @__PURE__ */ React.createElement(
|
|
170
|
+
"span",
|
|
171
|
+
{
|
|
172
|
+
className: (0, import_utils.cn)(
|
|
173
|
+
"absolute bottom-0 right-0 rounded-full ring-2 ring-background",
|
|
174
|
+
statusDotSizes[resolvedSize],
|
|
175
|
+
statusColors[status]
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
));
|
|
179
|
+
});
|
|
180
|
+
AvatarRoot.displayName = "Avatar";
|
|
181
|
+
const AvatarImage = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
|
|
182
|
+
AvatarPrimitive.Image,
|
|
183
|
+
{
|
|
184
|
+
ref,
|
|
185
|
+
className: (0, import_utils.cn)("object-cover w-full h-full", className),
|
|
186
|
+
...props
|
|
187
|
+
}
|
|
188
|
+
));
|
|
189
|
+
AvatarImage.displayName = "AvatarImage";
|
|
190
|
+
const AvatarFallback = React.forwardRef(({ className, size, name, colorized, colorVariant = "vivid", children, ...props }, ref) => {
|
|
191
|
+
const resolvedSize = size || "default";
|
|
192
|
+
const colorKey = name || colorized;
|
|
193
|
+
const color = colorKey ? getAvatarColor(colorKey, colorVariant) : null;
|
|
194
|
+
const resolvedChildren = children ?? (name ? getAvatarInitials(name) : void 0);
|
|
195
|
+
return /* @__PURE__ */ React.createElement(
|
|
196
|
+
AvatarPrimitive.Fallback,
|
|
197
|
+
{
|
|
198
|
+
ref,
|
|
199
|
+
className: (0, import_utils.cn)(
|
|
200
|
+
"flex items-center justify-center w-full h-full font-semibold",
|
|
201
|
+
color ? [color.bg, color.text] : "bg-background-muted text-text-muted",
|
|
202
|
+
fallbackFontSizes[resolvedSize],
|
|
203
|
+
className
|
|
204
|
+
),
|
|
205
|
+
...props
|
|
206
|
+
},
|
|
207
|
+
resolvedChildren
|
|
208
|
+
);
|
|
209
|
+
});
|
|
210
|
+
AvatarFallback.displayName = "AvatarFallback";
|
|
211
|
+
const AvatarGroup = React.forwardRef(
|
|
212
|
+
({ className, max, size = "default", shape = "circle", children, ...props }, ref) => {
|
|
213
|
+
const childArray = React.Children.toArray(children);
|
|
214
|
+
const visibleChildren = max ? childArray.slice(0, max) : childArray;
|
|
215
|
+
const overflowCount = max ? childArray.length - max : 0;
|
|
216
|
+
return /* @__PURE__ */ React.createElement(
|
|
217
|
+
"div",
|
|
218
|
+
{
|
|
219
|
+
ref,
|
|
220
|
+
className: (0, import_utils.cn)(
|
|
221
|
+
"flex items-center",
|
|
222
|
+
groupNegativeMargins[size],
|
|
223
|
+
"[&>*]:ring-2 [&>*]:ring-background",
|
|
224
|
+
className
|
|
225
|
+
),
|
|
226
|
+
...props
|
|
227
|
+
},
|
|
228
|
+
visibleChildren,
|
|
229
|
+
overflowCount > 0 && /* @__PURE__ */ React.createElement(AvatarRoot, { size, shape }, /* @__PURE__ */ React.createElement(AvatarFallback, { size }, "+", overflowCount))
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
AvatarGroup.displayName = "AvatarGroup";
|
|
234
|
+
const Avatar = Object.assign(AvatarRoot, {
|
|
235
|
+
Image: AvatarImage,
|
|
236
|
+
Fallback: AvatarFallback,
|
|
237
|
+
Group: AvatarGroup
|
|
238
|
+
});
|
|
239
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
240
|
+
0 && (module.exports = {
|
|
241
|
+
Avatar,
|
|
242
|
+
AvatarFallback,
|
|
243
|
+
AvatarGroup,
|
|
244
|
+
AvatarImage,
|
|
245
|
+
avatarColors,
|
|
246
|
+
avatarVariants,
|
|
247
|
+
getAvatarColor,
|
|
248
|
+
getAvatarInitials
|
|
249
|
+
});
|
|
250
|
+
//# sourceMappingURL=avatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/avatar.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport * as AvatarPrimitive from '@radix-ui/react-avatar'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// Avatar root variants\nconst avatarVariants = cva(\n 'relative inline-flex items-center justify-center overflow-hidden bg-background-muted select-none',\n {\n variants: {\n size: {\n xs: 'w-6 h-6', // 24px\n sm: 'w-8 h-8', // 32px\n default: 'w-10 h-10', // 40px\n lg: 'w-12 h-12', // 48px\n xl: 'w-16 h-16', // 64px\n '2xl': 'w-20 h-20', // 80px\n },\n shape: {\n circle: 'rounded-full',\n square: 'rounded-xl',\n },\n },\n defaultVariants: { size: 'default', shape: 'circle' },\n }\n)\n\n// Status dot sizes per avatar size\nconst statusDotSizes = {\n xs: 'w-1.5 h-1.5',\n sm: 'w-2 h-2',\n default: 'w-2.5 h-2.5',\n lg: 'w-3 h-3',\n xl: 'w-3.5 h-3.5',\n '2xl': 'w-4 h-4',\n}\n\n// Status dot colors\nconst statusColors = {\n online: 'bg-success',\n offline: 'bg-text-muted',\n busy: 'bg-error',\n away: 'bg-warning',\n}\n\n// Fallback font sizes per avatar size\nconst fallbackFontSizes = {\n xs: 'text-2xs',\n sm: 'text-xs',\n default: 'text-sm',\n lg: 'text-base',\n xl: 'text-xl',\n '2xl': 'text-2xl',\n}\n\n// Negative margin per size for AvatarGroup overlap\nconst groupNegativeMargins = {\n xs: '-space-x-1.5',\n sm: '-space-x-2',\n default: '-space-x-2.5',\n lg: '-space-x-3',\n xl: '-space-x-4',\n '2xl': '-space-x-5',\n}\n\n// Colorized fallback palette (12 colors × 2 variants) — exception 13 in TOKEN-EXCEPTIONS.md\nconst avatarColors = [\n { vivid: { bg: 'bg-[#DC2626]', text: 'text-white' }, soft: { bg: 'bg-[#FEE2E2]', text: 'text-[#DC2626]' } }, // red\n { vivid: { bg: 'bg-[#EA580C]', text: 'text-white' }, soft: { bg: 'bg-[#FFEDD5]', text: 'text-[#EA580C]' } }, // orange\n { vivid: { bg: 'bg-[#D97706]', text: 'text-white' }, soft: { bg: 'bg-[#FEF3C7]', text: 'text-[#B45309]' } }, // amber\n { vivid: { bg: 'bg-[#CA8A04]', text: 'text-white' }, soft: { bg: 'bg-[#FEF9C3]', text: 'text-[#A16207]' } }, // yellow\n { vivid: { bg: 'bg-[#059669]', text: 'text-white' }, soft: { bg: 'bg-[#D1FAE5]', text: 'text-[#047857]' } }, // emerald\n { vivid: { bg: 'bg-[#0D9488]', text: 'text-white' }, soft: { bg: 'bg-[#CCFBF1]', text: 'text-[#0F766E]' } }, // teal\n { vivid: { bg: 'bg-[#0891B2]', text: 'text-white' }, soft: { bg: 'bg-[#CFFAFE]', text: 'text-[#0E7490]' } }, // cyan\n { vivid: { bg: 'bg-[#2563EB]', text: 'text-white' }, soft: { bg: 'bg-[#DBEAFE]', text: 'text-[#1D4ED8]' } }, // blue\n { vivid: { bg: 'bg-[#4F46E5]', text: 'text-white' }, soft: { bg: 'bg-[#E0E7FF]', text: 'text-[#4338CA]' } }, // indigo\n { vivid: { bg: 'bg-[#7C3AED]', text: 'text-white' }, soft: { bg: 'bg-[#EDE9FE]', text: 'text-[#6D28D9]' } }, // violet\n { vivid: { bg: 'bg-[#9333EA]', text: 'text-white' }, soft: { bg: 'bg-[#F3E8FF]', text: 'text-[#7E22CE]' } }, // purple\n { vivid: { bg: 'bg-[#DB2777]', text: 'text-white' }, soft: { bg: 'bg-[#FCE7F3]', text: 'text-[#BE185D]' } }, // pink\n] as const\n\nexport type AvatarColorVariant = 'vivid' | 'soft'\n\n/** Extract initials from a name string (e.g. \"John Doe\" → \"JD\", \"김민수\" → \"김민\") */\nfunction getAvatarInitials(name: string, maxChars = 2): string {\n const trimmed = name.trim()\n if (!trimmed) return ''\n\n // CJK: use first character(s) directly\n const cjkRegex = /[\\u3000-\\u9fff\\uac00-\\ud7af\\uff00-\\uffef]/\n if (cjkRegex.test(trimmed.charAt(0))) {\n return trimmed.slice(0, maxChars)\n }\n\n // Split on spaces, hyphens, underscores, dots\n const parts = trimmed.split(/[\\s\\-_.]+/).filter(Boolean)\n if (parts.length === 1) {\n return parts[0].charAt(0).toUpperCase()\n }\n\n // First + last part initials\n return (parts[0].charAt(0) + parts[parts.length - 1].charAt(0))\n .toUpperCase()\n .slice(0, maxChars)\n}\n\n/** Hash a name string to a deterministic avatar color pair (djb2 xor variant) */\nfunction getAvatarColor(name: string, variant: AvatarColorVariant = 'vivid') {\n let hash = 5381\n for (let i = 0; i < name.length; i++) {\n hash = ((hash << 5) + hash) ^ name.charCodeAt(i)\n }\n return avatarColors[(hash >>> 0) % avatarColors.length][variant]\n}\n\nexport type AvatarSize = 'xs' | 'sm' | 'default' | 'lg' | 'xl' | '2xl'\nexport type AvatarShape = 'circle' | 'square'\nexport type AvatarStatus = 'online' | 'offline' | 'busy' | 'away'\n\nexport interface AvatarProps\n extends React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>,\n VariantProps<typeof avatarVariants> {\n status?: AvatarStatus\n}\n\nconst AvatarRoot = React.forwardRef<\n React.ElementRef<typeof AvatarPrimitive.Root>,\n AvatarProps\n>(({ className, size, shape, status, children, ...props }, ref) => {\n const resolvedSize = size || 'default'\n\n if (!status) {\n return (\n <AvatarPrimitive.Root\n ref={ref}\n className={cn(avatarVariants({ size, shape }), className)}\n {...props}\n >\n {children}\n </AvatarPrimitive.Root>\n )\n }\n\n // Wrap with an outer span so the status dot is not clipped by overflow-hidden\n return (\n <span className=\"relative inline-flex\">\n <AvatarPrimitive.Root\n ref={ref}\n className={cn(avatarVariants({ size, shape }), className)}\n {...props}\n >\n {children}\n </AvatarPrimitive.Root>\n <span\n className={cn(\n 'absolute bottom-0 right-0 rounded-full ring-2 ring-background',\n statusDotSizes[resolvedSize],\n statusColors[status]\n )}\n />\n </span>\n )\n})\nAvatarRoot.displayName = 'Avatar'\n\nexport interface AvatarImageProps\n extends React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image> {}\n\nconst AvatarImage = React.forwardRef<\n React.ElementRef<typeof AvatarPrimitive.Image>,\n AvatarImageProps\n>(({ className, ...props }, ref) => (\n <AvatarPrimitive.Image\n ref={ref}\n className={cn('object-cover w-full h-full', className)}\n {...props}\n />\n))\nAvatarImage.displayName = 'AvatarImage'\n\nexport interface AvatarFallbackProps\n extends React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> {\n size?: AvatarSize\n /** Shorthand: auto-generates initials + color from a name. Children override auto-initials. */\n name?: string\n /** Pass a name/key to enable colorized mode. The string is hashed to pick a deterministic color. */\n colorized?: string\n /** Color style: \"vivid\" (strong bg + white text) or \"soft\" (pastel bg + dark text). Default: \"vivid\" */\n colorVariant?: AvatarColorVariant\n}\n\nconst AvatarFallback = React.forwardRef<\n React.ElementRef<typeof AvatarPrimitive.Fallback>,\n AvatarFallbackProps\n>(({ className, size, name, colorized, colorVariant = 'vivid', children, ...props }, ref) => {\n const resolvedSize = size || 'default'\n const colorKey = name || colorized\n const color = colorKey ? getAvatarColor(colorKey, colorVariant) : null\n const resolvedChildren = children ?? (name ? getAvatarInitials(name) : undefined)\n return (\n <AvatarPrimitive.Fallback\n ref={ref}\n className={cn(\n 'flex items-center justify-center w-full h-full font-semibold',\n color ? [color.bg, color.text] : 'bg-background-muted text-text-muted',\n fallbackFontSizes[resolvedSize],\n className\n )}\n {...props}\n >\n {resolvedChildren}\n </AvatarPrimitive.Fallback>\n )\n})\nAvatarFallback.displayName = 'AvatarFallback'\n\nexport interface AvatarGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n max?: number\n size?: AvatarSize\n shape?: AvatarShape\n}\n\nconst AvatarGroup = React.forwardRef<HTMLDivElement, AvatarGroupProps>(\n ({ className, max, size = 'default', shape = 'circle', children, ...props }, ref) => {\n const childArray = React.Children.toArray(children)\n const visibleChildren = max ? childArray.slice(0, max) : childArray\n const overflowCount = max ? childArray.length - max : 0\n\n return (\n <div\n ref={ref}\n className={cn(\n 'flex items-center',\n groupNegativeMargins[size],\n '[&>*]:ring-2 [&>*]:ring-background',\n className\n )}\n {...props}\n >\n {visibleChildren}\n {overflowCount > 0 && (\n <AvatarRoot size={size} shape={shape}>\n <AvatarFallback size={size}>+{overflowCount}</AvatarFallback>\n </AvatarRoot>\n )}\n </div>\n )\n }\n)\nAvatarGroup.displayName = 'AvatarGroup'\n\n// ─── Namespace ──────────────────────────────────────────\nconst Avatar = Object.assign(AvatarRoot, {\n Image: AvatarImage,\n Fallback: AvatarFallback,\n Group: AvatarGroup,\n})\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nnamespace Avatar {\n export type ImageProps = AvatarImageProps\n export type FallbackProps = AvatarFallbackProps\n export type GroupProps = AvatarGroupProps\n}\n\nexport { Avatar, AvatarImage, AvatarFallback, AvatarGroup, avatarVariants, avatarColors, getAvatarColor, getAvatarInitials }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,YAAuB;AACvB,sBAAiC;AACjC,sCAAuC;AACvC,mBAAmB;AAGnB,MAAM,qBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,IAAS;AAAA;AAAA,QACT,IAAS;AAAA;AAAA,QACT,SAAS;AAAA;AAAA,QACT,IAAS;AAAA;AAAA,QACT,IAAS;AAAA;AAAA,QACT,OAAS;AAAA;AAAA,MACX;AAAA,MACA,OAAO;AAAA,QACL,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,IACA,iBAAiB,EAAE,MAAM,WAAW,OAAO,SAAS;AAAA,EACtD;AACF;AAGA,MAAM,iBAAiB;AAAA,EACrB,IAAS;AAAA,EACT,IAAS;AAAA,EACT,SAAS;AAAA,EACT,IAAS;AAAA,EACT,IAAS;AAAA,EACT,OAAS;AACX;AAGA,MAA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AAgB;AAAA,IAAhB;AAAA,MACC;AAAA,MACA,eAAW;AAAA,QACT;AAAA,QACA,QAAQ,CAAC,MAAM,IAAI,MAAM,IAAI,IAAI;AAAA,QACjC,kBAAkB,YAAY;AAAA,QAC9B;AAAA,MACF;AAAA,MACC,GAAG;AAAA;AAAA,IAEH;AAAA,EACH;AAEJ,CAAC;AACD,eAAe,cAAc;AAQ7B,MAAM,cAAc,MAAM;AAAA,EACxB,CAAC,EAAE,WAAW,KAAK,OAAO,WAAW,QAAQ,UAAU,UAAU,GAAG,MAAM,GAAG,QAAQ;AACnF,UAAM,aAAa,MAAM,SAAS,QAAQ,QAAQ;AAClD,UAAM,kBAAkB,MAAM,WAAW,MAAM,GAAG,GAAG,IAAI;AACzD,UAAM,gBAAgB,MAAM,WAAW,SAAS,MAAM;AAEtD,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,eAAW;AAAA,UACT;AAAA,UACA,qBAAqB,IAAI;AAAA,UACzB;AAAA,UACA;AAAA,QACF;AAAA,QACC,GAAG;AAAA;AAAA,MAEH;AAAA,MACA,gBAAgB,KACf,oCAAC,cAAW,MAAY,SACtB,oCAAC,kBAAe,QAAY,KAAE,aAAc,CAC9C;AAAA,IAEJ;AAAA,EAEJ;AACF;AACA,YAAY,cAAc;AAG1B,MAAM,SAAS,OAAO,OAAO,YAAY;AAAA,EACvC,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AACT,CAAC;","names":[]}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { cn } from "../../lib/utils";
|
|
6
|
+
const avatarVariants = cva(
|
|
7
|
+
"relative inline-flex items-center justify-center overflow-hidden bg-background-muted select-none",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
size: {
|
|
11
|
+
xs: "w-6 h-6",
|
|
12
|
+
// 24px
|
|
13
|
+
sm: "w-8 h-8",
|
|
14
|
+
// 32px
|
|
15
|
+
default: "w-10 h-10",
|
|
16
|
+
// 40px
|
|
17
|
+
lg: "w-12 h-12",
|
|
18
|
+
// 48px
|
|
19
|
+
xl: "w-16 h-16",
|
|
20
|
+
// 64px
|
|
21
|
+
"2xl": "w-20 h-20"
|
|
22
|
+
// 80px
|
|
23
|
+
},
|
|
24
|
+
shape: {
|
|
25
|
+
circle: "rounded-full",
|
|
26
|
+
square: "rounded-xl"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
defaultVariants: { size: "default", shape: "circle" }
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
const statusDotSizes = {
|
|
33
|
+
xs: "w-1.5 h-1.5",
|
|
34
|
+
sm: "w-2 h-2",
|
|
35
|
+
default: "w-2.5 h-2.5",
|
|
36
|
+
lg: "w-3 h-3",
|
|
37
|
+
xl: "w-3.5 h-3.5",
|
|
38
|
+
"2xl": "w-4 h-4"
|
|
39
|
+
};
|
|
40
|
+
const statusColors = {
|
|
41
|
+
online: "bg-success",
|
|
42
|
+
offline: "bg-text-muted",
|
|
43
|
+
busy: "bg-error",
|
|
44
|
+
away: "bg-warning"
|
|
45
|
+
};
|
|
46
|
+
const fallbackFontSizes = {
|
|
47
|
+
xs: "text-2xs",
|
|
48
|
+
sm: "text-xs",
|
|
49
|
+
default: "text-sm",
|
|
50
|
+
lg: "text-base",
|
|
51
|
+
xl: "text-xl",
|
|
52
|
+
"2xl": "text-2xl"
|
|
53
|
+
};
|
|
54
|
+
const groupNegativeMargins = {
|
|
55
|
+
xs: "-space-x-1.5",
|
|
56
|
+
sm: "-space-x-2",
|
|
57
|
+
default: "-space-x-2.5",
|
|
58
|
+
lg: "-space-x-3",
|
|
59
|
+
xl: "-space-x-4",
|
|
60
|
+
"2xl": "-space-x-5"
|
|
61
|
+
};
|
|
62
|
+
const avatarColors = [
|
|
63
|
+
{ vivid: { bg: "bg-[#DC2626]", text: "text-white" }, soft: { bg: "bg-[#FEE2E2]", text: "text-[#DC2626]" } },
|
|
64
|
+
// red
|
|
65
|
+
{ vivid: { bg: "bg-[#EA580C]", text: "text-white" }, soft: { bg: "bg-[#FFEDD5]", text: "text-[#EA580C]" } },
|
|
66
|
+
// orange
|
|
67
|
+
{ vivid: { bg: "bg-[#D97706]", text: "text-white" }, soft: { bg: "bg-[#FEF3C7]", text: "text-[#B45309]" } },
|
|
68
|
+
// amber
|
|
69
|
+
{ vivid: { bg: "bg-[#CA8A04]", text: "text-white" }, soft: { bg: "bg-[#FEF9C3]", text: "text-[#A16207]" } },
|
|
70
|
+
// yellow
|
|
71
|
+
{ vivid: { bg: "bg-[#059669]", text: "text-white" }, soft: { bg: "bg-[#D1FAE5]", text: "text-[#047857]" } },
|
|
72
|
+
// emerald
|
|
73
|
+
{ vivid: { bg: "bg-[#0D9488]", text: "text-white" }, soft: { bg: "bg-[#CCFBF1]", text: "text-[#0F766E]" } },
|
|
74
|
+
// teal
|
|
75
|
+
{ vivid: { bg: "bg-[#0891B2]", text: "text-white" }, soft: { bg: "bg-[#CFFAFE]", text: "text-[#0E7490]" } },
|
|
76
|
+
// cyan
|
|
77
|
+
{ vivid: { bg: "bg-[#2563EB]", text: "text-white" }, soft: { bg: "bg-[#DBEAFE]", text: "text-[#1D4ED8]" } },
|
|
78
|
+
// blue
|
|
79
|
+
{ vivid: { bg: "bg-[#4F46E5]", text: "text-white" }, soft: { bg: "bg-[#E0E7FF]", text: "text-[#4338CA]" } },
|
|
80
|
+
// indigo
|
|
81
|
+
{ vivid: { bg: "bg-[#7C3AED]", text: "text-white" }, soft: { bg: "bg-[#EDE9FE]", text: "text-[#6D28D9]" } },
|
|
82
|
+
// violet
|
|
83
|
+
{ vivid: { bg: "bg-[#9333EA]", text: "text-white" }, soft: { bg: "bg-[#F3E8FF]", text: "text-[#7E22CE]" } },
|
|
84
|
+
// purple
|
|
85
|
+
{ vivid: { bg: "bg-[#DB2777]", text: "text-white" }, soft: { bg: "bg-[#FCE7F3]", text: "text-[#BE185D]" } }
|
|
86
|
+
// pink
|
|
87
|
+
];
|
|
88
|
+
function getAvatarInitials(name, maxChars = 2) {
|
|
89
|
+
const trimmed = name.trim();
|
|
90
|
+
if (!trimmed) return "";
|
|
91
|
+
const cjkRegex = /[\u3000-\u9fff\uac00-\ud7af\uff00-\uffef]/;
|
|
92
|
+
if (cjkRegex.test(trimmed.charAt(0))) {
|
|
93
|
+
return trimmed.slice(0, maxChars);
|
|
94
|
+
}
|
|
95
|
+
const parts = trimmed.split(/[\s\-_.]+/).filter(Boolean);
|
|
96
|
+
if (parts.length === 1) {
|
|
97
|
+
return parts[0].charAt(0).toUpperCase();
|
|
98
|
+
}
|
|
99
|
+
return (parts[0].charAt(0) + parts[parts.length - 1].charAt(0)).toUpperCase().slice(0, maxChars);
|
|
100
|
+
}
|
|
101
|
+
function getAvatarColor(name, variant = "vivid") {
|
|
102
|
+
let hash = 5381;
|
|
103
|
+
for (let i = 0; i < name.length; i++) {
|
|
104
|
+
hash = (hash << 5) + hash ^ name.charCodeAt(i);
|
|
105
|
+
}
|
|
106
|
+
return avatarColors[(hash >>> 0) % avatarColors.length][variant];
|
|
107
|
+
}
|
|
108
|
+
const AvatarRoot = React.forwardRef(({ className, size, shape, status, children, ...props }, ref) => {
|
|
109
|
+
const resolvedSize = size || "default";
|
|
110
|
+
if (!status) {
|
|
111
|
+
return /* @__PURE__ */ React.createElement(
|
|
112
|
+
AvatarPrimitive.Root,
|
|
113
|
+
{
|
|
114
|
+
ref,
|
|
115
|
+
className: cn(avatarVariants({ size, shape }), className),
|
|
116
|
+
...props
|
|
117
|
+
},
|
|
118
|
+
children
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return /* @__PURE__ */ React.createElement("span", { className: "relative inline-flex" }, /* @__PURE__ */ React.createElement(
|
|
122
|
+
AvatarPrimitive.Root,
|
|
123
|
+
{
|
|
124
|
+
ref,
|
|
125
|
+
className: cn(avatarVariants({ size, shape }), className),
|
|
126
|
+
...props
|
|
127
|
+
},
|
|
128
|
+
children
|
|
129
|
+
), /* @__PURE__ */ React.createElement(
|
|
130
|
+
"span",
|
|
131
|
+
{
|
|
132
|
+
className: cn(
|
|
133
|
+
"absolute bottom-0 right-0 rounded-full ring-2 ring-background",
|
|
134
|
+
statusDotSizes[resolvedSize],
|
|
135
|
+
statusColors[status]
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
));
|
|
139
|
+
});
|
|
140
|
+
AvatarRoot.displayName = "Avatar";
|
|
141
|
+
const AvatarImage = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
|
|
142
|
+
AvatarPrimitive.Image,
|
|
143
|
+
{
|
|
144
|
+
ref,
|
|
145
|
+
className: cn("object-cover w-full h-full", className),
|
|
146
|
+
...props
|
|
147
|
+
}
|
|
148
|
+
));
|
|
149
|
+
AvatarImage.displayName = "AvatarImage";
|
|
150
|
+
const AvatarFallback = React.forwardRef(({ className, size, name, colorized, colorVariant = "vivid", children, ...props }, ref) => {
|
|
151
|
+
const resolvedSize = size || "default";
|
|
152
|
+
const colorKey = name || colorized;
|
|
153
|
+
const color = colorKey ? getAvatarColor(colorKey, colorVariant) : null;
|
|
154
|
+
const resolvedChildren = children ?? (name ? getAvatarInitials(name) : void 0);
|
|
155
|
+
return /* @__PURE__ */ React.createElement(
|
|
156
|
+
AvatarPrimitive.Fallback,
|
|
157
|
+
{
|
|
158
|
+
ref,
|
|
159
|
+
className: cn(
|
|
160
|
+
"flex items-center justify-center w-full h-full font-semibold",
|
|
161
|
+
color ? [color.bg, color.text] : "bg-background-muted text-text-muted",
|
|
162
|
+
fallbackFontSizes[resolvedSize],
|
|
163
|
+
className
|
|
164
|
+
),
|
|
165
|
+
...props
|
|
166
|
+
},
|
|
167
|
+
resolvedChildren
|
|
168
|
+
);
|
|
169
|
+
});
|
|
170
|
+
AvatarFallback.displayName = "AvatarFallback";
|
|
171
|
+
const AvatarGroup = React.forwardRef(
|
|
172
|
+
({ className, max, size = "default", shape = "circle", children, ...props }, ref) => {
|
|
173
|
+
const childArray = React.Children.toArray(children);
|
|
174
|
+
const visibleChildren = max ? childArray.slice(0, max) : childArray;
|
|
175
|
+
const overflowCount = max ? childArray.length - max : 0;
|
|
176
|
+
return /* @__PURE__ */ React.createElement(
|
|
177
|
+
"div",
|
|
178
|
+
{
|
|
179
|
+
ref,
|
|
180
|
+
className: cn(
|
|
181
|
+
"flex items-center",
|
|
182
|
+
groupNegativeMargins[size],
|
|
183
|
+
"[&>*]:ring-2 [&>*]:ring-background",
|
|
184
|
+
className
|
|
185
|
+
),
|
|
186
|
+
...props
|
|
187
|
+
},
|
|
188
|
+
visibleChildren,
|
|
189
|
+
overflowCount > 0 && /* @__PURE__ */ React.createElement(AvatarRoot, { size, shape }, /* @__PURE__ */ React.createElement(AvatarFallback, { size }, "+", overflowCount))
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
AvatarGroup.displayName = "AvatarGroup";
|
|
194
|
+
const Avatar = Object.assign(AvatarRoot, {
|
|
195
|
+
Image: AvatarImage,
|
|
196
|
+
Fallback: AvatarFallback,
|
|
197
|
+
Group: AvatarGroup
|
|
198
|
+
});
|
|
199
|
+
export {
|
|
200
|
+
Avatar,
|
|
201
|
+
AvatarFallback,
|
|
202
|
+
AvatarGroup,
|
|
203
|
+
AvatarImage,
|
|
204
|
+
avatarColors,
|
|
205
|
+
avatarVariants,
|
|
206
|
+
getAvatarColor,
|
|
207
|
+
getAvatarInitials
|
|
208
|
+
};
|
|
209
|
+
//# sourceMappingURL=avatar.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/ui/avatar.tsx"],"sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport * as AvatarPrimitive from '@radix-ui/react-avatar'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from '../../lib/utils'\n\n// Avatar root variants\nconst avatarVariants = cva(\n 'relative inline-flex items-center justify-center overflow-hidden bg-background-muted select-none',\n {\n variants: {\n size: {\n xs: 'w-6 h-6', // 24px\n sm: 'w-8 h-8', // 32px\n default: 'w-10 h-10', // 40px\n lg: 'w-12 h-12', // 48px\n xl: 'w-16 h-16', // 64px\n '2xl': 'w-20 h-20', // 80px\n },\n shape: {\n circle: 'rounded-full',\n square: 'rounded-xl',\n },\n },\n defaultVariants: { size: 'default', shape: 'circle' },\n }\n)\n\n// Status dot sizes per avatar size\nconst statusDotSizes = {\n xs: 'w-1.5 h-1.5',\n sm: 'w-2 h-2',\n default: 'w-2.5 h-2.5',\n lg: 'w-3 h-3',\n xl: 'w-3.5 h-3.5',\n '2xl': 'w-4 h-4',\n}\n\n// Status dot colors\nconst statusColors = {\n online: 'bg-success',\n offline: 'bg-text-muted',\n busy: 'bg-error',\n away: 'bg-warning',\n}\n\n// Fallback font sizes per avatar size\nconst fallbackFontSizes = {\n xs: 'text-2xs',\n sm: 'text-xs',\n default: 'text-sm',\n lg: 'text-base',\n xl: 'text-xl',\n '2xl': 'text-2xl',\n}\n\n// Negative margin per size for AvatarGroup overlap\nconst groupNegativeMargins = {\n xs: '-space-x-1.5',\n sm: '-space-x-2',\n default: '-space-x-2.5',\n lg: '-space-x-3',\n xl: '-space-x-4',\n '2xl': '-space-x-5',\n}\n\n// Colorized fallback palette (12 colors × 2 variants) — exception 13 in TOKEN-EXCEPTIONS.md\nconst avatarColors = [\n { vivid: { bg: 'bg-[#DC2626]', text: 'text-white' }, soft: { bg: 'bg-[#FEE2E2]', text: 'text-[#DC2626]' } }, // red\n { vivid: { bg: 'bg-[#EA580C]', text: 'text-white' }, soft: { bg: 'bg-[#FFEDD5]', text: 'text-[#EA580C]' } }, // orange\n { vivid: { bg: 'bg-[#D97706]', text: 'text-white' }, soft: { bg: 'bg-[#FEF3C7]', text: 'text-[#B45309]' } }, // amber\n { vivid: { bg: 'bg-[#CA8A04]', text: 'text-white' }, soft: { bg: 'bg-[#FEF9C3]', text: 'text-[#A16207]' } }, // yellow\n { vivid: { bg: 'bg-[#059669]', text: 'text-white' }, soft: { bg: 'bg-[#D1FAE5]', text: 'text-[#047857]' } }, // emerald\n { vivid: { bg: 'bg-[#0D9488]', text: 'text-white' }, soft: { bg: 'bg-[#CCFBF1]', text: 'text-[#0F766E]' } }, // teal\n { vivid: { bg: 'bg-[#0891B2]', text: 'text-white' }, soft: { bg: 'bg-[#CFFAFE]', text: 'text-[#0E7490]' } }, // cyan\n { vivid: { bg: 'bg-[#2563EB]', text: 'text-white' }, soft: { bg: 'bg-[#DBEAFE]', text: 'text-[#1D4ED8]' } }, // blue\n { vivid: { bg: 'bg-[#4F46E5]', text: 'text-white' }, soft: { bg: 'bg-[#E0E7FF]', text: 'text-[#4338CA]' } }, // indigo\n { vivid: { bg: 'bg-[#7C3AED]', text: 'text-white' }, soft: { bg: 'bg-[#EDE9FE]', text: 'text-[#6D28D9]' } }, // violet\n { vivid: { bg: 'bg-[#9333EA]', text: 'text-white' }, soft: { bg: 'bg-[#F3E8FF]', text: 'text-[#7E22CE]' } }, // purple\n { vivid: { bg: 'bg-[#DB2777]', text: 'text-white' }, soft: { bg: 'bg-[#FCE7F3]', text: 'text-[#BE185D]' } }, // pink\n] as const\n\nexport type AvatarColorVariant = 'vivid' | 'soft'\n\n/** Extract initials from a name string (e.g. \"John Doe\" → \"JD\", \"김민수\" → \"김민\") */\nfunction getAvatarInitials(name: string, maxChars = 2): string {\n const trimmed = name.trim()\n if (!trimmed) return ''\n\n // CJK: use first character(s) directly\n const cjkRegex = /[\\u3000-\\u9fff\\uac00-\\ud7af\\uff00-\\uffef]/\n if (cjkRegex.test(trimmed.charAt(0))) {\n return trimmed.slice(0, maxChars)\n }\n\n // Split on spaces, hyphens, underscores, dots\n const parts = trimmed.split(/[\\s\\-_.]+/).filter(Boolean)\n if (parts.length === 1) {\n return parts[0].charAt(0).toUpperCase()\n }\n\n // First + last part initials\n return (parts[0].charAt(0) + parts[parts.length - 1].charAt(0))\n .toUpperCase()\n .slice(0, maxChars)\n}\n\n/** Hash a name string to a deterministic avatar color pair (djb2 xor variant) */\nfunction getAvatarColor(name: string, variant: AvatarColorVariant = 'vivid') {\n let hash = 5381\n for (let i = 0; i < name.length; i++) {\n hash = ((hash << 5) + hash) ^ name.charCodeAt(i)\n }\n return avatarColors[(hash >>> 0) % avatarColors.length][variant]\n}\n\nexport type AvatarSize = 'xs' | 'sm' | 'default' | 'lg' | 'xl' | '2xl'\nexport type AvatarShape = 'circle' | 'square'\nexport type AvatarStatus = 'online' | 'offline' | 'busy' | 'away'\n\nexport interface AvatarProps\n extends React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>,\n VariantProps<typeof avatarVariants> {\n status?: AvatarStatus\n}\n\nconst AvatarRoot = React.forwardRef<\n React.ElementRef<typeof AvatarPrimitive.Root>,\n AvatarProps\n>(({ className, size, shape, status, children, ...props }, ref) => {\n const resolvedSize = size || 'default'\n\n if (!status) {\n return (\n <AvatarPrimitive.Root\n ref={ref}\n className={cn(avatarVariants({ size, shape }), className)}\n {...props}\n >\n {children}\n </AvatarPrimitive.Root>\n )\n }\n\n // Wrap with an outer span so the status dot is not clipped by overflow-hidden\n return (\n <span className=\"relative inline-flex\">\n <AvatarPrimitive.Root\n ref={ref}\n className={cn(avatarVariants({ size, shape }), className)}\n {...props}\n >\n {children}\n </AvatarPrimitive.Root>\n <span\n className={cn(\n 'absolute bottom-0 right-0 rounded-full ring-2 ring-background',\n statusDotSizes[resolvedSize],\n statusColors[status]\n )}\n />\n </span>\n )\n})\nAvatarRoot.displayName = 'Avatar'\n\nexport interface AvatarImageProps\n extends React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image> {}\n\nconst AvatarImage = React.forwardRef<\n React.ElementRef<typeof AvatarPrimitive.Image>,\n AvatarImageProps\n>(({ className, ...props }, ref) => (\n <AvatarPrimitive.Image\n ref={ref}\n className={cn('object-cover w-full h-full', className)}\n {...props}\n />\n))\nAvatarImage.displayName = 'AvatarImage'\n\nexport interface AvatarFallbackProps\n extends React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> {\n size?: AvatarSize\n /** Shorthand: auto-generates initials + color from a name. Children override auto-initials. */\n name?: string\n /** Pass a name/key to enable colorized mode. The string is hashed to pick a deterministic color. */\n colorized?: string\n /** Color style: \"vivid\" (strong bg + white text) or \"soft\" (pastel bg + dark text). Default: \"vivid\" */\n colorVariant?: AvatarColorVariant\n}\n\nconst AvatarFallback = React.forwardRef<\n React.ElementRef<typeof AvatarPrimitive.Fallback>,\n AvatarFallbackProps\n>(({ className, size, name, colorized, colorVariant = 'vivid', children, ...props }, ref) => {\n const resolvedSize = size || 'default'\n const colorKey = name || colorized\n const color = colorKey ? getAvatarColor(colorKey, colorVariant) : null\n const resolvedChildren = children ?? (name ? getAvatarInitials(name) : undefined)\n return (\n <AvatarPrimitive.Fallback\n ref={ref}\n className={cn(\n 'flex items-center justify-center w-full h-full font-semibold',\n color ? [color.bg, color.text] : 'bg-background-muted text-text-muted',\n fallbackFontSizes[resolvedSize],\n className\n )}\n {...props}\n >\n {resolvedChildren}\n </AvatarPrimitive.Fallback>\n )\n})\nAvatarFallback.displayName = 'AvatarFallback'\n\nexport interface AvatarGroupProps extends React.HTMLAttributes<HTMLDivElement> {\n max?: number\n size?: AvatarSize\n shape?: AvatarShape\n}\n\nconst AvatarGroup = React.forwardRef<HTMLDivElement, AvatarGroupProps>(\n ({ className, max, size = 'default', shape = 'circle', children, ...props }, ref) => {\n const childArray = React.Children.toArray(children)\n const visibleChildren = max ? childArray.slice(0, max) : childArray\n const overflowCount = max ? childArray.length - max : 0\n\n return (\n <div\n ref={ref}\n className={cn(\n 'flex items-center',\n groupNegativeMargins[size],\n '[&>*]:ring-2 [&>*]:ring-background',\n className\n )}\n {...props}\n >\n {visibleChildren}\n {overflowCount > 0 && (\n <AvatarRoot size={size} shape={shape}>\n <AvatarFallback size={size}>+{overflowCount}</AvatarFallback>\n </AvatarRoot>\n )}\n </div>\n )\n }\n)\nAvatarGroup.displayName = 'AvatarGroup'\n\n// ─── Namespace ──────────────────────────────────────────\nconst Avatar = Object.assign(AvatarRoot, {\n Image: AvatarImage,\n Fallback: AvatarFallback,\n Group: AvatarGroup,\n})\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nnamespace Avatar {\n export type ImageProps = AvatarImageProps\n export type FallbackProps = AvatarFallbackProps\n export type GroupProps = AvatarGroupProps\n}\n\nexport { Avatar, AvatarImage, AvatarFallback, AvatarGroup, avatarVariants, avatarColors, getAvatarColor, getAvatarInitials }\n"],"mappings":";AAEA,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,SAAS,WAA8B;AACvC,SAAS,UAAU;AAGnB,MAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,IAAS;AAAA;AAAA,QACT,IAAS;AAAA;AAAA,QACT,SAAS;AAAA;AAAA,QACT,IAAS;AAAA;AAAA,QACT,IAAS;AAAA;AAAA,QACT,OAAS;AAAA;AAAA,MACX;AAAA,MACA,OAAO;AAAA,QACL,QAAQ;AAAA,QACR,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,IACA,iBAAiB,EAAE,MAAM,WAAW,OAAO,SAAS;AAAA,EACtD;AACF;AAGA,MAAM,iBAAiB;AAAA,EACrB,IAAS;AAAA,EACT,IAAS;AAAA,EACT,SAAS;AAAA,EACT,IAAS;AAAA,EACT,IAAS;AAAA,EACT,OAAS;AACX;AAGA,MAAM,eAAe;AAAA,EACnB,QAAS;AAAA,EACT,SAAS;AAAA,EACT,MAAS;AAAA,EACT,MAAS;AACX;AAGA,MAAM,oBAAoB;AAAA,EACxB,IAAS;AAAA,EACT,IAAS;AAAA,EACT,SAAS;AAAA,EACT,IAAS;AAAA,EACT,IAAS;AAAA,EACT,OAAS;AACX;AAGA,MAAM,uBAAuB;AAAA,EAC3B,IAAS;AAAA,EACT,IAAS;AAAA,EACT,SAA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AAE,WAAW,KAAK,OAAO,WAAW,QAAQ,UAAU,UAAU,GAAG,MAAM,GAAG,QAAQ;AACnF,UAAM,aAAa,MAAM,SAAS,QAAQ,QAAQ;AAClD,UAAM,kBAAkB,MAAM,WAAW,MAAM,GAAG,GAAG,IAAI;AACzD,UAAM,gBAAgB,MAAM,WAAW,SAAS,MAAM;AAEtD,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,WAAW;AAAA,UACT;AAAA,UACA,qBAAqB,IAAI;AAAA,UACzB;AAAA,UACA;AAAA,QACF;AAAA,QACC,GAAG;AAAA;AAAA,MAEH;AAAA,MACA,gBAAgB,KACf,oCAAC,cAAW,MAAY,SACtB,oCAAC,kBAAe,QAAY,KAAE,aAAc,CAC9C;AAAA,IAEJ;AAAA,EAEJ;AACF;AACA,YAAY,cAAc;AAG1B,MAAM,SAAS,OAAO,OAAO,YAAY;AAAA,EACvC,OAAO;AAAA,EACP,UAAU;AAAA,EACV,OAAO;AACT,CAAC;","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
|
+
|
|
5
|
+
declare const badgeVariants: (props?: ({
|
|
6
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
7
|
+
radius?: "sm" | "lg" | "base" | "md" | "full" | null | undefined;
|
|
8
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
9
|
+
type BadgeVariant = 'solid' | 'subtle' | 'outline';
|
|
10
|
+
type BadgeColor = 'default' | 'primary' | 'success' | 'warning' | 'error' | 'info';
|
|
11
|
+
type BadgeSize = 'sm' | 'default' | 'lg';
|
|
12
|
+
type BadgeRadius = 'sm' | 'base' | 'md' | 'lg' | 'full';
|
|
13
|
+
interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement>, VariantProps<typeof badgeVariants> {
|
|
14
|
+
/** Visual style */
|
|
15
|
+
variant?: BadgeVariant;
|
|
16
|
+
/** Semantic color */
|
|
17
|
+
color?: BadgeColor;
|
|
18
|
+
/** Leading icon slot */
|
|
19
|
+
icon?: React.ReactNode;
|
|
20
|
+
/** Show a status dot before text */
|
|
21
|
+
dot?: boolean;
|
|
22
|
+
/** Show a remove button */
|
|
23
|
+
removable?: boolean;
|
|
24
|
+
/** Callback when remove button is clicked */
|
|
25
|
+
onRemove?: () => void;
|
|
26
|
+
/** Render as child element (Slot pattern) */
|
|
27
|
+
asChild?: boolean;
|
|
28
|
+
}
|
|
29
|
+
declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLSpanElement>>;
|
|
30
|
+
|
|
31
|
+
export { Badge, type BadgeColor, type BadgeProps, type BadgeRadius, type BadgeSize, type BadgeVariant, badgeVariants };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
|
+
|
|
5
|
+
declare const badgeVariants: (props?: ({
|
|
6
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
7
|
+
radius?: "sm" | "lg" | "base" | "md" | "full" | null | undefined;
|
|
8
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
9
|
+
type BadgeVariant = 'solid' | 'subtle' | 'outline';
|
|
10
|
+
type BadgeColor = 'default' | 'primary' | 'success' | 'warning' | 'error' | 'info';
|
|
11
|
+
type BadgeSize = 'sm' | 'default' | 'lg';
|
|
12
|
+
type BadgeRadius = 'sm' | 'base' | 'md' | 'lg' | 'full';
|
|
13
|
+
interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement>, VariantProps<typeof badgeVariants> {
|
|
14
|
+
/** Visual style */
|
|
15
|
+
variant?: BadgeVariant;
|
|
16
|
+
/** Semantic color */
|
|
17
|
+
color?: BadgeColor;
|
|
18
|
+
/** Leading icon slot */
|
|
19
|
+
icon?: React.ReactNode;
|
|
20
|
+
/** Show a status dot before text */
|
|
21
|
+
dot?: boolean;
|
|
22
|
+
/** Show a remove button */
|
|
23
|
+
removable?: boolean;
|
|
24
|
+
/** Callback when remove button is clicked */
|
|
25
|
+
onRemove?: () => void;
|
|
26
|
+
/** Render as child element (Slot pattern) */
|
|
27
|
+
asChild?: boolean;
|
|
28
|
+
}
|
|
29
|
+
declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLSpanElement>>;
|
|
30
|
+
|
|
31
|
+
export { Badge, type BadgeColor, type BadgeProps, type BadgeRadius, type BadgeSize, type BadgeVariant, badgeVariants };
|