ui-ingredients 0.0.42 → 0.0.44

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. package/README.md +3 -0
  2. package/dist/file-upload/create-file-upload.svelte.js +1 -0
  3. package/dist/file-upload/root.svelte +1 -0
  4. package/dist/floating-panel/body.svelte +24 -0
  5. package/dist/floating-panel/body.svelte.d.ts +18 -0
  6. package/dist/floating-panel/close-trigger.svelte +27 -0
  7. package/dist/floating-panel/close-trigger.svelte.d.ts +18 -0
  8. package/dist/floating-panel/content.svelte +36 -0
  9. package/dist/floating-panel/content.svelte.d.ts +18 -0
  10. package/dist/floating-panel/context.svelte.d.ts +2 -0
  11. package/dist/floating-panel/context.svelte.js +2 -0
  12. package/dist/floating-panel/create-floating-panel.svelte.d.ts +7 -0
  13. package/dist/floating-panel/create-floating-panel.svelte.js +19 -0
  14. package/dist/floating-panel/drag-trigger.svelte +27 -0
  15. package/dist/floating-panel/drag-trigger.svelte.d.ts +18 -0
  16. package/dist/floating-panel/floating-panel.d.ts +13 -0
  17. package/dist/floating-panel/floating-panel.js +13 -0
  18. package/dist/floating-panel/header.svelte +25 -0
  19. package/dist/floating-panel/header.svelte.d.ts +18 -0
  20. package/dist/floating-panel/index.d.ts +16 -0
  21. package/dist/floating-panel/index.js +3 -0
  22. package/dist/floating-panel/maximize-trigger.svelte +28 -0
  23. package/dist/floating-panel/maximize-trigger.svelte.d.ts +18 -0
  24. package/dist/floating-panel/minimize-trigger.svelte +28 -0
  25. package/dist/floating-panel/minimize-trigger.svelte.d.ts +18 -0
  26. package/dist/floating-panel/positioner.svelte +35 -0
  27. package/dist/floating-panel/positioner.svelte.d.ts +18 -0
  28. package/dist/floating-panel/resize-trigger.svelte +36 -0
  29. package/dist/floating-panel/resize-trigger.svelte.d.ts +18 -0
  30. package/dist/floating-panel/restore-trigger.svelte +28 -0
  31. package/dist/floating-panel/restore-trigger.svelte.d.ts +18 -0
  32. package/dist/floating-panel/root.svelte +50 -0
  33. package/dist/floating-panel/root.svelte.d.ts +18 -0
  34. package/dist/floating-panel/title.svelte +25 -0
  35. package/dist/floating-panel/title.svelte.d.ts +18 -0
  36. package/dist/floating-panel/trigger.svelte +27 -0
  37. package/dist/floating-panel/trigger.svelte.d.ts +18 -0
  38. package/dist/index.d.ts +2 -0
  39. package/dist/index.js +2 -0
  40. package/dist/is-object.d.ts +2 -0
  41. package/dist/is-object.js +4 -0
  42. package/dist/merge-props.js +1 -4
  43. package/dist/portal/root.svelte +32 -32
  44. package/dist/presence/root.svelte +5 -1
  45. package/dist/switch/control.svelte +24 -24
  46. package/dist/switch/hidden-input.svelte +23 -23
  47. package/dist/switch/label.svelte +24 -24
  48. package/dist/switch/root.svelte +54 -54
  49. package/dist/switch/thumb.svelte +24 -24
  50. package/dist/toast/actor.svelte +19 -19
  51. package/dist/toast/toaster.svelte +39 -39
  52. package/dist/tour/arrow-tip.svelte +24 -0
  53. package/dist/tour/arrow-tip.svelte.d.ts +18 -0
  54. package/dist/tour/arrow.svelte +24 -0
  55. package/dist/tour/arrow.svelte.d.ts +18 -0
  56. package/dist/tour/close-trigger.svelte +25 -0
  57. package/dist/tour/close-trigger.svelte.d.ts +18 -0
  58. package/dist/tour/content.svelte +30 -0
  59. package/dist/tour/content.svelte.d.ts +18 -0
  60. package/dist/tour/context.svelte.d.ts +2 -0
  61. package/dist/tour/context.svelte.js +3 -0
  62. package/dist/tour/create-tour.svelte.d.ts +7 -0
  63. package/dist/tour/create-tour.svelte.js +19 -0
  64. package/dist/tour/description.svelte +24 -0
  65. package/dist/tour/description.svelte.d.ts +18 -0
  66. package/dist/tour/index.d.ts +17 -0
  67. package/dist/tour/index.js +3 -0
  68. package/dist/tour/next-trigger.svelte +24 -0
  69. package/dist/tour/next-trigger.svelte.d.ts +18 -0
  70. package/dist/tour/overlay.svelte +43 -0
  71. package/dist/tour/overlay.svelte.d.ts +18 -0
  72. package/dist/tour/positioner.svelte +30 -0
  73. package/dist/tour/positioner.svelte.d.ts +18 -0
  74. package/dist/tour/prev-trigger.svelte +24 -0
  75. package/dist/tour/prev-trigger.svelte.d.ts +18 -0
  76. package/dist/tour/progress-text.svelte +28 -0
  77. package/dist/tour/progress-text.svelte.d.ts +18 -0
  78. package/dist/tour/root.svelte +52 -0
  79. package/dist/tour/root.svelte.d.ts +18 -0
  80. package/dist/tour/skip-trigger.svelte +24 -0
  81. package/dist/tour/skip-trigger.svelte.d.ts +18 -0
  82. package/dist/tour/spotlight.svelte +24 -0
  83. package/dist/tour/spotlight.svelte.d.ts +18 -0
  84. package/dist/tour/title.svelte +24 -0
  85. package/dist/tour/title.svelte.d.ts +18 -0
  86. package/dist/tour/tour.d.ts +14 -0
  87. package/dist/tour/tour.js +14 -0
  88. package/dist/types.d.ts +10 -16
  89. package/package.json +46 -46
  90. package/dist/floating-panel/.gitkeep +0 -0
  91. package/dist/tour/.gitkeep +0 -0
@@ -0,0 +1,50 @@
1
+ <script lang="ts" module>
2
+ import type {PresenceStrategyProps} from '../presence/create-presence.svelte.js';
3
+ import type {Snippet} from 'svelte';
4
+ import type {
5
+ CreateFloatingPanelProps,
6
+ CreateFloatingPanelReturn,
7
+ } from './create-floating-panel.svelte.js';
8
+
9
+ export interface FloatingPanelProps
10
+ extends CreateFloatingPanelProps,
11
+ PresenceStrategyProps {
12
+ children?: Snippet<[CreateFloatingPanelReturn]>;
13
+ }
14
+ </script>
15
+
16
+ <script lang="ts">
17
+ import {setPresenceContext} from '../presence/context.svelte.js';
18
+ import {createPresence} from '../presence/create-presence.svelte.js';
19
+ import {reflect} from '@zag-js/svelte';
20
+ import {createSplitProps} from '@zag-js/utils';
21
+ import {setFloatingPanelContext} from './context.svelte.js';
22
+ import {createFloatingPanel} from './create-floating-panel.svelte.js';
23
+
24
+ let {children, ...props}: FloatingPanelProps = $props();
25
+
26
+ let [presenceStrategyProps, floatingPanelProps] = $derived(
27
+ createSplitProps<PresenceStrategyProps>(['lazyMount', 'keepMounted'])(
28
+ props,
29
+ ),
30
+ );
31
+
32
+ let floatingPanel = createFloatingPanel(reflect(() => floatingPanelProps));
33
+
34
+ let presence = createPresence({
35
+ get present() {
36
+ return floatingPanel.open;
37
+ },
38
+ get lazyMount() {
39
+ return presenceStrategyProps.lazyMount;
40
+ },
41
+ get keepMounted() {
42
+ return presenceStrategyProps.keepMounted;
43
+ },
44
+ });
45
+
46
+ setFloatingPanelContext(floatingPanel);
47
+ setPresenceContext(presence);
48
+ </script>
49
+
50
+ {@render children?.(floatingPanel)}
@@ -0,0 +1,18 @@
1
+ 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> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: Props & {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const Root: $$__sveltets_2_IsomorphicComponent<FloatingPanelProps, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, "">;
17
+ type Root = InstanceType<typeof Root>;
18
+ export default Root;
@@ -0,0 +1,25 @@
1
+ <script lang="ts" module>
2
+ import type {HtmlIngredientProps} from '../types.js';
3
+
4
+ export interface FloatingPanelTitleProps
5
+ extends HtmlIngredientProps<'span'> {}
6
+ </script>
7
+
8
+ <script lang="ts">
9
+ import {mergeProps} from '../merge-props.js';
10
+ import {getFloatingPanelContext} from './context.svelte.js';
11
+
12
+ let {asChild, children, ...props}: FloatingPanelTitleProps = $props();
13
+
14
+ let floatingPanel = getFloatingPanelContext();
15
+
16
+ let mergedProps = $derived(mergeProps(props, floatingPanel.getTitleProps()));
17
+ </script>
18
+
19
+ {#if asChild}
20
+ {@render asChild(mergedProps)}
21
+ {:else}
22
+ <span {...mergedProps}>
23
+ {@render children?.()}
24
+ </span>
25
+ {/if}
@@ -0,0 +1,18 @@
1
+ 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> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: Props & {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const Title: $$__sveltets_2_IsomorphicComponent<FloatingPanelTitleProps, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, "">;
17
+ type Title = InstanceType<typeof Title>;
18
+ export default Title;
@@ -0,0 +1,27 @@
1
+ <script lang="ts" module>
2
+ import type {HtmlIngredientProps} from '../types.js';
3
+
4
+ export interface FloatingPanelTriggerProps
5
+ extends HtmlIngredientProps<'button'> {}
6
+ </script>
7
+
8
+ <script lang="ts">
9
+ import {mergeProps} from '../merge-props.js';
10
+ import {getFloatingPanelContext} from './context.svelte.js';
11
+
12
+ let {asChild, children, ...props}: FloatingPanelTriggerProps = $props();
13
+
14
+ let floatingPanel = getFloatingPanelContext();
15
+
16
+ let mergedProps = $derived(
17
+ mergeProps(props, floatingPanel.getTriggerProps()),
18
+ );
19
+ </script>
20
+
21
+ {#if asChild}
22
+ {@render asChild(mergedProps)}
23
+ {:else}
24
+ <button type="button" {...mergedProps}>
25
+ {@render children?.()}
26
+ </button>
27
+ {/if}
@@ -0,0 +1,18 @@
1
+ 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> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: Props & {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const Trigger: $$__sveltets_2_IsomorphicComponent<FloatingPanelTriggerProps, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, "">;
17
+ type Trigger = InstanceType<typeof Trigger>;
18
+ export default Trigger;
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export * from './editable/index.js';
12
12
  export * from './environment-provider/index.js';
13
13
  export * from './field/index.js';
14
14
  export * from './file-upload/index.js';
15
+ export * from './floating-panel/index.js';
15
16
  export * from './hover-card/index.js';
16
17
  export * from './locale-provider/index.js';
17
18
  export * from './menu/index.js';
@@ -39,4 +40,5 @@ export * from './timer/index.js';
39
40
  export * from './toast/index.js';
40
41
  export * from './toggle-group/index.js';
41
42
  export * from './tooltip/index.js';
43
+ export * from './tour/index.js';
42
44
  export * from './tree-view/index.js';
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ export * from './editable/index.js';
12
12
  export * from './environment-provider/index.js';
13
13
  export * from './field/index.js';
14
14
  export * from './file-upload/index.js';
15
+ export * from './floating-panel/index.js';
15
16
  export * from './hover-card/index.js';
16
17
  export * from './locale-provider/index.js';
17
18
  export * from './menu/index.js';
@@ -39,4 +40,5 @@ export * from './timer/index.js';
39
40
  export * from './toast/index.js';
40
41
  export * from './toggle-group/index.js';
41
42
  export * from './tooltip/index.js';
43
+ export * from './tour/index.js';
42
44
  export * from './tree-view/index.js';
@@ -0,0 +1,2 @@
1
+ import type { GenericObject } from './types.js';
2
+ export declare function isObject<T extends GenericObject>(value: unknown): value is T;
@@ -0,0 +1,4 @@
1
+ export function isObject(value) {
2
+ return (Object.prototype.toString.call(value) === '[object Object]' &&
3
+ value === Object(value));
4
+ }
@@ -1,8 +1,5 @@
1
1
  import { mergeProps as fn } from '@zag-js/svelte';
2
- function isObject(value) {
3
- return (Object.prototype.toString.call(value) === '[object Object]' &&
4
- value === Object(value));
5
- }
2
+ import { isObject } from './is-object.js';
6
3
  export function mergeProps(...args) {
7
4
  const r = fn(...args);
8
5
  const i = 'style';
@@ -1,32 +1,32 @@
1
- <script module lang="ts">
2
- import {type Snippet} from 'svelte';
3
-
4
- export interface PortalProps {
5
- container?: HTMLElement;
6
- disabled?: boolean;
7
- children: Snippet;
8
- [x: `data-${string}`]: string | number | boolean | null | undefined;
9
- }
10
- </script>
11
-
12
- <script lang="ts">
13
- import {getEnvironmentContext} from '../environment-provider/index.js';
14
- import {portal} from '@zag-js/svelte';
15
-
16
- let {container, disabled, children, ...props}: PortalProps = $props();
17
-
18
- let environment = getEnvironmentContext();
19
- </script>
20
-
21
- <div
22
- use:portal={{
23
- disabled,
24
- container,
25
- getRootNode: environment?.getRootNode,
26
- }}
27
- data-scope="portal"
28
- data-part="root"
29
- {...props}
30
- >
31
- {@render children?.()}
32
- </div>
1
+ <script module lang="ts">
2
+ import {type Snippet} from 'svelte';
3
+
4
+ export interface PortalProps {
5
+ container?: HTMLElement;
6
+ disabled?: boolean;
7
+ children: Snippet;
8
+ [x: `data-${string}`]: string | number | boolean | null | undefined;
9
+ }
10
+ </script>
11
+
12
+ <script lang="ts">
13
+ import {getEnvironmentContext} from '../environment-provider/index.js';
14
+ import {portal} from '@zag-js/svelte';
15
+
16
+ let {container, disabled, children, ...props}: PortalProps = $props();
17
+
18
+ let environment = getEnvironmentContext();
19
+ </script>
20
+
21
+ <div
22
+ use:portal={{
23
+ disabled,
24
+ container,
25
+ getRootNode: environment?.getRootNode,
26
+ }}
27
+ data-scope="portal"
28
+ data-part="root"
29
+ {...props}
30
+ >
31
+ {@render children?.()}
32
+ </div>
@@ -19,7 +19,11 @@
19
19
  let {asChild, children, ...props}: PresenceProps = $props();
20
20
 
21
21
  let [presenceProps, otherProps] = $derived(
22
- createSplitProps<CreatePresenceProps>(['present'])(props),
22
+ createSplitProps<CreatePresenceProps>([
23
+ 'present',
24
+ 'lazyMount',
25
+ 'keepMounted',
26
+ ])(props),
23
27
  );
24
28
 
25
29
  let presence = createPresence(reflect(() => presenceProps));
@@ -1,24 +1,24 @@
1
- <script lang="ts" module>
2
- import type {HtmlIngredientProps} from '../types.js';
3
-
4
- export interface SwitchControlProps extends HtmlIngredientProps<'div'> {}
5
- </script>
6
-
7
- <script lang="ts">
8
- import {mergeProps} from '../merge-props.js';
9
- import {getSwitchContext} from './context.svelte.js';
10
-
11
- let {asChild, children, ...props}: SwitchControlProps = $props();
12
-
13
- let switch$ = getSwitchContext();
14
-
15
- let mergedProps = $derived(mergeProps(props, switch$.getControlProps()));
16
- </script>
17
-
18
- {#if asChild}
19
- {@render asChild(mergedProps)}
20
- {:else}
21
- <div {...mergedProps}>
22
- {@render children?.()}
23
- </div>
24
- {/if}
1
+ <script lang="ts" module>
2
+ import type {HtmlIngredientProps} from '../types.js';
3
+
4
+ export interface SwitchControlProps extends HtmlIngredientProps<'div'> {}
5
+ </script>
6
+
7
+ <script lang="ts">
8
+ import {mergeProps} from '../merge-props.js';
9
+ import {getSwitchContext} from './context.svelte.js';
10
+
11
+ let {asChild, children, ...props}: SwitchControlProps = $props();
12
+
13
+ let switch$ = getSwitchContext();
14
+
15
+ let mergedProps = $derived(mergeProps(props, switch$.getControlProps()));
16
+ </script>
17
+
18
+ {#if asChild}
19
+ {@render asChild(mergedProps)}
20
+ {:else}
21
+ <div {...mergedProps}>
22
+ {@render children?.()}
23
+ </div>
24
+ {/if}
@@ -1,23 +1,23 @@
1
- <script lang="ts" module>
2
- import type {HtmlIngredientProps} from '../types.js';
3
-
4
- export interface SwitchHiddenInputProps
5
- extends HtmlIngredientProps<'input'> {}
6
- </script>
7
-
8
- <script lang="ts">
9
- import {mergeProps} from '../merge-props.js';
10
- import {getSwitchContext} from './context.svelte.js';
11
-
12
- let {asChild, ...props}: SwitchHiddenInputProps = $props();
13
-
14
- let switch$ = getSwitchContext();
15
-
16
- let mergedProps = $derived(mergeProps(props, switch$.getHiddenInputProps()));
17
- </script>
18
-
19
- {#if asChild}
20
- {@render asChild(mergedProps)}
21
- {:else}
22
- <input {...mergedProps} />
23
- {/if}
1
+ <script lang="ts" module>
2
+ import type {HtmlIngredientProps} from '../types.js';
3
+
4
+ export interface SwitchHiddenInputProps
5
+ extends HtmlIngredientProps<'input'> {}
6
+ </script>
7
+
8
+ <script lang="ts">
9
+ import {mergeProps} from '../merge-props.js';
10
+ import {getSwitchContext} from './context.svelte.js';
11
+
12
+ let {asChild, ...props}: SwitchHiddenInputProps = $props();
13
+
14
+ let switch$ = getSwitchContext();
15
+
16
+ let mergedProps = $derived(mergeProps(props, switch$.getHiddenInputProps()));
17
+ </script>
18
+
19
+ {#if asChild}
20
+ {@render asChild(mergedProps)}
21
+ {:else}
22
+ <input {...mergedProps} />
23
+ {/if}
@@ -1,24 +1,24 @@
1
- <script lang="ts" module>
2
- import type {HtmlIngredientProps} from '../types.js';
3
-
4
- export interface SwitchLabelProps extends HtmlIngredientProps<'span'> {}
5
- </script>
6
-
7
- <script lang="ts">
8
- import {mergeProps} from '../merge-props.js';
9
- import {getSwitchContext} from './context.svelte.js';
10
-
11
- let {asChild, children, ...props}: SwitchLabelProps = $props();
12
-
13
- let switch$ = getSwitchContext();
14
-
15
- let mergedProps = $derived(mergeProps(props, switch$.getLabelProps()));
16
- </script>
17
-
18
- {#if asChild}
19
- {@render asChild(mergedProps)}
20
- {:else}
21
- <span {...mergedProps}>
22
- {@render children?.()}
23
- </span>
24
- {/if}
1
+ <script lang="ts" module>
2
+ import type {HtmlIngredientProps} from '../types.js';
3
+
4
+ export interface SwitchLabelProps extends HtmlIngredientProps<'span'> {}
5
+ </script>
6
+
7
+ <script lang="ts">
8
+ import {mergeProps} from '../merge-props.js';
9
+ import {getSwitchContext} from './context.svelte.js';
10
+
11
+ let {asChild, children, ...props}: SwitchLabelProps = $props();
12
+
13
+ let switch$ = getSwitchContext();
14
+
15
+ let mergedProps = $derived(mergeProps(props, switch$.getLabelProps()));
16
+ </script>
17
+
18
+ {#if asChild}
19
+ {@render asChild(mergedProps)}
20
+ {:else}
21
+ <span {...mergedProps}>
22
+ {@render children?.()}
23
+ </span>
24
+ {/if}
@@ -1,54 +1,54 @@
1
- <script lang="ts" module>
2
- import type {Assign, HtmlIngredientProps} from '../types.js';
3
- import type {
4
- CreateSwitchProps,
5
- CreateSwitchReturn,
6
- } from './create-switch.svelte.js';
7
-
8
- export interface SwitchProps
9
- extends Assign<
10
- HtmlIngredientProps<'label', CreateSwitchReturn>,
11
- CreateSwitchProps
12
- > {}
13
- </script>
14
-
15
- <script lang="ts">
16
- import {mergeProps} from '../merge-props.js';
17
- import {reflect} from '@zag-js/svelte';
18
- import {createSplitProps} from '@zag-js/utils';
19
- import {setSwitchContext} from './context.svelte.js';
20
- import {createSwitch} from './create-switch.svelte.js';
21
-
22
- let {asChild, children, ...props}: SwitchProps = $props();
23
-
24
- let [switchProps, otherProps] = $derived(
25
- createSplitProps<CreateSwitchProps>([
26
- 'id',
27
- 'ids',
28
- 'form',
29
- 'name',
30
- 'label',
31
- 'value',
32
- 'checked',
33
- 'invalid',
34
- 'disabled',
35
- 'readOnly',
36
- 'required',
37
- 'onCheckedChange',
38
- ])(props),
39
- );
40
-
41
- let switch$ = createSwitch(reflect(() => switchProps));
42
-
43
- let mergedProps = $derived(mergeProps(otherProps, switch$.getRootProps()));
44
-
45
- setSwitchContext(switch$);
46
- </script>
47
-
48
- {#if asChild}
49
- {@render asChild(mergedProps, switch$)}
50
- {:else}
51
- <label {...mergedProps}>
52
- {@render children?.(switch$)}
53
- </label>
54
- {/if}
1
+ <script lang="ts" module>
2
+ import type {Assign, HtmlIngredientProps} from '../types.js';
3
+ import type {
4
+ CreateSwitchProps,
5
+ CreateSwitchReturn,
6
+ } from './create-switch.svelte.js';
7
+
8
+ export interface SwitchProps
9
+ extends Assign<
10
+ HtmlIngredientProps<'label', CreateSwitchReturn>,
11
+ CreateSwitchProps
12
+ > {}
13
+ </script>
14
+
15
+ <script lang="ts">
16
+ import {mergeProps} from '../merge-props.js';
17
+ import {reflect} from '@zag-js/svelte';
18
+ import {createSplitProps} from '@zag-js/utils';
19
+ import {setSwitchContext} from './context.svelte.js';
20
+ import {createSwitch} from './create-switch.svelte.js';
21
+
22
+ let {asChild, children, ...props}: SwitchProps = $props();
23
+
24
+ let [switchProps, otherProps] = $derived(
25
+ createSplitProps<CreateSwitchProps>([
26
+ 'id',
27
+ 'ids',
28
+ 'form',
29
+ 'name',
30
+ 'label',
31
+ 'value',
32
+ 'checked',
33
+ 'invalid',
34
+ 'disabled',
35
+ 'readOnly',
36
+ 'required',
37
+ 'onCheckedChange',
38
+ ])(props),
39
+ );
40
+
41
+ let switch$ = createSwitch(reflect(() => switchProps));
42
+
43
+ let mergedProps = $derived(mergeProps(otherProps, switch$.getRootProps()));
44
+
45
+ setSwitchContext(switch$);
46
+ </script>
47
+
48
+ {#if asChild}
49
+ {@render asChild(mergedProps, switch$)}
50
+ {:else}
51
+ <label {...mergedProps}>
52
+ {@render children?.(switch$)}
53
+ </label>
54
+ {/if}
@@ -1,24 +1,24 @@
1
- <script lang="ts" module>
2
- import type {HtmlIngredientProps} from '../types.js';
3
-
4
- export interface SwitchThumbProps extends HtmlIngredientProps<'div'> {}
5
- </script>
6
-
7
- <script lang="ts">
8
- import {mergeProps} from '../merge-props.js';
9
- import {getSwitchContext} from './context.svelte.js';
10
-
11
- let {asChild, children, ...props}: SwitchThumbProps = $props();
12
-
13
- let switch$ = getSwitchContext();
14
-
15
- let mergedProps = $derived(mergeProps(props, switch$.getThumbProps()));
16
- </script>
17
-
18
- {#if asChild}
19
- {@render asChild(mergedProps)}
20
- {:else}
21
- <div {...mergedProps}>
22
- {@render children?.()}
23
- </div>
24
- {/if}
1
+ <script lang="ts" module>
2
+ import type {HtmlIngredientProps} from '../types.js';
3
+
4
+ export interface SwitchThumbProps extends HtmlIngredientProps<'div'> {}
5
+ </script>
6
+
7
+ <script lang="ts">
8
+ import {mergeProps} from '../merge-props.js';
9
+ import {getSwitchContext} from './context.svelte.js';
10
+
11
+ let {asChild, children, ...props}: SwitchThumbProps = $props();
12
+
13
+ let switch$ = getSwitchContext();
14
+
15
+ let mergedProps = $derived(mergeProps(props, switch$.getThumbProps()));
16
+ </script>
17
+
18
+ {#if asChild}
19
+ {@render asChild(mergedProps)}
20
+ {:else}
21
+ <div {...mergedProps}>
22
+ {@render children?.()}
23
+ </div>
24
+ {/if}
@@ -1,19 +1,19 @@
1
- <script lang="ts">
2
- import * as toast$ from '@zag-js/toast';
3
- import type {Snippet} from 'svelte';
4
- import {setToastContext} from './context.svelte.js';
5
- import {createToast, type CreateToastReturn} from './create-toast.svelte.js';
6
-
7
- interface Props {
8
- actor: toast$.Service;
9
- children$: Snippet<[toast: CreateToastReturn]>;
10
- }
11
-
12
- let {actor, children$}: Props = $props();
13
-
14
- let toast = createToast(actor);
15
-
16
- setToastContext(toast);
17
- </script>
18
-
19
- {@render children$(toast)}
1
+ <script lang="ts">
2
+ import * as toast$ from '@zag-js/toast';
3
+ import type {Snippet} from 'svelte';
4
+ import {setToastContext} from './context.svelte.js';
5
+ import {createToast, type CreateToastReturn} from './create-toast.svelte.js';
6
+
7
+ interface Props {
8
+ actor: toast$.Service;
9
+ children$: Snippet<[toast: CreateToastReturn]>;
10
+ }
11
+
12
+ let {actor, children$}: Props = $props();
13
+
14
+ let toast = createToast(actor);
15
+
16
+ setToastContext(toast);
17
+ </script>
18
+
19
+ {@render children$(toast)}