tree_table/args/
args_dropdown.rs1use crate::DropdownState;
2use crate::SpanKey;
3use crate::Val;
4use crate::statics::default_emit_event_for_api;
5use crate::statics::default_expand_for_api;
6use crate::statics::default_save_selection_for_api;
7use crate::statics::default_undo_for_api;
8use alloc::string::String;
9use alloc::vec;
10use alloc::vec::Vec;
11
12#[cfg_attr(feature = "tsify", derive(tsify::Tsify))]
13#[cfg_attr(feature = "tsify", tsify(from_wasm_abi))]
14#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
15#[derive(Debug, Clone, PartialEq)]
16pub struct DropdownArgs {
17 pub key: SpanKey,
18 pub vals: Option<Vec<Val>>,
19 pub default_val: Option<Val>,
20 pub validation: bool,
21 pub text: Option<String>,
22 pub state: DropdownState,
23 #[cfg_attr(feature = "serde", serde(default = "default_emit_event_for_api"))]
24 pub emit: bool,
25 #[cfg_attr(feature = "serde", serde(default = "default_undo_for_api"))]
26 pub undo: bool,
27 #[cfg_attr(feature = "serde", serde(default = "default_save_selection_for_api"))]
28 pub save_selection: bool,
29 #[cfg_attr(feature = "serde", serde(default = "default_expand_for_api"))]
30 pub expand: bool,
31}
32
33impl Default for DropdownArgs {
34 fn default() -> Self {
35 DropdownArgs {
36 key: SpanKey::None,
37 vals: None,
38 default_val: None,
39 validation: true,
40 text: None,
41 state: DropdownState::Normal,
42 emit: default_emit_event_for_api(),
43 undo: default_undo_for_api(),
44 save_selection: default_save_selection_for_api(),
45 expand: default_expand_for_api(),
46 }
47 }
48}
49
50#[cfg_attr(feature = "tsify", derive(tsify::Tsify))]
52#[cfg_attr(feature = "tsify", tsify(from_wasm_abi))]
53#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
54#[derive(Debug, Clone, PartialEq)]
55pub struct SetDropdownArgs {
56 pub key: SpanKey,
57 pub vals: Option<Vec<Val>>,
58 pub default_val: Option<Option<Val>>,
59 pub validation: Option<bool>,
60 pub text: Option<Option<String>>,
61 pub state: Option<DropdownState>,
62 #[cfg_attr(feature = "serde", serde(default = "default_emit_event_for_api"))]
63 pub emit: bool,
64 #[cfg_attr(feature = "serde", serde(default = "default_undo_for_api"))]
65 pub undo: bool,
66 #[cfg_attr(feature = "serde", serde(default = "default_save_selection_for_api"))]
67 pub save_selection: bool,
68}
69
70impl Default for SetDropdownArgs {
71 fn default() -> Self {
72 SetDropdownArgs {
73 key: SpanKey::None,
74 vals: Some(vec![]),
75 default_val: None,
76 validation: None,
77 text: None,
78 state: None,
79 emit: default_emit_event_for_api(),
80 undo: default_undo_for_api(),
81 save_selection: default_save_selection_for_api(),
82 }
83 }
84}