@streamscloud/kit 0.94.8 → 0.95.0
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.
|
@@ -5,6 +5,7 @@ let { loadMore, container = null, rootMargin = '200px', children, showLoading =
|
|
|
5
5
|
const localization = new InfiniteScrollLocalization();
|
|
6
6
|
const source = $derived(typeof loadMore === 'function' ? { loadMore, failed: false, canLoadMore: true } : loadMore);
|
|
7
7
|
let isLoading = $state(false);
|
|
8
|
+
let root = $state(null);
|
|
8
9
|
let paginationTrigger = $state(null);
|
|
9
10
|
let itemsContainer = $state(null);
|
|
10
11
|
$effect(() => {
|
|
@@ -20,7 +21,7 @@ $effect(() => {
|
|
|
20
21
|
void onLoadMore();
|
|
21
22
|
}
|
|
22
23
|
}, {
|
|
23
|
-
root: container,
|
|
24
|
+
root: container === 'self' ? root : container,
|
|
24
25
|
rootMargin
|
|
25
26
|
});
|
|
26
27
|
// Re-observe trigger on container resize to force IntersectionObserver
|
|
@@ -52,7 +53,7 @@ const onRetry = () => {
|
|
|
52
53
|
};
|
|
53
54
|
</script>
|
|
54
55
|
|
|
55
|
-
<div class="infinite-scroll">
|
|
56
|
+
<div class="infinite-scroll" bind:this={root}>
|
|
56
57
|
<div class="infinite-scroll__items" bind:this={itemsContainer}>
|
|
57
58
|
{@render children()}
|
|
58
59
|
</div>
|
|
@@ -85,20 +86,24 @@ Pairs with `core/data-loaders` (`CursorDataLoader`, `PageDataLoader`, `CursorDat
|
|
|
85
86
|
|
|
86
87
|
Passing the loader itself — `loadMore={loader}` instead of `loadMore={loader.loadMore}` — disarms the sentinel while the loader reports `failed`, so a failing backend is not asked again on its own and the already-loaded list is kept. The manual continue appears only when the loader can still continue (`resumeAfterFailure`); a loader that closed its list on the failure ends silently, as it does at the natural end. A successful retry re-arms the sentinel on its own.
|
|
87
88
|
|
|
89
|
+
A history that loads upward (a chat) makes the component its own scroller laid out bottom-up: `display: flex`, `flex-direction: column-reverse`, `overflow-y: auto` through the properties below, with `container="self"`. The sentinel then sits at the top, the list opens at its end, older batches keep the view in place, and a reader at the end follows new items. The children keep their own order — lay them out bottom-up too to pass them newest first. The built-in `showLoading` spinner stays at the bottom edge; pass a `loading` snippet instead, which sits next to the sentinel.
|
|
90
|
+
|
|
88
91
|
### CSS Custom Properties
|
|
89
92
|
| Property | Description | Default |
|
|
90
93
|
|---|---|---|
|
|
91
94
|
| `--sc-kit--infinite-scroll--display` | Display mode for root and items container | `block` |
|
|
92
95
|
| `--sc-kit--infinite-scroll--flex` | Flex shorthand for root and items container | `initial` |
|
|
96
|
+
| `--sc-kit--infinite-scroll--flex-direction` | Flex direction of the root (`column-reverse` puts the sentinel on top) | `column` |
|
|
93
97
|
| `--sc-kit--infinite-scroll--overflow-y` | Vertical overflow behavior | `initial` |
|
|
94
98
|
-->
|
|
95
99
|
|
|
96
100
|
<style>.infinite-scroll {
|
|
97
101
|
--_infinite-scroll--display: var(--sc-kit--infinite-scroll--display, block);
|
|
98
102
|
--_infinite-scroll--flex: var(--sc-kit--infinite-scroll--flex, initial);
|
|
103
|
+
--_infinite-scroll--flex-direction: var(--sc-kit--infinite-scroll--flex-direction, column);
|
|
99
104
|
--_infinite-scroll--overflow-y: var(--sc-kit--infinite-scroll--overflow-y, initial);
|
|
100
105
|
display: var(--_infinite-scroll--display);
|
|
101
|
-
flex-direction:
|
|
106
|
+
flex-direction: var(--_infinite-scroll--flex-direction);
|
|
102
107
|
flex: var(--_infinite-scroll--flex);
|
|
103
108
|
overflow-y: var(--_infinite-scroll--overflow-y);
|
|
104
109
|
min-height: 2.625em;
|
|
@@ -11,12 +11,19 @@ type Props = {
|
|
|
11
11
|
* and leaves the sentinel armed through every failure.
|
|
12
12
|
*/
|
|
13
13
|
loadMore: LoadMoreSource;
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
/**
|
|
15
|
+
* The scrolling element `rootMargin` is measured against: a scroll ancestor, `'self'` when this component scrolls on its own
|
|
16
|
+
* (`--sc-kit--infinite-scroll--overflow-y`), or `null` for the viewport.
|
|
17
|
+
* @default null
|
|
18
|
+
*/
|
|
19
|
+
container?: HTMLElement | 'self' | null;
|
|
20
|
+
/** IntersectionObserver `rootMargin`. Default `'200px'` — fires the load that far before the reader reaches the sentinel. */
|
|
17
21
|
rootMargin?: string;
|
|
18
22
|
children: Snippet;
|
|
19
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Shows the kit `Spinner` while a batch loads, pinned to the root's bottom edge whatever the flex direction — a list loading at the top passes
|
|
25
|
+
* `loading` instead. Off by default — the list owner usually renders its own loading state.
|
|
26
|
+
*/
|
|
20
27
|
showLoading?: boolean;
|
|
21
28
|
/** Custom loading indicator snippet. Passing it turns the indicator on regardless of `showLoading`. */
|
|
22
29
|
loading?: Snippet;
|
|
@@ -30,11 +37,14 @@ type Props = {
|
|
|
30
37
|
*
|
|
31
38
|
* Passing the loader itself — `loadMore={loader}` instead of `loadMore={loader.loadMore}` — disarms the sentinel while the loader reports `failed`, so a failing backend is not asked again on its own and the already-loaded list is kept. The manual continue appears only when the loader can still continue (`resumeAfterFailure`); a loader that closed its list on the failure ends silently, as it does at the natural end. A successful retry re-arms the sentinel on its own.
|
|
32
39
|
*
|
|
40
|
+
* A history that loads upward (a chat) makes the component its own scroller laid out bottom-up: `display: flex`, `flex-direction: column-reverse`, `overflow-y: auto` through the properties below, with `container="self"`. The sentinel then sits at the top, the list opens at its end, older batches keep the view in place, and a reader at the end follows new items. The children keep their own order — lay them out bottom-up too to pass them newest first. The built-in `showLoading` spinner stays at the bottom edge; pass a `loading` snippet instead, which sits next to the sentinel.
|
|
41
|
+
*
|
|
33
42
|
* ### CSS Custom Properties
|
|
34
43
|
* | Property | Description | Default |
|
|
35
44
|
* |---|---|---|
|
|
36
45
|
* | `--sc-kit--infinite-scroll--display` | Display mode for root and items container | `block` |
|
|
37
46
|
* | `--sc-kit--infinite-scroll--flex` | Flex shorthand for root and items container | `initial` |
|
|
47
|
+
* | `--sc-kit--infinite-scroll--flex-direction` | Flex direction of the root (`column-reverse` puts the sentinel on top) | `column` |
|
|
38
48
|
* | `--sc-kit--infinite-scroll--overflow-y` | Vertical overflow behavior | `initial` |
|
|
39
49
|
*/
|
|
40
50
|
declare const Cmp: import("svelte").Component<Props, {}, "">;
|