@digital-b2c/coreui-kit 0.9.0 → 0.10.0
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/LICENSE.txt +21 -21
- package/README.md +52 -52
- package/dist/index.cjs +245 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +49 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.mjs +245 -52
- package/dist/index.mjs.map +1 -1
- package/dist/types/global.d.ts +25 -25
- package/package.json +100 -99
package/dist/index.d.cts
CHANGED
|
@@ -601,16 +601,24 @@ declare const TextCenterCtaInBottom: (({ className, title, subtitle, ctas, child
|
|
|
601
601
|
|
|
602
602
|
type ResourceView = 'grid' | 'list';
|
|
603
603
|
type ResourceItemType = 'pdf' | 'link';
|
|
604
|
-
type FilterOption = 'all' | '
|
|
604
|
+
type FilterOption = 'all' | 'pdf' | 'link';
|
|
605
605
|
type SortOption = 'latest' | 'oldest' | 'az' | 'za';
|
|
606
606
|
interface ResourceItem {
|
|
607
607
|
title: string;
|
|
608
608
|
date: string;
|
|
609
|
-
|
|
609
|
+
image?: string;
|
|
610
|
+
type: ResourceItemType;
|
|
611
|
+
href: string;
|
|
610
612
|
hasNotification?: boolean;
|
|
613
|
+
category?: string;
|
|
611
614
|
}
|
|
612
615
|
interface SidebarCategory {
|
|
613
616
|
label: string;
|
|
617
|
+
/**
|
|
618
|
+
* Value matched against `ResourceItem.category` to filter items.
|
|
619
|
+
* Omit it (e.g. an "All Resources" entry) to show every item.
|
|
620
|
+
*/
|
|
621
|
+
value?: string;
|
|
614
622
|
active?: boolean;
|
|
615
623
|
hasNotification?: boolean;
|
|
616
624
|
}
|
|
@@ -649,4 +657,4 @@ type SlotMap = Record<string, SlotComponent>;
|
|
|
649
657
|
*/
|
|
650
658
|
declare function resolveCompoundSlots(children: ReactNode, slots: SlotMap): Record<string, ReactNode>;
|
|
651
659
|
|
|
652
|
-
export { Anchor, type AnchorProps, BrandsStrip, type BrandsStripProps, Button, type ButtonProps, Card, CardCollection, type CardCollectionProps, type CardProps, ConditionalWrapper, type ConditionalWrapperProps, ContactModule, type ContactModuleProps, Container, type ContainerProps, CountingCard, type CountingCardProps, EventList, type EventListProps, Footer, type FooterProps, HeroBanner, HeroBannerCarousel, type HeroBannerCarouselProps, type HeroBannerProps, type ICta, type ICtaHoverLogo, type ICtaIcon, type ICtaLogo, type IPicture, Icon, type IconType, InfoCard, type InfoCardProps, InternalBrandsTab, type InternalBrandsTabProps, LogoBar, type LogoBarProps, MiniBanner, type MiniBannerProps, MiniSectionCta, type MiniSectionCtaProps, Pagination, type PaginationProps, Picture, type PictureProps, PracticeCard, type PracticeCardProps, PracticePathCards, type PracticePathCardsProps, type ResourceItem, type
|
|
660
|
+
export { Anchor, type AnchorProps, BrandsStrip, type BrandsStripProps, Button, type ButtonProps, Card, CardCollection, type CardCollectionProps, type CardProps, ConditionalWrapper, type ConditionalWrapperProps, ContactModule, type ContactModuleProps, Container, type ContainerProps, CountingCard, type CountingCardProps, EventList, type EventListProps, Footer, type FooterProps, HeroBanner, HeroBannerCarousel, type HeroBannerCarouselProps, type HeroBannerProps, type ICta, type ICtaHoverLogo, type ICtaIcon, type ICtaLogo, type IPicture, Icon, type IconType, InfoCard, type InfoCardProps, InternalBrandsTab, type InternalBrandsTabProps, LogoBar, type LogoBarProps, MiniBanner, type MiniBannerProps, MiniSectionCta, type MiniSectionCtaProps, Pagination, type PaginationProps, Picture, type PictureProps, PracticeCard, type PracticeCardProps, PracticePathCards, type PracticePathCardsProps, type ResourceItem, type ResourceView, ResourcesGridList, type ResourcesGridListProps, type SidebarCategory, Teaser5050With3Text, type Teaser5050With3TextProps, Teaser5050WithCta, type Teaser5050WithCtaProps, TextBody, type TextBodyProps, TextCenterCtaInBottom, type TextCenterCtaInBottomProps, TextEvent, type TextEventProps, resolveCompoundSlots, svgs, useIntersectionObserver };
|
package/dist/index.d.ts
CHANGED
|
@@ -601,16 +601,24 @@ declare const TextCenterCtaInBottom: (({ className, title, subtitle, ctas, child
|
|
|
601
601
|
|
|
602
602
|
type ResourceView = 'grid' | 'list';
|
|
603
603
|
type ResourceItemType = 'pdf' | 'link';
|
|
604
|
-
type FilterOption = 'all' | '
|
|
604
|
+
type FilterOption = 'all' | 'pdf' | 'link';
|
|
605
605
|
type SortOption = 'latest' | 'oldest' | 'az' | 'za';
|
|
606
606
|
interface ResourceItem {
|
|
607
607
|
title: string;
|
|
608
608
|
date: string;
|
|
609
|
-
|
|
609
|
+
image?: string;
|
|
610
|
+
type: ResourceItemType;
|
|
611
|
+
href: string;
|
|
610
612
|
hasNotification?: boolean;
|
|
613
|
+
category?: string;
|
|
611
614
|
}
|
|
612
615
|
interface SidebarCategory {
|
|
613
616
|
label: string;
|
|
617
|
+
/**
|
|
618
|
+
* Value matched against `ResourceItem.category` to filter items.
|
|
619
|
+
* Omit it (e.g. an "All Resources" entry) to show every item.
|
|
620
|
+
*/
|
|
621
|
+
value?: string;
|
|
614
622
|
active?: boolean;
|
|
615
623
|
hasNotification?: boolean;
|
|
616
624
|
}
|
|
@@ -649,4 +657,4 @@ type SlotMap = Record<string, SlotComponent>;
|
|
|
649
657
|
*/
|
|
650
658
|
declare function resolveCompoundSlots(children: ReactNode, slots: SlotMap): Record<string, ReactNode>;
|
|
651
659
|
|
|
652
|
-
export { Anchor, type AnchorProps, BrandsStrip, type BrandsStripProps, Button, type ButtonProps, Card, CardCollection, type CardCollectionProps, type CardProps, ConditionalWrapper, type ConditionalWrapperProps, ContactModule, type ContactModuleProps, Container, type ContainerProps, CountingCard, type CountingCardProps, EventList, type EventListProps, Footer, type FooterProps, HeroBanner, HeroBannerCarousel, type HeroBannerCarouselProps, type HeroBannerProps, type ICta, type ICtaHoverLogo, type ICtaIcon, type ICtaLogo, type IPicture, Icon, type IconType, InfoCard, type InfoCardProps, InternalBrandsTab, type InternalBrandsTabProps, LogoBar, type LogoBarProps, MiniBanner, type MiniBannerProps, MiniSectionCta, type MiniSectionCtaProps, Pagination, type PaginationProps, Picture, type PictureProps, PracticeCard, type PracticeCardProps, PracticePathCards, type PracticePathCardsProps, type ResourceItem, type
|
|
660
|
+
export { Anchor, type AnchorProps, BrandsStrip, type BrandsStripProps, Button, type ButtonProps, Card, CardCollection, type CardCollectionProps, type CardProps, ConditionalWrapper, type ConditionalWrapperProps, ContactModule, type ContactModuleProps, Container, type ContainerProps, CountingCard, type CountingCardProps, EventList, type EventListProps, Footer, type FooterProps, HeroBanner, HeroBannerCarousel, type HeroBannerCarouselProps, type HeroBannerProps, type ICta, type ICtaHoverLogo, type ICtaIcon, type ICtaLogo, type IPicture, Icon, type IconType, InfoCard, type InfoCardProps, InternalBrandsTab, type InternalBrandsTabProps, LogoBar, type LogoBarProps, MiniBanner, type MiniBannerProps, MiniSectionCta, type MiniSectionCtaProps, Pagination, type PaginationProps, Picture, type PictureProps, PracticeCard, type PracticeCardProps, PracticePathCards, type PracticePathCardsProps, type ResourceItem, type ResourceView, ResourcesGridList, type ResourcesGridListProps, type SidebarCategory, Teaser5050With3Text, type Teaser5050With3TextProps, Teaser5050WithCta, type Teaser5050WithCtaProps, TextBody, type TextBodyProps, TextCenterCtaInBottom, type TextCenterCtaInBottomProps, TextEvent, type TextEventProps, resolveCompoundSlots, svgs, useIntersectionObserver };
|
package/dist/index.mjs
CHANGED
|
@@ -2564,7 +2564,9 @@ var ResourcesGridList_module_default = {
|
|
|
2564
2564
|
searchCollapse: "ResourcesGridList_module_searchCollapse",
|
|
2565
2565
|
searchIconInner: "ResourcesGridList_module_searchIconInner",
|
|
2566
2566
|
searchInput: "ResourcesGridList_module_searchInput",
|
|
2567
|
+
searchClear: "ResourcesGridList_module_searchClear",
|
|
2567
2568
|
dropdownPanel: "ResourcesGridList_module_dropdownPanel",
|
|
2569
|
+
searchPanel: "ResourcesGridList_module_searchPanel",
|
|
2568
2570
|
dropdownOption: "ResourcesGridList_module_dropdownOption",
|
|
2569
2571
|
selected: "ResourcesGridList_module_selected",
|
|
2570
2572
|
content: "ResourcesGridList_module_content",
|
|
@@ -2581,6 +2583,7 @@ var ResourcesGridList_module_default = {
|
|
|
2581
2583
|
cardsArea: "ResourcesGridList_module_cardsArea",
|
|
2582
2584
|
grid: "ResourcesGridList_module_grid",
|
|
2583
2585
|
list: "ResourcesGridList_module_list",
|
|
2586
|
+
cardLink: "ResourcesGridList_module_cardLink",
|
|
2584
2587
|
cardGrid: "ResourcesGridList_module_cardGrid",
|
|
2585
2588
|
cardBody: "ResourcesGridList_module_cardBody",
|
|
2586
2589
|
cardIconTitle: "ResourcesGridList_module_cardIconTitle",
|
|
@@ -2614,23 +2617,31 @@ function FilterBar({
|
|
|
2614
2617
|
filterValue,
|
|
2615
2618
|
onFilterChange,
|
|
2616
2619
|
sortValue,
|
|
2617
|
-
onSortChange
|
|
2620
|
+
onSortChange,
|
|
2621
|
+
searchValue,
|
|
2622
|
+
onSearchChange
|
|
2618
2623
|
}) {
|
|
2619
2624
|
const [openDropdown, setOpenDropdown] = useState(null);
|
|
2620
2625
|
const [searchState, setSearchState] = useState("closed");
|
|
2621
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
2622
2626
|
const filterRef = useRef(null);
|
|
2623
2627
|
const sortRef = useRef(null);
|
|
2628
|
+
const searchRef = useRef(null);
|
|
2624
2629
|
const searchInputRef = useRef(null);
|
|
2625
2630
|
const closeSearch = () => {
|
|
2626
2631
|
setSearchState("closing");
|
|
2627
|
-
|
|
2632
|
+
onSearchChange("");
|
|
2633
|
+
};
|
|
2634
|
+
const clearSearch = () => {
|
|
2635
|
+
var _a;
|
|
2636
|
+
onSearchChange("");
|
|
2637
|
+
(_a = searchInputRef.current) == null ? void 0 : _a.focus();
|
|
2628
2638
|
};
|
|
2629
2639
|
useEffect(() => {
|
|
2630
2640
|
const handleMouseDown = (e) => {
|
|
2631
|
-
var _a, _b;
|
|
2641
|
+
var _a, _b, _c;
|
|
2632
2642
|
const target = e.target;
|
|
2633
|
-
if (((_a = filterRef.current) == null ? void 0 : _a.contains(target)) || ((_b = sortRef.current) == null ? void 0 : _b.contains(target)))
|
|
2643
|
+
if (((_a = filterRef.current) == null ? void 0 : _a.contains(target)) || ((_b = sortRef.current) == null ? void 0 : _b.contains(target)) || ((_c = searchRef.current) == null ? void 0 : _c.contains(target)))
|
|
2644
|
+
return;
|
|
2634
2645
|
setOpenDropdown(null);
|
|
2635
2646
|
};
|
|
2636
2647
|
document.addEventListener("mousedown", handleMouseDown);
|
|
@@ -2640,6 +2651,10 @@ function FilterBar({
|
|
|
2640
2651
|
var _a;
|
|
2641
2652
|
if (searchState === "open") (_a = searchInputRef.current) == null ? void 0 : _a.focus();
|
|
2642
2653
|
}, [searchState]);
|
|
2654
|
+
useEffect(() => {
|
|
2655
|
+
var _a;
|
|
2656
|
+
if (openDropdown === "search") (_a = searchInputRef.current) == null ? void 0 : _a.focus();
|
|
2657
|
+
}, [openDropdown]);
|
|
2643
2658
|
return /* @__PURE__ */ jsxs("div", { className: ResourcesGridList_module_default.filterBar, children: [
|
|
2644
2659
|
/* @__PURE__ */ jsxs("div", { className: ResourcesGridList_module_default.viewToggle, children: [
|
|
2645
2660
|
/* @__PURE__ */ jsxs(
|
|
@@ -2739,17 +2754,21 @@ function FilterBar({
|
|
|
2739
2754
|
opt.value
|
|
2740
2755
|
)) })
|
|
2741
2756
|
] }),
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
{
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2757
|
+
isMobile ? (
|
|
2758
|
+
/* Mobile — popup panel, mirroring the Filter/Sort dropdowns */
|
|
2759
|
+
/* @__PURE__ */ jsxs("div", { className: ResourcesGridList_module_default.dropdownWrapper, ref: searchRef, children: [
|
|
2760
|
+
/* @__PURE__ */ jsx(
|
|
2761
|
+
"button",
|
|
2762
|
+
{
|
|
2763
|
+
type: "button",
|
|
2764
|
+
className: clsx23(ResourcesGridList_module_default.chip, searchValue !== "" && ResourcesGridList_module_default.active),
|
|
2765
|
+
onClick: () => setOpenDropdown(openDropdown === "search" ? null : "search"),
|
|
2766
|
+
"aria-expanded": openDropdown === "search",
|
|
2767
|
+
"aria-label": "Search",
|
|
2768
|
+
children: /* @__PURE__ */ jsx(Icon, { type: "search", size: 20, "aria-hidden": "true" })
|
|
2769
|
+
}
|
|
2748
2770
|
),
|
|
2749
|
-
|
|
2750
|
-
if (searchState === "closing") setSearchState("closed");
|
|
2751
|
-
},
|
|
2752
|
-
children: [
|
|
2771
|
+
openDropdown === "search" && /* @__PURE__ */ jsxs("div", { className: ResourcesGridList_module_default.searchPanel, children: [
|
|
2753
2772
|
/* @__PURE__ */ jsx("span", { className: ResourcesGridList_module_default.searchIconInner, children: /* @__PURE__ */ jsx(Icon, { type: "search", size: 20, "aria-hidden": "true" }) }),
|
|
2754
2773
|
/* @__PURE__ */ jsx(
|
|
2755
2774
|
"input",
|
|
@@ -2758,24 +2777,90 @@ function FilterBar({
|
|
|
2758
2777
|
type: "text",
|
|
2759
2778
|
className: ResourcesGridList_module_default.searchInput,
|
|
2760
2779
|
placeholder: "Search\u2026",
|
|
2761
|
-
value:
|
|
2762
|
-
onChange: (e) =>
|
|
2780
|
+
value: searchValue,
|
|
2781
|
+
onChange: (e) => onSearchChange(e.target.value),
|
|
2763
2782
|
onKeyDown: (e) => {
|
|
2764
|
-
if (e.key === "Escape")
|
|
2765
|
-
|
|
2766
|
-
|
|
2783
|
+
if (e.key === "Escape") {
|
|
2784
|
+
if (searchValue) clearSearch();
|
|
2785
|
+
else setOpenDropdown(null);
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
),
|
|
2790
|
+
searchValue && /* @__PURE__ */ jsx(
|
|
2791
|
+
"button",
|
|
2792
|
+
{
|
|
2793
|
+
type: "button",
|
|
2794
|
+
className: ResourcesGridList_module_default.searchClear,
|
|
2795
|
+
"aria-label": "Clear search",
|
|
2796
|
+
onClick: clearSearch,
|
|
2797
|
+
children: /* @__PURE__ */ jsx(Icon, { type: "xBlack", size: 16, "aria-hidden": "true" })
|
|
2767
2798
|
}
|
|
2768
2799
|
)
|
|
2769
|
-
]
|
|
2770
|
-
}
|
|
2800
|
+
] })
|
|
2801
|
+
] })
|
|
2802
|
+
) : searchState !== "closed" ? (
|
|
2803
|
+
/* Desktop — animated inline expand */
|
|
2804
|
+
/* @__PURE__ */ jsxs(
|
|
2805
|
+
"div",
|
|
2806
|
+
{
|
|
2807
|
+
className: clsx23(
|
|
2808
|
+
ResourcesGridList_module_default.searchExpanded,
|
|
2809
|
+
searchState === "closing" && ResourcesGridList_module_default.searchCollapsing
|
|
2810
|
+
),
|
|
2811
|
+
onAnimationEnd: () => {
|
|
2812
|
+
if (searchState === "closing") setSearchState("closed");
|
|
2813
|
+
},
|
|
2814
|
+
children: [
|
|
2815
|
+
/* @__PURE__ */ jsx("span", { className: ResourcesGridList_module_default.searchIconInner, children: /* @__PURE__ */ jsx(Icon, { type: "search", size: 20, "aria-hidden": "true" }) }),
|
|
2816
|
+
/* @__PURE__ */ jsx(
|
|
2817
|
+
"input",
|
|
2818
|
+
{
|
|
2819
|
+
ref: searchInputRef,
|
|
2820
|
+
type: "text",
|
|
2821
|
+
className: ResourcesGridList_module_default.searchInput,
|
|
2822
|
+
placeholder: "Search\u2026",
|
|
2823
|
+
value: searchValue,
|
|
2824
|
+
onChange: (e) => onSearchChange(e.target.value),
|
|
2825
|
+
onKeyDown: (e) => {
|
|
2826
|
+
if (e.key === "Escape") {
|
|
2827
|
+
if (searchValue) clearSearch();
|
|
2828
|
+
else closeSearch();
|
|
2829
|
+
}
|
|
2830
|
+
},
|
|
2831
|
+
onBlur: () => {
|
|
2832
|
+
if (!searchValue) closeSearch();
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
),
|
|
2836
|
+
searchValue && /* @__PURE__ */ jsx(
|
|
2837
|
+
"button",
|
|
2838
|
+
{
|
|
2839
|
+
type: "button",
|
|
2840
|
+
className: ResourcesGridList_module_default.searchClear,
|
|
2841
|
+
"aria-label": "Clear search",
|
|
2842
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
2843
|
+
onClick: clearSearch,
|
|
2844
|
+
children: /* @__PURE__ */ jsx(Icon, { type: "xBlack", size: 16, "aria-hidden": "true" })
|
|
2845
|
+
}
|
|
2846
|
+
)
|
|
2847
|
+
]
|
|
2848
|
+
}
|
|
2849
|
+
)
|
|
2771
2850
|
) : /* @__PURE__ */ jsxs("button", { type: "button", className: ResourcesGridList_module_default.chip, onClick: () => setSearchState("open"), children: [
|
|
2772
2851
|
/* @__PURE__ */ jsx(Icon, { type: "search", size: 20, "aria-hidden": "true" }),
|
|
2773
|
-
|
|
2852
|
+
/* @__PURE__ */ jsx("span", { className: ResourcesGridList_module_default.chipLabel, children: "Search" })
|
|
2774
2853
|
] })
|
|
2775
2854
|
] })
|
|
2776
2855
|
] });
|
|
2777
2856
|
}
|
|
2778
|
-
var Sidebar = ({
|
|
2857
|
+
var Sidebar = ({
|
|
2858
|
+
categories,
|
|
2859
|
+
isMobile,
|
|
2860
|
+
onToggle,
|
|
2861
|
+
selectedIndex,
|
|
2862
|
+
onSelect
|
|
2863
|
+
}) => {
|
|
2779
2864
|
if (isMobile) {
|
|
2780
2865
|
return /* @__PURE__ */ jsx("div", { className: ResourcesGridList_module_default.sidebarMobile, children: /* @__PURE__ */ jsx(
|
|
2781
2866
|
"button",
|
|
@@ -2793,7 +2878,17 @@ var Sidebar = ({ categories, isMobile, onToggle }) => {
|
|
|
2793
2878
|
return /* @__PURE__ */ jsxs(
|
|
2794
2879
|
"li",
|
|
2795
2880
|
{
|
|
2796
|
-
className: clsx23(ResourcesGridList_module_default.sidebarItem,
|
|
2881
|
+
className: clsx23(ResourcesGridList_module_default.sidebarItem, i === selectedIndex && ResourcesGridList_module_default.active),
|
|
2882
|
+
role: "button",
|
|
2883
|
+
tabIndex: 0,
|
|
2884
|
+
"aria-pressed": i === selectedIndex,
|
|
2885
|
+
onClick: () => onSelect(i),
|
|
2886
|
+
onKeyDown: (e) => {
|
|
2887
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
2888
|
+
e.preventDefault();
|
|
2889
|
+
onSelect(i);
|
|
2890
|
+
}
|
|
2891
|
+
},
|
|
2797
2892
|
children: [
|
|
2798
2893
|
/* @__PURE__ */ jsx("span", { children: cat.label }),
|
|
2799
2894
|
cat.hasNotification && /* @__PURE__ */ jsx("span", { className: ResourcesGridList_module_default.notificationDot, "aria-label": "New" })
|
|
@@ -2803,14 +2898,19 @@ var Sidebar = ({ categories, isMobile, onToggle }) => {
|
|
|
2803
2898
|
);
|
|
2804
2899
|
}) }) });
|
|
2805
2900
|
};
|
|
2806
|
-
var ResourceIcon = ({ type }) =>
|
|
2901
|
+
var ResourceIcon = ({ image, type }) => {
|
|
2902
|
+
if (!image) return null;
|
|
2903
|
+
return /* @__PURE__ */ jsx("div", { className: ResourcesGridList_module_default.iconWrapper, children: /* @__PURE__ */ jsx("img", { src: image, alt: type != null ? type : "", width: 32, height: 32 }) });
|
|
2904
|
+
};
|
|
2807
2905
|
var ResourceCardItem = ({ item, view }) => {
|
|
2906
|
+
const hasHref = Boolean(item.href);
|
|
2907
|
+
const linkWrapper = ({ children }) => /* @__PURE__ */ jsx("a", { href: item.href, className: ResourcesGridList_module_default.cardLink, target: "_blank", rel: "noopener noreferrer", children });
|
|
2808
2908
|
if (view === "grid") {
|
|
2809
2909
|
return /* @__PURE__ */ jsx("article", { className: ResourcesGridList_module_default.cardGrid, children: /* @__PURE__ */ jsxs("div", { className: ResourcesGridList_module_default.cardBody, children: [
|
|
2810
|
-
/* @__PURE__ */ jsxs("div", { className: ResourcesGridList_module_default.cardIconTitle, children: [
|
|
2811
|
-
/* @__PURE__ */ jsx(ResourceIcon, { type: item.type }),
|
|
2910
|
+
/* @__PURE__ */ jsx(ConditionalWrapper, { condition: hasHref, wrapper: linkWrapper, children: /* @__PURE__ */ jsxs("div", { className: ResourcesGridList_module_default.cardIconTitle, children: [
|
|
2911
|
+
/* @__PURE__ */ jsx(ResourceIcon, { image: item.image, type: item.type }),
|
|
2812
2912
|
/* @__PURE__ */ jsx("span", { className: ResourcesGridList_module_default.cardTitle, children: item.title })
|
|
2813
|
-
] }),
|
|
2913
|
+
] }) }),
|
|
2814
2914
|
/* @__PURE__ */ jsxs("div", { className: ResourcesGridList_module_default.cardMeta, children: [
|
|
2815
2915
|
/* @__PURE__ */ jsx("span", { className: ResourcesGridList_module_default.cardDate, children: item.date }),
|
|
2816
2916
|
item.hasNotification && /* @__PURE__ */ jsx("span", { className: ResourcesGridList_module_default.notificationDot, "aria-label": "New" })
|
|
@@ -2819,22 +2919,59 @@ var ResourceCardItem = ({ item, view }) => {
|
|
|
2819
2919
|
}
|
|
2820
2920
|
return /* @__PURE__ */ jsxs("article", { className: ResourcesGridList_module_default.cardList, children: [
|
|
2821
2921
|
/* @__PURE__ */ jsxs("div", { className: ResourcesGridList_module_default.cardListLeft, children: [
|
|
2822
|
-
/* @__PURE__ */ jsx("span", { className: ResourcesGridList_module_default.
|
|
2823
|
-
|
|
2922
|
+
item.hasNotification && /* @__PURE__ */ jsx("span", { className: ResourcesGridList_module_default.notificationDot, "aria-label": "New" }),
|
|
2923
|
+
/* @__PURE__ */ jsx("span", { className: ResourcesGridList_module_default.cardDate, children: item.date })
|
|
2824
2924
|
] }),
|
|
2825
|
-
/* @__PURE__ */ jsxs("div", { className: ResourcesGridList_module_default.cardListRight, children: [
|
|
2826
|
-
/* @__PURE__ */ jsx(ResourceIcon, { type: item.type }),
|
|
2925
|
+
/* @__PURE__ */ jsx(ConditionalWrapper, { condition: hasHref, wrapper: linkWrapper, children: /* @__PURE__ */ jsxs("div", { className: ResourcesGridList_module_default.cardListRight, children: [
|
|
2926
|
+
/* @__PURE__ */ jsx(ResourceIcon, { image: item.image, type: item.type }),
|
|
2827
2927
|
/* @__PURE__ */ jsx("span", { className: ResourcesGridList_module_default.cardTitle, children: item.title })
|
|
2828
|
-
] })
|
|
2928
|
+
] }) })
|
|
2829
2929
|
] });
|
|
2830
2930
|
};
|
|
2831
|
-
var Pagination3 = (
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
/* @__PURE__ */
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2931
|
+
var Pagination3 = ({ currentPage, totalPages, onPageChange }) => {
|
|
2932
|
+
const isFirst = currentPage <= 1;
|
|
2933
|
+
const isLast = currentPage >= totalPages;
|
|
2934
|
+
return /* @__PURE__ */ jsxs("div", { className: ResourcesGridList_module_default.pagination, "aria-label": "Pagination", children: [
|
|
2935
|
+
/* @__PURE__ */ jsx(
|
|
2936
|
+
"button",
|
|
2937
|
+
{
|
|
2938
|
+
type: "button",
|
|
2939
|
+
className: ResourcesGridList_module_default.pageArrow,
|
|
2940
|
+
"aria-label": "Previous page",
|
|
2941
|
+
disabled: isFirst,
|
|
2942
|
+
onClick: () => onPageChange(currentPage - 1),
|
|
2943
|
+
children: /* @__PURE__ */ jsx(Icon, { type: "chevronLeftBlack", size: 32, "aria-hidden": "true" })
|
|
2944
|
+
}
|
|
2945
|
+
),
|
|
2946
|
+
Array.from({ length: totalPages }, (_, i) => {
|
|
2947
|
+
const page = i + 1;
|
|
2948
|
+
const isActive = page === currentPage;
|
|
2949
|
+
return /* @__PURE__ */ jsx(
|
|
2950
|
+
"button",
|
|
2951
|
+
{
|
|
2952
|
+
type: "button",
|
|
2953
|
+
className: clsx23(isActive ? ResourcesGridList_module_default.pageDotActive : ResourcesGridList_module_default.pageDot),
|
|
2954
|
+
"aria-label": `Page ${page}`,
|
|
2955
|
+
"aria-current": isActive ? "page" : void 0,
|
|
2956
|
+
onClick: () => onPageChange(page)
|
|
2957
|
+
},
|
|
2958
|
+
page
|
|
2959
|
+
);
|
|
2960
|
+
}),
|
|
2961
|
+
/* @__PURE__ */ jsx(
|
|
2962
|
+
"button",
|
|
2963
|
+
{
|
|
2964
|
+
type: "button",
|
|
2965
|
+
className: ResourcesGridList_module_default.pageArrow,
|
|
2966
|
+
"aria-label": "Next page",
|
|
2967
|
+
disabled: isLast,
|
|
2968
|
+
onClick: () => onPageChange(currentPage + 1),
|
|
2969
|
+
children: /* @__PURE__ */ jsx(Icon, { type: "chevronRightBlack", size: 32, "aria-hidden": "true" })
|
|
2970
|
+
}
|
|
2971
|
+
)
|
|
2972
|
+
] });
|
|
2973
|
+
};
|
|
2974
|
+
var ITEMS_PER_PAGE = 12;
|
|
2838
2975
|
var ResourcesGridList = ({
|
|
2839
2976
|
className,
|
|
2840
2977
|
items = [],
|
|
@@ -2843,19 +2980,51 @@ var ResourcesGridList = ({
|
|
|
2843
2980
|
defaultFilter = "all",
|
|
2844
2981
|
defaultSort = "latest"
|
|
2845
2982
|
}) => {
|
|
2983
|
+
var _a;
|
|
2846
2984
|
const [view, setView] = useState(defaultView);
|
|
2847
2985
|
const [isSidebarOpen, setIsSidebarOpen] = useState(false);
|
|
2848
2986
|
const [filterValue, setFilterValue] = useState(defaultFilter);
|
|
2849
2987
|
const [sortValue, setSortValue] = useState(defaultSort);
|
|
2988
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
2989
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
2990
|
+
const [selectedCategory, setSelectedCategory] = useState(() => {
|
|
2991
|
+
const activeIndex = categories.findIndex((cat) => cat.active);
|
|
2992
|
+
return activeIndex === -1 ? 0 : activeIndex;
|
|
2993
|
+
});
|
|
2850
2994
|
const { is } = useViewPort_default();
|
|
2851
2995
|
const isMobile = is("tablet", "below");
|
|
2852
|
-
const
|
|
2996
|
+
const selectedValue = (_a = categories[selectedCategory]) == null ? void 0 : _a.value;
|
|
2997
|
+
const handleSelectCategory = (index) => {
|
|
2998
|
+
setSelectedCategory(index);
|
|
2999
|
+
setCurrentPage(1);
|
|
3000
|
+
if (isMobile) setIsSidebarOpen(false);
|
|
3001
|
+
};
|
|
3002
|
+
const handleFilterChange = (value) => {
|
|
3003
|
+
setFilterValue(value);
|
|
3004
|
+
setCurrentPage(1);
|
|
3005
|
+
};
|
|
3006
|
+
const handleSortChange = (value) => {
|
|
3007
|
+
setSortValue(value);
|
|
3008
|
+
setCurrentPage(1);
|
|
3009
|
+
};
|
|
3010
|
+
const handleSearchChange = (value) => {
|
|
3011
|
+
setSearchQuery(value);
|
|
3012
|
+
setCurrentPage(1);
|
|
3013
|
+
};
|
|
3014
|
+
const displayedItems = [...items].filter((item) => filterValue === "all" || item.type === filterValue).filter((item) => selectedValue == null || item.category === selectedValue).filter((item) => {
|
|
3015
|
+
const q = searchQuery.trim().toLowerCase();
|
|
3016
|
+
return q === "" || item.title.toLowerCase().includes(q);
|
|
3017
|
+
}).sort((a, b) => {
|
|
2853
3018
|
if (sortValue === "latest") return new Date(b.date).getTime() - new Date(a.date).getTime();
|
|
2854
3019
|
if (sortValue === "oldest") return new Date(a.date).getTime() - new Date(b.date).getTime();
|
|
2855
3020
|
if (sortValue === "az") return a.title.localeCompare(b.title);
|
|
2856
3021
|
if (sortValue === "za") return b.title.localeCompare(a.title);
|
|
2857
3022
|
return 0;
|
|
2858
3023
|
});
|
|
3024
|
+
const totalPages = Math.max(1, Math.ceil(displayedItems.length / ITEMS_PER_PAGE));
|
|
3025
|
+
const safeCurrentPage = Math.min(currentPage, totalPages);
|
|
3026
|
+
const pageStart = (safeCurrentPage - 1) * ITEMS_PER_PAGE;
|
|
3027
|
+
const paginatedItems = displayedItems.slice(pageStart, pageStart + ITEMS_PER_PAGE);
|
|
2859
3028
|
return /* @__PURE__ */ jsxs("div", { className: clsx23(ResourcesGridList_module_default.widget, className), children: [
|
|
2860
3029
|
/* @__PURE__ */ jsx(
|
|
2861
3030
|
FilterBar,
|
|
@@ -2864,9 +3033,11 @@ var ResourcesGridList = ({
|
|
|
2864
3033
|
onViewChange: setView,
|
|
2865
3034
|
isMobile,
|
|
2866
3035
|
filterValue,
|
|
2867
|
-
onFilterChange:
|
|
3036
|
+
onFilterChange: handleFilterChange,
|
|
2868
3037
|
sortValue,
|
|
2869
|
-
onSortChange:
|
|
3038
|
+
onSortChange: handleSortChange,
|
|
3039
|
+
searchValue: searchQuery,
|
|
3040
|
+
onSearchChange: handleSearchChange
|
|
2870
3041
|
}
|
|
2871
3042
|
),
|
|
2872
3043
|
/* @__PURE__ */ jsxs("div", { className: ResourcesGridList_module_default.content, children: [
|
|
@@ -2880,17 +3051,30 @@ var ResourcesGridList = ({
|
|
|
2880
3051
|
"aria-hidden": !isSidebarOpen,
|
|
2881
3052
|
children: [
|
|
2882
3053
|
/* @__PURE__ */ jsx("nav", { className: ResourcesGridList_module_default.mobileCategoriesPanel, "aria-label": "Resource categories", children: /* @__PURE__ */ jsx("ul", { className: ResourcesGridList_module_default.mobileCategoriesList, children: categories.map((cat, i) => {
|
|
2883
|
-
var
|
|
3054
|
+
var _a2;
|
|
2884
3055
|
return /* @__PURE__ */ jsxs(
|
|
2885
3056
|
"li",
|
|
2886
3057
|
{
|
|
2887
|
-
className: clsx23(
|
|
3058
|
+
className: clsx23(
|
|
3059
|
+
ResourcesGridList_module_default.mobileSidebarItem,
|
|
3060
|
+
i === selectedCategory && ResourcesGridList_module_default.active
|
|
3061
|
+
),
|
|
3062
|
+
role: "button",
|
|
3063
|
+
tabIndex: 0,
|
|
3064
|
+
"aria-pressed": i === selectedCategory,
|
|
3065
|
+
onClick: () => handleSelectCategory(i),
|
|
3066
|
+
onKeyDown: (e) => {
|
|
3067
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
3068
|
+
e.preventDefault();
|
|
3069
|
+
handleSelectCategory(i);
|
|
3070
|
+
}
|
|
3071
|
+
},
|
|
2888
3072
|
children: [
|
|
2889
3073
|
/* @__PURE__ */ jsx("span", { children: cat.label }),
|
|
2890
3074
|
cat.hasNotification && /* @__PURE__ */ jsx("span", { className: ResourcesGridList_module_default.notificationDot, "aria-label": "New" })
|
|
2891
3075
|
]
|
|
2892
3076
|
},
|
|
2893
|
-
(
|
|
3077
|
+
(_a2 = cat.label) != null ? _a2 : i
|
|
2894
3078
|
);
|
|
2895
3079
|
}) }) }),
|
|
2896
3080
|
/* @__PURE__ */ jsx("div", { className: ResourcesGridList_module_default.mobileSidebarCloseColumn, children: /* @__PURE__ */ jsx(
|
|
@@ -2911,15 +3095,24 @@ var ResourcesGridList = ({
|
|
|
2911
3095
|
{
|
|
2912
3096
|
categories,
|
|
2913
3097
|
isMobile,
|
|
2914
|
-
onToggle: () => setIsSidebarOpen(true)
|
|
3098
|
+
onToggle: () => setIsSidebarOpen(true),
|
|
3099
|
+
selectedIndex: selectedCategory,
|
|
3100
|
+
onSelect: handleSelectCategory
|
|
2915
3101
|
}
|
|
2916
3102
|
),
|
|
2917
|
-
/* @__PURE__ */ jsx("div", { className: clsx23(ResourcesGridList_module_default.cardsArea, ResourcesGridList_module_default[view]), children:
|
|
2918
|
-
var
|
|
2919
|
-
return /* @__PURE__ */ jsx(ResourceCardItem, { item, view }, (
|
|
3103
|
+
/* @__PURE__ */ jsx("div", { className: clsx23(ResourcesGridList_module_default.cardsArea, ResourcesGridList_module_default[view]), children: paginatedItems.map((item, i) => {
|
|
3104
|
+
var _a2;
|
|
3105
|
+
return /* @__PURE__ */ jsx(ResourceCardItem, { item, view }, (_a2 = item.title) != null ? _a2 : i);
|
|
2920
3106
|
}) })
|
|
2921
3107
|
] }),
|
|
2922
|
-
/* @__PURE__ */ jsx(
|
|
3108
|
+
totalPages > 1 && /* @__PURE__ */ jsx(
|
|
3109
|
+
Pagination3,
|
|
3110
|
+
{
|
|
3111
|
+
currentPage: safeCurrentPage,
|
|
3112
|
+
totalPages,
|
|
3113
|
+
onPageChange: setCurrentPage
|
|
3114
|
+
}
|
|
3115
|
+
)
|
|
2923
3116
|
] });
|
|
2924
3117
|
};
|
|
2925
3118
|
function useIntersectionObserver({
|