@x33025/sveltely 0.1.8 → 0.1.10
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/components/Library/Floating/Floating.svelte +6 -7
- package/dist/components/Library/Grid/Grid.svelte +24 -15
- package/dist/components/Library/Grid/Grid.svelte.d.ts +2 -1
- package/dist/components/Library/GridItem/GridItem.svelte +16 -16
- package/dist/components/Library/GridItem/GridItem.svelte.d.ts +2 -1
- package/dist/components/Library/HStack/HStack.svelte +12 -6
- package/dist/components/Library/HStack/HStack.svelte.d.ts +2 -1
- package/dist/components/Library/Loader/Loader.demo.svelte +14 -14
- package/dist/components/Library/ScrollView/ScrollView.svelte +12 -2
- package/dist/components/Library/ScrollView/ScrollView.svelte.d.ts +2 -1
- package/dist/components/Library/VStack/VStack.svelte +12 -6
- package/dist/components/Library/VStack/VStack.svelte.d.ts +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/style/loader.d.ts +9 -0
- package/dist/style/loader.js +21 -0
- package/package.json +1 -1
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
-
function
|
|
306
|
+
function handleOutsidePointerDown(event: PointerEvent) {
|
|
307
307
|
if (!open) return;
|
|
308
308
|
if (isEventInFloatingTree(event)) return;
|
|
309
309
|
closePanel();
|
|
@@ -316,6 +316,7 @@
|
|
|
316
316
|
|
|
317
317
|
function handlePointerMove(event: MouseEvent) {
|
|
318
318
|
if (!closeOnPointerLeave) return;
|
|
319
|
+
if (!parentFloatingId) return;
|
|
319
320
|
if (!open || !triggerEl || !panelEl) return;
|
|
320
321
|
if (isEventInFloatingTree(event)) return;
|
|
321
322
|
if (hasOpenChild(floatingId)) return;
|
|
@@ -323,10 +324,10 @@
|
|
|
323
324
|
const pointer = { x: event.clientX, y: event.clientY };
|
|
324
325
|
const triggerRect = triggerEl.getBoundingClientRect();
|
|
325
326
|
const floatingRect = panelEl.getBoundingClientRect();
|
|
326
|
-
const safePolygon = getSafePolygon(triggerRect, floatingRect, resolvedAnchor);
|
|
327
327
|
|
|
328
328
|
if (isInsideRect(triggerRect, pointer.x, pointer.y)) return;
|
|
329
329
|
if (isInsideRect(floatingRect, pointer.x, pointer.y)) return;
|
|
330
|
+
const safePolygon = getSafePolygon(triggerRect, floatingRect, resolvedAnchor);
|
|
330
331
|
if (pointInPolygon(pointer, safePolygon)) return;
|
|
331
332
|
|
|
332
333
|
closePanel();
|
|
@@ -343,9 +344,11 @@
|
|
|
343
344
|
if (event.type === 'scroll' && isEventInFloatingTree(event)) return;
|
|
344
345
|
closePanel();
|
|
345
346
|
};
|
|
347
|
+
window.addEventListener('pointerdown', handleOutsidePointerDown, true);
|
|
346
348
|
window.addEventListener('scroll', handleWindowChange, true);
|
|
347
349
|
window.addEventListener('resize', handleWindowChange);
|
|
348
350
|
return () => {
|
|
351
|
+
window.removeEventListener('pointerdown', handleOutsidePointerDown, true);
|
|
349
352
|
window.removeEventListener('scroll', handleWindowChange, true);
|
|
350
353
|
window.removeEventListener('resize', handleWindowChange);
|
|
351
354
|
};
|
|
@@ -368,11 +371,7 @@
|
|
|
368
371
|
});
|
|
369
372
|
</script>
|
|
370
373
|
|
|
371
|
-
<svelte:window
|
|
372
|
-
onclick={handleOutsideClick}
|
|
373
|
-
onkeydown={handleEscape}
|
|
374
|
-
onmousemove={handlePointerMove}
|
|
375
|
-
/>
|
|
374
|
+
<svelte:window onkeydown={handleEscape} onmousemove={handlePointerMove} />
|
|
376
375
|
|
|
377
376
|
<div
|
|
378
377
|
bind:this={rootEl}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import { loader as loaderAction } from '../../../actions/loader';
|
|
4
|
+
import { extractLoaderProps, resolveLoaderOptions, type LoaderProps } from '../../../style/loader';
|
|
3
5
|
import { extractLayoutProps, layoutStyle, type LayoutProps } from '../../../style/layout';
|
|
4
6
|
import { extractStyleProps, surfaceStyle, type StyleProps } from '../../../style/surface';
|
|
5
7
|
|
|
@@ -10,27 +12,30 @@
|
|
|
10
12
|
autoRows?: number | string;
|
|
11
13
|
dense?: boolean;
|
|
12
14
|
} & LayoutProps &
|
|
13
|
-
StyleProps
|
|
15
|
+
StyleProps &
|
|
16
|
+
LoaderProps;
|
|
14
17
|
|
|
15
|
-
let {
|
|
16
|
-
children,
|
|
17
|
-
columns = 1,
|
|
18
|
-
rows,
|
|
19
|
-
autoRows,
|
|
20
|
-
dense = false,
|
|
21
|
-
...restProps
|
|
22
|
-
}: Props = $props();
|
|
18
|
+
let { children, columns = 1, rows, autoRows, dense = false, ...restProps }: Props = $props();
|
|
23
19
|
|
|
24
|
-
const
|
|
20
|
+
const extractedLoaderProps = $derived.by(() => extractLoaderProps(restProps));
|
|
21
|
+
const loaderProps = $derived(extractedLoaderProps.loaderProps);
|
|
22
|
+
const afterLoaderProps = $derived(extractedLoaderProps.restProps);
|
|
23
|
+
const loaderOptions = $derived.by(() => resolveLoaderOptions(loaderProps));
|
|
24
|
+
const extractedLayoutProps = $derived.by(() => extractLayoutProps(afterLoaderProps));
|
|
25
25
|
const layoutProps = $derived(extractedLayoutProps.layoutProps);
|
|
26
26
|
const afterLayoutProps = $derived(extractedLayoutProps.restProps);
|
|
27
27
|
const extractedStyleProps = $derived.by(() => extractStyleProps(afterLayoutProps));
|
|
28
28
|
const styleProps = $derived(extractedStyleProps.styleProps);
|
|
29
|
+
const props = $derived(extractedStyleProps.restProps);
|
|
29
30
|
const templateColumns = $derived(
|
|
30
31
|
typeof columns === 'number' ? `repeat(${columns}, minmax(0, 1fr))` : columns
|
|
31
32
|
);
|
|
32
33
|
const templateRows = $derived(
|
|
33
|
-
rows === undefined
|
|
34
|
+
rows === undefined
|
|
35
|
+
? undefined
|
|
36
|
+
: typeof rows === 'number'
|
|
37
|
+
? `repeat(${rows}, minmax(0, 1fr))`
|
|
38
|
+
: rows
|
|
34
39
|
);
|
|
35
40
|
const gridAutoRows = $derived(
|
|
36
41
|
autoRows === undefined ? undefined : typeof autoRows === 'number' ? `${autoRows}rem` : autoRows
|
|
@@ -48,7 +53,13 @@
|
|
|
48
53
|
);
|
|
49
54
|
</script>
|
|
50
55
|
|
|
51
|
-
<div
|
|
56
|
+
<div
|
|
57
|
+
class="grid"
|
|
58
|
+
class:grid-dense={dense}
|
|
59
|
+
style={rootStyle}
|
|
60
|
+
{...props}
|
|
61
|
+
use:loaderAction={loaderOptions}
|
|
62
|
+
>
|
|
52
63
|
{#if children}
|
|
53
64
|
{@render children()}
|
|
54
65
|
{/if}
|
|
@@ -62,9 +73,7 @@
|
|
|
62
73
|
align-items: stretch;
|
|
63
74
|
gap: var(--grid-gap, 0px);
|
|
64
75
|
border-radius: var(--grid-border-radius, 0px);
|
|
65
|
-
padding:
|
|
66
|
-
var(--grid-padding-y, 0px)
|
|
67
|
-
var(--grid-padding-x, 0px);
|
|
76
|
+
padding: var(--grid-padding-y, 0px) var(--grid-padding-x, 0px);
|
|
68
77
|
font-size: var(--grid-font-size, inherit);
|
|
69
78
|
}
|
|
70
79
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type LoaderProps } from '../../../style/loader';
|
|
2
3
|
import { type LayoutProps } from '../../../style/layout';
|
|
3
4
|
import { type StyleProps } from '../../../style/surface';
|
|
4
5
|
type Props = {
|
|
@@ -7,7 +8,7 @@ type Props = {
|
|
|
7
8
|
rows?: number | string;
|
|
8
9
|
autoRows?: number | string;
|
|
9
10
|
dense?: boolean;
|
|
10
|
-
} & LayoutProps & StyleProps;
|
|
11
|
+
} & LayoutProps & StyleProps & LoaderProps;
|
|
11
12
|
declare const Grid: import("svelte").Component<Props, {}, "">;
|
|
12
13
|
type Grid = ReturnType<typeof Grid>;
|
|
13
14
|
export default Grid;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import { loader as loaderAction } from '../../../actions/loader';
|
|
4
|
+
import { extractLoaderProps, resolveLoaderOptions, type LoaderProps } from '../../../style/loader';
|
|
3
5
|
import { extractLayoutProps, layoutStyle, type LayoutProps } from '../../../style/layout';
|
|
4
6
|
import { extractStyleProps, surfaceStyle, type StyleProps } from '../../../style/surface';
|
|
5
7
|
|
|
@@ -11,23 +13,21 @@
|
|
|
11
13
|
rowSpan?: number;
|
|
12
14
|
area?: string;
|
|
13
15
|
} & LayoutProps &
|
|
14
|
-
StyleProps
|
|
16
|
+
StyleProps &
|
|
17
|
+
LoaderProps;
|
|
15
18
|
|
|
16
|
-
let {
|
|
17
|
-
children,
|
|
18
|
-
column,
|
|
19
|
-
row,
|
|
20
|
-
columnSpan,
|
|
21
|
-
rowSpan,
|
|
22
|
-
area,
|
|
23
|
-
...restProps
|
|
24
|
-
}: Props = $props();
|
|
19
|
+
let { children, column, row, columnSpan, rowSpan, area, ...restProps }: Props = $props();
|
|
25
20
|
|
|
26
|
-
const
|
|
21
|
+
const extractedLoaderProps = $derived.by(() => extractLoaderProps(restProps));
|
|
22
|
+
const loaderProps = $derived(extractedLoaderProps.loaderProps);
|
|
23
|
+
const afterLoaderProps = $derived(extractedLoaderProps.restProps);
|
|
24
|
+
const loaderOptions = $derived.by(() => resolveLoaderOptions(loaderProps));
|
|
25
|
+
const extractedLayoutProps = $derived.by(() => extractLayoutProps(afterLoaderProps));
|
|
27
26
|
const layoutProps = $derived(extractedLayoutProps.layoutProps);
|
|
28
27
|
const afterLayoutProps = $derived(extractedLayoutProps.restProps);
|
|
29
28
|
const extractedStyleProps = $derived.by(() => extractStyleProps(afterLayoutProps));
|
|
30
29
|
const styleProps = $derived(extractedStyleProps.styleProps);
|
|
30
|
+
const props = $derived(extractedStyleProps.restProps);
|
|
31
31
|
const rootStyle = $derived.by(() =>
|
|
32
32
|
[
|
|
33
33
|
column !== undefined ? `grid-column: ${column};` : '',
|
|
@@ -35,7 +35,9 @@
|
|
|
35
35
|
column === undefined && columnSpan !== undefined
|
|
36
36
|
? `grid-column: span ${columnSpan} / span ${columnSpan};`
|
|
37
37
|
: '',
|
|
38
|
-
row === undefined && rowSpan !== undefined
|
|
38
|
+
row === undefined && rowSpan !== undefined
|
|
39
|
+
? `grid-row: span ${rowSpan} / span ${rowSpan};`
|
|
40
|
+
: '',
|
|
39
41
|
area !== undefined ? `grid-area: ${area};` : '',
|
|
40
42
|
layoutStyle(layoutProps),
|
|
41
43
|
surfaceStyle(styleProps, 'grid-item')
|
|
@@ -45,7 +47,7 @@
|
|
|
45
47
|
);
|
|
46
48
|
</script>
|
|
47
49
|
|
|
48
|
-
<div class="grid-item" style={rootStyle}>
|
|
50
|
+
<div class="grid-item" style={rootStyle} {...props} use:loaderAction={loaderOptions}>
|
|
49
51
|
{#if children}
|
|
50
52
|
{@render children()}
|
|
51
53
|
{/if}
|
|
@@ -57,9 +59,7 @@
|
|
|
57
59
|
min-height: 0;
|
|
58
60
|
height: 100%;
|
|
59
61
|
border-radius: var(--grid-item-border-radius, 0px);
|
|
60
|
-
padding:
|
|
61
|
-
var(--grid-item-padding-y, 0px)
|
|
62
|
-
var(--grid-item-padding-x, 0px);
|
|
62
|
+
padding: var(--grid-item-padding-y, 0px) var(--grid-item-padding-x, 0px);
|
|
63
63
|
font-size: var(--grid-item-font-size, inherit);
|
|
64
64
|
}
|
|
65
65
|
</style>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type LoaderProps } from '../../../style/loader';
|
|
2
3
|
import { type LayoutProps } from '../../../style/layout';
|
|
3
4
|
import { type StyleProps } from '../../../style/surface';
|
|
4
5
|
type Props = {
|
|
@@ -8,7 +9,7 @@ type Props = {
|
|
|
8
9
|
columnSpan?: number;
|
|
9
10
|
rowSpan?: number;
|
|
10
11
|
area?: string;
|
|
11
|
-
} & LayoutProps & StyleProps;
|
|
12
|
+
} & LayoutProps & StyleProps & LoaderProps;
|
|
12
13
|
declare const GridItem: import("svelte").Component<Props, {}, "">;
|
|
13
14
|
type GridItem = ReturnType<typeof GridItem>;
|
|
14
15
|
export default GridItem;
|
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import { loader as loaderAction } from '../../../actions/loader';
|
|
4
|
+
import { extractLoaderProps, resolveLoaderOptions, type LoaderProps } from '../../../style/loader';
|
|
3
5
|
import { extractLayoutProps, layoutStyle, type LayoutProps } from '../../../style/layout';
|
|
4
6
|
import { extractStyleProps, surfaceStyle, type StyleProps } from '../../../style/surface';
|
|
5
7
|
|
|
6
8
|
type Props = {
|
|
7
9
|
children?: Snippet;
|
|
8
10
|
} & LayoutProps &
|
|
9
|
-
StyleProps
|
|
11
|
+
StyleProps &
|
|
12
|
+
LoaderProps;
|
|
10
13
|
|
|
11
14
|
let { children, ...restProps }: Props = $props();
|
|
12
15
|
|
|
13
|
-
const
|
|
16
|
+
const extractedLoaderProps = $derived.by(() => extractLoaderProps(restProps));
|
|
17
|
+
const loaderProps = $derived(extractedLoaderProps.loaderProps);
|
|
18
|
+
const afterLoaderProps = $derived(extractedLoaderProps.restProps);
|
|
19
|
+
const loaderOptions = $derived.by(() => resolveLoaderOptions(loaderProps));
|
|
20
|
+
const extractedLayoutProps = $derived.by(() => extractLayoutProps(afterLoaderProps));
|
|
14
21
|
const layoutProps = $derived(extractedLayoutProps.layoutProps);
|
|
15
22
|
const afterLayoutProps = $derived(extractedLayoutProps.restProps);
|
|
16
23
|
const extractedStyleProps = $derived.by(() => extractStyleProps(afterLayoutProps));
|
|
17
24
|
const styleProps = $derived(extractedStyleProps.styleProps);
|
|
25
|
+
const props = $derived(extractedStyleProps.restProps);
|
|
18
26
|
const rootStyle = $derived.by(() =>
|
|
19
27
|
[layoutStyle(layoutProps), surfaceStyle(styleProps, 'stack')].filter(Boolean).join(' ')
|
|
20
28
|
);
|
|
21
29
|
</script>
|
|
22
30
|
|
|
23
|
-
<div class="hstack" style={rootStyle}>
|
|
31
|
+
<div class="hstack" style={rootStyle} {...props} use:loaderAction={loaderOptions}>
|
|
24
32
|
{#if children}
|
|
25
33
|
{@render children()}
|
|
26
34
|
{/if}
|
|
@@ -34,9 +42,7 @@
|
|
|
34
42
|
flex-direction: row;
|
|
35
43
|
gap: var(--stack-gap, 0px);
|
|
36
44
|
border-radius: var(--stack-border-radius, 0px);
|
|
37
|
-
padding:
|
|
38
|
-
var(--stack-padding-y, 0px)
|
|
39
|
-
var(--stack-padding-x, 0px);
|
|
45
|
+
padding: var(--stack-padding-y, 0px) var(--stack-padding-x, 0px);
|
|
40
46
|
font-size: var(--stack-font-size, inherit);
|
|
41
47
|
--divider-width: 1px;
|
|
42
48
|
--divider-height: auto;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type LoaderProps } from '../../../style/loader';
|
|
2
3
|
import { type LayoutProps } from '../../../style/layout';
|
|
3
4
|
import { type StyleProps } from '../../../style/surface';
|
|
4
5
|
type Props = {
|
|
5
6
|
children?: Snippet;
|
|
6
|
-
} & LayoutProps & StyleProps;
|
|
7
|
+
} & LayoutProps & StyleProps & LoaderProps;
|
|
7
8
|
declare const HStack: import("svelte").Component<Props, {}, "">;
|
|
8
9
|
type HStack = ReturnType<typeof HStack>;
|
|
9
10
|
export default HStack;
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
</script>
|
|
9
9
|
|
|
10
10
|
<script lang="ts">
|
|
11
|
-
import { loader } from '../../../actions/loader';
|
|
12
11
|
import Button from '../Button';
|
|
12
|
+
import ScrollView from '../ScrollView';
|
|
13
13
|
|
|
14
14
|
let pending = $state<Promise<void> | null>(null);
|
|
15
15
|
|
|
@@ -27,13 +27,20 @@
|
|
|
27
27
|
};
|
|
28
28
|
</script>
|
|
29
29
|
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
<ScrollView
|
|
31
|
+
background="color-mix(in oklab, var(--sveltely-background-color) 94%, var(--sveltely-primary-color))"
|
|
32
|
+
borderRadius="var(--sveltely-border-radius)"
|
|
33
|
+
scrollGradient={false}
|
|
34
|
+
loader={{ text: 'Loading preview...', promise: pending }}
|
|
35
|
+
>
|
|
36
|
+
<div class="loader-demo">
|
|
37
|
+
<div class="loader-demo-copy">
|
|
38
|
+
<strong>Preview panel</strong>
|
|
39
|
+
<span>Click the button to cover this ScrollView component with the loader overlay.</span>
|
|
40
|
+
</div>
|
|
41
|
+
<Button label="Show loader" onclick={startLoading} disabled={pending !== null} />
|
|
34
42
|
</div>
|
|
35
|
-
|
|
36
|
-
</div>
|
|
43
|
+
</ScrollView>
|
|
37
44
|
|
|
38
45
|
<style>
|
|
39
46
|
.loader-demo {
|
|
@@ -44,13 +51,6 @@
|
|
|
44
51
|
align-items: flex-start;
|
|
45
52
|
justify-content: space-between;
|
|
46
53
|
gap: var(--sveltely-gap);
|
|
47
|
-
border: 1px solid var(--sveltely-border-color);
|
|
48
|
-
border-radius: var(--sveltely-border-radius);
|
|
49
|
-
background: color-mix(
|
|
50
|
-
in oklab,
|
|
51
|
-
var(--sveltely-background-color) 94%,
|
|
52
|
-
var(--sveltely-primary-color)
|
|
53
|
-
);
|
|
54
54
|
padding: var(--sveltely-padding-y) var(--sveltely-padding-x);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { tick } from 'svelte';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
|
+
import { loader as loaderAction } from '../../../actions/loader';
|
|
5
|
+
import { extractLoaderProps, resolveLoaderOptions, type LoaderProps } from '../../../style/loader';
|
|
4
6
|
import { extractLayoutProps, layoutStyle, type LayoutProps } from '../../../style/layout';
|
|
5
7
|
import { extractStyleProps, surfaceStyle, type StyleProps } from '../../../style/surface';
|
|
6
8
|
import type { ScrollAxis } from '../../../style/scroll';
|
|
@@ -40,7 +42,8 @@
|
|
|
40
42
|
scrollGradient?: boolean;
|
|
41
43
|
scrollGradientSize?: number | string;
|
|
42
44
|
} & LayoutProps &
|
|
43
|
-
StyleProps
|
|
45
|
+
StyleProps &
|
|
46
|
+
LoaderProps;
|
|
44
47
|
|
|
45
48
|
let {
|
|
46
49
|
children,
|
|
@@ -53,11 +56,16 @@
|
|
|
53
56
|
...restProps
|
|
54
57
|
}: Props = $props();
|
|
55
58
|
|
|
56
|
-
const
|
|
59
|
+
const extractedLoaderProps = $derived.by(() => extractLoaderProps(restProps));
|
|
60
|
+
const loaderProps = $derived(extractedLoaderProps.loaderProps);
|
|
61
|
+
const afterLoaderProps = $derived(extractedLoaderProps.restProps);
|
|
62
|
+
const loaderOptions = $derived.by(() => resolveLoaderOptions(loaderProps));
|
|
63
|
+
const extractedLayoutProps = $derived.by(() => extractLayoutProps(afterLoaderProps));
|
|
57
64
|
const layoutProps = $derived(extractedLayoutProps.layoutProps);
|
|
58
65
|
const afterLayoutProps = $derived(extractedLayoutProps.restProps);
|
|
59
66
|
const extractedStyleProps = $derived.by(() => extractStyleProps(afterLayoutProps));
|
|
60
67
|
const styleProps = $derived(extractedStyleProps.styleProps);
|
|
68
|
+
const props = $derived(extractedStyleProps.restProps);
|
|
61
69
|
const viewportStyle = $derived.by(() => surfaceStyle(styleProps, 'scroll-view'));
|
|
62
70
|
const contentStyle = $derived.by(() => surfaceStyle(contentStyles, 'scroll-view-content'));
|
|
63
71
|
const scrollGradientStyle = $derived(
|
|
@@ -141,6 +149,8 @@
|
|
|
141
149
|
class:scroll-view-can-scroll-up={canScrollToTop}
|
|
142
150
|
class:scroll-view-can-scroll-down={canScrollToBottom}
|
|
143
151
|
style={rootStyle}
|
|
152
|
+
{...props}
|
|
153
|
+
use:loaderAction={loaderOptions}
|
|
144
154
|
onscroll={handleScroll}
|
|
145
155
|
onwheel={handleWheel}
|
|
146
156
|
>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type LoaderProps } from '../../../style/loader';
|
|
2
3
|
import { type LayoutProps } from '../../../style/layout';
|
|
3
4
|
import { type StyleProps } from '../../../style/surface';
|
|
4
5
|
import type { ScrollAxis } from '../../../style/scroll';
|
|
@@ -35,7 +36,7 @@ type Props = {
|
|
|
35
36
|
onScroll?: (geometry: ScrollGeometry) => void;
|
|
36
37
|
scrollGradient?: boolean;
|
|
37
38
|
scrollGradientSize?: number | string;
|
|
38
|
-
} & LayoutProps & StyleProps;
|
|
39
|
+
} & LayoutProps & StyleProps & LoaderProps;
|
|
39
40
|
declare const ScrollView: import("svelte").Component<Props, {}, "viewport">;
|
|
40
41
|
type ScrollView = ReturnType<typeof ScrollView>;
|
|
41
42
|
export default ScrollView;
|
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import { loader as loaderAction } from '../../../actions/loader';
|
|
4
|
+
import { extractLoaderProps, resolveLoaderOptions, type LoaderProps } from '../../../style/loader';
|
|
3
5
|
import { extractLayoutProps, layoutStyle, type LayoutProps } from '../../../style/layout';
|
|
4
6
|
import { extractStyleProps, surfaceStyle, type StyleProps } from '../../../style/surface';
|
|
5
7
|
|
|
6
8
|
type Props = {
|
|
7
9
|
children?: Snippet;
|
|
8
10
|
} & LayoutProps &
|
|
9
|
-
StyleProps
|
|
11
|
+
StyleProps &
|
|
12
|
+
LoaderProps;
|
|
10
13
|
|
|
11
14
|
let { children, ...restProps }: Props = $props();
|
|
12
15
|
|
|
13
|
-
const
|
|
16
|
+
const extractedLoaderProps = $derived.by(() => extractLoaderProps(restProps));
|
|
17
|
+
const loaderProps = $derived(extractedLoaderProps.loaderProps);
|
|
18
|
+
const afterLoaderProps = $derived(extractedLoaderProps.restProps);
|
|
19
|
+
const loaderOptions = $derived.by(() => resolveLoaderOptions(loaderProps));
|
|
20
|
+
const extractedLayoutProps = $derived.by(() => extractLayoutProps(afterLoaderProps));
|
|
14
21
|
const layoutProps = $derived(extractedLayoutProps.layoutProps);
|
|
15
22
|
const afterLayoutProps = $derived(extractedLayoutProps.restProps);
|
|
16
23
|
const extractedStyleProps = $derived.by(() => extractStyleProps(afterLayoutProps));
|
|
17
24
|
const styleProps = $derived(extractedStyleProps.styleProps);
|
|
25
|
+
const props = $derived(extractedStyleProps.restProps);
|
|
18
26
|
const rootStyle = $derived.by(() =>
|
|
19
27
|
[layoutStyle(layoutProps), surfaceStyle(styleProps, 'stack')].filter(Boolean).join(' ')
|
|
20
28
|
);
|
|
21
29
|
</script>
|
|
22
30
|
|
|
23
|
-
<div class="vstack" style={rootStyle}>
|
|
31
|
+
<div class="vstack" style={rootStyle} {...props} use:loaderAction={loaderOptions}>
|
|
24
32
|
{#if children}
|
|
25
33
|
{@render children()}
|
|
26
34
|
{/if}
|
|
@@ -34,9 +42,7 @@
|
|
|
34
42
|
flex-direction: column;
|
|
35
43
|
gap: var(--stack-gap, 0px);
|
|
36
44
|
border-radius: var(--stack-border-radius, 0px);
|
|
37
|
-
padding:
|
|
38
|
-
var(--stack-padding-y, 0px)
|
|
39
|
-
var(--stack-padding-x, 0px);
|
|
45
|
+
padding: var(--stack-padding-y, 0px) var(--stack-padding-x, 0px);
|
|
40
46
|
font-size: var(--stack-font-size, inherit);
|
|
41
47
|
--divider-width: 100%;
|
|
42
48
|
--divider-height: 1px;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type LoaderProps } from '../../../style/loader';
|
|
2
3
|
import { type LayoutProps } from '../../../style/layout';
|
|
3
4
|
import { type StyleProps } from '../../../style/surface';
|
|
4
5
|
type Props = {
|
|
5
6
|
children?: Snippet;
|
|
6
|
-
} & LayoutProps & StyleProps;
|
|
7
|
+
} & LayoutProps & StyleProps & LoaderProps;
|
|
7
8
|
declare const VStack: import("svelte").Component<Props, {}, "">;
|
|
8
9
|
type VStack = ReturnType<typeof VStack>;
|
|
9
10
|
export default VStack;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { tooltip } from './actions/tooltip';
|
|
|
4
4
|
export type { TooltipOptions } from './actions/tooltip';
|
|
5
5
|
export { loader } from './actions/loader';
|
|
6
6
|
export type { LoaderOptions } from './actions/loader';
|
|
7
|
+
export type { LoaderProps } from './style/loader';
|
|
7
8
|
export { LayoutAlignment, LayoutJustification, LayoutSize } from './style/layout';
|
|
8
9
|
export type { LayoutAlignmentValue, LayoutJustificationValue, LayoutProps, LayoutSizeValue } from './style/layout';
|
|
9
10
|
export { LabelOrientation } from './style/label';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { LoaderOptions } from '../actions/loader';
|
|
2
|
+
export type LoaderProps = {
|
|
3
|
+
loader?: LoaderOptions;
|
|
4
|
+
};
|
|
5
|
+
export declare const extractLoaderProps: <T extends Record<string, unknown>>(props: T) => {
|
|
6
|
+
loaderProps: LoaderProps;
|
|
7
|
+
restProps: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
export declare const resolveLoaderOptions: (props?: LoaderProps) => LoaderOptions;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const LOADER_PROP_KEYS = new Set(['loader']);
|
|
2
|
+
export const extractLoaderProps = (props) => {
|
|
3
|
+
const loaderProps = {};
|
|
4
|
+
const restProps = {};
|
|
5
|
+
for (const [key, value] of Object.entries(props)) {
|
|
6
|
+
if (LOADER_PROP_KEYS.has(key)) {
|
|
7
|
+
loaderProps[key] = value;
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
restProps[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
loaderProps,
|
|
14
|
+
restProps
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export const resolveLoaderOptions = (props) => {
|
|
18
|
+
if (!props)
|
|
19
|
+
return false;
|
|
20
|
+
return props.loader ?? false;
|
|
21
|
+
};
|