@digital-b2c/coreui-kit 0.17.2 → 0.17.4
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.cjs +23 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +4 -2
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +1 -4
- package/dist/index.d.ts +1 -4
- package/dist/index.mjs +24 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2409,7 +2409,7 @@ var ContactModule = ({
|
|
|
2409
2409
|
className: ContactModule_module_default.cta,
|
|
2410
2410
|
href: cta.url,
|
|
2411
2411
|
isExternal: cta.isExternal,
|
|
2412
|
-
variant: key % 2 ===
|
|
2412
|
+
variant: ctas.length === 1 || key % 2 === 1 ? "primary" : "secondary",
|
|
2413
2413
|
children: cta.label
|
|
2414
2414
|
},
|
|
2415
2415
|
key
|
|
@@ -4581,6 +4581,16 @@ var ResourcesGridList_module_default = {
|
|
|
4581
4581
|
notificationDot: "ResourcesGridList_module_notificationDot"
|
|
4582
4582
|
};
|
|
4583
4583
|
var ITEMS_PER_PAGE = 12;
|
|
4584
|
+
var getCategorySlug = (cat) => {
|
|
4585
|
+
var _a;
|
|
4586
|
+
return (cat == null ? void 0 : cat.extension) || ((_a = cat == null ? void 0 : cat.label) == null ? void 0 : _a.replaceAll(" ", "-").toLocaleLowerCase());
|
|
4587
|
+
};
|
|
4588
|
+
var subscribeHash = (onStoreChange) => {
|
|
4589
|
+
window.addEventListener("hashchange", onStoreChange);
|
|
4590
|
+
return () => window.removeEventListener("hashchange", onStoreChange);
|
|
4591
|
+
};
|
|
4592
|
+
var getHashSnapshot = () => window.location.hash;
|
|
4593
|
+
var getServerHashSnapshot = () => "";
|
|
4584
4594
|
var ResourcesGridList = ({
|
|
4585
4595
|
className,
|
|
4586
4596
|
items = [],
|
|
@@ -4596,22 +4606,28 @@ var ResourcesGridList = ({
|
|
|
4596
4606
|
const [sortValue, setSortValue] = React71.useState(defaultSort);
|
|
4597
4607
|
const [searchQuery, setSearchQuery] = React71.useState("");
|
|
4598
4608
|
const [currentPage, setCurrentPage] = React71.useState(1);
|
|
4599
|
-
const [selectedCategory, setSelectedCategory] = React71.useState(() => {
|
|
4600
|
-
const activeIndex = categories.findIndex((cat) => cat.active);
|
|
4601
|
-
return activeIndex === -1 ? 0 : activeIndex;
|
|
4602
|
-
});
|
|
4603
4609
|
const widgetRef = React71.useRef(null);
|
|
4604
4610
|
const { is } = useViewPort_default();
|
|
4605
4611
|
const isMobile = is("tablet", "below");
|
|
4612
|
+
const currentHash = React71.useSyncExternalStore(subscribeHash, getHashSnapshot, getServerHashSnapshot);
|
|
4613
|
+
const selectedCategory = (() => {
|
|
4614
|
+
const hash = decodeURIComponent(currentHash.replace(/^#/, ""));
|
|
4615
|
+
if (hash) {
|
|
4616
|
+
const hashIndex = categories.findIndex((cat) => getCategorySlug(cat) === hash);
|
|
4617
|
+
if (hashIndex !== -1) return hashIndex;
|
|
4618
|
+
}
|
|
4619
|
+
const activeIndex = categories.findIndex((cat) => cat.active);
|
|
4620
|
+
return activeIndex === -1 ? 0 : activeIndex;
|
|
4621
|
+
})();
|
|
4606
4622
|
const selectedValue = (_a = categories[selectedCategory]) == null ? void 0 : _a.value;
|
|
4607
4623
|
const handleSelectCategory = (index) => {
|
|
4608
4624
|
var _a2, _b;
|
|
4609
|
-
setSelectedCategory(index);
|
|
4610
4625
|
setCurrentPage(1);
|
|
4611
4626
|
const categoryText = (_b = (_a2 = categories[index]) == null ? void 0 : _a2.label) == null ? void 0 : _b.replaceAll(" ", "-");
|
|
4627
|
+
const slug = getCategorySlug(categories[index]);
|
|
4612
4628
|
if (typeof window !== "undefined" && categoryText) {
|
|
4613
4629
|
const base_url = window.location.pathname.endsWith("/") ? window.location.pathname.slice(0, -1) : window.location.pathname;
|
|
4614
|
-
const url = categoryText !== "All-Resources" ? `${base_url}
|
|
4630
|
+
const url = categoryText !== "All-Resources" ? `${base_url}/#${slug}` : `${base_url}`;
|
|
4615
4631
|
window.history.replaceState(null, "", url);
|
|
4616
4632
|
window.dispatchEvent(new HashChangeEvent("hashchange"));
|
|
4617
4633
|
}
|