1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4use ts_rs::TS;
5
6#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq, TS)]
8#[ts(export)]
9#[serde(untagged)]
10pub enum MenuItem {
11 Separator { separator: bool },
13 Action {
15 label: String,
16 action: String,
17 #[serde(default)]
18 #[ts(type = "Record<string, any>")]
19 args: HashMap<String, serde_json::Value>,
20 #[serde(default)]
21 when: Option<String>,
22 #[serde(default)]
24 checkbox: Option<String>,
25 },
26 Submenu { label: String, items: Vec<Self> },
28 DynamicSubmenu { label: String, source: String },
31 Label { info: String },
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq, TS)]
37#[ts(export)]
38pub struct Menu {
39 #[serde(default, skip_serializing_if = "Option::is_none")]
43 pub id: Option<String>,
44 pub label: String,
46 pub items: Vec<MenuItem>,
48}