@streamscloud/kit 0.94.7 → 0.94.9
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.
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script lang="ts">import { on as listen } from 'svelte/events';
|
|
2
|
+
const { elevation = 'flat', padding = 'md', header, footer, children, on } = $props();
|
|
2
3
|
const interactive = $derived(!!on?.click);
|
|
3
|
-
|
|
4
|
+
const contentId = $props.id();
|
|
5
|
+
const forwardClicks = (element) => listen(element, 'click', () => on?.click?.());
|
|
4
6
|
</script>
|
|
5
7
|
|
|
6
|
-
{
|
|
8
|
+
<div class="card card--{elevation} card--pad-{padding}" class:card--interactive={interactive} {@attach interactive && forwardClicks}>
|
|
9
|
+
{#if interactive}
|
|
10
|
+
<button type="button" class="card__activator" aria-labelledby={contentId}></button>
|
|
11
|
+
{/if}
|
|
7
12
|
{#if header}<div class="card__header">{@render header()}</div>{/if}
|
|
8
|
-
<div class="card__body">{@render children()}</div>
|
|
13
|
+
<div id={contentId} class="card__body">{@render children()}</div>
|
|
9
14
|
{#if footer}<div class="card__footer">{@render footer()}</div>{/if}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{#if interactive}
|
|
13
|
-
<button type="button" class="card card--{elevation} card--pad-{padding} card--interactive" onclick={() => on?.click?.()}>
|
|
14
|
-
{@render inner()}
|
|
15
|
-
</button>
|
|
16
|
-
{:else}
|
|
17
|
-
<div class="card card--{elevation} card--pad-{padding}">
|
|
18
|
-
{@render inner()}
|
|
19
|
-
</div>
|
|
20
|
-
{/if}
|
|
15
|
+
</div>
|
|
21
16
|
|
|
22
17
|
<!--
|
|
23
18
|
@component
|
|
24
19
|
Container surface with border, panel background, and rounded corners. Optional `header` and `footer`
|
|
25
|
-
snippets render in chrome with their own dividers. Pass `on.click` to
|
|
26
|
-
|
|
20
|
+
snippets render in chrome with their own dividers. Pass `on.click` to make the whole card a clickable
|
|
21
|
+
target with hover and focus state; controls inside it (a `Checkbox`, links) keep working.
|
|
27
22
|
When a parent stretches the card (a grid row, a flex row), the body takes the free height, so body
|
|
28
23
|
content with `block-size: 100%` can pin its own bottom row.
|
|
29
24
|
|
|
@@ -32,10 +27,10 @@ content with `block-size: 100%` can pin its own bottom row.
|
|
|
32
27
|
|---|---|---|
|
|
33
28
|
| `--sc-kit--card--background` | Body background | `var(--sc-kit--color--bg--panel)` |
|
|
34
29
|
| `--sc-kit--card--border-color` | Border color | `var(--sc-kit--color--border)` |
|
|
35
|
-
| `--sc-kit--card--border-color--hover` | Border color
|
|
30
|
+
| `--sc-kit--card--border-color--hover` | Border color of a clickable card on hover | `var(--sc-kit--color--border--strong)` |
|
|
36
31
|
| `--sc-kit--card--border-radius` | Border radius | `var(--sc-kit--radius--lg)` |
|
|
37
32
|
| `--sc-kit--card--shadow` | Box-shadow on `elevation='raised'` | `var(--sc-kit--shadow--md)` |
|
|
38
|
-
| `--sc-kit--card--shadow--hover` | Box-shadow
|
|
33
|
+
| `--sc-kit--card--shadow--hover` | Box-shadow of a clickable card on hover | `var(--sc-kit--shadow--sm)` |
|
|
39
34
|
| `--sc-kit--card--color` | Body text color | `var(--sc-kit--color--text--primary)` |
|
|
40
35
|
| `--sc-kit--card--header--background` | Header bar background | `transparent` |
|
|
41
36
|
| `--sc-kit--card--header--border-color` | Header bottom divider | `var(--sc-kit--color--border)` |
|
|
@@ -107,16 +102,24 @@ content with `block-size: 100%` can pin its own bottom row.
|
|
|
107
102
|
border-top: 1px solid var(--_card--footer-border-color);
|
|
108
103
|
}
|
|
109
104
|
.card--interactive {
|
|
105
|
+
position: relative;
|
|
110
106
|
cursor: pointer;
|
|
111
|
-
font-family: inherit;
|
|
112
|
-
font-size: inherit;
|
|
113
107
|
transition: border-color var(--sc-kit--duration--base) var(--sc-kit--ease--default), box-shadow var(--sc-kit--duration--base) var(--sc-kit--ease--default);
|
|
114
108
|
}
|
|
115
109
|
.card--interactive:hover {
|
|
116
110
|
--sc-kit--card--border-color: var(--_card--border-color-hover);
|
|
117
111
|
box-shadow: var(--_card--shadow-hover);
|
|
118
112
|
}
|
|
119
|
-
.
|
|
113
|
+
.card__activator {
|
|
114
|
+
position: absolute;
|
|
115
|
+
inset: 0;
|
|
116
|
+
padding: 0;
|
|
117
|
+
background: transparent;
|
|
118
|
+
border: none;
|
|
119
|
+
border-radius: inherit;
|
|
120
|
+
pointer-events: none;
|
|
121
|
+
}
|
|
122
|
+
.card__activator:focus-visible {
|
|
120
123
|
outline: 2px solid var(--sc-kit--color--border--focus);
|
|
121
|
-
outline-offset: 2px;
|
|
124
|
+
outline-offset: -2px;
|
|
122
125
|
}</style>
|
|
@@ -10,8 +10,9 @@ type Props = {
|
|
|
10
10
|
footer?: Snippet;
|
|
11
11
|
children: Snippet;
|
|
12
12
|
/**
|
|
13
|
-
* Presence of `on.click`
|
|
14
|
-
*
|
|
13
|
+
* Presence of `on.click` makes the whole card clickable, with hover/focus states and a keyboard-reachable
|
|
14
|
+
* activator button. Interactive content inside keeps working; a nested control that must not also
|
|
15
|
+
* trigger the card stops propagation of its own click.
|
|
15
16
|
*/
|
|
16
17
|
on?: {
|
|
17
18
|
click?: () => void;
|
|
@@ -19,8 +20,8 @@ type Props = {
|
|
|
19
20
|
};
|
|
20
21
|
/**
|
|
21
22
|
* Container surface with border, panel background, and rounded corners. Optional `header` and `footer`
|
|
22
|
-
* snippets render in chrome with their own dividers. Pass `on.click` to
|
|
23
|
-
*
|
|
23
|
+
* snippets render in chrome with their own dividers. Pass `on.click` to make the whole card a clickable
|
|
24
|
+
* target with hover and focus state; controls inside it (a `Checkbox`, links) keep working.
|
|
24
25
|
* When a parent stretches the card (a grid row, a flex row), the body takes the free height, so body
|
|
25
26
|
* content with `block-size: 100%` can pin its own bottom row.
|
|
26
27
|
*
|
|
@@ -29,10 +30,10 @@ type Props = {
|
|
|
29
30
|
* |---|---|---|
|
|
30
31
|
* | `--sc-kit--card--background` | Body background | `var(--sc-kit--color--bg--panel)` |
|
|
31
32
|
* | `--sc-kit--card--border-color` | Border color | `var(--sc-kit--color--border)` |
|
|
32
|
-
* | `--sc-kit--card--border-color--hover` | Border color
|
|
33
|
+
* | `--sc-kit--card--border-color--hover` | Border color of a clickable card on hover | `var(--sc-kit--color--border--strong)` |
|
|
33
34
|
* | `--sc-kit--card--border-radius` | Border radius | `var(--sc-kit--radius--lg)` |
|
|
34
35
|
* | `--sc-kit--card--shadow` | Box-shadow on `elevation='raised'` | `var(--sc-kit--shadow--md)` |
|
|
35
|
-
* | `--sc-kit--card--shadow--hover` | Box-shadow
|
|
36
|
+
* | `--sc-kit--card--shadow--hover` | Box-shadow of a clickable card on hover | `var(--sc-kit--shadow--sm)` |
|
|
36
37
|
* | `--sc-kit--card--color` | Body text color | `var(--sc-kit--color--text--primary)` |
|
|
37
38
|
* | `--sc-kit--card--header--background` | Header bar background | `transparent` |
|
|
38
39
|
* | `--sc-kit--card--header--border-color` | Header bottom divider | `var(--sc-kit--color--border)` |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">import { Button } from '../button';
|
|
2
2
|
import { Spinner } from '../spinner';
|
|
3
3
|
import { InfiniteScrollLocalization } from './infinite-scroll-localization';
|
|
4
|
-
let { loadMore, container = null, rootMargin = '200px', children, showLoading = false, loading, retry } = $props();
|
|
4
|
+
let { loadMore, container = null, rootMargin = '200px', direction = 'down', children, showLoading = false, loading, retry } = $props();
|
|
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);
|
|
@@ -52,17 +52,13 @@ const onRetry = () => {
|
|
|
52
52
|
};
|
|
53
53
|
</script>
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
<div class="infinite-scroll__items" bind:this={itemsContainer}>
|
|
57
|
-
{@render children()}
|
|
58
|
-
</div>
|
|
59
|
-
|
|
55
|
+
{#snippet loadingEnd()}
|
|
60
56
|
<div class="infinite-scroll__pagination-trigger" bind:this={paginationTrigger}></div>
|
|
61
57
|
{#if isLoading}
|
|
62
58
|
{#if loading}
|
|
63
59
|
{@render loading()}
|
|
64
60
|
{:else if showLoading}
|
|
65
|
-
<div class="infinite-scroll__loading-container">
|
|
61
|
+
<div class="infinite-scroll__loading-container" class:infinite-scroll__loading-container--up={direction === 'up'}>
|
|
66
62
|
<Spinner timeout={500} />
|
|
67
63
|
</div>
|
|
68
64
|
{/if}
|
|
@@ -75,6 +71,20 @@ const onRetry = () => {
|
|
|
75
71
|
</div>
|
|
76
72
|
{/if}
|
|
77
73
|
{/if}
|
|
74
|
+
{/snippet}
|
|
75
|
+
|
|
76
|
+
<div class="infinite-scroll" class:infinite-scroll--up={direction === 'up'}>
|
|
77
|
+
{#if direction === 'up'}
|
|
78
|
+
{@render loadingEnd()}
|
|
79
|
+
{/if}
|
|
80
|
+
|
|
81
|
+
<div class="infinite-scroll__items" bind:this={itemsContainer}>
|
|
82
|
+
{@render children()}
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
{#if direction === 'down'}
|
|
86
|
+
{@render loadingEnd()}
|
|
87
|
+
{/if}
|
|
78
88
|
</div>
|
|
79
89
|
|
|
80
90
|
<!--
|
|
@@ -85,11 +95,13 @@ Pairs with `core/data-loaders` (`CursorDataLoader`, `PageDataLoader`, `CursorDat
|
|
|
85
95
|
|
|
86
96
|
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
97
|
|
|
98
|
+
The component never reorders anything: it renders `children` as given and only decides on which side of them the sentinel sits. With `direction="up"` the consumer renders oldest → newest (a newest-first loader's items reversed) inside a scroll container set to `display: flex; flex-direction: column-reverse` with this component as its only child. Such a container scrolls from the bottom, so the list opens at its end, batches added above leave the view where it was, and a reader at the end keeps seeing new items appended below.
|
|
99
|
+
|
|
88
100
|
### CSS Custom Properties
|
|
89
101
|
| Property | Description | Default |
|
|
90
102
|
|---|---|---|
|
|
91
103
|
| `--sc-kit--infinite-scroll--display` | Display mode for root and items container | `block` |
|
|
92
|
-
| `--sc-kit--infinite-scroll--flex` | Flex shorthand for root and items container | `initial` |
|
|
104
|
+
| `--sc-kit--infinite-scroll--flex` | Flex shorthand for root and items container | `initial`; `none` with `direction="up"` |
|
|
93
105
|
| `--sc-kit--infinite-scroll--overflow-y` | Vertical overflow behavior | `initial` |
|
|
94
106
|
-->
|
|
95
107
|
|
|
@@ -105,6 +117,9 @@ Passing the loader itself — `loadMore={loader}` instead of `loadMore={loader.l
|
|
|
105
117
|
position: relative;
|
|
106
118
|
width: 100%;
|
|
107
119
|
}
|
|
120
|
+
.infinite-scroll--up {
|
|
121
|
+
--_infinite-scroll--flex: var(--sc-kit--infinite-scroll--flex, none);
|
|
122
|
+
}
|
|
108
123
|
.infinite-scroll__items {
|
|
109
124
|
display: var(--_infinite-scroll--display);
|
|
110
125
|
flex-direction: column;
|
|
@@ -119,6 +134,10 @@ Passing the loader itself — `loadMore={loader}` instead of `loadMore={loader.l
|
|
|
119
134
|
left: 50%;
|
|
120
135
|
transform: translateX(-50%);
|
|
121
136
|
}
|
|
137
|
+
.infinite-scroll__loading-container--up {
|
|
138
|
+
top: 0.3125em;
|
|
139
|
+
bottom: auto;
|
|
140
|
+
}
|
|
122
141
|
.infinite-scroll__retry {
|
|
123
142
|
display: flex;
|
|
124
143
|
justify-content: center;
|
|
@@ -13,8 +13,14 @@ type Props = {
|
|
|
13
13
|
loadMore: LoadMoreSource;
|
|
14
14
|
/** Scroll ancestor used as the IntersectionObserver root. Required when the viewport differs from the scrolling container. */
|
|
15
15
|
container?: HTMLElement | null;
|
|
16
|
-
/** IntersectionObserver `rootMargin`. Default `'200px'` — fires the load
|
|
16
|
+
/** IntersectionObserver `rootMargin`. Default `'200px'` — fires the load that far before the reader reaches the loading end. */
|
|
17
17
|
rootMargin?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Which end of the list loads more. `'up'` puts the sentinel above the items for a newest-at-the-bottom history; the scroll container must be a
|
|
20
|
+
* `column-reverse` flex box with this component as its only child, so it starts at the end and keeps the view in place as batches land above.
|
|
21
|
+
* @default 'down'
|
|
22
|
+
*/
|
|
23
|
+
direction?: 'down' | 'up';
|
|
18
24
|
children: Snippet;
|
|
19
25
|
/** Shows the kit `Spinner` while a batch loads. Off by default — the list owner usually renders its own loading state. */
|
|
20
26
|
showLoading?: boolean;
|
|
@@ -30,11 +36,13 @@ type Props = {
|
|
|
30
36
|
*
|
|
31
37
|
* 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
38
|
*
|
|
39
|
+
* The component never reorders anything: it renders `children` as given and only decides on which side of them the sentinel sits. With `direction="up"` the consumer renders oldest → newest (a newest-first loader's items reversed) inside a scroll container set to `display: flex; flex-direction: column-reverse` with this component as its only child. Such a container scrolls from the bottom, so the list opens at its end, batches added above leave the view where it was, and a reader at the end keeps seeing new items appended below.
|
|
40
|
+
*
|
|
33
41
|
* ### CSS Custom Properties
|
|
34
42
|
* | Property | Description | Default |
|
|
35
43
|
* |---|---|---|
|
|
36
44
|
* | `--sc-kit--infinite-scroll--display` | Display mode for root and items container | `block` |
|
|
37
|
-
* | `--sc-kit--infinite-scroll--flex` | Flex shorthand for root and items container | `initial` |
|
|
45
|
+
* | `--sc-kit--infinite-scroll--flex` | Flex shorthand for root and items container | `initial`; `none` with `direction="up"` |
|
|
38
46
|
* | `--sc-kit--infinite-scroll--overflow-y` | Vertical overflow behavior | `initial` |
|
|
39
47
|
*/
|
|
40
48
|
declare const Cmp: import("svelte").Component<Props, {}, "">;
|