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