@burdenoff/fe-libs 2026.1118.1 → 2026.1118.3
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/shared/assistant/api.d.ts +10 -0
- package/dist/shared/assistant/api.js +5 -3
- package/dist/shared/assistant/createSandboxAssistantTransport.js +4 -1
- package/dist/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/turnOutcome.js +46 -38
- package/dist/shared/assistant/turnOutcomeCopy.d.ts +8 -0
- package/dist/shared/assistant/turnOutcomeCopy.js +8 -0
- package/dist/shared/assistant/turnProgress.d.ts +23 -0
- package/dist/shared/assistant/turnProgress.js +17 -7
- package/dist/shared/assistant/turnStall.d.ts +39 -0
- package/dist/shared/assistant/turnStall.js +16 -0
- package/dist/shared/assistant/types.d.ts +17 -0
- package/dist/shared/assistant/ui/AssistantChatArea.js +1348 -1332
- package/dist/shared/hooks/index.d.ts +1 -0
- package/dist/shared/hooks/useInfiniteScroll.d.ts +40 -0
- package/dist/shared/hooks/useInfiniteScroll.js +41 -0
- package/dist/shared-assistant.js +334 -333
- package/dist/shared-hooks.js +24 -23
- package/dist/shared.js +37 -36
- package/package.json +1 -1
|
@@ -22,6 +22,7 @@ export { useSessionStorage } from './useSessionStorage';
|
|
|
22
22
|
export { usePrevious, usePreviousDistinct, usePreviousHistory } from './usePrevious';
|
|
23
23
|
export { useToggle, useToggleObject, useConditionalToggle } from './useToggle';
|
|
24
24
|
export { usePagination, type UsePaginationOptions, type UsePaginationResult, } from './usePagination';
|
|
25
|
+
export { useInfiniteScroll, type UseInfiniteScrollOptions } from './useInfiniteScroll';
|
|
25
26
|
export { useAsync, useAsyncImmediate, type UseAsyncReturn } from './useAsync';
|
|
26
27
|
export * from '../keyboard';
|
|
27
28
|
export * from '../logger';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface UseInfiniteScrollOptions {
|
|
2
|
+
/** More items exist after the ones already shown. */
|
|
3
|
+
hasMore: boolean;
|
|
4
|
+
/** A page is being fetched; no new request starts until it finishes. */
|
|
5
|
+
loading: boolean;
|
|
6
|
+
/** Fetch the next page. Called at most once per time the end comes into view. */
|
|
7
|
+
onLoadMore: () => void;
|
|
8
|
+
/**
|
|
9
|
+
* How far before the end of the list to start loading, as an
|
|
10
|
+
* IntersectionObserver `rootMargin`. Default: 300px below the viewport.
|
|
11
|
+
*/
|
|
12
|
+
rootMargin?: string;
|
|
13
|
+
/** Stop watching, e.g. while an error is shown. */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Infinite scrolling for a list (BOFF-15331): put the returned ref on an
|
|
18
|
+
* element after the last item, and the next page loads as that element comes
|
|
19
|
+
* near the viewport.
|
|
20
|
+
*
|
|
21
|
+
* - One request at a time: nothing is watched while `loading` is true.
|
|
22
|
+
* - Short pages keep loading: when a page finishes and the end of the list is
|
|
23
|
+
* still in view, the next page loads too, so a page that does not fill the
|
|
24
|
+
* screen never leaves the list stuck.
|
|
25
|
+
* - Nothing happens once `hasMore` is false, or where IntersectionObserver is
|
|
26
|
+
* missing; render a "Load more" button as well for that case and for
|
|
27
|
+
* keyboard users.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* const endRef = useInfiniteScroll({ hasMore, loading: isLoadingMore, onLoadMore: loadMore });
|
|
32
|
+
* return (
|
|
33
|
+
* <>
|
|
34
|
+
* {items.map((item) => <Row key={item.id} item={item} />)}
|
|
35
|
+
* <div ref={endRef} aria-hidden="true" />
|
|
36
|
+
* </>
|
|
37
|
+
* );
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function useInfiniteScroll({ hasMore, loading, onLoadMore, rootMargin, disabled, }: UseInfiniteScrollOptions): (element: Element | null) => void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useEffect as e, useLayoutEffect as t, useRef as n, useState as r } from "react";
|
|
2
|
+
// src/shared/hooks/useInfiniteScroll.ts
|
|
3
|
+
var i = typeof window > "u" ? e : t;
|
|
4
|
+
function a({ hasMore: t, loading: a, onLoadMore: o, rootMargin: s = "0px 0px 300px 0px", disabled: c = !1 }) {
|
|
5
|
+
let [l, u] = r(null), d = n({
|
|
6
|
+
onLoadMore: o,
|
|
7
|
+
hasMore: t,
|
|
8
|
+
loading: a,
|
|
9
|
+
disabled: c
|
|
10
|
+
});
|
|
11
|
+
return i(() => {
|
|
12
|
+
d.current = {
|
|
13
|
+
onLoadMore: o,
|
|
14
|
+
hasMore: t,
|
|
15
|
+
loading: a,
|
|
16
|
+
disabled: c
|
|
17
|
+
};
|
|
18
|
+
}, [
|
|
19
|
+
o,
|
|
20
|
+
t,
|
|
21
|
+
a,
|
|
22
|
+
c
|
|
23
|
+
]), e(() => {
|
|
24
|
+
if (!l || c || !t || a || typeof IntersectionObserver > "u") return;
|
|
25
|
+
let e = !0, n = new IntersectionObserver((t) => {
|
|
26
|
+
if (!e || !t.some((e) => e.isIntersecting)) return;
|
|
27
|
+
let r = d.current;
|
|
28
|
+
r.loading || !r.hasMore || r.disabled || (e = !1, n.disconnect(), r.onLoadMore());
|
|
29
|
+
}, { rootMargin: s });
|
|
30
|
+
return n.observe(l), () => {
|
|
31
|
+
e = !1, n.disconnect();
|
|
32
|
+
};
|
|
33
|
+
}, [
|
|
34
|
+
l,
|
|
35
|
+
t,
|
|
36
|
+
a,
|
|
37
|
+
c,
|
|
38
|
+
s
|
|
39
|
+
]), u;
|
|
40
|
+
}
|
|
41
|
+
export { a as useInfiniteScroll };
|