/
vshmidt
/
label-studio
Обзор
Документация
Войти
/
vshmidt
/
label-studio
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
web/libs/editor/src/stores/CustomButton.ts
34 строки
1 KB
Nick Skriabin
feat: DIA-2142: Use the new Button component in LSO apps and libraries (#7359)
09 июл 2025, 16:51
Не верифицирован
09 июл 2025, 16:51
c7d5c72
Код
Авторство
О чём код?
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, variant: types.maybe( types.enumeration(["primary", "neutral", "positive", "negative", "warning", "inverted"] as const), ), look: types.maybe(types.enumeration(["filled", "outlined", "string"])), size: types.maybe(types.enumeration(["medium", "small", "smaller"])), 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]; } } }, }));