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 * @file 18 * @kit ArkUI 19 */ 20 21/** 22 * Define options used to construct a rating. 23 * 24 * @interface RatingOptions 25 * @syscap SystemCapability.ArkUI.ArkUI.Full 26 * @crossplatform 27 * @form 28 * @atomicservice 29 * @since 18 30 */ 31declare interface RatingOptions { 32 /** 33 * Rating option. 34 * 35 * @type { number } 36 * @syscap SystemCapability.ArkUI.ArkUI.Full 37 * @since 7 38 */ 39 /** 40 * Rating option. 41 * 42 * @type { number } 43 * @syscap SystemCapability.ArkUI.ArkUI.Full 44 * @form 45 * @since 9 46 */ 47 /** 48 * Rating option. 49 * 50 * @type { number } 51 * @syscap SystemCapability.ArkUI.ArkUI.Full 52 * @crossplatform 53 * @form 54 * @since 10 55 */ 56 /** 57 * Rating option. 58 * 59 * @type { number } 60 * @syscap SystemCapability.ArkUI.ArkUI.Full 61 * @crossplatform 62 * @form 63 * @atomicservice 64 * @since 11 65 */ 66 /** 67 * Rating option. 68 * Anonymous Object Rectification. 69 * 70 * @type { number } 71 * @syscap SystemCapability.ArkUI.ArkUI.Full 72 * @crossplatform 73 * @form 74 * @atomicservice 75 * @since 18 76 */ 77 rating: number; 78 79 /** 80 * Indicator option. 81 * 82 * @type { ?boolean } 83 * @syscap SystemCapability.ArkUI.ArkUI.Full 84 * @since 7 85 */ 86 /** 87 * Indicator option. 88 * 89 * @type { ?boolean } 90 * @syscap SystemCapability.ArkUI.ArkUI.Full 91 * @form 92 * @since 9 93 */ 94 /** 95 * Indicator option. 96 * 97 * @type { ?boolean } 98 * @syscap SystemCapability.ArkUI.ArkUI.Full 99 * @crossplatform 100 * @form 101 * @since 10 102 */ 103 /** 104 * Indicator option. 105 * 106 * @type { ?boolean } 107 * @syscap SystemCapability.ArkUI.ArkUI.Full 108 * @crossplatform 109 * @form 110 * @atomicservice 111 * @since 11 112 */ 113 /** 114 * Indicator option. 115 * 116 * @type { ?boolean } 117 * @syscap SystemCapability.ArkUI.ArkUI.Full 118 * @crossplatform 119 * @form 120 * @atomicservice 121 * @since 18 122 */ 123 indicator?: boolean 124} 125 126/** 127 * Define star style options. 128 * 129 * @interface StarStyleOptions 130 * @syscap SystemCapability.ArkUI.ArkUI.Full 131 * @crossplatform 132 * @form 133 * @atomicservice 134 * @since 18 135 */ 136declare interface StarStyleOptions { 137 /** 138 * Background URI option. 139 * 140 * @type { string } 141 * @syscap SystemCapability.ArkUI.ArkUI.Full 142 * @since 7 143 */ 144 /** 145 * Background URI option. 146 * 147 * @type { string } 148 * @syscap SystemCapability.ArkUI.ArkUI.Full 149 * @form 150 * @since 9 151 */ 152 /** 153 * Background URI option. 154 * 155 * @type { string } 156 * @syscap SystemCapability.ArkUI.ArkUI.Full 157 * @crossplatform 158 * @form 159 * @since 10 160 */ 161 /** 162 * Background URI option. 163 * 164 * @type { string } 165 * @syscap SystemCapability.ArkUI.ArkUI.Full 166 * @crossplatform 167 * @form 168 * @atomicservice 169 * @since 11 170 */ 171 backgroundUri: string; 172 173 /** 174 * Foreground URI option. 175 * 176 * @type { string } 177 * @syscap SystemCapability.ArkUI.ArkUI.Full 178 * @since 7 179 */ 180 /** 181 * Foreground URI option. 182 * 183 * @type { string } 184 * @syscap SystemCapability.ArkUI.ArkUI.Full 185 * @form 186 * @since 9 187 */ 188 /** 189 * Foreground URI option. 190 * 191 * @type { string } 192 * @syscap SystemCapability.ArkUI.ArkUI.Full 193 * @crossplatform 194 * @form 195 * @since 10 196 */ 197 /** 198 * Foreground URI option. 199 * 200 * @type { string } 201 * @syscap SystemCapability.ArkUI.ArkUI.Full 202 * @crossplatform 203 * @form 204 * @atomicservice 205 * @since 11 206 */ 207 foregroundUri: string; 208 209 /** 210 * Secondary URI option. 211 * 212 * @type { ?string } 213 * @syscap SystemCapability.ArkUI.ArkUI.Full 214 * @since 7 215 */ 216 /** 217 * Secondary URI option. 218 * 219 * @type { ?string } 220 * @syscap SystemCapability.ArkUI.ArkUI.Full 221 * @form 222 * @since 9 223 */ 224 /** 225 * Secondary URI option. 226 * 227 * @type { ?string } 228 * @syscap SystemCapability.ArkUI.ArkUI.Full 229 * @crossplatform 230 * @form 231 * @since 10 232 */ 233 /** 234 * Secondary URI option. 235 * 236 * @type { ?string } 237 * @syscap SystemCapability.ArkUI.ArkUI.Full 238 * @crossplatform 239 * @form 240 * @atomicservice 241 * @since 11 242 */ 243 secondaryUri?: string 244} 245 246/** 247 * Provides the interface for scoring bars. 248 * 249 * @interface RatingInterface 250 * @syscap SystemCapability.ArkUI.ArkUI.Full 251 * @since 7 252 */ 253/** 254 * Provides the interface for scoring bars. 255 * 256 * @interface RatingInterface 257 * @syscap SystemCapability.ArkUI.ArkUI.Full 258 * @form 259 * @since 9 260 */ 261/** 262 * Provides the interface for scoring bars. 263 * 264 * @interface RatingInterface 265 * @syscap SystemCapability.ArkUI.ArkUI.Full 266 * @crossplatform 267 * @form 268 * @since 10 269 */ 270/** 271 * Provides the interface for scoring bars. 272 * 273 * @interface RatingInterface 274 * @syscap SystemCapability.ArkUI.ArkUI.Full 275 * @crossplatform 276 * @form 277 * @atomicservice 278 * @since 11 279 */ 280interface RatingInterface { 281 /** 282 * Called when a score bar is created. 283 * 284 * @param { object } options 285 * @returns { RatingAttribute } 286 * @syscap SystemCapability.ArkUI.ArkUI.Full 287 * @since 7 288 */ 289 /** 290 * Called when a score bar is created. 291 * 292 * @param { object } options 293 * @returns { RatingAttribute } 294 * @syscap SystemCapability.ArkUI.ArkUI.Full 295 * @form 296 * @since 9 297 */ 298 /** 299 * Called when a score bar is created. 300 * 301 * @param { object } options 302 * @returns { RatingAttribute } 303 * @syscap SystemCapability.ArkUI.ArkUI.Full 304 * @crossplatform 305 * @form 306 * @since 10 307 */ 308 /** 309 * Called when a score bar is created. 310 * 311 * @param { object } options 312 * @returns { RatingAttribute } 313 * @syscap SystemCapability.ArkUI.ArkUI.Full 314 * @crossplatform 315 * @form 316 * @atomicservice 317 * @since 11 318 */ 319 /** 320 * Called when a score bar is created. 321 * Anonymous Object Rectification. 322 * 323 * @param { RatingOptions } [options] - rating options 324 * @returns { RatingAttribute } 325 * @syscap SystemCapability.ArkUI.ArkUI.Full 326 * @crossplatform 327 * @form 328 * @atomicservice 329 * @since 18 330 */ 331 (options?: RatingOptions): RatingAttribute; 332} 333 334/** 335 * RatingConfiguration used by rating content modifier. 336 * 337 * @extends CommonConfiguration<RatingConfiguration> 338 * @interface RatingConfiguration 339 * @syscap SystemCapability.ArkUI.ArkUI.Full 340 * @crossplatform 341 * @atomicservice 342 * @since 12 343 */ 344declare interface RatingConfiguration extends CommonConfiguration<RatingConfiguration> { 345 /** 346 * Current number of Rating. 347 * 348 * @type { number } 349 * @syscap SystemCapability.ArkUI.ArkUI.Full 350 * @crossplatform 351 * @atomicservice 352 * @since 12 353 */ 354 rating: number; 355 356 /** 357 * Indicates whether Rating is used as an indicator. 358 * 359 * @type { boolean } 360 * @syscap SystemCapability.ArkUI.ArkUI.Full 361 * @crossplatform 362 * @atomicservice 363 * @since 12 364 */ 365 indicator: boolean; 366 367 /** 368 * Total stars of Rating. 369 * 370 * @type { number } 371 * @syscap SystemCapability.ArkUI.ArkUI.Full 372 * @crossplatform 373 * @atomicservice 374 * @since 12 375 */ 376 stars: number; 377 378 /** 379 * The step size of the Rating. 380 * 381 * @type { number } 382 * @syscap SystemCapability.ArkUI.ArkUI.Full 383 * @crossplatform 384 * @atomicservice 385 * @since 12 386 */ 387 stepSize: number; 388 389 /** 390 * Trigger Rating select change. 391 * 392 * @type { Callback<number> } 393 * @syscap SystemCapability.ArkUI.ArkUI.Full 394 * @crossplatform 395 * @atomicservice 396 * @since 12 397 */ 398 triggerChange: Callback<number>; 399} 400 401/** 402 * Callback of the star rating of the operation scoring bar changes event. 403 * 404 * @typedef {function} OnRatingChangeCallback 405 * @param {number} rating - The rating of the rating bar. 406 * @syscap SystemCapability.ArkUI.ArkUI.Full 407 * @crossplatform 408 * @atomicservice 409 * @since 18 410 */ 411 declare type OnRatingChangeCallback = (rating: number) => void; 412 413/** 414 * Defines the rating attribute functions. 415 * 416 * @extends CommonMethod<RatingAttribute> 417 * @syscap SystemCapability.ArkUI.ArkUI.Full 418 * @since 7 419 */ 420/** 421 * Defines the rating attribute functions. 422 * 423 * @extends CommonMethod<RatingAttribute> 424 * @syscap SystemCapability.ArkUI.ArkUI.Full 425 * @form 426 * @since 9 427 */ 428/** 429 * Defines the rating attribute functions. 430 * 431 * @extends CommonMethod<RatingAttribute> 432 * @syscap SystemCapability.ArkUI.ArkUI.Full 433 * @crossplatform 434 * @form 435 * @since 10 436 */ 437/** 438 * Defines the rating attribute functions. 439 * 440 * @extends CommonMethod<RatingAttribute> 441 * @syscap SystemCapability.ArkUI.ArkUI.Full 442 * @crossplatform 443 * @form 444 * @atomicservice 445 * @since 11 446 */ 447declare class RatingAttribute extends CommonMethod<RatingAttribute> { 448 /** 449 * Called when the total number of stars is set. 450 * 451 * @param { number } value 452 * @returns { RatingAttribute } 453 * @syscap SystemCapability.ArkUI.ArkUI.Full 454 * @since 7 455 */ 456 /** 457 * Called when the total number of stars is set. 458 * 459 * @param { number } value 460 * @returns { RatingAttribute } 461 * @syscap SystemCapability.ArkUI.ArkUI.Full 462 * @form 463 * @since 9 464 */ 465 /** 466 * Called when the total number of stars is set. 467 * 468 * @param { number } value 469 * @returns { RatingAttribute } 470 * @syscap SystemCapability.ArkUI.ArkUI.Full 471 * @crossplatform 472 * @form 473 * @since 10 474 */ 475 /** 476 * Called when the total number of stars is set. 477 * 478 * @param { number } value 479 * @returns { RatingAttribute } 480 * @syscap SystemCapability.ArkUI.ArkUI.Full 481 * @crossplatform 482 * @form 483 * @atomicservice 484 * @since 11 485 */ 486 stars(value: number): RatingAttribute; 487 488 /** 489 * Called when the total number of stars is set. 490 * 491 * @param { Optional<number> } starCount 492 * @returns { RatingAttribute } 493 * @syscap SystemCapability.ArkUI.ArkUI.Full 494 * @crossplatform 495 * @form 496 * @atomicservice 497 * @since 18 498 */ 499 stars(starCount: Optional<number>): RatingAttribute; 500 501 /** 502 * Called when the step size of the operation rating. 503 * 504 * @param { number } value 505 * @returns { RatingAttribute } 506 * @syscap SystemCapability.ArkUI.ArkUI.Full 507 * @since 7 508 */ 509 /** 510 * Called when the step size of the operation rating. 511 * 512 * @param { number } value 513 * @returns { RatingAttribute } 514 * @syscap SystemCapability.ArkUI.ArkUI.Full 515 * @form 516 * @since 9 517 */ 518 /** 519 * Called when the step size of the operation rating. 520 * 521 * @param { number } value 522 * @returns { RatingAttribute } 523 * @syscap SystemCapability.ArkUI.ArkUI.Full 524 * @crossplatform 525 * @form 526 * @since 10 527 */ 528 /** 529 * Called when the step size of the operation rating. 530 * 531 * @param { number } value 532 * @returns { RatingAttribute } 533 * @syscap SystemCapability.ArkUI.ArkUI.Full 534 * @crossplatform 535 * @form 536 * @atomicservice 537 * @since 11 538 */ 539 stepSize(value: number): RatingAttribute; 540 541 /** 542 * Called when the step size of the operation rating. 543 * 544 * @param { Optional<number> } size 545 * @returns { RatingAttribute } 546 * @syscap SystemCapability.ArkUI.ArkUI.Full 547 * @crossplatform 548 * @form 549 * @atomicservice 550 * @since 18 551 */ 552 stepSize(size: Optional<number>): RatingAttribute; 553 554 /** 555 * Called when a picture is set. 556 * 557 * @param { object } value 558 * @returns { RatingAttribute } 559 * @syscap SystemCapability.ArkUI.ArkUI.Full 560 * @since 7 561 */ 562 /** 563 * Called when a picture is set. 564 * 565 * @param { object } value 566 * @returns { RatingAttribute } 567 * @syscap SystemCapability.ArkUI.ArkUI.Full 568 * @form 569 * @since 9 570 */ 571 /** 572 * Called when a picture is set. 573 * 574 * @param { object } value 575 * @returns { RatingAttribute } 576 * @syscap SystemCapability.ArkUI.ArkUI.Full 577 * @crossplatform 578 * @form 579 * @since 10 580 */ 581 /** 582 * Called when a picture is set. 583 * 584 * @param { object } value 585 * @returns { RatingAttribute } 586 * @syscap SystemCapability.ArkUI.ArkUI.Full 587 * @crossplatform 588 * @form 589 * @atomicservice 590 * @since 11 591 */ 592 /** 593 * Called when a picture is set. 594 * Anonymous Object Rectification. 595 * 596 * @param { StarStyleOptions } options - star style options 597 * @returns { RatingAttribute } 598 * @syscap SystemCapability.ArkUI.ArkUI.Full 599 * @crossplatform 600 * @form 601 * @atomicservice 602 * @since 18 603 */ 604 starStyle(options: StarStyleOptions): RatingAttribute; 605 606 /** 607 * Called when a picture is set. 608 * 609 * @param { Optional<StarStyleOptions> } options - star style options 610 * @returns { RatingAttribute } 611 * @syscap SystemCapability.ArkUI.ArkUI.Full 612 * @crossplatform 613 * @form 614 * @atomicservice 615 * @since 18 616 */ 617 starStyle(options: Optional<StarStyleOptions>): RatingAttribute; 618 619 /** 620 * Called when the star rating of the operation scoring bar changes. 621 * 622 * @param { function } callback 623 * @returns { RatingAttribute } 624 * @syscap SystemCapability.ArkUI.ArkUI.Full 625 * @since 7 626 */ 627 /** 628 * Called when the star rating of the operation scoring bar changes. 629 * 630 * @param { function } callback 631 * @returns { RatingAttribute } 632 * @syscap SystemCapability.ArkUI.ArkUI.Full 633 * @form 634 * @since 9 635 */ 636 /** 637 * Called when the star rating of the operation scoring bar changes. 638 * 639 * @param { function } callback 640 * @returns { RatingAttribute } 641 * @syscap SystemCapability.ArkUI.ArkUI.Full 642 * @crossplatform 643 * @form 644 * @since 10 645 */ 646 /** 647 * Called when the star rating of the operation scoring bar changes. 648 * 649 * @param { function } callback 650 * @returns { RatingAttribute } 651 * @syscap SystemCapability.ArkUI.ArkUI.Full 652 * @crossplatform 653 * @form 654 * @atomicservice 655 * @since 11 656 */ 657 onChange(callback: (value: number) => void): RatingAttribute; 658 659 /** 660 * Called when the star rating of the operation scoring bar changes. 661 * 662 * @param { Optional<OnRatingChangeCallback> } callback 663 * @returns { RatingAttribute } 664 * @syscap SystemCapability.ArkUI.ArkUI.Full 665 * @crossplatform 666 * @form 667 * @atomicservice 668 * @since 18 669 */ 670 onChange(callback: Optional<OnRatingChangeCallback>): RatingAttribute; 671 672 /** 673 * Set the content modifier of rating. 674 * 675 * @param { ContentModifier<RatingConfiguration> } modifier - The content modifier of rating. 676 * @returns { RatingAttribute } 677 * @syscap SystemCapability.ArkUI.ArkUI.Full 678 * @crossplatform 679 * @atomicservice 680 * @since 12 681 */ 682 contentModifier(modifier: ContentModifier<RatingConfiguration>): RatingAttribute; 683 684 /** 685 * Set the content modifier of rating. 686 * 687 * @param { Optional<ContentModifier<RatingConfiguration>> } modifier - The content modifier of rating. 688 * @returns { RatingAttribute } 689 * @syscap SystemCapability.ArkUI.ArkUI.Full 690 * @crossplatform 691 * @atomicservice 692 * @since 18 693 */ 694 contentModifier(modifier: Optional<ContentModifier<RatingConfiguration>>): RatingAttribute; 695} 696 697/** 698 * Defines Rating Component. 699 * 700 * @syscap SystemCapability.ArkUI.ArkUI.Full 701 * @since 7 702 */ 703/** 704 * Defines Rating Component. 705 * 706 * @syscap SystemCapability.ArkUI.ArkUI.Full 707 * @form 708 * @since 9 709 */ 710/** 711 * Defines Rating Component. 712 * 713 * @syscap SystemCapability.ArkUI.ArkUI.Full 714 * @crossplatform 715 * @form 716 * @since 10 717 */ 718/** 719 * Defines Rating Component. 720 * 721 * @syscap SystemCapability.ArkUI.ArkUI.Full 722 * @crossplatform 723 * @form 724 * @atomicservice 725 * @since 11 726 */ 727declare const Rating: RatingInterface; 728 729/** 730 * Defines Rating Component instance. 731 * 732 * @syscap SystemCapability.ArkUI.ArkUI.Full 733 * @since 7 734 */ 735/** 736 * Defines Rating Component instance. 737 * 738 * @syscap SystemCapability.ArkUI.ArkUI.Full 739 * @form 740 * @since 9 741 */ 742/** 743 * Defines Rating Component instance. 744 * 745 * @syscap SystemCapability.ArkUI.ArkUI.Full 746 * @crossplatform 747 * @form 748 * @since 10 749 */ 750/** 751 * Defines Rating Component instance. 752 * 753 * @syscap SystemCapability.ArkUI.ArkUI.Full 754 * @crossplatform 755 * @form 756 * @atomicservice 757 * @since 11 758 */ 759declare const RatingInstance: RatingAttribute; 760