1/* 2 * Copyright (c) 2021-2023 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 * Define the contents of each selector item. 18 * 19 * @interface TextPickerRangeContent 20 * @syscap SystemCapability.ArkUI.ArkUI.Full 21 * @crossplatform 22 * @since 10 23 */ 24declare interface TextPickerRangeContent { 25 /** 26 * Specifies the icon content. 27 * 28 * @type { string | Resource } 29 * @syscap SystemCapability.ArkUI.ArkUI.Full 30 * @crossplatform 31 * @since 10 32 */ 33 icon: string | Resource; 34 35 /** 36 * Specifies the text content. 37 * 38 * @type { ?(string | Resource) } 39 * @syscap SystemCapability.ArkUI.ArkUI.Full 40 * @crossplatform 41 * @since 10 42 */ 43 text?: string | Resource; 44} 45 46/** 47 * Define the contents of text cascade picker. 48 * 49 * @interface TextCascadePickerRangeContent 50 * @syscap SystemCapability.ArkUI.ArkUI.Full 51 * @since 10 52 */ 53declare interface TextCascadePickerRangeContent { 54 /** 55 * Specifies the text content. 56 * 57 * @type { string | Resource } 58 * @syscap SystemCapability.ArkUI.ArkUI.Full 59 * @since 10 60 */ 61 text: string | Resource; 62 63 /** 64 * Defines the text cascade picker children. 65 * 66 * @type { ?TextCascadePickerRangeContent[] } 67 * @syscap SystemCapability.ArkUI.ArkUI.Full 68 * @since 10 69 */ 70 children?: TextCascadePickerRangeContent[]; 71} 72 73/** 74 * Defines the options of TextPicker. 75 * 76 * @interface TextPickerOptions 77 * @syscap SystemCapability.ArkUI.ArkUI.Full 78 * @since 8 79 */ 80/** 81 * Defines the options of TextPicker. 82 * 83 * @interface TextPickerOptions 84 * @syscap SystemCapability.ArkUI.ArkUI.Full 85 * @crossplatform 86 * @since 10 87 */ 88declare interface TextPickerOptions { 89 /** 90 * Specifies the range of the text selector. 91 * 92 * @type {string[] | string[][] | Resource | TextPickerRangeContent[] | TextCascadePickerRangeContent[]} 93 * @syscap SystemCapability.ArkUI.ArkUI.Full 94 * @since 8 95 */ 96 /** 97 * Specifies the range of the selector. 98 * Support the display of pictures, text and pictures plus text, or multi column plain text. 99 * 100 * @type {string[] | string[][] | Resource | TextPickerRangeContent[] | TextCascadePickerRangeContent[]} 101 * @syscap SystemCapability.ArkUI.ArkUI.Full 102 * @crossplatform 103 * @since 10 104 */ 105 range: string[] | string[][] | Resource | TextPickerRangeContent[] | TextCascadePickerRangeContent[]; 106 107 /** 108 * Value of the current selection. 109 * 110 * @type { ?(string | string[]) } 111 * @syscap SystemCapability.ArkUI.ArkUI.Full 112 * @since 8 113 */ 114 /** 115 * Value of the current selection. 116 * Only valid when only text is displayed. 117 * 118 * @type { ?(string | string[]) } 119 * @syscap SystemCapability.ArkUI.ArkUI.Full 120 * @crossplatform 121 * @since 10 122 */ 123 value?: string | string[]; 124 125 /** 126 * Current selected subscript. 127 * 128 * @type { ?(number | number[]) } 129 * @syscap SystemCapability.ArkUI.ArkUI.Full 130 * @since 8 131 */ 132 /** 133 * Current selected subscript. 134 * 135 * @type { ?(number | number[]) } 136 * @syscap SystemCapability.ArkUI.ArkUI.Full 137 * @crossplatform 138 * @since 10 139 */ 140 selected?: number | number[]; 141} 142 143/** 144 * TextPickerInterface 145 * 146 * @interface TextPickerInterface 147 * @syscap SystemCapability.ArkUI.ArkUI.Full 148 * @since 8 149 */ 150/** 151 * TextPickerInterface 152 * 153 * @interface TextPickerInterface 154 * @syscap SystemCapability.ArkUI.ArkUI.Full 155 * @crossplatform 156 * @since 10 157 */ 158interface TextPickerInterface { 159 /** 160 * Defines the TextPicker constructor. 161 * 162 * @param { TextPickerOptions } options 163 * @returns { TextPickerAttribute } 164 * @syscap SystemCapability.ArkUI.ArkUI.Full 165 * @since 8 166 */ 167 /** 168 * Defines the TextPicker constructor. 169 * 170 * @param { TextPickerOptions } options 171 * @returns { TextPickerAttribute } 172 * @syscap SystemCapability.ArkUI.ArkUI.Full 173 * @crossplatform 174 * @since 10 175 */ 176 (options?: TextPickerOptions): TextPickerAttribute; 177} 178 179/** 180 * Style the text selector. 181 * 182 * @extends CommonMethod 183 * @syscap SystemCapability.ArkUI.ArkUI.Full 184 * @since 8 185 */ 186/** 187 * Style the text selector. 188 * 189 * @extends CommonMethod 190 * @syscap SystemCapability.ArkUI.ArkUI.Full 191 * @crossplatform 192 * @since 10 193 */ 194declare class TextPickerAttribute extends CommonMethod<TextPickerAttribute> { 195 /** 196 * Called when the default height of the selected element is set. 197 * 198 * @param { number | string } value 199 * @returns { TextPickerAttribute } 200 * @syscap SystemCapability.ArkUI.ArkUI.Full 201 * @since 8 202 */ 203 /** 204 * Called when the default height of the selected element is set. 205 * 206 * @param { number | string } value 207 * @returns { TextPickerAttribute } 208 * @syscap SystemCapability.ArkUI.ArkUI.Full 209 * @crossplatform 210 * @since 10 211 */ 212 defaultPickerItemHeight(value: number | string): TextPickerAttribute; 213 214 /** 215 * Can scroll loop if true is set, on the contrary it can not. 216 * 217 * @param { boolean } value 218 * @returns { TextPickerAttribute } 219 * @syscap SystemCapability.ArkUI.ArkUI.Full 220 * @since 10 221 */ 222 canLoop(value: boolean): TextPickerAttribute; 223 224 /** 225 * Sets the text style of disappearing items 226 * 227 * @param { PickerTextStyle } value - indicates the text style of disappearing items. 228 * @returns { TextPickerAttribute } 229 * @syscap SystemCapability.ArkUI.ArkUI.Full 230 * @crossplatform 231 * @since 10 232 */ 233 disappearTextStyle(value: PickerTextStyle): TextPickerAttribute; 234 235 /** 236 * Sets the text style of normal items 237 * 238 * @param { PickerTextStyle } value - indicates the text style of normal items. 239 * @returns { TextPickerAttribute } 240 * @syscap SystemCapability.ArkUI.ArkUI.Full 241 * @crossplatform 242 * @since 10 243 */ 244 textStyle(value: PickerTextStyle): TextPickerAttribute; 245 246 /** 247 * Sets the text style of selected items 248 * 249 * @param { PickerTextStyle } value - indicates the text style of selected items. 250 * @returns { TextPickerAttribute } 251 * @syscap SystemCapability.ArkUI.ArkUI.Full 252 * @crossplatform 253 * @since 10 254 */ 255 selectedTextStyle(value: PickerTextStyle): TextPickerAttribute; 256 257 /** 258 * Called when the pop-up value is returned. 259 * 260 * @param { function } callback 261 * @returns { TextPickerAttribute } 262 * @syscap SystemCapability.ArkUI.ArkUI.Full 263 * @since 8 264 * @deprecated since 10 265 */ 266 onAccept(callback: (value: string, index: number) => void): TextPickerAttribute; 267 268 /** 269 * Called when the Cancel button in the pop-up window is clicked. 270 * 271 * @param { function } callback 272 * @returns { TextPickerAttribute } 273 * @syscap SystemCapability.ArkUI.ArkUI.Full 274 * @since 8 275 * @deprecated since 10 276 */ 277 onCancel(callback: () => void): TextPickerAttribute; 278 279 /** 280 * Called when the OK button in the pop-up window is clicked. 281 * 282 * @param { function } callback - the callback of onChange. 283 * @returns { TextPickerAttribute } 284 * @syscap SystemCapability.ArkUI.ArkUI.Full 285 * @since 8 286 */ 287 /** 288 * This event is triggered when a TextPicker item is selected. 289 * Only valid when only text is displayed. When picture or picture plus text is displayed, the value is "". 290 * 291 * @param { function } callback - the callback of onChange. 292 * @returns { TextPickerAttribute } 293 * @syscap SystemCapability.ArkUI.ArkUI.Full 294 * @crossplatform 295 * @since 10 296 */ 297 onChange(callback: (value: string | string[], index: number | number[]) => void): TextPickerAttribute; 298 299 /** 300 * Set the selected indices. 301 * The array size is the total number of columns. 302 * 303 * @param { number | number[] } value - the selected indices. 304 * @returns { TextPickerAttribute } 305 * @syscap SystemCapability.ArkUI.ArkUI.Full 306 * @crossplatform 307 * @since 10 308 */ 309 selectedIndex(value: number | number[]): TextPickerAttribute; 310} 311 312/** 313 * Defines the struct of TextPickerResult. 314 * 315 * @interface TextPickerResult 316 * @syscap SystemCapability.ArkUI.ArkUI.Full 317 * @since 8 318 */ 319/** 320 * Defines the struct of TextPickerResult. 321 * 322 * @interface TextPickerResult 323 * @syscap SystemCapability.ArkUI.ArkUI.Full 324 * @crossplatform 325 * @since 10 326 */ 327declare interface TextPickerResult { 328 /** 329 * The currently selected value. 330 * 331 * @type { string | string[] } 332 * @syscap SystemCapability.ArkUI.ArkUI.Full 333 * @since 8 334 */ 335 /** 336 * The currently selected value. 337 * Only valid when only text is displayed.When picture or picture plus text is displayed, the value of value is "". 338 * 339 * @type { string | string[] } 340 * @syscap SystemCapability.ArkUI.ArkUI.Full 341 * @crossplatform 342 * @since 10 343 */ 344 value: string | string[]; 345 346 /** 347 * The subscript of the current selection. 348 * 349 * @syscap SystemCapability.ArkUI.ArkUI.Full 350 * @since 8 351 */ 352 /** 353 * The subscript of the current selection. 354 * 355 * @type { number | number[] } 356 * @syscap SystemCapability.ArkUI.ArkUI.Full 357 * @crossplatform 358 * @since 10 359 */ 360 index: number | number[]; 361} 362 363/** 364 * Defines the TextPickerDialogOptions for Text Picker Dialog. 365 * 366 * @interface TextPickerDialogOptions 367 * @syscap SystemCapability.ArkUI.ArkUI.Full 368 * @since 8 369 */ 370/** 371 * Defines the TextPickerDialogOptions for Text Picker Dialog. 372 * 373 * @interface TextPickerDialogOptions 374 * @syscap SystemCapability.ArkUI.ArkUI.Full 375 * @crossplatform 376 * @since 10 377 */ 378declare interface TextPickerDialogOptions extends TextPickerOptions { 379 /** 380 * Called when the default height of the selected element is set. 381 * 382 * @type { ?(number | string) } 383 * @syscap SystemCapability.ArkUI.ArkUI.Full 384 * @since 8 385 */ 386 /** 387 * Called when the default height of the selected element is set. 388 * 389 * @type { ?(number | string) } 390 * @syscap SystemCapability.ArkUI.ArkUI.Full 391 * @crossplatform 392 * @since 10 393 */ 394 defaultPickerItemHeight?: number | string; 395 396 /** 397 * Can scroll loop if true is set, on the contrary it can not. 398 * 399 * @type { ?boolean } 400 * @default true 401 * @syscap SystemCapability.ArkUI.ArkUI.Full 402 * @since 10 403 */ 404 canLoop?: boolean; 405 406 /** 407 * Text style of disappearing items 408 * 409 * @type { ?PickerTextStyle } 410 * @syscap SystemCapability.ArkUI.ArkUI.Full 411 * @crossplatform 412 * @since 10 413 */ 414 disappearTextStyle?: PickerTextStyle; 415 416 /** 417 * Text style of normal items 418 * 419 * @type { ?PickerTextStyle } 420 * @syscap SystemCapability.ArkUI.ArkUI.Full 421 * @crossplatform 422 * @since 10 423 */ 424 textStyle?: PickerTextStyle; 425 426 /** 427 * Text style of selected items 428 * 429 * @type { ?PickerTextStyle } 430 * @syscap SystemCapability.ArkUI.ArkUI.Full 431 * @crossplatform 432 * @since 10 433 */ 434 selectedTextStyle?: PickerTextStyle; 435 /** 436 * Called when the OK button in the dialog is clicked. 437 * 438 * @type { ?function } 439 * @syscap SystemCapability.ArkUI.ArkUI.Full 440 * @since 8 441 */ 442 /** 443 * Called when the OK button in the dialog is clicked. 444 * 445 * @type { ?function } 446 * @syscap SystemCapability.ArkUI.ArkUI.Full 447 * @crossplatform 448 * @since 10 449 */ 450 onAccept?: (value: TextPickerResult) => void; 451 452 /** 453 * Called when the Cancel button in the dialog is clicked. 454 * 455 * @type { ?function } 456 * @syscap SystemCapability.ArkUI.ArkUI.Full 457 * @since 8 458 */ 459 /** 460 * Called when the Cancel button in the dialog is clicked. 461 * 462 * @type { ?function } 463 * @syscap SystemCapability.ArkUI.ArkUI.Full 464 * @crossplatform 465 * @since 10 466 */ 467 onCancel?: () => void; 468 469 /** 470 * This event is triggered when a TextPicker text is selected in dialog. 471 * 472 * @type { ?function } 473 * @syscap SystemCapability.ArkUI.ArkUI.Full 474 * @since 8 475 */ 476 /** 477 * This event is triggered when a TextPicker text is selected in dialog. 478 * 479 * @type { ?function } 480 * @syscap SystemCapability.ArkUI.ArkUI.Full 481 * @crossplatform 482 * @since 10 483 */ 484 onChange?: (value: TextPickerResult) => void; 485 486 /** 487 * Mask Region of dialog. The size cannot exceed the main window. 488 * 489 * @type { ?Rectangle } 490 * @syscap SystemCapability.ArkUI.ArkUI.Full 491 * @crossplatform 492 * @since 10 493 */ 494 maskRect?: Rectangle; 495 496 /** 497 * Defines the dialog alignment of the screen. 498 * 499 * @type { ?DialogAlignment } 500 * @syscap SystemCapability.ArkUI.ArkUI.Full 501 * @crossplatform 502 * @since 10 503 */ 504 alignment?: DialogAlignment; 505 506 /** 507 * Defines the dialog offset. 508 * 509 * @type { ?Offset } 510 * @syscap SystemCapability.ArkUI.ArkUI.Full 511 * @crossplatform 512 * @since 10 513 */ 514 offset?: Offset; 515} 516 517/** 518 * Defines TextPickerDialog which uses show method to show TextPicker dialog. 519 * 520 * @since 8 521 */ 522/** 523 * Defines TextPickerDialog which uses show method to show TextPicker dialog. 524 * 525 * @crossplatform 526 * @since 10 527 */ 528declare class TextPickerDialog { 529 /** 530 * Invoking method display. 531 * 532 * @param { TextPickerDialogOptions } options 533 * @syscap SystemCapability.ArkUI.ArkUI.Full 534 * @since 8 535 */ 536 /** 537 * Invoking method display. 538 * 539 * @param { TextPickerDialogOptions } options 540 * @syscap SystemCapability.ArkUI.ArkUI.Full 541 * @crossplatform 542 * @since 10 543 */ 544 static show(options?: TextPickerDialogOptions); 545} 546 547/** 548 * Defines TextPicker Component. 549 * 550 * @syscap SystemCapability.ArkUI.ArkUI.Full 551 * @since 8 552 */ 553/** 554 * Defines TextPicker Component. 555 * 556 * @syscap SystemCapability.ArkUI.ArkUI.Full 557 * @crossplatform 558 * @since 10 559 */ 560declare const TextPicker: TextPickerInterface; 561 562/** 563 * Defines TextPicker Component instance. 564 * 565 * @syscap SystemCapability.ArkUI.ArkUI.Full 566 * @since 8 567 */ 568/** 569 * Defines TextPicker Component instance. 570 * 571 * @syscap SystemCapability.ArkUI.ArkUI.Full 572 * @crossplatform 573 * @since 10 574 */ 575declare const TextPickerInstance: TextPickerAttribute; 576 577declare module "textPickerDialogParam" { 578 module "textPickerDialogParam" { 579 // @ts-ignore 580 export { TextPickerDialogOptions }; 581 } 582}