Skip to content

Commit a20a355

Browse files
committed
fix: resolve MoonBit check warnings
1 parent 96abe37 commit a20a355

16 files changed

Lines changed: 90 additions & 820 deletions

rui/context_menu.mbt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,8 @@ fn context_scope(
454454
point_x : Int,
455455
point_y : Int,
456456
set_open : @cmd.Emit[Bool],
457-
set_active : @cmd.Emit[Int],
458457
toggle_checked : @cmd.Emit[String],
459458
set_radio : @cmd.Emit[(String, String)],
460-
set_submenu : @cmd.Emit[MenuSubmenuChange],
461459
) -> ContextMenuScope {
462460
{
463461
point_x,
@@ -468,13 +466,10 @@ fn context_scope(
468466
trigger_id: id + "-trigger",
469467
model,
470468
counter: Ref(0),
471-
open_command: set_open(true),
472469
close_command: set_open(false),
473470
toggle_command: set_open(!model.open),
474-
set_active,
475471
toggle_checked,
476472
set_radio,
477-
set_submenu,
478473
},
479474
}
480475
}
@@ -656,10 +651,8 @@ pub fn context_menu(
656651
model.point_x,
657652
model.point_y,
658653
emit.map(open => ContextSetOpen(open)),
659-
emit.map(index => ContextSetActive(index)),
660654
emit.map(value => ContextToggleChecked(value)),
661655
emit.map(pair => ContextSetRadio(pair.0, pair.1)),
662-
emit.map(value => ContextSetSubmenu(value)),
663656
)
664657
menu_root_surface(
665658
"context-menu",
@@ -693,8 +686,6 @@ pub fn context_menu(
693686
menu_noop_emit(),
694687
menu_noop_emit(),
695688
menu_noop_emit(),
696-
menu_noop_emit(),
697-
menu_noop_emit(),
698689
)
699690
@rabbita.Val::constant(
700691
menu_root_surface(

rui/dropdown_menu.mbt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@ fn dropdown_scope(
4141
id : String,
4242
model : MenuCoreModel,
4343
set_open : @cmd.Emit[Bool],
44-
set_active : @cmd.Emit[Int],
4544
toggle_checked : @cmd.Emit[String],
4645
set_radio : @cmd.Emit[(String, String)],
47-
set_submenu : @cmd.Emit[MenuSubmenuChange],
4846
) -> DropdownMenuScope {
4947
{
5048
menu: {
@@ -53,13 +51,10 @@ fn dropdown_scope(
5351
trigger_id: id + "-trigger",
5452
model,
5553
counter: Ref(0),
56-
open_command: set_open(true),
5754
close_command: set_open(false),
5855
toggle_command: set_open(!model.open),
59-
set_active,
6056
toggle_checked,
6157
set_radio,
62-
set_submenu,
6358
},
6459
}
6560
}
@@ -200,10 +195,8 @@ pub fn dropdown_menu(
200195
id,
201196
model,
202197
emit.map(open => DropdownSetOpen(open)),
203-
emit.map(index => DropdownSetActive(index)),
204198
emit.map(value => DropdownToggleChecked(value)),
205199
emit.map(pair => DropdownSetRadio(pair.0, pair.1)),
206-
emit.map(value => DropdownSetSubmenu(value)),
207200
)
208201
menu_root_surface(
209202
"dropdown-menu",
@@ -235,8 +228,6 @@ pub fn dropdown_menu(
235228
menu_noop_emit(),
236229
menu_noop_emit(),
237230
menu_noop_emit(),
238-
menu_noop_emit(),
239-
menu_noop_emit(),
240231
)
241232
@rabbita.Val::constant(
242233
menu_root_surface(

rui/interaction.mbt

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -323,61 +323,6 @@ fn ui_dialog_close(id : String) -> @cmd.Cmd {
323323
@cmd.none
324324
}
325325

326-
///|
327-
#cfg(target="js")
328-
fn ui_dialog_request_close(id : String) -> @cmd.Cmd {
329-
@cmd.custom_cmd(kind=@cmd.after_render, _ => {
330-
if @dom.document().get_element_by_id(id).to_option() is Some(element) &&
331-
element.to_html_element() is Some(html_element) &&
332-
html_element.to_html_dialog_element() is Some(dialog) {
333-
dialog.request_close()
334-
}
335-
})
336-
}
337-
338-
///|
339-
#cfg(not(target="js"))
340-
fn ui_dialog_request_close(id : String) -> @cmd.Cmd {
341-
ignore(id)
342-
@cmd.none
343-
}
344-
345-
///|
346-
#cfg(target="js")
347-
fn ui_popover_show(id : String) -> @cmd.Cmd {
348-
@cmd.custom_cmd(kind=@cmd.after_render, _ => {
349-
if @dom.document().get_element_by_id(id).to_option() is Some(element) &&
350-
element.to_html_element() is Some(html_element) {
351-
html_element.show_popover()
352-
}
353-
})
354-
}
355-
356-
///|
357-
#cfg(not(target="js"))
358-
fn ui_popover_show(id : String) -> @cmd.Cmd {
359-
ignore(id)
360-
@cmd.none
361-
}
362-
363-
///|
364-
#cfg(target="js")
365-
fn ui_popover_hide(id : String) -> @cmd.Cmd {
366-
@cmd.custom_cmd(kind=@cmd.after_render, _ => {
367-
if @dom.document().get_element_by_id(id).to_option() is Some(element) &&
368-
element.to_html_element() is Some(html_element) {
369-
html_element.hide_popover()
370-
}
371-
})
372-
}
373-
374-
///|
375-
#cfg(not(target="js"))
376-
fn ui_popover_hide(id : String) -> @cmd.Cmd {
377-
ignore(id)
378-
@cmd.none
379-
}
380-
381326
///|
382327
#cfg(target="js")
383328
fn ui_focus_id(id : String) -> @cmd.Cmd {

rui/menu_internal.mbt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,16 @@ enum MenuSubmenuChange {
1717
} derive(Eq)
1818

1919
///|
20-
struct MenuScope {
20+
priv struct MenuScope {
2121
id : String
2222
content_id : String
2323
trigger_id : String
2424
model : MenuCoreModel
2525
counter : Ref[Int]
26-
open_command : @cmd.Cmd
2726
close_command : @cmd.Cmd
2827
toggle_command : @cmd.Cmd
29-
set_active : @cmd.Emit[Int]
3028
toggle_checked : @cmd.Emit[String]
3129
set_radio : @cmd.Emit[(String, String)]
32-
set_submenu : @cmd.Emit[MenuSubmenuChange]
3330
}
3431

3532
///|
@@ -242,6 +239,7 @@ fn menu_scope_next_index(scope : MenuScope) -> Int {
242239
}
243240

244241
///|
242+
#cfg(not(target="js"))
245243
fn[A] menu_noop_emit() -> @cmd.Emit[A] {
246244
@cmd.Emit(_ => @cmd.none)
247245
}

rui/menubar.mbt

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@ struct MenubarScope {
1212
model : MenubarModel
1313
counter : Ref[Int]
1414
focus_claimed : Ref[Bool]
15-
activate : @cmd.Emit[(String, Int)]
1615
toggle : @cmd.Emit[(String, Int)]
1716
close_command : @cmd.Cmd
18-
set_active : @cmd.Emit[Int]
1917
toggle_checked : @cmd.Emit[String]
2018
set_radio : @cmd.Emit[(String, String)]
21-
set_submenu : @cmd.Emit[MenuSubmenuChange]
2219
}
2320

2421
///|
@@ -570,26 +567,20 @@ fn menubar_trigger_id(id : String, index : Int) -> String {
570567
fn menubar_scope(
571568
id : String,
572569
model : MenubarModel,
573-
activate : @cmd.Emit[(String, Int)],
574570
toggle : @cmd.Emit[(String, Int)],
575571
close_command : @cmd.Cmd,
576-
set_active : @cmd.Emit[Int],
577572
toggle_checked : @cmd.Emit[String],
578573
set_radio : @cmd.Emit[(String, String)],
579-
set_submenu : @cmd.Emit[MenuSubmenuChange],
580574
) -> MenubarScope {
581575
{
582576
id,
583577
model,
584578
counter: Ref(0),
585579
focus_claimed: Ref(false),
586-
activate,
587580
toggle,
588581
close_command,
589-
set_active,
590582
toggle_checked,
591583
set_radio,
592-
set_submenu,
593584
}
594585
}
595586

@@ -686,7 +677,6 @@ pub fn menubar(
686677
(current, @cmd.none)
687678
} else {
688679
let next = {
689-
..current,
690680
active_value: Some(value),
691681
active_index: index,
692682
focus_index: index,
@@ -706,7 +696,6 @@ pub fn menubar(
706696
}
707697
MenubarSwitch(value, index) => {
708698
let next = {
709-
..current,
710699
active_value: Some(value),
711700
active_index: index,
712701
focus_index: index,
@@ -736,7 +725,6 @@ pub fn menubar(
736725
} else if current.active_value == Some(value) {
737726
(
738727
{
739-
..current,
740728
active_value: None,
741729
active_index: -1,
742730
focus_index: index,
@@ -754,7 +742,6 @@ pub fn menubar(
754742
)
755743
} else {
756744
let next = {
757-
..current,
758745
active_value: Some(value),
759746
active_index: index,
760747
focus_index: index,
@@ -780,7 +767,6 @@ pub fn menubar(
780767
if current.active_value is Some(_) {
781768
(
782769
{
783-
..current,
784770
active_value: None,
785771
active_index: -1,
786772
focus_index: current.active_index,
@@ -811,7 +797,6 @@ pub fn menubar(
811797
} else {
812798
(
813799
{
814-
..current,
815800
active_value: Some(value),
816801
active_index: index,
817802
focus_index: index,
@@ -823,7 +808,6 @@ pub fn menubar(
823808
} else if current.active_value == Some(value) {
824809
(
825810
{
826-
..current,
827811
active_value: None,
828812
active_index: -1,
829813
focus_index: index,
@@ -895,13 +879,10 @@ pub fn menubar(
895879
let scope = menubar_scope(
896880
id,
897881
model,
898-
emit.map(pair => MenubarActivate(pair.0, pair.1)),
899882
emit.map(pair => MenubarToggle(pair.0, pair.1)),
900883
emit(MenubarClose),
901-
emit.map(index => MenubarSetActive(index)),
902884
emit.map(value => MenubarToggleChecked(value)),
903885
emit.map(pair => MenubarSetRadio(pair.0, pair.1)),
904-
emit.map(value => MenubarSetSubmenu(value)),
905886
)
906887
let element_attrs = menu_state_attrs(
907888
attrs,
@@ -962,12 +943,9 @@ pub fn menubar(
962943
id,
963944
model,
964945
menu_noop_emit(),
965-
menu_noop_emit(),
966946
@cmd.none,
967947
menu_noop_emit(),
968948
menu_noop_emit(),
969-
menu_noop_emit(),
970-
menu_noop_emit(),
971949
)
972950
let element_attrs = menu_state_attrs(
973951
attrs,
@@ -1048,13 +1026,10 @@ pub fn[C : @html.IsChildren] menubar_menu(
10481026
trigger_id: menubar_trigger_id(scope.id, index),
10491027
model: menu_model,
10501028
counter: Ref(0),
1051-
open_command: (scope.activate)((value, index)),
10521029
close_command: scope.close_command,
10531030
toggle_command: (scope.toggle)((value, index)),
1054-
set_active: scope.set_active,
10551031
toggle_checked: scope.toggle_checked,
10561032
set_radio: scope.set_radio,
1057-
set_submenu: scope.set_submenu,
10581033
}
10591034
@html.div(
10601035
style=ui_styles([UiBoxSizing, "display:contents"], style),

rui/message_scroller.mbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ pub(all) enum MessageScrollDirection {
88
priv struct MessageScrollerPosition {
99
at_start : Bool
1010
at_end : Bool
11-
} derive(Debug, Eq)
11+
} derive(Eq)
1212

1313
///|
1414
priv enum MessageScrollerMsg {
1515
SetScrollerPosition(Bool, Bool)
16-
} derive(Debug)
16+
}
1717

1818
///|
1919
/// Opaque render scope owned by `message_scroller`.

rui/navigation_menu.mbt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ struct NavigationMenuScope {
1414
viewport : Bool
1515
contents : Ref[Array[NavigationMenuContentEntry]]
1616
viewport_rendered : Ref[Bool]
17-
activate : @cmd.Emit[(String, Int)]
1817
toggle : @cmd.Emit[(String, Int)]
19-
close_command : @cmd.Cmd
2018
}
2119

2220
///|
@@ -30,9 +28,7 @@ struct NavigationMenuItemScope {
3028
active_value_set : Bool
3129
viewport : Bool
3230
contents : Ref[Array[NavigationMenuContentEntry]]
33-
activate_command : @cmd.Cmd
3431
toggle_command : @cmd.Cmd
35-
close_command : @cmd.Cmd
3632
}
3733

3834
///|
@@ -726,9 +722,7 @@ pub fn navigation_menu(
726722
viewport,
727723
contents: Ref([]),
728724
viewport_rendered: Ref(false),
729-
activate: emit.map(pair => NavigationActivate(pair.0, pair.1)),
730725
toggle: emit.map(pair => NavigationToggle(pair.0, pair.1)),
731-
close_command: emit(NavigationClose),
732726
}
733727
let element_attrs = menu_state_attrs(
734728
attrs,
@@ -798,9 +792,7 @@ pub fn navigation_menu(
798792
viewport,
799793
contents: Ref([]),
800794
viewport_rendered: Ref(false),
801-
activate: menu_noop_emit(),
802795
toggle: menu_noop_emit(),
803-
close_command: @cmd.none,
804796
}
805797
let element_attrs = menu_state_attrs(
806798
attrs,
@@ -902,9 +894,7 @@ pub fn[C : @html.IsChildren] navigation_menu_item(
902894
active_value_set: scope.model.value is Some(_),
903895
viewport: scope.viewport,
904896
contents: scope.contents,
905-
activate_command: (scope.activate)((value, index)),
906897
toggle_command: (scope.toggle)((value, index)),
907-
close_command: scope.close_command,
908898
}
909899
@html.li(
910900
style=ui_styles([UiBoxSizing, NavigationMenuItemStyle], style),

rui/pkg.generated.mbti

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,8 +1072,6 @@ type MenuCoreModel derive(Eq)
10721072

10731073
type MenuIndicatorPlacement derive(Eq)
10741074

1075-
type MenuScope
1076-
10771075
type MenuSubmenuChange derive(Eq)
10781076

10791077
type MenubarMenuScope

0 commit comments

Comments
 (0)