@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.js +36 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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,45 @@ 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
|
-
|
|
352
|
-
|
|
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 timer = setTimeout(() => setFailed(true), LOAD_TIMEOUT_MS);
|
|
362
|
+
const onLoad = () => {
|
|
363
|
+
setFailed(false);
|
|
364
|
+
clearTimeout(timer);
|
|
365
|
+
};
|
|
366
|
+
el == null ? void 0 : el.addEventListener("iconload", onLoad);
|
|
367
|
+
return () => {
|
|
368
|
+
el == null ? void 0 : el.removeEventListener("iconload", onLoad);
|
|
369
|
+
clearTimeout(timer);
|
|
370
|
+
};
|
|
371
|
+
}, [props.imageURL]);
|
|
372
|
+
if (props.imageURL && !failed) {
|
|
373
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
374
|
+
"svg",
|
|
375
|
+
{
|
|
376
|
+
ref,
|
|
377
|
+
"data-cache": "disabled",
|
|
378
|
+
"data-src": props.imageURL,
|
|
379
|
+
className: `${s.box} shrink-0 ${s.rounded} object-cover`,
|
|
380
|
+
viewBox: "0 0 32 32",
|
|
381
|
+
width: "32",
|
|
382
|
+
height: "32",
|
|
383
|
+
fill: "none",
|
|
384
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
385
|
+
}
|
|
386
|
+
);
|
|
353
387
|
}
|
|
354
388
|
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
389
|
}
|