@edifice.io/react 2.6.13-develop-integration-demo.20261108115137 → 2.6.13-develop-b2school.20261109110305

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.
Files changed (214) hide show
  1. package/dist/components/Checkbox/Checkbox.js +1 -1
  2. package/dist/components/Layout/Layout.js +12 -4
  3. package/dist/components/Masonry/Masonry.d.ts +40 -0
  4. package/dist/components/Masonry/Masonry.js +50 -0
  5. package/dist/components/Masonry/index.d.ts +2 -0
  6. package/dist/components/SearchBar/SearchBar.js +17 -26
  7. package/dist/components/index.d.ts +1 -0
  8. package/dist/homepage.js +106 -24
  9. package/dist/hooks/useUpload/useUpload.js +1 -1
  10. package/dist/hooks/useZendeskGuide/useZendeskGuide.d.ts +2 -6
  11. package/dist/hooks/useZendeskGuide/useZendeskGuide.js +11 -8
  12. package/dist/icons.js +406 -404
  13. package/dist/index.js +2 -0
  14. package/dist/modules/HelpZone/HelpZone.js +6 -8
  15. package/dist/modules/HelpZone/HelpZoneContainer.js +2 -5
  16. package/dist/modules/homepage/components/Agenda/Agenda.d.ts +10 -0
  17. package/dist/modules/homepage/components/Agenda/Agenda.js +54 -0
  18. package/dist/modules/homepage/components/Agenda/AgendaContainer.d.ts +1 -0
  19. package/dist/modules/homepage/components/Agenda/AgendaContainer.js +14 -0
  20. package/dist/modules/homepage/components/Agenda/AgendaEventCard.d.ts +10 -0
  21. package/dist/modules/homepage/components/Agenda/AgendaEventCard.js +30 -0
  22. package/dist/modules/homepage/components/Agenda/hooks/useAgendaContainer.d.ts +14 -0
  23. package/dist/modules/homepage/components/Agenda/hooks/useAgendaContainer.js +27 -0
  24. package/dist/modules/homepage/components/Agenda/index.d.ts +3 -0
  25. package/dist/modules/homepage/components/Agenda/services/api/agendaService.d.ts +24 -0
  26. package/dist/modules/homepage/components/Agenda/services/api/agendaService.js +45 -0
  27. package/dist/modules/homepage/components/Agenda/services/api/index.d.ts +4 -0
  28. package/dist/modules/homepage/components/Agenda/services/api/index.js +5 -0
  29. package/dist/modules/homepage/components/Agenda/services/queries/agenda.d.ts +19 -0
  30. package/dist/modules/homepage/components/Agenda/services/queries/agenda.js +26 -0
  31. package/dist/modules/homepage/components/BriefMe/BriefMe.d.ts +9 -0
  32. package/dist/modules/homepage/components/BriefMe/BriefMe.js +59 -0
  33. package/dist/modules/homepage/components/BriefMe/BriefMeContainer.d.ts +4 -0
  34. package/dist/modules/homepage/components/BriefMe/BriefMeContainer.js +17 -0
  35. package/dist/modules/homepage/components/BriefMe/index.d.ts +4 -0
  36. package/dist/modules/homepage/components/BriefMe/types.d.ts +17 -0
  37. package/dist/modules/homepage/components/BriefMe/types.js +8 -0
  38. package/dist/modules/homepage/components/BriefMe/useBriefMe.d.ts +31 -0
  39. package/dist/modules/homepage/components/BriefMe/useBriefMe.js +51 -0
  40. package/dist/modules/homepage/components/Cantine/Cantine.d.ts +7 -0
  41. package/dist/modules/homepage/components/Cantine/Cantine.js +44 -0
  42. package/dist/modules/homepage/components/Cantine/CantineContainer.d.ts +4 -0
  43. package/dist/modules/homepage/components/Cantine/CantineContainer.js +18 -0
  44. package/dist/modules/homepage/components/Cantine/CantineModal.d.ts +24 -0
  45. package/dist/modules/homepage/components/Cantine/CantineModal.js +88 -0
  46. package/dist/modules/homepage/components/Cantine/CantineModalContainer.d.ts +7 -0
  47. package/dist/modules/homepage/components/Cantine/CantineModalContainer.js +12 -0
  48. package/dist/modules/homepage/components/Cantine/components/CantineLegend.d.ts +5 -0
  49. package/dist/modules/homepage/components/Cantine/components/CantineLegend.js +22 -0
  50. package/dist/modules/homepage/components/Cantine/components/CantineMenuSection.d.ts +6 -0
  51. package/dist/modules/homepage/components/Cantine/components/CantineMenuSection.js +28 -0
  52. package/dist/modules/homepage/components/Cantine/components/cantineLabels.d.ts +12 -0
  53. package/dist/modules/homepage/components/Cantine/components/cantineLabels.js +60 -0
  54. package/dist/modules/homepage/components/Cantine/hooks/useCantine.d.ts +11 -0
  55. package/dist/modules/homepage/components/Cantine/hooks/useCantine.js +20 -0
  56. package/dist/modules/homepage/components/Cantine/hooks/useCantineMenu.d.ts +24 -0
  57. package/dist/modules/homepage/components/Cantine/hooks/useCantineMenu.js +65 -0
  58. package/dist/modules/homepage/components/Cantine/hooks/useCantineModal.d.ts +23 -0
  59. package/dist/modules/homepage/components/Cantine/hooks/useCantineModal.js +43 -0
  60. package/dist/modules/homepage/components/Cantine/index.d.ts +7 -0
  61. package/dist/modules/homepage/components/Cantine/types.d.ts +42 -0
  62. package/dist/modules/homepage/components/Captation/CaptationAudio/CaptationAudio.d.ts +7 -0
  63. package/dist/modules/homepage/components/Captation/CaptationVideo/CaptationVideo.d.ts +9 -0
  64. package/dist/modules/homepage/components/Edumalin/Edumalin.d.ts +9 -0
  65. package/dist/modules/homepage/components/Edumalin/Edumalin.js +65 -0
  66. package/dist/modules/homepage/components/Edumalin/EdumalinContainer.d.ts +4 -0
  67. package/dist/modules/homepage/components/Edumalin/EdumalinContainer.js +21 -0
  68. package/dist/modules/homepage/components/Edumalin/EdumalinModal.d.ts +8 -0
  69. package/dist/modules/homepage/components/Edumalin/EdumalinModal.js +62 -0
  70. package/dist/modules/homepage/components/Edumalin/components/EdumalinBadge.d.ts +5 -0
  71. package/dist/modules/homepage/components/Edumalin/components/EdumalinBadge.js +38 -0
  72. package/dist/modules/homepage/components/Edumalin/components/EdumalinPicture.d.ts +5 -0
  73. package/dist/modules/homepage/components/Edumalin/components/EdumalinPicture.js +12 -0
  74. package/dist/modules/homepage/components/Edumalin/index.d.ts +7 -0
  75. package/dist/modules/homepage/components/Edumalin/types.d.ts +24 -0
  76. package/dist/modules/homepage/components/Edumalin/types.js +4 -0
  77. package/dist/modules/homepage/components/Edumalin/useEdumalin.d.ts +16 -0
  78. package/dist/modules/homepage/components/Edumalin/useEdumalin.js +35 -0
  79. package/dist/modules/homepage/components/Edumalin/utils.d.ts +28 -0
  80. package/dist/modules/homepage/components/Edumalin/utils.js +56 -0
  81. package/dist/modules/homepage/components/GenerationHdf/GenerationHdf.d.ts +16 -0
  82. package/dist/modules/homepage/components/GenerationHdf/GenerationHdf.js +65 -0
  83. package/dist/modules/homepage/components/GenerationHdf/GenerationHdfContainer.d.ts +4 -0
  84. package/dist/modules/homepage/components/GenerationHdf/GenerationHdfContainer.js +12 -0
  85. package/dist/modules/homepage/components/GenerationHdf/formatSolde.d.ts +1 -0
  86. package/dist/modules/homepage/components/GenerationHdf/formatSolde.js +6 -0
  87. package/dist/modules/homepage/components/GenerationHdf/index.d.ts +3 -0
  88. package/dist/modules/homepage/components/GenerationHdf/useGenerationHdf.d.ts +10 -0
  89. package/dist/modules/homepage/components/GenerationHdf/useGenerationHdf.js +69 -0
  90. package/dist/modules/homepage/components/Header/Header.js +9 -21
  91. package/dist/modules/homepage/components/HomeCard/HomeCardHeader.d.ts +5 -1
  92. package/dist/modules/homepage/components/HomeCard/HomeCardHeader.js +1 -1
  93. package/dist/modules/homepage/components/Mediacentre/Mediacentre.d.ts +13 -0
  94. package/dist/modules/homepage/components/Mediacentre/Mediacentre.js +57 -0
  95. package/dist/modules/homepage/components/Mediacentre/MediacentreContainer.d.ts +4 -0
  96. package/dist/modules/homepage/components/Mediacentre/MediacentreContainer.js +12 -0
  97. package/dist/modules/homepage/components/Mediacentre/components/MediacentreUniversalisSearch.d.ts +6 -0
  98. package/dist/modules/homepage/components/Mediacentre/components/MediacentreUniversalisSearch.js +30 -0
  99. package/dist/modules/homepage/components/Mediacentre/hooks/useMediacentre.d.ts +17 -0
  100. package/dist/modules/homepage/components/Mediacentre/hooks/useMediacentre.js +32 -0
  101. package/dist/modules/homepage/components/Mediacentre/index.d.ts +5 -0
  102. package/dist/modules/homepage/components/Mediacentre/services/mediacentreService.d.ts +24 -0
  103. package/dist/modules/homepage/components/Mediacentre/services/mediacentreService.js +25 -0
  104. package/dist/modules/homepage/components/Mediacentre/types.d.ts +8 -0
  105. package/dist/modules/homepage/components/MessageFlashList/MessageFlash.js +0 -2
  106. package/dist/modules/homepage/components/Notifications/NotificationList.js +7 -8
  107. package/dist/modules/homepage/components/Notifications/NotificationListSkeleton.js +7 -12
  108. package/dist/modules/homepage/components/Notifications/NotificationSkeleton.js +7 -4
  109. package/dist/modules/homepage/components/Notifications/components/NotificationFilterModal.js +11 -13
  110. package/dist/modules/homepage/components/Notifications/components/ReportNotificationModal.js +6 -12
  111. package/dist/modules/homepage/components/Notifications/components/notificationAdapter.js +12 -10
  112. package/dist/modules/homepage/components/Notifications/hooks/useNotificationList.js +9 -10
  113. package/dist/modules/homepage/components/Qwant/Qwant.d.ts +4 -0
  114. package/dist/modules/homepage/components/Qwant/Qwant.js +41 -0
  115. package/dist/modules/homepage/components/Qwant/QwantContainer.d.ts +1 -0
  116. package/dist/modules/homepage/components/Qwant/QwantContainer.js +10 -0
  117. package/dist/modules/homepage/components/Qwant/index.d.ts +3 -0
  118. package/dist/modules/homepage/components/Rss/Rss.d.ts +11 -0
  119. package/dist/modules/homepage/components/Rss/Rss.js +64 -0
  120. package/dist/modules/homepage/components/Rss/RssContainer.d.ts +1 -0
  121. package/dist/modules/homepage/components/Rss/RssContainer.js +45 -0
  122. package/dist/modules/homepage/components/Rss/RssFeedForm.d.ts +13 -0
  123. package/dist/modules/homepage/components/Rss/RssFeedForm.js +69 -0
  124. package/dist/modules/homepage/components/Rss/RssFeedsModal.d.ts +11 -0
  125. package/dist/modules/homepage/components/Rss/RssFeedsModal.js +58 -0
  126. package/dist/modules/homepage/components/Rss/hooks/useRssContainer.d.ts +25 -0
  127. package/dist/modules/homepage/components/Rss/hooks/useRssContainer.js +43 -0
  128. package/dist/modules/homepage/components/Rss/index.d.ts +6 -0
  129. package/dist/modules/homepage/components/Rss/services/api/index.d.ts +5 -0
  130. package/dist/modules/homepage/components/Rss/services/api/index.js +5 -0
  131. package/dist/modules/homepage/components/Rss/services/api/rssService.d.ts +38 -0
  132. package/dist/modules/homepage/components/Rss/services/api/rssService.js +51 -0
  133. package/dist/modules/homepage/components/Rss/services/queries/rss.d.ts +28 -0
  134. package/dist/modules/homepage/components/Rss/services/queries/rss.js +71 -0
  135. package/dist/modules/homepage/components/Rss/types.d.ts +25 -0
  136. package/dist/modules/homepage/components/Rss/utils.d.ts +7 -0
  137. package/dist/modules/homepage/components/Rss/utils.js +19 -0
  138. package/dist/modules/homepage/components/SchoolSpace/SchoolSpaceContainer.js +1 -1
  139. package/dist/modules/homepage/components/ScreenTime/ScreenTime.d.ts +11 -0
  140. package/dist/modules/homepage/components/ScreenTime/ScreenTime.js +49 -0
  141. package/dist/modules/homepage/components/ScreenTime/ScreenTimeChart.d.ts +10 -0
  142. package/dist/modules/homepage/components/ScreenTime/ScreenTimeChart.js +115 -0
  143. package/dist/modules/homepage/components/ScreenTime/ScreenTimeContainer.d.ts +1 -0
  144. package/dist/modules/homepage/components/ScreenTime/ScreenTimeContainer.js +25 -0
  145. package/dist/modules/homepage/components/ScreenTime/ScreenTimeError.d.ts +5 -0
  146. package/dist/modules/homepage/components/ScreenTime/ScreenTimeError.js +22 -0
  147. package/dist/modules/homepage/components/ScreenTime/ScreenTimeModal.d.ts +22 -0
  148. package/dist/modules/homepage/components/ScreenTime/ScreenTimeModal.js +81 -0
  149. package/dist/modules/homepage/components/ScreenTime/hooks/useScreenTimeContainer.d.ts +14 -0
  150. package/dist/modules/homepage/components/ScreenTime/hooks/useScreenTimeContainer.js +22 -0
  151. package/dist/modules/homepage/components/ScreenTime/hooks/useScreenTimeKids.d.ts +6 -0
  152. package/dist/modules/homepage/components/ScreenTime/hooks/useScreenTimeKids.js +25 -0
  153. package/dist/modules/homepage/components/ScreenTime/hooks/useScreenTimeModal.d.ts +31 -0
  154. package/dist/modules/homepage/components/ScreenTime/hooks/useScreenTimeModal.js +34 -0
  155. package/dist/modules/homepage/components/ScreenTime/index.d.ts +6 -0
  156. package/dist/modules/homepage/components/ScreenTime/services/api/index.d.ts +4 -0
  157. package/dist/modules/homepage/components/ScreenTime/services/api/index.js +5 -0
  158. package/dist/modules/homepage/components/ScreenTime/services/api/screenTimeService.d.ts +28 -0
  159. package/dist/modules/homepage/components/ScreenTime/services/api/screenTimeService.js +39 -0
  160. package/dist/modules/homepage/components/ScreenTime/services/queries/screenTime.d.ts +23 -0
  161. package/dist/modules/homepage/components/ScreenTime/services/queries/screenTime.js +41 -0
  162. package/dist/modules/homepage/components/ScreenTime/types.d.ts +30 -0
  163. package/dist/modules/homepage/components/ScreenTime/utils.d.ts +50 -0
  164. package/dist/modules/homepage/components/ScreenTime/utils.js +115 -0
  165. package/dist/modules/homepage/components/TabsKids/components/TabsKids.d.ts +43 -0
  166. package/dist/modules/homepage/components/TabsKids/components/TabsKids.js +23 -0
  167. package/dist/modules/homepage/components/TabsKids/components/TabsKidsItem.d.ts +34 -0
  168. package/dist/modules/homepage/components/TabsKids/components/TabsKidsItem.js +26 -0
  169. package/dist/modules/homepage/components/TabsKids/components/TabsKidsList.d.ts +14 -0
  170. package/dist/modules/homepage/components/TabsKids/components/TabsKidsList.js +64 -0
  171. package/dist/modules/homepage/components/TabsKids/hooks/useTabsKidsOverflow.d.ts +20 -0
  172. package/dist/modules/homepage/components/TabsKids/hooks/useTabsKidsOverflow.js +43 -0
  173. package/dist/modules/homepage/components/TabsKids/index.d.ts +3 -0
  174. package/dist/modules/homepage/components/TabsKids/utils/visibleTabs.d.ts +15 -0
  175. package/dist/modules/homepage/components/TabsKids/utils/visibleTabs.js +21 -0
  176. package/dist/modules/homepage/components/Universalis/Universalis.d.ts +8 -0
  177. package/dist/modules/homepage/components/Universalis/Universalis.js +62 -0
  178. package/dist/modules/homepage/components/Universalis/UniversalisContainer.d.ts +1 -0
  179. package/dist/modules/homepage/components/Universalis/UniversalisContainer.js +16 -0
  180. package/dist/modules/homepage/components/Universalis/index.d.ts +3 -0
  181. package/dist/modules/homepage/components/UsefulLinks/UsefulLinks.js +2 -2
  182. package/dist/modules/homepage/components/UsefulLinks/UsefulLinksModal.js +2 -2
  183. package/dist/modules/homepage/components/UserSpace/UserSpace.d.ts +3 -1
  184. package/dist/modules/homepage/components/UserSpace/UserSpace.js +13 -7
  185. package/dist/modules/homepage/components/UserSpace/UserSpaceContainer.d.ts +4 -2
  186. package/dist/modules/homepage/components/UserSpace/UserSpaceContainer.js +3 -2
  187. package/dist/modules/homepage/components/WidgetsPersonalizationPanel/WidgetToggle.d.ts +16 -0
  188. package/dist/modules/homepage/components/WidgetsPersonalizationPanel/WidgetToggle.js +15 -0
  189. package/dist/modules/homepage/components/WidgetsPersonalizationPanel/WidgetsPersonalizationPanel.d.ts +21 -0
  190. package/dist/modules/homepage/components/WidgetsPersonalizationPanel/WidgetsPersonalizationPanel.js +47 -0
  191. package/dist/modules/homepage/components/WidgetsPersonalizationPanel/index.d.ts +2 -0
  192. package/dist/modules/homepage/components/index.d.ts +14 -2
  193. package/dist/modules/homepage/{components/SchoolSpace → hooks}/useUserSchools.d.ts +2 -2
  194. package/dist/modules/homepage/{components/SchoolSpace → hooks}/useUserSchools.js +4 -4
  195. package/dist/modules/icons/components/IconAddWidget.d.ts +7 -0
  196. package/dist/modules/icons/components/IconAddWidget.js +12 -0
  197. package/dist/modules/icons/components/index.d.ts +1 -0
  198. package/dist/modules/icons/components/nav/IconCommunitiesBeta.js +5 -7
  199. package/dist/modules/icons/components/nav/IconHomeBeta.js +6 -3
  200. package/dist/modules/icons/components/nav/IconMessagesBeta.js +7 -7
  201. package/dist/modules/icons/components/nav/IconMyAppsBeta.js +2 -3
  202. package/dist/modules/icons/components/nav/IconNotificationBeta.js +2 -4
  203. package/dist/modules/multimedia/AudioRecorder/AudioRecorder.d.ts +2 -0
  204. package/dist/modules/multimedia/AudioRecorder/AudioRecorder.js +24 -10
  205. package/dist/modules/multimedia/AudioRecorder/AudioRecorderTimer.js +1 -1
  206. package/dist/modules/multimedia/AudioRecorder/useAudioRecorder.d.ts +1 -0
  207. package/dist/modules/multimedia/AudioRecorder/useAudioRecorder.js +89 -50
  208. package/dist/modules/multimedia/VideoRecorder/VideoRecorder.d.ts +6 -0
  209. package/dist/modules/multimedia/VideoRecorder/VideoRecorder.js +53 -19
  210. package/dist/modules/multimedia/VideoRecorder/VideoRecorderToolbar.js +27 -27
  211. package/dist/modules/multimedia/VideoRecorder/useCameras.d.ts +2 -0
  212. package/dist/modules/multimedia/VideoRecorder/useCameras.js +10 -4
  213. package/dist/modules/multimedia/Workspace/Workspace.js +1 -1
  214. package/package.json +7 -6
@@ -14,31 +14,30 @@ const useNotificationListContainer = () => {
14
14
  mutate: saveTimelinePreference
15
15
  } = useSaveTimelinePreference(), [selectedTypes, setSelectedTypesState] = useState();
16
16
  useEffect(() => {
17
- if (selectedTypes === void 0 && isFetchedTypes && isFetchedPreference) {
18
- const preferredTypes = preference == null ? void 0 : preference.type;
19
- setSelectedTypesState(preferredTypes && preferredTypes.length > 0 ? preferredTypes : notificationTypes ?? []);
20
- }
17
+ selectedTypes === void 0 && isFetchedTypes && isFetchedPreference && setSelectedTypesState((preference == null ? void 0 : preference.type) ?? notificationTypes ?? []);
21
18
  }, [selectedTypes, isFetchedTypes, isFetchedPreference, preference, notificationTypes]);
22
19
  const setSelectedTypes = (types) => {
23
20
  setSelectedTypesState(types), saveTimelinePreference({
24
21
  ...preference,
25
22
  type: types
26
23
  });
27
- }, {
28
- data: notifications,
24
+ }, hasNoTypeSelected = (selectedTypes == null ? void 0 : selectedTypes.length) === 0, {
25
+ data,
29
26
  hasNextPage,
30
27
  isLoading: isLoadingNotifications,
31
28
  error: errorNotifications,
32
29
  fetchNextPage
33
- } = useNotifications(selectedTypes ?? [], isFetchedTypes && !!selectedTypes);
30
+ } = useNotifications(selectedTypes ?? [], isFetchedTypes && !!selectedTypes && !hasNoTypeSelected);
34
31
  return {
35
- notifications,
32
+ notifications: hasNoTypeSelected ? [] : data,
36
33
  notificationTypes,
37
34
  selectedTypes,
38
35
  setSelectedTypes,
39
- hasNextPage,
36
+ hasNextPage: hasNoTypeSelected ? !1 : hasNextPage,
40
37
  loadNextPage: () => fetchNextPage(),
41
- isLoading: isLoadingTypes || isLoadingNotifications,
38
+ // The notification query stays disabled until the saved filter is
39
+ // read, so this wait must count as loading too.
40
+ isLoading: isLoadingTypes || selectedTypes === void 0 || isLoadingNotifications,
42
41
  error: errorTypes || errorNotifications
43
42
  };
44
43
  }, useHasNotificationToday = () => {
@@ -0,0 +1,4 @@
1
+ export interface QwantProps {
2
+ handleActionClick: () => void;
3
+ }
4
+ export default function Qwant({ handleActionClick }: QwantProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,41 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import illuQwant from "@edifice.io/bootstrap/dist/images/homepage/illu-qwant.png";
3
+ import { useForm } from "react-hook-form";
4
+ import { useTranslation } from "react-i18next";
5
+ import SvgIconExternalLink from "../../../icons/components/IconExternalLink.js";
6
+ import SvgIconSearch from "../../../icons/components/IconSearch.js";
7
+ import HomeCard from "../HomeCard/HomeCard.js";
8
+ import ButtonBeta from "../../../../components/ButtonBeta/ButtonBeta.js";
9
+ import Image from "../../../../components/Image/Image.js";
10
+ import FormControl from "../../../../components/Form/FormControl.js";
11
+ import Input from "../../../../components/Input/Input.js";
12
+ function Qwant({
13
+ handleActionClick
14
+ }) {
15
+ const {
16
+ t
17
+ } = useTranslation(), {
18
+ register
19
+ } = useForm();
20
+ return /* @__PURE__ */ jsxs(HomeCard, { variant: "primary", children: [
21
+ /* @__PURE__ */ jsxs("div", { className: "qwant__header", children: [
22
+ /* @__PURE__ */ jsx("h3", { className: "qwant__title", children: t("homepage.widget.qwant.title") }),
23
+ /* @__PURE__ */ jsx(ButtonBeta, { className: "qwant__header-button", "data-testid": "qwant-button-open", "aria-label": t("homepage.widget.qwant.open"), onClick: handleActionClick, leftIcon: /* @__PURE__ */ jsx(SvgIconExternalLink, {}), variant: "ghost", color: "tertiary" })
24
+ ] }),
25
+ /* @__PURE__ */ jsx(HomeCard.Content, { children: /* @__PURE__ */ jsxs("div", { className: "qwant", children: [
26
+ /* @__PURE__ */ jsxs("div", { className: "qwant__intro", children: [
27
+ /* @__PURE__ */ jsx(Image, { src: illuQwant, alt: "Qwant", className: "qwant__logo" }),
28
+ /* @__PURE__ */ jsx("p", { className: "qwant__description", children: t("homepage.widget.qwant.description") })
29
+ ] }),
30
+ /* @__PURE__ */ jsx("form", { method: "GET", action: "https://www.qwant.com", target: "_blank", className: "qwant__search", children: /* @__PURE__ */ jsxs(FormControl, { id: "inputQwantQuery", className: "qwant__search-field", children: [
31
+ /* @__PURE__ */ jsx(FormControl.Label, { className: "visually-hidden", children: t("search") }),
32
+ /* @__PURE__ */ jsx(Input, { "data-testid": "qwant-search-input", placeholder: t("search"), size: "md", type: "text", maxLength: 255, ...register("q") }),
33
+ /* @__PURE__ */ jsx("input", { type: "hidden", name: "l", value: "fr" }),
34
+ /* @__PURE__ */ jsx(ButtonBeta, { leftIcon: /* @__PURE__ */ jsx(SvgIconSearch, {}), type: "submit", "aria-label": t("search"), variant: "filled", color: "default" })
35
+ ] }) })
36
+ ] }) })
37
+ ] });
38
+ }
39
+ export {
40
+ Qwant as default
41
+ };
@@ -0,0 +1 @@
1
+ export declare function QwantContainer(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import Qwant from "./Qwant.js";
3
+ function QwantContainer() {
4
+ return /* @__PURE__ */ jsx(Qwant, { handleActionClick: () => {
5
+ window.open("https://www.qwant.com", "_blank", "noopener,noreferrer");
6
+ } });
7
+ }
8
+ export {
9
+ QwantContainer
10
+ };
@@ -0,0 +1,3 @@
1
+ export * from './Qwant';
2
+ export { default as Qwant } from './Qwant';
3
+ export * from './QwantContainer';
@@ -0,0 +1,11 @@
1
+ import { RssArticle, RssArticlesStatus, RssFeed } from './types';
2
+ export interface RssProps {
3
+ feeds: RssFeed[];
4
+ isLoading?: boolean;
5
+ selectedIndex: number;
6
+ onSelectFeed: (index: number) => void;
7
+ articles: RssArticle[];
8
+ articlesStatus: RssArticlesStatus;
9
+ onEditClick: () => void;
10
+ }
11
+ export declare function Rss({ feeds, isLoading, selectedIndex, onSelectFeed, articles, articlesStatus, onEditClick, }: RssProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,64 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import clsx from "clsx";
3
+ import { useTranslation } from "react-i18next";
4
+ import illuEmptyArticles from "@edifice.io/bootstrap/dist/images/homepage/illu-rss-empty-articles.svg";
5
+ import illuError from "@edifice.io/bootstrap/dist/images/homepage/illu-rss-error.svg";
6
+ import illuEmptyFeeds from "@edifice.io/bootstrap/dist/images/homepage/illu-empty-useful-links.png";
7
+ import SvgIconEdit from "../../../icons/components/IconEdit.js";
8
+ import SvgIconPlus from "../../../icons/components/IconPlus.js";
9
+ import { htmlToText } from "./utils.js";
10
+ import useDate from "../../../../hooks/useDate/useDate.js";
11
+ import HomeCard from "../HomeCard/HomeCard.js";
12
+ import ButtonBeta from "../../../../components/ButtonBeta/ButtonBeta.js";
13
+ import Image from "../../../../components/Image/Image.js";
14
+ import TextSkeleton from "../../../../components/Skeleton/TextSkeleton.js";
15
+ const SKELETON_ARTICLES = [0, 1, 2];
16
+ function Rss({
17
+ feeds,
18
+ isLoading = !1,
19
+ selectedIndex,
20
+ onSelectFeed,
21
+ articles,
22
+ articlesStatus,
23
+ onEditClick
24
+ }) {
25
+ const {
26
+ t
27
+ } = useTranslation(), {
28
+ formatDate
29
+ } = useDate(), hasFeeds = feeds.length > 0, renderArticles = (status) => status === "loading" ? /* @__PURE__ */ jsx("div", { className: "rss-widget__articles", "data-testid": "rss-skeleton", children: SKELETON_ARTICLES.map((key) => /* @__PURE__ */ jsxs("div", { className: "rss-widget__article", "aria-hidden": "true", children: [
30
+ /* @__PURE__ */ jsx(TextSkeleton, { className: "rss-widget__skeleton-title" }),
31
+ /* @__PURE__ */ jsx(TextSkeleton, { size: "xs", className: "rss-widget__skeleton-date" }),
32
+ /* @__PURE__ */ jsx(TextSkeleton, { size: "sm" }),
33
+ /* @__PURE__ */ jsx(TextSkeleton, { size: "sm" })
34
+ ] }, key)) }) : status === "error" ? /* @__PURE__ */ jsxs("div", { className: "rss-widget__state", children: [
35
+ /* @__PURE__ */ jsx("div", { className: "rss-widget__state-illustration", children: /* @__PURE__ */ jsx(Image, { src: illuError, alt: "", "aria-hidden": "true", className: "rss-widget__error-image" }) }),
36
+ /* @__PURE__ */ jsx("p", { className: "rss-widget__state-text", children: t("homepage.widget.rss.error") })
37
+ ] }) : articles.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "rss-widget__state", children: [
38
+ /* @__PURE__ */ jsx(Image, { src: illuEmptyArticles, alt: "", "aria-hidden": "true", className: "rss-widget__empty-articles-image" }),
39
+ /* @__PURE__ */ jsx("p", { className: "rss-widget__state-text", children: t("homepage.widget.rss.noArticles") })
40
+ ] }) : /* @__PURE__ */ jsx("div", { className: "rss-widget__articles", children: articles.map((article, index) => /* @__PURE__ */ jsxs("a", { href: article.link, target: "_blank", rel: "noopener noreferrer", className: "rss-widget__article", "data-testid": `rss-link-article-${index}`, children: [
41
+ /* @__PURE__ */ jsx("span", { className: "rss-widget__article-title", children: article.title }),
42
+ article.pubDate && /* @__PURE__ */ jsx("span", { className: "rss-widget__article-date", children: formatDate(new Date(article.pubDate), "dddd D MMMM YYYY") }),
43
+ article.description && /* @__PURE__ */ jsx("span", { className: "rss-widget__article-description", children: htmlToText(article.description) })
44
+ ] }, `${article.link}-${index}`)) });
45
+ return /* @__PURE__ */ jsxs(HomeCard, { variant: "primary", children: [
46
+ /* @__PURE__ */ jsxs("div", { className: "rss-widget__header", children: [
47
+ /* @__PURE__ */ jsx("h3", { className: "rss-widget__title", children: t("homepage.widget.rss.title") }),
48
+ !isLoading && (hasFeeds ? /* @__PURE__ */ jsx(ButtonBeta, { type: "button", variant: "ghost", color: "tertiary", leftIcon: /* @__PURE__ */ jsx(SvgIconEdit, {}), "aria-label": t("homepage.widget.rss.edit"), "data-testid": "rss-button-edit", onClick: onEditClick }) : /* @__PURE__ */ jsx(ButtonBeta, { type: "button", variant: "ghost", color: "tertiary", size: "sm", rightIcon: /* @__PURE__ */ jsx(SvgIconPlus, {}), "data-testid": "rss-button-add", onClick: onEditClick, children: t("homepage.widget.rss.add") }))
49
+ ] }),
50
+ /* @__PURE__ */ jsx(HomeCard.Content, { children: /* @__PURE__ */ jsxs("div", { className: "rss-widget", children: [
51
+ !isLoading && !hasFeeds && /* @__PURE__ */ jsxs("div", { className: "rss-widget__empty", children: [
52
+ /* @__PURE__ */ jsx(Image, { src: illuEmptyFeeds, alt: "", "aria-hidden": "true", className: "rss-widget__empty-image" }),
53
+ /* @__PURE__ */ jsx("p", { className: "rss-widget__state-text", children: t("homepage.widget.rss.empty") })
54
+ ] }),
55
+ !isLoading && hasFeeds && /* @__PURE__ */ jsx("div", { className: "rss-widget__feeds", role: "group", "aria-label": t("homepage.widget.rss.feeds"), children: feeds.map((feed, index) => /* @__PURE__ */ jsx("button", { type: "button", className: clsx("rss-widget__chip", {
56
+ "rss-widget__chip-active": index === selectedIndex
57
+ }), "aria-pressed": index === selectedIndex, "data-testid": `rss-button-feed-${index}`, onClick: () => onSelectFeed(index), children: feed.title }, `${feed.link}-${index}`)) }),
58
+ (isLoading || hasFeeds) && renderArticles(isLoading ? "loading" : articlesStatus)
59
+ ] }) })
60
+ ] });
61
+ }
62
+ export {
63
+ Rss
64
+ };
@@ -0,0 +1 @@
1
+ export declare function RssContainer(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,45 @@
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { useRssContainer } from "./hooks/useRssContainer.js";
4
+ import { Rss } from "./Rss.js";
5
+ import { RssFeedForm } from "./RssFeedForm.js";
6
+ import { RssFeedsModal } from "./RssFeedsModal.js";
7
+ function RssContainer() {
8
+ const [view, setView] = useState({
9
+ name: "closed"
10
+ }), {
11
+ feeds,
12
+ isLoading,
13
+ canAddFeed,
14
+ selectedIndex,
15
+ selectFeed,
16
+ articles,
17
+ articlesStatus,
18
+ addFeed,
19
+ updateFeed,
20
+ deleteFeed,
21
+ isSaving
22
+ } = useRssContainer(), closeAll = () => setView({
23
+ name: "closed"
24
+ }), backToManage = () => setView({
25
+ name: "manage"
26
+ }), handleSubmit = (payload) => {
27
+ view.name === "edit" ? updateFeed(view.index, payload, backToManage) : addFeed(payload, backToManage);
28
+ };
29
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
30
+ /* @__PURE__ */ jsx(Rss, { feeds, isLoading, selectedIndex, onSelectFeed: selectFeed, articles, articlesStatus, onEditClick: () => setView({
31
+ name: "manage"
32
+ }) }),
33
+ /* @__PURE__ */ jsx(RssFeedsModal, { isOpen: view.name === "manage", feeds, canAddFeed, onClose: closeAll, onAddClick: () => setView({
34
+ name: "add"
35
+ }), onEditFeed: (index) => setView({
36
+ name: "edit",
37
+ index,
38
+ feed: feeds[index]
39
+ }), onDeleteFeed: deleteFeed }),
40
+ (view.name === "add" || view.name === "edit") && /* @__PURE__ */ jsx(RssFeedForm, { mode: view.name, feed: view.name === "edit" ? view.feed : void 0, isSubmitting: isSaving, onCancel: backToManage, onClose: closeAll, onSubmit: handleSubmit })
41
+ ] });
42
+ }
43
+ export {
44
+ RssContainer
45
+ };
@@ -0,0 +1,13 @@
1
+ import { RssFeed, RssFeedPayload } from './types';
2
+ export interface RssFeedFormProps {
3
+ mode: 'add' | 'edit';
4
+ /** Feed being edited. Ignored in "add" mode. */
5
+ feed?: RssFeed;
6
+ isSubmitting: boolean;
7
+ /** Closes the form and goes back to the management modal, without saving. */
8
+ onCancel: () => void;
9
+ /** Closes the whole modal stack. */
10
+ onClose: () => void;
11
+ onSubmit: (payload: RssFeedPayload) => void;
12
+ }
13
+ export declare function RssFeedForm({ mode, feed, isSubmitting, onCancel, onClose, onSubmit, }: RssFeedFormProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,69 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useForm } from "react-hook-form";
3
+ import { useTranslation } from "react-i18next";
4
+ import { isValidRssFeedUrl } from "./utils.js";
5
+ import ModalBeta from "../../../../components/ModalBeta/ModalBeta.js";
6
+ import FormControl from "../../../../components/Form/FormControl.js";
7
+ import Label from "../../../../components/Label/Label.js";
8
+ import Input from "../../../../components/Input/Input.js";
9
+ import ButtonBeta from "../../../../components/ButtonBeta/ButtonBeta.js";
10
+ const TITLE_MAX_LENGTH = 80;
11
+ function RssFeedForm({
12
+ mode,
13
+ feed,
14
+ isSubmitting,
15
+ onCancel,
16
+ onClose,
17
+ onSubmit
18
+ }) {
19
+ const {
20
+ t
21
+ } = useTranslation(), formId = "rss-feed-form", {
22
+ register,
23
+ handleSubmit,
24
+ formState: {
25
+ errors,
26
+ isDirty,
27
+ isValid
28
+ }
29
+ } = useForm({
30
+ mode: "onChange",
31
+ defaultValues: {
32
+ title: (feed == null ? void 0 : feed.title) ?? "",
33
+ link: (feed == null ? void 0 : feed.link) ?? ""
34
+ }
35
+ }), modalTitle = t(mode === "add" ? "homepage.widget.rss.form.addTitle" : "homepage.widget.rss.form.editTitle"), handleFormSubmit = (data) => {
36
+ onSubmit({
37
+ title: data.title.trim(),
38
+ link: data.link.trim()
39
+ });
40
+ };
41
+ return /* @__PURE__ */ jsxs(ModalBeta, { id: "rss-feed-modal", isOpen: !0, size: "l", onModalClose: onClose, children: [
42
+ /* @__PURE__ */ jsx(ModalBeta.Header, { onModalClose: onClose, children: modalTitle }),
43
+ /* @__PURE__ */ jsx(ModalBeta.Body, { children: /* @__PURE__ */ jsxs("form", { id: formId, className: "rss-widget-form", onSubmit: handleSubmit(handleFormSubmit), children: [
44
+ /* @__PURE__ */ jsxs(FormControl, { id: "rss-feed-title", isRequired: !0, children: [
45
+ /* @__PURE__ */ jsx(Label, { children: t("homepage.widget.rss.form.title") }),
46
+ /* @__PURE__ */ jsx(Input, { type: "text", size: "md", maxLength: TITLE_MAX_LENGTH, showCounter: !0, clearable: !0, "data-testid": "rss-input-title", placeholder: t("homepage.widget.rss.form.title.placeholder"), ...register("title", {
47
+ required: !0,
48
+ maxLength: TITLE_MAX_LENGTH,
49
+ validate: (value) => value.trim().length > 0
50
+ }) })
51
+ ] }),
52
+ /* @__PURE__ */ jsxs(FormControl, { id: "rss-feed-link", isRequired: !0, status: errors.link ? "invalid" : void 0, children: [
53
+ /* @__PURE__ */ jsx(Label, { children: t("homepage.widget.rss.form.link") }),
54
+ /* @__PURE__ */ jsx(Input, { type: "text", size: "md", "data-testid": "rss-input-link", placeholder: t("homepage.widget.rss.form.link.placeholder"), ...register("link", {
55
+ required: !0,
56
+ validate: isValidRssFeedUrl
57
+ }) }),
58
+ errors.link && /* @__PURE__ */ jsx(FormControl.Text, { children: t("homepage.widget.rss.error") })
59
+ ] })
60
+ ] }) }),
61
+ /* @__PURE__ */ jsxs(ModalBeta.Footer, { children: [
62
+ /* @__PURE__ */ jsx(ButtonBeta, { type: "button", variant: "ghost", color: "tertiary", "data-testid": "rss-button-cancel", onClick: onCancel, children: t("homepage.widget.rss.form.cancel") }),
63
+ /* @__PURE__ */ jsx(ButtonBeta, { form: formId, type: "submit", isLoading: isSubmitting, disabled: !isValid || !isDirty || isSubmitting, "data-testid": "rss-button-save", children: t("homepage.widget.rss.form.save") })
64
+ ] })
65
+ ] });
66
+ }
67
+ export {
68
+ RssFeedForm
69
+ };
@@ -0,0 +1,11 @@
1
+ import { RssFeed } from './types';
2
+ export interface RssFeedsModalProps {
3
+ isOpen: boolean;
4
+ feeds: RssFeed[];
5
+ canAddFeed: boolean;
6
+ onClose: () => void;
7
+ onAddClick: () => void;
8
+ onEditFeed: (index: number) => void;
9
+ onDeleteFeed: (index: number) => void;
10
+ }
11
+ export declare function RssFeedsModal({ isOpen, feeds, canAddFeed, onClose, onAddClick, onEditFeed, onDeleteFeed, }: RssFeedsModalProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,58 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useTranslation } from "react-i18next";
3
+ import illuEmptyFeeds from "@edifice.io/bootstrap/dist/images/homepage/illu-empty-useful-links.png";
4
+ import SvgIconClose from "../../../icons/components/IconClose.js";
5
+ import SvgIconEdit from "../../../icons/components/IconEdit.js";
6
+ import SvgIconPlus from "../../../icons/components/IconPlus.js";
7
+ import useBreakpoint from "../../../../hooks/useBreakpoint/useBreakpoint.js";
8
+ import ModalBeta from "../../../../components/ModalBeta/ModalBeta.js";
9
+ import Table from "../../../../components/Table/components/Table.js";
10
+ import ButtonBeta from "../../../../components/ButtonBeta/ButtonBeta.js";
11
+ import Image from "../../../../components/Image/Image.js";
12
+ function RssFeedsModal({
13
+ isOpen,
14
+ feeds,
15
+ canAddFeed,
16
+ onClose,
17
+ onAddClick,
18
+ onEditFeed,
19
+ onDeleteFeed
20
+ }) {
21
+ const {
22
+ t
23
+ } = useTranslation(), {
24
+ md
25
+ } = useBreakpoint(), columnCount = md ? 3 : 2;
26
+ return /* @__PURE__ */ jsxs(ModalBeta, { id: "rss-feeds-modal", isOpen, size: "l", onModalClose: onClose, children: [
27
+ /* @__PURE__ */ jsx(ModalBeta.Header, { onModalClose: onClose, children: t("homepage.widget.rss.modal.title") }),
28
+ /* @__PURE__ */ jsx(ModalBeta.Body, { children: /* @__PURE__ */ jsx("div", { className: "rss-widget-table", children: /* @__PURE__ */ jsxs(Table, { children: [
29
+ /* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
30
+ /* @__PURE__ */ jsx(Table.Th, { className: "visually-hidden", children: t("homepage.widget.rss.modal.table.name") }),
31
+ /* @__PURE__ */ jsx(Table.Th, { className: "visually-hidden", children: t("homepage.widget.rss.modal.table.url") }),
32
+ /* @__PURE__ */ jsx(Table.Th, { className: "visually-hidden", children: t("homepage.widget.rss.modal.table.actions") })
33
+ ] }) }),
34
+ /* @__PURE__ */ jsxs(Table.Tbody, { children: [
35
+ /* @__PURE__ */ jsx(Table.Tr, { className: "rss-widget-table__action-row", children: /* @__PURE__ */ jsx(Table.Td, { colSpan: columnCount, children: /* @__PURE__ */ jsx("div", { className: "rss-widget-table__toolbar", children: /* @__PURE__ */ jsx(ButtonBeta, { type: "button", variant: "outline", leftIcon: /* @__PURE__ */ jsx(SvgIconPlus, {}), onClick: onAddClick, disabled: !canAddFeed, "data-testid": "rss-button-add-feed", children: t("homepage.widget.rss.modal.add") }) }) }) }),
36
+ feeds.length === 0 ? /* @__PURE__ */ jsx(Table.Tr, { className: "rss-widget-table__empty-row", children: /* @__PURE__ */ jsx(Table.Td, { colSpan: columnCount, children: /* @__PURE__ */ jsxs("div", { className: "rss-widget-table__empty", children: [
37
+ /* @__PURE__ */ jsx(Image, { src: illuEmptyFeeds, alt: "", "aria-hidden": "true", className: "rss-widget-table__empty-image" }),
38
+ /* @__PURE__ */ jsx("p", { className: "rss-widget-table__empty-title", children: t("homepage.widget.rss.modal.empty.title") }),
39
+ /* @__PURE__ */ jsx("p", { className: "rss-widget-table__empty-text", children: t("homepage.widget.rss.empty") })
40
+ ] }) }) }) : feeds.map((feed, index) => /* @__PURE__ */ jsxs(Table.Tr, { "data-testid": `rss-row-${index}`, children: [
41
+ /* @__PURE__ */ jsx(Table.Td, { className: "rss-widget-table__name", children: feed.title }),
42
+ /* @__PURE__ */ jsx(Table.Td, { className: "rss-widget-table__url", children: feed.link }),
43
+ /* @__PURE__ */ jsx(Table.Td, { className: "rss-widget-table__actions", children: /* @__PURE__ */ jsxs("div", { className: "rss-widget-table__actions-buttons", children: [
44
+ /* @__PURE__ */ jsx(ButtonBeta, { type: "button", variant: "ghost", color: "tertiary", size: "sm", leftIcon: /* @__PURE__ */ jsx(SvgIconEdit, {}), "aria-label": t("homepage.widget.rss.modal.table.edit", {
45
+ title: feed.title
46
+ }), "data-testid": `rss-button-edit-${index}`, onClick: () => onEditFeed(index) }),
47
+ /* @__PURE__ */ jsx(ButtonBeta, { type: "button", variant: "ghost", color: "tertiary", size: "sm", leftIcon: /* @__PURE__ */ jsx(SvgIconClose, {}), "aria-label": t("homepage.widget.rss.modal.table.delete", {
48
+ title: feed.title
49
+ }), "data-testid": `rss-button-delete-${index}`, onClick: () => onDeleteFeed(index) })
50
+ ] }) })
51
+ ] }, `${feed.link}-${index}`))
52
+ ] })
53
+ ] }) }) })
54
+ ] });
55
+ }
56
+ export {
57
+ RssFeedsModal
58
+ };
@@ -0,0 +1,25 @@
1
+ import { RssArticle, RssArticlesStatus, RssFeed, RssFeedPayload } from '../types';
2
+ /** Maximum number of feeds a user can follow. */
3
+ export declare const MAX_RSS_FEEDS = 10;
4
+ /** Maximum number of articles displayed for the selected feed. */
5
+ export declare const MAX_RSS_ARTICLES = 3;
6
+ export interface UseRssContainerReturn {
7
+ feeds: RssFeed[];
8
+ isLoading: boolean;
9
+ /** Whether the user can still add a feed (fewer than MAX_RSS_FEEDS). */
10
+ canAddFeed: boolean;
11
+ selectedIndex: number;
12
+ selectFeed: (index: number) => void;
13
+ /** The selected feed's latest articles, at most MAX_RSS_ARTICLES. */
14
+ articles: RssArticle[];
15
+ articlesStatus: RssArticlesStatus;
16
+ addFeed: (payload: RssFeedPayload, onSuccess?: () => void) => void;
17
+ updateFeed: (index: number, payload: RssFeedPayload, onSuccess?: () => void) => void;
18
+ deleteFeed: (index: number) => void;
19
+ isSaving: boolean;
20
+ }
21
+ /**
22
+ * Custom hook that provides the RSS feeds, the selected feed's articles and
23
+ * the feed CRUD handlers. Feeds have no id: they are handled by index.
24
+ */
25
+ export declare const useRssContainer: () => UseRssContainerReturn;
@@ -0,0 +1,43 @@
1
+ import { useState } from "react";
2
+ import { useRssChannel, useSaveRssFeeds, useRssArticles } from "../services/queries/rss.js";
3
+ const MAX_RSS_FEEDS = 10, MAX_RSS_ARTICLES = 3, DEFAULT_FEED_SHOW = 3, useRssContainer = () => {
4
+ var _a;
5
+ const {
6
+ data: channel,
7
+ isLoading
8
+ } = useRssChannel(), saveMutation = useSaveRssFeeds(), [selectedIndex, setSelectedIndex] = useState(0), feeds = (channel == null ? void 0 : channel.feeds) ?? [], currentIndex = Math.min(selectedIndex, Math.max(feeds.length - 1, 0)), articlesQuery = useRssArticles((_a = feeds[currentIndex]) == null ? void 0 : _a.link);
9
+ let articlesStatus = "loading";
10
+ articlesQuery.isError ? articlesStatus = "error" : articlesQuery.isSuccess && (articlesStatus = "success");
11
+ const saveFeeds = (nextFeeds, onSuccess) => saveMutation.mutate({
12
+ channelId: channel == null ? void 0 : channel.channelId,
13
+ feeds: nextFeeds
14
+ }, {
15
+ onSuccess
16
+ }), deleteFeed = (index) => {
17
+ index < currentIndex && setSelectedIndex(currentIndex - 1), saveFeeds(feeds.filter((_, i) => i !== index));
18
+ };
19
+ return {
20
+ feeds,
21
+ isLoading,
22
+ canAddFeed: feeds.length < MAX_RSS_FEEDS,
23
+ selectedIndex: currentIndex,
24
+ selectFeed: setSelectedIndex,
25
+ articles: (articlesQuery.data ?? []).slice(0, MAX_RSS_ARTICLES),
26
+ articlesStatus,
27
+ addFeed: (payload, onSuccess) => saveFeeds([...feeds, {
28
+ ...payload,
29
+ show: DEFAULT_FEED_SHOW
30
+ }], onSuccess),
31
+ updateFeed: (index, payload, onSuccess) => saveFeeds(feeds.map((feed, i) => i === index ? {
32
+ ...feed,
33
+ ...payload
34
+ } : feed), onSuccess),
35
+ deleteFeed,
36
+ isSaving: saveMutation.isPending
37
+ };
38
+ };
39
+ export {
40
+ MAX_RSS_ARTICLES,
41
+ MAX_RSS_FEEDS,
42
+ useRssContainer
43
+ };
@@ -0,0 +1,6 @@
1
+ export * from './Rss';
2
+ export * from './RssContainer';
3
+ export * from './RssFeedForm';
4
+ export * from './RssFeedsModal';
5
+ export * from './hooks/useRssContainer';
6
+ export * from './types';
@@ -0,0 +1,5 @@
1
+ export declare const rssService: {
2
+ getChannel(): Promise<import('./rssService').RssChannel>;
3
+ saveFeeds(channelId: string | undefined, feeds: import('../..').RssFeed[]): Promise<string>;
4
+ getArticles(url: string): Promise<import('../..').RssArticle[]>;
5
+ };
@@ -0,0 +1,5 @@
1
+ import { createRssService } from "./rssService.js";
2
+ const rssService = createRssService("");
3
+ export {
4
+ rssService
5
+ };
@@ -0,0 +1,38 @@
1
+ import { RssArticle, RssFeed } from '../../types';
2
+ /** The user's RSS channel: its id (none until first saved) and its feeds. */
3
+ export interface RssChannel {
4
+ channelId?: string;
5
+ feeds: RssFeed[];
6
+ }
7
+ /**
8
+ * Creates an RSS service for the homepage "RSS" widget, on top of the
9
+ * legacy `rss` backend module.
10
+ *
11
+ * Backend contract:
12
+ * - `GET /rss/channels` returns the user's channels; only the first one is
13
+ * used, and an empty array means the user has never saved a feed.
14
+ * - `POST /rss/channel { feeds }` creates the channel and returns `{ _id }`.
15
+ * - `PUT /rss/channel/:id { feeds }` replaces the whole feeds array: adding,
16
+ * editing and deleting a feed are all done this way.
17
+ * - `GET /rss/feed/items?url=…&force=0` fetches and parses a feed (served
18
+ * from the backend cache). The body carries its own `status`: anything
19
+ * other than 200 means the URL is not a readable RSS feed.
20
+ *
21
+ * @param baseURL The base URL for the rss service API.
22
+ */
23
+ export declare const createRssService: (baseURL: string) => {
24
+ /**
25
+ * Get the current user's RSS channel.
26
+ */
27
+ getChannel(): Promise<RssChannel>;
28
+ /**
29
+ * Save the whole feeds array, creating the channel on first save.
30
+ * @returns the channel id.
31
+ */
32
+ saveFeeds(channelId: string | undefined, feeds: RssFeed[]): Promise<string>;
33
+ /**
34
+ * Get the articles of a feed.
35
+ * @throws when the URL cannot be fetched or parsed as an RSS feed.
36
+ */
37
+ getArticles(url: string): Promise<RssArticle[]>;
38
+ };
@@ -0,0 +1,51 @@
1
+ import { odeServices } from "@edifice.io/client";
2
+ const createRssService = (baseURL) => ({
3
+ /**
4
+ * Get the current user's RSS channel.
5
+ */
6
+ async getChannel() {
7
+ const http = odeServices.http(), channels = await http.get(`${baseURL}/rss/channels`);
8
+ if (http.isResponseError())
9
+ throw new Error(http.latestResponse.statusText);
10
+ const [channel] = channels;
11
+ return {
12
+ channelId: channel == null ? void 0 : channel._id,
13
+ feeds: (channel == null ? void 0 : channel.feeds) ?? []
14
+ };
15
+ },
16
+ /**
17
+ * Save the whole feeds array, creating the channel on first save.
18
+ * @returns the channel id.
19
+ */
20
+ async saveFeeds(channelId, feeds) {
21
+ const http = odeServices.http();
22
+ if (!channelId) {
23
+ const {
24
+ _id
25
+ } = await http.postJson(`${baseURL}/rss/channel`, {
26
+ feeds
27
+ });
28
+ if (http.isResponseError())
29
+ throw new Error(http.latestResponse.statusText);
30
+ return _id;
31
+ }
32
+ if (await http.putJson(`${baseURL}/rss/channel/${channelId}`, {
33
+ feeds
34
+ }), http.isResponseError())
35
+ throw new Error(http.latestResponse.statusText);
36
+ return channelId;
37
+ },
38
+ /**
39
+ * Get the articles of a feed.
40
+ * @throws when the URL cannot be fetched or parsed as an RSS feed.
41
+ */
42
+ async getArticles(url) {
43
+ const http = odeServices.http(), result = await http.get(`${baseURL}/rss/feed/items?url=${encodeURIComponent(url)}&force=0`);
44
+ if (http.isResponseError() || (result == null ? void 0 : result.status) !== 200)
45
+ throw new Error("rss.feed.invalid");
46
+ return result.Items ?? [];
47
+ }
48
+ });
49
+ export {
50
+ createRssService
51
+ };
@@ -0,0 +1,28 @@
1
+ import { RssChannel } from '../api/rssService';
2
+ import { RssArticle } from '../../types';
3
+ export declare const rssQueryKeys: {
4
+ all: () => readonly ["rss"];
5
+ channel: () => readonly ["rss", "channel"];
6
+ articles: (url: string) => readonly ["rss", "articles", string];
7
+ };
8
+ export declare const rssQueryOptions: {
9
+ getChannel(): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<RssChannel, Error, RssChannel, import('@tanstack/react-query').QueryKey>, "queryFn"> & {
10
+ queryFn?: import('@tanstack/react-query').QueryFunction<RssChannel, import('@tanstack/react-query').QueryKey, never> | undefined;
11
+ } & {
12
+ queryKey: import('@tanstack/react-query').DataTag<import('@tanstack/react-query').QueryKey, RssChannel>;
13
+ };
14
+ getArticles(url: string): import('@tanstack/react-query').OmitKeyof<import('@tanstack/react-query').UseQueryOptions<RssArticle[], Error, RssArticle[], import('@tanstack/react-query').QueryKey>, "queryFn"> & {
15
+ queryFn?: import('@tanstack/react-query').QueryFunction<RssArticle[], import('@tanstack/react-query').QueryKey, never> | undefined;
16
+ } & {
17
+ queryKey: import('@tanstack/react-query').DataTag<import('@tanstack/react-query').QueryKey, RssArticle[]>;
18
+ };
19
+ };
20
+ export declare const useRssChannel: () => import('@tanstack/react-query').UseQueryResult<RssChannel, Error>;
21
+ export declare const useRssArticles: (url: string | undefined) => import('@tanstack/react-query').UseQueryResult<RssArticle[], Error>;
22
+ /**
23
+ * Saves the whole feeds array (the backend has no per-feed route), with an
24
+ * optimistic update so that adding, editing and deleting feel immediate.
25
+ */
26
+ export declare const useSaveRssFeeds: () => import('@tanstack/react-query').UseMutationResult<string, Error, RssChannel, {
27
+ previousChannel: RssChannel | undefined;
28
+ }>;