feat: add generic type for property value

This commit is contained in:
Ilia Mashkov
2026-01-09 16:11:35 +03:00
parent 6f7e863b13
commit 1990860717
6 changed files with 52 additions and 25 deletions

View File

@@ -4,7 +4,7 @@ import type { FilterGroupConfig } from '../../model/const/types/common';
/**
* Create a filter manager instance.
*/
export function createFilterManager(configs: FilterGroupConfig[]) {
export function createFilterManager<TValue extends string>(configs: FilterGroupConfig<TValue>[]) {
// Create filter instances upfront
const groups = $state(
configs.map(config => ({

View File

@@ -1,70 +1,90 @@
import type {
FontCategory,
FontProvider,
FontSubset,
} from '$entities/Font';
import type { Property } from '$shared/lib';
export const FONT_CATEGORIES: Property[] = [
export const FONT_CATEGORIES: Property<FontCategory>[] = [
{
id: 'serif',
name: 'Serif',
value: 'serif',
},
{
id: 'sans-serif',
name: 'Sans-serif',
value: 'sans-serif',
},
{
id: 'display',
name: 'Display',
value: 'display',
},
{
id: 'handwriting',
name: 'Handwriting',
value: 'handwriting',
},
{
id: 'monospace',
name: 'Monospace',
value: 'monospace',
},
{
id: 'script',
name: 'Script',
value: 'script',
},
{
id: 'slab',
name: 'Slab',
value: 'slab',
},
] as const;
export const FONT_PROVIDERS: Property[] = [
export const FONT_PROVIDERS: Property<FontProvider>[] = [
{
id: 'google',
name: 'Google Fonts',
value: 'google',
},
{
id: 'fontshare',
name: 'Fontshare',
value: 'fontshare',
},
] as const;
export const FONT_SUBSETS: Property[] = [
export const FONT_SUBSETS: Property<FontSubset>[] = [
{
id: 'latin',
name: 'Latin',
value: 'latin',
},
{
id: 'latin-ext',
name: 'Latin Extended',
value: 'latin-ext',
},
{
id: 'cyrillic',
name: 'Cyrillic',
value: 'cyrillic',
},
{
id: 'greek',
name: 'Greek',
value: 'greek',
},
{
id: 'arabic',
name: 'Arabic',
value: 'arabic',
},
{
id: 'devanagari',
name: 'Devanagari',
value: 'devanagari',
},
] as const;

View File

@@ -1,7 +1,7 @@
import type { Property } from '$shared/lib';
export interface FilterGroupConfig {
export interface FilterGroupConfig<TValue extends string> {
id: string;
label: string;
properties: Property[];
properties: Property<TValue>[];
}