@local-civics/hub-ui 0.1.174 → 0.1.176
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.d.ts +1 -0
- package/dist/index.js +35 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1035,6 +1035,7 @@ type PathwayCardProps = {
|
|
|
1035
1035
|
target?: number;
|
|
1036
1036
|
displayTags?: string[];
|
|
1037
1037
|
criteria?: PathwayCriteria;
|
|
1038
|
+
categoryNames?: Record<string, string>;
|
|
1038
1039
|
points?: Record<string, number>;
|
|
1039
1040
|
onClose?: () => void;
|
|
1040
1041
|
onSubmit?: () => void;
|
package/dist/index.js
CHANGED
|
@@ -5599,30 +5599,46 @@ const PathwayCard = (props) => {
|
|
|
5599
5599
|
const completedCount = badges.filter((b) => b.completedAt).length;
|
|
5600
5600
|
const target = props.target || badges.length;
|
|
5601
5601
|
const categoryTargets = (_a = props.criteria) != null ? _a : {};
|
|
5602
|
+
const categoryIds = Object.keys(categoryTargets);
|
|
5602
5603
|
const points = (_b = props.points) != null ? _b : {};
|
|
5603
|
-
const allCategories = Array.from(
|
|
5604
|
-
new Set(badges.flatMap((b) => b.categories || []))
|
|
5605
|
-
);
|
|
5606
5604
|
const [filters, setFilters] = React__namespace.useState(
|
|
5607
5605
|
() => {
|
|
5608
5606
|
const obj = {};
|
|
5609
|
-
|
|
5610
|
-
obj[
|
|
5607
|
+
categoryIds.forEach((id) => {
|
|
5608
|
+
obj[id] = {
|
|
5609
|
+
id,
|
|
5610
|
+
isActive: false
|
|
5611
|
+
};
|
|
5611
5612
|
});
|
|
5612
5613
|
return obj;
|
|
5613
5614
|
}
|
|
5614
5615
|
);
|
|
5615
|
-
|
|
5616
|
-
setFilters((prev) =>
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5616
|
+
React__namespace.useEffect(() => {
|
|
5617
|
+
setFilters((prev) => {
|
|
5618
|
+
const next = {};
|
|
5619
|
+
categoryIds.forEach((id) => {
|
|
5620
|
+
var _a2, _b2;
|
|
5621
|
+
next[id] = {
|
|
5622
|
+
id,
|
|
5623
|
+
isActive: (_b2 = (_a2 = prev[id]) == null ? void 0 : _a2.isActive) != null ? _b2 : false
|
|
5624
|
+
};
|
|
5625
|
+
});
|
|
5626
|
+
return next;
|
|
5627
|
+
});
|
|
5628
|
+
}, [categoryIds]);
|
|
5629
|
+
const toggleFilter = (id) => {
|
|
5630
|
+
setFilters((prev) => {
|
|
5631
|
+
return __spreadProps$1(__spreadValues$2({}, prev), {
|
|
5632
|
+
[id]: __spreadProps$1(__spreadValues$2({}, prev[id]), {
|
|
5633
|
+
isActive: !prev[id].isActive
|
|
5634
|
+
})
|
|
5635
|
+
});
|
|
5636
|
+
});
|
|
5621
5637
|
};
|
|
5622
5638
|
const activeFilters = Object.values(filters).filter((f) => f.isActive);
|
|
5623
5639
|
const filteredBadges = activeFilters.length === 0 ? badges : badges.filter(
|
|
5624
5640
|
(b) => activeFilters.some(
|
|
5625
|
-
(f) => (b.categories || []).includes(f.
|
|
5641
|
+
(f) => (b.categories || []).includes(f.id)
|
|
5626
5642
|
)
|
|
5627
5643
|
);
|
|
5628
5644
|
const filterClassName = "inline-block px-4 py-2 bg-gray-600 text-white rounded-full cursor-pointer text-sm";
|
|
@@ -5640,17 +5656,18 @@ const PathwayCard = (props) => {
|
|
|
5640
5656
|
points,
|
|
5641
5657
|
height: "sm"
|
|
5642
5658
|
}
|
|
5643
|
-
), /* @__PURE__ */ React__namespace.createElement("div", { className: "flex flex-wrap gap-2 mt-3" },
|
|
5644
|
-
var _a2;
|
|
5645
|
-
const isActive = (_a2 = filters[
|
|
5659
|
+
), /* @__PURE__ */ React__namespace.createElement("div", { className: "flex flex-wrap gap-2 mt-3" }, categoryIds.map((id) => {
|
|
5660
|
+
var _a2, _b2, _c2;
|
|
5661
|
+
const isActive = (_a2 = filters[id]) == null ? void 0 : _a2.isActive;
|
|
5662
|
+
const label = (_c2 = (_b2 = props.categoryNames) == null ? void 0 : _b2[id]) != null ? _c2 : id;
|
|
5646
5663
|
return /* @__PURE__ */ React__namespace.createElement(
|
|
5647
5664
|
"div",
|
|
5648
5665
|
{
|
|
5649
|
-
key:
|
|
5650
|
-
onClick: () => toggleFilter(
|
|
5666
|
+
key: id,
|
|
5667
|
+
onClick: () => toggleFilter(id),
|
|
5651
5668
|
className: isActive ? `${filterClassName} bg-gray-700` : "inline-block px-4 py-2 rounded-full hover:bg-gray-200 cursor-pointer text-sm"
|
|
5652
5669
|
},
|
|
5653
|
-
|
|
5670
|
+
label
|
|
5654
5671
|
);
|
|
5655
5672
|
})), /* @__PURE__ */ React__namespace.createElement("div", { className: "mt-2 grid grid-cols-1 gap-y-2 max-h-[18rem] overflow-y-auto" }, filteredBadges.map((b) => {
|
|
5656
5673
|
const buttonText = b.completedAt ? "Completed" : b.startedAt ? "Continue" : "Start";
|