@edifice.io/react 2.6.7-develop-b2school.20260929181638 → 2.6.7-develop-b2school.20260930103331
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,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
2
|
+
import { forwardRef, useState, useEffect } from "react";
|
|
3
3
|
import clsx from "clsx";
|
|
4
4
|
import * as iconsApps from "../../icons-apps.js";
|
|
5
5
|
import useEdificeIcons from "../../hooks/useEdificeIcons/useEdificeIcons.js";
|
|
@@ -15,7 +15,7 @@ const AppIcon = /* @__PURE__ */ forwardRef(({
|
|
|
15
15
|
const {
|
|
16
16
|
isIconUrl,
|
|
17
17
|
getIconCode
|
|
18
|
-
} = useEdificeIcons(), isSquare = variant === "square", isRounded = variant === "rounded", isCircle = variant === "circle", isContain = iconFit === "contain", isRatio = iconFit === "ratio", iconSizes = {
|
|
18
|
+
} = useEdificeIcons(), [imageLoadFailed, setImageLoadFailed] = useState(!1), isSquare = variant === "square", isRounded = variant === "rounded", isCircle = variant === "circle", isContain = iconFit === "contain", isRatio = iconFit === "ratio", iconSizes = {
|
|
19
19
|
"icon-xs": size === "24",
|
|
20
20
|
"icon-sm": size === "40",
|
|
21
21
|
"icon-md": size === "48",
|
|
@@ -28,7 +28,11 @@ const AppIcon = /* @__PURE__ */ forwardRef(({
|
|
|
28
28
|
}, iconFits = {
|
|
29
29
|
"icon-contain": isContain,
|
|
30
30
|
"icon-ratio": isRatio
|
|
31
|
-
}, icon = typeof app == "string" ? app : (app == null ? void 0 : app.icon) !== void 0 ? app.icon : "placeholder", displayName = typeof app != "string" && (app == null ? void 0 : app.displayName)
|
|
31
|
+
}, icon = typeof app == "string" ? app : (app == null ? void 0 : app.icon) !== void 0 ? app.icon : "placeholder", displayName = typeof app != "string" && ((app == null ? void 0 : app.displayName) || (app == null ? void 0 : app.name)) || "", code = app ? getIconCode(app) : "", iconIsUrl = !!isIconUrl(icon), isIconURL = iconIsUrl && !imageLoadFailed, showLetterFallback = iconIsUrl && imageLoadFailed && !!displayName;
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
setImageLoadFailed(!1);
|
|
34
|
+
}, [icon]);
|
|
35
|
+
const appCode = iconIsUrl ? "placeholder" : code || "placeholder", classes = clsx("app-icon", {
|
|
32
36
|
...iconSizes,
|
|
33
37
|
...iconVariant,
|
|
34
38
|
...iconFits,
|
|
@@ -42,12 +46,14 @@ const AppIcon = /* @__PURE__ */ forwardRef(({
|
|
|
42
46
|
const classes2 = clsx("h-full", className);
|
|
43
47
|
return /* @__PURE__ */ jsx(Image, { src: icon, alt: displayName, objectFit: "contain", width: size, height: size, className: classes2, style: {
|
|
44
48
|
minWidth: size + "px"
|
|
45
|
-
} });
|
|
49
|
+
}, onError: () => setImageLoadFailed(!0) });
|
|
46
50
|
}
|
|
47
51
|
return /* @__PURE__ */ jsx("div", { ref, className: classes, style: {
|
|
48
52
|
width: size + "px",
|
|
49
53
|
height: size + "px"
|
|
50
|
-
}, children: /* @__PURE__ */ jsx(
|
|
54
|
+
}, children: showLetterFallback ? /* @__PURE__ */ jsx("span", { className: "app-icon-letter", style: {
|
|
55
|
+
fontSize: size + "px"
|
|
56
|
+
}, children: displayName.charAt(0).toUpperCase() }) : /* @__PURE__ */ jsx(IconComponent, { width: size, height: size }) });
|
|
51
57
|
});
|
|
52
58
|
export {
|
|
53
59
|
AppIcon as default
|
|
@@ -10,6 +10,7 @@ const Image = /* @__PURE__ */ forwardRef(({
|
|
|
10
10
|
ratio,
|
|
11
11
|
objectFit,
|
|
12
12
|
className,
|
|
13
|
+
onError: onErrorProp,
|
|
13
14
|
...restProps
|
|
14
15
|
}, ref) => {
|
|
15
16
|
const placeholder = imgPlaceholder ?? commonPlaceholder, {
|
|
@@ -18,7 +19,9 @@ const Image = /* @__PURE__ */ forwardRef(({
|
|
|
18
19
|
} = useImage({
|
|
19
20
|
src,
|
|
20
21
|
placeholder
|
|
21
|
-
}),
|
|
22
|
+
}), handleError = (event) => {
|
|
23
|
+
onError(), onErrorProp == null || onErrorProp(event);
|
|
24
|
+
}, ratioImage = {
|
|
22
25
|
"ratio ratio-1x1": ratio === "1",
|
|
23
26
|
"ratio ratio-4x3": ratio === "4",
|
|
24
27
|
"ratio ratio-16x9": ratio === "16",
|
|
@@ -33,7 +36,7 @@ const Image = /* @__PURE__ */ forwardRef(({
|
|
|
33
36
|
...ratioImage
|
|
34
37
|
}), classes = clsx({
|
|
35
38
|
...objectImage
|
|
36
|
-
}, className), renderImage = /* @__PURE__ */ jsx("img", { alt, onError, ref, src: imgSrc, className: classes, ...restProps });
|
|
39
|
+
}, className), renderImage = /* @__PURE__ */ jsx("img", { alt, onError: handleError, ref, src: imgSrc, className: classes, ...restProps });
|
|
37
40
|
return ratio ? /* @__PURE__ */ jsx("div", { className: ratioClasses, children: renderImage }) : renderImage;
|
|
38
41
|
});
|
|
39
42
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edifice.io/react",
|
|
3
|
-
"version": "2.6.7-develop-b2school.
|
|
3
|
+
"version": "2.6.7-develop-b2school.20260930103331",
|
|
4
4
|
"description": "Edifice React Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -140,9 +140,9 @@
|
|
|
140
140
|
"swiper": "10.1.0",
|
|
141
141
|
"ua-parser-js": "1.0.36",
|
|
142
142
|
"zustand": "4.5.7",
|
|
143
|
-
"@edifice.io/
|
|
144
|
-
"@edifice.io/
|
|
145
|
-
"@edifice.io/utilities": "2.6.7-develop-b2school.
|
|
143
|
+
"@edifice.io/bootstrap": "2.6.7-develop-b2school.20260930103331",
|
|
144
|
+
"@edifice.io/tiptap-extensions": "2.6.7-develop-b2school.20260930103331",
|
|
145
|
+
"@edifice.io/utilities": "2.6.7-develop-b2school.20260930103331"
|
|
146
146
|
},
|
|
147
147
|
"devDependencies": {
|
|
148
148
|
"@babel/plugin-transform-react-pure-annotations": "7.27.1",
|
|
@@ -173,8 +173,8 @@
|
|
|
173
173
|
"vite": "5.4.14",
|
|
174
174
|
"vite-plugin-dts": "4.5.4",
|
|
175
175
|
"vite-tsconfig-paths": "5.1.4",
|
|
176
|
-
"@edifice.io/
|
|
177
|
-
"@edifice.io/
|
|
176
|
+
"@edifice.io/client": "2.6.7-develop-b2school.20260930103331",
|
|
177
|
+
"@edifice.io/config": "2.6.7-develop-b2school.20260930103331"
|
|
178
178
|
},
|
|
179
179
|
"peerDependencies": {
|
|
180
180
|
"@react-spring/web": "9.7.5",
|