@fluid-app/portal-sdk 0.1.227 → 0.1.228

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.
@@ -1615,6 +1615,37 @@ function ProductDetailScreen({ productId, countryCode, fetchProduct: fetchPortal
1615
1615
  });
1616
1616
  }
1617
1617
  //#endregion
1618
+ //#region ../../shareables/ui/src/hooks/use-infinite-list-sentinel.ts
1619
+ /**
1620
+ * Wires a sentinel `<div>` to TanStack Query infinite-pagination state.
1621
+ *
1622
+ * Returns a ref the caller attaches to a 1px sentinel element rendered below
1623
+ * the list. When the sentinel scrolls into view (with a 200px root margin)
1624
+ * and the query has a next page, isn't already fetching, and hasn't errored,
1625
+ * `fetchNextPage()` is invoked.
1626
+ */
1627
+ function useInfiniteListSentinel({ hasNextPage, isFetchingNextPage, fetchNextPage, error }) {
1628
+ const sentinelRef = useRef(null);
1629
+ useEffect(() => {
1630
+ const target = sentinelRef.current;
1631
+ if (!target) return;
1632
+ const observer = new IntersectionObserver((entries) => {
1633
+ if (entries[0]?.isIntersecting && hasNextPage && !isFetchingNextPage && !error) fetchNextPage();
1634
+ }, {
1635
+ threshold: 0,
1636
+ rootMargin: "200px"
1637
+ });
1638
+ observer.observe(target);
1639
+ return () => observer.disconnect();
1640
+ }, [
1641
+ fetchNextPage,
1642
+ hasNextPage,
1643
+ isFetchingNextPage,
1644
+ error
1645
+ ]);
1646
+ return sentinelRef;
1647
+ }
1648
+ //#endregion
1618
1649
  //#region ../../shareables/ui/src/components/OwnerFilterTabs.tsx
1619
1650
  function getFilteredEmptyMessage({ searchTerm, ownerFilter, hasOtherFilters = false, entityName = "items", defaultMessage = "Nothing available at the moment." }) {
1620
1651
  const isFiltered = ownerFilter !== "all" || hasOtherFilters;
@@ -1709,7 +1740,6 @@ function MediaListingScreen(_props) {
1709
1740
  }, 300);
1710
1741
  return () => clearTimeout(timer);
1711
1742
  }, [searchTerm]);
1712
- const observerTarget = useRef(null);
1713
1743
  const { mutate: deleteMedia, isPending: isDeleting } = useMutation({
1714
1744
  mutationFn: (id) => api.media.deleteMedia(id),
1715
1745
  onSuccess: () => {
@@ -1755,22 +1785,12 @@ function MediaListingScreen(_props) {
1755
1785
  });
1756
1786
  const allItems = useMemo(() => data?.pages.flatMap((p) => p.media) ?? [], [data?.pages]);
1757
1787
  const filteredItems = ownerFilter === "all" ? allItems : ownerFilter === "my" ? allItems.filter((item) => item.owner_type === "user") : allItems.filter((item) => item.owner_type === "company");
1758
- useEffect(() => {
1759
- const target = observerTarget.current;
1760
- if (!target) return;
1761
- const observer = new IntersectionObserver((entries) => {
1762
- if (entries[0]?.isIntersecting && hasNextPage && !isFetchingNextPage) fetchNextPage();
1763
- }, {
1764
- threshold: 0,
1765
- rootMargin: "200px"
1766
- });
1767
- observer.observe(target);
1768
- return () => observer.disconnect();
1769
- }, [
1770
- fetchNextPage,
1788
+ const sentinelRef = useInfiniteListSentinel({
1771
1789
  hasNextPage,
1772
- isFetchingNextPage
1773
- ]);
1790
+ isFetchingNextPage,
1791
+ fetchNextPage,
1792
+ error
1793
+ });
1774
1794
  const filterBar = /* @__PURE__ */ jsxs("div", {
1775
1795
  className: "flex items-center gap-3",
1776
1796
  children: [/* @__PURE__ */ jsx(OwnerFilterTabs, {
@@ -1867,7 +1887,7 @@ function MediaListingScreen(_props) {
1867
1887
  }),
1868
1888
  filters: filterBar,
1869
1889
  footer,
1870
- sentinelRef: observerTarget,
1890
+ sentinelRef,
1871
1891
  loadingFilterShape: "search-view",
1872
1892
  children: viewMode === "grid" ? /* @__PURE__ */ jsx("div", {
1873
1893
  className: SHAREABLE_GRID_CLASS,
@@ -12499,4 +12519,4 @@ const shareablesScreenPropertySchema = {
12499
12519
  //#endregion
12500
12520
  export { ShareablesScreen_exports as n, shareablesScreenPropertySchema as r, ShareablesScreen as t };
12501
12521
 
12502
- //# sourceMappingURL=ShareablesScreen-CNARhXTE.mjs.map
12522
+ //# sourceMappingURL=ShareablesScreen-DaOvfu8L.mjs.map