/
45case
/
ptable
Обзор
Документация
Войти
/
45case
/
ptable
Код
Запросы
3
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
dev
src/entities/element/model/properties.ts
209 строк
6 KB
Olya
feat: интерактивная подсветка элементов по сериям и агрегатным состояниям
15 июл 2026, 18:34
15 июл 2026, 18:34
681598d
Код
Авторство
О чём код?
import type { ElementCategory } from "./category"; import type { ElementPhaseAtStp, ElementSeries } from "./elements"; export const elementPropertyKeys = [ "atomicNumber", "symbol", "name", "nameEn", "series", "phaseAtStp", "period", "group", "atomicMass", "state", "category", ] as const; export type ElementPropertyKey = (typeof elementPropertyKeys)[number]; export type ElementPropertyKind = "quantitative" | "categorical" | "text"; export type ElementPropertyValueType = "number" | "enum" | "string"; export type ElementPropertyUnit = "none" | "u"; export interface ElementPropertyDefinition { key: ElementPropertyKey; label: string; shortLabel: string; description: string; kind: ElementPropertyKind; valueType: ElementPropertyValueType; unit: ElementPropertyUnit; options?: readonly string[]; optionLabels?: Record<string, string>; }; const elementSeriesOptions: readonly ElementSeries[] = [ "alkali-metal", "alkaline-earth-metal", "transition-metal", "post-transition-metal", "metalloid", "nonmetal", "noble-gas", "lanthanide", "actinide", "unknown", ]; const elementCategoryOptions: readonly ElementCategory[] = [ "alkali-metal", "alkaline-earth-metal", "transition-metal", "post-transition-metal", "metalloid", "nonmetal", "halogen", "noble-gas", "lanthanide", "actinide", "unknown", ]; const phaseAtStpOptions: readonly ElementPhaseAtStp[] = ["solid", "liquid", "gas", "unknown"]; export const elementPropertyCatalog: Record<ElementPropertyKey, ElementPropertyDefinition> = { atomicNumber: { key: "atomicNumber", label: "Атомный номер", shortLabel: "№", description: "Порядковый номер элемента в периодической таблице.", kind: "quantitative", valueType: "number", unit: "none", }, symbol: { key: "symbol", label: "Символ", shortLabel: "Символ", description: "Краткое химическое обозначение элемента.", kind: "text", valueType: "string", unit: "none", }, name: { key: "name", label: "Русское название", shortLabel: "Название", description: "Русское название химического элемента.", kind: "text", valueType: "string", unit: "none", }, nameEn: { key: "nameEn", label: "Английское название", shortLabel: "Name", description: "Английское название химического элемента.", kind: "text", valueType: "string", unit: "none", }, series: { key: "series", label: "Серия", shortLabel: "Серия", description: "Химическая серия элемента внутри периодической таблицы.", kind: "categorical", valueType: "enum", unit: "none", options: elementSeriesOptions, optionLabels: { "alkali-metal": "Щелочной металл", "alkaline-earth-metal": "Щёлочноземельный металл", "transition-metal": "Переходный металл", "post-transition-metal": "Постпереходный металл", metalloid: "Металлоид", nonmetal: "Неметалл", "noble-gas": "Благородный газ", lanthanide: "Лантаноид", actinide: "Актиноид", unknown: "Неизвестно", }, }, phaseAtStp: { key: "phaseAtStp", label: "Состояние при СТП", shortLabel: "СТП", description: "Агрегатное состояние элемента при стандартных условиях.", kind: "categorical", valueType: "enum", unit: "none", options: phaseAtStpOptions, optionLabels: { solid: "Твёрдое", liquid: "Жидкое", gas: "Газ", unknown: "Неизвестно", }, }, period: { key: "period", label: "Период", shortLabel: "Период", description: "Номер периода элемента в периодической таблице.", kind: "quantitative", valueType: "number", unit: "none", }, group: { key: "group", label: "Группа", shortLabel: "Группа", description: "Номер группы элемента в периодической таблице.", kind: "quantitative", valueType: "number", unit: "none", }, atomicMass: { key: "atomicMass", label: "Атомная масса", shortLabel: "Масса", description: "Средняя атомная масса элемента.", kind: "quantitative", valueType: "number", unit: "u", }, state: { key: "state", label: "Состояние", shortLabel: "Состояние", description: "Человекочитаемая подпись агрегатного состояния элемента.", kind: "text", valueType: "string", unit: "none", }, category: { key: "category", label: "Категория", shortLabel: "Категория", description: "Химическая категория элемента в периодической таблице.", kind: "categorical", valueType: "enum", unit: "none", options: elementCategoryOptions, optionLabels: { "alkali-metal": "Щелочной металл", "alkaline-earth-metal": "Щёлочноземельный металл", "transition-metal": "Переходный металл", "post-transition-metal": "Постпереходный металл", metalloid: "Металлоид", nonmetal: "Неметалл", halogen: "Галоген", "noble-gas": "Благородный газ", lanthanide: "Лантаноид", actinide: "Актиноид", unknown: "Неизвестно", }, }, }; export function getElementPropertyDefinition(key: ElementPropertyKey) { return elementPropertyCatalog[key]; } export function getElementPropertyDefinitions() { return elementPropertyKeys.map((key) => elementPropertyCatalog[key]); }