From d7b3d781a82a3a19fcc9eb7916e247156ab432ee Mon Sep 17 00:00:00 2001 From: Luigi Trabacchin Date: Wed, 14 Oct 2015 15:36:34 +0200 Subject: [PATCH] Typeahead : DisplayKey is now Display --- typeahead/typeahead-tests.ts | 20 ++++++++++---------- typeahead/typeahead.d.ts | 5 ++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/typeahead/typeahead-tests.ts b/typeahead/typeahead-tests.ts index 3864865c9..ec2b2e2f3 100644 --- a/typeahead/typeahead-tests.ts +++ b/typeahead/typeahead-tests.ts @@ -6,7 +6,7 @@ // var substringMatcher = function (strs: any) { - return function findMatches(q: string, syncResults: (x: any) => void) { + return function findMatches(q: string, syncResults: (x: Array) => void) { var matches: Array<{ value: string }> = []; // regex used to determine if a string contains the substring `q` var substrRegex = new RegExp(q, 'i'); @@ -97,7 +97,7 @@ function test_datasets_array() { function with_displayKey_option() { $('#the-basics .typeahead').typeahead(options, [{ - displayKey: 'value', + display: 'value', source: substringMatcher(states) }] ); @@ -114,7 +114,7 @@ function test_datasets_array() { function with_all_options() { $('#the-basics .typeahead').typeahead(options, [{ name: 'states', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) }] @@ -125,13 +125,13 @@ function test_datasets_array() { $('#the-basics .typeahead').typeahead(options, [ { name: 'states', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) }, { name: 'states alternative', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) } @@ -161,7 +161,7 @@ function test_datasets_objects() { function with_displayKey_option() { $('#the-basics .typeahead').typeahead(options, { - displayKey: 'value', + display: 'value', source: substringMatcher(states) } ); @@ -180,7 +180,7 @@ function test_datasets_objects() { $('#the-basics .typeahead').typeahead(options, { name: 'states', - displayKey: 'value', + display: x => x.value, templates: {}, source: substringMatcher(states) } @@ -191,13 +191,13 @@ function test_datasets_objects() { $('#the-basics .typeahead').typeahead(options, { name: 'states', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) }, { name: 'states alternative', - displayKey: 'value', + display: 'value', templates: {}, source: substringMatcher(states) } @@ -291,7 +291,7 @@ function test_dataset_templates() { suggestion: function (context) { return context.name; } - } + }, }); } } diff --git a/typeahead/typeahead.d.ts b/typeahead/typeahead.d.ts index cde3a9277..7ffbe5b50 100644 --- a/typeahead/typeahead.d.ts +++ b/typeahead/typeahead.d.ts @@ -105,7 +105,7 @@ declare module Twitter.Typeahead { * cb can be invoked synchronously or asynchronously. * */ - source: ((query: string, syncResults: (result: any) => void, asyncResults?: (result: any) => void) => void); + source: ((query: string, syncResults: (result: Array) => void, asyncResults?: (result: Array) => void) => void); /** * The name of the dataset. @@ -120,7 +120,7 @@ declare module Twitter.Typeahead { * This will be used when setting the value of the input control after a suggestion is selected. Can be either a key string or a function that transforms a suggestion object into a string. * Defaults to value. */ - displayKey?: string | ((obj: any) => string); + display?: string | ((obj: any) => string); /** * A hash of templates to be used when rendering the dataset. @@ -128,7 +128,6 @@ declare module Twitter.Typeahead { */ templates?: Templates; async?: boolean; - display?: boolean | ((x: any) => boolean); }