muffin-admin 11.3.0 → 11.3.1
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/fields/AvatarField.js +12 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/fields/AvatarField.tsx +14 -1
- package/src/index.tsx +1 -1
|
@@ -11,12 +11,23 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import Avatar from "@mui/material/Avatar";
|
|
14
|
+
import CircularProgress from "@mui/material/CircularProgress";
|
|
14
15
|
import get from "lodash/get";
|
|
15
16
|
import { useRecordContext } from "ra-core";
|
|
16
17
|
export function AvatarField(_a) {
|
|
17
18
|
var { source, alt, style, nameProp } = _a, props = __rest(_a, ["source", "alt", "style", "nameProp"]);
|
|
18
19
|
const record = useRecordContext(props);
|
|
19
|
-
|
|
20
|
+
let value = get(record, source), name = record[nameProp];
|
|
21
|
+
// Check value is a valid URL
|
|
22
|
+
if (value) {
|
|
23
|
+
try {
|
|
24
|
+
new URL(value);
|
|
25
|
+
}
|
|
26
|
+
catch (_b) {
|
|
27
|
+
// Not a valid URL, return loader
|
|
28
|
+
return (_jsx(CircularProgress, { size: 24 }));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
20
31
|
const letters = name
|
|
21
32
|
? name
|
|
22
33
|
.trim(" ")
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED