@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.
Files changed (122) hide show
  1. package/README.md +1 -1
  2. package/dist/components/Accordion/Accordion.svelte +49 -52
  3. package/dist/components/Accordion/Accordion.svelte.d.ts +2 -14
  4. package/dist/components/Accordion/AccordionItem.svelte +43 -37
  5. package/dist/components/Accordion/AccordionItem.svelte.d.ts +2 -14
  6. package/dist/components/Accordion/context.js +2 -1
  7. package/dist/components/Accordion/index.d.ts +4 -0
  8. package/dist/components/Accordion/index.js +1 -1
  9. package/dist/components/Accordion/types.d.ts +7 -9
  10. package/dist/components/AppBar/AppBar.svelte +43 -40
  11. package/dist/components/AppBar/AppBar.svelte.d.ts +2 -14
  12. package/dist/components/Avatar/Avatar.svelte +56 -44
  13. package/dist/components/Avatar/Avatar.svelte.d.ts +2 -14
  14. package/dist/components/Avatar/types.d.ts +3 -3
  15. package/dist/components/Combobox/Combobox.svelte +144 -0
  16. package/dist/components/Combobox/Combobox.svelte.d.ts +18 -0
  17. package/dist/components/Combobox/types.d.ts +64 -0
  18. package/dist/components/Combobox/types.js +1 -0
  19. package/dist/components/FileUpload/FileUpload.svelte +70 -63
  20. package/dist/components/FileUpload/FileUpload.svelte.d.ts +2 -14
  21. package/dist/components/FileUpload/types.d.ts +3 -4
  22. package/dist/components/Modal/Modal.svelte +87 -0
  23. package/dist/components/Modal/Modal.svelte.d.ts +4 -0
  24. package/dist/components/Modal/types.d.ts +57 -0
  25. package/dist/components/Modal/types.js +1 -0
  26. package/dist/components/Navigation/NavBar.svelte +48 -0
  27. package/dist/components/Navigation/NavBar.svelte.d.ts +5 -0
  28. package/dist/components/Navigation/NavRail.svelte +90 -0
  29. package/dist/components/Navigation/NavRail.svelte.d.ts +5 -0
  30. package/dist/components/Navigation/NavTile.svelte +87 -0
  31. package/dist/components/Navigation/NavTile.svelte.d.ts +5 -0
  32. package/dist/components/Navigation/context.js +7 -0
  33. package/dist/components/Navigation/index.d.ts +6 -0
  34. package/dist/components/{Nav → Navigation}/index.js +1 -1
  35. package/dist/components/{Nav → Navigation}/types.d.ts +5 -3
  36. package/dist/components/Pagination/Pagination.svelte +58 -67
  37. package/dist/components/Pagination/Pagination.svelte.d.ts +2 -14
  38. package/dist/components/Pagination/types.d.ts +15 -15
  39. package/dist/components/Popover/Popover.svelte +78 -0
  40. package/dist/components/Popover/Popover.svelte.d.ts +4 -0
  41. package/dist/components/Popover/types.d.ts +42 -0
  42. package/dist/components/Popover/types.js +1 -0
  43. package/dist/components/Progress/Progress.svelte +44 -38
  44. package/dist/components/Progress/Progress.svelte.d.ts +2 -14
  45. package/dist/components/Progress/types.d.ts +1 -1
  46. package/dist/components/ProgressRing/ProgressRing.svelte +58 -46
  47. package/dist/components/ProgressRing/ProgressRing.svelte.d.ts +2 -14
  48. package/dist/components/ProgressRing/types.d.ts +3 -1
  49. package/dist/components/Rating/Rating.svelte +101 -57
  50. package/dist/components/Rating/Rating.svelte.d.ts +2 -14
  51. package/dist/components/Rating/types.d.ts +1 -5
  52. package/dist/components/Segment/Segment.svelte +59 -61
  53. package/dist/components/Segment/Segment.svelte.d.ts +3 -15
  54. package/dist/components/Segment/SegmentItem.svelte +28 -21
  55. package/dist/components/Segment/SegmentItem.svelte.d.ts +2 -14
  56. package/dist/components/Segment/context.js +3 -2
  57. package/dist/components/Segment/index.d.ts +4 -0
  58. package/dist/components/Segment/index.js +1 -1
  59. package/dist/components/Segment/types.d.ts +8 -10
  60. package/dist/components/Slider/Slider.svelte +67 -72
  61. package/dist/components/Slider/Slider.svelte.d.ts +2 -14
  62. package/dist/components/Slider/types.d.ts +5 -9
  63. package/dist/components/Switch/Switch.svelte +75 -90
  64. package/dist/components/Switch/Switch.svelte.d.ts +2 -14
  65. package/dist/components/Switch/types.d.ts +2 -8
  66. package/dist/components/Tabs/Tabs.svelte +59 -0
  67. package/dist/components/Tabs/Tabs.svelte.d.ts +5 -0
  68. package/dist/components/Tabs/TabsControl.svelte +51 -0
  69. package/dist/components/Tabs/TabsControl.svelte.d.ts +5 -0
  70. package/dist/components/Tabs/TabsPanel.svelte +23 -0
  71. package/dist/components/Tabs/TabsPanel.svelte.d.ts +5 -0
  72. package/dist/components/{Tab → Tabs}/context.js +3 -2
  73. package/dist/components/Tabs/index.d.ts +5 -0
  74. package/dist/components/{Tab → Tabs}/index.js +1 -1
  75. package/dist/components/{Tab → Tabs}/types.d.ts +1 -3
  76. package/dist/components/TagsInput/TagsInput.svelte +48 -54
  77. package/dist/components/TagsInput/TagsInput.svelte.d.ts +2 -14
  78. package/dist/components/TagsInput/types.d.ts +3 -7
  79. package/dist/components/Toast/Toast.svelte +68 -0
  80. package/dist/components/Toast/Toast.svelte.d.ts +4 -0
  81. package/dist/components/Toast/Toaster.svelte +68 -0
  82. package/dist/components/Toast/Toaster.svelte.d.ts +4 -0
  83. package/dist/components/Toast/create-toaster.d.ts +2 -0
  84. package/dist/components/Toast/create-toaster.js +5 -0
  85. package/dist/components/Toast/types.d.ts +43 -0
  86. package/dist/components/Toast/types.js +1 -0
  87. package/dist/components/Tooltip/Tooltip.svelte +79 -0
  88. package/dist/components/Tooltip/Tooltip.svelte.d.ts +4 -0
  89. package/dist/components/Tooltip/types.d.ts +44 -0
  90. package/dist/components/Tooltip/types.js +1 -0
  91. package/dist/index.d.ts +8 -2
  92. package/dist/index.js +12 -3
  93. package/dist/internal/create-context.d.ts +6 -0
  94. package/dist/internal/create-context.js +3 -3
  95. package/dist/internal/test-utils.d.ts +3 -0
  96. package/dist/internal/test-utils.js +9 -0
  97. package/package.json +43 -54
  98. package/dist/components/Accordion/Accordion.svelte.spec.d.ts +0 -1
  99. package/dist/components/Accordion/Accordion.svelte.spec.js +0 -4
  100. package/dist/components/Nav/NavBar.svelte +0 -45
  101. package/dist/components/Nav/NavBar.svelte.d.ts +0 -17
  102. package/dist/components/Nav/NavRail.svelte +0 -79
  103. package/dist/components/Nav/NavRail.svelte.d.ts +0 -17
  104. package/dist/components/Nav/NavTile.svelte +0 -76
  105. package/dist/components/Nav/NavTile.svelte.d.ts +0 -17
  106. package/dist/components/Nav/context.js +0 -7
  107. package/dist/components/Tab/Tabs.svelte +0 -65
  108. package/dist/components/Tab/Tabs.svelte.d.ts +0 -17
  109. package/dist/components/Tab/TabsControl.svelte +0 -42
  110. package/dist/components/Tab/TabsControl.svelte.d.ts +0 -17
  111. package/dist/components/Tab/TabsPanel.svelte +0 -18
  112. package/dist/components/Tab/TabsPanel.svelte.d.ts +0 -17
  113. package/dist/internal/noop.d.ts +0 -1
  114. package/dist/internal/noop.js +0 -2
  115. package/dist/internal/snippets.d.ts +0 -3
  116. package/dist/internal/snippets.js +0 -45
  117. package/dist/internal/use-id.d.ts +0 -2
  118. package/dist/internal/use-id.js +0 -5
  119. /package/dist/components/{Nav → Navigation}/context.d.ts +0 -0
  120. /package/dist/components/{Nav → Navigation}/types.js +0 -0
  121. /package/dist/components/{Tab → Tabs}/context.d.ts +0 -0
  122. /package/dist/components/{Tab → Tabs}/types.js +0 -0
@@ -1,41 +1,47 @@
1
- <script lang="ts">import * as progress from "@zag-js/progress";
2
- import { normalizeProps, useMachine } from "@zag-js/svelte";
3
- import { useId } from "../../internal/use-id.js";
4
- let {
5
- // Root
6
- base = "flex items-center gap-4",
7
- height = "h-2",
8
- width = "w-full",
9
- classes = "",
10
- // Label
11
- labelBase = "whitespace-nowrap",
12
- labelText = "text-xs",
13
- labelClasses = "",
14
- // Track
15
- trackBase = "h-full w-full overflow-x-hidden",
16
- trackBg = "bg-surface-200-800",
17
- trackRounded = "rounded",
18
- trackClasses = "",
19
- // Meter
20
- meterBase = "h-full w-full",
21
- meterBg = "bg-surface-950-50",
22
- meterRounded = "rounded",
23
- meterTransition = "transition-[width]",
24
- meterAnimate = "animate-progress-indeterminate",
25
- meterClasses = "",
26
- // Snippets
27
- children,
28
- // Zag
29
- ...zagProps
30
- } = $props();
31
- const [state, send] = useMachine(
32
- progress.machine({
33
- id: useId()
34
- }),
35
- { context: zagProps }
36
- );
37
- const api = $derived(progress.connect(state, send, normalizeProps));
38
- const rxIndeterminate = $derived(state.context.isIndeterminate ? meterAnimate : "");
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: $$__sveltets_2_IsomorphicComponent<ProgressProps, {
14
- [evt: string]: CustomEvent<any>;
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.Context, 'id'> {
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">import * as progress from "@zag-js/progress";
2
- import { normalizeProps, useMachine } from "@zag-js/svelte";
3
- import { useId } from "../../internal/use-id.js";
4
- let {
5
- label,
6
- strokeWidth = "10px",
7
- strokeLinecap = "round",
8
- // Root
9
- base = "relative",
10
- size = "size-32",
11
- classes = "",
12
- // Slot
13
- childrenBase = "absolute top-0 left-0 z-[1] flex justify-center items-center",
14
- childrenClasses = "",
15
- // SVG
16
- svgBase = "absolute top-0 left-0 size-full rounded-full",
17
- svgClasses = "",
18
- // Track
19
- trackBase = "fill-none",
20
- trackStroke = "stroke-surface-200-800",
21
- trackClasses = "",
22
- // Meter
23
- meterBase = "fill-none",
24
- meterStroke = "stroke-primary-500",
25
- meterTransition = "transition-[stroke-dashoffset] transition-[stroke-dashoffset]",
26
- meterAnimate = "animate-ring-indeterminate",
27
- meterDuration = "duration-200",
28
- meterClasses = "",
29
- // Label
30
- labelBase = "",
31
- labelFill = "fill-surface-950-50",
32
- labelFontSize = 24,
33
- // px
34
- labelFontWeight = "bold",
35
- labelClasses = "",
36
- // Snippets
37
- children,
38
- // Zag
39
- ...zagProps
40
- } = $props();
41
- const [snapshot, send] = useMachine(progress.machine({ id: useId() }), { context: zagProps });
42
- const api = $derived(progress.connect(snapshot, send, normalizeProps));
43
- const rxAnimCircle = $derived(api.indeterminate && "animate-spin");
44
- const rxAnimMeter = $derived(api.indeterminate && meterAnimate);
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:100%;--thickness:{strokeWidth};"
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: $$__sveltets_2_IsomorphicComponent<ProgressRingProps, {
14
- [evt: string]: CustomEvent<any>;
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.Context, 'id'> {
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">import * as rating from "@zag-js/rating-group";
2
- import { useMachine, normalizeProps } from "@zag-js/svelte";
3
- import { useId } from "../../internal/use-id.js";
4
- import { starEmpty, starHalf, starFull } from "../../internal/snippets.js";
5
- import { noop } from "../../internal/noop.js";
6
- let {
7
- value = $bindable(),
8
- // Root
9
- base = "",
10
- classes = "",
11
- // Control
12
- controlBase = "flex",
13
- controlGap = "gap-2",
14
- controlClasses,
15
- // Label
16
- labelBase = "",
17
- labelClasses = "",
18
- // Item
19
- itemBase = "",
20
- itemClasses = "",
21
- // State
22
- stateInteractive = "cursor-pointer",
23
- stateReadOnly = "",
24
- stateDisabled = "cursor-not-allowed opacity-50",
25
- // Icons
26
- iconEmpty = starEmpty,
27
- iconHalf = starHalf,
28
- iconFull = starFull,
29
- // Children
30
- label,
31
- // Events
32
- onValueChange = noop,
33
- // Zag
34
- ...zagProps
35
- } = $props();
36
- const [state, send] = useMachine(
37
- rating.machine({
38
- id: useId(),
39
- onValueChange: (details) => {
40
- value = details.value;
41
- onValueChange(details.value);
42
- }
43
- }),
44
- {
45
- context: {
46
- ...zagProps,
47
- get value() {
48
- return value;
49
- }
50
- }
51
- }
52
- );
53
- const api = $derived(rating.connect(state, send, normalizeProps));
54
- const rxInteractive = $derived(state.context.isInteractive ? stateInteractive : "");
55
- const rxReadOnly = $derived(state.context.readOnly ? stateReadOnly : "");
56
- const rxDisabled = $derived(state.context.disabled ? stateDisabled : "");
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} {rxInteractive} {rxReadOnly} {rxDisabled} {controlClasses}"
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: $$__sveltets_2_IsomorphicComponent<RatingProps, {
14
- [evt: string]: CustomEvent<any>;
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.Context, 'id' | 'onValueChange'> {
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">import * as radio from "@zag-js/radio-group";
2
- import { useMachine, normalizeProps } from "@zag-js/svelte";
3
- import { setSegmentContext } from "./context.js";
4
- import { useId } from "../../internal/use-id.js";
5
- let {
6
- value = $bindable(""),
7
- orientation = "horizontal",
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",
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",
27
- indicatorClasses = "",
28
- // Snippets
29
- children,
30
- // Zag
31
- ...zagProps
32
- } = $props();
33
- const [snapshot, send] = useMachine(
34
- radio.machine({
35
- id: useId(),
36
- onValueChange(details) {
37
- value = details.value;
38
- },
39
- orientation
40
- }),
41
- {
42
- context: {
43
- ...zagProps,
44
- get value() {
45
- return value;
46
- }
47
- }
48
- }
49
- );
50
- const api = $derived(radio.connect(snapshot, send, normalizeProps));
51
- setSegmentContext({
52
- get api() {
53
- return api;
54
- },
55
- get indicatorText() {
56
- return indicatorText;
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 { SegmentControl } 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
- }
1
+ import type { SegmentProps } from './types.js';
12
2
  /** Capture input for a limited set of options. */
13
- declare const Segment: $$__sveltets_2_IsomorphicComponent<SegmentControl, {
14
- [evt: string]: CustomEvent<any>;
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;