This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Smart filter library for use with autocomplete.
version 1.0.5
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.5
Committed At 2018-02-18 18:24:44 UTC
elm-lang/html 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/core 5.0.0 <= v < 6.0.0 5.1.1

Modules

README

elm-sifter

Overview

elm-sifter is a library for contextually searching and sorting arrays of Elm records. The user supplies a configuration that describes which fields to search and some search rules and sifter returns a filtered list of records sorted by most relevant. This library is specifically designed for auto-complete and is inspired by brianreavis/sifter.js.

Demo

You can see a working demo of this library working with real city/state data at: http://elm-sifter-demo.s3-website-us-east-1.amazonaws.com/

Usage

type alias Place =
    { city : String
    , stateAbbrev : String
    , state : String
    }

config : Sifter.Config Place
config =
    { extractors = [ .city, .stateAbbrev, .state ]
    , limit = 15
    , sort = Nothing
    , filter = True
    , conjunction = Sifter.Or
    , respectWordBoundaries = False
    }

data =
    [
      { city = "Baltimore", stateAbbrev = "MD", state = "Maryland"}
    , { city = "Boston", stateAbbrev = "MA", state = "Massachusetts"}
    , { city = "Chicago", stateAbbrev = "IL", state = "Illinois"}
    ]


sifter config "b" data ==
    [
      { city = "Baltimore", stateAbbrev = "MD", state = "Maryland"}
    , { city = "Boston", stateAbbrev = "MA", state = "Massachusetts"}
    ]

sifter config "bos" data ==
    [{ city = "Boston", stateAbbrev = "MA", state = "Massachusetts"}]