@kopexa/avatar 1.0.1 → 1.0.2
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/dist/avatar-group.context.d.mts +13 -0
- package/dist/avatar-group.context.d.ts +13 -0
- package/dist/avatar-group.context.js +37 -0
- package/dist/avatar-group.context.mjs +9 -0
- package/dist/avatar-group.d.mts +14 -0
- package/dist/avatar-group.d.ts +14 -0
- package/dist/avatar-group.js +306 -0
- package/dist/avatar-group.mjs +11 -0
- package/dist/avatar.d.mts +7 -17
- package/dist/avatar.d.ts +7 -17
- package/dist/avatar.js +135 -63
- package/dist/avatar.mjs +3 -1
- package/dist/chunk-CI55TF4E.mjs +118 -0
- package/dist/chunk-FBUAHX2S.mjs +13 -0
- package/dist/chunk-HBUPEI6X.mjs +30 -0
- package/dist/chunk-J37VYVJO.mjs +83 -0
- package/dist/chunk-KPWT5YIU.mjs +67 -0
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +231 -65
- package/dist/index.mjs +9 -2
- package/dist/use-avatar-group.d.mts +51 -0
- package/dist/use-avatar-group.d.ts +51 -0
- package/dist/use-avatar-group.js +104 -0
- package/dist/use-avatar-group.mjs +7 -0
- package/dist/use-avatar.d.mts +136 -0
- package/dist/use-avatar.d.ts +136 -0
- package/dist/use-avatar.js +141 -0
- package/dist/use-avatar.mjs +8 -0
- package/package.json +4 -4
- package/dist/chunk-EVKHBB7E.mjs +0 -109
package/dist/avatar.js
CHANGED
|
@@ -34,78 +34,150 @@ __export(avatar_exports, {
|
|
|
34
34
|
Avatar: () => Avatar
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(avatar_exports);
|
|
37
|
+
var import_shared_utils2 = require("@kopexa/shared-utils");
|
|
38
|
+
var AvatarPrimitive = __toESM(require("@radix-ui/react-avatar"));
|
|
39
|
+
|
|
40
|
+
// src/use-avatar.ts
|
|
37
41
|
var import_shared_utils = require("@kopexa/shared-utils");
|
|
38
42
|
var import_theme = require("@kopexa/theme");
|
|
39
|
-
var AvatarPrimitive = __toESM(require("@radix-ui/react-avatar"));
|
|
40
43
|
var import_react = require("react");
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
|
|
45
|
+
// src/avatar-group.context.ts
|
|
46
|
+
var import_react_utils = require("@kopexa/react-utils");
|
|
47
|
+
var [AvatarGroupProvider, useAvatarGroupContext] = (0, import_react_utils.createContext)({
|
|
48
|
+
name: "AvatarGroupContext",
|
|
49
|
+
strict: false
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// src/use-avatar.ts
|
|
53
|
+
function useAvatar(originalProps = {}) {
|
|
54
|
+
var _a, _b, _c, _d, _e;
|
|
55
|
+
const groupContext = useAvatarGroupContext();
|
|
56
|
+
const isInGroup = !!groupContext;
|
|
43
57
|
const {
|
|
44
|
-
|
|
45
|
-
size,
|
|
46
|
-
radius,
|
|
47
|
-
name,
|
|
48
|
-
color,
|
|
58
|
+
ref,
|
|
49
59
|
src,
|
|
50
|
-
|
|
51
|
-
isBordered,
|
|
52
|
-
isDisabled,
|
|
53
|
-
imgRef,
|
|
60
|
+
name,
|
|
54
61
|
classNames,
|
|
55
|
-
alt,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
62
|
+
alt = name || "avatar",
|
|
63
|
+
imgRef: imgRefProp,
|
|
64
|
+
color = (_a = groupContext == null ? void 0 : groupContext.color) != null ? _a : "default",
|
|
65
|
+
radius = (_b = groupContext == null ? void 0 : groupContext.radius) != null ? _b : "full",
|
|
66
|
+
size = (_c = groupContext == null ? void 0 : groupContext.size) != null ? _c : "md",
|
|
67
|
+
isBordered = (_d = groupContext == null ? void 0 : groupContext.isBordered) != null ? _d : false,
|
|
68
|
+
isDisabled = (_e = groupContext == null ? void 0 : groupContext.isDisabled) != null ? _e : false,
|
|
69
|
+
className,
|
|
70
|
+
onError,
|
|
71
|
+
onLoadingStatusChange,
|
|
72
|
+
...otherProps
|
|
73
|
+
} = originalProps;
|
|
74
|
+
const [status, setStatus] = (0, import_react.useState)("idle");
|
|
75
|
+
const handleLoadingStatusChange = (0, import_react.useCallback)(
|
|
76
|
+
(status2) => {
|
|
77
|
+
onLoadingStatusChange == null ? void 0 : onLoadingStatusChange(status2);
|
|
78
|
+
setStatus(status2);
|
|
79
|
+
},
|
|
80
|
+
[onLoadingStatusChange]
|
|
60
81
|
);
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
82
|
+
const slots = (0, import_react.useMemo)(
|
|
83
|
+
() => {
|
|
84
|
+
var _a2;
|
|
85
|
+
return (0, import_theme.avatar)({
|
|
86
|
+
color,
|
|
87
|
+
radius,
|
|
88
|
+
size,
|
|
89
|
+
isBordered,
|
|
90
|
+
isDisabled,
|
|
91
|
+
isInGroup,
|
|
92
|
+
isInGridGroup: (_a2 = groupContext == null ? void 0 : groupContext.isGrid) != null ? _a2 : false
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
[
|
|
96
|
+
color,
|
|
97
|
+
radius,
|
|
98
|
+
size,
|
|
99
|
+
isBordered,
|
|
100
|
+
isDisabled,
|
|
101
|
+
isInGroup,
|
|
102
|
+
groupContext == null ? void 0 : groupContext.isGrid
|
|
103
|
+
]
|
|
104
|
+
);
|
|
105
|
+
const baseStyles = (0, import_shared_utils.cn)(classNames == null ? void 0 : classNames.root, className);
|
|
106
|
+
const getAvatarProps = (0, import_react.useCallback)(
|
|
107
|
+
(props = {}) => ({
|
|
108
|
+
ref,
|
|
69
109
|
"data-slot": "avatar",
|
|
70
|
-
className:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
src,
|
|
78
|
-
"data-status": status,
|
|
79
|
-
className: styles.img(),
|
|
80
|
-
onLoadingStatusChange: handleLoadingStatusChange,
|
|
81
|
-
ref: imgRef,
|
|
82
|
-
alt
|
|
83
|
-
}
|
|
84
|
-
),
|
|
85
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvatarPrimitive.Fallback, { "data-slot": "avatar-fallback", children: name ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
86
|
-
"span",
|
|
87
|
-
{
|
|
88
|
-
className: styles.name({
|
|
89
|
-
className: classNames == null ? void 0 : classNames.name
|
|
90
|
-
}),
|
|
91
|
-
role: "img",
|
|
92
|
-
"aria-label": alt,
|
|
93
|
-
children: (0, import_shared_utils.getInitials)(name)
|
|
94
|
-
}
|
|
95
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
96
|
-
"span",
|
|
97
|
-
{
|
|
98
|
-
className: styles.icon({
|
|
99
|
-
className: classNames == null ? void 0 : classNames.icon
|
|
100
|
-
}),
|
|
101
|
-
role: "img",
|
|
102
|
-
"aria-label": alt,
|
|
103
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvatarIcon, {})
|
|
104
|
-
}
|
|
105
|
-
) })
|
|
106
|
-
]
|
|
107
|
-
}
|
|
110
|
+
className: slots.root({
|
|
111
|
+
class: (0, import_shared_utils.cn)(baseStyles, props == null ? void 0 : props.className)
|
|
112
|
+
}),
|
|
113
|
+
...otherProps
|
|
114
|
+
}),
|
|
115
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: we want to memoize this
|
|
116
|
+
[slots, baseStyles, otherProps, ref]
|
|
108
117
|
);
|
|
118
|
+
const getImageProps = (0, import_react.useCallback)(
|
|
119
|
+
() => ({
|
|
120
|
+
"data-slot": "avatar-image",
|
|
121
|
+
"data-status": status,
|
|
122
|
+
src,
|
|
123
|
+
onLoadingStatusChange: handleLoadingStatusChange,
|
|
124
|
+
ref: imgRefProp,
|
|
125
|
+
alt,
|
|
126
|
+
onError,
|
|
127
|
+
className: slots.img({
|
|
128
|
+
class: classNames == null ? void 0 : classNames.img
|
|
129
|
+
})
|
|
130
|
+
}),
|
|
131
|
+
[
|
|
132
|
+
status,
|
|
133
|
+
src,
|
|
134
|
+
handleLoadingStatusChange,
|
|
135
|
+
imgRefProp,
|
|
136
|
+
alt,
|
|
137
|
+
slots.img,
|
|
138
|
+
classNames == null ? void 0 : classNames.img,
|
|
139
|
+
onError
|
|
140
|
+
]
|
|
141
|
+
);
|
|
142
|
+
return {
|
|
143
|
+
src,
|
|
144
|
+
alt,
|
|
145
|
+
slots,
|
|
146
|
+
classNames,
|
|
147
|
+
name,
|
|
148
|
+
getAvatarProps,
|
|
149
|
+
getImageProps
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// src/avatar.tsx
|
|
154
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
155
|
+
var Avatar = (props) => {
|
|
156
|
+
const { alt, getAvatarProps, getImageProps, slots, classNames, name } = useAvatar(props);
|
|
157
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AvatarPrimitive.Root, { ...getAvatarProps(), children: [
|
|
158
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvatarPrimitive.Image, { ...getImageProps() }),
|
|
159
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvatarPrimitive.Fallback, { "data-slot": "avatar-fallback", children: name ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
160
|
+
"span",
|
|
161
|
+
{
|
|
162
|
+
className: slots.name({
|
|
163
|
+
className: classNames == null ? void 0 : classNames.name
|
|
164
|
+
}),
|
|
165
|
+
role: "img",
|
|
166
|
+
"aria-label": alt,
|
|
167
|
+
children: (0, import_shared_utils2.getInitials)(name)
|
|
168
|
+
}
|
|
169
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
170
|
+
"span",
|
|
171
|
+
{
|
|
172
|
+
className: slots.icon({
|
|
173
|
+
className: classNames == null ? void 0 : classNames.icon
|
|
174
|
+
}),
|
|
175
|
+
role: "img",
|
|
176
|
+
"aria-label": alt,
|
|
177
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvatarIcon, {})
|
|
178
|
+
}
|
|
179
|
+
) })
|
|
180
|
+
] });
|
|
109
181
|
};
|
|
110
182
|
var AvatarIcon = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
111
183
|
"svg",
|
package/dist/avatar.mjs
CHANGED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useAvatarGroupContext
|
|
4
|
+
} from "./chunk-FBUAHX2S.mjs";
|
|
5
|
+
|
|
6
|
+
// src/use-avatar.ts
|
|
7
|
+
import { cn } from "@kopexa/shared-utils";
|
|
8
|
+
import {
|
|
9
|
+
avatar
|
|
10
|
+
} from "@kopexa/theme";
|
|
11
|
+
import {
|
|
12
|
+
useCallback,
|
|
13
|
+
useMemo,
|
|
14
|
+
useState
|
|
15
|
+
} from "react";
|
|
16
|
+
function useAvatar(originalProps = {}) {
|
|
17
|
+
var _a, _b, _c, _d, _e;
|
|
18
|
+
const groupContext = useAvatarGroupContext();
|
|
19
|
+
const isInGroup = !!groupContext;
|
|
20
|
+
const {
|
|
21
|
+
ref,
|
|
22
|
+
src,
|
|
23
|
+
name,
|
|
24
|
+
classNames,
|
|
25
|
+
alt = name || "avatar",
|
|
26
|
+
imgRef: imgRefProp,
|
|
27
|
+
color = (_a = groupContext == null ? void 0 : groupContext.color) != null ? _a : "default",
|
|
28
|
+
radius = (_b = groupContext == null ? void 0 : groupContext.radius) != null ? _b : "full",
|
|
29
|
+
size = (_c = groupContext == null ? void 0 : groupContext.size) != null ? _c : "md",
|
|
30
|
+
isBordered = (_d = groupContext == null ? void 0 : groupContext.isBordered) != null ? _d : false,
|
|
31
|
+
isDisabled = (_e = groupContext == null ? void 0 : groupContext.isDisabled) != null ? _e : false,
|
|
32
|
+
className,
|
|
33
|
+
onError,
|
|
34
|
+
onLoadingStatusChange,
|
|
35
|
+
...otherProps
|
|
36
|
+
} = originalProps;
|
|
37
|
+
const [status, setStatus] = useState("idle");
|
|
38
|
+
const handleLoadingStatusChange = useCallback(
|
|
39
|
+
(status2) => {
|
|
40
|
+
onLoadingStatusChange == null ? void 0 : onLoadingStatusChange(status2);
|
|
41
|
+
setStatus(status2);
|
|
42
|
+
},
|
|
43
|
+
[onLoadingStatusChange]
|
|
44
|
+
);
|
|
45
|
+
const slots = useMemo(
|
|
46
|
+
() => {
|
|
47
|
+
var _a2;
|
|
48
|
+
return avatar({
|
|
49
|
+
color,
|
|
50
|
+
radius,
|
|
51
|
+
size,
|
|
52
|
+
isBordered,
|
|
53
|
+
isDisabled,
|
|
54
|
+
isInGroup,
|
|
55
|
+
isInGridGroup: (_a2 = groupContext == null ? void 0 : groupContext.isGrid) != null ? _a2 : false
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
[
|
|
59
|
+
color,
|
|
60
|
+
radius,
|
|
61
|
+
size,
|
|
62
|
+
isBordered,
|
|
63
|
+
isDisabled,
|
|
64
|
+
isInGroup,
|
|
65
|
+
groupContext == null ? void 0 : groupContext.isGrid
|
|
66
|
+
]
|
|
67
|
+
);
|
|
68
|
+
const baseStyles = cn(classNames == null ? void 0 : classNames.root, className);
|
|
69
|
+
const getAvatarProps = useCallback(
|
|
70
|
+
(props = {}) => ({
|
|
71
|
+
ref,
|
|
72
|
+
"data-slot": "avatar",
|
|
73
|
+
className: slots.root({
|
|
74
|
+
class: cn(baseStyles, props == null ? void 0 : props.className)
|
|
75
|
+
}),
|
|
76
|
+
...otherProps
|
|
77
|
+
}),
|
|
78
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: we want to memoize this
|
|
79
|
+
[slots, baseStyles, otherProps, ref]
|
|
80
|
+
);
|
|
81
|
+
const getImageProps = useCallback(
|
|
82
|
+
() => ({
|
|
83
|
+
"data-slot": "avatar-image",
|
|
84
|
+
"data-status": status,
|
|
85
|
+
src,
|
|
86
|
+
onLoadingStatusChange: handleLoadingStatusChange,
|
|
87
|
+
ref: imgRefProp,
|
|
88
|
+
alt,
|
|
89
|
+
onError,
|
|
90
|
+
className: slots.img({
|
|
91
|
+
class: classNames == null ? void 0 : classNames.img
|
|
92
|
+
})
|
|
93
|
+
}),
|
|
94
|
+
[
|
|
95
|
+
status,
|
|
96
|
+
src,
|
|
97
|
+
handleLoadingStatusChange,
|
|
98
|
+
imgRefProp,
|
|
99
|
+
alt,
|
|
100
|
+
slots.img,
|
|
101
|
+
classNames == null ? void 0 : classNames.img,
|
|
102
|
+
onError
|
|
103
|
+
]
|
|
104
|
+
);
|
|
105
|
+
return {
|
|
106
|
+
src,
|
|
107
|
+
alt,
|
|
108
|
+
slots,
|
|
109
|
+
classNames,
|
|
110
|
+
name,
|
|
111
|
+
getAvatarProps,
|
|
112
|
+
getImageProps
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export {
|
|
117
|
+
useAvatar
|
|
118
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/avatar-group.context.ts
|
|
4
|
+
import { createContext } from "@kopexa/react-utils";
|
|
5
|
+
var [AvatarGroupProvider, useAvatarGroupContext] = createContext({
|
|
6
|
+
name: "AvatarGroupContext",
|
|
7
|
+
strict: false
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
AvatarGroupProvider,
|
|
12
|
+
useAvatarGroupContext
|
|
13
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
Avatar
|
|
4
|
+
} from "./chunk-KPWT5YIU.mjs";
|
|
5
|
+
import {
|
|
6
|
+
useAvatarGroup
|
|
7
|
+
} from "./chunk-J37VYVJO.mjs";
|
|
8
|
+
import {
|
|
9
|
+
AvatarGroupProvider
|
|
10
|
+
} from "./chunk-FBUAHX2S.mjs";
|
|
11
|
+
|
|
12
|
+
// src/avatar-group.tsx
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
function AvatarGroup(props) {
|
|
15
|
+
const {
|
|
16
|
+
clones,
|
|
17
|
+
context,
|
|
18
|
+
remainingCount,
|
|
19
|
+
getAvatarGroupCountProps,
|
|
20
|
+
getAvatarGroupProps
|
|
21
|
+
} = useAvatarGroup(props);
|
|
22
|
+
return /* @__PURE__ */ jsx("div", { ...getAvatarGroupProps(), children: /* @__PURE__ */ jsxs(AvatarGroupProvider, { value: context, children: [
|
|
23
|
+
clones,
|
|
24
|
+
remainingCount > 0 && /* @__PURE__ */ jsx(Avatar, { ...getAvatarGroupCountProps(), name: `+${remainingCount}` })
|
|
25
|
+
] }) });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
AvatarGroup
|
|
30
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/use-avatar-group.ts
|
|
4
|
+
import { getValidChildren } from "@kopexa/react-utils";
|
|
5
|
+
import { cn, compact } from "@kopexa/shared-utils";
|
|
6
|
+
import {
|
|
7
|
+
avatarGroup
|
|
8
|
+
} from "@kopexa/theme";
|
|
9
|
+
import { cloneElement, useMemo } from "react";
|
|
10
|
+
function useAvatarGroup(props = {}) {
|
|
11
|
+
const {
|
|
12
|
+
ref,
|
|
13
|
+
max = 5,
|
|
14
|
+
total,
|
|
15
|
+
size,
|
|
16
|
+
color,
|
|
17
|
+
radius,
|
|
18
|
+
children,
|
|
19
|
+
isBordered,
|
|
20
|
+
isDisabled,
|
|
21
|
+
isGrid,
|
|
22
|
+
className,
|
|
23
|
+
classNames,
|
|
24
|
+
...otherProps
|
|
25
|
+
} = props;
|
|
26
|
+
const context = useMemo(
|
|
27
|
+
() => ({
|
|
28
|
+
size,
|
|
29
|
+
color,
|
|
30
|
+
radius,
|
|
31
|
+
isGrid,
|
|
32
|
+
isBordered,
|
|
33
|
+
isDisabled
|
|
34
|
+
}),
|
|
35
|
+
[size, color, radius, isGrid, isBordered, isDisabled]
|
|
36
|
+
);
|
|
37
|
+
const slots = useMemo(
|
|
38
|
+
() => avatarGroup({ className, isGrid }),
|
|
39
|
+
[className, isGrid]
|
|
40
|
+
);
|
|
41
|
+
const validChildren = getValidChildren(children);
|
|
42
|
+
const childrenWithinMax = max ? validChildren.slice(0, max) : validChildren;
|
|
43
|
+
const remainingCount = total ? total : max != null ? validChildren.length - max : -1;
|
|
44
|
+
const clones = childrenWithinMax.map((child, index) => {
|
|
45
|
+
const isFirstAvatar = index === 0;
|
|
46
|
+
const isLastAvatar = index === childrenWithinMax.length - 1;
|
|
47
|
+
const childProps = {
|
|
48
|
+
className: cn(
|
|
49
|
+
isFirstAvatar ? "ms-0" : !isGrid ? "-ms-2" : "",
|
|
50
|
+
isLastAvatar && remainingCount < 1 ? "hover:-translate-x-0" : ""
|
|
51
|
+
)
|
|
52
|
+
};
|
|
53
|
+
return cloneElement(child, compact(childProps));
|
|
54
|
+
});
|
|
55
|
+
const getAvatarGroupProps = () => {
|
|
56
|
+
return {
|
|
57
|
+
ref,
|
|
58
|
+
className: slots.base({
|
|
59
|
+
class: cn(classNames == null ? void 0 : classNames.base, className)
|
|
60
|
+
}),
|
|
61
|
+
role: "group",
|
|
62
|
+
...otherProps
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const getAvatarGroupCountProps = () => {
|
|
66
|
+
return {
|
|
67
|
+
className: slots.count({
|
|
68
|
+
class: classNames == null ? void 0 : classNames.count
|
|
69
|
+
})
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
context,
|
|
74
|
+
remainingCount,
|
|
75
|
+
clones,
|
|
76
|
+
getAvatarGroupProps,
|
|
77
|
+
getAvatarGroupCountProps
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
useAvatarGroup
|
|
83
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useAvatar
|
|
4
|
+
} from "./chunk-CI55TF4E.mjs";
|
|
5
|
+
|
|
6
|
+
// src/avatar.tsx
|
|
7
|
+
import { getInitials } from "@kopexa/shared-utils";
|
|
8
|
+
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
var Avatar = (props) => {
|
|
11
|
+
const { alt, getAvatarProps, getImageProps, slots, classNames, name } = useAvatar(props);
|
|
12
|
+
return /* @__PURE__ */ jsxs(AvatarPrimitive.Root, { ...getAvatarProps(), children: [
|
|
13
|
+
/* @__PURE__ */ jsx(AvatarPrimitive.Image, { ...getImageProps() }),
|
|
14
|
+
/* @__PURE__ */ jsx(AvatarPrimitive.Fallback, { "data-slot": "avatar-fallback", children: name ? /* @__PURE__ */ jsx(
|
|
15
|
+
"span",
|
|
16
|
+
{
|
|
17
|
+
className: slots.name({
|
|
18
|
+
className: classNames == null ? void 0 : classNames.name
|
|
19
|
+
}),
|
|
20
|
+
role: "img",
|
|
21
|
+
"aria-label": alt,
|
|
22
|
+
children: getInitials(name)
|
|
23
|
+
}
|
|
24
|
+
) : /* @__PURE__ */ jsx(
|
|
25
|
+
"span",
|
|
26
|
+
{
|
|
27
|
+
className: slots.icon({
|
|
28
|
+
className: classNames == null ? void 0 : classNames.icon
|
|
29
|
+
}),
|
|
30
|
+
role: "img",
|
|
31
|
+
"aria-label": alt,
|
|
32
|
+
children: /* @__PURE__ */ jsx(AvatarIcon, {})
|
|
33
|
+
}
|
|
34
|
+
) })
|
|
35
|
+
] });
|
|
36
|
+
};
|
|
37
|
+
var AvatarIcon = () => /* @__PURE__ */ jsxs(
|
|
38
|
+
"svg",
|
|
39
|
+
{
|
|
40
|
+
"aria-hidden": "true",
|
|
41
|
+
fill: "none",
|
|
42
|
+
height: "80%",
|
|
43
|
+
role: "presentation",
|
|
44
|
+
viewBox: "0 0 24 24",
|
|
45
|
+
width: "80%",
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx(
|
|
48
|
+
"path",
|
|
49
|
+
{
|
|
50
|
+
d: "M12 2C9.38 2 7.25 4.13 7.25 6.75C7.25 9.32 9.26 11.4 11.88 11.49C11.96 11.48 12.04 11.48 12.1 11.49C12.12 11.49 12.13 11.49 12.15 11.49C12.16 11.49 12.16 11.49 12.17 11.49C14.73 11.4 16.74 9.32 16.75 6.75C16.75 4.13 14.62 2 12 2Z",
|
|
51
|
+
fill: "currentColor"
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
/* @__PURE__ */ jsx(
|
|
55
|
+
"path",
|
|
56
|
+
{
|
|
57
|
+
d: "M17.0809 14.1489C14.2909 12.2889 9.74094 12.2889 6.93094 14.1489C5.66094 14.9989 4.96094 16.1489 4.96094 17.3789C4.96094 18.6089 5.66094 19.7489 6.92094 20.5889C8.32094 21.5289 10.1609 21.9989 12.0009 21.9989C13.8409 21.9989 15.6809 21.5289 17.0809 20.5889C18.3409 19.7389 19.0409 18.5989 19.0409 17.3589C19.0309 16.1289 18.3409 14.9889 17.0809 14.1489Z",
|
|
58
|
+
fill: "currentColor"
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
Avatar
|
|
67
|
+
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export { Avatar, AvatarProps } from './avatar.mjs';
|
|
2
|
+
export { AvatarGroup, AvatarGroupProps } from './avatar-group.mjs';
|
|
2
3
|
import 'react/jsx-runtime';
|
|
4
|
+
import './use-avatar.mjs';
|
|
5
|
+
import 'tailwind-variants';
|
|
6
|
+
import '@kopexa/react-utils';
|
|
3
7
|
import '@kopexa/theme';
|
|
4
|
-
import '@radix-ui/react-avatar';
|
|
5
8
|
import 'react';
|
|
9
|
+
import './use-avatar-group.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export { Avatar, AvatarProps } from './avatar.js';
|
|
2
|
+
export { AvatarGroup, AvatarGroupProps } from './avatar-group.js';
|
|
2
3
|
import 'react/jsx-runtime';
|
|
4
|
+
import './use-avatar.js';
|
|
5
|
+
import 'tailwind-variants';
|
|
6
|
+
import '@kopexa/react-utils';
|
|
3
7
|
import '@kopexa/theme';
|
|
4
|
-
import '@radix-ui/react-avatar';
|
|
5
8
|
import 'react';
|
|
9
|
+
import './use-avatar-group.js';
|