ui-ingredients 0.0.14 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
package/README.md
CHANGED
@@ -1,30 +1,47 @@
|
|
1
1
|
import * as segmentGroup from '@zag-js/radio-group';
|
2
|
-
import {
|
2
|
+
import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
|
3
3
|
import { getContext, setContext } from 'svelte';
|
4
|
-
import {
|
4
|
+
import { parts } from './anatomy.js';
|
5
5
|
export function createSegmentGroupContext(props) {
|
6
|
-
const parts = $derived(segmentGroupAnatomy.build());
|
7
6
|
const [state, send] = useMachine(segmentGroup.machine(props));
|
8
7
|
const api = $derived(segmentGroup.connect(state, send, normalizeProps));
|
9
8
|
const modified = $derived(reflect(() => ({
|
10
9
|
...api,
|
11
10
|
getIndicatorProps() {
|
12
|
-
return
|
11
|
+
return {
|
12
|
+
...api.getIndicatorProps(),
|
13
|
+
...parts.indicator.attrs,
|
14
|
+
};
|
13
15
|
},
|
14
16
|
getItemControlProps(props) {
|
15
|
-
return
|
17
|
+
return {
|
18
|
+
...api.getItemControlProps(props),
|
19
|
+
...parts.itemControl.attrs,
|
20
|
+
};
|
16
21
|
},
|
17
22
|
getItemProps(props) {
|
18
|
-
return
|
23
|
+
return {
|
24
|
+
...api.getItemProps(props),
|
25
|
+
...parts.item.attrs,
|
26
|
+
};
|
19
27
|
},
|
20
28
|
getItemTextProps(props) {
|
21
|
-
return
|
29
|
+
return {
|
30
|
+
...api.getItemTextProps(props),
|
31
|
+
...parts.itemText.attrs,
|
32
|
+
};
|
22
33
|
},
|
23
34
|
getLabelProps() {
|
24
|
-
return
|
35
|
+
return {
|
36
|
+
...api.getLabelProps(),
|
37
|
+
...parts.label.attrs,
|
38
|
+
};
|
25
39
|
},
|
26
40
|
getRootProps() {
|
27
|
-
return
|
41
|
+
return {
|
42
|
+
...api.getRootProps(),
|
43
|
+
...parts.root.attrs,
|
44
|
+
};
|
28
45
|
},
|
29
46
|
})));
|
30
47
|
return modified;
|