@heroui/avatar 2.2.7 → 2.2.8
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 +1 -1
- package/README.md +2 -2
- package/package.json +10 -10
- package/dist/avatar-group-context.d.ts +0 -13
- package/dist/avatar-group-context.js +0 -37
- package/dist/avatar-group-context.mjs +0 -9
- package/dist/avatar-group.d.ts +0 -14
- package/dist/avatar-group.js +0 -340
- package/dist/avatar-group.mjs +0 -12
- package/dist/avatar-icon.d.ts +0 -5
- package/dist/avatar-icon.js +0 -58
- package/dist/avatar-icon.mjs +0 -7
- package/dist/avatar.d.ts +0 -12
- package/dist/avatar.js +0 -236
- package/dist/avatar.mjs +0 -10
- package/dist/chunk-25E6VDTZ.mjs +0 -35
- package/dist/chunk-JUJ53SJZ.mjs +0 -13
- package/dist/chunk-LTC67JRI.mjs +0 -138
- package/dist/chunk-NB7VH5TP.mjs +0 -38
- package/dist/chunk-QH65JCLF.mjs +0 -85
- package/dist/chunk-SXMLSBOY.mjs +0 -50
- package/dist/index.d.ts +0 -12
- package/dist/index.js +0 -358
- package/dist/index.mjs +0 -29
- package/dist/use-avatar-group.d.ts +0 -67
- package/dist/use-avatar-group.js +0 -108
- package/dist/use-avatar-group.mjs +0 -7
- package/dist/use-avatar.d.ts +0 -207
- package/dist/use-avatar.js +0 -167
- package/dist/use-avatar.mjs +0 -8
package/dist/index.js
DELETED
|
@@ -1,358 +0,0 @@
|
|
|
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/index.ts
|
|
22
|
-
var src_exports = {};
|
|
23
|
-
__export(src_exports, {
|
|
24
|
-
Avatar: () => avatar_default,
|
|
25
|
-
AvatarGroup: () => avatar_group_default,
|
|
26
|
-
AvatarGroupProvider: () => AvatarGroupProvider,
|
|
27
|
-
AvatarIcon: () => AvatarIcon,
|
|
28
|
-
useAvatar: () => useAvatar,
|
|
29
|
-
useAvatarGroup: () => useAvatarGroup,
|
|
30
|
-
useAvatarGroupContext: () => useAvatarGroupContext
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(src_exports);
|
|
33
|
-
|
|
34
|
-
// src/avatar.tsx
|
|
35
|
-
var import_react2 = require("react");
|
|
36
|
-
var import_system2 = require("@heroui/system");
|
|
37
|
-
|
|
38
|
-
// src/avatar-icon.tsx
|
|
39
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
-
var AvatarIcon = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
41
|
-
"svg",
|
|
42
|
-
{
|
|
43
|
-
"aria-hidden": "true",
|
|
44
|
-
fill: "none",
|
|
45
|
-
height: "80%",
|
|
46
|
-
role: "presentation",
|
|
47
|
-
viewBox: "0 0 24 24",
|
|
48
|
-
width: "80%",
|
|
49
|
-
children: [
|
|
50
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
51
|
-
"path",
|
|
52
|
-
{
|
|
53
|
-
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",
|
|
54
|
-
fill: "currentColor"
|
|
55
|
-
}
|
|
56
|
-
),
|
|
57
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
58
|
-
"path",
|
|
59
|
-
{
|
|
60
|
-
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",
|
|
61
|
-
fill: "currentColor"
|
|
62
|
-
}
|
|
63
|
-
)
|
|
64
|
-
]
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
// src/use-avatar.ts
|
|
69
|
-
var import_theme = require("@heroui/theme");
|
|
70
|
-
var import_system = require("@heroui/system");
|
|
71
|
-
var import_utils = require("@react-aria/utils");
|
|
72
|
-
var import_react_utils2 = require("@heroui/react-utils");
|
|
73
|
-
var import_shared_utils = require("@heroui/shared-utils");
|
|
74
|
-
var import_focus = require("@react-aria/focus");
|
|
75
|
-
var import_react = require("react");
|
|
76
|
-
var import_use_image = require("@heroui/use-image");
|
|
77
|
-
var import_interactions = require("@react-aria/interactions");
|
|
78
|
-
|
|
79
|
-
// src/avatar-group-context.ts
|
|
80
|
-
var import_react_utils = require("@heroui/react-utils");
|
|
81
|
-
var [AvatarGroupProvider, useAvatarGroupContext] = (0, import_react_utils.createContext)({
|
|
82
|
-
name: "AvatarGroupContext",
|
|
83
|
-
strict: false
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
// src/use-avatar.ts
|
|
87
|
-
function useAvatar(originalProps = {}) {
|
|
88
|
-
var _a, _b, _c, _d, _e, _f;
|
|
89
|
-
const globalContext = (0, import_system.useProviderContext)();
|
|
90
|
-
const groupContext = useAvatarGroupContext();
|
|
91
|
-
const isInGroup = !!groupContext;
|
|
92
|
-
const {
|
|
93
|
-
as,
|
|
94
|
-
ref,
|
|
95
|
-
src,
|
|
96
|
-
name,
|
|
97
|
-
icon,
|
|
98
|
-
classNames,
|
|
99
|
-
fallback,
|
|
100
|
-
alt = name || "avatar",
|
|
101
|
-
imgRef: imgRefProp,
|
|
102
|
-
color = (_a = groupContext == null ? void 0 : groupContext.color) != null ? _a : "default",
|
|
103
|
-
radius = (_b = groupContext == null ? void 0 : groupContext.radius) != null ? _b : "full",
|
|
104
|
-
size = (_c = groupContext == null ? void 0 : groupContext.size) != null ? _c : "md",
|
|
105
|
-
isBordered = (_d = groupContext == null ? void 0 : groupContext.isBordered) != null ? _d : false,
|
|
106
|
-
isDisabled = (_e = groupContext == null ? void 0 : groupContext.isDisabled) != null ? _e : false,
|
|
107
|
-
isFocusable = false,
|
|
108
|
-
getInitials = import_shared_utils.safeText,
|
|
109
|
-
ignoreFallback = false,
|
|
110
|
-
showFallback: showFallbackProp = false,
|
|
111
|
-
ImgComponent = "img",
|
|
112
|
-
imgProps,
|
|
113
|
-
className,
|
|
114
|
-
onError,
|
|
115
|
-
disableAnimation: disableAnimationProp,
|
|
116
|
-
...otherProps
|
|
117
|
-
} = originalProps;
|
|
118
|
-
const Component = as || "span";
|
|
119
|
-
const domRef = (0, import_react_utils2.useDOMRef)(ref);
|
|
120
|
-
const imgRef = (0, import_react_utils2.useDOMRef)(imgRefProp);
|
|
121
|
-
const { isFocusVisible, isFocused, focusProps } = (0, import_focus.useFocusRing)();
|
|
122
|
-
const { isHovered, hoverProps } = (0, import_interactions.useHover)({ isDisabled });
|
|
123
|
-
const disableAnimation = (_f = disableAnimationProp != null ? disableAnimationProp : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _f : false;
|
|
124
|
-
const imageStatus = (0, import_use_image.useImage)({ src, onError, ignoreFallback });
|
|
125
|
-
const isImgLoaded = imageStatus === "loaded";
|
|
126
|
-
const shouldFilterDOMProps = typeof ImgComponent === "string";
|
|
127
|
-
const showFallback = (!src || !isImgLoaded) && showFallbackProp;
|
|
128
|
-
const slots = (0, import_react.useMemo)(
|
|
129
|
-
() => {
|
|
130
|
-
var _a2;
|
|
131
|
-
return (0, import_theme.avatar)({
|
|
132
|
-
color,
|
|
133
|
-
radius,
|
|
134
|
-
size,
|
|
135
|
-
isBordered,
|
|
136
|
-
isDisabled,
|
|
137
|
-
isInGroup,
|
|
138
|
-
disableAnimation,
|
|
139
|
-
isInGridGroup: (_a2 = groupContext == null ? void 0 : groupContext.isGrid) != null ? _a2 : false
|
|
140
|
-
});
|
|
141
|
-
},
|
|
142
|
-
[
|
|
143
|
-
color,
|
|
144
|
-
radius,
|
|
145
|
-
size,
|
|
146
|
-
isBordered,
|
|
147
|
-
isDisabled,
|
|
148
|
-
disableAnimation,
|
|
149
|
-
isInGroup,
|
|
150
|
-
groupContext == null ? void 0 : groupContext.isGrid
|
|
151
|
-
]
|
|
152
|
-
);
|
|
153
|
-
const baseStyles = (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.base, className);
|
|
154
|
-
const canBeFocused = (0, import_react.useMemo)(() => {
|
|
155
|
-
return isFocusable || as === "button";
|
|
156
|
-
}, [isFocusable, as]);
|
|
157
|
-
const getAvatarProps = (0, import_react.useCallback)(
|
|
158
|
-
(props = {}) => ({
|
|
159
|
-
ref: domRef,
|
|
160
|
-
tabIndex: canBeFocused ? 0 : -1,
|
|
161
|
-
"data-hover": (0, import_shared_utils.dataAttr)(isHovered),
|
|
162
|
-
"data-focus": (0, import_shared_utils.dataAttr)(isFocused),
|
|
163
|
-
"data-focus-visible": (0, import_shared_utils.dataAttr)(isFocusVisible),
|
|
164
|
-
className: slots.base({
|
|
165
|
-
class: (0, import_shared_utils.clsx)(baseStyles, props == null ? void 0 : props.className)
|
|
166
|
-
}),
|
|
167
|
-
...(0, import_utils.mergeProps)(otherProps, hoverProps, canBeFocused ? focusProps : {})
|
|
168
|
-
}),
|
|
169
|
-
[canBeFocused, slots, baseStyles, focusProps, otherProps]
|
|
170
|
-
);
|
|
171
|
-
const getImageProps = (0, import_react.useCallback)(
|
|
172
|
-
(props = {}) => ({
|
|
173
|
-
ref: imgRef,
|
|
174
|
-
src,
|
|
175
|
-
"data-loaded": (0, import_shared_utils.dataAttr)(isImgLoaded),
|
|
176
|
-
className: slots.img({ class: classNames == null ? void 0 : classNames.img }),
|
|
177
|
-
...(0, import_utils.mergeProps)(
|
|
178
|
-
imgProps,
|
|
179
|
-
props,
|
|
180
|
-
(0, import_react_utils2.filterDOMProps)({ disableAnimation }, {
|
|
181
|
-
enabled: shouldFilterDOMProps
|
|
182
|
-
})
|
|
183
|
-
)
|
|
184
|
-
}),
|
|
185
|
-
[slots, isImgLoaded, imgProps, disableAnimation, src, imgRef, shouldFilterDOMProps]
|
|
186
|
-
);
|
|
187
|
-
return {
|
|
188
|
-
Component,
|
|
189
|
-
ImgComponent,
|
|
190
|
-
src,
|
|
191
|
-
alt,
|
|
192
|
-
icon,
|
|
193
|
-
name,
|
|
194
|
-
imgRef,
|
|
195
|
-
slots,
|
|
196
|
-
classNames,
|
|
197
|
-
fallback,
|
|
198
|
-
isImgLoaded,
|
|
199
|
-
showFallback,
|
|
200
|
-
ignoreFallback,
|
|
201
|
-
getInitials,
|
|
202
|
-
getAvatarProps,
|
|
203
|
-
getImageProps
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// src/avatar.tsx
|
|
208
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
209
|
-
var Avatar = (0, import_system2.forwardRef)((props, ref) => {
|
|
210
|
-
const {
|
|
211
|
-
Component,
|
|
212
|
-
ImgComponent,
|
|
213
|
-
src,
|
|
214
|
-
icon = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AvatarIcon, {}),
|
|
215
|
-
alt,
|
|
216
|
-
classNames,
|
|
217
|
-
slots,
|
|
218
|
-
name,
|
|
219
|
-
showFallback,
|
|
220
|
-
fallback: fallbackComponent,
|
|
221
|
-
getInitials,
|
|
222
|
-
getAvatarProps,
|
|
223
|
-
getImageProps
|
|
224
|
-
} = useAvatar({
|
|
225
|
-
...props,
|
|
226
|
-
ref
|
|
227
|
-
});
|
|
228
|
-
const fallback = (0, import_react2.useMemo)(() => {
|
|
229
|
-
if (!showFallback && src)
|
|
230
|
-
return null;
|
|
231
|
-
if (fallbackComponent) {
|
|
232
|
-
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 });
|
|
233
|
-
}
|
|
234
|
-
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 });
|
|
235
|
-
}, [showFallback, src, fallbackComponent, name, classNames]);
|
|
236
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(Component, { ...getAvatarProps(), children: [
|
|
237
|
-
src && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ImgComponent, { ...getImageProps(), alt }),
|
|
238
|
-
fallback
|
|
239
|
-
] });
|
|
240
|
-
});
|
|
241
|
-
Avatar.displayName = "HeroUI.Avatar";
|
|
242
|
-
var avatar_default = Avatar;
|
|
243
|
-
|
|
244
|
-
// src/avatar-group.tsx
|
|
245
|
-
var import_system3 = require("@heroui/system");
|
|
246
|
-
|
|
247
|
-
// src/use-avatar-group.ts
|
|
248
|
-
var import_theme2 = require("@heroui/theme");
|
|
249
|
-
var import_react_utils3 = require("@heroui/react-utils");
|
|
250
|
-
var import_shared_utils2 = require("@heroui/shared-utils");
|
|
251
|
-
var import_react_utils4 = require("@heroui/react-utils");
|
|
252
|
-
var import_react3 = require("react");
|
|
253
|
-
function useAvatarGroup(props = {}) {
|
|
254
|
-
const {
|
|
255
|
-
as,
|
|
256
|
-
ref,
|
|
257
|
-
max = 5,
|
|
258
|
-
total,
|
|
259
|
-
size,
|
|
260
|
-
color,
|
|
261
|
-
radius,
|
|
262
|
-
children,
|
|
263
|
-
isBordered,
|
|
264
|
-
isDisabled,
|
|
265
|
-
isGrid,
|
|
266
|
-
renderCount,
|
|
267
|
-
className,
|
|
268
|
-
classNames,
|
|
269
|
-
...otherProps
|
|
270
|
-
} = props;
|
|
271
|
-
const domRef = (0, import_react_utils3.useDOMRef)(ref);
|
|
272
|
-
const Component = as || "div";
|
|
273
|
-
const context = (0, import_react3.useMemo)(
|
|
274
|
-
() => ({
|
|
275
|
-
size,
|
|
276
|
-
color,
|
|
277
|
-
radius,
|
|
278
|
-
isGrid,
|
|
279
|
-
isBordered,
|
|
280
|
-
isDisabled
|
|
281
|
-
}),
|
|
282
|
-
[size, color, radius, isGrid, isBordered, isDisabled]
|
|
283
|
-
);
|
|
284
|
-
const slots = (0, import_react3.useMemo)(() => (0, import_theme2.avatarGroup)({ className, isGrid }), [className, isGrid]);
|
|
285
|
-
const validChildren = (0, import_react_utils4.getValidChildren)(children);
|
|
286
|
-
const childrenWithinMax = max ? validChildren.slice(0, max) : validChildren;
|
|
287
|
-
const remainingCount = total ? total : max != null ? validChildren.length - max : -1;
|
|
288
|
-
const clones = childrenWithinMax.map((child, index) => {
|
|
289
|
-
const isFirstAvatar = index === 0;
|
|
290
|
-
const isLastAvatar = index === childrenWithinMax.length - 1;
|
|
291
|
-
const childProps = {
|
|
292
|
-
className: (0, import_shared_utils2.clsx)(
|
|
293
|
-
isFirstAvatar ? "ms-0" : !isGrid ? "-ms-2" : "",
|
|
294
|
-
isLastAvatar && remainingCount < 1 ? "hover:-translate-x-0" : ""
|
|
295
|
-
)
|
|
296
|
-
};
|
|
297
|
-
return (0, import_react3.cloneElement)(child, (0, import_shared_utils2.compact)(childProps));
|
|
298
|
-
});
|
|
299
|
-
const getAvatarGroupProps = () => {
|
|
300
|
-
return {
|
|
301
|
-
ref: domRef,
|
|
302
|
-
className: slots.base({
|
|
303
|
-
class: (0, import_shared_utils2.clsx)(classNames == null ? void 0 : classNames.base, className)
|
|
304
|
-
}),
|
|
305
|
-
role: "group",
|
|
306
|
-
...otherProps
|
|
307
|
-
};
|
|
308
|
-
};
|
|
309
|
-
const getAvatarGroupCountProps = () => {
|
|
310
|
-
return {
|
|
311
|
-
className: slots.count({
|
|
312
|
-
class: classNames == null ? void 0 : classNames.count
|
|
313
|
-
})
|
|
314
|
-
};
|
|
315
|
-
};
|
|
316
|
-
return {
|
|
317
|
-
Component,
|
|
318
|
-
context,
|
|
319
|
-
remainingCount,
|
|
320
|
-
clones,
|
|
321
|
-
renderCount,
|
|
322
|
-
getAvatarGroupProps,
|
|
323
|
-
getAvatarGroupCountProps
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// src/avatar-group.tsx
|
|
328
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
329
|
-
var AvatarGroup = (0, import_system3.forwardRef)((props, ref) => {
|
|
330
|
-
const {
|
|
331
|
-
Component,
|
|
332
|
-
clones,
|
|
333
|
-
context,
|
|
334
|
-
remainingCount,
|
|
335
|
-
getAvatarGroupCountProps,
|
|
336
|
-
getAvatarGroupProps,
|
|
337
|
-
renderCount = (count) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(avatar_default, { ...getAvatarGroupCountProps(), name: `+${count}` })
|
|
338
|
-
} = useAvatarGroup({
|
|
339
|
-
...props,
|
|
340
|
-
ref
|
|
341
|
-
});
|
|
342
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Component, { ...getAvatarGroupProps(), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(AvatarGroupProvider, { value: context, children: [
|
|
343
|
-
clones,
|
|
344
|
-
remainingCount > 0 && renderCount(remainingCount)
|
|
345
|
-
] }) });
|
|
346
|
-
});
|
|
347
|
-
AvatarGroup.displayName = "HeroUI.AvatarGroup";
|
|
348
|
-
var avatar_group_default = AvatarGroup;
|
|
349
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
350
|
-
0 && (module.exports = {
|
|
351
|
-
Avatar,
|
|
352
|
-
AvatarGroup,
|
|
353
|
-
AvatarGroupProvider,
|
|
354
|
-
AvatarIcon,
|
|
355
|
-
useAvatar,
|
|
356
|
-
useAvatarGroup,
|
|
357
|
-
useAvatarGroupContext
|
|
358
|
-
});
|
package/dist/index.mjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
avatar_group_default
|
|
4
|
-
} from "./chunk-NB7VH5TP.mjs";
|
|
5
|
-
import {
|
|
6
|
-
avatar_default
|
|
7
|
-
} from "./chunk-SXMLSBOY.mjs";
|
|
8
|
-
import {
|
|
9
|
-
AvatarIcon
|
|
10
|
-
} from "./chunk-25E6VDTZ.mjs";
|
|
11
|
-
import {
|
|
12
|
-
useAvatarGroup
|
|
13
|
-
} from "./chunk-QH65JCLF.mjs";
|
|
14
|
-
import {
|
|
15
|
-
useAvatar
|
|
16
|
-
} from "./chunk-LTC67JRI.mjs";
|
|
17
|
-
import {
|
|
18
|
-
AvatarGroupProvider,
|
|
19
|
-
useAvatarGroupContext
|
|
20
|
-
} from "./chunk-JUJ53SJZ.mjs";
|
|
21
|
-
export {
|
|
22
|
-
avatar_default as Avatar,
|
|
23
|
-
avatar_group_default as AvatarGroup,
|
|
24
|
-
AvatarGroupProvider,
|
|
25
|
-
AvatarIcon,
|
|
26
|
-
useAvatar,
|
|
27
|
-
useAvatarGroup,
|
|
28
|
-
useAvatarGroupContext
|
|
29
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
3
|
-
import * as _heroui_system from '@heroui/system';
|
|
4
|
-
import { PropGetter, HTMLHeroUIProps } from '@heroui/system';
|
|
5
|
-
import { AvatarGroupVariantProps, SlotsToClasses, AvatarGroupSlots } from '@heroui/theme';
|
|
6
|
-
import { ReactRef } from '@heroui/react-utils';
|
|
7
|
-
import { AvatarProps } from './avatar.js';
|
|
8
|
-
import './use-avatar.js';
|
|
9
|
-
import 'tailwind-variants';
|
|
10
|
-
|
|
11
|
-
interface Props extends HTMLHeroUIProps<"div"> {
|
|
12
|
-
/**
|
|
13
|
-
* Ref to the DOM node.
|
|
14
|
-
*/
|
|
15
|
-
ref?: ReactRef<HTMLDivElement | null>;
|
|
16
|
-
/**
|
|
17
|
-
* Whether the avatars should be displayed in a grid
|
|
18
|
-
*/
|
|
19
|
-
isGrid?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* The maximum number of visible avatars
|
|
22
|
-
* @default 5
|
|
23
|
-
*/
|
|
24
|
-
max?: number;
|
|
25
|
-
/**
|
|
26
|
-
* Control the number of avatar not visible
|
|
27
|
-
*/
|
|
28
|
-
total?: number;
|
|
29
|
-
/**
|
|
30
|
-
* This allows you to render a custom count component.
|
|
31
|
-
*/
|
|
32
|
-
renderCount?: (count: number) => ReactNode;
|
|
33
|
-
/**
|
|
34
|
-
* Classname or List of classes to change the classNames of the avatar group.
|
|
35
|
-
* if `className` is passed, it will be added to the base slot.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```ts
|
|
39
|
-
* <AvatarGroup classNames={{
|
|
40
|
-
* base: "base-classes",
|
|
41
|
-
* count: "count-classes"
|
|
42
|
-
* }} />
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
classNames?: SlotsToClasses<AvatarGroupSlots>;
|
|
46
|
-
}
|
|
47
|
-
type UseAvatarGroupProps = Props & Omit<AvatarGroupVariantProps, "children" | "isGrid"> & Partial<Pick<AvatarProps, "size" | "color" | "radius" | "isDisabled" | "isBordered">>;
|
|
48
|
-
type ContextType = {
|
|
49
|
-
size?: AvatarProps["size"];
|
|
50
|
-
color?: AvatarProps["color"];
|
|
51
|
-
radius?: AvatarProps["radius"];
|
|
52
|
-
isGrid?: boolean;
|
|
53
|
-
isBordered?: AvatarProps["isBordered"];
|
|
54
|
-
isDisabled?: AvatarProps["isDisabled"];
|
|
55
|
-
};
|
|
56
|
-
declare function useAvatarGroup(props?: UseAvatarGroupProps): {
|
|
57
|
-
Component: _heroui_system.As<any>;
|
|
58
|
-
context: ContextType;
|
|
59
|
-
remainingCount: number;
|
|
60
|
-
clones: react.ReactElement<any, string | react.JSXElementConstructor<any>>[];
|
|
61
|
-
renderCount: ((count: number) => ReactNode) | undefined;
|
|
62
|
-
getAvatarGroupProps: PropGetter<Record<string, unknown>, _heroui_system.DOMAttributes<_heroui_system.DOMElement>>;
|
|
63
|
-
getAvatarGroupCountProps: () => AvatarProps;
|
|
64
|
-
};
|
|
65
|
-
type UseAvatarReturn = ReturnType<typeof useAvatarGroup>;
|
|
66
|
-
|
|
67
|
-
export { ContextType, UseAvatarGroupProps, UseAvatarReturn, useAvatarGroup };
|
package/dist/use-avatar-group.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
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/use-avatar-group.ts
|
|
22
|
-
var use_avatar_group_exports = {};
|
|
23
|
-
__export(use_avatar_group_exports, {
|
|
24
|
-
useAvatarGroup: () => useAvatarGroup
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(use_avatar_group_exports);
|
|
27
|
-
var import_theme = require("@heroui/theme");
|
|
28
|
-
var import_react_utils = require("@heroui/react-utils");
|
|
29
|
-
var import_shared_utils = require("@heroui/shared-utils");
|
|
30
|
-
var import_react_utils2 = require("@heroui/react-utils");
|
|
31
|
-
var import_react = require("react");
|
|
32
|
-
function useAvatarGroup(props = {}) {
|
|
33
|
-
const {
|
|
34
|
-
as,
|
|
35
|
-
ref,
|
|
36
|
-
max = 5,
|
|
37
|
-
total,
|
|
38
|
-
size,
|
|
39
|
-
color,
|
|
40
|
-
radius,
|
|
41
|
-
children,
|
|
42
|
-
isBordered,
|
|
43
|
-
isDisabled,
|
|
44
|
-
isGrid,
|
|
45
|
-
renderCount,
|
|
46
|
-
className,
|
|
47
|
-
classNames,
|
|
48
|
-
...otherProps
|
|
49
|
-
} = props;
|
|
50
|
-
const domRef = (0, import_react_utils.useDOMRef)(ref);
|
|
51
|
-
const Component = as || "div";
|
|
52
|
-
const context = (0, import_react.useMemo)(
|
|
53
|
-
() => ({
|
|
54
|
-
size,
|
|
55
|
-
color,
|
|
56
|
-
radius,
|
|
57
|
-
isGrid,
|
|
58
|
-
isBordered,
|
|
59
|
-
isDisabled
|
|
60
|
-
}),
|
|
61
|
-
[size, color, radius, isGrid, isBordered, isDisabled]
|
|
62
|
-
);
|
|
63
|
-
const slots = (0, import_react.useMemo)(() => (0, import_theme.avatarGroup)({ className, isGrid }), [className, isGrid]);
|
|
64
|
-
const validChildren = (0, import_react_utils2.getValidChildren)(children);
|
|
65
|
-
const childrenWithinMax = max ? validChildren.slice(0, max) : validChildren;
|
|
66
|
-
const remainingCount = total ? total : max != null ? validChildren.length - max : -1;
|
|
67
|
-
const clones = childrenWithinMax.map((child, index) => {
|
|
68
|
-
const isFirstAvatar = index === 0;
|
|
69
|
-
const isLastAvatar = index === childrenWithinMax.length - 1;
|
|
70
|
-
const childProps = {
|
|
71
|
-
className: (0, import_shared_utils.clsx)(
|
|
72
|
-
isFirstAvatar ? "ms-0" : !isGrid ? "-ms-2" : "",
|
|
73
|
-
isLastAvatar && remainingCount < 1 ? "hover:-translate-x-0" : ""
|
|
74
|
-
)
|
|
75
|
-
};
|
|
76
|
-
return (0, import_react.cloneElement)(child, (0, import_shared_utils.compact)(childProps));
|
|
77
|
-
});
|
|
78
|
-
const getAvatarGroupProps = () => {
|
|
79
|
-
return {
|
|
80
|
-
ref: domRef,
|
|
81
|
-
className: slots.base({
|
|
82
|
-
class: (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.base, className)
|
|
83
|
-
}),
|
|
84
|
-
role: "group",
|
|
85
|
-
...otherProps
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
const getAvatarGroupCountProps = () => {
|
|
89
|
-
return {
|
|
90
|
-
className: slots.count({
|
|
91
|
-
class: classNames == null ? void 0 : classNames.count
|
|
92
|
-
})
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
return {
|
|
96
|
-
Component,
|
|
97
|
-
context,
|
|
98
|
-
remainingCount,
|
|
99
|
-
clones,
|
|
100
|
-
renderCount,
|
|
101
|
-
getAvatarGroupProps,
|
|
102
|
-
getAvatarGroupCountProps
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
-
0 && (module.exports = {
|
|
107
|
-
useAvatarGroup
|
|
108
|
-
});
|