mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-17 20:31:47 +02:00
ui : drop unused toggle and toggle-group components
Assisted-by: llama-ui:Qwen3.8-Flash-Next
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
import Root from './toggle-group.svelte';
|
||||
import Item from './toggle-group-item.svelte';
|
||||
|
||||
export {
|
||||
Root,
|
||||
Item,
|
||||
//
|
||||
Root as ToggleGroup,
|
||||
Item as ToggleGroupItem
|
||||
};
|
||||
@@ -1,35 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { getToggleGroupCtx } from './toggle-group.svelte';
|
||||
import { type ToggleVariants, toggleVariants } from '$lib/components/ui/toggle/index.js';
|
||||
import { cn } from '$lib/components/ui/utils.js';
|
||||
import { ToggleGroup as ToggleGroupPrimitive } from 'bits-ui';
|
||||
|
||||
let {
|
||||
class: className,
|
||||
ref = $bindable(null),
|
||||
size,
|
||||
value = $bindable(),
|
||||
variant,
|
||||
...restProps
|
||||
}: ToggleGroupPrimitive.ItemProps & ToggleVariants = $props();
|
||||
|
||||
const ctx = getToggleGroupCtx();
|
||||
</script>
|
||||
|
||||
<ToggleGroupPrimitive.Item
|
||||
bind:ref
|
||||
class={cn(
|
||||
'group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg shrink-0 focus:z-10 focus-visible:z-10 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t',
|
||||
toggleVariants({
|
||||
size: ctx.size || size,
|
||||
variant: ctx.variant || variant
|
||||
}),
|
||||
className
|
||||
)}
|
||||
data-size={ctx.size || size}
|
||||
data-slot="toggle-group-item"
|
||||
data-spacing={ctx.spacing}
|
||||
data-variant={ctx.variant || variant}
|
||||
{value}
|
||||
{...restProps}
|
||||
/>
|
||||
@@ -1,75 +0,0 @@
|
||||
<script lang="ts" module>
|
||||
import { toggleVariants } from '$lib/components/ui/toggle/index.js';
|
||||
import { getContext, setContext } from 'svelte';
|
||||
import type { VariantProps } from 'tailwind-variants';
|
||||
|
||||
type ToggleVariants = VariantProps<typeof toggleVariants>;
|
||||
|
||||
interface ToggleGroupContext extends ToggleVariants {
|
||||
spacing?: number;
|
||||
orientation?: 'horizontal' | 'vertical';
|
||||
}
|
||||
|
||||
export function setToggleGroupCtx(props: ToggleGroupContext) {
|
||||
setContext('toggleGroup', props);
|
||||
}
|
||||
|
||||
export function getToggleGroupCtx() {
|
||||
return getContext<Required<ToggleGroupContext>>('toggleGroup');
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { cn } from '$lib/components/ui/utils.js';
|
||||
import { ToggleGroup as ToggleGroupPrimitive } from 'bits-ui';
|
||||
|
||||
let {
|
||||
class: className,
|
||||
orientation = 'horizontal',
|
||||
ref = $bindable(null),
|
||||
size = 'default',
|
||||
spacing = 0,
|
||||
value = $bindable(),
|
||||
variant = 'default',
|
||||
...restProps
|
||||
}: ToggleGroupPrimitive.RootProps &
|
||||
ToggleVariants & {
|
||||
spacing?: number;
|
||||
orientation?: 'horizontal' | 'vertical';
|
||||
} = $props();
|
||||
|
||||
setToggleGroupCtx({
|
||||
get orientation() {
|
||||
return orientation;
|
||||
},
|
||||
get size() {
|
||||
return size;
|
||||
},
|
||||
get spacing() {
|
||||
return spacing;
|
||||
},
|
||||
get variant() {
|
||||
return variant;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<!--
|
||||
Discriminated Unions + Destructing (required for bindable) do not
|
||||
get along, so we shut typescript up by casting `value` to `never`.
|
||||
-->
|
||||
<ToggleGroupPrimitive.Root
|
||||
bind:ref
|
||||
bind:value={value as never}
|
||||
class={cn(
|
||||
'rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-vertical:flex-col data-vertical:items-stretch',
|
||||
className
|
||||
)}
|
||||
data-size={size}
|
||||
data-slot="toggle-group"
|
||||
data-spacing={spacing}
|
||||
data-variant={variant}
|
||||
{orientation}
|
||||
style={`--gap: ${spacing}`}
|
||||
{...restProps}
|
||||
/>
|
||||
@@ -1,13 +0,0 @@
|
||||
import Root from './toggle.svelte';
|
||||
export {
|
||||
toggleVariants,
|
||||
type ToggleSize,
|
||||
type ToggleVariant,
|
||||
type ToggleVariants
|
||||
} from './toggle.svelte';
|
||||
|
||||
export {
|
||||
Root,
|
||||
//
|
||||
Root as Toggle
|
||||
};
|
||||
@@ -1,52 +0,0 @@
|
||||
<script lang="ts" module>
|
||||
import { tv, type VariantProps } from 'tailwind-variants';
|
||||
|
||||
export const toggleVariants = tv({
|
||||
base: "gap-1 rounded-lg text-sm font-medium transition-all hover:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg:not([class*='size-'])]:size-4 group/toggle inline-flex items-center justify-center whitespace-nowrap outline-none hover:bg-muted focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
||||
defaultVariants: {
|
||||
size: 'default',
|
||||
variant: 'default'
|
||||
},
|
||||
variants: {
|
||||
size: {
|
||||
default:
|
||||
'h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
|
||||
lg: 'h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
|
||||
sm: "h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5"
|
||||
},
|
||||
variant: {
|
||||
default: 'bg-transparent',
|
||||
outline: 'border border-input bg-transparent hover:bg-muted'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export type ToggleVariant = VariantProps<typeof toggleVariants>['variant'];
|
||||
export type ToggleSize = VariantProps<typeof toggleVariants>['size'];
|
||||
export type ToggleVariants = VariantProps<typeof toggleVariants>;
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { cn } from '$lib/components/ui/utils.js';
|
||||
import { Toggle as TogglePrimitive } from 'bits-ui';
|
||||
|
||||
let {
|
||||
class: className,
|
||||
pressed = $bindable(false),
|
||||
ref = $bindable(null),
|
||||
size = 'default',
|
||||
variant = 'default',
|
||||
...restProps
|
||||
}: TogglePrimitive.RootProps & {
|
||||
variant?: ToggleVariant;
|
||||
size?: ToggleSize;
|
||||
} = $props();
|
||||
</script>
|
||||
|
||||
<TogglePrimitive.Root
|
||||
bind:pressed
|
||||
bind:ref
|
||||
class={cn(toggleVariants({ size, variant }), className)}
|
||||
data-slot="toggle"
|
||||
{...restProps}
|
||||
/>
|
||||
Reference in New Issue
Block a user