@local-civics/mgmt-ui 0.1.217 → 0.1.219
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/index.js +33 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { Avatar, createStyles, Modal, Center, Loader, Container, Group, Button,
|
|
|
5
5
|
import { Link } from 'react-router-dom';
|
|
6
6
|
import { showNotification, NotificationsProvider } from '@mantine/notifications';
|
|
7
7
|
export { showNotification, updateNotification } from '@mantine/notifications';
|
|
8
|
+
import 'external-svg-loader';
|
|
8
9
|
import { Dropzone, MIME_TYPES } from '@mantine/dropzone';
|
|
9
10
|
import { useForm } from '@mantine/form';
|
|
10
11
|
import * as papa from 'papaparse';
|
|
@@ -324,12 +325,42 @@ const ACCENT = {
|
|
|
324
325
|
mint: { bg: "bg-mint-400/15", text: "text-mint-400" },
|
|
325
326
|
gold: { bg: "bg-gold-400/15", text: "text-gold-400" }
|
|
326
327
|
};
|
|
328
|
+
const LOAD_TIMEOUT_MS = 3e3;
|
|
327
329
|
function Emblem(props) {
|
|
328
330
|
const s = SIZE[props.size || "sm"];
|
|
329
331
|
const a = ACCENT[props.accent];
|
|
330
332
|
const Icon = props.icon;
|
|
331
|
-
|
|
332
|
-
|
|
333
|
+
const [failed, setFailed] = React.useState(false);
|
|
334
|
+
const ref = React.useRef(null);
|
|
335
|
+
React.useEffect(() => {
|
|
336
|
+
setFailed(false);
|
|
337
|
+
if (!props.imageURL) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const el = ref.current;
|
|
341
|
+
const onLoad = () => setFailed(false);
|
|
342
|
+
el == null ? void 0 : el.addEventListener("iconload", onLoad);
|
|
343
|
+
const timer = setTimeout(() => setFailed(true), LOAD_TIMEOUT_MS);
|
|
344
|
+
return () => {
|
|
345
|
+
el == null ? void 0 : el.removeEventListener("iconload", onLoad);
|
|
346
|
+
clearTimeout(timer);
|
|
347
|
+
};
|
|
348
|
+
}, [props.imageURL]);
|
|
349
|
+
if (props.imageURL && !failed) {
|
|
350
|
+
return /* @__PURE__ */ React.createElement(
|
|
351
|
+
"svg",
|
|
352
|
+
{
|
|
353
|
+
ref,
|
|
354
|
+
"data-cache": "disabled",
|
|
355
|
+
"data-src": props.imageURL,
|
|
356
|
+
className: `${s.box} shrink-0 ${s.rounded} object-cover`,
|
|
357
|
+
viewBox: "0 0 32 32",
|
|
358
|
+
width: "32",
|
|
359
|
+
height: "32",
|
|
360
|
+
fill: "none",
|
|
361
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
362
|
+
}
|
|
363
|
+
);
|
|
333
364
|
}
|
|
334
365
|
return /* @__PURE__ */ React.createElement("div", { className: `flex ${s.box} shrink-0 items-center justify-center ${s.rounded} ${a.bg}` }, /* @__PURE__ */ React.createElement(Icon, { size: s.icon, stroke: 1.75, className: a.text }));
|
|
335
366
|
}
|