xtreme-ui 0.0.92 → 0.0.94
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../../src/components/base/Avatar/Avatar.tsx"],"names":[],"mappings":"AASA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAe,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../../src/components/base/Avatar/Avatar.tsx"],"names":[],"mappings":"AASA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAe,YAAY,EAAE,MAAM,SAAS,CAAC;AAEpD,eAAO,MAAM,MAAM,yGA0EjB,CAAC"}
|
|
@@ -1,52 +1,53 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as i } from "react/jsx-runtime";
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import
|
|
5
|
-
import { FACE_ICONS as
|
|
6
|
-
import { readImageFile as
|
|
7
|
-
import { Icon as
|
|
3
|
+
import { forwardRef as z, useState as c, useEffect as E } from "react";
|
|
4
|
+
import C from "clsx";
|
|
5
|
+
import { FACE_ICONS as m } from "../../../utils/constants/iconCollection.js";
|
|
6
|
+
import { readImageFile as F, readImageSrc as L } from "../../../utils/helper/imageHelper.js";
|
|
7
|
+
import { Icon as b } from "../Icon/Icon.js";
|
|
8
8
|
/* empty css */
|
|
9
|
-
import { EAvatarSize as
|
|
10
|
-
const
|
|
11
|
-
const { className: u, src: a, file:
|
|
9
|
+
import { EAvatarSize as M } from "./types.js";
|
|
10
|
+
const R = z((h, g) => {
|
|
11
|
+
const { className: u, src: a, file: o, alt: v, placeholderIcon: y, size: l = "default", onClick: I } = h, [n, f] = c(), [x, A] = c(m.happy[0]), [N, t] = c(!!a || !!o), [p, r] = c(!1), d = typeof l == "number" ? l : M[l], S = C(
|
|
12
12
|
"xtrAvatar",
|
|
13
13
|
u,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
N && "loading",
|
|
15
|
+
p && "error"
|
|
16
16
|
), s = (e) => {
|
|
17
|
-
e && setTimeout(() =>
|
|
17
|
+
e && setTimeout(() => f(e), 300), setTimeout(() => t(!1), 1e3);
|
|
18
18
|
};
|
|
19
19
|
return E(() => {
|
|
20
|
+
A(m.happy[Math.floor(Math.random() * m.happy.length)]);
|
|
20
21
|
try {
|
|
21
|
-
|
|
22
|
-
console.log(e), t(!1),
|
|
23
|
-
})) : a ? (t(!0),
|
|
24
|
-
console.log(e, a), t(!1),
|
|
25
|
-
})) : (
|
|
22
|
+
o ? (t(!0), r(!1), F(o).then((e) => s(e)).catch((e) => {
|
|
23
|
+
console.log(e), t(!1), r(!0);
|
|
24
|
+
})) : a ? (t(!0), r(!1), L(a).then((e) => s(e)).catch((e) => {
|
|
25
|
+
console.log(e, a), t(!1), r(!0);
|
|
26
|
+
})) : (f(void 0), s());
|
|
26
27
|
} catch {
|
|
27
28
|
s();
|
|
28
29
|
}
|
|
29
|
-
}, [a,
|
|
30
|
+
}, [a, o]), /* @__PURE__ */ i(
|
|
30
31
|
"div",
|
|
31
32
|
{
|
|
32
|
-
ref:
|
|
33
|
-
className:
|
|
34
|
-
style: { "--avatarSize":
|
|
33
|
+
ref: g,
|
|
34
|
+
className: S,
|
|
35
|
+
style: { "--avatarSize": d + "px" },
|
|
35
36
|
onClick: I,
|
|
36
37
|
role: "img",
|
|
37
|
-
children:
|
|
38
|
-
|
|
38
|
+
children: n ? /* @__PURE__ */ i("img", { className: "image", src: n, alt: v }) : /* @__PURE__ */ i(
|
|
39
|
+
b,
|
|
39
40
|
{
|
|
40
41
|
className: "placeholder",
|
|
41
42
|
type: "solid",
|
|
42
|
-
size: 8 +
|
|
43
|
-
code:
|
|
43
|
+
size: 8 + d / 4,
|
|
44
|
+
code: p ? "e1b7" : y ?? x
|
|
44
45
|
}
|
|
45
46
|
)
|
|
46
47
|
}
|
|
47
48
|
);
|
|
48
49
|
});
|
|
49
|
-
|
|
50
|
+
R.displayName = "Avatar";
|
|
50
51
|
export {
|
|
51
|
-
|
|
52
|
+
R as Avatar
|
|
52
53
|
};
|