Skip to content

Instantly share code, notes, and snippets.

@MawiraIke
Last active May 20, 2021 09:18
Show Gist options
  • Save MawiraIke/ce98ca114d04959aa2ec847809365588 to your computer and use it in GitHub Desktop.
Save MawiraIke/ce98ca114d04959aa2ec847809365588 to your computer and use it in GitHub Desktop.
@startuml
hide empty description
state disabledchoice <<choice>>
state disabled
state enabled{
state freetextchoice <<choice>>
state default_drop {
default_drop: This is a non 'free-text' dropdown i.e, 'free-text' is false
state no_focus
state open {
open: THe dropdown is open
state filter_choice <<choice>>
state filtering as "filter-box?"{
filtering: The filter box is displaying
filtering: This is true when the argument 'filter-box?' is true
state blank_fb as "blank"{
blank_fb: The filter box is empty. \nA placeholder will be shown if 'filter-placeholder' is true
state blank_fb_choice <<choice>>
state placeholder_fb as "placeholder"
state blank_fb2 as "blank"
[*] -> blank_fb_choice
blank_fb_choice -> placeholder_fb : [filter-placeholder = true]
blank_fb_choice -> blank_fb2 : [filter-placeholder = false]
}
state text_fb as "filtering"{
text_fb: The filter box is not empty, the user has already started typing
}
[*] -> blank_fb
blank_fb -> text_fb : press-key
text_fb -> blank_fb : clear filter box
}
state no_filtering as "no_filter_box"
[*] -> filter_choice
filter_choice -> filtering : [filter-box? = true]
filter_choice --> no_filtering : [filter-box? = false]
--
state keybd_highlight{
keybd_highlight: A choice is currently highlighted.
keybd_highlight: This happens when the selected choice is in the list of currently displayed choices
keybd_highlight: When up or down arrow are pressed, the previous and next choices are highlighted
}
state no_highlight{
no_highlight: No option is highlighted
}
state keybd_highlight_choice <<choice>>
[*] -> keybd_highlight_choice
keybd_highlight_choice -> no_highlight : [choices list is empty || \n selected-choice = false || \n (selected-choice = true && \n selected-choice not in choices) ]
keybd_highlight_choice --> keybd_highlight : [selected-choice = true && \n choices list is not empty && \n selected-choice in choices]
no_highlight --> keybd_highlight : press-up \n [choices list not empty]
no_highlight --> keybd_highlight : press-down \n [choices list not empty]
no_highlight --> keybd_highlight : press-home \n [choices list not empty]
no_highlight --> keybd_highlight : press-end \n [choices list not empty]
no_highlight --> keybd_highlight : press-page-up \n [choices list not empty]
--
state mouse_highlight{
mouse_highlight: A choice which is directly below the mouse cursor is currently highlighted
mouse_highlight: Moving the mouse cursor to another choice highlights it.
mouse_highlight: When the cursor is dragged out of the dropdown choices, no option is highlighted
}
state no_mouse_highlight{
no_mouse_highlight: NO choice is currently selected
}
[*] -> no_mouse_highlight
no_mouse_highlight --> mouse_highlight : on-mouse-over [choices list not empty]
mouse_highlight --> no_mouse_highlight : on-mouse-out
--
state no_choices{
no_choices: No choices are displayed on the dropdown
no_choices: This can happen when the filter text does not match to any choice.
}
state choices{
choices: The dropdown is currently displaying choices
}
state choices_choice <<choice>>
[*] -> choices_choice
choices_choice --> choices : [choices list not empty]
choices_choice -> no_choices : [empty choices list]
}
state focused
state just_dropped_choice <<choice>>
[*] -> just_dropped_choice
just_dropped_choice -> no_focus : [just-drop? = false]
just_dropped_choice --> open : [just-drop? = true]
no_focus --> open : on-mouse-click
open --> no_focus: on-mouse-focus-lost [just-drop? = false]
open --> no_focus: press-escape [just-drop? = false]
open --> focused : on-mouse-click [just-drop? = false]
focused -> open : on-mouse-click
focused -> open : press-up
focused -> open : press-down
focused -> open : press-end
focused -> open : press-page-up
focused -> open : press-page-down
focused -> open : press-enter[enter-drop? = true]
focused -> focused : press-home
focused -> focused : press-escape[cancelable? = true]
focused -down-> no_focus : on-mouse-focus-lost
--
state show_tooltip
state hide_tooltip
[*] -> hide_tooltip
hide_tooltip -> show_tooltip : [on-mouse-over && tooltip = true]
show_tooltip -> hide_tooltip : [on-mouse-out]
}
'Free text state
state free_text{
state idle as "no_focus?"
state typing as "focused?"
[*] -> idle
idle -> typing : on-mouse-click
typing -> idle : on-mouse-focus-lost
typing -> typing : press-key
--
state text_open as "open?"
state text_closed as "closed?"
[*] -> text_closed
text_closed -> text_open : click dropdown
text_open -> text_closed : click dropdown
text_open -> text_closed : press-escape
}
[*] -> freetextchoice
freetextchoice -> free_text : [free-text? = true]
freetextchoice --> default_drop : [free-text? = false]
||
state freetextselectchoice <<choice>>
state blank_ft as "blank?" {
blank_ft: No choice is selected, \nthe dropdown is displaying the placeholder \nif it exists.
state blankplaceholderchoice <<choice>>
state blank_placeholder_ft as "blank"
state text_placeholder_ft as "selected"
[*] --> blankplaceholderchoice
blankplaceholderchoice --> blank_placeholder_ft : [placeholder is nil]
blankplaceholderchoice --> text_placeholder_ft : [placeholder not nil]
}
state selected_ft as "selected-choice?"
[*] --> freetextselectchoice
freetextselectchoice --> blank_ft : [selected-choice \n = false]
freetextselectchoice --> selected_ft : [selected-choice \n =true]
}
[*] --> disabledchoice
disabledchoice -> disabled : [disabled? = true]
disabledchoice --> enabled : [disabled? = false]
@enduml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment