@local-civics/mgmt-ui 0.1.257 → 0.1.258
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 +37 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1224,6 +1224,41 @@ function Table$8(props) {
|
|
|
1224
1224
|
))));
|
|
1225
1225
|
}
|
|
1226
1226
|
|
|
1227
|
+
const isUrl = (value) => /^https?:\/\/\S+$/i.test(value.trim());
|
|
1228
|
+
const isUpload = (value) => /\/\/cdn\.localcivics\.io\/v1\/store\//i.test(value);
|
|
1229
|
+
const hostOf = (value) => {
|
|
1230
|
+
try {
|
|
1231
|
+
return new URL(value).hostname.replace(/^www\./, "");
|
|
1232
|
+
} catch (e) {
|
|
1233
|
+
return value;
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1236
|
+
function AnswerValue(props) {
|
|
1237
|
+
const values = (props.answer || []).filter((v) => typeof v === "string" && v.trim() !== "");
|
|
1238
|
+
const text = values.filter((v) => !isUrl(v));
|
|
1239
|
+
const links = values.filter(isUrl);
|
|
1240
|
+
if (values.length === 0) {
|
|
1241
|
+
return props.emptyText ? /* @__PURE__ */ React__namespace.createElement("div", { className: props.className }, props.emptyText) : null;
|
|
1242
|
+
}
|
|
1243
|
+
return /* @__PURE__ */ React__namespace.createElement("div", { className: `flex flex-col gap-2 ${props.className || ""}` }, text.length > 0 && /* @__PURE__ */ React__namespace.createElement("div", null, text.join(", ")), links.length > 0 && /* @__PURE__ */ React__namespace.createElement("div", { className: "flex flex-wrap gap-2" }, links.map((link) => {
|
|
1244
|
+
const upload = isUpload(link);
|
|
1245
|
+
return /* @__PURE__ */ React__namespace.createElement(
|
|
1246
|
+
"a",
|
|
1247
|
+
{
|
|
1248
|
+
key: link,
|
|
1249
|
+
href: link,
|
|
1250
|
+
download: upload || void 0,
|
|
1251
|
+
target: "_blank",
|
|
1252
|
+
rel: "noopener noreferrer",
|
|
1253
|
+
title: link,
|
|
1254
|
+
className: "flex w-fit items-center gap-1 rounded-md border border-slate-200 px-2.5 py-1.5 text-[11px] font-bold text-slate-600 no-underline hover:bg-slate-50"
|
|
1255
|
+
},
|
|
1256
|
+
upload ? /* @__PURE__ */ React__namespace.createElement(icons.IconDownload, { size: 12, stroke: 2 }) : /* @__PURE__ */ React__namespace.createElement(icons.IconExternalLink, { size: 12, stroke: 2 }),
|
|
1257
|
+
upload ? "Download" : `Open link (${hostOf(link)})`
|
|
1258
|
+
);
|
|
1259
|
+
})));
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1227
1262
|
function Table$7(props) {
|
|
1228
1263
|
const { items: sortedItems, requestSort, sortConfig } = useSortableData(props.items);
|
|
1229
1264
|
if (props.items.length === 0) {
|
|
@@ -1246,7 +1281,7 @@ function Table$7(props) {
|
|
|
1246
1281
|
className: `px-5 py-4 ${i < row.questions.length - 1 || row.reflection ? "border-b border-slate-100" : ""}`
|
|
1247
1282
|
},
|
|
1248
1283
|
/* @__PURE__ */ React__namespace.createElement("div", { className: "text-xs font-semibold text-slate-500" }, q.questionName),
|
|
1249
|
-
/* @__PURE__ */ React__namespace.createElement(
|
|
1284
|
+
/* @__PURE__ */ React__namespace.createElement(AnswerValue, { answer: q.answer, className: "mt-1 text-xs text-slate-600" })
|
|
1250
1285
|
)), row.reflection && /* @__PURE__ */ React__namespace.createElement("div", { className: "flex items-start justify-between gap-4 px-5 py-4" }, /* @__PURE__ */ React__namespace.createElement("div", { className: "min-w-0" }, /* @__PURE__ */ React__namespace.createElement("div", { className: "text-xs font-semibold text-slate-500" }, "Reflection"), /* @__PURE__ */ React__namespace.createElement("div", { className: "mt-1 text-xs text-slate-600" }, row.reflection)), !!row.rating && /* @__PURE__ */ React__namespace.createElement("div", { className: "shrink-0 rounded-full bg-gold-100 px-2.5 py-1 text-[10px] font-bold text-dark-blue-400" }, row.rating.toLocaleString()))));
|
|
1251
1286
|
})));
|
|
1252
1287
|
}
|
|
@@ -1495,7 +1530,7 @@ const SplitButton$3 = (props) => {
|
|
|
1495
1530
|
function Stack$3(props) {
|
|
1496
1531
|
const hasAnswers = props.items.length > 0;
|
|
1497
1532
|
const hasReflection = !!props.reflection;
|
|
1498
|
-
return /* @__PURE__ */ React__namespace.createElement(
|
|
1533
|
+
return /* @__PURE__ */ React__namespace.createElement("div", { className: "flex flex-col gap-4" }, hasAnswers ? props.items.map((row) => /* @__PURE__ */ React__namespace.createElement("div", { key: row.questionName }, /* @__PURE__ */ React__namespace.createElement("div", { className: "text-sm font-bold text-dark-blue-400" }, row.questionName), /* @__PURE__ */ React__namespace.createElement(AnswerValue, { answer: row.answer, emptyText: "No answer.", className: "mt-1 text-sm text-slate-600" }))) : !hasReflection ? /* @__PURE__ */ React__namespace.createElement("div", { className: "text-sm font-bold text-dark-blue-400" }, "No question responses recorded yet.") : null, hasReflection && /* @__PURE__ */ React__namespace.createElement("div", null, /* @__PURE__ */ React__namespace.createElement("div", { className: "flex items-center justify-between gap-3" }, /* @__PURE__ */ React__namespace.createElement("div", { className: "text-sm font-bold text-dark-blue-400" }, "Reflection"), !!props.rating && /* @__PURE__ */ React__namespace.createElement("div", { className: "shrink-0 rounded-full bg-gold-100 px-2.5 py-1 text-[10px] font-bold text-dark-blue-400" }, props.rating)), /* @__PURE__ */ React__namespace.createElement("div", { className: "mt-1 text-sm text-slate-600" }, props.reflection)), /* @__PURE__ */ React__namespace.createElement(reactRouterDom.Link, { to: props.href, state: props.state, className: "w-fit text-xs font-bold text-dark-blue-400 no-underline hover:underline" }, "View full response \u2192"));
|
|
1499
1534
|
}
|
|
1500
1535
|
|
|
1501
1536
|
var __defProp$d = Object.defineProperty;
|