@heroui/avatar 0.0.0-canary-20250109194025
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/LICENSE +21 -0
- package/README.md +24 -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.ts +14 -0
- package/dist/avatar-group.js +340 -0
- package/dist/avatar-group.mjs +12 -0
- package/dist/avatar-icon.d.ts +5 -0
- package/dist/avatar-icon.js +58 -0
- package/dist/avatar-icon.mjs +7 -0
- package/dist/avatar.d.ts +12 -0
- package/dist/avatar.js +236 -0
- package/dist/avatar.mjs +10 -0
- package/dist/chunk-25E6VDTZ.mjs +35 -0
- package/dist/chunk-JUJ53SJZ.mjs +13 -0
- package/dist/chunk-LTC67JRI.mjs +138 -0
- package/dist/chunk-MJUNODSQ.mjs +38 -0
- package/dist/chunk-QH65JCLF.mjs +85 -0
- package/dist/chunk-RATOCJCD.mjs +50 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +358 -0
- package/dist/index.mjs +29 -0
- package/dist/use-avatar-group.d.ts +67 -0
- package/dist/use-avatar-group.js +108 -0
- package/dist/use-avatar-group.mjs +7 -0
- package/dist/use-avatar.d.ts +207 -0
- package/dist/use-avatar.js +167 -0
- package/dist/use-avatar.mjs +8 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Next UI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @heroui/avatar
|
|
2
|
+
|
|
3
|
+
The Avatar component is used to represent a user, and displays the profile picture, initials or fallback icon.
|
|
4
|
+
|
|
5
|
+
Please refer to the [documentation](https://heroui.com/docs/components/avatar) for more information.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
yarn add @heroui/avatar
|
|
11
|
+
# or
|
|
12
|
+
npm i @heroui/avatar
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Contribution
|
|
16
|
+
|
|
17
|
+
Yes please! See the
|
|
18
|
+
[contributing guidelines](https://github.com/frontio-ai/heroui/blob/master/CONTRIBUTING.md)
|
|
19
|
+
for details.
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
This project is licensed under the terms of the
|
|
24
|
+
[MIT license](https://github.com/frontio-ai/heroui/blob/master/LICENSE).
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ContextType } from './use-avatar-group.js';
|
|
3
|
+
import '@heroui/system';
|
|
4
|
+
import '@heroui/theme';
|
|
5
|
+
import '@heroui/react-utils';
|
|
6
|
+
import './avatar.js';
|
|
7
|
+
import './use-avatar.js';
|
|
8
|
+
import 'tailwind-variants';
|
|
9
|
+
|
|
10
|
+
declare const AvatarGroupProvider: react.Provider<ContextType>;
|
|
11
|
+
declare const useAvatarGroupContext: () => ContextType;
|
|
12
|
+
|
|
13
|
+
export { AvatarGroupProvider, useAvatarGroupContext };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/avatar-group-context.ts
|
|
22
|
+
var avatar_group_context_exports = {};
|
|
23
|
+
__export(avatar_group_context_exports, {
|
|
24
|
+
AvatarGroupProvider: () => AvatarGroupProvider,
|
|
25
|
+
useAvatarGroupContext: () => useAvatarGroupContext
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(avatar_group_context_exports);
|
|
28
|
+
var import_react_utils = require("@heroui/react-utils");
|
|
29
|
+
var [AvatarGroupProvider, useAvatarGroupContext] = (0, import_react_utils.createContext)({
|
|
30
|
+
name: "AvatarGroupContext",
|
|
31
|
+
strict: false
|
|
32
|
+
});
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
AvatarGroupProvider,
|
|
36
|
+
useAvatarGroupContext
|
|
37
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as _heroui_system from '@heroui/system';
|
|
2
|
+
import { UseAvatarGroupProps } from './use-avatar-group.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '@heroui/theme';
|
|
5
|
+
import '@heroui/react-utils';
|
|
6
|
+
import './avatar.js';
|
|
7
|
+
import './use-avatar.js';
|
|
8
|
+
import 'tailwind-variants';
|
|
9
|
+
|
|
10
|
+
interface AvatarGroupProps extends UseAvatarGroupProps {
|
|
11
|
+
}
|
|
12
|
+
declare const AvatarGroup: _heroui_system.InternalForwardRefRenderFunction<"div", AvatarGroupProps, never>;
|
|
13
|
+
|
|
14
|
+
export { AvatarGroupProps, AvatarGroup as default };
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/avatar-group.tsx
|
|
22
|
+
var avatar_group_exports = {};
|
|
23
|
+
__export(avatar_group_exports, {
|
|
24
|
+
default: () => avatar_group_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(avatar_group_exports);
|
|
27
|
+
var import_system3 = require("@heroui/system");
|
|
28
|
+
|
|
29
|
+
// src/avatar-group-context.ts
|
|
30
|
+
var import_react_utils = require("@heroui/react-utils");
|
|
31
|
+
var [AvatarGroupProvider, useAvatarGroupContext] = (0, import_react_utils.createContext)({
|
|
32
|
+
name: "AvatarGroupContext",
|
|
33
|
+
strict: false
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// src/use-avatar-group.ts
|
|
37
|
+
var import_theme = require("@heroui/theme");
|
|
38
|
+
var import_react_utils2 = require("@heroui/react-utils");
|
|
39
|
+
var import_shared_utils = require("@heroui/shared-utils");
|
|
40
|
+
var import_react_utils3 = require("@heroui/react-utils");
|
|
41
|
+
var import_react = require("react");
|
|
42
|
+
function useAvatarGroup(props = {}) {
|
|
43
|
+
const {
|
|
44
|
+
as,
|
|
45
|
+
ref,
|
|
46
|
+
max = 5,
|
|
47
|
+
total,
|
|
48
|
+
size,
|
|
49
|
+
color,
|
|
50
|
+
radius,
|
|
51
|
+
children,
|
|
52
|
+
isBordered,
|
|
53
|
+
isDisabled,
|
|
54
|
+
isGrid,
|
|
55
|
+
renderCount,
|
|
56
|
+
className,
|
|
57
|
+
classNames,
|
|
58
|
+
...otherProps
|
|
59
|
+
} = props;
|
|
60
|
+
const domRef = (0, import_react_utils2.useDOMRef)(ref);
|
|
61
|
+
const Component = as || "div";
|
|
62
|
+
const context = (0, import_react.useMemo)(
|
|
63
|
+
() => ({
|
|
64
|
+
size,
|
|
65
|
+
color,
|
|
66
|
+
radius,
|
|
67
|
+
isGrid,
|
|
68
|
+
isBordered,
|
|
69
|
+
isDisabled
|
|
70
|
+
}),
|
|
71
|
+
[size, color, radius, isGrid, isBordered, isDisabled]
|
|
72
|
+
);
|
|
73
|
+
const slots = (0, import_react.useMemo)(() => (0, import_theme.avatarGroup)({ className, isGrid }), [className, isGrid]);
|
|
74
|
+
const validChildren = (0, import_react_utils3.getValidChildren)(children);
|
|
75
|
+
const childrenWithinMax = max ? validChildren.slice(0, max) : validChildren;
|
|
76
|
+
const remainingCount = total ? total : max != null ? validChildren.length - max : -1;
|
|
77
|
+
const clones = childrenWithinMax.map((child, index) => {
|
|
78
|
+
const isFirstAvatar = index === 0;
|
|
79
|
+
const isLastAvatar = index === childrenWithinMax.length - 1;
|
|
80
|
+
const childProps = {
|
|
81
|
+
className: (0, import_shared_utils.clsx)(
|
|
82
|
+
isFirstAvatar ? "ms-0" : !isGrid ? "-ms-2" : "",
|
|
83
|
+
isLastAvatar && remainingCount < 1 ? "hover:-translate-x-0" : ""
|
|
84
|
+
)
|
|
85
|
+
};
|
|
86
|
+
return (0, import_react.cloneElement)(child, (0, import_shared_utils.compact)(childProps));
|
|
87
|
+
});
|
|
88
|
+
const getAvatarGroupProps = () => {
|
|
89
|
+
return {
|
|
90
|
+
ref: domRef,
|
|
91
|
+
className: slots.base({
|
|
92
|
+
class: (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.base, className)
|
|
93
|
+
}),
|
|
94
|
+
role: "group",
|
|
95
|
+
...otherProps
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
const getAvatarGroupCountProps = () => {
|
|
99
|
+
return {
|
|
100
|
+
className: slots.count({
|
|
101
|
+
class: classNames == null ? void 0 : classNames.count
|
|
102
|
+
})
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
return {
|
|
106
|
+
Component,
|
|
107
|
+
context,
|
|
108
|
+
remainingCount,
|
|
109
|
+
clones,
|
|
110
|
+
renderCount,
|
|
111
|
+
getAvatarGroupProps,
|
|
112
|
+
getAvatarGroupCountProps
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/avatar.tsx
|
|
117
|
+
var import_react3 = require("react");
|
|
118
|
+
var import_system2 = require("@heroui/system");
|
|
119
|
+
|
|
120
|
+
// src/avatar-icon.tsx
|
|
121
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
122
|
+
var AvatarIcon = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
123
|
+
"svg",
|
|
124
|
+
{
|
|
125
|
+
"aria-hidden": "true",
|
|
126
|
+
fill: "none",
|
|
127
|
+
height: "80%",
|
|
128
|
+
role: "presentation",
|
|
129
|
+
viewBox: "0 0 24 24",
|
|
130
|
+
width: "80%",
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
133
|
+
"path",
|
|
134
|
+
{
|
|
135
|
+
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",
|
|
136
|
+
fill: "currentColor"
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
140
|
+
"path",
|
|
141
|
+
{
|
|
142
|
+
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",
|
|
143
|
+
fill: "currentColor"
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
// src/use-avatar.ts
|
|
151
|
+
var import_theme2 = require("@heroui/theme");
|
|
152
|
+
var import_system = require("@heroui/system");
|
|
153
|
+
var import_utils = require("@react-aria/utils");
|
|
154
|
+
var import_react_utils4 = require("@heroui/react-utils");
|
|
155
|
+
var import_shared_utils2 = require("@heroui/shared-utils");
|
|
156
|
+
var import_focus = require("@react-aria/focus");
|
|
157
|
+
var import_react2 = require("react");
|
|
158
|
+
var import_use_image = require("@heroui/use-image");
|
|
159
|
+
var import_interactions = require("@react-aria/interactions");
|
|
160
|
+
function useAvatar(originalProps = {}) {
|
|
161
|
+
var _a, _b, _c, _d, _e, _f;
|
|
162
|
+
const globalContext = (0, import_system.useProviderContext)();
|
|
163
|
+
const groupContext = useAvatarGroupContext();
|
|
164
|
+
const isInGroup = !!groupContext;
|
|
165
|
+
const {
|
|
166
|
+
as,
|
|
167
|
+
ref,
|
|
168
|
+
src,
|
|
169
|
+
name,
|
|
170
|
+
icon,
|
|
171
|
+
classNames,
|
|
172
|
+
fallback,
|
|
173
|
+
alt = name || "avatar",
|
|
174
|
+
imgRef: imgRefProp,
|
|
175
|
+
color = (_a = groupContext == null ? void 0 : groupContext.color) != null ? _a : "default",
|
|
176
|
+
radius = (_b = groupContext == null ? void 0 : groupContext.radius) != null ? _b : "full",
|
|
177
|
+
size = (_c = groupContext == null ? void 0 : groupContext.size) != null ? _c : "md",
|
|
178
|
+
isBordered = (_d = groupContext == null ? void 0 : groupContext.isBordered) != null ? _d : false,
|
|
179
|
+
isDisabled = (_e = groupContext == null ? void 0 : groupContext.isDisabled) != null ? _e : false,
|
|
180
|
+
isFocusable = false,
|
|
181
|
+
getInitials = import_shared_utils2.safeText,
|
|
182
|
+
ignoreFallback = false,
|
|
183
|
+
showFallback: showFallbackProp = false,
|
|
184
|
+
ImgComponent = "img",
|
|
185
|
+
imgProps,
|
|
186
|
+
className,
|
|
187
|
+
onError,
|
|
188
|
+
disableAnimation: disableAnimationProp,
|
|
189
|
+
...otherProps
|
|
190
|
+
} = originalProps;
|
|
191
|
+
const Component = as || "span";
|
|
192
|
+
const domRef = (0, import_react_utils4.useDOMRef)(ref);
|
|
193
|
+
const imgRef = (0, import_react_utils4.useDOMRef)(imgRefProp);
|
|
194
|
+
const { isFocusVisible, isFocused, focusProps } = (0, import_focus.useFocusRing)();
|
|
195
|
+
const { isHovered, hoverProps } = (0, import_interactions.useHover)({ isDisabled });
|
|
196
|
+
const disableAnimation = (_f = disableAnimationProp != null ? disableAnimationProp : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _f : false;
|
|
197
|
+
const imageStatus = (0, import_use_image.useImage)({ src, onError, ignoreFallback });
|
|
198
|
+
const isImgLoaded = imageStatus === "loaded";
|
|
199
|
+
const shouldFilterDOMProps = typeof ImgComponent === "string";
|
|
200
|
+
const showFallback = (!src || !isImgLoaded) && showFallbackProp;
|
|
201
|
+
const slots = (0, import_react2.useMemo)(
|
|
202
|
+
() => {
|
|
203
|
+
var _a2;
|
|
204
|
+
return (0, import_theme2.avatar)({
|
|
205
|
+
color,
|
|
206
|
+
radius,
|
|
207
|
+
size,
|
|
208
|
+
isBordered,
|
|
209
|
+
isDisabled,
|
|
210
|
+
isInGroup,
|
|
211
|
+
disableAnimation,
|
|
212
|
+
isInGridGroup: (_a2 = groupContext == null ? void 0 : groupContext.isGrid) != null ? _a2 : false
|
|
213
|
+
});
|
|
214
|
+
},
|
|
215
|
+
[
|
|
216
|
+
color,
|
|
217
|
+
radius,
|
|
218
|
+
size,
|
|
219
|
+
isBordered,
|
|
220
|
+
isDisabled,
|
|
221
|
+
disableAnimation,
|
|
222
|
+
isInGroup,
|
|
223
|
+
groupContext == null ? void 0 : groupContext.isGrid
|
|
224
|
+
]
|
|
225
|
+
);
|
|
226
|
+
const baseStyles = (0, import_shared_utils2.clsx)(classNames == null ? void 0 : classNames.base, className);
|
|
227
|
+
const canBeFocused = (0, import_react2.useMemo)(() => {
|
|
228
|
+
return isFocusable || as === "button";
|
|
229
|
+
}, [isFocusable, as]);
|
|
230
|
+
const getAvatarProps = (0, import_react2.useCallback)(
|
|
231
|
+
(props = {}) => ({
|
|
232
|
+
ref: domRef,
|
|
233
|
+
tabIndex: canBeFocused ? 0 : -1,
|
|
234
|
+
"data-hover": (0, import_shared_utils2.dataAttr)(isHovered),
|
|
235
|
+
"data-focus": (0, import_shared_utils2.dataAttr)(isFocused),
|
|
236
|
+
"data-focus-visible": (0, import_shared_utils2.dataAttr)(isFocusVisible),
|
|
237
|
+
className: slots.base({
|
|
238
|
+
class: (0, import_shared_utils2.clsx)(baseStyles, props == null ? void 0 : props.className)
|
|
239
|
+
}),
|
|
240
|
+
...(0, import_utils.mergeProps)(otherProps, hoverProps, canBeFocused ? focusProps : {})
|
|
241
|
+
}),
|
|
242
|
+
[canBeFocused, slots, baseStyles, focusProps, otherProps]
|
|
243
|
+
);
|
|
244
|
+
const getImageProps = (0, import_react2.useCallback)(
|
|
245
|
+
(props = {}) => ({
|
|
246
|
+
ref: imgRef,
|
|
247
|
+
src,
|
|
248
|
+
"data-loaded": (0, import_shared_utils2.dataAttr)(isImgLoaded),
|
|
249
|
+
className: slots.img({ class: classNames == null ? void 0 : classNames.img }),
|
|
250
|
+
...(0, import_utils.mergeProps)(
|
|
251
|
+
imgProps,
|
|
252
|
+
props,
|
|
253
|
+
(0, import_react_utils4.filterDOMProps)({ disableAnimation }, {
|
|
254
|
+
enabled: shouldFilterDOMProps
|
|
255
|
+
})
|
|
256
|
+
)
|
|
257
|
+
}),
|
|
258
|
+
[slots, isImgLoaded, imgProps, disableAnimation, src, imgRef, shouldFilterDOMProps]
|
|
259
|
+
);
|
|
260
|
+
return {
|
|
261
|
+
Component,
|
|
262
|
+
ImgComponent,
|
|
263
|
+
src,
|
|
264
|
+
alt,
|
|
265
|
+
icon,
|
|
266
|
+
name,
|
|
267
|
+
imgRef,
|
|
268
|
+
slots,
|
|
269
|
+
classNames,
|
|
270
|
+
fallback,
|
|
271
|
+
isImgLoaded,
|
|
272
|
+
showFallback,
|
|
273
|
+
ignoreFallback,
|
|
274
|
+
getInitials,
|
|
275
|
+
getAvatarProps,
|
|
276
|
+
getImageProps
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// src/avatar.tsx
|
|
281
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
282
|
+
var Avatar = (0, import_system2.forwardRef)((props, ref) => {
|
|
283
|
+
const {
|
|
284
|
+
Component,
|
|
285
|
+
ImgComponent,
|
|
286
|
+
src,
|
|
287
|
+
icon = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AvatarIcon, {}),
|
|
288
|
+
alt,
|
|
289
|
+
classNames,
|
|
290
|
+
slots,
|
|
291
|
+
name,
|
|
292
|
+
showFallback,
|
|
293
|
+
fallback: fallbackComponent,
|
|
294
|
+
getInitials,
|
|
295
|
+
getAvatarProps,
|
|
296
|
+
getImageProps
|
|
297
|
+
} = useAvatar({
|
|
298
|
+
...props,
|
|
299
|
+
ref
|
|
300
|
+
});
|
|
301
|
+
const fallback = (0, import_react3.useMemo)(() => {
|
|
302
|
+
if (!showFallback && src)
|
|
303
|
+
return null;
|
|
304
|
+
if (fallbackComponent) {
|
|
305
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "aria-label": alt, className: slots.fallback({ class: classNames == null ? void 0 : classNames.fallback }), role: "img", children: fallbackComponent });
|
|
306
|
+
}
|
|
307
|
+
return name ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "aria-label": alt, className: slots.name({ class: classNames == null ? void 0 : classNames.name }), role: "img", children: getInitials(name) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "aria-label": alt, className: slots.icon({ class: classNames == null ? void 0 : classNames.icon }), role: "img", children: icon });
|
|
308
|
+
}, [showFallback, src, fallbackComponent, name, classNames]);
|
|
309
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Component, { ...getAvatarProps(), children: [
|
|
310
|
+
src && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ImgComponent, { ...getImageProps(), alt }),
|
|
311
|
+
fallback
|
|
312
|
+
] });
|
|
313
|
+
});
|
|
314
|
+
Avatar.displayName = "HeorUI.Avatar";
|
|
315
|
+
var avatar_default = Avatar;
|
|
316
|
+
|
|
317
|
+
// src/avatar-group.tsx
|
|
318
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
319
|
+
var AvatarGroup = (0, import_system3.forwardRef)((props, ref) => {
|
|
320
|
+
const {
|
|
321
|
+
Component,
|
|
322
|
+
clones,
|
|
323
|
+
context,
|
|
324
|
+
remainingCount,
|
|
325
|
+
getAvatarGroupCountProps,
|
|
326
|
+
getAvatarGroupProps,
|
|
327
|
+
renderCount = (count) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(avatar_default, { ...getAvatarGroupCountProps(), name: `+${count}` })
|
|
328
|
+
} = useAvatarGroup({
|
|
329
|
+
...props,
|
|
330
|
+
ref
|
|
331
|
+
});
|
|
332
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Component, { ...getAvatarGroupProps(), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(AvatarGroupProvider, { value: context, children: [
|
|
333
|
+
clones,
|
|
334
|
+
remainingCount > 0 && renderCount(remainingCount)
|
|
335
|
+
] }) });
|
|
336
|
+
});
|
|
337
|
+
AvatarGroup.displayName = "HeorUI.AvatarGroup";
|
|
338
|
+
var avatar_group_default = AvatarGroup;
|
|
339
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
340
|
+
0 && (module.exports = {});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
avatar_group_default
|
|
4
|
+
} from "./chunk-MJUNODSQ.mjs";
|
|
5
|
+
import "./chunk-RATOCJCD.mjs";
|
|
6
|
+
import "./chunk-25E6VDTZ.mjs";
|
|
7
|
+
import "./chunk-QH65JCLF.mjs";
|
|
8
|
+
import "./chunk-LTC67JRI.mjs";
|
|
9
|
+
import "./chunk-JUJ53SJZ.mjs";
|
|
10
|
+
export {
|
|
11
|
+
avatar_group_default as default
|
|
12
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/avatar-icon.tsx
|
|
22
|
+
var avatar_icon_exports = {};
|
|
23
|
+
__export(avatar_icon_exports, {
|
|
24
|
+
AvatarIcon: () => AvatarIcon
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(avatar_icon_exports);
|
|
27
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
|
+
var AvatarIcon = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
29
|
+
"svg",
|
|
30
|
+
{
|
|
31
|
+
"aria-hidden": "true",
|
|
32
|
+
fill: "none",
|
|
33
|
+
height: "80%",
|
|
34
|
+
role: "presentation",
|
|
35
|
+
viewBox: "0 0 24 24",
|
|
36
|
+
width: "80%",
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
39
|
+
"path",
|
|
40
|
+
{
|
|
41
|
+
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",
|
|
42
|
+
fill: "currentColor"
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
46
|
+
"path",
|
|
47
|
+
{
|
|
48
|
+
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",
|
|
49
|
+
fill: "currentColor"
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
AvatarIcon
|
|
58
|
+
});
|
package/dist/avatar.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as _heroui_system from '@heroui/system';
|
|
2
|
+
import { UseAvatarProps } from './use-avatar.js';
|
|
3
|
+
import 'tailwind-variants';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@heroui/theme';
|
|
6
|
+
import '@heroui/react-utils';
|
|
7
|
+
|
|
8
|
+
interface AvatarProps extends UseAvatarProps {
|
|
9
|
+
}
|
|
10
|
+
declare const Avatar: _heroui_system.InternalForwardRefRenderFunction<"span", AvatarProps, never>;
|
|
11
|
+
|
|
12
|
+
export { AvatarProps, Avatar as default };
|