@skeletonlabs/skeleton-svelte 1.0.0-next.9 → 1.1.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.
- package/README.md +1 -1
- package/dist/components/Accordion/Accordion.svelte +49 -52
- package/dist/components/Accordion/Accordion.svelte.d.ts +2 -14
- package/dist/components/Accordion/AccordionItem.svelte +43 -37
- package/dist/components/Accordion/AccordionItem.svelte.d.ts +2 -14
- package/dist/components/Accordion/context.js +2 -1
- package/dist/components/Accordion/index.d.ts +4 -0
- package/dist/components/Accordion/index.js +1 -1
- package/dist/components/Accordion/types.d.ts +7 -9
- package/dist/components/AppBar/AppBar.svelte +43 -40
- package/dist/components/AppBar/AppBar.svelte.d.ts +2 -14
- package/dist/components/Avatar/Avatar.svelte +56 -44
- package/dist/components/Avatar/Avatar.svelte.d.ts +2 -14
- package/dist/components/Avatar/types.d.ts +3 -3
- package/dist/components/Combobox/Combobox.svelte +144 -0
- package/dist/components/Combobox/Combobox.svelte.d.ts +18 -0
- package/dist/components/Combobox/types.d.ts +64 -0
- package/dist/components/Combobox/types.js +1 -0
- package/dist/components/FileUpload/FileUpload.svelte +70 -63
- package/dist/components/FileUpload/FileUpload.svelte.d.ts +2 -14
- package/dist/components/FileUpload/types.d.ts +3 -4
- package/dist/components/Modal/Modal.svelte +87 -0
- package/dist/components/Modal/Modal.svelte.d.ts +4 -0
- package/dist/components/Modal/types.d.ts +57 -0
- package/dist/components/Modal/types.js +1 -0
- package/dist/components/Navigation/NavBar.svelte +48 -0
- package/dist/components/Navigation/NavBar.svelte.d.ts +5 -0
- package/dist/components/Navigation/NavRail.svelte +90 -0
- package/dist/components/Navigation/NavRail.svelte.d.ts +5 -0
- package/dist/components/Navigation/NavTile.svelte +87 -0
- package/dist/components/Navigation/NavTile.svelte.d.ts +5 -0
- package/dist/components/Navigation/context.js +7 -0
- package/dist/components/Navigation/index.d.ts +6 -0
- package/dist/components/{Nav → Navigation}/index.js +1 -1
- package/dist/components/{Nav → Navigation}/types.d.ts +5 -3
- package/dist/components/Pagination/Pagination.svelte +58 -67
- package/dist/components/Pagination/Pagination.svelte.d.ts +2 -14
- package/dist/components/Pagination/types.d.ts +15 -15
- package/dist/components/Popover/Popover.svelte +78 -0
- package/dist/components/Popover/Popover.svelte.d.ts +4 -0
- package/dist/components/Popover/types.d.ts +42 -0
- package/dist/components/Popover/types.js +1 -0
- package/dist/components/Progress/Progress.svelte +44 -38
- package/dist/components/Progress/Progress.svelte.d.ts +2 -14
- package/dist/components/Progress/types.d.ts +1 -1
- package/dist/components/ProgressRing/ProgressRing.svelte +58 -46
- package/dist/components/ProgressRing/ProgressRing.svelte.d.ts +2 -14
- package/dist/components/ProgressRing/types.d.ts +3 -1
- package/dist/components/Rating/Rating.svelte +101 -57
- package/dist/components/Rating/Rating.svelte.d.ts +2 -14
- package/dist/components/Rating/types.d.ts +1 -5
- package/dist/components/Segment/Segment.svelte +59 -61
- package/dist/components/Segment/Segment.svelte.d.ts +3 -15
- package/dist/components/Segment/SegmentItem.svelte +28 -21
- package/dist/components/Segment/SegmentItem.svelte.d.ts +2 -14
- package/dist/components/Segment/context.js +3 -2
- package/dist/components/Segment/index.d.ts +4 -0
- package/dist/components/Segment/index.js +1 -1
- package/dist/components/Segment/types.d.ts +8 -10
- package/dist/components/Slider/Slider.svelte +67 -72
- package/dist/components/Slider/Slider.svelte.d.ts +2 -14
- package/dist/components/Slider/types.d.ts +5 -9
- package/dist/components/Switch/Switch.svelte +75 -90
- package/dist/components/Switch/Switch.svelte.d.ts +2 -14
- package/dist/components/Switch/types.d.ts +2 -8
- package/dist/components/Tabs/Tabs.svelte +59 -0
- package/dist/components/Tabs/Tabs.svelte.d.ts +5 -0
- package/dist/components/Tabs/TabsControl.svelte +51 -0
- package/dist/components/Tabs/TabsControl.svelte.d.ts +5 -0
- package/dist/components/Tabs/TabsPanel.svelte +23 -0
- package/dist/components/Tabs/TabsPanel.svelte.d.ts +5 -0
- package/dist/components/{Tab → Tabs}/context.js +3 -2
- package/dist/components/Tabs/index.d.ts +5 -0
- package/dist/components/{Tab → Tabs}/index.js +1 -1
- package/dist/components/{Tab → Tabs}/types.d.ts +1 -3
- package/dist/components/TagsInput/TagsInput.svelte +48 -54
- package/dist/components/TagsInput/TagsInput.svelte.d.ts +2 -14
- package/dist/components/TagsInput/types.d.ts +3 -7
- package/dist/components/Toast/Toast.svelte +68 -0
- package/dist/components/Toast/Toast.svelte.d.ts +4 -0
- package/dist/components/Toast/Toaster.svelte +68 -0
- package/dist/components/Toast/Toaster.svelte.d.ts +4 -0
- package/dist/components/Toast/create-toaster.d.ts +2 -0
- package/dist/components/Toast/create-toaster.js +5 -0
- package/dist/components/Toast/types.d.ts +43 -0
- package/dist/components/Toast/types.js +1 -0
- package/dist/components/Tooltip/Tooltip.svelte +79 -0
- package/dist/components/Tooltip/Tooltip.svelte.d.ts +4 -0
- package/dist/components/Tooltip/types.d.ts +44 -0
- package/dist/components/Tooltip/types.js +1 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +12 -3
- package/dist/internal/create-context.d.ts +6 -0
- package/dist/internal/create-context.js +3 -3
- package/dist/internal/test-utils.d.ts +3 -0
- package/dist/internal/test-utils.js +9 -0
- package/package.json +43 -54
- package/dist/components/Accordion/Accordion.svelte.spec.d.ts +0 -1
- package/dist/components/Accordion/Accordion.svelte.spec.js +0 -4
- package/dist/components/Nav/NavBar.svelte +0 -45
- package/dist/components/Nav/NavBar.svelte.d.ts +0 -17
- package/dist/components/Nav/NavRail.svelte +0 -79
- package/dist/components/Nav/NavRail.svelte.d.ts +0 -17
- package/dist/components/Nav/NavTile.svelte +0 -76
- package/dist/components/Nav/NavTile.svelte.d.ts +0 -17
- package/dist/components/Nav/context.js +0 -7
- package/dist/components/Tab/Tabs.svelte +0 -65
- package/dist/components/Tab/Tabs.svelte.d.ts +0 -17
- package/dist/components/Tab/TabsControl.svelte +0 -42
- package/dist/components/Tab/TabsControl.svelte.d.ts +0 -17
- package/dist/components/Tab/TabsPanel.svelte +0 -18
- package/dist/components/Tab/TabsPanel.svelte.d.ts +0 -17
- package/dist/internal/noop.d.ts +0 -1
- package/dist/internal/noop.js +0 -2
- package/dist/internal/snippets.d.ts +0 -3
- package/dist/internal/snippets.js +0 -45
- package/dist/internal/use-id.d.ts +0 -2
- package/dist/internal/use-id.js +0 -5
- /package/dist/components/{Nav → Navigation}/context.d.ts +0 -0
- /package/dist/components/{Nav → Navigation}/types.js +0 -0
- /package/dist/components/{Tab → Tabs}/context.d.ts +0 -0
- /package/dist/components/{Tab → Tabs}/types.js +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { setNavigationContext } from './context.js';
|
|
3
|
+
import type { NavRailProps } from './types.js';
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
value = '',
|
|
7
|
+
expanded = false,
|
|
8
|
+
// Root
|
|
9
|
+
base = 'h-full flex flex-col',
|
|
10
|
+
background = 'preset-filled-surface-100-900',
|
|
11
|
+
padding = 'p-1',
|
|
12
|
+
width = 'w-24',
|
|
13
|
+
widthExpanded = 'w-64',
|
|
14
|
+
height = 'h-full',
|
|
15
|
+
classes = '',
|
|
16
|
+
// Header
|
|
17
|
+
headerBase = 'flex',
|
|
18
|
+
headerFlexDirection = 'flex-col',
|
|
19
|
+
headerJustify = 'justify-center',
|
|
20
|
+
headerItems = 'items-center',
|
|
21
|
+
headerGap = 'gap-1',
|
|
22
|
+
headerClasses = '',
|
|
23
|
+
// Tiles
|
|
24
|
+
tilesBase = 'flex-1 flex',
|
|
25
|
+
tilesFlexDirection = 'flex-col',
|
|
26
|
+
tilesJustify = 'justify-center',
|
|
27
|
+
tilesItems = 'items-center',
|
|
28
|
+
tilesGap = 'gap-1',
|
|
29
|
+
tilesClasses = '',
|
|
30
|
+
// Footer
|
|
31
|
+
footerBase = 'flex',
|
|
32
|
+
footerFlexDirection = 'flex-col',
|
|
33
|
+
footerJustify = 'justify-center',
|
|
34
|
+
footerItems = 'items-center',
|
|
35
|
+
footerGap = 'gap-1',
|
|
36
|
+
footerClasses = '',
|
|
37
|
+
// Events
|
|
38
|
+
onValueChange,
|
|
39
|
+
// Snippets
|
|
40
|
+
header,
|
|
41
|
+
tiles,
|
|
42
|
+
footer
|
|
43
|
+
}: NavRailProps = $props();
|
|
44
|
+
|
|
45
|
+
// Context
|
|
46
|
+
setNavigationContext({
|
|
47
|
+
parent: 'rail',
|
|
48
|
+
get value() {
|
|
49
|
+
return value;
|
|
50
|
+
},
|
|
51
|
+
get expanded() {
|
|
52
|
+
return expanded;
|
|
53
|
+
},
|
|
54
|
+
get onValueChange() {
|
|
55
|
+
return onValueChange;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Reactive
|
|
60
|
+
let rxWidth = $derived(expanded ? widthExpanded : width);
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<!-- @component Provides a vertical navigation interface. -->
|
|
64
|
+
|
|
65
|
+
<aside class="{base} {background} {height} {padding} {rxWidth} {classes}" data-testid="nav-rail">
|
|
66
|
+
<!-- Header -->
|
|
67
|
+
{#if header}
|
|
68
|
+
<header
|
|
69
|
+
class="{headerBase} {headerFlexDirection} {headerJustify} {headerItems} {headerGap} {headerClasses}"
|
|
70
|
+
data-testid="nav-rail-header"
|
|
71
|
+
>
|
|
72
|
+
{@render header()}
|
|
73
|
+
</header>
|
|
74
|
+
{/if}
|
|
75
|
+
<!-- Tiles -->
|
|
76
|
+
{#if tiles}
|
|
77
|
+
<nav class="{tilesBase} {tilesFlexDirection} {tilesJustify} {tilesItems} {tilesGap} {tilesClasses}" data-testid="nav-rail-tiles">
|
|
78
|
+
{@render tiles()}
|
|
79
|
+
</nav>
|
|
80
|
+
{/if}
|
|
81
|
+
<!-- Footer -->
|
|
82
|
+
{#if footer}
|
|
83
|
+
<footer
|
|
84
|
+
class="{footerBase} {footerFlexDirection} {footerJustify} {footerItems} {footerGap} {footerClasses}"
|
|
85
|
+
data-testid="nav-rail-footer"
|
|
86
|
+
>
|
|
87
|
+
{@render footer()}
|
|
88
|
+
</footer>
|
|
89
|
+
{/if}
|
|
90
|
+
</aside>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getNavigationContext } from './context.js';
|
|
3
|
+
import type { NavTileProps } from './types.js';
|
|
4
|
+
|
|
5
|
+
const propsId = $props.id();
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
id = propsId,
|
|
9
|
+
href,
|
|
10
|
+
target,
|
|
11
|
+
label,
|
|
12
|
+
labelExpanded,
|
|
13
|
+
title,
|
|
14
|
+
selected = undefined,
|
|
15
|
+
type = 'button',
|
|
16
|
+
// Root
|
|
17
|
+
base = 'flex items-center',
|
|
18
|
+
width = 'w-full',
|
|
19
|
+
aspect = 'aspect-square',
|
|
20
|
+
background = '',
|
|
21
|
+
hover = 'hover:preset-filled-surface-50-950',
|
|
22
|
+
active = 'preset-filled-primary-500',
|
|
23
|
+
padding = 'p-2',
|
|
24
|
+
gap = 'gap-1',
|
|
25
|
+
rounded = 'rounded-container',
|
|
26
|
+
classes = 'flex-col justify-center',
|
|
27
|
+
// Expanded
|
|
28
|
+
expandedPadding = 'py-3 px-4',
|
|
29
|
+
expandedGap = 'gap-4',
|
|
30
|
+
expandedClasses = '',
|
|
31
|
+
// Label (base)
|
|
32
|
+
labelBase = 'text-xs',
|
|
33
|
+
labelClasses = '',
|
|
34
|
+
// Label (expanded)
|
|
35
|
+
labelExpandedBase = '',
|
|
36
|
+
labelExpandedClasses = '',
|
|
37
|
+
// Events
|
|
38
|
+
onclick,
|
|
39
|
+
// Snippets
|
|
40
|
+
children
|
|
41
|
+
}: NavTileProps = $props();
|
|
42
|
+
|
|
43
|
+
// Context
|
|
44
|
+
const ctx = getNavigationContext();
|
|
45
|
+
|
|
46
|
+
// Reactive
|
|
47
|
+
const element = $derived(href ? 'a' : 'button');
|
|
48
|
+
const role = $derived(href ? undefined : 'button');
|
|
49
|
+
const rxSize = $derived(ctx.parent === 'bar' ? `h-full` : `${aspect}`);
|
|
50
|
+
const classesCollapsed = $derived(`${rxSize} ${padding} ${gap} ${classes}`);
|
|
51
|
+
const classesExtended = $derived(`${expandedPadding} ${expandedGap} ${expandedClasses}`);
|
|
52
|
+
const rxMode = $derived(ctx.expanded ? classesExtended : classesCollapsed);
|
|
53
|
+
const isActive = $derived(selected !== undefined ? selected : ctx.value === id);
|
|
54
|
+
const rxBackground = $derived(isActive ? active : `${background} ${hover}`);
|
|
55
|
+
|
|
56
|
+
function onClickHandler() {
|
|
57
|
+
if (onclick && !id) throw new Error('No ID was provided');
|
|
58
|
+
if (onclick && id) onclick(id);
|
|
59
|
+
ctx.onValueChange?.(id);
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<!-- @component An individual Navigation component tile. -->
|
|
64
|
+
|
|
65
|
+
<svelte:element
|
|
66
|
+
this={element}
|
|
67
|
+
class="{base} {width} {rounded} {rxBackground} {rxMode}"
|
|
68
|
+
{href}
|
|
69
|
+
{target}
|
|
70
|
+
type={element === 'button' ? type : undefined}
|
|
71
|
+
{title}
|
|
72
|
+
{role}
|
|
73
|
+
onclick={onClickHandler}
|
|
74
|
+
tabindex="0"
|
|
75
|
+
data-testid="nav-tile"
|
|
76
|
+
>
|
|
77
|
+
<!-- Icon -->
|
|
78
|
+
{#if children}<div>{@render children()}</div>{/if}
|
|
79
|
+
<!-- Label (base) -->
|
|
80
|
+
{#if label && !ctx.expanded}
|
|
81
|
+
<div class="{labelBase} {labelClasses}" data-testid="nav-tile-label">{label}</div>
|
|
82
|
+
{/if}
|
|
83
|
+
<!-- Label (expanded) -->
|
|
84
|
+
{#if labelExpanded && ctx.expanded}
|
|
85
|
+
<div class="{labelExpandedBase} {labelExpandedClasses}" data-testid="nav-tile-label-expanded">{labelExpanded}</div>
|
|
86
|
+
{/if}
|
|
87
|
+
</svelte:element>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const _default: import("svelte").Component<import("./types").NavRailProps, {}, ""> & {
|
|
2
|
+
Rail: import("svelte").Component<import("./types").NavRailProps, {}, "">;
|
|
3
|
+
Bar: import("svelte").Component<import("./types").NavBarProps, {}, "">;
|
|
4
|
+
Tile: import("svelte").Component<import("./types").NavTileProps, {}, "">;
|
|
5
|
+
};
|
|
6
|
+
export default _default;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
export interface NavContext {
|
|
3
3
|
parent: 'bar' | 'rail' | 'none';
|
|
4
|
-
value
|
|
4
|
+
value?: string;
|
|
5
5
|
expanded: boolean;
|
|
6
|
-
|
|
6
|
+
onValueChange?: (id: string) => void;
|
|
7
7
|
}
|
|
8
8
|
export interface NavCommonProps {
|
|
9
9
|
value?: string;
|
|
@@ -34,7 +34,7 @@ export interface NavCommonProps {
|
|
|
34
34
|
/** Provide arbitrary CSS classes. */
|
|
35
35
|
tilesClasses?: string;
|
|
36
36
|
/** Triggers when selection occurs. */
|
|
37
|
-
|
|
37
|
+
onValueChange?: (id: string) => void;
|
|
38
38
|
}
|
|
39
39
|
export interface NavBarProps extends NavCommonProps {
|
|
40
40
|
/** The default children snippet. */
|
|
@@ -89,6 +89,8 @@ export interface NavTileProps {
|
|
|
89
89
|
title?: string;
|
|
90
90
|
/** Enable the active selected state. */
|
|
91
91
|
selected?: boolean;
|
|
92
|
+
/** Set button type. */
|
|
93
|
+
type?: 'button' | 'submit' | 'reset';
|
|
92
94
|
/** Set base styles. */
|
|
93
95
|
base?: string;
|
|
94
96
|
/** Set width classes. */
|
|
@@ -1,78 +1,69 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return pageSize;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
const api = $derived(pagination.connect(snapshot, send, normalizeProps));
|
|
60
|
-
const rxButtonActive = (page2) => {
|
|
61
|
-
return snapshot.context.page === page2.value ? buttonActive : `${buttonInactive} ${buttonHover}`;
|
|
62
|
-
};
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as pagination from '@zag-js/pagination';
|
|
3
|
+
import { normalizeProps, useMachine } from '@zag-js/svelte';
|
|
4
|
+
import type { PaginationProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
const {
|
|
7
|
+
data = [],
|
|
8
|
+
alternative = false,
|
|
9
|
+
textSeparator = 'of',
|
|
10
|
+
showFirstLastButtons = false,
|
|
11
|
+
// Root
|
|
12
|
+
base = 'inline-flex items-stretch overflow-hidden',
|
|
13
|
+
background = 'preset-outlined-surface-200-800',
|
|
14
|
+
border = 'p-2',
|
|
15
|
+
gap = 'gap-2',
|
|
16
|
+
padding = '',
|
|
17
|
+
rounded = 'rounded-container',
|
|
18
|
+
classes = '',
|
|
19
|
+
// Titles
|
|
20
|
+
titleFirst,
|
|
21
|
+
titlePrevious,
|
|
22
|
+
titleNumeral,
|
|
23
|
+
titleNext,
|
|
24
|
+
titleLast,
|
|
25
|
+
// Buttons
|
|
26
|
+
buttonBase = 'btn',
|
|
27
|
+
buttonActive = 'preset-filled',
|
|
28
|
+
buttonInactive = 'preset-tonal',
|
|
29
|
+
buttonHover = 'hover:preset-filled',
|
|
30
|
+
buttonClasses = '',
|
|
31
|
+
// Children
|
|
32
|
+
labelFirst,
|
|
33
|
+
labelPrevious,
|
|
34
|
+
labelEllipsis,
|
|
35
|
+
labelNext,
|
|
36
|
+
labelLast,
|
|
37
|
+
// Zag ---
|
|
38
|
+
...zagProps
|
|
39
|
+
}: PaginationProps = $props();
|
|
40
|
+
|
|
41
|
+
// Zag
|
|
42
|
+
const id = $props.id();
|
|
43
|
+
const service = useMachine(pagination.machine, () => ({
|
|
44
|
+
id: id,
|
|
45
|
+
count: zagProps.count ?? data.length,
|
|
46
|
+
...zagProps
|
|
47
|
+
}));
|
|
48
|
+
const api = $derived(pagination.connect(service, normalizeProps));
|
|
49
|
+
|
|
50
|
+
// Reactive
|
|
51
|
+
const rxButtonActive = (page: { value: number }) => {
|
|
52
|
+
return service.prop('page') === page.value ? buttonActive : `${buttonInactive} ${buttonHover}`;
|
|
53
|
+
};
|
|
63
54
|
</script>
|
|
64
55
|
|
|
65
56
|
{#if api.totalPages > 1}
|
|
66
57
|
<div {...api.getRootProps()} class="{base} {background} {border} {gap} {padding} {rounded} {classes}" data-testid="pagination">
|
|
67
58
|
<!-- Button: First Page -->
|
|
68
|
-
{#if
|
|
59
|
+
{#if showFirstLastButtons}
|
|
69
60
|
<button
|
|
70
61
|
type="button"
|
|
71
62
|
onclick={api.goToFirstPage}
|
|
72
63
|
class="{buttonBase} {buttonInactive} {buttonHover} {buttonClasses}"
|
|
73
64
|
title={titleFirst}
|
|
74
65
|
disabled={api.page === 1}
|
|
75
|
-
data-testid="pagination-button-
|
|
66
|
+
data-testid="pagination-button-first"
|
|
76
67
|
>
|
|
77
68
|
{#if labelFirst}{@render labelFirst()}{:else}«{/if}
|
|
78
69
|
</button>
|
|
@@ -123,7 +114,7 @@ const rxButtonActive = (page2) => {
|
|
|
123
114
|
<span class="opacity-60">
|
|
124
115
|
{api.page}
|
|
125
116
|
{textSeparator}
|
|
126
|
-
{api.
|
|
117
|
+
{api.totalPages}
|
|
127
118
|
</span>
|
|
128
119
|
</span>
|
|
129
120
|
{/if}
|
|
@@ -139,14 +130,14 @@ const rxButtonActive = (page2) => {
|
|
|
139
130
|
{#if labelNext}{@render labelNext()}{:else}→{/if}
|
|
140
131
|
</button>
|
|
141
132
|
<!-- Button: Last Page -->
|
|
142
|
-
{#if
|
|
133
|
+
{#if showFirstLastButtons}
|
|
143
134
|
<button
|
|
144
135
|
type="button"
|
|
145
136
|
onclick={api.goToLastPage}
|
|
146
137
|
class="{buttonBase} {buttonInactive} {buttonHover} {buttonClasses}"
|
|
147
138
|
title={titleLast}
|
|
148
139
|
disabled={!api.nextPage}
|
|
149
|
-
data-testid="pagination-button-
|
|
140
|
+
data-testid="pagination-button-last"
|
|
150
141
|
>
|
|
151
142
|
{#if labelLast}{@render labelLast()}{:else}»{/if}
|
|
152
143
|
</button>
|
|
@@ -1,16 +1,4 @@
|
|
|
1
1
|
import type { PaginationProps } from './types.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
$$bindings?: Bindings;
|
|
5
|
-
} & Exports;
|
|
6
|
-
(internal: unknown, props: Props & {
|
|
7
|
-
$$events?: Events;
|
|
8
|
-
$$slots?: Slots;
|
|
9
|
-
}): Exports;
|
|
10
|
-
z_$$bindings?: Bindings;
|
|
11
|
-
}
|
|
12
|
-
declare const Pagination: $$__sveltets_2_IsomorphicComponent<PaginationProps, {
|
|
13
|
-
[evt: string]: CustomEvent<any>;
|
|
14
|
-
}, {}, {}, "pageSize" | "page">;
|
|
15
|
-
type Pagination = InstanceType<typeof Pagination>;
|
|
2
|
+
declare const Pagination: import("svelte").Component<PaginationProps, {}, "">;
|
|
3
|
+
type Pagination = ReturnType<typeof Pagination>;
|
|
16
4
|
export default Pagination;
|
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import * as pagination from '@zag-js/pagination';
|
|
3
|
-
export interface PaginationProps extends Omit<pagination.
|
|
4
|
-
/**
|
|
5
|
-
page: number;
|
|
6
|
-
/** Bind the number of data items to display. */
|
|
7
|
-
pageSize: number;
|
|
3
|
+
export interface PaginationProps extends Omit<pagination.Props, 'id'> {
|
|
4
|
+
/** Provide source data as an array. */
|
|
8
5
|
data: unknown[];
|
|
6
|
+
/** Enables alternative display with stats and first/last buttons. */
|
|
9
7
|
alternative?: boolean;
|
|
10
8
|
/** Set the separator text or character, such as "of" in "X of Y". */
|
|
11
9
|
textSeparator?: string;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
/** Set an optional title for the previous button. */
|
|
15
|
-
titlePrevious?: string;
|
|
16
|
-
/** Set an optional title for the numeral buttons (ex: Page 1). */
|
|
17
|
-
titleNumeral?: string;
|
|
18
|
-
/** Set an optional title for the next button. */
|
|
19
|
-
titleNext?: string;
|
|
20
|
-
/** Set an optional title for the last button. */
|
|
21
|
-
titleLast?: string;
|
|
10
|
+
/** Show first and last page button. */
|
|
11
|
+
showFirstLastButtons?: boolean;
|
|
22
12
|
/** Sets base classes for the list. */
|
|
23
13
|
base?: string;
|
|
24
14
|
/** Sets background classes for the list. */
|
|
@@ -33,6 +23,16 @@ export interface PaginationProps extends Omit<pagination.Context, 'id' | 'page'
|
|
|
33
23
|
rounded?: string;
|
|
34
24
|
/** Provide arbitrary CSS classes for the root. */
|
|
35
25
|
classes?: string;
|
|
26
|
+
/** Set an optional title for the first button. */
|
|
27
|
+
titleFirst?: string;
|
|
28
|
+
/** Set an optional title for the previous button. */
|
|
29
|
+
titlePrevious?: string;
|
|
30
|
+
/** Set an optional title for the numeral buttons (ex: Page 1). */
|
|
31
|
+
titleNumeral?: string;
|
|
32
|
+
/** Set an optional title for the next button. */
|
|
33
|
+
titleNext?: string;
|
|
34
|
+
/** Set an optional title for the last button. */
|
|
35
|
+
titleLast?: string;
|
|
36
36
|
/** Sets base classes for buttons. */
|
|
37
37
|
buttonBase?: string;
|
|
38
38
|
/** Sets active state classes for buttons. */
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { fade } from 'svelte/transition';
|
|
3
|
+
|
|
4
|
+
import * as popover from '@zag-js/popover';
|
|
5
|
+
import { portal, useMachine, normalizeProps, mergeProps } from '@zag-js/svelte';
|
|
6
|
+
import type { PopoverProps } from './types.js';
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
arrow = false,
|
|
10
|
+
zIndex = 'auto',
|
|
11
|
+
// Base
|
|
12
|
+
base = '',
|
|
13
|
+
classes = '',
|
|
14
|
+
// Trigger
|
|
15
|
+
triggerBase = '',
|
|
16
|
+
triggerBackground = '',
|
|
17
|
+
triggerClasses = '',
|
|
18
|
+
triggerAriaLabel = '',
|
|
19
|
+
// Positioner
|
|
20
|
+
positionerBase = '',
|
|
21
|
+
positionerClasses = '',
|
|
22
|
+
// Content
|
|
23
|
+
contentBase = '',
|
|
24
|
+
contentBackground = '',
|
|
25
|
+
contentClasses = '',
|
|
26
|
+
// Arrow
|
|
27
|
+
arrowBase = '',
|
|
28
|
+
arrowBackground = '!bg-surface-200 dark:!bg-surface-800',
|
|
29
|
+
arrowClasses = '',
|
|
30
|
+
// Snippets
|
|
31
|
+
trigger,
|
|
32
|
+
content,
|
|
33
|
+
// Events
|
|
34
|
+
onclick,
|
|
35
|
+
// Zag ---
|
|
36
|
+
...zagProps
|
|
37
|
+
}: PopoverProps = $props();
|
|
38
|
+
|
|
39
|
+
// Zag
|
|
40
|
+
const id = $props.id();
|
|
41
|
+
const service = useMachine(popover.machine, () => ({
|
|
42
|
+
id: id,
|
|
43
|
+
...zagProps
|
|
44
|
+
}));
|
|
45
|
+
const api = $derived(popover.connect(service, normalizeProps));
|
|
46
|
+
const triggerProps = $derived(mergeProps(api.getTriggerProps(), { onclick }));
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<span class="{base} {classes}" data-testid="popover">
|
|
50
|
+
<!-- Snippet: Trigger -->
|
|
51
|
+
{#if trigger}
|
|
52
|
+
<button {...triggerProps} class="{triggerBase} {triggerBackground} {triggerClasses}" type="button" aria-label={triggerAriaLabel}>
|
|
53
|
+
{@render trigger()}
|
|
54
|
+
</button>
|
|
55
|
+
{/if}
|
|
56
|
+
<!-- Portal -->
|
|
57
|
+
<div use:portal={{ disabled: !api.portalled }} {...api.getPositionerProps()} class="{positionerBase} {positionerClasses}">
|
|
58
|
+
<!-- Popover -->
|
|
59
|
+
{#if api.open}
|
|
60
|
+
<div {...api.getContentProps()} transition:fade={{ duration: 100 }} style="z-index: {zIndex};">
|
|
61
|
+
<!-- Arrow -->
|
|
62
|
+
{#if arrow}
|
|
63
|
+
<div {...api.getArrowProps()}>
|
|
64
|
+
<div {...api.getArrowTipProps()} class="{arrowBase} {arrowBackground} {arrowClasses}"></div>
|
|
65
|
+
</div>
|
|
66
|
+
{/if}
|
|
67
|
+
<!-- Snippet: Content -->
|
|
68
|
+
<div class="{contentBase} {contentBackground} {contentClasses}">{@render content?.()}</div>
|
|
69
|
+
</div>
|
|
70
|
+
{/if}
|
|
71
|
+
</div>
|
|
72
|
+
</span>
|
|
73
|
+
|
|
74
|
+
<style>
|
|
75
|
+
:global([data-part='arrow']) {
|
|
76
|
+
--arrow-size: 10px;
|
|
77
|
+
}
|
|
78
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import * as popover from '@zag-js/popover';
|
|
3
|
+
export interface PopoverProps extends Omit<popover.Props, 'id'> {
|
|
4
|
+
/** Enable display of the popover arrow. */
|
|
5
|
+
arrow?: boolean;
|
|
6
|
+
/** Set z-index for the positioner. */
|
|
7
|
+
zIndex?: string;
|
|
8
|
+
/** Set base classes for the root element. */
|
|
9
|
+
base?: string;
|
|
10
|
+
/** Provide arbitrary classes for the root element. */
|
|
11
|
+
classes?: string;
|
|
12
|
+
/** Set base classes for the trigger. */
|
|
13
|
+
triggerBase?: string;
|
|
14
|
+
/** Set background classes for the trigger. */
|
|
15
|
+
triggerBackground?: string;
|
|
16
|
+
/** Provide arbitrary classes for the trigger. */
|
|
17
|
+
triggerClasses?: string;
|
|
18
|
+
/** Set the aria-label for the trigger. */
|
|
19
|
+
triggerAriaLabel?: string;
|
|
20
|
+
/** Set base classes for the positioner. */
|
|
21
|
+
positionerBase?: string;
|
|
22
|
+
/** Provide arbitrary classes for the positioner. */
|
|
23
|
+
positionerClasses?: string;
|
|
24
|
+
/** Set base classes for the content. */
|
|
25
|
+
contentBase?: string;
|
|
26
|
+
/** Set background classes for the content. */
|
|
27
|
+
contentBackground?: string;
|
|
28
|
+
/** Provide arbitrary classes for the content. */
|
|
29
|
+
contentClasses?: string;
|
|
30
|
+
/** Set base classes for the arrow. */
|
|
31
|
+
arrowBase?: string;
|
|
32
|
+
/** Set background classes for the arrow. */
|
|
33
|
+
arrowBackground?: string;
|
|
34
|
+
/** Provide arbitrary classes for the arrow. */
|
|
35
|
+
arrowClasses?: string;
|
|
36
|
+
/** Provide the template contents inside the trigger button. */
|
|
37
|
+
trigger?: Snippet;
|
|
38
|
+
/** Provide the template contents of the popover itself. */
|
|
39
|
+
content?: Snippet;
|
|
40
|
+
/** Handle the popover button click event. */
|
|
41
|
+
onclick?: () => void;
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as popover from '@zag-js/popover';
|