@edifice.io/react 2.6.6 → 2.6.7

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/homepage.js CHANGED
@@ -1,13 +1,17 @@
1
- import { default as default2 } from "./modules/homepage/components/Header/Header.js";
2
- import { default as default3 } from "./modules/homepage/components/HomeCard/HomeCard.js";
3
- import { default as default4 } from "./modules/homepage/components/LastInfos/LastInfos.js";
4
- import { default as default5 } from "./modules/homepage/components/MessageFlashList/MessageFlash.js";
5
- import { default as default6 } from "./modules/homepage/components/MessageFlashList/MessageFlashList.js";
6
- import { default as default7 } from "./modules/homepage/components/Notifications/NotificationItem.js";
7
- import { default as default8 } from "./modules/homepage/components/Notifications/NotificationList.js";
1
+ import { default as default2 } from "./modules/homepage/components/Communities/Communities.js";
2
+ import { default as default3 } from "./modules/homepage/components/Communities/CommunityItem.js";
3
+ import { default as default4 } from "./modules/homepage/components/Communities/CommunitiesSkeleton.js";
4
+ import { default as default5 } from "./modules/homepage/components/Header/Header.js";
5
+ import { default as default6 } from "./modules/homepage/components/HomeCard/HomeCard.js";
6
+ import { default as default7 } from "./modules/homepage/components/LastInfos/LastInfos.js";
7
+ import { default as default8 } from "./modules/homepage/components/MessageFlashList/MessageFlash.js";
8
+ import { default as default9 } from "./modules/homepage/components/MessageFlashList/MessageFlashList.js";
9
+ import { default as default10 } from "./modules/homepage/components/Notifications/NotificationItem.js";
10
+ import { default as default11 } from "./modules/homepage/components/Notifications/NotificationList.js";
8
11
  import { NotificationListContainer } from "./modules/homepage/components/Notifications/NotificationListContainer.js";
9
- import { default as default9 } from "./modules/homepage/components/SchoolSpace/SchoolSpace.js";
10
- import { default as default10 } from "./modules/homepage/components/UserSpace/UserSpace.js";
12
+ import { default as default12 } from "./modules/homepage/components/SchoolSpace/SchoolSpace.js";
13
+ import { default as default13 } from "./modules/homepage/components/UserSpace/UserSpace.js";
14
+ import { CommunitiesContainer } from "./modules/homepage/components/Communities/CommunitiesContainer.js";
11
15
  import { Favorites } from "./modules/homepage/components/Favorites/Favorites.js";
12
16
  import { FavoritesContainer } from "./modules/homepage/components/Favorites/FavoritesContainer.js";
13
17
  import { LastInfosContainer } from "./modules/homepage/components/LastInfos/LastInfosContainer.js";
@@ -15,22 +19,28 @@ import { LastInfosList } from "./modules/homepage/components/LastInfos/LastInfos
15
19
  import { MessageFlashListContainer } from "./modules/homepage/components/MessageFlashList/MessageFlashListContainer.js";
16
20
  import { SchoolSpaceContainer } from "./modules/homepage/components/SchoolSpace/SchoolSpaceContainer.js";
17
21
  import { UserSpaceContainer } from "./modules/homepage/components/UserSpace/UserSpaceContainer.js";
22
+ import { useCommunities } from "./modules/homepage/components/Communities/useCommunities.js";
18
23
  export {
24
+ default2 as Communities,
25
+ CommunitiesContainer,
26
+ default3 as CommunitiesItem,
27
+ default4 as CommunitiesSkeleton,
19
28
  Favorites,
20
29
  FavoritesContainer,
21
- default2 as Header,
22
- default3 as HomeCard,
23
- default4 as LastInfos,
30
+ default5 as Header,
31
+ default6 as HomeCard,
32
+ default7 as LastInfos,
24
33
  LastInfosContainer,
25
34
  LastInfosList,
26
- default5 as MessageFlash,
27
- default6 as MessageFlashList,
35
+ default8 as MessageFlash,
36
+ default9 as MessageFlashList,
28
37
  MessageFlashListContainer,
29
- default7 as NotificationItem,
30
- default8 as NotificationList,
38
+ default10 as NotificationItem,
39
+ default11 as NotificationList,
31
40
  NotificationListContainer,
32
- default9 as SchoolSpace,
41
+ default12 as SchoolSpace,
33
42
  SchoolSpaceContainer,
34
- default10 as UserSpace,
35
- UserSpaceContainer
43
+ default13 as UserSpace,
44
+ UserSpaceContainer,
45
+ useCommunities
36
46
  };
@@ -0,0 +1,35 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import illuCommunities from "@edifice.io/bootstrap/dist/images/homepage/illu-communities.svg";
3
+ import { useMeasure } from "@uidotdev/usehooks";
4
+ import { useTranslation } from "react-i18next";
5
+ import SvgIconArrowRight from "../../../icons/components/IconArrowRight.js";
6
+ import CommunityItem from "./CommunityItem.js";
7
+ import HomeCard from "../HomeCard/HomeCard.js";
8
+ import Flex from "../../../../components/Flex/Flex.js";
9
+ import Image from "../../../../components/Image/Image.js";
10
+ const NARROW_CONTAINER_WIDTH = 800, MAX_ITEMS = 4, MAX_ITEMS_NARROW = 3, Communities = ({
11
+ communitiesList = [],
12
+ handleActionClick
13
+ }) => {
14
+ const {
15
+ t
16
+ } = useTranslation(), [containerRef, {
17
+ width
18
+ }] = useMeasure(), maxItems = width !== null && width < NARROW_CONTAINER_WIDTH ? MAX_ITEMS_NARROW : MAX_ITEMS, visibleCommunities = communitiesList.slice(0, maxItems), itemWidth = `${100 / maxItems}%`;
19
+ return /* @__PURE__ */ jsxs(HomeCard, { variant: "primary", children: [
20
+ /* @__PURE__ */ jsx(HomeCard.Header, { actionLabel: communitiesList.length > 0 ? t("homepage.communities.actionLabel.seeMore") : t("homepage.communities.actionLabel.create"), actionRightIcon: /* @__PURE__ */ jsx(SvgIconArrowRight, {}), onActionClick: handleActionClick, title: t("homepage.communities.title") }),
21
+ /* @__PURE__ */ jsx(HomeCard.Content, { children: /* @__PURE__ */ jsx(Flex, { ref: containerRef, gap: "16", children: visibleCommunities.length > 0 ? visibleCommunities.map((community, index) => /* @__PURE__ */ jsx(CommunityItem, { title: community.title, communityImage: community.communityImage, onActionClick: community.onActionClick, nbNotifications: community.nbNotifications, width: itemWidth }, index)) : /* @__PURE__ */ jsxs("div", { className: "communities-empty", children: [
22
+ /* @__PURE__ */ jsx(Image, { src: illuCommunities, alt: "", "aria-hidden": "true", style: {
23
+ width: 80,
24
+ height: 80
25
+ } }),
26
+ /* @__PURE__ */ jsxs("div", { className: "communities-empty-content", children: [
27
+ /* @__PURE__ */ jsx("p", { className: "communities-empty-title", children: t("homepage.communities.subtitle", "Créez votre première communauté pour animer votre classe !") }),
28
+ /* @__PURE__ */ jsx("p", { className: "communities-empty-description", children: t("homepage.communities.description", "Vous pouvez centraliser et organiser les documents et les ressources pour vos élèves.") })
29
+ ] })
30
+ ] }) }) })
31
+ ] });
32
+ };
33
+ export {
34
+ Communities as default
35
+ };
@@ -1,9 +1,11 @@
1
1
  import { CommunitiesModel } from './useCommunities';
2
2
  export type CommunitiesContainerProps = {
3
+ /** Handle a click on a community. If undefined, the community's home page will be opened. */
3
4
  onCommunityClick?: (community: CommunitiesModel) => void;
4
- onHeaderActionClick: () => void;
5
+ /** Handle a click on the header action button. If undefined, communities (or the community creation flow) will be opened. */
6
+ onHeaderActionClick?: () => void;
5
7
  };
6
- export declare function CommunitiesContainer({ onCommunityClick, onHeaderActionClick, }: CommunitiesContainerProps): import("react/jsx-runtime").JSX.Element | "An error occurred while loading communities.";
8
+ export declare function CommunitiesContainer({ onCommunityClick: handleCommunityClick, onHeaderActionClick: handleHeaderActionClick, }: CommunitiesContainerProps): import("react/jsx-runtime").JSX.Element | "An error occurred while loading communities.";
7
9
  export declare namespace CommunitiesContainer {
8
10
  var displayName: string;
9
11
  }
@@ -0,0 +1,31 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useCallback, useMemo } from "react";
3
+ import Communities from "./Communities.js";
4
+ import CommunitiesSkeleton from "./CommunitiesSkeleton.js";
5
+ import { useCommunities } from "./useCommunities.js";
6
+ function CommunitiesContainer({
7
+ onCommunityClick: handleCommunityClick = (community) => {
8
+ window.open(`/communities/id/${community.id}/home`, "_self");
9
+ },
10
+ onHeaderActionClick: handleHeaderActionClick
11
+ }) {
12
+ const {
13
+ communities,
14
+ isLoading,
15
+ error
16
+ } = useCommunities(), handleActionClick = useCallback(() => {
17
+ if (handleHeaderActionClick) {
18
+ handleHeaderActionClick();
19
+ return;
20
+ }
21
+ window.open(communities.length > 0 ? "/communities" : "/communities/create/step-type", "_self");
22
+ }, [handleHeaderActionClick, communities.length]), mappedCommunities = useMemo(() => communities.map((community) => ({
23
+ title: community.title,
24
+ communityImage: community.image ?? "",
25
+ onActionClick: () => handleCommunityClick(community)
26
+ })), [communities, handleCommunityClick]);
27
+ return isLoading ? /* @__PURE__ */ jsx(CommunitiesSkeleton, {}) : error ? "An error occurred while loading communities." : /* @__PURE__ */ jsx(Communities, { communitiesList: mappedCommunities, handleActionClick });
28
+ }
29
+ export {
30
+ CommunitiesContainer
31
+ };
@@ -0,0 +1,32 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import HomeCard from "../HomeCard/HomeCard.js";
3
+ import Flex from "../../../../components/Flex/Flex.js";
4
+ import TextSkeleton from "../../../../components/Skeleton/TextSkeleton.js";
5
+ import ButtonSkeleton from "../../../../components/Skeleton/ButtonSkeleton.js";
6
+ const primaryTitleWidths = ["80%", "64%", "88%", "72%"], secondaryTitleWidths = ["56%", "44%", "60%", "48%"], CommunitiesSkeleton = () => /* @__PURE__ */ jsxs(HomeCard, { variant: "primary", "data-testid": "communities-skeleton", children: [
7
+ /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", gap: "8", className: "home-card-header", children: [
8
+ /* @__PURE__ */ jsx(TextSkeleton, { size: "lg", className: "col-5" }),
9
+ /* @__PURE__ */ jsx(ButtonSkeleton, { "aria-hidden": "true", size: "sm", className: "px-24", color: "tertiary" })
10
+ ] }),
11
+ /* @__PURE__ */ jsx(HomeCard.Content, { children: /* @__PURE__ */ jsx(Flex, { gap: "16", children: primaryTitleWidths.map((primaryWidth, index) => /* @__PURE__ */ jsxs("div", { className: "communities-item", style: {
12
+ width: "25%"
13
+ }, "aria-hidden": "true", children: [
14
+ /* @__PURE__ */ jsx("div", { className: "communities-item-image placeholder rounded", style: {
15
+ display: "block",
16
+ aspectRatio: "1 / 1"
17
+ } }),
18
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "4", className: "mt-8", children: [
19
+ /* @__PURE__ */ jsx("div", { style: {
20
+ width: primaryWidth,
21
+ alignSelf: "center"
22
+ }, children: /* @__PURE__ */ jsx(TextSkeleton, { className: "col-12", size: "sm" }) }),
23
+ /* @__PURE__ */ jsx("div", { style: {
24
+ width: secondaryTitleWidths[index],
25
+ alignSelf: "center"
26
+ }, children: /* @__PURE__ */ jsx(TextSkeleton, { className: "col-12", size: "sm" }) })
27
+ ] })
28
+ ] }, primaryWidth)) }) })
29
+ ] });
30
+ export {
31
+ CommunitiesSkeleton as default
32
+ };
@@ -3,9 +3,10 @@ export interface CommunityItemProps {
3
3
  communityImage: string;
4
4
  onActionClick: () => void;
5
5
  nbNotifications?: number;
6
+ width?: string;
6
7
  }
7
8
  declare const CommunityItem: {
8
- ({ title, communityImage, nbNotifications, onActionClick, }: CommunityItemProps): import("react/jsx-runtime").JSX.Element;
9
+ ({ title, communityImage, nbNotifications, onActionClick, width, }: CommunityItemProps): import("react/jsx-runtime").JSX.Element;
9
10
  displayName: string;
10
11
  };
11
12
  export default CommunityItem;
@@ -0,0 +1,28 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import clsx from "clsx";
3
+ import Badge from "../../../../components/Badge/Badge.js";
4
+ import Image from "../../../../components/Image/Image.js";
5
+ const CommunityItem = ({
6
+ title,
7
+ communityImage,
8
+ nbNotifications,
9
+ onActionClick,
10
+ width = "25%"
11
+ }) => {
12
+ const hasNotifications = (nbNotifications ?? 0) > 0;
13
+ return /* @__PURE__ */ jsxs("div", { role: "button", tabIndex: 0, onClick: onActionClick, className: clsx("communities-item", {
14
+ "communities-item-has-notifications": hasNotifications
15
+ }), style: {
16
+ width
17
+ }, children: [
18
+ hasNotifications && /* @__PURE__ */ jsx(Badge, { className: "communities-item-badge", variant: {
19
+ level: "danger",
20
+ type: "notification"
21
+ }, children: nbNotifications }),
22
+ /* @__PURE__ */ jsx(Image, { className: "communities-item-image", src: communityImage, alt: title }),
23
+ /* @__PURE__ */ jsx("p", { className: "communities-item-title text-truncate text-truncate-2", children: title })
24
+ ] });
25
+ };
26
+ export {
27
+ CommunityItem as default
28
+ };
@@ -1,10 +1,7 @@
1
1
  export interface CommunitiesModel {
2
2
  id: number | string;
3
3
  title: string;
4
- communityImage?: string;
5
- icon?: string;
6
- nbNotifications?: number;
7
- notifications?: number;
4
+ image?: string;
8
5
  }
9
6
  export declare function useCommunities(): {
10
7
  communities: CommunitiesModel[];
@@ -0,0 +1,25 @@
1
+ import { odeServices } from "@edifice.io/client";
2
+ import { useQuery, queryOptions } from "@tanstack/react-query";
3
+ function useCommunities() {
4
+ const {
5
+ data,
6
+ isLoading,
7
+ error
8
+ } = useQuery(queryOptions({
9
+ queryKey: ["communities", "preview"],
10
+ queryFn: async () => {
11
+ const http = odeServices.http(), response = await http.get("/communities/api/communities?page=1&size=4");
12
+ if (http.isResponseError())
13
+ throw new Error(http.latestResponse.statusText);
14
+ return response.items;
15
+ }
16
+ }));
17
+ return {
18
+ communities: data ?? [],
19
+ isLoading,
20
+ error
21
+ };
22
+ }
23
+ export {
24
+ useCommunities
25
+ };
@@ -6,3 +6,4 @@ export * from './MessageFlashList';
6
6
  export * from './Notifications';
7
7
  export * from './SchoolSpace';
8
8
  export * from './UserSpace';
9
+ export * from './Communities';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.6.6",
3
+ "version": "2.6.7",
4
4
  "description": "Edifice React Library",
5
5
  "keywords": [
6
6
  "react",
@@ -140,9 +140,9 @@
140
140
  "swiper": "10.1.0",
141
141
  "ua-parser-js": "1.0.36",
142
142
  "zustand": "4.5.7",
143
- "@edifice.io/bootstrap": "2.6.6",
144
- "@edifice.io/tiptap-extensions": "2.6.6",
145
- "@edifice.io/utilities": "2.6.6"
143
+ "@edifice.io/bootstrap": "2.6.7",
144
+ "@edifice.io/tiptap-extensions": "2.6.7",
145
+ "@edifice.io/utilities": "2.6.7"
146
146
  },
147
147
  "devDependencies": {
148
148
  "@babel/plugin-transform-react-pure-annotations": "7.27.1",
@@ -173,8 +173,8 @@
173
173
  "vite": "5.4.14",
174
174
  "vite-plugin-dts": "4.5.4",
175
175
  "vite-tsconfig-paths": "5.1.4",
176
- "@edifice.io/config": "2.6.6",
177
- "@edifice.io/client": "2.6.6"
176
+ "@edifice.io/client": "2.6.7",
177
+ "@edifice.io/config": "2.6.7"
178
178
  },
179
179
  "peerDependencies": {
180
180
  "@react-spring/web": "9.7.5",