ui-ingredients 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ import * as segmentGroup from '@zag-js/radio-group';
2
+ export interface CreateSegmentGroupContextProps extends segmentGroup.Context {
3
+ }
4
+ export interface CreateSegmentGroupContextReturn extends ReturnType<typeof createSegmentGroupContext> {
5
+ }
6
+ export declare function createSegmentGroupContext(props: CreateSegmentGroupContextProps): any;
7
+ export declare function setSegmentGroupContext(value: CreateSegmentGroupContextReturn): void;
8
+ export declare function useSegmentGroupContext(): CreateSegmentGroupContextReturn;
9
+ export declare function setSegmentGroupItemPropsContext(value: segmentGroup.ItemProps): void;
10
+ export declare function useSegmentGroupItemPropsContext(): segmentGroup.ItemProps;
@@ -1,10 +1,50 @@
1
1
  import * as segmentGroup from '@zag-js/radio-group';
2
- import { normalizeProps, useMachine } from '@zag-js/svelte';
2
+ import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
3
3
  import { getContext, setContext } from 'svelte';
4
+ import { parts } from './anatomy.js';
4
5
  export function createSegmentGroupContext(props) {
5
6
  const [state, send] = useMachine(segmentGroup.machine(props));
6
7
  const api = $derived(segmentGroup.connect(state, send, normalizeProps));
7
- return api;
8
+ const modified = $derived(reflect(() => ({
9
+ ...api,
10
+ getIndicatorProps() {
11
+ return {
12
+ ...api.getIndicatorProps(),
13
+ ...parts.indicator.attrs,
14
+ };
15
+ },
16
+ getItemControlProps(props) {
17
+ return {
18
+ ...api.getItemControlProps(props),
19
+ ...parts.itemControl.attrs,
20
+ };
21
+ },
22
+ getItemProps(props) {
23
+ return {
24
+ ...api.getItemProps(props),
25
+ ...parts.item.attrs,
26
+ };
27
+ },
28
+ getItemTextProps(props) {
29
+ return {
30
+ ...api.getItemTextProps(props),
31
+ ...parts.itemText.attrs,
32
+ };
33
+ },
34
+ getLabelProps() {
35
+ return {
36
+ ...api.getLabelProps(),
37
+ ...parts.label.attrs,
38
+ };
39
+ },
40
+ getRootProps() {
41
+ return {
42
+ ...api.getRootProps(),
43
+ ...parts.root.attrs,
44
+ };
45
+ },
46
+ })));
47
+ return modified;
8
48
  }
9
49
  export function setSegmentGroupContext(value) {
10
50
  setContext('SegmentGroup', value);
@@ -7,7 +7,6 @@
7
7
 
8
8
  <script lang="ts">
9
9
  import {mergeProps} from '@zag-js/svelte';
10
- import {parts} from './anatomy.js';
11
10
  import {useSegmentGroupContext} from './context.svelte.js';
12
11
 
13
12
  let {children, ...props}: SegmentGroupIndicatorProps = $props();
@@ -17,6 +16,6 @@
17
16
  let attrs = $derived(mergeProps(props, context.getIndicatorProps()));
18
17
  </script>
19
18
 
20
- <span {...attrs} {...parts.indicator.attrs}>
19
+ <span {...attrs}>
21
20
  {@render children?.()}
22
21
  </span>
@@ -7,7 +7,6 @@
7
7
 
8
8
  <script lang="ts">
9
9
  import {mergeProps} from '@zag-js/svelte';
10
- import {parts} from './anatomy.js';
11
10
  import {
12
11
  useSegmentGroupContext,
13
12
  useSegmentGroupItemPropsContext,
@@ -24,6 +23,6 @@
24
23
  );
25
24
  </script>
26
25
 
27
- <div {...attrs} {...parts.itemControl.attrs}>
26
+ <div {...attrs}>
28
27
  {@render children?.()}
29
28
  </div>
@@ -7,7 +7,6 @@
7
7
 
8
8
  <script lang="ts">
9
9
  import {mergeProps} from '@zag-js/svelte';
10
- import {parts} from './anatomy.js';
11
10
  import {
12
11
  useSegmentGroupContext,
13
12
  useSegmentGroupItemPropsContext,
@@ -22,6 +21,6 @@
22
21
  let attrs = $derived(mergeProps(props, context.getItemTextProps(itemProps)));
23
22
  </script>
24
23
 
25
- <span {...attrs} {...parts.itemText.attrs}>
24
+ <span {...attrs}>
26
25
  {@render children?.()}
27
26
  </span>
@@ -11,7 +11,6 @@
11
11
 
12
12
  <script lang="ts">
13
13
  import {mergeProps} from '@zag-js/svelte';
14
- import {parts} from './anatomy.js';
15
14
  import {
16
15
  setSegmentGroupItemPropsContext,
17
16
  useSegmentGroupContext,
@@ -54,6 +53,6 @@
54
53
  });
55
54
  </script>
56
55
 
57
- <label {...attrs} {...parts.item.attrs}>
56
+ <label {...attrs}>
58
57
  {@render children?.(state)}
59
58
  </label>
@@ -6,7 +6,6 @@
6
6
 
7
7
  <script lang="ts">
8
8
  import {mergeProps} from '@zag-js/svelte';
9
- import {parts} from './anatomy.js';
10
9
  import {useSegmentGroupContext} from './context.svelte.js';
11
10
 
12
11
  let {children, ...props}: SegmentGroupLabelProps = $props();
@@ -16,6 +15,6 @@
16
15
  let attrs = $derived(mergeProps(props, context.getLabelProps()));
17
16
  </script>
18
17
 
19
- <span {...attrs} {...parts.label.attrs}>
18
+ <span {...attrs}>
20
19
  {@render children?.()}
21
20
  </span>
@@ -20,7 +20,6 @@
20
20
  import {useLocaleContext} from '../locale-provider/index.js';
21
21
  import {createUniqueId} from '../utils.svelte.js';
22
22
  import {mergeProps} from '@zag-js/svelte';
23
- import {parts} from './anatomy.js';
24
23
  import {
25
24
  createSegmentGroupContext,
26
25
  setSegmentGroupContext,
@@ -64,6 +63,6 @@
64
63
  setSegmentGroupContext(context);
65
64
  </script>
66
65
 
67
- <div {...attrs} {...parts.root.attrs}>
66
+ <div {...attrs}>
68
67
  {@render children?.(context)}
69
68
  </div>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ui-ingredients",
3
3
  "type": "module",
4
- "version": "0.0.15",
4
+ "version": "0.0.16",
5
5
  "packageManager": "pnpm@9.7.0",
6
6
  "svelte": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",