@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
|
@@ -1,41 +1,47 @@
|
|
|
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
|
-
const
|
|
38
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as progress from '@zag-js/progress';
|
|
3
|
+
import { normalizeProps, useMachine } from '@zag-js/svelte';
|
|
4
|
+
import type { ProgressProps } from './types.js';
|
|
5
|
+
|
|
6
|
+
// Props
|
|
7
|
+
const {
|
|
8
|
+
// Root
|
|
9
|
+
base = 'flex items-center gap-4',
|
|
10
|
+
height = 'h-2',
|
|
11
|
+
width = 'w-full',
|
|
12
|
+
classes = '',
|
|
13
|
+
// Label
|
|
14
|
+
labelBase = 'whitespace-nowrap',
|
|
15
|
+
labelText = 'text-xs',
|
|
16
|
+
labelClasses = '',
|
|
17
|
+
// Track
|
|
18
|
+
trackBase = 'h-full w-full overflow-x-hidden',
|
|
19
|
+
trackBg = 'bg-surface-200-800',
|
|
20
|
+
trackRounded = 'rounded-base',
|
|
21
|
+
trackClasses = '',
|
|
22
|
+
// Meter
|
|
23
|
+
meterBase = 'h-full w-full',
|
|
24
|
+
meterBg = 'bg-surface-950-50',
|
|
25
|
+
meterRounded = 'rounded-base',
|
|
26
|
+
meterTransition = 'transition-[width]',
|
|
27
|
+
meterAnimate = 'animate-progress-indeterminate',
|
|
28
|
+
meterClasses = '',
|
|
29
|
+
// Snippets
|
|
30
|
+
children,
|
|
31
|
+
// Zag
|
|
32
|
+
...zagProps
|
|
33
|
+
}: ProgressProps = $props();
|
|
34
|
+
|
|
35
|
+
// Zag
|
|
36
|
+
const id = $props.id();
|
|
37
|
+
const service = useMachine(progress.machine, () => ({
|
|
38
|
+
id: id,
|
|
39
|
+
...zagProps
|
|
40
|
+
}));
|
|
41
|
+
const api = $derived(progress.connect(service, normalizeProps));
|
|
42
|
+
|
|
43
|
+
// Reactive
|
|
44
|
+
const rxIndeterminate = $derived(api.indeterminate ? meterAnimate : '');
|
|
39
45
|
</script>
|
|
40
46
|
|
|
41
47
|
<!-- @component A linear progress bar. -->
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import type { ProgressProps } from './types.js';
|
|
2
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
-
$$bindings?: Bindings;
|
|
5
|
-
} & Exports;
|
|
6
|
-
(internal: unknown, props: Props & {
|
|
7
|
-
$$events?: Events;
|
|
8
|
-
$$slots?: Slots;
|
|
9
|
-
}): Exports;
|
|
10
|
-
z_$$bindings?: Bindings;
|
|
11
|
-
}
|
|
12
2
|
/** A linear progress bar. */
|
|
13
|
-
declare const Progress:
|
|
14
|
-
|
|
15
|
-
}, {}, {}, "">;
|
|
16
|
-
type Progress = InstanceType<typeof Progress>;
|
|
3
|
+
declare const Progress: import("svelte").Component<ProgressProps, {}, "">;
|
|
4
|
+
type Progress = ReturnType<typeof Progress>;
|
|
17
5
|
export default Progress;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as progress from '@zag-js/progress';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
export interface ProgressProps extends Omit<progress.
|
|
3
|
+
export interface ProgressProps extends Omit<progress.Props, 'id'> {
|
|
4
4
|
/** Set root base classes */
|
|
5
5
|
base?: string;
|
|
6
6
|
/** Set root background classes */
|
|
@@ -1,47 +1,58 @@
|
|
|
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
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as progress from '@zag-js/progress';
|
|
3
|
+
import { normalizeProps, useMachine } from '@zag-js/svelte';
|
|
4
|
+
|
|
5
|
+
import type { ProgressRingProps } from './types.js';
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
label,
|
|
9
|
+
showLabel = false,
|
|
10
|
+
strokeWidth = '10px',
|
|
11
|
+
strokeLinecap = 'round',
|
|
12
|
+
// Root
|
|
13
|
+
base = 'relative',
|
|
14
|
+
size = 'size-32',
|
|
15
|
+
classes = '',
|
|
16
|
+
// Slot
|
|
17
|
+
childrenBase = 'absolute top-0 left-0 z-[1] flex justify-center items-center',
|
|
18
|
+
childrenClasses = '',
|
|
19
|
+
// SVG
|
|
20
|
+
svgBase = 'absolute top-0 left-0 size-full rounded-full',
|
|
21
|
+
svgClasses = '',
|
|
22
|
+
// Track
|
|
23
|
+
trackBase = 'fill-none',
|
|
24
|
+
trackStroke = 'stroke-surface-200-800',
|
|
25
|
+
trackClasses = '',
|
|
26
|
+
// Meter
|
|
27
|
+
meterBase = 'fill-none',
|
|
28
|
+
meterStroke = 'stroke-primary-500',
|
|
29
|
+
meterTransition = 'transition-[stroke-dashoffset] transition-[stroke-dashoffset]',
|
|
30
|
+
meterAnimate = 'animate-ring-indeterminate',
|
|
31
|
+
meterDuration = 'duration-200',
|
|
32
|
+
meterClasses = '',
|
|
33
|
+
// Label
|
|
34
|
+
labelBase = '',
|
|
35
|
+
labelFill = 'fill-surface-950-50',
|
|
36
|
+
labelFontSize = 24, // px
|
|
37
|
+
labelFontWeight = 'bold',
|
|
38
|
+
labelClasses = '',
|
|
39
|
+
// Snippets
|
|
40
|
+
children,
|
|
41
|
+
// Zag
|
|
42
|
+
...zagProps
|
|
43
|
+
}: ProgressRingProps = $props();
|
|
44
|
+
|
|
45
|
+
// Zag
|
|
46
|
+
const id = $props.id();
|
|
47
|
+
const service = useMachine(progress.machine, () => ({
|
|
48
|
+
id: id,
|
|
49
|
+
...zagProps
|
|
50
|
+
}));
|
|
51
|
+
const api = $derived(progress.connect(service, normalizeProps));
|
|
52
|
+
|
|
53
|
+
// Reactive Classes
|
|
54
|
+
const rxAnimCircle = $derived(api.indeterminate ? 'animate-spin' : '');
|
|
55
|
+
const rxAnimMeter = $derived(api.indeterminate ? meterAnimate : '');
|
|
45
56
|
</script>
|
|
46
57
|
|
|
47
58
|
<!-- @component A circular progress bar. -->
|
|
@@ -54,8 +65,9 @@ const rxAnimMeter = $derived(api.indeterminate && meterAnimate);
|
|
|
54
65
|
<!-- SVG -->
|
|
55
66
|
<svg
|
|
56
67
|
{...api.getCircleProps()}
|
|
68
|
+
viewBox="0 0 100 100"
|
|
57
69
|
class="{svgBase} {svgClasses} {rxAnimCircle}"
|
|
58
|
-
style="--size:
|
|
70
|
+
style="--size:100px;--thickness:{strokeWidth};"
|
|
59
71
|
data-testid="progress-ring-svg"
|
|
60
72
|
>
|
|
61
73
|
<!-- Track -->
|
|
@@ -68,7 +80,7 @@ const rxAnimMeter = $derived(api.indeterminate && meterAnimate);
|
|
|
68
80
|
data-testid="progress-ring-meter"
|
|
69
81
|
/>
|
|
70
82
|
<!-- Label -->
|
|
71
|
-
{#if api.value !== null && !children}
|
|
83
|
+
{#if api.value !== null && !children && showLabel}
|
|
72
84
|
<text
|
|
73
85
|
class="{labelBase} {labelFill} {labelClasses}"
|
|
74
86
|
x="50%"
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import type { ProgressRingProps } from './types.js';
|
|
2
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
-
$$bindings?: Bindings;
|
|
5
|
-
} & Exports;
|
|
6
|
-
(internal: unknown, props: Props & {
|
|
7
|
-
$$events?: Events;
|
|
8
|
-
$$slots?: Slots;
|
|
9
|
-
}): Exports;
|
|
10
|
-
z_$$bindings?: Bindings;
|
|
11
|
-
}
|
|
12
2
|
/** A circular progress bar. */
|
|
13
|
-
declare const ProgressRing:
|
|
14
|
-
|
|
15
|
-
}, {}, {}, "">;
|
|
16
|
-
type ProgressRing = InstanceType<typeof ProgressRing>;
|
|
3
|
+
declare const ProgressRing: import("svelte").Component<ProgressRingProps, {}, "">;
|
|
4
|
+
type ProgressRing = ReturnType<typeof ProgressRing>;
|
|
17
5
|
export default ProgressRing;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import * as progress from '@zag-js/progress';
|
|
3
|
-
export interface ProgressRingProps extends Omit<progress.
|
|
3
|
+
export interface ProgressRingProps extends Omit<progress.Props, 'id'> {
|
|
4
4
|
/** Set the text for the scalable label */
|
|
5
5
|
label?: string;
|
|
6
|
+
/** When enabled, show a text label with the percentage amount */
|
|
7
|
+
showLabel?: boolean;
|
|
6
8
|
/** Set the stroke size (ex: 15px) */
|
|
7
9
|
strokeWidth?: string;
|
|
8
10
|
/** Defines the shape of the meter */
|
|
@@ -1,59 +1,103 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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 : '');
|
|
57
101
|
</script>
|
|
58
102
|
|
|
59
103
|
<!-- @component A visual representation of a numeric range. -->
|
|
@@ -68,7 +112,7 @@ const rxDisabled = $derived(state.context.disabled ? stateDisabled : "");
|
|
|
68
112
|
{/if}
|
|
69
113
|
<!-- Control -->
|
|
70
114
|
<div
|
|
71
|
-
class="{controlBase} {controlGap} {
|
|
115
|
+
class="{controlBase} {controlGap} {rxReadOnly} {rxDisabled} {controlClasses}"
|
|
72
116
|
{...api.getControlProps()}
|
|
73
117
|
data-testid="rating-control"
|
|
74
118
|
>
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import type { RatingProps } from './types.js';
|
|
2
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
-
$$bindings?: Bindings;
|
|
5
|
-
} & Exports;
|
|
6
|
-
(internal: unknown, props: Props & {
|
|
7
|
-
$$events?: Events;
|
|
8
|
-
$$slots?: Slots;
|
|
9
|
-
}): Exports;
|
|
10
|
-
z_$$bindings?: Bindings;
|
|
11
|
-
}
|
|
12
2
|
/** A visual representation of a numeric range. */
|
|
13
|
-
declare const Rating:
|
|
14
|
-
|
|
15
|
-
}, {}, {}, "value">;
|
|
16
|
-
type Rating = InstanceType<typeof Rating>;
|
|
3
|
+
declare const Rating: import("svelte").Component<RatingProps, {}, "">;
|
|
4
|
+
type Rating = ReturnType<typeof Rating>;
|
|
17
5
|
export default Rating;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as rating from '@zag-js/rating-group';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
export interface RatingProps extends Omit<rating.
|
|
3
|
+
export interface RatingProps extends Omit<rating.Props, 'id'> {
|
|
4
4
|
/** Set root base classes */
|
|
5
5
|
base?: string;
|
|
6
6
|
/** Set root gap classes */
|
|
@@ -21,8 +21,6 @@ export interface RatingProps extends Omit<rating.Context, 'id' | 'onValueChange'
|
|
|
21
21
|
itemBase?: string;
|
|
22
22
|
/** Set item arbitrary classes */
|
|
23
23
|
itemClasses?: string;
|
|
24
|
-
/** Set item interactive state classes */
|
|
25
|
-
stateInteractive?: string;
|
|
26
24
|
/** Set item read-only state classes */
|
|
27
25
|
stateReadOnly?: string;
|
|
28
26
|
/** Set item disabled state classes */
|
|
@@ -35,6 +33,4 @@ export interface RatingProps extends Omit<rating.Context, 'id' | 'onValueChange'
|
|
|
35
33
|
iconFull?: Snippet;
|
|
36
34
|
/** Set the label snippet */
|
|
37
35
|
label?: Snippet;
|
|
38
|
-
/** Set the onValueChange callback */
|
|
39
|
-
onValueChange?: (value: number) => void;
|
|
40
36
|
}
|
|
@@ -1,64 +1,61 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const rxOrientation = $derived(snapshot.context.orientation === "vertical" ? orientVertical : orientHorizontal);
|
|
60
|
-
const rxDisabled = $derived(snapshot.context.disabled ? stateDisabled : "");
|
|
61
|
-
const rxReadOnly = $derived(snapshot.context.readOnly ? stateReadOnly : "");
|
|
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 = 'p-2',
|
|
12
|
+
gap = 'gap-2',
|
|
13
|
+
padding = '',
|
|
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 : '');
|
|
62
59
|
</script>
|
|
63
60
|
|
|
64
61
|
<!-- @component Capture input for a limited set of options. -->
|
|
@@ -66,6 +63,7 @@ const rxReadOnly = $derived(snapshot.context.readOnly ? stateReadOnly : "");
|
|
|
66
63
|
<div
|
|
67
64
|
{...api.getRootProps()}
|
|
68
65
|
class="{base} {rxOrientation} {background} {border} {padding} {gap} {rounded} {width} {rxDisabled} {rxReadOnly} {classes}"
|
|
66
|
+
aria-labelledby={labelledby}
|
|
69
67
|
data-testid="segment"
|
|
70
68
|
>
|
|
71
69
|
<!-- Indicator -->
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
-
$$bindings?: Bindings;
|
|
5
|
-
} & Exports;
|
|
6
|
-
(internal: unknown, props: Props & {
|
|
7
|
-
$$events?: Events;
|
|
8
|
-
$$slots?: Slots;
|
|
9
|
-
}): Exports;
|
|
10
|
-
z_$$bindings?: Bindings;
|
|
11
|
-
}
|
|
1
|
+
import type { SegmentProps } from './types.js';
|
|
12
2
|
/** Capture input for a limited set of options. */
|
|
13
|
-
declare const Segment:
|
|
14
|
-
|
|
15
|
-
}, {}, {}, "value">;
|
|
16
|
-
type Segment = InstanceType<typeof Segment>;
|
|
3
|
+
declare const Segment: import("svelte").Component<SegmentProps, {}, "">;
|
|
4
|
+
type Segment = ReturnType<typeof Segment>;
|
|
17
5
|
export default Segment;
|