/
alt3rmann
/
label-studio
Обзор
Документация
Войти
/
alt3rmann
/
label-studio
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
web/libs/editor/src/stores/CustomButton.ts
32 строки
1 KB
Sergey
feat: LEAP-1356: Add custom button props (#6787)
15 янв 2025, 19:06
Не верифицирован
15 янв 2025, 19:06
6d9d939
Код
Авторство
О чём код?
import { type Instance, type SnapshotIn, types } from "mobx-state-tree"; import { guidGenerator } from "../utils/unique"; export type CustomButtonType = Instance<typeof CustomButton>; export type CustomButtonSnType = SnapshotIn<typeof CustomButton>; /** * Custom buttons that can be injected from outside application. * The only required property is `name`. If the `name` is one of the predefined buttons, it will be rendered as such. * @see CustomControl in BottomBar/Controls */ export const CustomButton = types .model("CustomButton", { id: types.optional(types.identifier, guidGenerator), name: types.string, title: types.string, look: types.maybe( types.enumeration(["primary", "danger", "destructive", "alt", "outlined", "active", "disabled"] as const), ), tooltip: types.maybe(types.string), ariaLabel: types.maybe(types.string), disabled: types.maybe(types.boolean), props: types.maybe(types.frozen()), }) .actions((self) => ({ updateState(newState: CustomButtonSnType) { for (const key in newState) { if (key in self) { self[key] = newState[key]; } } }, }));