@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 CHANGED
@@ -5,6 +5,7 @@ var icons = require('@tabler/icons');
5
5
  var core = require('@mantine/core');
6
6
  var reactRouterDom = require('react-router-dom');
7
7
  var notifications = require('@mantine/notifications');
8
+ require('external-svg-loader');
8
9
  var dropzone = require('@mantine/dropzone');
9
10
  var form = require('@mantine/form');
10
11
  var papa = require('papaparse');
@@ -344,12 +345,42 @@ const ACCENT = {
344
345
  mint: { bg: "bg-mint-400/15", text: "text-mint-400" },
345
346
  gold: { bg: "bg-gold-400/15", text: "text-gold-400" }
346
347
  };
348
+ const LOAD_TIMEOUT_MS = 3e3;
347
349
  function Emblem(props) {
348
350
  const s = SIZE[props.size || "sm"];
349
351
  const a = ACCENT[props.accent];
350
352
  const Icon = props.icon;
351
- if (props.imageURL) {
352
- return /* @__PURE__ */ React__namespace.createElement("img", { src: props.imageURL, alt: props.alt || "", className: `${s.box} shrink-0 ${s.rounded} object-cover` });
353
+ const [failed, setFailed] = React__namespace.useState(false);
354
+ const ref = React__namespace.useRef(null);
355
+ React__namespace.useEffect(() => {
356
+ setFailed(false);
357
+ if (!props.imageURL) {
358
+ return;
359
+ }
360
+ const el = ref.current;
361
+ const onLoad = () => setFailed(false);
362
+ el == null ? void 0 : el.addEventListener("iconload", onLoad);
363
+ const timer = setTimeout(() => setFailed(true), LOAD_TIMEOUT_MS);
364
+ return () => {
365
+ el == null ? void 0 : el.removeEventListener("iconload", onLoad);
366
+ clearTimeout(timer);
367
+ };
368
+ }, [props.imageURL]);
369
+ if (props.imageURL && !failed) {
370
+ return /* @__PURE__ */ React__namespace.createElement(
371
+ "svg",
372
+ {
373
+ ref,
374
+ "data-cache": "disabled",
375
+ "data-src": props.imageURL,
376
+ className: `${s.box} shrink-0 ${s.rounded} object-cover`,
377
+ viewBox: "0 0 32 32",
378
+ width: "32",
379
+ height: "32",
380
+ fill: "none",
381
+ xmlns: "http://www.w3.org/2000/svg"
382
+ }
383
+ );
353
384
  }
354
385
  return /* @__PURE__ */ React__namespace.createElement("div", { className: `flex ${s.box} shrink-0 items-center justify-center ${s.rounded} ${a.bg}` }, /* @__PURE__ */ React__namespace.createElement(Icon, { size: s.icon, stroke: 1.75, className: a.text }));
355
386
  }