@skeletonlabs/skeleton-svelte 1.5.1 → 2.0.0-next.1
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/{composed → components}/accordion/anatomy/accordion-content.svelte +2 -1
- package/dist/{composed → components}/accordion/anatomy/accordion-heading.svelte +12 -2
- package/dist/{composed → components}/accordion/anatomy/accordion-indicator.svelte +10 -1
- package/dist/{composed → components}/accordion/anatomy/accordion-item.svelte +2 -1
- package/dist/{composed → components}/accordion/anatomy/accordion-root.svelte +2 -1
- package/dist/{composed → components}/accordion/anatomy/accordion-trigger.svelte +2 -2
- package/dist/{composed → components}/avatar/anatomy/avatar-fallback.svelte +2 -1
- package/dist/{composed → components}/avatar/anatomy/avatar-image.svelte +2 -1
- package/dist/{composed → components}/avatar/anatomy/avatar-root.svelte +2 -1
- package/dist/index.css +2 -0
- package/dist/index.d.ts +2 -21
- package/dist/index.js +2 -29
- package/package.json +31 -38
- package/dist/components/Accordion/Accordion.svelte +0 -55
- package/dist/components/Accordion/Accordion.svelte.d.ts +0 -5
- package/dist/components/Accordion/AccordionItem.svelte +0 -90
- package/dist/components/Accordion/AccordionItem.svelte.d.ts +0 -5
- package/dist/components/Accordion/context.d.ts +0 -2
- package/dist/components/Accordion/context.js +0 -3
- package/dist/components/Accordion/index.d.ts +0 -4
- package/dist/components/Accordion/index.js +0 -3
- package/dist/components/Accordion/types.d.ts +0 -74
- package/dist/components/AppBar/AppBar.svelte +0 -72
- package/dist/components/AppBar/AppBar.svelte.d.ts +0 -5
- package/dist/components/AppBar/types.d.ts +0 -61
- package/dist/components/AppBar/types.js +0 -1
- package/dist/components/Avatar/Avatar.svelte +0 -68
- package/dist/components/Avatar/Avatar.svelte.d.ts +0 -5
- package/dist/components/Avatar/types.d.ts +0 -39
- package/dist/components/Avatar/types.js +0 -1
- package/dist/components/Combobox/Combobox.svelte +0 -154
- package/dist/components/Combobox/Combobox.svelte.d.ts +0 -18
- package/dist/components/Combobox/types.d.ts +0 -66
- package/dist/components/Combobox/types.js +0 -1
- package/dist/components/FileUpload/FileUpload.svelte +0 -132
- package/dist/components/FileUpload/FileUpload.svelte.d.ts +0 -5
- package/dist/components/FileUpload/types.d.ts +0 -74
- package/dist/components/FileUpload/types.js +0 -1
- package/dist/components/Modal/Modal.svelte +0 -87
- package/dist/components/Modal/Modal.svelte.d.ts +0 -4
- package/dist/components/Modal/types.d.ts +0 -58
- package/dist/components/Modal/types.js +0 -1
- package/dist/components/Navigation/NavBar.svelte +0 -48
- package/dist/components/Navigation/NavBar.svelte.d.ts +0 -5
- package/dist/components/Navigation/NavRail.svelte +0 -90
- package/dist/components/Navigation/NavRail.svelte.d.ts +0 -5
- package/dist/components/Navigation/NavTile.svelte +0 -87
- package/dist/components/Navigation/NavTile.svelte.d.ts +0 -5
- package/dist/components/Navigation/context.d.ts +0 -2
- package/dist/components/Navigation/context.js +0 -6
- package/dist/components/Navigation/index.d.ts +0 -6
- package/dist/components/Navigation/index.js +0 -4
- package/dist/components/Navigation/types.d.ts +0 -132
- package/dist/components/Navigation/types.js +0 -1
- package/dist/components/Pagination/Pagination.svelte +0 -146
- package/dist/components/Pagination/Pagination.svelte.d.ts +0 -4
- package/dist/components/Pagination/types.d.ts +0 -56
- package/dist/components/Pagination/types.js +0 -1
- package/dist/components/Popover/Popover.svelte +0 -74
- package/dist/components/Popover/Popover.svelte.d.ts +0 -4
- package/dist/components/Popover/types.d.ts +0 -45
- package/dist/components/Popover/types.js +0 -1
- package/dist/components/Progress/Progress.svelte +0 -63
- package/dist/components/Progress/Progress.svelte.d.ts +0 -5
- package/dist/components/Progress/types.d.ts +0 -44
- package/dist/components/Progress/types.js +0 -1
- package/dist/components/ProgressRing/ProgressRing.svelte +0 -98
- package/dist/components/ProgressRing/ProgressRing.svelte.d.ts +0 -5
- package/dist/components/ProgressRing/types.d.ts +0 -56
- package/dist/components/ProgressRing/types.js +0 -1
- package/dist/components/Rating/Rating.svelte +0 -135
- package/dist/components/Rating/Rating.svelte.d.ts +0 -5
- package/dist/components/Rating/index.d.ts +0 -2
- package/dist/components/Rating/index.js +0 -2
- package/dist/components/Rating/types.d.ts +0 -36
- package/dist/components/Rating/types.js +0 -1
- package/dist/components/Segment/Segment.svelte +0 -77
- package/dist/components/Segment/Segment.svelte.d.ts +0 -5
- package/dist/components/Segment/SegmentItem.svelte +0 -40
- package/dist/components/Segment/SegmentItem.svelte.d.ts +0 -5
- package/dist/components/Segment/context.d.ts +0 -2
- package/dist/components/Segment/context.js +0 -6
- package/dist/components/Segment/index.d.ts +0 -4
- package/dist/components/Segment/index.js +0 -3
- package/dist/components/Segment/types.d.ts +0 -64
- package/dist/components/Segment/types.js +0 -1
- package/dist/components/Slider/Slider.svelte +0 -105
- package/dist/components/Slider/Slider.svelte.d.ts +0 -4
- package/dist/components/Slider/types.d.ts +0 -68
- package/dist/components/Slider/types.js +0 -1
- package/dist/components/Switch/Switch.svelte +0 -102
- package/dist/components/Switch/Switch.svelte.d.ts +0 -5
- package/dist/components/Switch/types.d.ts +0 -64
- package/dist/components/Switch/types.js +0 -1
- package/dist/components/Tabs/Tabs.svelte +0 -59
- package/dist/components/Tabs/Tabs.svelte.d.ts +0 -5
- package/dist/components/Tabs/TabsControl.svelte +0 -51
- package/dist/components/Tabs/TabsControl.svelte.d.ts +0 -5
- package/dist/components/Tabs/TabsPanel.svelte +0 -23
- package/dist/components/Tabs/TabsPanel.svelte.d.ts +0 -5
- package/dist/components/Tabs/context.d.ts +0 -2
- package/dist/components/Tabs/context.js +0 -6
- package/dist/components/Tabs/index.d.ts +0 -5
- package/dist/components/Tabs/index.js +0 -4
- package/dist/components/Tabs/types.d.ts +0 -68
- package/dist/components/Tabs/types.js +0 -1
- package/dist/components/TagsInput/TagsInput.svelte +0 -96
- package/dist/components/TagsInput/TagsInput.svelte.d.ts +0 -5
- package/dist/components/TagsInput/types.d.ts +0 -40
- package/dist/components/TagsInput/types.js +0 -1
- package/dist/components/Toast/Toast.svelte +0 -76
- package/dist/components/Toast/Toast.svelte.d.ts +0 -4
- package/dist/components/Toast/Toaster.svelte +0 -72
- package/dist/components/Toast/Toaster.svelte.d.ts +0 -4
- package/dist/components/Toast/create-toaster.d.ts +0 -2
- package/dist/components/Toast/create-toaster.js +0 -4
- package/dist/components/Toast/types.d.ts +0 -47
- package/dist/components/Toast/types.js +0 -1
- package/dist/components/Tooltip/Tooltip.svelte +0 -78
- package/dist/components/Tooltip/Tooltip.svelte.d.ts +0 -4
- package/dist/components/Tooltip/types.d.ts +0 -47
- package/dist/components/Tooltip/types.js +0 -1
- package/dist/composed/accordion/modules/types.js +0 -1
- package/dist/composed/index.d.ts +0 -2
- package/dist/composed/index.js +0 -2
- /package/dist/{composed → components}/accordion/anatomy/accordion-content.svelte.d.ts +0 -0
- /package/dist/{composed → components}/accordion/anatomy/accordion-heading.svelte.d.ts +0 -0
- /package/dist/{composed → components}/accordion/anatomy/accordion-indicator.svelte.d.ts +0 -0
- /package/dist/{composed → components}/accordion/anatomy/accordion-item.svelte.d.ts +0 -0
- /package/dist/{composed → components}/accordion/anatomy/accordion-root.svelte.d.ts +0 -0
- /package/dist/{composed → components}/accordion/anatomy/accordion-trigger.svelte.d.ts +0 -0
- /package/dist/{composed → components}/accordion/index.d.ts +0 -0
- /package/dist/{composed → components}/accordion/index.js +0 -0
- /package/dist/{composed → components}/accordion/modules/anatomy.d.ts +0 -0
- /package/dist/{composed → components}/accordion/modules/anatomy.js +0 -0
- /package/dist/{composed → components}/accordion/modules/context.d.ts +0 -0
- /package/dist/{composed → components}/accordion/modules/context.js +0 -0
- /package/dist/{composed → components}/accordion/modules/types.d.ts +0 -0
- /package/dist/components/{Accordion → accordion/modules}/types.js +0 -0
- /package/dist/{composed → components}/avatar/anatomy/avatar-fallback.svelte.d.ts +0 -0
- /package/dist/{composed → components}/avatar/anatomy/avatar-image.svelte.d.ts +0 -0
- /package/dist/{composed → components}/avatar/anatomy/avatar-root.svelte.d.ts +0 -0
- /package/dist/{composed → components}/avatar/index.d.ts +0 -0
- /package/dist/{composed → components}/avatar/index.js +0 -0
- /package/dist/{composed → components}/avatar/modules/anatomy.d.ts +0 -0
- /package/dist/{composed → components}/avatar/modules/anatomy.js +0 -0
- /package/dist/{composed → components}/avatar/modules/context.d.ts +0 -0
- /package/dist/{composed → components}/avatar/modules/context.js +0 -0
- /package/dist/{composed → components}/avatar/modules/types.d.ts +0 -0
- /package/dist/{composed → components}/avatar/modules/types.js +0 -0
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import { createRawSnippet } from 'svelte';
|
|
3
|
-
|
|
4
|
-
const starEmpty = createRawSnippet(() => {
|
|
5
|
-
return {
|
|
6
|
-
render: () => /* html */ `
|
|
7
|
-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" height="24" width="24">
|
|
8
|
-
<path
|
|
9
|
-
stroke-linecap="round"
|
|
10
|
-
stroke-linejoin="round"
|
|
11
|
-
d="M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.562.562 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.562.562 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z"
|
|
12
|
-
/>
|
|
13
|
-
</svg>
|
|
14
|
-
`
|
|
15
|
-
};
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const starHalf = createRawSnippet(() => {
|
|
19
|
-
return {
|
|
20
|
-
render: () => /* html */ `
|
|
21
|
-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" height="24" width="24">
|
|
22
|
-
<path
|
|
23
|
-
stroke-linecap="round"
|
|
24
|
-
stroke-linejoin="round"
|
|
25
|
-
d="M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.562.562 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.562.562 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z"
|
|
26
|
-
/>
|
|
27
|
-
<defs>
|
|
28
|
-
<linearGradient id="half-fill">
|
|
29
|
-
<stop offset="50%" stop-color="currentColor" />
|
|
30
|
-
<stop offset="50%" stop-color="transparent" />
|
|
31
|
-
</linearGradient>
|
|
32
|
-
</defs>
|
|
33
|
-
<path
|
|
34
|
-
fill="url(#half-fill)"
|
|
35
|
-
d="M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.006 5.404.434c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.434 2.082-5.005Z"
|
|
36
|
-
/>
|
|
37
|
-
</svg>
|
|
38
|
-
`
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const starFull = createRawSnippet(() => {
|
|
43
|
-
return {
|
|
44
|
-
render: () => /*html*/ `
|
|
45
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" height="24" width="24">
|
|
46
|
-
<path
|
|
47
|
-
fill-rule="evenodd"
|
|
48
|
-
d="M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.006 5.404.434c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.434 2.082-5.005Z"
|
|
49
|
-
clip-rule="evenodd"
|
|
50
|
-
/>
|
|
51
|
-
</svg>
|
|
52
|
-
`
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
</script>
|
|
56
|
-
|
|
57
|
-
<script lang="ts">
|
|
58
|
-
import * as rating from '@zag-js/rating-group';
|
|
59
|
-
import { useMachine, normalizeProps } from '@zag-js/svelte';
|
|
60
|
-
import type { RatingProps } from './types.js';
|
|
61
|
-
|
|
62
|
-
// Props
|
|
63
|
-
const {
|
|
64
|
-
// Root
|
|
65
|
-
base = '',
|
|
66
|
-
classes = '',
|
|
67
|
-
// Control
|
|
68
|
-
controlBase = 'flex',
|
|
69
|
-
controlGap = 'gap-2',
|
|
70
|
-
controlClasses,
|
|
71
|
-
// Label
|
|
72
|
-
labelBase = 'label-text',
|
|
73
|
-
labelClasses = '',
|
|
74
|
-
// Item
|
|
75
|
-
itemBase = 'cursor-pointer',
|
|
76
|
-
itemClasses = '',
|
|
77
|
-
// State
|
|
78
|
-
stateReadOnly = '',
|
|
79
|
-
stateDisabled = 'cursor-not-allowed opacity-50',
|
|
80
|
-
// Icons
|
|
81
|
-
iconEmpty = starEmpty,
|
|
82
|
-
iconHalf = starHalf,
|
|
83
|
-
iconFull = starFull,
|
|
84
|
-
// Children
|
|
85
|
-
label,
|
|
86
|
-
// Zag
|
|
87
|
-
...zagProps
|
|
88
|
-
}: RatingProps = $props();
|
|
89
|
-
|
|
90
|
-
// Zag
|
|
91
|
-
const id = $props.id();
|
|
92
|
-
const service = useMachine(rating.machine, () => ({
|
|
93
|
-
id: id,
|
|
94
|
-
...zagProps
|
|
95
|
-
}));
|
|
96
|
-
const api = $derived(rating.connect(service, normalizeProps));
|
|
97
|
-
|
|
98
|
-
// Reactive
|
|
99
|
-
const rxReadOnly = $derived(service.prop('readOnly') ? stateReadOnly : '');
|
|
100
|
-
const rxDisabled = $derived(service.prop('disabled') ? stateDisabled : '');
|
|
101
|
-
</script>
|
|
102
|
-
|
|
103
|
-
<!-- @component A visual representation of a numeric range. -->
|
|
104
|
-
|
|
105
|
-
<!-- Root -->
|
|
106
|
-
<div class="{base} {classes}" {...api.getRootProps()} data-testid="rating">
|
|
107
|
-
<!-- Label -->
|
|
108
|
-
{#if !!label}
|
|
109
|
-
<label class="{labelBase} {labelClasses}" {...api.getLabelProps()} data-testid="rating-label">
|
|
110
|
-
{@render label()}
|
|
111
|
-
</label>
|
|
112
|
-
{/if}
|
|
113
|
-
<!-- Control -->
|
|
114
|
-
<div
|
|
115
|
-
class="{controlBase} {controlGap} {rxReadOnly} {rxDisabled} {controlClasses}"
|
|
116
|
-
{...api.getControlProps()}
|
|
117
|
-
data-testid="rating-control"
|
|
118
|
-
>
|
|
119
|
-
{#each api.items as index}
|
|
120
|
-
{@const itemState = api.getItemState({ index })}
|
|
121
|
-
<!-- Item -->
|
|
122
|
-
<span class="{itemBase} {itemClasses}" {...api.getItemProps({ index })} data-testid="rating-item">
|
|
123
|
-
{#if !itemState.highlighted}
|
|
124
|
-
{@render iconEmpty()}
|
|
125
|
-
{:else if itemState.half}
|
|
126
|
-
{@render iconHalf()}
|
|
127
|
-
{:else}
|
|
128
|
-
{@render iconFull()}
|
|
129
|
-
{/if}
|
|
130
|
-
</span>
|
|
131
|
-
{/each}
|
|
132
|
-
</div>
|
|
133
|
-
<!-- Hidden Input -->
|
|
134
|
-
<input {...api.getHiddenInputProps()} data-testid="rating-input" />
|
|
135
|
-
</div>
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import * as rating from '@zag-js/rating-group';
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
export interface RatingProps extends Omit<rating.Props, 'id'> {
|
|
4
|
-
/** Set root base classes */
|
|
5
|
-
base?: string;
|
|
6
|
-
/** Set root gap classes */
|
|
7
|
-
gap?: string;
|
|
8
|
-
/** Set root arbitrary classes */
|
|
9
|
-
classes?: string;
|
|
10
|
-
/** Set control base classes */
|
|
11
|
-
controlBase?: string;
|
|
12
|
-
/** Set control gap classes */
|
|
13
|
-
controlGap?: string;
|
|
14
|
-
/** Set control arbitrary classes */
|
|
15
|
-
controlClasses?: string;
|
|
16
|
-
/** Set label base classes */
|
|
17
|
-
labelBase?: string;
|
|
18
|
-
/** Set label arbitrary classes */
|
|
19
|
-
labelClasses?: string;
|
|
20
|
-
/** Set item base classes */
|
|
21
|
-
itemBase?: string;
|
|
22
|
-
/** Set item arbitrary classes */
|
|
23
|
-
itemClasses?: string;
|
|
24
|
-
/** Set item read-only state classes */
|
|
25
|
-
stateReadOnly?: string;
|
|
26
|
-
/** Set item disabled state classes */
|
|
27
|
-
stateDisabled?: string;
|
|
28
|
-
/** Set the empty icon snippet */
|
|
29
|
-
iconEmpty?: Snippet;
|
|
30
|
-
/** Set the half icon snippet */
|
|
31
|
-
iconHalf?: Snippet;
|
|
32
|
-
/** Set the full icon snippet */
|
|
33
|
-
iconFull?: Snippet;
|
|
34
|
-
/** Set the label snippet */
|
|
35
|
-
label?: Snippet;
|
|
36
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import * as rating from '@zag-js/rating-group';
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import * as radio from '@zag-js/radio-group';
|
|
3
|
-
import { useMachine, normalizeProps } from '@zag-js/svelte';
|
|
4
|
-
import type { SegmentProps } from './types.js';
|
|
5
|
-
import { setSegmentContext } from './context.js';
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
// Root
|
|
9
|
-
base = 'inline-flex items-stretch overflow-hidden',
|
|
10
|
-
background = 'preset-outlined-surface-200-800',
|
|
11
|
-
border = '',
|
|
12
|
-
gap = 'gap-2',
|
|
13
|
-
padding = 'p-2',
|
|
14
|
-
rounded = 'rounded-container',
|
|
15
|
-
width = '',
|
|
16
|
-
classes = '',
|
|
17
|
-
// States
|
|
18
|
-
orientVertical = 'flex-col items-stretch',
|
|
19
|
-
orientHorizontal = 'flex-row',
|
|
20
|
-
stateDisabled = 'disabled',
|
|
21
|
-
stateReadOnly = 'pointer-events-none',
|
|
22
|
-
// Indicator
|
|
23
|
-
indicatorBase = 'top-[var(--top)] left-[var(--left)] w-[var(--width)] h-[var(--height)]',
|
|
24
|
-
indicatorBg = 'preset-filled',
|
|
25
|
-
indicatorText = 'text-surface-contrast-950 dark:text-surface-contrast-50',
|
|
26
|
-
indicatorRounded = 'rounded-base',
|
|
27
|
-
indicatorClasses = '',
|
|
28
|
-
// Label
|
|
29
|
-
labelledby = '',
|
|
30
|
-
// Snippets
|
|
31
|
-
children,
|
|
32
|
-
// Zag
|
|
33
|
-
...zagProps
|
|
34
|
-
}: SegmentProps = $props();
|
|
35
|
-
|
|
36
|
-
// Zag
|
|
37
|
-
const id = $props.id();
|
|
38
|
-
const service = useMachine(radio.machine, () => ({
|
|
39
|
-
id: id,
|
|
40
|
-
orientation: zagProps.orientation ?? 'horizontal',
|
|
41
|
-
...zagProps
|
|
42
|
-
}));
|
|
43
|
-
const api = $derived(radio.connect(service, normalizeProps));
|
|
44
|
-
|
|
45
|
-
// Set Context
|
|
46
|
-
setSegmentContext({
|
|
47
|
-
get api() {
|
|
48
|
-
return api;
|
|
49
|
-
},
|
|
50
|
-
get indicatorText() {
|
|
51
|
-
return indicatorText;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Reactive
|
|
56
|
-
const rxOrientation = $derived(service.prop('orientation') === 'vertical' ? orientVertical : orientHorizontal);
|
|
57
|
-
const rxDisabled = $derived(service.prop('disabled') ? stateDisabled : '');
|
|
58
|
-
const rxReadOnly = $derived(service.prop('readOnly') ? stateReadOnly : '');
|
|
59
|
-
</script>
|
|
60
|
-
|
|
61
|
-
<!-- @component Capture input for a limited set of options. -->
|
|
62
|
-
|
|
63
|
-
<div
|
|
64
|
-
{...api.getRootProps()}
|
|
65
|
-
class="{base} {rxOrientation} {background} {border} {padding} {gap} {rounded} {width} {rxDisabled} {rxReadOnly} {classes}"
|
|
66
|
-
aria-labelledby={labelledby}
|
|
67
|
-
data-testid="segment"
|
|
68
|
-
>
|
|
69
|
-
<!-- Indicator -->
|
|
70
|
-
<div
|
|
71
|
-
{...api.getIndicatorProps()}
|
|
72
|
-
class="{indicatorBase} {indicatorBg} {indicatorRounded} {indicatorClasses}"
|
|
73
|
-
data-testid="segment-indicator"
|
|
74
|
-
></div>
|
|
75
|
-
<!-- Items -->
|
|
76
|
-
{@render children?.()}
|
|
77
|
-
</div>
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { SegmentItemProps } from './types.js';
|
|
3
|
-
import { getSegmentContext } from './context.js';
|
|
4
|
-
|
|
5
|
-
let {
|
|
6
|
-
// Root
|
|
7
|
-
base = 'btn cursor-pointer z-[1]',
|
|
8
|
-
classes = '',
|
|
9
|
-
// State
|
|
10
|
-
stateDisabled = 'disabled',
|
|
11
|
-
stateFocused = 'focused',
|
|
12
|
-
// Label
|
|
13
|
-
labelBase = 'pointer-events-none transition-colors duration-100',
|
|
14
|
-
labelClasses = '',
|
|
15
|
-
// Snippets
|
|
16
|
-
children,
|
|
17
|
-
// Zag
|
|
18
|
-
...zagProps
|
|
19
|
-
}: SegmentItemProps = $props();
|
|
20
|
-
|
|
21
|
-
// Context
|
|
22
|
-
const ctx = getSegmentContext();
|
|
23
|
-
|
|
24
|
-
// Reactive
|
|
25
|
-
const state = $derived(ctx.api.getItemState(zagProps));
|
|
26
|
-
const rxDisabled = $derived(state.disabled ? stateDisabled : '');
|
|
27
|
-
const rxActiveText = $derived(state.checked ? ctx.indicatorText : '');
|
|
28
|
-
const rxFocused = $derived(state.focused ? stateFocused : '');
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<!-- @component An individual Segment option. -->
|
|
32
|
-
|
|
33
|
-
<label {...ctx.api.getItemProps(zagProps)} class="{base} {rxDisabled} {rxFocused} {classes}" data-testid="segment-item">
|
|
34
|
-
<!-- Label -->
|
|
35
|
-
<span {...ctx.api.getItemTextProps(zagProps)} class="{labelBase} {rxActiveText} {labelClasses}" data-testid="segment-item-label">
|
|
36
|
-
{@render children?.()}
|
|
37
|
-
</span>
|
|
38
|
-
<!-- Hidden Input -->
|
|
39
|
-
<input {...ctx.api.getItemHiddenInputProps(zagProps)} data-testid="segment-item-input" />
|
|
40
|
-
</label>
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte';
|
|
2
|
-
import * as radio from '@zag-js/radio-group';
|
|
3
|
-
export interface SegmentContext {
|
|
4
|
-
api: ReturnType<typeof radio.connect>;
|
|
5
|
-
indicatorText: string;
|
|
6
|
-
}
|
|
7
|
-
export interface SegmentProps extends Omit<radio.Props, 'id'> {
|
|
8
|
-
/** Sets base classes. */
|
|
9
|
-
base?: string;
|
|
10
|
-
/** Set background classes. */
|
|
11
|
-
background?: string;
|
|
12
|
-
/** Set border classes. */
|
|
13
|
-
border?: string;
|
|
14
|
-
/** Set flex direction classes. */
|
|
15
|
-
flexDirection?: string;
|
|
16
|
-
/** Set gap classes. */
|
|
17
|
-
gap?: string;
|
|
18
|
-
/** Set padding classes. */
|
|
19
|
-
padding?: string;
|
|
20
|
-
/** Set rounded classes. */
|
|
21
|
-
rounded?: string;
|
|
22
|
-
/** Set width classes. */
|
|
23
|
-
width?: string;
|
|
24
|
-
/** Provide arbitrary CSS classes. */
|
|
25
|
-
classes?: string;
|
|
26
|
-
/** Set classes to provide a vertical layout. */
|
|
27
|
-
orientVertical?: string;
|
|
28
|
-
/** Set classes to provide a horizontal layout. */
|
|
29
|
-
orientHorizontal?: string;
|
|
30
|
-
/** Set classes for the disabled state. */
|
|
31
|
-
stateDisabled?: string;
|
|
32
|
-
/** Set classes for the read-only state. */
|
|
33
|
-
stateReadOnly?: string;
|
|
34
|
-
/** Sets base classes to the indicator. */
|
|
35
|
-
indicatorBase?: string;
|
|
36
|
-
/** Sets background classes to the indicator. */
|
|
37
|
-
indicatorBg?: string;
|
|
38
|
-
/** Sets text classes to the indicator. */
|
|
39
|
-
indicatorText?: string;
|
|
40
|
-
/** Sets border radius classes to the indicator. */
|
|
41
|
-
indicatorRounded?: string;
|
|
42
|
-
/** Provide arbitrary CSS classes to the indicator. */
|
|
43
|
-
indicatorClasses?: string;
|
|
44
|
-
/** Set aria-labelledby for element */
|
|
45
|
-
labelledby?: string;
|
|
46
|
-
/** The default child slot. */
|
|
47
|
-
children?: Snippet;
|
|
48
|
-
}
|
|
49
|
-
export interface SegmentItemProps extends Omit<radio.ItemProps, 'invalid'> {
|
|
50
|
-
/** Sets base classes. */
|
|
51
|
-
base?: string;
|
|
52
|
-
/** Provide arbitrary CSS classes. */
|
|
53
|
-
classes?: string;
|
|
54
|
-
/** Set classes for the disabled state. */
|
|
55
|
-
stateDisabled?: string;
|
|
56
|
-
/** Set classes for the focus state. */
|
|
57
|
-
stateFocused?: string;
|
|
58
|
-
/** Sets base classes for the label element. */
|
|
59
|
-
labelBase?: string;
|
|
60
|
-
/** Provide arbitrary CSS classes for the label element. */
|
|
61
|
-
labelClasses?: string;
|
|
62
|
-
/** The default child slot. */
|
|
63
|
-
children?: Snippet;
|
|
64
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import * as radio from '@zag-js/radio-group';
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import * as slider from '@zag-js/slider';
|
|
3
|
-
import { normalizeProps, useMachine } from '@zag-js/svelte';
|
|
4
|
-
import type { SliderProps } from './types.js';
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
markers = [],
|
|
8
|
-
height = 'h-1.5',
|
|
9
|
-
// Root ---
|
|
10
|
-
base = 'w-full bg-green',
|
|
11
|
-
spaceY = '',
|
|
12
|
-
classes = '',
|
|
13
|
-
// Control ---
|
|
14
|
-
controlBase = '',
|
|
15
|
-
controlClasses = '',
|
|
16
|
-
// Track ---
|
|
17
|
-
trackBase = 'overflow-hidden',
|
|
18
|
-
trackBg = 'bg-surface-200-800',
|
|
19
|
-
trackRounded = 'rounded-full',
|
|
20
|
-
trackClasses = '',
|
|
21
|
-
// Meter ---
|
|
22
|
-
meterBase = '',
|
|
23
|
-
meterBg = 'bg-surface-950-50',
|
|
24
|
-
meterRounded = 'rounded-container',
|
|
25
|
-
meterClasses = '',
|
|
26
|
-
// Thumb ---
|
|
27
|
-
thumbBase = 'ring-inset transition-scale duration-100 ease-in-out',
|
|
28
|
-
thumbSize = 'size-8 md:size-5',
|
|
29
|
-
thumbBg = 'bg-surface-50-950',
|
|
30
|
-
thumbRingSize = 'ring-2',
|
|
31
|
-
thumbRingColor = 'ring-surface-950-50',
|
|
32
|
-
thumbRounded = 'rounded-full',
|
|
33
|
-
thumbCursor = 'hover:cursor-pointer',
|
|
34
|
-
thumbClasses = '',
|
|
35
|
-
// Markers ---
|
|
36
|
-
markersBase = '',
|
|
37
|
-
markersClasses = '',
|
|
38
|
-
// Mark ---
|
|
39
|
-
markBase = '',
|
|
40
|
-
markText = 'text-[10px]',
|
|
41
|
-
markOpacity = 'opacity-50',
|
|
42
|
-
markClasses = '',
|
|
43
|
-
// State ---
|
|
44
|
-
stateDisabled = 'disabled',
|
|
45
|
-
stateReadOnly = 'cursor-not-allowed',
|
|
46
|
-
// Children ---
|
|
47
|
-
mark,
|
|
48
|
-
// Zag ---
|
|
49
|
-
...zagProps
|
|
50
|
-
}: SliderProps = $props();
|
|
51
|
-
|
|
52
|
-
// Zag
|
|
53
|
-
const id = $props.id();
|
|
54
|
-
const service = useMachine(slider.machine, () => ({
|
|
55
|
-
id: id,
|
|
56
|
-
...zagProps
|
|
57
|
-
}));
|
|
58
|
-
const api = $derived(slider.connect(service, normalizeProps));
|
|
59
|
-
|
|
60
|
-
// Reactive
|
|
61
|
-
const rxDisabled = $derived(service.prop('disabled') ? stateDisabled : '');
|
|
62
|
-
const rxReadOnly = $derived(service.prop('readOnly') ? stateReadOnly : thumbCursor);
|
|
63
|
-
</script>
|
|
64
|
-
|
|
65
|
-
<div {...api.getRootProps()} class="{base} {height} {spaceY} {rxDisabled} {classes}" data-testid="slider">
|
|
66
|
-
<!-- Control -->
|
|
67
|
-
<div {...api.getControlProps()} class="{controlBase} {controlClasses}" data-testid="slider-control">
|
|
68
|
-
<!-- Track -->
|
|
69
|
-
<div {...api.getTrackProps()} class="{trackBase} {trackBg} {height} {trackRounded} {trackClasses}" data-testid="slider-track">
|
|
70
|
-
<!-- Meter -->
|
|
71
|
-
<div {...api.getRangeProps()} class="{meterBase} {height} {meterBg} {meterRounded} {meterClasses}" data-testid="slider-meter"></div>
|
|
72
|
-
</div>
|
|
73
|
-
<!-- NOTE: this div centers thumbs vertically -->
|
|
74
|
-
<div class={height} style="display: flex; align-items: center; transform: translateY(-100%);" data-testid="slider-thumb-wrapper">
|
|
75
|
-
<!-- Disabled: skipping this so we can match Zag implementation. -->
|
|
76
|
-
<!-- eslint-disable @typescript-eslint/no-unused-vars -->
|
|
77
|
-
{#each api.value as _, index}
|
|
78
|
-
<div {...api.getThumbProps({ index })}>
|
|
79
|
-
<!-- Thumb -->
|
|
80
|
-
<div
|
|
81
|
-
class="{thumbBase} {thumbSize} {thumbBg} {thumbRingSize} {thumbRingColor} {thumbRounded} {rxReadOnly} {thumbClasses}"
|
|
82
|
-
data-testid="slider-thumb"
|
|
83
|
-
></div>
|
|
84
|
-
<!-- Hidden Input(s) -->
|
|
85
|
-
<input {...api.getHiddenInputProps({ index })} data-testid="slider-input" />
|
|
86
|
-
</div>
|
|
87
|
-
{/each}
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
<!-- Markers -->
|
|
91
|
-
{#if markers.length > 0}
|
|
92
|
-
<div {...api.getMarkerGroupProps()} class="{markersBase} {markersClasses}" data-testid="slider-markers">
|
|
93
|
-
{#each markers as value}
|
|
94
|
-
<!-- Mark -->
|
|
95
|
-
<span {...api.getMarkerProps({ value })} class="{markBase} {markText} {markOpacity} {markClasses}" data-testid="slider-mark">
|
|
96
|
-
{#if mark}
|
|
97
|
-
{@render mark(value)}
|
|
98
|
-
{:else}
|
|
99
|
-
{value}
|
|
100
|
-
{/if}
|
|
101
|
-
</span>
|
|
102
|
-
{/each}
|
|
103
|
-
</div>
|
|
104
|
-
{/if}
|
|
105
|
-
</div>
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import * as slider from '@zag-js/slider';
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
export interface SliderProps extends Omit<slider.Props, 'id' | 'thumbSize'> {
|
|
4
|
-
/** Provide an array of value markers */
|
|
5
|
-
markers?: number[];
|
|
6
|
-
/** Set height classes for the overall slider. */
|
|
7
|
-
height?: string;
|
|
8
|
-
/** Set base classes. */
|
|
9
|
-
base?: string;
|
|
10
|
-
/** Set vertical spacing between the control and markers. */
|
|
11
|
-
spaceY?: string;
|
|
12
|
-
/** Provide arbitrary classes for the root. */
|
|
13
|
-
classes?: string;
|
|
14
|
-
/** Set base classes for the control. */
|
|
15
|
-
controlBase?: string;
|
|
16
|
-
/** Provide arbitrary classes for the control. */
|
|
17
|
-
controlClasses?: string;
|
|
18
|
-
/** Set base classes for the track. */
|
|
19
|
-
trackBase?: string;
|
|
20
|
-
/** Set background classes for the track. */
|
|
21
|
-
trackBg?: string;
|
|
22
|
-
/** Set border radius classes for the track. */
|
|
23
|
-
trackRounded?: string;
|
|
24
|
-
/** Provide arbitrary classes for the track. */
|
|
25
|
-
trackClasses?: string;
|
|
26
|
-
/** Set base classes for the meter. */
|
|
27
|
-
meterBase?: string;
|
|
28
|
-
/** Set background classes for the meter. */
|
|
29
|
-
meterBg?: string;
|
|
30
|
-
/** Set border radius classes for the meter. */
|
|
31
|
-
meterRounded?: string;
|
|
32
|
-
/** Provide arbitrary classes for the meter. */
|
|
33
|
-
meterClasses?: string;
|
|
34
|
-
/** Set base classes for the thumb. */
|
|
35
|
-
thumbBase?: string;
|
|
36
|
-
/** Set size classes for the thumb. */
|
|
37
|
-
thumbSize?: string;
|
|
38
|
-
/** Set background classes for the thumb. */
|
|
39
|
-
thumbBg?: string;
|
|
40
|
-
/** Set ring size classes for the thumb. */
|
|
41
|
-
thumbRingSize?: string;
|
|
42
|
-
/** Set ring color classes for the thumb. */
|
|
43
|
-
thumbRingColor?: string;
|
|
44
|
-
/** Set border-radius classes for the thumb. */
|
|
45
|
-
thumbRounded?: string;
|
|
46
|
-
/** Set cursor classes for the thumb. */
|
|
47
|
-
thumbCursor?: string;
|
|
48
|
-
/** Provide arbitrary classes for the thumb. */
|
|
49
|
-
thumbClasses?: string;
|
|
50
|
-
/** Set base classes for the markers. */
|
|
51
|
-
markersBase?: string;
|
|
52
|
-
/** Provide arbitrary classes for the markers. */
|
|
53
|
-
markersClasses?: string;
|
|
54
|
-
/** Set base classes for each mark. */
|
|
55
|
-
markBase?: string;
|
|
56
|
-
/** Set text size classes for each mark. */
|
|
57
|
-
markText?: string;
|
|
58
|
-
/** Set opacity classes for each mark. */
|
|
59
|
-
markOpacity?: string;
|
|
60
|
-
/** Provide arbitrary classes for each mark. */
|
|
61
|
-
markClasses?: string;
|
|
62
|
-
/** Set disabled state classes for the root element. */
|
|
63
|
-
stateDisabled?: string;
|
|
64
|
-
/** Set read-only state classes for the root element. */
|
|
65
|
-
stateReadOnly?: string;
|
|
66
|
-
/** Replace numeric markers with symbol, such as a icon. Takes marker value as argument. */
|
|
67
|
-
mark?: Snippet<[number]>;
|
|
68
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import * as slider from '@zag-js/slider';
|