ui-ingredients 0.10.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- export declare const createUniqueId: () => string;
1
+ export declare function createUniqueId(): string;
@@ -1,2 +1,15 @@
1
- import { uid } from 'uid';
2
- export const createUniqueId = () => uid();
1
+ let prefix = 0;
2
+ let counter = 0;
3
+ export function createUniqueId() {
4
+ if (prefix >= Number.MAX_SAFE_INTEGER) {
5
+ prefix = 0;
6
+ }
7
+ if (counter >= Number.MAX_SAFE_INTEGER) {
8
+ prefix += 1;
9
+ counter = 0;
10
+ }
11
+ else {
12
+ counter += 1;
13
+ }
14
+ return `${prefix}${counter}`.padStart(8, '0');
15
+ }
@@ -1,8 +1,10 @@
1
1
  import { createUniqueId } from '../create-unique-id.js';
2
2
  import { getEnvironmentContext } from '../environment-provider/enviroment-provider-context.svelte.js';
3
3
  import { getLocaleContext } from '../locale-provider/local-provider-context.svelte.js';
4
+ import { mergeProps } from '../merge-props.js';
4
5
  import * as segmentGroup from '@zag-js/radio-group';
5
6
  import { normalizeProps, reflect, useMachine } from '@zag-js/svelte';
7
+ import { parts } from './segment-group-anatomy.js';
6
8
  export function createSegmentGroup(props) {
7
9
  const locale = getLocaleContext();
8
10
  const environment = getEnvironmentContext();
@@ -14,5 +16,28 @@ export function createSegmentGroup(props) {
14
16
  ...props,
15
17
  }));
16
18
  const [state, send] = useMachine(segmentGroup.machine(context));
17
- return reflect(() => segmentGroup.connect(state, send, normalizeProps));
19
+ return reflect(() => {
20
+ const o = segmentGroup.connect(state, send, normalizeProps);
21
+ return {
22
+ ...o,
23
+ getIndicatorProps() {
24
+ return mergeProps(o.getIndicatorProps(), parts.indicator.attrs);
25
+ },
26
+ getItemControlProps(props) {
27
+ return mergeProps(o.getItemControlProps(props), parts.itemControl.attrs);
28
+ },
29
+ getItemProps(props) {
30
+ return mergeProps(o.getItemProps(props), parts.item.attrs);
31
+ },
32
+ getItemTextProps(props) {
33
+ return mergeProps(o.getItemTextProps(props), parts.itemText.attrs);
34
+ },
35
+ getLabelProps() {
36
+ return mergeProps(o.getLabelProps(), parts.label.attrs);
37
+ },
38
+ getRootProps() {
39
+ return mergeProps(o.getRootProps(), parts.root.attrs);
40
+ },
41
+ };
42
+ });
18
43
  }
@@ -7,7 +7,6 @@
7
7
 
8
8
  <script lang="ts">
9
9
  import {mergeProps} from '../merge-props.js';
10
- import {parts} from './segment-group-anatomy.js';
11
10
  import {getSegmentGroupContext} from './segment-group-context.svelte.js';
12
11
 
13
12
  let {
@@ -20,7 +19,7 @@
20
19
  let segmentGroup = getSegmentGroupContext();
21
20
 
22
21
  let mergedProps = $derived(
23
- mergeProps(segmentGroup.getIndicatorProps(), parts.indicator.attrs, props),
22
+ mergeProps(segmentGroup.getIndicatorProps(), props),
24
23
  );
25
24
  </script>
26
25
 
@@ -7,7 +7,6 @@
7
7
 
8
8
  <script lang="ts">
9
9
  import {mergeProps} from '../merge-props.js';
10
- import {parts} from './segment-group-anatomy.js';
11
10
  import {
12
11
  getSegmentGroupContext,
13
12
  getSegmentGroupItemPropsContext,
@@ -24,11 +23,7 @@
24
23
  let itemProps = getSegmentGroupItemPropsContext();
25
24
 
26
25
  let mergedProps = $derived(
27
- mergeProps(
28
- segmentGroup.getItemControlProps(itemProps),
29
- parts.itemControl.attrs,
30
- props,
31
- ),
26
+ mergeProps(segmentGroup.getItemControlProps(itemProps), props),
32
27
  );
33
28
  </script>
34
29
 
@@ -7,7 +7,6 @@
7
7
 
8
8
  <script lang="ts">
9
9
  import {mergeProps} from '../merge-props.js';
10
- import {parts} from './segment-group-anatomy.js';
11
10
  import {
12
11
  getSegmentGroupContext,
13
12
  getSegmentGroupItemPropsContext,
@@ -24,11 +23,7 @@
24
23
  let itemProps = getSegmentGroupItemPropsContext();
25
24
 
26
25
  let mergedProps = $derived(
27
- mergeProps(
28
- segmentGroup.getItemTextProps(itemProps),
29
- parts.itemText.attrs,
30
- props,
31
- ),
26
+ mergeProps(segmentGroup.getItemTextProps(itemProps), props),
32
27
  );
33
28
  </script>
34
29
 
@@ -12,7 +12,6 @@
12
12
  <script lang="ts">
13
13
  import {mergeProps} from '../merge-props.js';
14
14
  import {createSplitProps} from '@zag-js/utils';
15
- import {parts} from './segment-group-anatomy.js';
16
15
  import {
17
16
  getSegmentGroupContext,
18
17
  setSegmentGroupItemPropsContext,
@@ -33,11 +32,7 @@
33
32
 
34
33
  let itemState = $derived(segmentGroup.getItemState(itemProps));
35
34
  let mergedProps = $derived(
36
- mergeProps(
37
- segmentGroup.getItemProps(itemProps),
38
- parts.item.attrs,
39
- localProps,
40
- ),
35
+ mergeProps(segmentGroup.getItemProps(itemProps), localProps),
41
36
  );
42
37
 
43
38
  setSegmentGroupItemPropsContext(() => itemProps);
@@ -7,7 +7,6 @@
7
7
 
8
8
  <script lang="ts">
9
9
  import {mergeProps} from '../merge-props.js';
10
- import {parts} from './segment-group-anatomy.js';
11
10
  import {getSegmentGroupContext} from './segment-group-context.svelte.js';
12
11
 
13
12
  let {
@@ -19,9 +18,7 @@
19
18
 
20
19
  let segmentGroup = getSegmentGroupContext();
21
20
 
22
- let mergedProps = $derived(
23
- mergeProps(segmentGroup.getLabelProps(), parts.label.attrs, props),
24
- );
21
+ let mergedProps = $derived(mergeProps(segmentGroup.getLabelProps(), props));
25
22
  </script>
26
23
 
27
24
  {#if asChild}
@@ -17,7 +17,6 @@
17
17
  import {reflect} from '@zag-js/svelte';
18
18
  import {createSplitProps} from '@zag-js/utils';
19
19
  import {createSegmentGroup} from './create-segment-group.svelte.js';
20
- import {parts} from './segment-group-anatomy.js';
21
20
  import {setSegmentGroupContext} from './segment-group-context.svelte.js';
22
21
 
23
22
  let {
@@ -44,7 +43,7 @@
44
43
  let segmentGroup = createSegmentGroup(reflect(() => createSegmentGroupProps));
45
44
 
46
45
  let mergedProps = $derived(
47
- mergeProps(segmentGroup.getRootProps(), parts.root.attrs, localProps),
46
+ mergeProps(segmentGroup.getRootProps(), localProps),
48
47
  );
49
48
 
50
49
  setSegmentGroupContext(segmentGroup);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "ui-ingredients",
3
3
  "type": "module",
4
4
  "license": "MIT",
5
- "version": "0.10.0",
5
+ "version": "0.12.0",
6
6
  "packageManager": "pnpm@9.12.2",
7
7
  "svelte": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
@@ -344,8 +344,7 @@
344
344
  "@zag-js/tooltip": "^0.76.0",
345
345
  "@zag-js/tour": "^0.76.0",
346
346
  "@zag-js/tree-view": "^0.76.0",
347
- "@zag-js/utils": "^0.76.0",
348
- "uid": "^2.0.2"
347
+ "@zag-js/utils": "^0.76.0"
349
348
  },
350
349
  "peerDependencies": {
351
350
  "svelte": ">=5.0.0"