Files
ss-tools/frontend/src/lib/utils.ts
busya 4fc3356312 refactor(frontend): migrate Svelte stores from .ts to .svelte.ts runes
- Delete legacy .ts stores (auth, activity, assistantChat, datasetReview, environmentContext, health, sidebar, taskDrawer, translationRun)
- Create new .svelte.ts runes-based stores using  reactive primitives
- Migrate i18n: /i18n → /i18n/index.svelte.js
- Migrate toasts: /toasts → /toasts.svelte.js
- Update all component imports across 180+ files: components, pages, routes, lib
- Remove fromStore() wrappers — use store.value directly with Svelte 5 runes
- Update test mocks for new import paths
- Add @DEPRECATED annotation to legacy  alias
2026-06-02 09:54:18 +03:00

33 lines
1.2 KiB
TypeScript

// #region UtilsModule [C:1] [TYPE Module] [SEMANTICS utility, classnames, merge, helper]
// #region Utils:Module [TYPE Function]
/**
* @PURPOSE: General utility functions (class merging)
* @LAYER Infra
*
* Merges Tailwind class names into a single string. Handles strings, falsy values,
* numbers, arrays, and nested structures — compatible with clsx/classnames convention.
*/
type ClassValue = string | number | boolean | undefined | null | ClassValue[] | Record<string, boolean | undefined | null>;
function _flattenClassValue(input: ClassValue): string[] {
if (typeof input === "string" && input.length > 0) return [input];
if (typeof input === "number") return [String(input)];
if (typeof input === "boolean") return [];
if (input === null || input === undefined) return [];
if (Array.isArray(input)) return input.flatMap(_flattenClassValue);
if (typeof input === "object") {
return Object.entries(input)
.filter(([_, val]) => val)
.map(([key]) => key);
}
return [];
}
export function cn(...inputs: ClassValue[]): string {
return inputs.flatMap(_flattenClassValue).join(" ");
}
// #endregion Utils:Module
// #endregion UtilsModule