1module Components.Select
8import Data.Array as Array
9import Data.Eq.Generic (genericEq)
10import Data.Generic.Rep (class Generic)
11import Data.Maybe (maybe)
13import Effect.Uncurried (mkEffectFn1)
14import NextUI.NextUI as NextUI
15import React.Basic.DOM.Simplified.ToJSX (el)
16import React.Basic.Hooks as React
20 , onSelect :: Option -> Effect Unit
23data Option = All | Code | Package
25derive instance Generic Option _
26instance Eq Option where
29renderOption ∷ Option → String
30renderOption All = "All"
31renderOption Code = "Code"
32renderOption Package = "Package"
34foreign import data Set :: Type -> Type
35foreign import toArray :: Set String -> Array String
37foreign import new_ :: forall item. item -> Set item
39fromKey :: String -> Option
41fromKey "Package" = Package
44mkSelect :: React.Component Props
46 React.component "Select" \{ selected, onSelect } -> React.do
48 $ el NextUI.container { justify: "flex-start" }
49 $ el NextUI.dropdown { solid: true }
50 [ el NextUI.dropdownButton { color: "secondary" } $ renderOption selected
51 , el NextUI.dropdownMenu
52 { disallowEmptySelection: true
55 , selectionMode: "single"
56 , selectedKeys: new_ $ renderOption selected
57 , onSelectionChange: mkEffectFn1 $ toArray >>> Array.head >>> maybe All fromKey >>> onSelect
58 } $ [ All, Code, Package ] <#> option
63 el NextUI.dropdownItem { key: renderOption opt }
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list