/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
packages/mui-utils/src/generateUtilityClass/generateUtilityClass.ts
33 строки
894 B
Michał Dudak
[base-ui] Change the CSS class prefix to `base-` (#40205)
15 янв 2024, 15:54
Не верифицирован
15 янв 2024, 15:54
8b96649
Код
Авторство
О чём код?
import ClassNameGenerator from '../ClassNameGenerator'; export type GlobalStateSlot = keyof typeof globalStateClasses; export const globalStateClasses = { active: 'active', checked: 'checked', completed: 'completed', disabled: 'disabled', error: 'error', expanded: 'expanded', focused: 'focused', focusVisible: 'focusVisible', open: 'open', readOnly: 'readOnly', required: 'required', selected: 'selected', }; export default function generateUtilityClass( componentName: string, slot: string, globalStatePrefix = 'Mui', ): string { const globalStateClass = globalStateClasses[slot as GlobalStateSlot]; return globalStateClass ? `${globalStatePrefix}-${globalStateClass}` : `${ClassNameGenerator.generate(componentName)}-${slot}`; } export function isGlobalState(slot: string) { return globalStateClasses[slot as GlobalStateSlot] !== undefined; }