Remove SProxy reference
This commit is contained in:
parent
27befa13f2
commit
c5b397497a
4 changed files with 54 additions and 44 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,6 +6,7 @@ node_modules
|
|||
# Generated files
|
||||
.psci
|
||||
.psc-ide-port
|
||||
.spago
|
||||
output
|
||||
package-lock.json
|
||||
generated-docs
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
# Select
|
||||
|
||||
> [!NOTE]
|
||||
> This fork makes this package work with newer PureScript versions, by removing a stale `SProxy` import. This fork is here for personal use only. Use at your own risk.
|
||||
|
||||
[](https://circleci.com/gh/citizennet/purescript-halogen-select/tree/master)
|
||||
[](http://github.com/thomashoneyman)
|
||||
|
||||
|
@ -43,7 +46,6 @@ Instantiating a typeahead shouldn't require a 50-field configuration record. We
|
|||
4. Be accessible (Upcoming)
|
||||
ARIA props and other features necessary for accessibility online should be handled properly without any setup.
|
||||
|
||||
|
||||
# Rendering
|
||||
|
||||
The primary design decision made in this project vs. other typeaheads is offloading HTML rendering to the user. Rather than render an input field ourselves and provide a CSS class for styling, we allow you to write your own HTML and augment your properties with the behaviors we need for the select to function.
|
||||
|
@ -61,10 +63,8 @@ For example, you can make your container compatible with the component with the
|
|||
]
|
||||
```
|
||||
|
||||
|
||||
> Warning: If you provide any of the same events that we use for our behaviors, only yours will trigger, preventing that behavior from being applied. E.g., if you provide your own `HE.onValueInput` event on the element you're applying `setInputProps` to, you will end up overriding our search functionality for that input.
|
||||
|
||||
|
||||
## Inspiration & Thanks
|
||||
|
||||
This project drew inspiration from the approach taken by [paypal/downshift](https://github.com/paypal/downshift). Special thanks to [Nathan Faubion](https://github.com/natefaubion) and [Nicholas Scheel](https://github.com/MonoidMusician) for their help.
|
||||
|
|
9
spago.yaml
Normal file
9
spago.yaml
Normal file
|
@ -0,0 +1,9 @@
|
|||
package:
|
||||
name: halogen-select
|
||||
dependencies:
|
||||
- halogen
|
||||
- record
|
||||
workspace:
|
||||
packageSet:
|
||||
registry: 64.10.0
|
||||
extraPackages: {}
|
|
@ -10,7 +10,6 @@ import Prelude
|
|||
import Control.Monad.Free (liftF)
|
||||
import Data.Const (Const)
|
||||
import Data.Maybe (Maybe(..), fromMaybe)
|
||||
import Data.Symbol (SProxy(..))
|
||||
import Data.Time.Duration (Milliseconds)
|
||||
import Data.Traversable (for_, traverse, traverse_)
|
||||
import Effect.Aff (Fiber, delay, error, forkAff, killFiber)
|
||||
|
@ -24,6 +23,7 @@ import Halogen.HTML as HH
|
|||
import Halogen.Query.ChildQuery (ChildQueryBox)
|
||||
import Prim.Row as Row
|
||||
import Record.Builder as Builder
|
||||
import Type.Prelude (Proxy(..))
|
||||
import Unsafe.Coerce (unsafeCoerce)
|
||||
import Web.Event.Event (preventDefault)
|
||||
import Web.HTML.HTMLElement as HTMLElement
|
||||
|
@ -73,6 +73,7 @@ type Slot' = Slot (Const Void) () Void
|
|||
-- | Represents a way to navigate on `Highlight` events: to the previous
|
||||
-- | item, next item, or the item at a particular index.
|
||||
data Target = Prev | Next | Index Int
|
||||
|
||||
derive instance eqTarget :: Eq Target
|
||||
|
||||
-- | Represents whether the component should display the item container. You
|
||||
|
@ -82,6 +83,7 @@ derive instance eqTarget :: Eq Target
|
|||
-- | render state = if state.visibility == On then renderAll else renderInputOnly
|
||||
-- | ```
|
||||
data Visibility = Off | On
|
||||
|
||||
derive instance eqVisibility :: Eq Visibility
|
||||
derive instance ordVisibility :: Ord Visibility
|
||||
|
||||
|
@ -126,39 +128,37 @@ type HalogenM st action slots msg m a =
|
|||
|
||||
type Spec st query action slots input msg m =
|
||||
{ -- usual Halogen component spec
|
||||
render
|
||||
:: State st
|
||||
render ::
|
||||
State st
|
||||
-> ComponentHTML action slots m
|
||||
|
||||
-- handle additional actions provided to the component
|
||||
, handleAction
|
||||
:: action
|
||||
, handleAction ::
|
||||
action
|
||||
-> HalogenM st action slots msg m Unit
|
||||
|
||||
-- handle additional queries provided to the component
|
||||
, handleQuery
|
||||
:: forall a
|
||||
, handleQuery ::
|
||||
forall a
|
||||
. query a
|
||||
-> HalogenM st action slots msg m (Maybe a)
|
||||
|
||||
-- handle messages emitted by the component; provide H.raise to simply
|
||||
-- raise the Select messages to the parent.
|
||||
, handleEvent
|
||||
:: Event
|
||||
, handleEvent ::
|
||||
Event
|
||||
-> HalogenM st action slots msg m Unit
|
||||
|
||||
-- optionally handle input on parent re-renders
|
||||
, receive
|
||||
:: input
|
||||
, receive ::
|
||||
input
|
||||
-> Maybe action
|
||||
|
||||
-- perform some action when the component initializes.
|
||||
, initialize
|
||||
:: Maybe action
|
||||
, initialize :: Maybe action
|
||||
|
||||
-- optionally perform some action on initialization. disabled by default.
|
||||
, finalize
|
||||
:: Maybe action
|
||||
, finalize :: Maybe action
|
||||
}
|
||||
|
||||
type Spec' st input m = Spec st (Const Void) Void () input Void m
|
||||
|
@ -201,11 +201,11 @@ component mkInput spec = H.mkComponent
|
|||
initialState = Builder.build pipeline
|
||||
where
|
||||
pipeline =
|
||||
Builder.modify (SProxy :: _ "search") (fromMaybe "")
|
||||
>>> Builder.modify (SProxy :: _ "debounceTime") (fromMaybe mempty)
|
||||
>>> Builder.insert (SProxy :: _ "debounceRef") Nothing
|
||||
>>> Builder.insert (SProxy :: _ "visibility") Off
|
||||
>>> Builder.insert (SProxy :: _ "highlightedIndex") Nothing
|
||||
Builder.modify (Proxy :: _ "search") (fromMaybe "")
|
||||
>>> Builder.modify (Proxy :: _ "debounceTime") (fromMaybe mempty)
|
||||
>>> Builder.insert (Proxy :: _ "debounceRef") Nothing
|
||||
>>> Builder.insert (Proxy :: _ "visibility") Off
|
||||
>>> Builder.insert (Proxy :: _ "highlightedIndex") Nothing
|
||||
|
||||
handleQuery
|
||||
:: forall st query action slots msg m a
|
||||
|
@ -319,7 +319,7 @@ handleAction handleAction' handleEvent = case _ of
|
|||
preventIt
|
||||
for_ st.highlightedIndex \ix ->
|
||||
handle $ Select (Index ix) Nothing
|
||||
otherKey -> pure unit
|
||||
_ -> pure unit
|
||||
|
||||
PreventClick ev ->
|
||||
H.liftEffect $ preventDefault $ ME.toEvent ev
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue