ui-ingredients 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -60,7 +60,7 @@ npm install ui-ingredients
60
60
  - 🟢 RadioGroup
61
61
  - 🟢 RatingGroup
62
62
  - 🟢 Select
63
- - 🟡 SegmentGroup
63
+ - 🟢 SegmentGroup
64
64
  - ⚪ SignaturePad
65
65
  - 🟢 Slider
66
66
  - ⚪ Splitter
@@ -1,2 +1,3 @@
1
1
  import { anatomy } from '@zag-js/radio-group';
2
2
  export const segmentGroupAnatomy = anatomy.rename('segment-group');
3
+ export const parts = segmentGroupAnatomy.build();
@@ -1,33 +1,10 @@
1
1
  import * as segmentGroup from '@zag-js/radio-group';
2
- import { mergeProps, normalizeProps, reflect, useMachine } from '@zag-js/svelte';
2
+ import { normalizeProps, useMachine } from '@zag-js/svelte';
3
3
  import { getContext, setContext } from 'svelte';
4
- import { segmentGroupAnatomy } from './anatomy.js';
5
4
  export function createSegmentGroupContext(props) {
6
- const parts = $derived(segmentGroupAnatomy.build());
7
5
  const [state, send] = useMachine(segmentGroup.machine(props));
8
6
  const api = $derived(segmentGroup.connect(state, send, normalizeProps));
9
- const modified = $derived(reflect(() => ({
10
- ...api,
11
- getIndicatorProps() {
12
- return mergeProps(api.getIndicatorProps(), parts.indicator.attrs);
13
- },
14
- getItemControlProps(props) {
15
- return mergeProps(api.getItemControlProps(props), parts.itemControl.attrs);
16
- },
17
- getItemProps(props) {
18
- return mergeProps(api.getItemProps(props), parts.item.attrs);
19
- },
20
- getItemTextProps(props) {
21
- return mergeProps(api.getItemTextProps(props), parts.itemText.attrs);
22
- },
23
- getLabelProps() {
24
- return mergeProps(api.getLabelProps(), parts.label.attrs);
25
- },
26
- getRootProps() {
27
- return mergeProps(api.getRootProps(), parts.root.attrs);
28
- },
29
- })));
30
- return modified;
7
+ return api;
31
8
  }
32
9
  export function setSegmentGroupContext(value) {
33
10
  setContext('SegmentGroup', value);
@@ -7,6 +7,7 @@
7
7
 
8
8
  <script lang="ts">
9
9
  import {mergeProps} from '@zag-js/svelte';
10
+ import {parts} from './anatomy.js';
10
11
  import {useSegmentGroupContext} from './context.svelte.js';
11
12
 
12
13
  let {children, ...props}: SegmentGroupIndicatorProps = $props();
@@ -16,6 +17,6 @@
16
17
  let attrs = $derived(mergeProps(props, context.getIndicatorProps()));
17
18
  </script>
18
19
 
19
- <span {...attrs}>
20
+ <span {...attrs} {...parts.indicator.attrs}>
20
21
  {@render children?.()}
21
22
  </span>
@@ -7,6 +7,7 @@
7
7
 
8
8
  <script lang="ts">
9
9
  import {mergeProps} from '@zag-js/svelte';
10
+ import {parts} from './anatomy.js';
10
11
  import {
11
12
  useSegmentGroupContext,
12
13
  useSegmentGroupItemPropsContext,
@@ -23,6 +24,6 @@
23
24
  );
24
25
  </script>
25
26
 
26
- <div {...attrs}>
27
+ <div {...attrs} {...parts.itemControl.attrs}>
27
28
  {@render children?.()}
28
29
  </div>
@@ -7,6 +7,7 @@
7
7
 
8
8
  <script lang="ts">
9
9
  import {mergeProps} from '@zag-js/svelte';
10
+ import {parts} from './anatomy.js';
10
11
  import {
11
12
  useSegmentGroupContext,
12
13
  useSegmentGroupItemPropsContext,
@@ -21,6 +22,6 @@
21
22
  let attrs = $derived(mergeProps(props, context.getItemTextProps(itemProps)));
22
23
  </script>
23
24
 
24
- <span {...attrs}>
25
+ <span {...attrs} {...parts.itemText.attrs}>
25
26
  {@render children?.()}
26
27
  </span>
@@ -11,6 +11,7 @@
11
11
 
12
12
  <script lang="ts">
13
13
  import {mergeProps} from '@zag-js/svelte';
14
+ import {parts} from './anatomy.js';
14
15
  import {
15
16
  setSegmentGroupItemPropsContext,
16
17
  useSegmentGroupContext,
@@ -53,6 +54,6 @@
53
54
  });
54
55
  </script>
55
56
 
56
- <label {...attrs}>
57
+ <label {...attrs} {...parts.item.attrs}>
57
58
  {@render children?.(state)}
58
59
  </label>
@@ -6,6 +6,7 @@
6
6
 
7
7
  <script lang="ts">
8
8
  import {mergeProps} from '@zag-js/svelte';
9
+ import {parts} from './anatomy.js';
9
10
  import {useSegmentGroupContext} from './context.svelte.js';
10
11
 
11
12
  let {children, ...props}: SegmentGroupLabelProps = $props();
@@ -15,6 +16,6 @@
15
16
  let attrs = $derived(mergeProps(props, context.getLabelProps()));
16
17
  </script>
17
18
 
18
- <span {...attrs}>
19
+ <span {...attrs} {...parts.label.attrs}>
19
20
  {@render children?.()}
20
21
  </span>
@@ -20,6 +20,7 @@
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';
23
24
  import {
24
25
  createSegmentGroupContext,
25
26
  setSegmentGroupContext,
@@ -63,6 +64,6 @@
63
64
  setSegmentGroupContext(context);
64
65
  </script>
65
66
 
66
- <div {...attrs}>
67
+ <div {...attrs} {...parts.root.attrs}>
67
68
  {@render children?.(context)}
68
69
  </div>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ui-ingredients",
3
3
  "type": "module",
4
- "version": "0.0.14",
4
+ "version": "0.0.15",
5
5
  "packageManager": "pnpm@9.7.0",
6
6
  "svelte": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -1,10 +0,0 @@
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;