@local-civics/mgmt-ui 0.1.218 → 0.1.220

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.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,45 @@ 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
- if (props.imageURL) {
332
- return /* @__PURE__ */ React.createElement("img", { src: props.imageURL, alt: props.alt || "", className: `${s.box} shrink-0 ${s.rounded} object-cover` });
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 timer = setTimeout(() => setFailed(true), LOAD_TIMEOUT_MS);
342
+ const onLoad = () => {
343
+ setFailed(false);
344
+ clearTimeout(timer);
345
+ };
346
+ el == null ? void 0 : el.addEventListener("iconload", onLoad);
347
+ return () => {
348
+ el == null ? void 0 : el.removeEventListener("iconload", onLoad);
349
+ clearTimeout(timer);
350
+ };
351
+ }, [props.imageURL]);
352
+ if (props.imageURL && !failed) {
353
+ return /* @__PURE__ */ React.createElement(
354
+ "svg",
355
+ {
356
+ ref,
357
+ "data-cache": "disabled",
358
+ "data-src": props.imageURL,
359
+ className: `${s.box} shrink-0 ${s.rounded} object-cover`,
360
+ viewBox: "0 0 32 32",
361
+ width: "32",
362
+ height: "32",
363
+ fill: "none",
364
+ xmlns: "http://www.w3.org/2000/svg"
365
+ }
366
+ );
333
367
  }
334
368
  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
369
  }