@@ -5,6 +5,14 @@ export function matchStateToTerm(state, value) {
55 )
66}
77
8+ export function matchStateToTermWithHeaders ( state , value ) {
9+ return (
10+ state . header ||
11+ state . name . toLowerCase ( ) . indexOf ( value . toLowerCase ( ) ) !== - 1 ||
12+ state . abbr . toLowerCase ( ) . indexOf ( value . toLowerCase ( ) ) !== - 1
13+ )
14+ }
15+
816/**
917 * An example of how to implement a relevancy-based sorting method. States are
1018 * sorted based on the location of the match - For example, a search for "or"
@@ -32,6 +40,14 @@ export function fakeRequest(value, cb) {
3240 )
3341}
3442
43+
44+ export function fakeCategorizedRequest ( value , cb ) {
45+ setTimeout ( cb , 500 , value ?
46+ getCategorizedStates ( ) . filter ( state => matchStateToTermWithHeaders ( state , value ) ) :
47+ getCategorizedStates ( )
48+ )
49+ }
50+
3551export function getStates ( ) {
3652 return [
3753 { abbr : 'AL' , name : 'Alabama' } ,
@@ -87,4 +103,64 @@ export function getStates() {
87103 ]
88104}
89105
106+ export function getCategorizedStates ( ) {
107+ return [
108+ { header : 'West' } ,
109+ { abbr : 'AZ' , name : 'Arizona' } ,
110+ { abbr : 'CA' , name : 'California' } ,
111+ { abbr : 'CO' , name : 'Colorado' } ,
112+ { abbr : 'ID' , name : 'Idaho' } ,
113+ { abbr : 'MT' , name : 'Montana' } ,
114+ { abbr : 'NV' , name : 'Nevada' } ,
115+ { abbr : 'NM' , name : 'New Mexico' } ,
116+ { abbr : 'OK' , name : 'Oklahoma' } ,
117+ { abbr : 'OR' , name : 'Oregon' } ,
118+ { abbr : 'TX' , name : 'Texas' } ,
119+ { abbr : 'UT' , name : 'Utah' } ,
120+ { abbr : 'WA' , name : 'Washington' } ,
121+ { abbr : 'WY' , name : 'Wyoming' } ,
122+ { header : 'Southeast' } ,
123+ { abbr : 'AL' , name : 'Alabama' } ,
124+ { abbr : 'AR' , name : 'Arkansas' } ,
125+ { abbr : 'FL' , name : 'Florida' } ,
126+ { abbr : 'GA' , name : 'Georgia' } ,
127+ { abbr : 'KY' , name : 'Kentucky' } ,
128+ { abbr : 'LA' , name : 'Louisiana' } ,
129+ { abbr : 'MS' , name : 'Mississippi' } ,
130+ { abbr : 'NC' , name : 'North Carolina' } ,
131+ { abbr : 'SC' , name : 'South Carolina' } ,
132+ { abbr : 'TN' , name : 'Tennessee' } ,
133+ { abbr : 'VA' , name : 'Virginia' } ,
134+ { abbr : 'WV' , name : 'West Virginia' } ,
135+ { header : 'Midwest' } ,
136+ { abbr : 'IL' , name : 'Illinois' } ,
137+ { abbr : 'IN' , name : 'Indiana' } ,
138+ { abbr : 'IA' , name : 'Iowa' } ,
139+ { abbr : 'KS' , name : 'Kansas' } ,
140+ { abbr : 'MI' , name : 'Michigan' } ,
141+ { abbr : 'MN' , name : 'Minnesota' } ,
142+ { abbr : 'MO' , name : 'Missouri' } ,
143+ { abbr : 'NE' , name : 'Nebraska' } ,
144+ { abbr : 'OH' , name : 'Ohio' } ,
145+ { abbr : 'ND' , name : 'North Dakota' } ,
146+ { abbr : 'SD' , name : 'South Dakota' } ,
147+ { abbr : 'WI' , name : 'Wisconsin' } ,
148+ { header : 'Northeast' } ,
149+ { abbr : 'CT' , name : 'Connecticut' } ,
150+ { abbr : 'DE' , name : 'Delaware' } ,
151+ { abbr : 'ME' , name : 'Maine' } ,
152+ { abbr : 'MD' , name : 'Maryland' } ,
153+ { abbr : 'MA' , name : 'Massachusetts' } ,
154+ { abbr : 'NH' , name : 'New Hampshire' } ,
155+ { abbr : 'NJ' , name : 'New Jersey' } ,
156+ { abbr : 'NY' , name : 'New York' } ,
157+ { abbr : 'PA' , name : 'Pennsylvania' } ,
158+ { abbr : 'RI' , name : 'Rhode Island' } ,
159+ { abbr : 'VT' , name : 'Vermont' } ,
160+ { header :'Pacific' } ,
161+ { abbr : 'AK' , name : 'Alaska' } ,
162+ { abbr : 'HI' , name : 'Hawaii' } ,
163+ ]
164+ }
165+
90166
0 commit comments