@edifice.io/react 2.3.2-develop-b2school-actualites.20251027110554 → 2.3.2-develop-b2school-actualites.20251103101842

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.
@@ -0,0 +1 @@
1
+ export { default as useInfiniteScroll } from './useInfiniteScroll';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * A custom React hook that provides infinite scroll functionality using the Intersection Observer API.
3
+ *
4
+ * This hook returns a ref callback that can be attached to a DOM element (typically at the bottom
5
+ * of a scrollable list). When that element becomes visible in the viewport, the provided callback
6
+ * function is executed, allowing you to load more content.
7
+ *
8
+ * @param params - Configuration object for the infinite scroll hook
9
+ * @param params.callback - Function to execute when the observed element intersects with the viewport
10
+ * @param params.options - Optional Intersection Observer configuration options (defaults to { threshold: 0.1 })
11
+ *
12
+ * @returns A ref callback function that should be attached to the target DOM element
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const loadMoreRef = useInfiniteScroll({
17
+ * // Load more data when the element is visible
18
+ * callback: loadMoreItems,
19
+ * options: { threshold: 0.5 } // Trigger when 50% of element is visible
20
+ * });
21
+ *
22
+ * return (
23
+ * <div>
24
+ * {items.map(item => <Item key={item.id} {...item} />)}
25
+ * <div ref={loadMoreRef}>Loading...</div>
26
+ * </div>
27
+ * );
28
+ * ```
29
+ */
30
+ export default function useInfiniteScroll({ callback, options, }: {
31
+ callback: () => void;
32
+ options?: IntersectionObserverInit;
33
+ }): (node: HTMLElement | null) => void;
package/dist/index.js CHANGED
@@ -128,6 +128,7 @@ import { useEdificeTheme } from "./providers/EdificeThemeProvider/EdificeThemePr
128
128
  import { MockedProvider } from "./providers/MockedProvider/MockedProvider.js";
129
129
  import { checkUserRight } from "./utilities/check-user-rights/check-user-rights.js";
130
130
  import { emptyScreenMapping } from "./utilities/emptyscreen-mapping/emptyscreen-mapping.js";
131
+ import { invalidateQueriesWithFirstPage } from "./utilities/react-query/react-query-utils.js";
131
132
  import { mergeRefs, setRef } from "./utilities/refs/ref.js";
132
133
  export {
133
134
  AccessiblePalette,
@@ -243,6 +244,7 @@ export {
243
244
  getIndicesToUpdate,
244
245
  getProjection,
245
246
  hasChildren,
247
+ invalidateQueriesWithFirstPage,
246
248
  mergeRefs,
247
249
  modifyNode,
248
250
  moveNode,
@@ -1,3 +1,4 @@
1
1
  export * from './check-user-rights';
2
2
  export * from './emptyscreen-mapping';
3
+ export * from './react-query';
3
4
  export * from './refs';
@@ -0,0 +1 @@
1
+ export * from './react-query-utils';
@@ -0,0 +1,21 @@
1
+ import { InvalidateQueryFilters, QueryClient } from '../../node_modules/@tanstack/react-query';
2
+ /**
3
+ * Invalidates queries and resets infinite query data to only contain the first page.
4
+ *
5
+ * This utility function is useful when you want to invalidate a query but also ensure
6
+ * that any infinite query data is reset to show only the first page, removing any
7
+ * previously loaded subsequent pages.
8
+ *
9
+ * @param queryClient - The TanStack Query client instance used to manage queries
10
+ * @param options - The invalidate query filters that specify which queries to invalidate
11
+ * @returns The result of the invalidateQueries operation, or undefined if no queryKey is provided
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Invalidate user queries and reset to first page only
16
+ * invalidateQueriesWithFirstPage(queryClient, {
17
+ * queryKey: ['users']
18
+ * });
19
+ * ```
20
+ */
21
+ export declare function invalidateQueriesWithFirstPage(queryClient: QueryClient, options: InvalidateQueryFilters): Promise<void> | undefined;
@@ -0,0 +1,13 @@
1
+ function invalidateQueriesWithFirstPage(queryClient, options) {
2
+ if (options.queryKey)
3
+ return queryClient.setQueriesData({
4
+ queryKey: options.queryKey
5
+ }, (oldData) => oldData != null && oldData.pages ? {
6
+ ...oldData,
7
+ pages: [oldData.pages[0]],
8
+ pageParams: [oldData.pageParams[0]]
9
+ } : oldData), queryClient.invalidateQueries(options);
10
+ }
11
+ export {
12
+ invalidateQueriesWithFirstPage
13
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.3.2-develop-b2school-actualites.20251027110554",
3
+ "version": "2.3.2-develop-b2school-actualites.20251103101842",
4
4
  "description": "Edifice React Library",
5
5
  "keywords": [
6
6
  "react",
@@ -131,9 +131,9 @@
131
131
  "react-slugify": "^3.0.3",
132
132
  "swiper": "^10.1.0",
133
133
  "ua-parser-js": "^1.0.36",
134
- "@edifice.io/bootstrap": "2.3.2-develop-b2school-actualites.20251027110554",
135
- "@edifice.io/utilities": "2.3.2-develop-b2school-actualites.20251027110554",
136
- "@edifice.io/tiptap-extensions": "2.3.2-develop-b2school-actualites.20251027110554"
134
+ "@edifice.io/bootstrap": "2.3.2-develop-b2school-actualites.20251103101842",
135
+ "@edifice.io/tiptap-extensions": "2.3.2-develop-b2school-actualites.20251103101842",
136
+ "@edifice.io/utilities": "2.3.2-develop-b2school-actualites.20251103101842"
137
137
  },
138
138
  "devDependencies": {
139
139
  "@babel/plugin-transform-react-pure-annotations": "^7.23.3",
@@ -164,8 +164,8 @@
164
164
  "vite": "^5.4.11",
165
165
  "vite-plugin-dts": "^4.1.0",
166
166
  "vite-tsconfig-paths": "^5.0.1",
167
- "@edifice.io/config": "2.3.2-develop-b2school-actualites.20251027110554",
168
- "@edifice.io/client": "2.3.2-develop-b2school-actualites.20251027110554"
167
+ "@edifice.io/client": "2.3.2-develop-b2school-actualites.20251103101842",
168
+ "@edifice.io/config": "2.3.2-develop-b2school-actualites.20251103101842"
169
169
  },
170
170
  "peerDependencies": {
171
171
  "@react-spring/web": "^9.7.5",