UNPKG

2.73 kBTypeScriptView Raw
1import { View } from '../core/view';
2import { Property } from '../core/properties';
3import { EventData } from '../../data/observable';
4import { Color } from '../../color';
5
6/**
7 * Represents a search bar component.
8 */
9export class SearchBar extends View {
10 /**
11 * String value used when hooking to submit event.
12 */
13 public static submitEvent: string;
14
15 /**
16 * String value used when hooking to clear event.
17 */
18 public static clearEvent: string;
19
20 /**
21 * Gets the native [android widget](http://developer.android.com/reference/android/widget/SearchView.html) that represents the user interface for this component. Valid only when running on Android OS.
22 */
23 android: any /* android.widget.SearchView */;
24
25 /**
26 * Gets the native iOS [UISearchBar](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISearchBar_Class/) that represents the user interface for this component. Valid only when running on iOS.
27 */
28 ios: any /* UISearchBar */;
29
30 /**
31 * Gets or sets a search bar text.
32 */
33 text: string;
34
35 /**
36 * Gets or sets the text of the search bar text field hint/placeholder.
37 */
38 hint: string;
39
40 /**
41 * Gets or sets the TextField background color of the SearchBar component.
42 */
43 textFieldBackgroundColor: Color;
44
45 /**
46 * Gets or sets the TextField Hint color of the SearchBar component.
47 */
48 textFieldHintColor: Color;
49
50 /**
51 * A basic method signature to hook an event listener (shortcut alias to the addEventListener method).
52 * @param eventNames - String corresponding to events (e.g. "propertyChange"). Optionally could be used more events separated by `,` (e.g. "propertyChange", "change").
53 * @param callback - Callback function which will be executed when event is raised.
54 * @param thisArg - An optional parameter which will be used as `this` context for callback execution.
55 */
56 on(eventNames: string, callback: (data: EventData) => void, thisArg?: any): void;
57
58 /**
59 * Raised when a search bar search is submitted.
60 */
61 on(event: 'submit', callback: (args: EventData) => void, thisArg?: any): void;
62
63 /**
64 * Raised when a search bar search is closed.
65 */
66 on(event: 'close', callback: (args: EventData) => void, thisArg?: any): void;
67
68 /**
69 * Hides the soft input method, usually a soft keyboard.
70 */
71 dismissSoftInput(): void;
72}
73
74/**
75 * Dependency property used to support binding operations related to search-bar text.
76 */
77export const textProperty: Property<SearchBar, string>;
78export const hintProperty: Property<SearchBar, string>;
79
80/**
81 * Gets or sets the TextField background color of the SearchBar component.
82 */
83export const textFieldBackgroundColorProperty: Property<SearchBar, Color>;
84
85export const textFieldHintColorProperty: Property<SearchBar, Color>;