@edifice.io/react 2.6.8 → 2.6.9-develop-orga.20261013105203

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
@@ -11,6 +11,7 @@ import { default as default11 } from "./modules/homepage/components/Notification
11
11
  import { NotificationListContainer } from "./modules/homepage/components/Notifications/NotificationListContainer.js";
12
12
  import { default as default12 } from "./modules/homepage/components/SchoolSpace/SchoolSpace.js";
13
13
  import { default as default13 } from "./modules/homepage/components/UserSpace/UserSpace.js";
14
+ import { COMMUNITIES_PREVIEW_SIZE, useCommunities } from "./modules/homepage/components/Communities/useCommunities.js";
14
15
  import { CommunitiesContainer } from "./modules/homepage/components/Communities/CommunitiesContainer.js";
15
16
  import { Favorites } from "./modules/homepage/components/Favorites/Favorites.js";
16
17
  import { FavoritesContainer } from "./modules/homepage/components/Favorites/FavoritesContainer.js";
@@ -24,8 +25,8 @@ import { UsefulLinks } from "./modules/homepage/components/UsefulLinks/UsefulLin
24
25
  import { UsefulLinksContainer } from "./modules/homepage/components/UsefulLinks/UsefulLinksContainer.js";
25
26
  import { UsefulLinksModal } from "./modules/homepage/components/UsefulLinks/UsefulLinksModal.js";
26
27
  import { UserSpaceContainer } from "./modules/homepage/components/UserSpace/UserSpaceContainer.js";
27
- import { useCommunities } from "./modules/homepage/components/Communities/useCommunities.js";
28
28
  export {
29
+ COMMUNITIES_PREVIEW_SIZE,
29
30
  default2 as Communities,
30
31
  CommunitiesContainer,
31
32
  default3 as CommunitiesItem,
@@ -30,9 +30,9 @@ const EditorToolbarTypography = ({
30
30
  label: t("tiptap.toolbar.typo.mono"),
31
31
  className: "ff-script"
32
32
  }, {
33
- value: "Ecriture A",
34
- label: t("tiptap.toolbar.typo.cursive"),
35
- className: "ff-cursive"
33
+ value: "Marelle",
34
+ label: t("tiptap.toolbar.typo.marelle"),
35
+ className: "ff-marelle"
36
36
  }, {
37
37
  value: "OpenDyslexic",
38
38
  label: t("tiptap.toolbar.typo.dyslexic"),
@@ -2,9 +2,10 @@ import { CommunityItemProps } from './CommunityItem';
2
2
  export interface CommunitiesProps {
3
3
  communitiesList?: CommunityItemProps[];
4
4
  handleActionClick: () => void;
5
+ canCreateCommunity?: boolean;
5
6
  }
6
7
  declare const Communities: {
7
- ({ communitiesList, handleActionClick, }: CommunitiesProps): import("react/jsx-runtime").JSX.Element;
8
+ ({ communitiesList, handleActionClick, canCreateCommunity, }: CommunitiesProps): import("react/jsx-runtime").JSX.Element;
8
9
  displayName: string;
9
10
  };
10
11
  export default Communities;
@@ -1,32 +1,33 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import illuCommunities from "@edifice.io/bootstrap/dist/images/homepage/illu-communities.svg";
3
- import { useMeasure } from "@uidotdev/usehooks";
4
3
  import { useTranslation } from "react-i18next";
5
4
  import SvgIconArrowRight from "../../../icons/components/IconArrowRight.js";
6
5
  import CommunityItem from "./CommunityItem.js";
7
6
  import HomeCard from "../HomeCard/HomeCard.js";
8
7
  import Flex from "../../../../components/Flex/Flex.js";
9
8
  import Image from "../../../../components/Image/Image.js";
10
- const NARROW_CONTAINER_WIDTH = 800, MAX_ITEMS = 4, MAX_ITEMS_NARROW = 3, Communities = ({
9
+ const Communities = ({
11
10
  communitiesList = [],
12
- handleActionClick
11
+ handleActionClick,
12
+ canCreateCommunity = !1
13
13
  }) => {
14
14
  const {
15
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}%`;
16
+ } = useTranslation();
19
17
  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: [
18
+ /* @__PURE__ */ jsx(HomeCard.Header, { actionLabel: communitiesList.length > 0 || !canCreateCommunity ? t("homepage.communities.actionLabel.seeMore", "Voir plus") : t("homepage.communities.actionLabel.create", "Créer une communauté"), actionRightIcon: /* @__PURE__ */ jsx(SvgIconArrowRight, {}), onActionClick: handleActionClick, title: t("homepage.communities.title", "Mes communautés") }),
19
+ /* @__PURE__ */ jsx(HomeCard.Content, { className: "communities-content", children: /* @__PURE__ */ jsx(Flex, { gap: "16", children: communitiesList.length > 0 ? /* @__PURE__ */ jsx("div", { className: "communities-list", children: communitiesList.map((community, index) => /* @__PURE__ */ jsx(CommunityItem, { title: community.title, communityImage: community.communityImage, onActionClick: community.onActionClick, nbNotifications: community.nbNotifications, width: "auto" }, index)) }) : /* @__PURE__ */ jsxs("div", { className: "communities-empty", children: [
22
20
  /* @__PURE__ */ jsx(Image, { src: illuCommunities, alt: "", "aria-hidden": "true", style: {
23
21
  width: 80,
24
22
  height: 80
25
23
  } }),
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
- ] })
24
+ /* @__PURE__ */ jsx("div", { className: "communities-empty-content", children: canCreateCommunity ? /* @__PURE__ */ jsxs(Fragment, { children: [
25
+ /* @__PURE__ */ jsx("p", { className: "communities-empty-title", children: t("homepage.communities.subtitle.teacher", "Réunissez vos élèves avec Communautés !") }),
26
+ /* @__PURE__ */ jsx("p", { className: "communities-empty-description", children: t("homepage.communities.description.teacher", "Centralisez et organisez les documents et les ressources pour vos groupes d'élèves.") })
27
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
28
+ /* @__PURE__ */ jsx("p", { className: "communities-empty-title", children: t("homepage.communities.subtitle.student", "Retrouvez toutes vos communautés ici ! ") }),
29
+ /* @__PURE__ */ jsx("p", { className: "communities-empty-description", children: t("homepage.communities.description.student", `Consultez l'onglet "Nouveaux partages" pour découvrir si vous avez été ajouté à une nouvelle communauté.`) })
30
+ ] }) })
30
31
  ] }) }) })
31
32
  ] });
32
33
  };
@@ -5,7 +5,7 @@ export type CommunitiesContainerProps = {
5
5
  /** Handle a click on the header action button. If undefined, communities (or the community creation flow) will be opened. */
6
6
  onHeaderActionClick?: () => void;
7
7
  };
8
- export declare function CommunitiesContainer({ onCommunityClick: handleCommunityClick, onHeaderActionClick: handleHeaderActionClick, }: 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." | null;
9
9
  export declare namespace CommunitiesContainer {
10
10
  var displayName: string;
11
11
  }
@@ -3,28 +3,32 @@ import { useCallback, useMemo } from "react";
3
3
  import Communities from "./Communities.js";
4
4
  import CommunitiesSkeleton from "./CommunitiesSkeleton.js";
5
5
  import { useCommunities } from "./useCommunities.js";
6
+ import useHasWorkflow from "../../../../hooks/useHasWorkflow/useHasWorkflow.js";
7
+ const COMMUNITY_ACCESS_WORKFLOW = "community.access", COMMUNITY_CREATE_WORKFLOW = "community.create", COMMUNITY_WORKFLOWS = [COMMUNITY_ACCESS_WORKFLOW, COMMUNITY_CREATE_WORKFLOW];
6
8
  function CommunitiesContainer({
7
9
  onCommunityClick: handleCommunityClick = (community) => {
8
10
  window.open(`/communities/id/${community.id}/home`, "_self");
9
11
  },
10
12
  onHeaderActionClick: handleHeaderActionClick
11
13
  }) {
12
- const {
14
+ const rights = useHasWorkflow(COMMUNITY_WORKFLOWS), canCreateCommunity = (rights == null ? void 0 : rights[COMMUNITY_CREATE_WORKFLOW]) === !0, hasCommunitiesRight = canCreateCommunity || (rights == null ? void 0 : rights[COMMUNITY_ACCESS_WORKFLOW]) === !0, {
13
15
  communities,
14
16
  isLoading,
15
17
  error
16
- } = useCommunities(), handleActionClick = useCallback(() => {
18
+ } = useCommunities({
19
+ enabled: hasCommunitiesRight
20
+ }), handleActionClick = useCallback(() => {
17
21
  if (handleHeaderActionClick) {
18
22
  handleHeaderActionClick();
19
23
  return;
20
24
  }
21
- window.open(communities.length > 0 ? "/communities" : "/communities/create/step-type", "_self");
22
- }, [handleHeaderActionClick, communities.length]), mappedCommunities = useMemo(() => communities.map((community) => ({
25
+ window.open(communities.length === 0 && canCreateCommunity ? "/communities/create/step-type" : "/communities", "_self");
26
+ }, [handleHeaderActionClick, communities.length, canCreateCommunity]), mappedCommunities = useMemo(() => communities.map((community) => ({
23
27
  title: community.title,
24
28
  communityImage: community.image ?? "",
25
29
  onActionClick: () => handleCommunityClick(community)
26
30
  })), [communities, handleCommunityClick]);
27
- return isLoading ? /* @__PURE__ */ jsx(CommunitiesSkeleton, {}) : error ? "An error occurred while loading communities." : /* @__PURE__ */ jsx(Communities, { communitiesList: mappedCommunities, handleActionClick });
31
+ return rights === void 0 || isLoading ? /* @__PURE__ */ jsx(CommunitiesSkeleton, {}) : hasCommunitiesRight ? error ? "An error occurred while loading communities." : /* @__PURE__ */ jsx(Communities, { communitiesList: mappedCommunities, handleActionClick, canCreateCommunity }) : null;
28
32
  }
29
33
  export {
30
34
  CommunitiesContainer
@@ -3,17 +3,14 @@ import HomeCard from "../HomeCard/HomeCard.js";
3
3
  import Flex from "../../../../components/Flex/Flex.js";
4
4
  import TextSkeleton from "../../../../components/Skeleton/TextSkeleton.js";
5
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: [
6
+ const primaryTitleWidths = ["80%", "64%", "88%", "72%", "76%", "68%"], secondaryTitleWidths = ["56%", "44%", "60%", "48%", "52%", "40%"], CommunitiesSkeleton = () => /* @__PURE__ */ jsxs(HomeCard, { variant: "primary", "data-testid": "communities-skeleton", children: [
7
7
  /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", gap: "8", className: "home-card-header", children: [
8
8
  /* @__PURE__ */ jsx(TextSkeleton, { size: "lg", className: "col-5" }),
9
9
  /* @__PURE__ */ jsx(ButtonSkeleton, { "aria-hidden": "true", size: "sm", className: "px-24", color: "tertiary" })
10
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: [
11
+ /* @__PURE__ */ jsx(HomeCard.Content, { className: "communities-content", children: /* @__PURE__ */ jsx(Flex, { gap: "16", children: /* @__PURE__ */ jsx("div", { className: "communities-list", children: primaryTitleWidths.map((primaryWidth, index) => /* @__PURE__ */ jsxs("div", { className: "communities-item", "aria-hidden": "true", children: [
14
12
  /* @__PURE__ */ jsx("div", { className: "communities-item-image placeholder rounded", style: {
15
- display: "block",
16
- aspectRatio: "1 / 1"
13
+ display: "block"
17
14
  } }),
18
15
  /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "4", className: "mt-8", children: [
19
16
  /* @__PURE__ */ jsx("div", { style: {
@@ -25,7 +22,7 @@ const primaryTitleWidths = ["80%", "64%", "88%", "72%"], secondaryTitleWidths =
25
22
  alignSelf: "center"
26
23
  }, children: /* @__PURE__ */ jsx(TextSkeleton, { className: "col-12", size: "sm" }) })
27
24
  ] })
28
- ] }, primaryWidth)) }) })
25
+ ] }, primaryWidth)) }) }) })
29
26
  ] });
30
27
  export {
31
28
  CommunitiesSkeleton as default
@@ -3,7 +3,10 @@ export interface CommunitiesModel {
3
3
  title: string;
4
4
  image?: string;
5
5
  }
6
- export declare function useCommunities(): {
6
+ export declare const COMMUNITIES_PREVIEW_SIZE = 6;
7
+ export declare function useCommunities({ enabled }?: {
8
+ enabled?: boolean;
9
+ }): {
7
10
  communities: CommunitiesModel[];
8
11
  isLoading: boolean;
9
12
  error: Error | null;
@@ -1,6 +1,9 @@
1
1
  import { odeServices } from "@edifice.io/client";
2
2
  import { useQuery, queryOptions } from "@tanstack/react-query";
3
- function useCommunities() {
3
+ const COMMUNITIES_PREVIEW_SIZE = 6;
4
+ function useCommunities({
5
+ enabled = !0
6
+ } = {}) {
4
7
  const {
5
8
  data,
6
9
  isLoading,
@@ -8,11 +11,12 @@ function useCommunities() {
8
11
  } = useQuery(queryOptions({
9
12
  queryKey: ["communities", "preview"],
10
13
  queryFn: async () => {
11
- const http = odeServices.http(), response = await http.get("/communities/api/communities?page=1&size=4");
14
+ const http = odeServices.http(), response = await http.get(`/communities/api/communities?page=1&size=${COMMUNITIES_PREVIEW_SIZE}`);
12
15
  if (http.isResponseError())
13
16
  throw new Error(http.latestResponse.statusText);
14
17
  return response.items;
15
- }
18
+ },
19
+ enabled
16
20
  }));
17
21
  return {
18
22
  communities: data ?? [],
@@ -21,5 +25,6 @@ function useCommunities() {
21
25
  };
22
26
  }
23
27
  export {
28
+ COMMUNITIES_PREVIEW_SIZE,
24
29
  useCommunities
25
30
  };
@@ -13,9 +13,9 @@ const HomeCardHeader = ({
13
13
  ...rest
14
14
  }) => {
15
15
  const hasAction = !!actionLabel && !!onActionClick;
16
- return /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", gap: "8", className: clsx("home-card-header", className), ...rest, children: [
16
+ return /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", gap: "8", wrap: "wrap", className: clsx("home-card-header", className), ...rest, children: [
17
17
  /* @__PURE__ */ jsx("h3", { className: "home-card-header-title", children: title }),
18
- hasAction && /* @__PURE__ */ jsx(ButtonBeta, { color: "tertiary", size: "sm", variant: "ghost", onClick: onActionClick, leftIcon: actionLeftIcon, rightIcon: actionRightIcon, "data-testid": "home-card-header-action", ...actionProps, children: actionLabel })
18
+ hasAction && /* @__PURE__ */ jsx(ButtonBeta, { color: "tertiary", size: "sm", variant: "ghost", onClick: onActionClick, className: "home-card-header-action", leftIcon: actionLeftIcon, rightIcon: actionRightIcon, "data-testid": "home-card-header-action", ...actionProps, children: actionLabel })
19
19
  ] });
20
20
  };
21
21
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.6.8",
3
+ "version": "2.6.9-develop-orga.20261013105203",
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.8",
144
- "@edifice.io/tiptap-extensions": "2.6.8",
145
- "@edifice.io/utilities": "2.6.8"
143
+ "@edifice.io/tiptap-extensions": "2.6.9-develop-orga.20261013105203",
144
+ "@edifice.io/utilities": "2.6.9-develop-orga.20261013105203",
145
+ "@edifice.io/bootstrap": "2.6.9-develop-orga.20261013105203"
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/client": "2.6.8",
177
- "@edifice.io/config": "2.6.8"
176
+ "@edifice.io/config": "2.6.9-develop-orga.20261013105203",
177
+ "@edifice.io/client": "2.6.9-develop-orga.20261013105203"
178
178
  },
179
179
  "peerDependencies": {
180
180
  "@react-spring/web": "9.7.5",