/
aqa
/
claude-code
Обзор
Документация
Войти
/
aqa
/
claude-code
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
components/CustomSelect/option-map.ts
50 строк
1 KB
kuberwastaken
new initial commit (history rewritten)
01 апр 2026, 14:57
01 апр 2026, 14:57
c1996f2
Код
Авторство
О чём код?
import type { ReactNode } from 'react' import type { OptionWithDescription } from './select.js' type OptionMapItem<T> = { label: ReactNode value: T description?: string previous: OptionMapItem<T> | undefined next: OptionMapItem<T> | undefined index: number } export default class OptionMap<T> extends Map<T, OptionMapItem<T>> { readonly first: OptionMapItem<T> | undefined readonly last: OptionMapItem<T> | undefined constructor(options: OptionWithDescription<T>[]) { const items: Array<[T, OptionMapItem<T>]> = [] let firstItem: OptionMapItem<T> | undefined let lastItem: OptionMapItem<T> | undefined let previous: OptionMapItem<T> | undefined let index = 0 for (const option of options) { const item = { label: option.label, value: option.value, description: option.description, previous, next: undefined, index, } if (previous) { previous.next = item } firstItem ||= item lastItem = item items.push([option.value, item]) index++ previous = item } super(items) this.first = firstItem this.last = lastItem } }