1/* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * Defines the options of TextPicker. 18 * @since 8 19 */ 20declare interface TextPickerOptions { 21 /** 22 * Specifies the range of the text selector. 23 */ 24 range: string[] | Resource; 25 /** 26 * Value of the current selection. 27 */ 28 value?: string; 29 /** 30 * Current selected subscript. 31 */ 32 selected?: number; 33} 34 35/** 36 * @since 8 37 */ 38interface TextPickerInterface { 39 /** 40 * Defines the TextPicker constructor. 41 * @since 8 42 */ 43 (options?: TextPickerOptions): TextPickerAttribute; 44} 45 46/** 47 * Style the text selector. 48 * @since 8 49 */ 50declare class TextPickerAttribute extends CommonMethod<TextPickerAttribute> { 51 /** 52 * Called when the default height of the selected element is set. 53 * @since 8 54 */ 55 defaultPickerItemHeight(value: number | string): TextPickerAttribute; 56 /** 57 * Called when the pop-up value is returned. 58 * @since 8 59 */ 60 onAccept(callback: (value: string, index: number) => void): TextPickerAttribute; 61 /** 62 * Called when the Cancel button in the pop-up window is clicked. 63 * @since 8 64 */ 65 onCancel(callback: () => void): TextPickerAttribute; 66 /** 67 * Called when the OK button in the pop-up window is clicked. 68 * @since 8 69 */ 70 onChange(callback: (value: string, index: number) => void): TextPickerAttribute; 71} 72 73/** 74 * Defines the struct of TextPickerResult. 75 * @since 8 76 */ 77declare interface TextPickerResult { 78 /** 79 * The currently selected value. 80 * @since 8 81 */ 82 value: string; 83 /** 84 * The subscript of the current selection. 85 * @since 8 86 */ 87 index: number; 88} 89 90/** 91 * Defines the TextPickerDialogOptions for Text Picker Dialog. 92 * @since 8 93 */ 94declare interface TextPickerDialogOptions extends TextPickerOptions { 95 /** 96 * Called when the default height of the selected element is set. 97 * @since 8 98 */ 99 defaultPickerItemHeight?: number | string; 100 /** 101 * Called when the OK button in the dialog is clicked. 102 * @since 8 103 */ 104 onAccept?: (value: TextPickerResult) => void; 105 /** 106 * Called when the Cancel button in the dialog is clicked. 107 * @since 8 108 */ 109 onCancel?: () => void; 110 /** 111 * This event is triggered when a TextPicker text is selected in dialog. 112 * @since 8 113 */ 114 onChange?: (value: TextPickerResult) => void; 115} 116 117/** 118 * Defines TextPickerDialog which uses show method to show TextPicker dialog. 119 * @since 8 120 */ 121declare class TextPickerDialog { 122 /** 123 * Invoking method display. 124 * @since 8 125 */ 126 static show(options?: TextPickerDialogOptions); 127} 128 129/** 130 * Defines TextPicker Component. 131 * @since 8 132 */ 133declare const TextPicker: TextPickerInterface; 134 135/** 136 * Defines TextPicker Component instance. 137 * @since 8 138 */ 139declare const TextPickerInstance: TextPickerAttribute; 140