compote-ui 0.46.4 → 0.46.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,10 +8,11 @@
8
8
  children,
9
9
  pressed = $bindable(),
10
10
  size,
11
+ icon,
11
12
  ...rootProps
12
13
  }: ToggleProps = $props();
13
14
  </script>
14
15
 
15
- <ArkToggle.Root {...rootProps} bind:pressed class={toggle({ size, class: className as never })}>
16
+ <ArkToggle.Root {...rootProps} bind:pressed class={toggle({ size, icon, class: className as never })}>
16
17
  {@render children?.()}
17
18
  </ArkToggle.Root>
@@ -5,17 +5,26 @@ export declare const toggle: import("tailwind-variants").TVReturnType<{
5
5
  md: string;
6
6
  lg: string;
7
7
  };
8
+ icon: {
9
+ true: string;
10
+ };
8
11
  }, undefined, "inline-flex cursor-pointer items-center justify-center rounded-md font-medium text-ink-dim transition-colors select-none hover:bg-surface-2 hover:text-ink focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none data-disabled:cursor-not-allowed data-disabled:opacity-50 data-pressed:bg-surface-2 data-pressed:text-ink data-pressed:shadow-sm data-[state=on]:bg-surface-2 data-[state=on]:text-ink data-[state=on]:shadow-sm [&_svg]:shrink-0", {
9
12
  size: {
10
13
  sm: string;
11
14
  md: string;
12
15
  lg: string;
13
16
  };
17
+ icon: {
18
+ true: string;
19
+ };
14
20
  }, undefined, import("tailwind-variants").TVReturnType<{
15
21
  size: {
16
22
  sm: string;
17
23
  md: string;
18
24
  lg: string;
19
25
  };
26
+ icon: {
27
+ true: string;
28
+ };
20
29
  }, undefined, "inline-flex cursor-pointer items-center justify-center rounded-md font-medium text-ink-dim transition-colors select-none hover:bg-surface-2 hover:text-ink focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none data-disabled:cursor-not-allowed data-disabled:opacity-50 data-pressed:bg-surface-2 data-pressed:text-ink data-pressed:shadow-sm data-[state=on]:bg-surface-2 data-[state=on]:text-ink data-[state=on]:shadow-sm [&_svg]:shrink-0", unknown, unknown, undefined>>;
21
30
  export type ToggleSize = NonNullable<VariantProps<typeof toggle>['size']>;
@@ -5,8 +5,16 @@ export const toggle = tv({
5
5
  size: {
6
6
  sm: 'h-7 min-w-7 gap-1 px-1.5 text-xs [&_svg]:size-3.5',
7
7
  md: 'h-8 min-w-8 gap-1.5 px-2 text-sm [&_svg]:size-4',
8
- lg: 'h-10 min-w-10 gap-2 px-2.5 text-sm [&_svg]:size-5'
8
+ lg: 'h-9 min-w-9 gap-2 px-2.5 text-sm [&_svg]:size-5'
9
+ },
10
+ icon: {
11
+ true: ''
9
12
  }
10
13
  },
14
+ compoundVariants: [
15
+ { size: 'sm', icon: true, class: 'w-7 px-0 [&_svg]:size-5' },
16
+ { size: 'md', icon: true, class: 'w-8 px-0 [&_svg]:size-6' },
17
+ { size: 'lg', icon: true, class: 'w-9 px-0 [&_svg]:size-7' }
18
+ ],
11
19
  defaultVariants: { size: 'md' }
12
20
  });
@@ -4,5 +4,6 @@ import type { ToggleSize } from './toggle.variants';
4
4
  export interface ToggleProps extends ToggleRootProps {
5
5
  class?: ClassValue | null;
6
6
  size?: ToggleSize;
7
+ icon?: boolean;
7
8
  }
8
9
  export type { ToggleSize };
@@ -1,8 +1,15 @@
1
1
  import type { ToggleSize } from '../toggle/toggle.variants';
2
+ export type ToggleGroupVariant = 'outline' | 'ghost';
2
3
  export declare const getToggleGroupContext: () => {
3
4
  readonly size: ToggleSize;
5
+ readonly variant: ToggleGroupVariant;
6
+ readonly icon: boolean;
4
7
  }, setToggleGroupContext: (context: {
5
8
  readonly size: ToggleSize;
9
+ readonly variant: ToggleGroupVariant;
10
+ readonly icon: boolean;
6
11
  }) => {
7
12
  readonly size: ToggleSize;
13
+ readonly variant: ToggleGroupVariant;
14
+ readonly icon: boolean;
8
15
  };
@@ -8,16 +8,23 @@
8
8
  interface Props extends ToggleGroupItemBaseProps {
9
9
  class?: ClassValue | null;
10
10
  size?: ToggleSize;
11
+ icon?: boolean;
11
12
  }
12
13
 
13
- let { class: className, children, size, ...rest }: Props = $props();
14
+ let { class: className, children, size, icon, ...rest }: Props = $props();
14
15
  const groupContext = getToggleGroupContext();
15
16
  const itemSize = $derived(size ?? groupContext.size);
17
+ const itemIcon = $derived(icon ?? groupContext.icon);
18
+ const itemClass = $derived(
19
+ groupContext.variant === 'ghost'
20
+ ? toggle({ size: itemSize, icon: itemIcon, class: className as never })
21
+ : toggle({ size: itemSize, icon: itemIcon, class: ['rounded-none', className] as never })
22
+ );
16
23
  </script>
17
24
 
18
25
  <ToggleGroup.Item
19
26
  {...rest}
20
- class={toggle({ size: itemSize, class: ['rounded-none', className] as never })}
27
+ class={itemClass}
21
28
  >
22
29
  {@render children?.()}
23
30
  </ToggleGroup.Item>
@@ -4,6 +4,7 @@ import { type ToggleSize } from '../toggle/toggle.variants';
4
4
  interface Props extends ToggleGroupItemBaseProps {
5
5
  class?: ClassValue | null;
6
6
  size?: ToggleSize;
7
+ icon?: boolean;
7
8
  }
8
9
  declare const ToggleGroupItem: import("svelte").Component<Props, {}, "">;
9
10
  type ToggleGroupItem = ReturnType<typeof ToggleGroupItem>;
@@ -3,11 +3,13 @@
3
3
  import type { ToggleGroupRootBaseProps } from '@ark-ui/svelte/toggle-group';
4
4
  import { cn } from 'tailwind-variants';
5
5
  import type { ToggleSize } from '../toggle/toggle.variants';
6
- import { setToggleGroupContext } from './toggle-group-context';
6
+ import { setToggleGroupContext, type ToggleGroupVariant } from './toggle-group-context';
7
7
 
8
8
  interface Props extends ToggleGroupRootBaseProps {
9
9
  class?: string;
10
10
  size?: ToggleSize;
11
+ variant?: ToggleGroupVariant;
12
+ icon?: boolean;
11
13
  }
12
14
 
13
15
  let {
@@ -15,23 +17,37 @@
15
17
  children,
16
18
  value = $bindable(),
17
19
  size = 'md',
20
+ variant = 'outline',
21
+ icon = false,
18
22
  ...rootProps
19
23
  }: Props = $props();
20
24
 
21
25
  setToggleGroupContext({
22
26
  get size() {
23
27
  return size;
28
+ },
29
+ get variant() {
30
+ return variant;
31
+ },
32
+ get icon() {
33
+ return icon;
24
34
  }
25
35
  });
36
+
37
+ const rootClass = $derived(
38
+ variant === 'ghost'
39
+ ? cn('inline-flex w-fit gap-1 data-[orientation=vertical]:flex-col data-[orientation=vertical]:gap-1', className)
40
+ : cn(
41
+ 'inline-flex w-fit rounded border border-border data-[orientation=vertical]:flex-col [&>:not([hidden])~:not([hidden])]:border-border data-[orientation=horizontal]:[&>:not([hidden])~:not([hidden])]:border-s data-[orientation=horizontal]:[&>:not([hidden])~:not([hidden])]:border-e-0 data-[orientation=vertical]:[&>:not([hidden])~:not([hidden])]:border-t data-[orientation=vertical]:[&>:not([hidden])~:not([hidden])]:border-b-0',
42
+ className
43
+ )
44
+ );
26
45
  </script>
27
46
 
28
47
  <ToggleGroup.Root
29
48
  {...rootProps}
30
49
  bind:value
31
- class={cn(
32
- 'inline-flex w-fit rounded border border-border data-[orientation=vertical]:flex-col [&>:not([hidden])~:not([hidden])]:border-border data-[orientation=horizontal]:[&>:not([hidden])~:not([hidden])]:border-s data-[orientation=horizontal]:[&>:not([hidden])~:not([hidden])]:border-e-0 data-[orientation=vertical]:[&>:not([hidden])~:not([hidden])]:border-t data-[orientation=vertical]:[&>:not([hidden])~:not([hidden])]:border-b-0',
33
- className
34
- )}
50
+ class={rootClass}
35
51
  >
36
52
  {@render children?.()}
37
53
  </ToggleGroup.Root>
@@ -1,9 +1,12 @@
1
1
  import { ToggleGroup } from '@ark-ui/svelte/toggle-group';
2
2
  import type { ToggleGroupRootBaseProps } from '@ark-ui/svelte/toggle-group';
3
3
  import type { ToggleSize } from '../toggle/toggle.variants';
4
+ import { type ToggleGroupVariant } from './toggle-group-context';
4
5
  interface Props extends ToggleGroupRootBaseProps {
5
6
  class?: string;
6
7
  size?: ToggleSize;
8
+ variant?: ToggleGroupVariant;
9
+ icon?: boolean;
7
10
  }
8
11
  declare const ToggleGroup: import("svelte").Component<Props, {}, "value">;
9
12
  type ToggleGroup = ReturnType<typeof ToggleGroup>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "compote-ui",
3
- "version": "0.46.4",
3
+ "version": "0.46.5",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "vite dev --open",