feature: move all shadcn related code to src/shared/shadcn

This commit is contained in:
Ilia Mashkov
2026-01-01 14:37:18 +03:00
parent 8713207afb
commit 1321347ac3
88 changed files with 107 additions and 653 deletions

View File

@@ -0,0 +1,37 @@
import { type ClassValue, clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
/**
* Utility function to merge Tailwind CSS classes
* Combines clsx for conditional classes and tailwind-merge to handle conflicts
*/
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
/**
* Type utility to add a ref property to HTML element attributes
* Used in shadcn-svelte components to support element references
* @template T - The attributes type (e.g., HTMLAttributes<HTMLDivElement>)
* @template E - The element type (e.g., HTMLDivElement)
*/
export type WithElementRef<T, E extends HTMLElement = HTMLElement> = T & {
/**
* Reference to the DOM element
*/
ref?: E | null;
};
/**
* Type utility to remove 'children' and 'child' properties from a type
* Used in shadcn-svelte components that use Snippets instead of children
* @template T - The type to remove children from
*/
export type WithoutChildren<T> = Omit<T, 'children'>;
/**
* Type utility to remove 'children' and 'child' properties from a type
* Used in shadcn-svelte components that use Snippets instead of children
* @template T - The type to remove children and child from
*/
export type WithoutChildrenOrChild<T> = Omit<T, 'children' | 'child'>;