@skeletonlabs/skeleton-svelte 2.0.0-next.3 → 2.0.0-next.4

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 (154) hide show
  1. package/dist/components/accordion/anatomy/content.svelte +9 -7
  2. package/dist/components/accordion/anatomy/content.svelte.d.ts +2 -2
  3. package/dist/components/accordion/anatomy/heading.svelte +9 -5
  4. package/dist/components/accordion/anatomy/heading.svelte.d.ts +2 -2
  5. package/dist/components/accordion/anatomy/indicator.svelte +7 -9
  6. package/dist/components/accordion/anatomy/indicator.svelte.d.ts +2 -2
  7. package/dist/components/accordion/anatomy/item.svelte +13 -16
  8. package/dist/components/accordion/anatomy/item.svelte.d.ts +2 -2
  9. package/dist/components/accordion/anatomy/root-context.svelte +6 -4
  10. package/dist/components/accordion/anatomy/root-context.svelte.d.ts +2 -2
  11. package/dist/components/accordion/anatomy/root-provider.svelte +31 -0
  12. package/dist/components/accordion/anatomy/root-provider.svelte.d.ts +9 -0
  13. package/dist/components/accordion/anatomy/root.svelte +17 -19
  14. package/dist/components/accordion/anatomy/root.svelte.d.ts +2 -2
  15. package/dist/components/accordion/anatomy/trigger.svelte +9 -7
  16. package/dist/components/accordion/anatomy/trigger.svelte.d.ts +2 -2
  17. package/dist/components/accordion/index.d.ts +2 -3
  18. package/dist/components/accordion/index.js +1 -0
  19. package/dist/components/accordion/modules/anatomy.d.ts +1 -1
  20. package/dist/components/accordion/modules/anatomy.js +2 -2
  21. package/dist/components/accordion/modules/item-context.d.ts +3 -7
  22. package/dist/components/accordion/modules/use-accordion.svelte.js +7 -0
  23. package/dist/components/avatar/anatomy/fallback.svelte +10 -6
  24. package/dist/components/avatar/anatomy/fallback.svelte.d.ts +2 -2
  25. package/dist/components/avatar/anatomy/image.svelte +10 -6
  26. package/dist/components/avatar/anatomy/image.svelte.d.ts +2 -2
  27. package/dist/components/avatar/anatomy/root-context.svelte +6 -4
  28. package/dist/components/avatar/anatomy/root-context.svelte.d.ts +2 -2
  29. package/dist/components/avatar/anatomy/root-provider.svelte +35 -0
  30. package/dist/components/avatar/anatomy/root-provider.svelte.d.ts +9 -0
  31. package/dist/components/avatar/anatomy/root.svelte +17 -16
  32. package/dist/components/avatar/anatomy/root.svelte.d.ts +2 -2
  33. package/dist/components/avatar/index.d.ts +2 -1
  34. package/dist/components/avatar/index.js +1 -0
  35. package/dist/components/avatar/modules/anatomy.d.ts +1 -0
  36. package/dist/components/avatar/modules/anatomy.js +2 -0
  37. package/dist/components/avatar/modules/use-avatar.svelte.js +7 -0
  38. package/dist/components/progress-linear/anatomy/label.svelte +8 -12
  39. package/dist/components/progress-linear/anatomy/label.svelte.d.ts +2 -2
  40. package/dist/components/progress-linear/anatomy/range.svelte +8 -12
  41. package/dist/components/progress-linear/anatomy/range.svelte.d.ts +2 -2
  42. package/dist/components/progress-linear/anatomy/root-context.svelte +6 -4
  43. package/dist/components/progress-linear/anatomy/root-context.svelte.d.ts +2 -2
  44. package/dist/components/progress-linear/anatomy/root-provider.svelte +35 -0
  45. package/dist/components/progress-linear/anatomy/root-provider.svelte.d.ts +9 -0
  46. package/dist/components/progress-linear/anatomy/root.svelte +14 -25
  47. package/dist/components/progress-linear/anatomy/root.svelte.d.ts +2 -2
  48. package/dist/components/progress-linear/anatomy/track.svelte +10 -6
  49. package/dist/components/progress-linear/anatomy/track.svelte.d.ts +2 -2
  50. package/dist/components/progress-linear/index.d.ts +2 -1
  51. package/dist/components/progress-linear/index.js +1 -0
  52. package/dist/components/progress-linear/modules/use-progress-linear.svelte.js +7 -0
  53. package/dist/components/rating-group/anatomy/control.svelte +13 -7
  54. package/dist/components/rating-group/anatomy/control.svelte.d.ts +2 -2
  55. package/dist/components/rating-group/anatomy/hidden-input.svelte +10 -8
  56. package/dist/components/rating-group/anatomy/hidden-input.svelte.d.ts +2 -2
  57. package/dist/components/rating-group/anatomy/item.svelte +11 -17
  58. package/dist/components/rating-group/anatomy/item.svelte.d.ts +2 -2
  59. package/dist/components/rating-group/anatomy/label.svelte +13 -7
  60. package/dist/components/rating-group/anatomy/label.svelte.d.ts +2 -2
  61. package/dist/components/rating-group/anatomy/root-context.svelte +6 -4
  62. package/dist/components/rating-group/anatomy/root-context.svelte.d.ts +2 -2
  63. package/dist/components/rating-group/anatomy/root-provider.svelte +35 -0
  64. package/dist/components/rating-group/anatomy/root-provider.svelte.d.ts +9 -0
  65. package/dist/components/rating-group/anatomy/root.svelte +18 -23
  66. package/dist/components/rating-group/anatomy/root.svelte.d.ts +3 -3
  67. package/dist/components/rating-group/index.d.ts +2 -3
  68. package/dist/components/rating-group/index.js +1 -0
  69. package/dist/components/rating-group/modules/anatomy.d.ts +1 -1
  70. package/dist/components/rating-group/modules/anatomy.js +2 -2
  71. package/dist/components/rating-group/modules/use-rating-group.svelte.js +7 -0
  72. package/dist/components/switch/anatomy/control.svelte +32 -0
  73. package/dist/components/switch/anatomy/control.svelte.d.ts +7 -0
  74. package/dist/components/switch/anatomy/hidden-input.svelte +30 -0
  75. package/dist/components/switch/anatomy/hidden-input.svelte.d.ts +7 -0
  76. package/dist/components/switch/anatomy/label.svelte +32 -0
  77. package/dist/components/switch/anatomy/label.svelte.d.ts +7 -0
  78. package/dist/components/switch/anatomy/root-context.svelte +20 -0
  79. package/dist/components/switch/anatomy/root-context.svelte.d.ts +8 -0
  80. package/dist/components/switch/anatomy/root-provider.svelte +35 -0
  81. package/dist/components/switch/anatomy/root-provider.svelte.d.ts +9 -0
  82. package/dist/components/switch/anatomy/root.svelte +42 -0
  83. package/dist/components/switch/anatomy/root.svelte.d.ts +8 -0
  84. package/dist/components/switch/anatomy/thumb.svelte +32 -0
  85. package/dist/components/switch/anatomy/thumb.svelte.d.ts +7 -0
  86. package/dist/components/switch/index.d.ts +9 -0
  87. package/dist/components/switch/index.js +2 -0
  88. package/dist/components/switch/modules/anatomy.d.ts +8 -0
  89. package/dist/components/switch/modules/anatomy.js +15 -0
  90. package/dist/components/{rating-group/modules/item-context.js → switch/modules/root-context.js} +1 -1
  91. package/dist/components/switch/modules/use-switch.svelte.js +7 -0
  92. package/dist/components/tabs/anatomy/content.svelte +10 -6
  93. package/dist/components/tabs/anatomy/content.svelte.d.ts +2 -2
  94. package/dist/components/tabs/anatomy/indicator.svelte +10 -6
  95. package/dist/components/tabs/anatomy/indicator.svelte.d.ts +2 -2
  96. package/dist/components/tabs/anatomy/list.svelte +10 -6
  97. package/dist/components/tabs/anatomy/list.svelte.d.ts +2 -2
  98. package/dist/components/tabs/anatomy/root-context.svelte +6 -4
  99. package/dist/components/tabs/anatomy/root-context.svelte.d.ts +2 -2
  100. package/dist/components/tabs/anatomy/root-provider.svelte +34 -0
  101. package/dist/components/tabs/anatomy/root-provider.svelte.d.ts +9 -0
  102. package/dist/components/tabs/anatomy/root.svelte +16 -19
  103. package/dist/components/tabs/anatomy/root.svelte.d.ts +2 -2
  104. package/dist/components/tabs/anatomy/trigger.svelte +10 -6
  105. package/dist/components/tabs/anatomy/trigger.svelte.d.ts +2 -2
  106. package/dist/components/tabs/index.d.ts +9 -1
  107. package/dist/components/tabs/index.js +2 -1
  108. package/dist/components/tabs/modules/anatomy.d.ts +1 -0
  109. package/dist/components/tabs/modules/anatomy.js +2 -0
  110. package/dist/components/tabs/modules/use-tabs.svelte.js +7 -0
  111. package/dist/components/toast/anatomy/action-trigger.svelte +32 -0
  112. package/dist/components/toast/anatomy/action-trigger.svelte.d.ts +7 -0
  113. package/dist/components/toast/anatomy/close-trigger.svelte +37 -0
  114. package/dist/components/toast/anatomy/close-trigger.svelte.d.ts +7 -0
  115. package/dist/components/toast/anatomy/description.svelte +32 -0
  116. package/dist/components/toast/anatomy/description.svelte.d.ts +7 -0
  117. package/dist/components/toast/anatomy/group.svelte +47 -0
  118. package/dist/components/toast/anatomy/group.svelte.d.ts +11 -0
  119. package/dist/components/toast/anatomy/message.svelte +29 -0
  120. package/dist/components/toast/anatomy/message.svelte.d.ts +7 -0
  121. package/dist/components/toast/anatomy/root-context.svelte +20 -0
  122. package/dist/components/toast/anatomy/root-context.svelte.d.ts +8 -0
  123. package/dist/components/toast/anatomy/root.svelte +74 -0
  124. package/dist/components/toast/anatomy/root.svelte.d.ts +9 -0
  125. package/dist/components/toast/anatomy/title.svelte +32 -0
  126. package/dist/components/toast/anatomy/title.svelte.d.ts +7 -0
  127. package/dist/components/toast/index.d.ts +9 -0
  128. package/dist/components/toast/index.js +2 -0
  129. package/dist/components/toast/modules/anatomy.d.ts +9 -0
  130. package/dist/components/toast/modules/anatomy.js +17 -0
  131. package/dist/components/toast/modules/group-context.d.ts +6 -0
  132. package/dist/components/toast/modules/group-context.js +2 -0
  133. package/dist/components/toast/modules/root-context.d.ts +6 -0
  134. package/dist/components/toast/modules/root-context.js +2 -0
  135. package/dist/index.d.ts +2 -0
  136. package/dist/index.js +2 -0
  137. package/dist/internal/components/x.svelte +14 -0
  138. package/dist/internal/components/x.svelte.d.ts +26 -0
  139. package/dist/internal/html-attributes.d.ts +2 -0
  140. package/dist/internal/html-attributes.js +1 -0
  141. package/dist/internal/props-with-element.d.ts +4 -4
  142. package/package.json +19 -19
  143. package/dist/components/accordion/anatomy/item-context.svelte +0 -18
  144. package/dist/components/accordion/anatomy/item-context.svelte.d.ts +0 -8
  145. package/dist/components/accordion/modules/root-context.d.ts +0 -9
  146. package/dist/components/avatar/modules/root-context.d.ts +0 -9
  147. package/dist/components/progress-linear/modules/root-context.d.ts +0 -9
  148. package/dist/components/rating-group/anatomy/item-context.svelte +0 -18
  149. package/dist/components/rating-group/anatomy/item-context.svelte.d.ts +0 -8
  150. package/dist/components/rating-group/modules/item-context.d.ts +0 -9
  151. package/dist/components/rating-group/modules/root-context.d.ts +0 -9
  152. package/dist/components/tabs/modules/root-context.d.ts +0 -9
  153. package/dist/internal/test-utils.d.ts +0 -3
  154. package/dist/internal/test-utils.js +0 -9
@@ -0,0 +1,9 @@
1
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
2
+ import type { PropsWithElement } from '../../../internal/props-with-element';
3
+ import type { useAvatar } from '../modules/use-avatar.svelte';
4
+ export interface AvatarRootProviderProps extends PropsWithElement<'div'>, HTMLAttributes<'div', 'id' | 'dir'> {
5
+ value: ReturnType<typeof useAvatar>;
6
+ }
7
+ declare const RootProvider: import("svelte").Component<AvatarRootProviderProps, {}, "">;
8
+ type RootProvider = ReturnType<typeof RootProvider>;
9
+ export default RootProvider;
@@ -1,39 +1,40 @@
1
1
  <script lang="ts" module>
2
- import type { HTMLAttributes } from 'svelte/elements';
2
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
3
3
  import type { PropsWithElement } from '../../../internal/props-with-element';
4
4
  import type { Props } from '@zag-js/avatar';
5
5
 
6
- export interface AvatarRootProps extends PropsWithElement, Omit<Props, 'id'>, Omit<HTMLAttributes<HTMLDivElement>, 'id' | 'dir'> {}
6
+ export interface AvatarRootProps extends Omit<Props, 'id'>, PropsWithElement<'div'>, HTMLAttributes<'div', 'id' | 'dir'> {}
7
7
  </script>
8
8
 
9
9
  <script lang="ts">
10
- import { useMachine, normalizeProps, mergeProps } from '@zag-js/svelte';
10
+ import { mergeProps } from '@zag-js/svelte';
11
11
  import { classesAvatar } from '@skeletonlabs/skeleton-common';
12
12
  import { AvatarRootContext } from '../modules/root-context';
13
- import { connect, machine, splitProps } from '@zag-js/avatar';
13
+ import { splitProps } from '@zag-js/avatar';
14
+ import { useAvatar } from '../modules/use-avatar.svelte';
14
15
 
15
16
  const props: AvatarRootProps = $props();
16
- const [machineProps, componentProps] = $derived(splitProps(props));
17
- const { element, children, ...restAttributes } = $derived(componentProps);
17
+
18
+ const [avatarProps, componentProps] = $derived(splitProps(props));
19
+ const { element, children, ...rest } = $derived(componentProps);
18
20
 
19
21
  const id = $props.id();
20
- const service = useMachine(machine, () => ({
22
+ const avatar = useAvatar(() => ({
21
23
  id: id,
22
- ...machineProps
24
+ ...avatarProps
23
25
  }));
24
- const api = $derived(connect(service, normalizeProps));
25
26
 
26
- const attributes = $derived(mergeProps(api.getRootProps(), { class: classesAvatar.root }, restAttributes));
27
+ const attributes = $derived(
28
+ mergeProps(avatar().getRootProps(), rest, {
29
+ class: classesAvatar.root
30
+ })
31
+ );
27
32
 
28
- AvatarRootContext.provide({
29
- get api() {
30
- return api;
31
- }
32
- });
33
+ AvatarRootContext.provide(() => avatar());
33
34
  </script>
34
35
 
35
36
  {#if element}
36
- {@render element({ attributes: restAttributes })}
37
+ {@render element(attributes)}
37
38
  {:else}
38
39
  <div {...attributes}>
39
40
  {@render children?.()}
@@ -1,7 +1,7 @@
1
- import type { HTMLAttributes } from 'svelte/elements';
1
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
2
2
  import type { PropsWithElement } from '../../../internal/props-with-element';
3
3
  import type { Props } from '@zag-js/avatar';
4
- export interface AvatarRootProps extends PropsWithElement, Omit<Props, 'id'>, Omit<HTMLAttributes<HTMLDivElement>, 'id' | 'dir'> {
4
+ export interface AvatarRootProps extends Omit<Props, 'id'>, PropsWithElement<'div'>, HTMLAttributes<'div', 'id' | 'dir'> {
5
5
  }
6
6
  declare const Root: import("svelte").Component<AvatarRootProps, {}, "">;
7
7
  type Root = ReturnType<typeof Root>;
@@ -1,6 +1,7 @@
1
1
  export { Avatar } from './modules/anatomy';
2
+ export { useAvatar } from './modules/use-avatar.svelte';
2
3
  export type { AvatarRootProps } from './anatomy/root.svelte';
4
+ export type { AvatarRootProviderProps } from './anatomy/root-provider.svelte';
3
5
  export type { AvatarRootContextProps } from './anatomy/root-context.svelte';
4
6
  export type { AvatarImageProps } from './anatomy/image.svelte';
5
7
  export type { AvatarFallbackProps } from './anatomy/fallback.svelte';
6
- export type { AvatarRootContextType as AvatarRootContext } from './modules/root-context';
@@ -1 +1,2 @@
1
1
  export { Avatar } from './modules/anatomy';
2
+ export { useAvatar } from './modules/use-avatar.svelte';
@@ -1,4 +1,5 @@
1
1
  export declare const Avatar: import("svelte").Component<import("../anatomy/root.svelte").AvatarRootProps, {}, ""> & {
2
+ Provider: import("svelte").Component<import("../anatomy/root-provider.svelte").AvatarRootProviderProps, {}, "">;
2
3
  Context: import("svelte").Component<import("../anatomy/root-context.svelte").AvatarRootContextProps, {}, "">;
3
4
  Image: import("svelte").Component<import("../anatomy/image.svelte").AvatarImageProps, {}, "">;
4
5
  Fallback: import("svelte").Component<import("../anatomy/fallback.svelte").AvatarFallbackProps, {}, "">;
@@ -1,8 +1,10 @@
1
1
  import Root from '../anatomy/root.svelte';
2
+ import RootProvider from '../anatomy/root-provider.svelte';
2
3
  import RootContext from '../anatomy/root-context.svelte';
3
4
  import Image from '../anatomy/image.svelte';
4
5
  import Fallback from '../anatomy/fallback.svelte';
5
6
  export const Avatar = Object.assign(Root, {
7
+ Provider: RootProvider,
6
8
  Context: RootContext,
7
9
  Image: Image,
8
10
  Fallback: Fallback
@@ -0,0 +1,7 @@
1
+ import { connect, machine } from '@zag-js/avatar';
2
+ import { useMachine, normalizeProps } from '@zag-js/svelte';
3
+ export function useAvatar(props) {
4
+ const service = useMachine(machine, props);
5
+ const avatar = $derived(connect(service, normalizeProps));
6
+ return () => avatar;
7
+ }
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" module>
2
2
  import type { PropsWithElement } from '../../../internal/props-with-element';
3
- import type { HTMLAttributes } from 'svelte/elements';
3
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
4
4
 
5
- export interface ProgressLinearLabelProps extends PropsWithElement, HTMLAttributes<HTMLDivElement> {}
5
+ export interface ProgressLinearLabelProps extends PropsWithElement<'div'>, HTMLAttributes<'div'> {}
6
6
  </script>
7
7
 
8
8
  <script lang="ts">
@@ -12,23 +12,19 @@
12
12
 
13
13
  const props: ProgressLinearLabelProps = $props();
14
14
 
15
- const rootContext = ProgressLinearRootContext.consume();
15
+ const progressLinear = ProgressLinearRootContext.consume();
16
16
 
17
- const { element, children, ...restAttributes } = $derived(props);
17
+ const { element, children, ...rest } = $derived(props);
18
18
 
19
19
  const attributes = $derived(
20
- mergeProps(
21
- rootContext.api.getLabelProps(),
22
- {
23
- class: classesProgressLinear.label
24
- },
25
- restAttributes
26
- )
20
+ mergeProps(progressLinear().getLabelProps(), rest, {
21
+ class: classesProgressLinear.label
22
+ })
27
23
  );
28
24
  </script>
29
25
 
30
26
  {#if element}
31
- {@render element({ attributes })}
27
+ {@render element(attributes)}
32
28
  {:else}
33
29
  <div {...attributes}>
34
30
  {@render children?.()}
@@ -1,6 +1,6 @@
1
1
  import type { PropsWithElement } from '../../../internal/props-with-element';
2
- import type { HTMLAttributes } from 'svelte/elements';
3
- export interface ProgressLinearLabelProps extends PropsWithElement, HTMLAttributes<HTMLDivElement> {
2
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
3
+ export interface ProgressLinearLabelProps extends PropsWithElement<'div'>, HTMLAttributes<'div'> {
4
4
  }
5
5
  declare const Label: import("svelte").Component<ProgressLinearLabelProps, {}, "">;
6
6
  type Label = ReturnType<typeof Label>;
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" module>
2
2
  import type { PropsWithElement } from '../../../internal/props-with-element';
3
- import type { HTMLAttributes } from 'svelte/elements';
3
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
4
4
 
5
- export interface ProgressLinearRangeProps extends PropsWithElement, HTMLAttributes<HTMLDivElement> {}
5
+ export interface ProgressLinearRangeProps extends PropsWithElement<'div'>, HTMLAttributes<'div'> {}
6
6
  </script>
7
7
 
8
8
  <script lang="ts">
@@ -12,23 +12,19 @@
12
12
 
13
13
  const props: ProgressLinearRangeProps = $props();
14
14
 
15
- const rootContext = ProgressLinearRootContext.consume();
15
+ const progressLinear = ProgressLinearRootContext.consume();
16
16
 
17
- const { element, children, ...restAttributes } = $derived(props);
17
+ const { element, children, ...rest } = $derived(props);
18
18
 
19
19
  const attributes = $derived(
20
- mergeProps(
21
- rootContext.api.getRangeProps(),
22
- {
23
- class: classesProgressLinear.range
24
- },
25
- restAttributes
26
- )
20
+ mergeProps(progressLinear().getRangeProps(), rest, {
21
+ class: classesProgressLinear.range
22
+ })
27
23
  );
28
24
  </script>
29
25
 
30
26
  {#if element}
31
- {@render element({ attributes })}
27
+ {@render element(attributes)}
32
28
  {:else}
33
29
  <div {...attributes}>
34
30
  {@render children?.()}
@@ -1,6 +1,6 @@
1
1
  import type { PropsWithElement } from '../../../internal/props-with-element';
2
- import type { HTMLAttributes } from 'svelte/elements';
3
- export interface ProgressLinearRangeProps extends PropsWithElement, HTMLAttributes<HTMLDivElement> {
2
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
3
+ export interface ProgressLinearRangeProps extends PropsWithElement<'div'>, HTMLAttributes<'div'> {
4
4
  }
5
5
  declare const Range: import("svelte").Component<ProgressLinearRangeProps, {}, "">;
6
6
  type Range = ReturnType<typeof Range>;
@@ -1,9 +1,9 @@
1
1
  <script lang="ts" module>
2
2
  import type { Snippet } from 'svelte';
3
- import type { ProgressLinearRootContextType } from '../modules/root-context';
3
+ import type { useProgressLinear } from '../modules/use-progress-linear.svelte';
4
4
 
5
5
  export interface ProgressLinearRootContextProps {
6
- children: Snippet<[ProgressLinearRootContextType]>;
6
+ children: Snippet<[ReturnType<typeof useProgressLinear>]>;
7
7
  }
8
8
  </script>
9
9
 
@@ -12,7 +12,9 @@
12
12
 
13
13
  const props: ProgressLinearRootContextProps = $props();
14
14
 
15
- const rootContext = ProgressLinearRootContext.consume();
15
+ const progressLinear = ProgressLinearRootContext.consume();
16
+
17
+ const { children } = $derived(props);
16
18
  </script>
17
19
 
18
- {@render props.children(rootContext)}
20
+ {@render children(progressLinear)}
@@ -1,7 +1,7 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { ProgressLinearRootContextType } from '../modules/root-context';
2
+ import type { useProgressLinear } from '../modules/use-progress-linear.svelte';
3
3
  export interface ProgressLinearRootContextProps {
4
- children: Snippet<[ProgressLinearRootContextType]>;
4
+ children: Snippet<[ReturnType<typeof useProgressLinear>]>;
5
5
  }
6
6
  declare const RootContext: import("svelte").Component<ProgressLinearRootContextProps, {}, "">;
7
7
  type RootContext = ReturnType<typeof RootContext>;
@@ -0,0 +1,35 @@
1
+ <script lang="ts" module>
2
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
3
+ import type { PropsWithElement } from '../../../internal/props-with-element';
4
+ import { useProgressLinear } from '../modules/use-progress-linear.svelte';
5
+
6
+ export interface ProgressLinearRootProviderProps extends PropsWithElement<'div'>, HTMLAttributes<'div', 'id' | 'dir'> {
7
+ value: ReturnType<typeof useProgressLinear>;
8
+ }
9
+ </script>
10
+
11
+ <script lang="ts">
12
+ import { mergeProps } from '@zag-js/svelte';
13
+ import { classesProgressLinear } from '@skeletonlabs/skeleton-common';
14
+ import { ProgressLinearRootContext } from '../modules/root-context';
15
+
16
+ const props: ProgressLinearRootProviderProps = $props();
17
+
18
+ const { element, children, value: avatar, ...rest } = $derived(props);
19
+
20
+ const attributes = $derived(
21
+ mergeProps(avatar().getRootProps(), rest, {
22
+ class: classesProgressLinear.root
23
+ })
24
+ );
25
+
26
+ ProgressLinearRootContext.provide(() => avatar());
27
+ </script>
28
+
29
+ {#if element}
30
+ {@render element(attributes)}
31
+ {:else}
32
+ <div {...attributes}>
33
+ {@render children?.()}
34
+ </div>
35
+ {/if}
@@ -0,0 +1,9 @@
1
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
2
+ import type { PropsWithElement } from '../../../internal/props-with-element';
3
+ import { useProgressLinear } from '../modules/use-progress-linear.svelte';
4
+ export interface ProgressLinearRootProviderProps extends PropsWithElement<'div'>, HTMLAttributes<'div', 'id' | 'dir'> {
5
+ value: ReturnType<typeof useProgressLinear>;
6
+ }
7
+ declare const RootProvider: import("svelte").Component<ProgressLinearRootProviderProps, {}, "">;
8
+ type RootProvider = ReturnType<typeof RootProvider>;
9
+ export default RootProvider;
@@ -1,51 +1,40 @@
1
1
  <script lang="ts" module>
2
- import type { HTMLAttributes } from 'svelte/elements';
2
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
3
3
  import type { PropsWithElement } from '../../../internal/props-with-element';
4
4
  import type { Props } from '@zag-js/progress';
5
5
 
6
- export interface ProgressLinearRootProps
7
- extends PropsWithElement,
8
- Omit<Props, 'id'>,
9
- Omit<HTMLAttributes<HTMLDivElement>, 'id' | 'dir'> {}
6
+ export interface ProgressLinearRootProps extends Omit<Props, 'id'>, PropsWithElement<'div'>, HTMLAttributes<'div', 'id' | 'dir'> {}
10
7
  </script>
11
8
 
12
9
  <script lang="ts">
13
- import { splitProps, machine, connect } from '@zag-js/progress';
14
- import { mergeProps, normalizeProps, useMachine } from '@zag-js/svelte';
10
+ import { splitProps } from '@zag-js/progress';
11
+ import { mergeProps } from '@zag-js/svelte';
15
12
  import { classesProgressLinear } from '@skeletonlabs/skeleton-common';
16
13
  import { ProgressLinearRootContext } from '../modules/root-context';
14
+ import { useProgressLinear } from '../modules/use-progress-linear.svelte';
17
15
 
18
16
  const props: ProgressLinearRootProps = $props();
19
17
 
20
- const [machineProps, componentProps] = $derived(splitProps(props));
21
- const { element, children, ...restAttributes } = $derived(componentProps);
18
+ const [progressLinearProps, componentProps] = $derived(splitProps(props));
19
+ const { element, children, ...rest } = $derived(componentProps);
22
20
 
23
21
  const id = $props.id();
24
- const service = useMachine(machine, () => ({
22
+ const avatar = useProgressLinear(() => ({
25
23
  id,
26
- ...machineProps
24
+ ...progressLinearProps
27
25
  }));
28
- const api = $derived(connect(service, normalizeProps));
29
26
 
30
27
  const attributes = $derived(
31
- mergeProps(
32
- api.getRootProps(),
33
- {
34
- class: classesProgressLinear.root
35
- },
36
- restAttributes
37
- )
28
+ mergeProps(avatar().getRootProps(), rest, {
29
+ class: classesProgressLinear.root
30
+ })
38
31
  );
39
32
 
40
- ProgressLinearRootContext.provide({
41
- get api() {
42
- return api;
43
- }
44
- });
33
+ ProgressLinearRootContext.provide(() => avatar());
45
34
  </script>
46
35
 
47
36
  {#if element}
48
- {@render element({ attributes })}
37
+ {@render element(attributes)}
49
38
  {:else}
50
39
  <div {...attributes}>
51
40
  {@render children?.()}
@@ -1,7 +1,7 @@
1
- import type { HTMLAttributes } from 'svelte/elements';
1
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
2
2
  import type { PropsWithElement } from '../../../internal/props-with-element';
3
3
  import type { Props } from '@zag-js/progress';
4
- export interface ProgressLinearRootProps extends PropsWithElement, Omit<Props, 'id'>, Omit<HTMLAttributes<HTMLDivElement>, 'id' | 'dir'> {
4
+ export interface ProgressLinearRootProps extends Omit<Props, 'id'>, PropsWithElement<'div'>, HTMLAttributes<'div', 'id' | 'dir'> {
5
5
  }
6
6
  declare const Root: import("svelte").Component<ProgressLinearRootProps, {}, "">;
7
7
  type Root = ReturnType<typeof Root>;
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" module>
2
2
  import type { PropsWithElement } from '../../../internal/props-with-element';
3
- import type { HTMLAttributes } from 'svelte/elements';
3
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
4
4
 
5
- export interface ProgressLinearTrackProps extends PropsWithElement, HTMLAttributes<HTMLDivElement> {}
5
+ export interface ProgressLinearTrackProps extends PropsWithElement<'div'>, HTMLAttributes<'div'> {}
6
6
  </script>
7
7
 
8
8
  <script lang="ts">
@@ -12,15 +12,19 @@
12
12
 
13
13
  const props: ProgressLinearTrackProps = $props();
14
14
 
15
- const rootContext = ProgressLinearRootContext.consume();
15
+ const progressLinear = ProgressLinearRootContext.consume();
16
16
 
17
- const { element, children, ...restAttributes } = $derived(props);
17
+ const { element, children, ...rest } = $derived(props);
18
18
 
19
- const attributes = $derived(mergeProps(rootContext.api.getTrackProps(), { class: classesProgressLinear.track }, restAttributes));
19
+ const attributes = $derived(
20
+ mergeProps(progressLinear().getTrackProps(), rest, {
21
+ class: classesProgressLinear.track
22
+ })
23
+ );
20
24
  </script>
21
25
 
22
26
  {#if element}
23
- {@render element({ attributes })}
27
+ {@render element(attributes)}
24
28
  {:else}
25
29
  <div {...attributes}>
26
30
  {@render children?.()}
@@ -1,6 +1,6 @@
1
1
  import type { PropsWithElement } from '../../../internal/props-with-element';
2
- import type { HTMLAttributes } from 'svelte/elements';
3
- export interface ProgressLinearTrackProps extends PropsWithElement, HTMLAttributes<HTMLDivElement> {
2
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
3
+ export interface ProgressLinearTrackProps extends PropsWithElement<'div'>, HTMLAttributes<'div'> {
4
4
  }
5
5
  declare const Track: import("svelte").Component<ProgressLinearTrackProps, {}, "">;
6
6
  type Track = ReturnType<typeof Track>;
@@ -1,7 +1,8 @@
1
1
  export { ProgressLinear } from './modules/anatomy';
2
+ export { useProgressLinear } from './modules/use-progress-linear.svelte';
2
3
  export type { ProgressLinearRootProps } from './anatomy/root.svelte';
4
+ export type { ProgressLinearRootProviderProps } from './anatomy/root-provider.svelte';
3
5
  export type { ProgressLinearRootContextProps } from './anatomy/root-context.svelte';
4
6
  export type { ProgressLinearLabelProps } from './anatomy/label.svelte';
5
7
  export type { ProgressLinearTrackProps } from './anatomy/track.svelte';
6
8
  export type { ProgressLinearRangeProps } from './anatomy/range.svelte';
7
- export type { ProgressLinearRootContextType as ProgressLinearRootContext } from './modules/root-context';
@@ -1 +1,2 @@
1
1
  export { ProgressLinear } from './modules/anatomy';
2
+ export { useProgressLinear } from './modules/use-progress-linear.svelte';
@@ -0,0 +1,7 @@
1
+ import { connect, machine } from '@zag-js/progress';
2
+ import { useMachine, normalizeProps } from '@zag-js/svelte';
3
+ export function useProgressLinear(props) {
4
+ const service = useMachine(machine, props);
5
+ const progressLinear = $derived(connect(service, normalizeProps));
6
+ return () => progressLinear;
7
+ }
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" module>
2
- import type { HTMLAttributes } from 'svelte/elements';
2
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
3
3
  import type { PropsWithElement } from '../../../internal/props-with-element';
4
4
 
5
- export interface RatingGroupControlProps extends PropsWithElement, Omit<HTMLAttributes<HTMLDivElement>, 'id' | 'defaultValue' | 'dir'> {}
5
+ export interface RatingGroupControlProps extends PropsWithElement<'div'>, HTMLAttributes<'div', 'id' | 'dir'> {}
6
6
  </script>
7
7
 
8
8
  <script lang="ts">
@@ -12,15 +12,21 @@
12
12
 
13
13
  const props: RatingGroupControlProps = $props();
14
14
 
15
- const rootContext = RatingGroupRootContext.consume();
15
+ const ratingGroup = RatingGroupRootContext.consume();
16
16
 
17
- const { element, children, ...restAttributes } = $derived(props);
17
+ const { element, children, ...rest } = $derived(props);
18
18
 
19
- const attributes = $derived(mergeProps(rootContext.api.getControlProps(), { class: classesRatingGroup.control }, restAttributes));
19
+ const attributes = $derived(
20
+ mergeProps(ratingGroup().getControlProps(), rest, {
21
+ class: classesRatingGroup.control
22
+ })
23
+ );
20
24
  </script>
21
25
 
22
26
  {#if element}
23
- {@render element({ attributes })}
27
+ {@render element(attributes)}
24
28
  {:else}
25
- <div {...attributes}>{@render children?.()}</div>
29
+ <div {...attributes}>
30
+ {@render children?.()}
31
+ </div>
26
32
  {/if}
@@ -1,6 +1,6 @@
1
- import type { HTMLAttributes } from 'svelte/elements';
1
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
2
2
  import type { PropsWithElement } from '../../../internal/props-with-element';
3
- export interface RatingGroupControlProps extends PropsWithElement, Omit<HTMLAttributes<HTMLDivElement>, 'id' | 'defaultValue' | 'dir'> {
3
+ export interface RatingGroupControlProps extends PropsWithElement<'div'>, HTMLAttributes<'div', 'id' | 'dir'> {
4
4
  }
5
5
  declare const Control: import("svelte").Component<RatingGroupControlProps, {}, "">;
6
6
  type Control = ReturnType<typeof Control>;
@@ -1,10 +1,8 @@
1
1
  <script lang="ts" module>
2
- import type { HTMLInputAttributes } from 'svelte/elements';
3
2
  import type { PropsWithElement } from '../../../internal/props-with-element';
3
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
4
4
 
5
- export interface RatingGroupHiddenInputProps
6
- extends PropsWithElement,
7
- Omit<HTMLInputAttributes, 'id' | 'defaultValue' | 'dir' | 'children'> {}
5
+ export interface RatingGroupHiddenInputProps extends PropsWithElement<'input'>, HTMLAttributes<'input'> {}
8
6
  </script>
9
7
 
10
8
  <script lang="ts">
@@ -14,15 +12,19 @@
14
12
 
15
13
  const props: RatingGroupHiddenInputProps = $props();
16
14
 
17
- const rootContext = RatingGroupRootContext.consume();
15
+ const ratingGroup = RatingGroupRootContext.consume();
18
16
 
19
- const { element, ...restAttributes } = $derived(props);
17
+ const { element, ...rest } = $derived(props);
20
18
 
21
- const attributes = $derived(mergeProps(rootContext.api.getHiddenInputProps(), { class: classesRatingGroup.hiddenInput }, restAttributes));
19
+ const attributes = $derived(
20
+ mergeProps(ratingGroup().getHiddenInputProps(), rest, {
21
+ class: classesRatingGroup.hiddenInput
22
+ })
23
+ );
22
24
  </script>
23
25
 
24
26
  {#if element}
25
- {@render element({ attributes })}
27
+ {@render element(attributes)}
26
28
  {:else}
27
29
  <input {...attributes} />
28
30
  {/if}
@@ -1,6 +1,6 @@
1
- import type { HTMLInputAttributes } from 'svelte/elements';
2
1
  import type { PropsWithElement } from '../../../internal/props-with-element';
3
- export interface RatingGroupHiddenInputProps extends PropsWithElement, Omit<HTMLInputAttributes, 'id' | 'defaultValue' | 'dir' | 'children'> {
2
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
3
+ export interface RatingGroupHiddenInputProps extends PropsWithElement<'input'>, HTMLAttributes<'input'> {
4
4
  }
5
5
  declare const HiddenInput: import("svelte").Component<RatingGroupHiddenInputProps, {}, "">;
6
6
  type HiddenInput = ReturnType<typeof HiddenInput>;
@@ -1,12 +1,9 @@
1
1
  <script lang="ts" module>
2
- import type { HTMLAttributes } from 'svelte/elements';
2
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
3
3
  import type { PropsWithElement } from '../../../internal/props-with-element';
4
4
  import type { ItemProps } from '@zag-js/rating-group';
5
5
 
6
- export interface RatingGroupItemProps
7
- extends PropsWithElement,
8
- ItemProps,
9
- Omit<HTMLAttributes<HTMLSpanElement>, 'id' | 'defaultValue' | 'dir'> {
6
+ export interface RatingGroupItemProps extends ItemProps, PropsWithElement<'span'>, HTMLAttributes<'span', 'id' | 'dir'> {
10
7
  /**
11
8
  * The content to render when the item is in the empty state.
12
9
  *
@@ -33,7 +30,6 @@
33
30
  import { classesRatingGroup } from '@skeletonlabs/skeleton-common';
34
31
  import { splitItemProps } from '@zag-js/rating-group';
35
32
  import { RatingGroupRootContext } from '../modules/root-context';
36
- import { RatingGroupItemContext } from '../modules/item-context';
37
33
  import StarFull from '../../../internal/components/star-full.svelte';
38
34
  import StarEmpty from '../../../internal/components/star-empty.svelte';
39
35
  import StarHalf from '../../../internal/components/star-half.svelte';
@@ -41,20 +37,18 @@
41
37
 
42
38
  const props: RatingGroupItemProps = $props();
43
39
 
44
- const rootContext = RatingGroupRootContext.consume();
40
+ const ratingGroup = RatingGroupRootContext.consume();
45
41
 
46
42
  const [itemProps, componentProps] = $derived(splitItemProps(props));
47
- const { element, children, empty = starEmpty, half = starHalf, full = starFull, ...restAttributes } = $derived(componentProps);
43
+ const { element, children, empty = starEmpty, half = starHalf, full = starFull, ...rest } = $derived(componentProps);
48
44
 
49
- const itemState = $derived(rootContext.api.getItemState(itemProps));
45
+ const itemState = $derived(ratingGroup().getItemState(itemProps));
50
46
 
51
- const attributes = $derived(mergeProps(rootContext.api.getItemProps(itemProps), { class: classesRatingGroup.item }, restAttributes));
52
-
53
- RatingGroupItemContext.provide({
54
- get itemState() {
55
- return itemState;
56
- }
57
- });
47
+ const attributes = $derived(
48
+ mergeProps(ratingGroup().getItemProps(itemProps), rest, {
49
+ class: classesRatingGroup.item
50
+ })
51
+ );
58
52
  </script>
59
53
 
60
54
  {#snippet starEmpty()}
@@ -70,7 +64,7 @@
70
64
  {/snippet}
71
65
 
72
66
  {#if element}
73
- {@render element({ attributes })}
67
+ {@render element(attributes)}
74
68
  {:else}
75
69
  <div {...attributes}>
76
70
  {#if children}
@@ -1,7 +1,7 @@
1
- import type { HTMLAttributes } from 'svelte/elements';
1
+ import type { HTMLAttributes } from '../../../internal/html-attributes';
2
2
  import type { PropsWithElement } from '../../../internal/props-with-element';
3
3
  import type { ItemProps } from '@zag-js/rating-group';
4
- export interface RatingGroupItemProps extends PropsWithElement, ItemProps, Omit<HTMLAttributes<HTMLSpanElement>, 'id' | 'defaultValue' | 'dir'> {
4
+ export interface RatingGroupItemProps extends ItemProps, PropsWithElement<'span'>, HTMLAttributes<'span', 'id' | 'dir'> {
5
5
  /**
6
6
  * The content to render when the item is in the empty state.
7
7
  *