1/* 2 * Copyright (c) 2023-2024 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/// <reference path='./import.ts' /> 17class TextInputStyleModifier extends ModifierWithKey<number> { 18 constructor(value: number) { 19 super(value); 20 } 21 static identity: Symbol = Symbol('textInputStyle'); 22 applyPeer(node: KNode, reset: boolean): void { 23 if (reset) { 24 getUINativeModule().textInput.resetStyle(node); 25 } else { 26 getUINativeModule().textInput.setStyle(node, this.value!); 27 } 28 } 29 checkObjectDiff(): boolean { 30 return !isBaseOrResourceEqual(this.stageValue, this.value); 31 } 32} 33class TextInputMaxLengthModifier extends ModifierWithKey<number> { 34 constructor(value: number) { 35 super(value); 36 } 37 static identity: Symbol = Symbol('textInputMaxLength'); 38 applyPeer(node: KNode, reset: boolean): void { 39 if (reset) { 40 getUINativeModule().textInput.resetMaxLength(node); 41 } else { 42 getUINativeModule().textInput.setMaxLength(node, this.value!); 43 } 44 } 45 checkObjectDiff(): boolean { 46 return !isBaseOrResourceEqual(this.stageValue, this.value); 47 } 48} 49class TextInputMaxLinesModifier extends ModifierWithKey<number> { 50 constructor(value: number) { 51 super(value); 52 } 53 static identity: Symbol = Symbol('textInputMaxLines'); 54 applyPeer(node: KNode, reset: boolean): void { 55 if (reset) { 56 getUINativeModule().textInput.resetMaxLines(node); 57 } else { 58 getUINativeModule().textInput.setMaxLines(node, this.value!); 59 } 60 } 61 checkObjectDiff(): boolean { 62 return !isBaseOrResourceEqual(this.stageValue, this.value); 63 } 64} 65 66class TextInputDecorationModifier extends ModifierWithKey<{ type: TextDecorationType; color?: ResourceColor; style?: TextDecorationStyle }> { 67 constructor(value: { type: TextDecorationType; color?: ResourceColor; style?: TextDecorationStyle }) { 68 super(value); 69 } 70 static identity: Symbol = Symbol('textInputDecoration'); 71 applyPeer(node: KNode, reset: boolean): void { 72 if (reset) { 73 getUINativeModule().textInput.resetDecoration(node); 74 } else { 75 getUINativeModule().textInput.setDecoration(node, this.value!.type, this.value!.color, this.value!.style); 76 } 77 } 78 79 checkObjectDiff(): boolean { 80 if (this.stageValue.type !== this.value.type || this.stageValue.style !== this.value.style) { 81 return true; 82 } 83 if (isResource(this.stageValue.color) && isResource(this.value.color)) { 84 return !isResourceEqual(this.stageValue.color, this.value.color); 85 } else if (!isResource(this.stageValue.color) && !isResource(this.value.color)) { 86 return !(this.stageValue.color === this.value.color); 87 } else { 88 return true; 89 } 90 } 91} 92 93class TextInputLetterSpacingModifier extends ModifierWithKey<number | string> { 94 constructor(value: number | string) { 95 super(value); 96 } 97 static identity: Symbol = Symbol('textInputLetterSpacing'); 98 applyPeer(node: KNode, reset: boolean): void { 99 if (reset) { 100 getUINativeModule().textInput.resetLetterSpacing(node); 101 } else { 102 getUINativeModule().textInput.setLetterSpacing(node, this.value); 103 } 104 } 105 106 checkObjectDiff(): boolean { 107 return !isBaseOrResourceEqual(this.stageValue, this.value); 108 } 109} 110 111class TextInputLineHeightModifier extends ModifierWithKey<number | string | Resource> { 112 constructor(value: number | string | Resource) { 113 super(value); 114 } 115 static identity: Symbol = Symbol('textInputLineHeight'); 116 applyPeer(node: KNode, reset: boolean): void { 117 if (reset) { 118 getUINativeModule().textInput.resetLineHeight(node); 119 } else { 120 getUINativeModule().textInput.setLineHeight(node, this.value); 121 } 122 } 123 124 checkObjectDiff(): boolean { 125 return !isBaseOrResourceEqual(this.stageValue, this.value); 126 } 127} 128 129class TextInputHalfLeadingModifier extends ModifierWithKey<boolean> { 130 constructor(value: boolean) { 131 super(value); 132 } 133 static identity: Symbol = Symbol('textInputHalfLeading'); 134 applyPeer(node: KNode, reset: boolean): void { 135 if (reset) { 136 getUINativeModule().textInput.resetHalfLeading(node); 137 } else { 138 getUINativeModule().textInput.setHalfLeading(node, this.value); 139 } 140 } 141 142 checkObjectDiff(): boolean { 143 return !isBaseOrResourceEqual(this.stageValue, this.value); 144 } 145} 146 147class TextInputUnderlineColorModifier extends ModifierWithKey<ResourceColor | UnderlineColor | undefined> { 148 constructor(value: ResourceColor | UnderlineColor | undefined) { 149 super(value); 150 } 151 static identity: Symbol = Symbol('textInputUnderlineColor'); 152 applyPeer(node: KNode, reset: boolean): void { 153 if (reset) { 154 getUINativeModule().textInput.resetUnderlineColor(node); 155 } else { 156 const valueType: string = typeof this.value; 157 if (valueType === 'number' || valueType === 'string' || isResource(this.value)) { 158 getUINativeModule().textInput.setUnderlineColor(node, this.value, undefined, undefined, undefined, undefined); 159 } else { 160 getUINativeModule().textInput.setUnderlineColor(node, undefined, (this.value as UnderlineColor).normal, 161 (this.value as UnderlineColor).typing, (this.value as UnderlineColor).error, (this.value as UnderlineColor).disable); 162 } 163 } 164 } 165 166 checkObjectDiff(): boolean { 167 if (isResource(this.stageValue) && isResource(this.value)) { 168 return !isBaseOrResourceEqual(this.stageValue, this.value); 169 } else if (!isResource(this.stageValue) && !isResource(this.value)) { 170 return !((this.stageValue as UnderlineColor).normal === (this.value as UnderlineColor).normal && 171 (this.stageValue as UnderlineColor).typing === (this.value as UnderlineColor).typing && 172 (this.stageValue as UnderlineColor).error === (this.value as UnderlineColor).error && 173 (this.stageValue as UnderlineColor).disable === (this.value as UnderlineColor).disable); 174 } else { 175 return true; 176 } 177 } 178} 179 180class TextInputWordBreakModifier extends ModifierWithKey<WordBreak> { 181 constructor(value: WordBreak) { 182 super(value); 183 } 184 static identity: Symbol = Symbol('textInputWordBreak'); 185 applyPeer(node: KNode, reset: boolean): void { 186 if (reset) { 187 getUINativeModule().textInput.resetWordBreak(node); 188 } else { 189 getUINativeModule().textInput.setWordBreak(node, this.value!); 190 } 191 } 192 checkObjectDiff(): boolean { 193 return !isBaseOrResourceEqual(this.stageValue, this.value); 194 } 195} 196 197class TextInputLineBreakStrategyModifier extends ModifierWithKey<LineBreakStrategy> { 198 constructor(value: LineBreakStrategy) { 199 super(value); 200 } 201 static identity: Symbol = Symbol('textInputLineBreakStrategy'); 202 applyPeer(node: KNode, reset: boolean): void { 203 if (reset) { 204 getUINativeModule().textInput.resetLineBreakStrategy(node); 205 } else { 206 getUINativeModule().textInput.setLineBreakStrategy(node, this.value!); 207 } 208 } 209 checkObjectDiff(): boolean { 210 return !isBaseOrResourceEqual(this.stageValue, this.value); 211 } 212} 213 214class TextInputMinFontSizeModifier extends ModifierWithKey<number | string | Resource> { 215 constructor(value: number | string | Resource) { 216 super(value); 217 } 218 static identity: Symbol = Symbol('textInputMinFontSize'); 219 applyPeer(node: KNode, reset: boolean): void { 220 if (reset) { 221 getUINativeModule().textInput.resetMinFontSize(node); 222 } else { 223 getUINativeModule().textInput.setMinFontSize(node, this.value!); 224 } 225 } 226 checkObjectDiff(): boolean { 227 return !isBaseOrResourceEqual(this.stageValue, this.value); 228 } 229} 230 231class TextInputMaxFontSizeModifier extends ModifierWithKey<number | string | Resource> { 232 constructor(value: number | string | Resource) { 233 super(value); 234 } 235 static identity: Symbol = Symbol('textInputMaxFontSize'); 236 applyPeer(node: KNode, reset: boolean): void { 237 if (reset) { 238 getUINativeModule().textInput.resetMaxFontSize(node); 239 } else { 240 getUINativeModule().textInput.setMaxFontSize(node, this.value!); 241 } 242 } 243 checkObjectDiff(): boolean { 244 return !isBaseOrResourceEqual(this.stageValue, this.value); 245 } 246} 247 248class TextInputMinFontScaleModifier extends ModifierWithKey<number | Resource> { 249 constructor(value: number | Resource) { 250 super(value); 251 } 252 static identity: Symbol = Symbol('textInputMinFontScale'); 253 applyPeer(node: KNode, reset: boolean): void { 254 if (reset) { 255 getUINativeModule().textInput.resetMinFontScale(node); 256 } else { 257 getUINativeModule().textInput.setMinFontScale(node, this.value!); 258 } 259 } 260 261 checkObjectDiff(): boolean { 262 return !isBaseOrResourceEqual(this.stageValue, this.value); 263 } 264} 265 266class TextInputMaxFontScaleModifier extends ModifierWithKey<number | Resource> { 267 constructor(value: number | Resource) { 268 super(value); 269 } 270 static identity: Symbol = Symbol('textInputMaxFontScale'); 271 applyPeer(node: KNode, reset: boolean): void { 272 if (reset) { 273 getUINativeModule().textInput.resetMaxFontScale(node); 274 } else { 275 getUINativeModule().textInput.setMaxFontScale(node, this.value!); 276 } 277 } 278 279 checkObjectDiff(): boolean { 280 return !isBaseOrResourceEqual(this.stageValue, this.value); 281 } 282} 283 284class TextInputHeightAdaptivePolicyModifier extends ModifierWithKey<TextHeightAdaptivePolicy> { 285 constructor(value: TextHeightAdaptivePolicy) { 286 super(value); 287 } 288 static identity: Symbol = Symbol('textInputHeightAdaptivePolicy'); 289 applyPeer(node: KNode, reset: boolean): void { 290 if (reset) { 291 getUINativeModule().textInput.resetHeightAdaptivePolicy(node); 292 } else { 293 getUINativeModule().textInput.setHeightAdaptivePolicy(node, this.value!); 294 } 295 } 296 checkObjectDiff(): boolean { 297 return !isBaseOrResourceEqual(this.stageValue, this.value); 298 } 299} 300class TextInputTextOverflowModifier extends ModifierWithKey<TextOverflow> { 301 constructor(value: TextOverflow) { 302 super(value); 303 } 304 static identity: Symbol = Symbol('textInputTextOverflow'); 305 applyPeer(node: KNode, reset: boolean): void { 306 if (reset) { 307 getUINativeModule().textInput.resetTextOverflow(node); 308 } else { 309 getUINativeModule().textInput.setTextOverflow(node, this.value!); 310 } 311 } 312 checkObjectDiff(): boolean { 313 return this.stageValue !== this.value; 314 } 315} 316 317class TextInputTextIndentModifier extends ModifierWithKey<Dimension> { 318 constructor(value: Dimension) { 319 super(value); 320 } 321 static identity: Symbol = Symbol('textInputTextIndent'); 322 applyPeer(node: KNode, reset: boolean): void { 323 if (reset) { 324 getUINativeModule().textInput.resetTextIndent(node); 325 } else { 326 getUINativeModule().textInput.setTextIndent(node, this.value!); 327 } 328 } 329 330 checkObjectDiff(): boolean { 331 return !isBaseOrResourceEqual(this.stageValue, this.value); 332 } 333} 334 335class TextInputShowPasswordIconModifier extends ModifierWithKey<boolean> { 336 constructor(value: boolean) { 337 super(value); 338 } 339 static identity: Symbol = Symbol('textInputShowPasswordIcon'); 340 applyPeer(node: KNode, reset: boolean): void { 341 if (reset) { 342 getUINativeModule().textInput.resetShowPasswordIcon(node); 343 } else { 344 getUINativeModule().textInput.setShowPasswordIcon(node, this.value!); 345 } 346 } 347 checkObjectDiff(): boolean { 348 return !isBaseOrResourceEqual(this.stageValue, this.value); 349 } 350} 351class TextInputShowPasswordModifier extends ModifierWithKey<boolean> { 352 constructor(value: boolean) { 353 super(value); 354 } 355 static identity: Symbol = Symbol('textInputShowPassword'); 356 applyPeer(node: KNode, reset: boolean): void { 357 if (reset) { 358 getUINativeModule().textInput.resetShowPassword(node); 359 } else { 360 getUINativeModule().textInput.setShowPassword(node, this.value!); 361 } 362 } 363 checkObjectDiff(): boolean { 364 return !isBaseOrResourceEqual(this.stageValue, this.value); 365 } 366} 367class TextInputTextAlignModifier extends ModifierWithKey<number> { 368 constructor(value: number) { 369 super(value); 370 } 371 static identity: Symbol = Symbol('textInputTextAlign'); 372 applyPeer(node: KNode, reset: boolean): void { 373 if (reset) { 374 getUINativeModule().textInput.resetTextAlign(node); 375 } else { 376 getUINativeModule().textInput.setTextAlign(node, this.value!); 377 } 378 } 379 checkObjectDiff(): boolean { 380 return !isBaseOrResourceEqual(this.stageValue, this.value); 381 } 382} 383 384class TextInputPlaceholderFontModifier extends ModifierWithKey<Font> { 385 constructor(value: Font) { 386 super(value); 387 } 388 static identity: Symbol = Symbol('textInputPlaceholderFont'); 389 390 applyPeer(node: KNode, reset: boolean): void { 391 if (reset) { 392 getUINativeModule().textInput.resetPlaceholderFont(node); 393 } else { 394 getUINativeModule().textInput.setPlaceholderFont(node, this.value.size, 395 this.value.weight, this.value.family, this.value.style); 396 } 397 } 398 399 checkObjectDiff(): boolean { 400 if (!(this.stageValue.weight === this.value.weight && 401 this.stageValue.style === this.value.style)) { 402 return true; 403 } else { 404 if (((isResource(this.stageValue.size) && isResource(this.value.size) && 405 isResourceEqual(this.stageValue.size, this.value.size)) || 406 (!isResource(this.stageValue.size) && !isResource(this.value.size) && 407 this.stageValue.size === this.value.size)) && 408 ((isResource(this.stageValue.family) && isResource(this.value.family) && 409 isResourceEqual(this.stageValue.family, this.value.family)) || 410 (!isResource(this.stageValue.family) && !isResource(this.value.family) && 411 this.stageValue.family === this.value.family))) { 412 return false; 413 } else { 414 return true; 415 } 416 } 417 } 418} 419 420class TextInputPlaceholderColorModifier extends ModifierWithKey<ResourceColor> { 421 constructor(value: ResourceColor) { 422 super(value); 423 } 424 static identity: Symbol = Symbol('textInputPlaceholderColor'); 425 applyPeer(node: KNode, reset: boolean): void { 426 if (reset) { 427 getUINativeModule().textInput.resetPlaceholderColor(node); 428 } else { 429 getUINativeModule().textInput.setPlaceholderColor(node, this.value!); 430 } 431 } 432 checkObjectDiff(): boolean { 433 return !isBaseOrResourceEqual(this.stageValue, this.value); 434 } 435} 436 437class TextInputPasswordIconModifier extends ModifierWithKey<PasswordIcon> { 438 constructor(value: PasswordIcon) { 439 super(value); 440 } 441 static identity: Symbol = Symbol('textInputPasswordIcon'); 442 applyPeer(node: KNode, reset: boolean): void { 443 if (reset) { 444 getUINativeModule().textInput.resetPasswordIcon(node); 445 } else { 446 getUINativeModule().textInput.setPasswordIcon(node, this.value.onIconSrc, this.value.offIconSrc); 447 } 448 } 449 checkObjectDiff(): boolean { 450 return !isBaseOrResourceEqual(this.stageValue.onIconSrc, this.value.onIconSrc) || 451 !isBaseOrResourceEqual(this.stageValue.offIconSrc, this.value.offIconSrc); 452 } 453} 454 455class TextInputSelectedBackgroundColorModifier extends ModifierWithKey<ResourceColor> { 456 constructor(value: ResourceColor) { 457 super(value); 458 } 459 static identity: Symbol = Symbol('textInputSelectedBackgroundColor'); 460 applyPeer(node: KNode, reset: boolean): void { 461 if (reset) { 462 getUINativeModule().textInput.resetSelectedBackgroundColor(node); 463 } else { 464 getUINativeModule().textInput.setSelectedBackgroundColor(node, this.value!); 465 } 466 } 467 checkObjectDiff(): boolean { 468 return !isBaseOrResourceEqual(this.stageValue, this.value); 469 } 470} 471 472class TextInputSelectionMenuHiddenModifier extends ModifierWithKey<boolean> { 473 constructor(value: boolean) { 474 super(value); 475 } 476 static identity: Symbol = Symbol('textInputSelectionMenuHidden'); 477 applyPeer(node: KNode, reset: boolean): void { 478 if (reset) { 479 getUINativeModule().textInput.resetSelectionMenuHidden(node); 480 } else { 481 getUINativeModule().textInput.setSelectionMenuHidden(node, this.value!); 482 } 483 } 484 checkObjectDiff(): boolean { 485 return !isBaseOrResourceEqual(this.stageValue, this.value); 486 } 487} 488class TextInputShowUnderlineModifier extends ModifierWithKey<boolean> { 489 constructor(value: boolean) { 490 super(value); 491 } 492 static identity: Symbol = Symbol('textInputShowUnderLine'); 493 applyPeer(node: KNode, reset: boolean): void { 494 if (reset) { 495 getUINativeModule().textInput.resetShowUnderline(node); 496 } else { 497 getUINativeModule().textInput.setShowUnderline(node, this.value!); 498 } 499 } 500 checkObjectDiff(): boolean { 501 return !isBaseOrResourceEqual(this.stageValue, this.value); 502 } 503} 504class TextInputPasswordRulesModifier extends ModifierWithKey<string> { 505 constructor(value: string) { 506 super(value); 507 } 508 static identity: Symbol = Symbol('textInputPasswordRules'); 509 applyPeer(node: KNode, reset: boolean): void { 510 if (reset) { 511 getUINativeModule().textInput.resetPasswordRules(node); 512 } else { 513 getUINativeModule().textInput.setPasswordRules(node, this.value!); 514 } 515 } 516 checkObjectDiff(): boolean { 517 return !isBaseOrResourceEqual(this.stageValue, this.value); 518 } 519} 520class TextInputEnableAutoFillModifier extends ModifierWithKey<boolean> { 521 constructor(value: boolean) { 522 super(value); 523 } 524 static identity: Symbol = Symbol('textInputEnableAutoFill'); 525 applyPeer(node: KNode, reset: boolean): void { 526 if (reset) { 527 getUINativeModule().textInput.resetEnableAutoFill(node); 528 } else { 529 getUINativeModule().textInput.setEnableAutoFill(node, this.value!); 530 } 531 } 532 checkObjectDiff(): boolean { 533 return !isBaseOrResourceEqual(this.stageValue, this.value); 534 } 535} 536class TextInputShowErrorModifier extends ModifierWithKey<ResourceStr | undefined> { 537 constructor(value: ResourceStr | undefined) { 538 super(value); 539 } 540 static identity: Symbol = Symbol('textInputShowError'); 541 applyPeer(node: KNode, reset: boolean): void { 542 if (reset) { 543 getUINativeModule().textInput.resetShowError(node); 544 } else { 545 getUINativeModule().textInput.setShowError(node, this.value!); 546 } 547 } 548 checkObjectDiff(): boolean { 549 return !isBaseOrResourceEqual(this.stageValue, this.value); 550 } 551} 552class TextInputTypeModifier extends ModifierWithKey<number> { 553 constructor(value: number) { 554 super(value); 555 } 556 static identity: Symbol = Symbol('textInputType'); 557 applyPeer(node: KNode, reset: boolean): void { 558 if (reset) { 559 getUINativeModule().textInput.resetType(node); 560 } else { 561 getUINativeModule().textInput.setType(node, this.value!); 562 } 563 } 564 checkObjectDiff(): boolean { 565 return !isBaseOrResourceEqual(this.stageValue, this.value); 566 } 567} 568 569class TextInputCaretPositionModifier extends ModifierWithKey<number> { 570 constructor(value: number) { 571 super(value); 572 } 573 static identity: Symbol = Symbol('textInputCaretPosition'); 574 applyPeer(node: KNode, reset: boolean): void { 575 if (reset) { 576 getUINativeModule().textInput.resetCaretPosition(node); 577 } else { 578 getUINativeModule().textInput.setCaretPosition(node, this.value); 579 } 580 } 581 checkObjectDiff(): boolean { 582 return !isBaseOrResourceEqual(this.stageValue, this.value); 583 } 584} 585 586class TextInputCopyOptionModifier extends ModifierWithKey<number> { 587 constructor(value: number) { 588 super(value); 589 } 590 static identity: Symbol = Symbol('textInputCopyOption'); 591 applyPeer(node: KNode, reset: boolean): void { 592 if (reset) { 593 getUINativeModule().textInput.resetCopyOption(node); 594 } else { 595 getUINativeModule().textInput.setCopyOption(node, this.value); 596 } 597 } 598 checkObjectDiff(): boolean { 599 return !isBaseOrResourceEqual(this.stageValue, this.value); 600 } 601} 602 603class TextInputEnableKeyboardOnFocusModifier extends ModifierWithKey<boolean> { 604 constructor(value: boolean) { 605 super(value); 606 } 607 static identity: Symbol = Symbol('textInputEnableKeyboardOnFocus'); 608 applyPeer(node: KNode, reset: boolean): void { 609 if (reset) { 610 getUINativeModule().textInput.resetEnableKeyboardOnFocus(node); 611 } else { 612 getUINativeModule().textInput.setEnableKeyboardOnFocus(node, this.value); 613 } 614 } 615 checkObjectDiff(): boolean { 616 return !isBaseOrResourceEqual(this.stageValue, this.value); 617 } 618} 619 620class TextInputCaretStyleModifier extends ModifierWithKey<CaretStyle> { 621 constructor(value: CaretStyle) { 622 super(value); 623 } 624 static identity: Symbol = Symbol('textInputCaretStyle'); 625 applyPeer(node: KNode, reset: boolean): void { 626 if (reset) { 627 getUINativeModule().textInput.resetCaretStyle(node); 628 } else { 629 getUINativeModule().textInput.setCaretStyle(node, this.value!.width, 630 this.value.color); 631 } 632 } 633 634 checkObjectDiff(): boolean { 635 if (isObject(this.stageValue) && isObject(this.value)) { 636 return !isBaseOrResourceEqual(this.stageValue.width, this.value.width); 637 } else { 638 return true; 639 } 640 } 641} 642 643class TextInputEnterKeyTypeModifier extends ModifierWithKey<number> { 644 constructor(value: number) { 645 super(value); 646 } 647 static identity: Symbol = Symbol('textInputEnterKeyType'); 648 applyPeer(node: KNode, reset: boolean): void { 649 if (reset) { 650 getUINativeModule().textInput.resetEnterKeyType(node); 651 } else { 652 getUINativeModule().textInput.setEnterKeyType(node, this.value); 653 } 654 } 655 checkObjectDiff(): boolean { 656 return !isBaseOrResourceEqual(this.stageValue, this.value); 657 } 658} 659 660class TextInputBarStateModifier extends ModifierWithKey<number> { 661 constructor(value: number) { 662 super(value); 663 } 664 static identity: Symbol = Symbol('textInputBarState'); 665 applyPeer(node: KNode, reset: boolean): void { 666 if (reset) { 667 getUINativeModule().textInput.resetBarState(node); 668 } else { 669 getUINativeModule().textInput.setBarState(node, this.value); 670 } 671 } 672 checkObjectDiff(): boolean { 673 return !isBaseOrResourceEqual(this.stageValue, this.value); 674 } 675} 676 677class TextInputCaretColorModifier extends ModifierWithKey<ResourceColor> { 678 constructor(value: ResourceColor) { 679 super(value); 680 } 681 static identity: Symbol = Symbol('textinputCaretColor'); 682 applyPeer(node: KNode, reset: boolean): void { 683 if (reset) { 684 getUINativeModule().textInput.resetCaretColor(node); 685 } else { 686 getUINativeModule().textInput.setCaretColor(node, this.value!); 687 } 688 } 689 checkObjectDiff(): boolean { 690 return !isBaseOrResourceEqual(this.stageValue, this.value); 691 } 692} 693class TextInputFontColorModifier extends ModifierWithKey<ResourceColor> { 694 constructor(value: ResourceColor) { 695 super(value); 696 } 697 static identity: Symbol = Symbol('textInputFontColor'); 698 applyPeer(node: KNode, reset: boolean): void { 699 if (reset) { 700 getUINativeModule().textInput.resetFontColor(node); 701 } else { 702 getUINativeModule().textInput.setFontColor(node, this.value!); 703 } 704 } 705 checkObjectDiff(): boolean { 706 return !isBaseOrResourceEqual(this.stageValue, this.value); 707 } 708} 709 710 711class TextInputFontSizeModifier extends ModifierWithKey<Length> { 712 constructor(value: Length) { 713 super(value); 714 } 715 static identity: Symbol = Symbol('textInputFontSize'); 716 717 applyPeer(node: KNode, reset: boolean): void { 718 if (reset) { 719 getUINativeModule().textInput.resetFontSize(node); 720 } else { 721 getUINativeModule().textInput.setFontSize(node, this.value!); 722 } 723 } 724 725 checkObjectDiff(): boolean { 726 return !isBaseOrResourceEqual(this.stageValue, this.value); 727 } 728} 729class TextInputFontStyleModifier extends ModifierWithKey<number> { 730 constructor(value: number) { 731 super(value); 732 } 733 static identity: Symbol = Symbol('textInputFontStyle'); 734 applyPeer(node: KNode, reset: boolean): void { 735 if (reset) { 736 getUINativeModule().textInput.resetFontStyle(node); 737 } else { 738 getUINativeModule().textInput.setFontStyle(node, this.value!); 739 } 740 } 741 checkObjectDiff(): boolean { 742 return !isBaseOrResourceEqual(this.stageValue, this.value); 743 } 744} 745 746class TextInputFontWeightModifier extends ModifierWithKey<number | string> { 747 constructor(value: number | string) { 748 super(value); 749 } 750 static identity: Symbol = Symbol('textInputFontWeight'); 751 applyPeer(node: KNode, reset: boolean): void { 752 if (reset) { 753 getUINativeModule().textInput.resetFontWeight(node); 754 } else { 755 getUINativeModule().textInput.setFontWeight(node, this.value!); 756 } 757 } 758 checkObjectDiff(): boolean { 759 return !isBaseOrResourceEqual(this.stageValue, this.value); 760 } 761} 762 763class TextInputFontFamilyModifier extends ModifierWithKey<ResourceStr> { 764 constructor(value: ResourceStr) { 765 super(value); 766 } 767 static identity: Symbol = Symbol('textInputFontFamily'); 768 applyPeer(node: KNode, reset: boolean): void { 769 if (reset) { 770 getUINativeModule().textInput.resetFontFamily(node); 771 } else { 772 getUINativeModule().textInput.setFontFamily(node, this.value!); 773 } 774 } 775 776 checkObjectDiff(): boolean { 777 return !isBaseOrResourceEqual(this.stageValue, this.value); 778 } 779} 780 781class TextInputFontFeatureModifier extends ModifierWithKey<FontFeature> { 782 constructor(value: FontFeature) { 783 super(value); 784 } 785 static identity: Symbol = Symbol('textInputFontFeature'); 786 applyPeer(node: KNode, reset: boolean): void { 787 if (reset) { 788 getUINativeModule().textInput.resetFontFeature(node); 789 } else { 790 getUINativeModule().textInput.setFontFeature(node, this.value!); 791 } 792 } 793 checkObjectDiff(): boolean { 794 return !isBaseOrResourceEqual(this.stageValue, this.value); 795 } 796} 797 798class TextInputCancelButtonModifier extends ModifierWithKey<{ style?: CancelButtonStyle, icon?: IconOptions }> { 799 constructor(value: { style?: CancelButtonStyle, icon?: IconOptions }) { 800 super(value); 801 } 802 static identity = Symbol('textInputCancelButton'); 803 applyPeer(node: KNode, reset: boolean): void { 804 if (reset) { 805 getUINativeModule().textInput.resetCancelButton(node); 806 } else { 807 getUINativeModule().textInput.setCancelButton(node, this.value.style, 808 this.value.icon); 809 } 810 } 811 checkObjectDiff(): boolean { 812 return this.stageValue.style !== this.value.style || 813 !isBaseOrResourceEqual(this.stageValue.icon?.size, this.value.icon?.size) || 814 !isBaseOrResourceEqual(this.stageValue.icon?.color, this.value.icon?.color) || 815 !isBaseOrResourceEqual(this.stageValue.icon?.src, this.value.icon?.src); 816 } 817} 818 819class TextInputSelectAllModifier extends ModifierWithKey<boolean> { 820 constructor(value: boolean) { 821 super(value); 822 } 823 static identity = Symbol('textInputSelectAll'); 824 applyPeer(node: KNode, reset: boolean): void { 825 if (reset) { 826 getUINativeModule().textInput.resetSelectAll(node); 827 } 828 else { 829 getUINativeModule().textInput.setSelectAll(node, this.value); 830 } 831 } 832 checkObjectDiff(): boolean { 833 return !isBaseOrResourceEqual(this.stageValue, this.value); 834 } 835} 836 837class TextInputShowCounterModifier extends ModifierWithKey<ArkTextFieldShowCounter> { 838 constructor(value: ArkTextFieldShowCounter) { 839 super(value); 840 } 841 static identity = Symbol('textInputShowCounter'); 842 applyPeer(node: KNode, reset: boolean): void { 843 if (reset) { 844 getUINativeModule().textInput.resetShowCounter(node); 845 } 846 else { 847 getUINativeModule().textInput.setShowCounter(node, this.value.value!, this.value.highlightBorder, this.value.thresholdPercentage); 848 } 849 } 850 checkObjectDiff(): boolean { 851 return !isBaseOrResourceEqual(this.stageValue.value, this.value.value) || 852 !isBaseOrResourceEqual(this.stageValue.highlightBorder, this.value.highlightBorder) || 853 !isBaseOrResourceEqual(this.stageValue.thresholdPercentage, this.value.thresholdPercentage); 854 } 855} 856 857class TextInputOnEditChangeModifier extends ModifierWithKey<(isEditing: boolean) => void> { 858 constructor(value: (isEditing: boolean) => void) { 859 super(value); 860 } 861 static identity = Symbol('textInputOnEditChange'); 862 applyPeer(node: KNode, reset: boolean): void { 863 if (reset) { 864 getUINativeModule().textInput.resetOnEditChange(node); 865 } else { 866 getUINativeModule().textInput.setOnEditChange(node, this.value); 867 } 868 } 869} 870 871class TextInputFilterModifier extends ModifierWithKey<ArkTextInputFilter> { 872 constructor(value: ArkTextInputFilter) { 873 super(value); 874 } 875 static identity = Symbol('textInputFilter'); 876 applyPeer(node: KNode, reset: boolean): void { 877 if (reset) { 878 getUINativeModule().textInput.resetInputFilter(node); 879 } 880 else { 881 getUINativeModule().textInput.setInputFilter(node, this.value.value, this.value.error); 882 } 883 } 884 checkObjectDiff(): boolean { 885 return !isBaseOrResourceEqual(this.stageValue.value, this.value.value) || 886 !isBaseOrResourceEqual(this.stageValue.error, this.value.error); 887 } 888} 889 890class TextInputOnSubmitModifier extends ModifierWithKey<(enterKey: EnterKeyType, event: SubmitEvent) => void> { 891 constructor(value: (enterKey: EnterKeyType, event: SubmitEvent) => void) { 892 super(value); 893 } 894 static identity = Symbol('textInputOnSubmit'); 895 applyPeer(node: KNode, reset: boolean): void { 896 if (reset) { 897 getUINativeModule().textInput.resetOnSubmit(node); 898 } else { 899 getUINativeModule().textInput.setOnSubmit(node, this.value); 900 } 901 } 902} 903 904class TextInputOnChangeModifier extends ModifierWithKey<(value: ChangeValueInfo) => void> { 905 constructor(value: (value: ChangeValueInfo) => void) { 906 super(value); 907 } 908 static identity = Symbol('textInputOnChange'); 909 applyPeer(node: KNode, reset: boolean): void { 910 if (reset) { 911 getUINativeModule().textInput.resetOnChange(node); 912 } else { 913 getUINativeModule().textInput.setOnChange(node, this.value); 914 } 915 } 916} 917 918class TextInputOnTextSelectionChangeModifier extends ModifierWithKey<(selectionStart: number, selectionEnd: number) => void> { 919 constructor(value: (selectionStart: number, selectionEnd: number) => void) { 920 super(value); 921 } 922 static identity = Symbol('textInputOnTextSelectionChange'); 923 applyPeer(node: KNode, reset: boolean): void { 924 if (reset) { 925 getUINativeModule().textInput.resetOnTextSelectionChange(node); 926 } else { 927 getUINativeModule().textInput.setOnTextSelectionChange(node, this.value); 928 } 929 } 930} 931 932class TextInputOnContentScrollModifier extends ModifierWithKey<(totalOffsetX: number, totalOffsetY: number) => void> { 933 constructor(value: (totalOffsetX: number, totalOffsetY: number) => void) { 934 super(value); 935 } 936 static identity = Symbol('textInputOnContentScroll'); 937 applyPeer(node: KNode, reset: boolean): void { 938 if (reset) { 939 getUINativeModule().textInput.resetOnContentScroll(node); 940 } else { 941 getUINativeModule().textInput.setOnContentScroll(node, this.value); 942 } 943 } 944} 945 946class TextInputOnCopyModifier extends ModifierWithKey<(value: string) => void> { 947 constructor(value: (value: string) => void) { 948 super(value); 949 } 950 static identity = Symbol('textInputOnCopy'); 951 applyPeer(node: KNode, reset: boolean): void { 952 if (reset) { 953 getUINativeModule().textInput.resetOnCopy(node); 954 } else { 955 getUINativeModule().textInput.setOnCopy(node, this.value); 956 } 957 } 958} 959 960class TextInputOnCutModifier extends ModifierWithKey<(value: string) => void> { 961 constructor(value: (value: string) => void) { 962 super(value); 963 } 964 static identity = Symbol('textInputOnCut'); 965 applyPeer(node: KNode, reset: boolean): void { 966 if (reset) { 967 getUINativeModule().textInput.resetOnCut(node); 968 } else { 969 getUINativeModule().textInput.setOnCut(node, this.value); 970 } 971 } 972} 973 974class TextInputOnPasteModifier extends ModifierWithKey<(value: string, event: PasteEvent) => void> { 975 constructor(value: (value: string, event: PasteEvent) => void) { 976 super(value); 977 } 978 static identity = Symbol('textInputOnPaste'); 979 applyPeer(node: KNode, reset: boolean): void { 980 if (reset) { 981 getUINativeModule().textInput.resetOnPaste(node); 982 } else { 983 getUINativeModule().textInput.setOnPaste(node, this.value); 984 } 985 } 986} 987 988class TextInputPaddingModifier extends ModifierWithKey<ArkPadding> { 989 constructor(value: ArkPadding) { 990 super(value); 991 } 992 static identity: Symbol = Symbol('textInputPadding'); 993 applyPeer(node: KNode, reset: boolean): void { 994 if (reset) { 995 getUINativeModule().textInput.resetPadding(node); 996 } 997 else { 998 getUINativeModule().textInput.setPadding(node, this.value.top, this.value.right, this.value.bottom, this.value.left); 999 } 1000 } 1001 checkObjectDiff(): boolean { 1002 return !isBaseOrResourceEqual(this.stageValue.top, this.value.top) || 1003 !isBaseOrResourceEqual(this.stageValue.right, this.value.right) || 1004 !isBaseOrResourceEqual(this.stageValue.bottom, this.value.bottom) || 1005 !isBaseOrResourceEqual(this.stageValue.left, this.value.left); 1006 } 1007} 1008 1009class TextInputContentTypeModifier extends ModifierWithKey<ContentType> { 1010 constructor(value: ContentType) { 1011 super(value); 1012 } 1013 static identity: Symbol = Symbol('textInputContentType'); 1014 applyPeer(node: KNode, reset: boolean): void { 1015 if (reset) { 1016 getUINativeModule().textInput.resetContentType(node); 1017 } 1018 else { 1019 getUINativeModule().textInput.setContentType(node, this.value); 1020 } 1021 } 1022} 1023 1024class TextInputTextModifier extends ModifierWithKey<ResourceStr> { 1025 constructor(value: ResourceStr) { 1026 super(value); 1027 } 1028 static identity: Symbol = Symbol('textInputText'); 1029 applyPeer(node: KNode, reset: boolean): void { 1030 if (reset) { 1031 getUINativeModule().textInput.resetText(node); 1032 } else { 1033 getUINativeModule().textInput.setText(node, this.value!); 1034 } 1035 } 1036 1037 checkObjectDiff(): boolean { 1038 return !isBaseOrResourceEqual(this.stageValue, this.value); 1039 } 1040} 1041 1042class TextInputBorderModifier extends ModifierWithKey<ArkBorder> { 1043 constructor(value: ArkBorder) { 1044 super(value); 1045 } 1046 static identity: Symbol = Symbol('textInputBorder'); 1047 applyPeer(node: KNode, reset: boolean): void { 1048 if (reset) { 1049 getUINativeModule().textInput.resetBorder(node); 1050 } else { 1051 getUINativeModule().textInput.setBorder(node, 1052 this.value.arkWidth.left, this.value.arkWidth.right, this.value.arkWidth.top, this.value.arkWidth.bottom, 1053 this.value.arkColor.leftColor, this.value.arkColor.rightColor, this.value.arkColor.topColor, this.value.arkColor.bottomColor, 1054 this.value.arkRadius.topLeft, this.value.arkRadius.topRight, this.value.arkRadius.bottomLeft, this.value.arkRadius.bottomRight, 1055 this.value.arkStyle.top, this.value.arkStyle.right, this.value.arkStyle.bottom, this.value.arkStyle.left, 1056 this.value.arkDashGap.left, this.value.arkDashGap.right, this.value.arkDashGap.top, this.value.arkDashGap.bottom, 1057 this.value.arkDashWidth.left, this.value.arkDashWidth.right, this.value.arkDashWidth.top, this.value.arkDashWidth.bottom, 1058 this.value.arkDashGap.start, this.value.arkDashGap.end, this.value.arkDashWidth.start, this.value.arkDashWidth.end); 1059 } 1060 } 1061 checkObjectDiff(): boolean { 1062 return this.value.checkObjectDiff(this.stageValue); 1063 } 1064} 1065 1066class TextInputBorderWidthModifier extends ModifierWithKey<Length | EdgeWidths> { 1067 constructor(value: Length | EdgeWidths | LocalizedEdgeWidths) { 1068 super(value); 1069 } 1070 static identity: Symbol = Symbol('textInputBorderWidth'); 1071 applyPeer(node: KNode, reset: boolean): void { 1072 if (reset) { 1073 getUINativeModule().textInput.resetBorderWidth(node); 1074 } else { 1075 if (isNumber(this.value) || isString(this.value) || isResource(this.value)) { 1076 getUINativeModule().textInput.setBorderWidth(node, this.value, this.value, this.value, this.value); 1077 } else { 1078 if ((Object.keys(this.value).indexOf('start') >= 0) || 1079 (Object.keys(this.value).indexOf('end') >= 0)) { 1080 getUINativeModule().textInput.setBorderWidth(node, 1081 (this.value as LocalizedEdgeWidths).top, 1082 (this.value as LocalizedEdgeWidths).end, 1083 (this.value as LocalizedEdgeWidths).bottom, 1084 (this.value as LocalizedEdgeWidths).start); 1085 } else { 1086 getUINativeModule().textInput.setBorderWidth(node, 1087 (this.value as EdgeWidths).top, 1088 (this.value as EdgeWidths).right, 1089 (this.value as EdgeWidths).bottom, 1090 (this.value as EdgeWidths).left); 1091 } 1092 } 1093 } 1094 } 1095 1096 checkObjectDiff(): boolean { 1097 if (isResource(this.stageValue) && isResource(this.value)) { 1098 return !isResourceEqual(this.stageValue, this.value); 1099 } else if (!isResource(this.stageValue) && !isResource(this.value)) { 1100 if ((Object.keys(this.value).indexOf('start') >= 0) || 1101 (Object.keys(this.value).indexOf('end') >= 0)) { 1102 return !((this.stageValue as LocalizedEdgeWidths).start === (this.value as LocalizedEdgeWidths).start && 1103 (this.stageValue as LocalizedEdgeWidths).end === (this.value as LocalizedEdgeWidths).end && 1104 (this.stageValue as LocalizedEdgeWidths).top === (this.value as LocalizedEdgeWidths).top && 1105 (this.stageValue as LocalizedEdgeWidths).bottom === (this.value as LocalizedEdgeWidths).bottom); 1106 } 1107 return !((this.stageValue as EdgeWidths).left === (this.value as EdgeWidths).left && 1108 (this.stageValue as EdgeWidths).right === (this.value as EdgeWidths).right && 1109 (this.stageValue as EdgeWidths).top === (this.value as EdgeWidths).top && 1110 (this.stageValue as EdgeWidths).bottom === (this.value as EdgeWidths).bottom); 1111 } else { 1112 return true; 1113 } 1114 } 1115} 1116 1117class TextInputBorderColorModifier extends ModifierWithKey<ResourceColor | EdgeColors> { 1118 constructor(value: ResourceColor | EdgeColors | LocalizedEdgeColors) { 1119 super(value); 1120 } 1121 static identity: Symbol = Symbol('textInputBorderColor'); 1122 applyPeer(node: KNode, reset: boolean): void { 1123 if (reset) { 1124 getUINativeModule().textInput.resetBorderColor(node); 1125 } else { 1126 const valueType: string = typeof this.value; 1127 if (valueType === 'number' || valueType === 'string' || isResource(this.value)) { 1128 getUINativeModule().textInput.setBorderColor(node, this.value, this.value, this.value, this.value); 1129 } else { 1130 if ((Object.keys(this.value).indexOf('start') >= 0) || 1131 (Object.keys(this.value).indexOf('end') >= 0)) { 1132 getUINativeModule().textInput.setBorderColor(node, 1133 (this.value as LocalizedEdgeColors).top, 1134 (this.value as LocalizedEdgeColors).end, 1135 (this.value as LocalizedEdgeColors).bottom, 1136 (this.value as LocalizedEdgeColors).start, 1137 true); 1138 } else { 1139 getUINativeModule().textInput.setBorderColor(node, 1140 (this.value as EdgeColors).top, 1141 (this.value as EdgeColors).right, 1142 (this.value as EdgeColors).bottom, 1143 (this.value as EdgeColors).left, 1144 false); 1145 } 1146 } 1147 1148 } 1149 } 1150 1151 checkObjectDiff(): boolean { 1152 if (isResource(this.stageValue) && isResource(this.value)) { 1153 return !isResourceEqual(this.stageValue, this.value); 1154 } else if (!isResource(this.stageValue) && !isResource(this.value)) { 1155 if ((Object.keys(this.value).indexOf('start') >= 0) || 1156 (Object.keys(this.value).indexOf('end') >= 0)) { 1157 return !((this.stageValue as LocalizedEdgeColors).start === (this.value as LocalizedEdgeColors).start && 1158 (this.stageValue as LocalizedEdgeColors).end === (this.value as LocalizedEdgeColors).end && 1159 (this.stageValue as LocalizedEdgeColors).top === (this.value as LocalizedEdgeColors).top && 1160 (this.stageValue as LocalizedEdgeColors).bottom === (this.value as LocalizedEdgeColors).bottom); 1161 } 1162 return !((this.stageValue as EdgeColors).left === (this.value as EdgeColors).left && 1163 (this.stageValue as EdgeColors).right === (this.value as EdgeColors).right && 1164 (this.stageValue as EdgeColors).top === (this.value as EdgeColors).top && 1165 (this.stageValue as EdgeColors).bottom === (this.value as EdgeColors).bottom); 1166 } else { 1167 return true; 1168 } 1169 } 1170} 1171 1172class TextInputBorderStyleModifier extends ModifierWithKey<BorderStyle | EdgeStyles> { 1173 constructor(value: BorderStyle | EdgeStyles) { 1174 super(value); 1175 } 1176 static identity: Symbol = Symbol('textInputBorderStyle'); 1177 applyPeer(node: KNode, reset: boolean): void { 1178 if (reset) { 1179 getUINativeModule().textInput.resetBorderStyle(node); 1180 } else { 1181 let type: boolean; 1182 let style: BorderStyle; 1183 let top: BorderStyle; 1184 let right: BorderStyle; 1185 let bottom: BorderStyle; 1186 let left: BorderStyle; 1187 if (isNumber(this.value)) { 1188 style = this.value as BorderStyle; 1189 type = true; 1190 } else if (isObject(this.value)) { 1191 top = (this.value as EdgeStyles)?.top; 1192 right = (this.value as EdgeStyles)?.right; 1193 bottom = (this.value as EdgeStyles)?.bottom; 1194 left = (this.value as EdgeStyles)?.left; 1195 type = true; 1196 } 1197 if (type === true) { 1198 getUINativeModule().textInput.setBorderStyle(node, type, style, top, right, bottom, left); 1199 } else { 1200 getUINativeModule().textInput.resetBorderStyle(node); 1201 } 1202 } 1203 } 1204 checkObjectDiff(): boolean { 1205 return !((this.value as EdgeStyles)?.top === (this.stageValue as EdgeStyles)?.top && 1206 (this.value as EdgeStyles)?.right === (this.stageValue as EdgeStyles)?.right && 1207 (this.value as EdgeStyles)?.bottom === (this.stageValue as EdgeStyles)?.bottom && 1208 (this.value as EdgeStyles)?.left === (this.stageValue as EdgeStyles)?.left); 1209 } 1210} 1211 1212class TextInputBorderRadiusModifier extends ModifierWithKey<Length | BorderRadiuses> { 1213 constructor(value: Length | BorderRadiuses | LocalizedBorderRadius) { 1214 super(value); 1215 } 1216 static identity: Symbol = Symbol('textInputBorderRadius'); 1217 applyPeer(node: KNode, reset: boolean): void { 1218 if (reset) { 1219 getUINativeModule().textInput.resetBorderRadius(node); 1220 } else { 1221 if (isNumber(this.value) || isString(this.value) || isResource(this.value)) { 1222 getUINativeModule().textInput.setBorderRadius(node, this.value, this.value, this.value, this.value); 1223 } else { 1224 if ((Object.keys(this.value).indexOf('topStart') >= 0) || 1225 (Object.keys(this.value).indexOf('topEnd') >= 0) || 1226 (Object.keys(this.value).indexOf('bottomStart') >= 0) || 1227 (Object.keys(this.value).indexOf('bottomEnd') >= 0)) { 1228 getUINativeModule().textInput.setBorderRadius(node, 1229 (this.value as LocalizedBorderRadius).topStart, 1230 (this.value as LocalizedBorderRadius).topEnd, 1231 (this.value as LocalizedBorderRadius).bottomStart, 1232 (this.value as LocalizedBorderRadius).bottomEnd); 1233 } else { 1234 getUINativeModule().textInput.setBorderRadius(node, 1235 (this.value as BorderRadiuses).topLeft, 1236 (this.value as BorderRadiuses).topRight, 1237 (this.value as BorderRadiuses).bottomLeft, 1238 (this.value as BorderRadiuses).bottomRight); 1239 } 1240 } 1241 } 1242 } 1243 1244 checkObjectDiff(): boolean { 1245 if (isResource(this.stageValue) && isResource(this.value)) { 1246 return !isResourceEqual(this.stageValue, this.value); 1247 } else if (!isResource(this.stageValue) && !isResource(this.value)) { 1248 if ((Object.keys(this.value).indexOf('topStart') >= 0) || 1249 (Object.keys(this.value).indexOf('topEnd') >= 0) || 1250 (Object.keys(this.value).indexOf('bottomStart') >= 0) || 1251 (Object.keys(this.value).indexOf('bottomEnd') >= 0)) { 1252 return !((this.stageValue as LocalizedBorderRadius).topStart === (this.value as LocalizedBorderRadius).topStart && 1253 (this.stageValue as LocalizedBorderRadius).topEnd === (this.value as LocalizedBorderRadius).topEnd && 1254 (this.stageValue as LocalizedBorderRadius).bottomStart === (this.value as LocalizedBorderRadius).bottomStart && 1255 (this.stageValue as LocalizedBorderRadius).bottomEnd === (this.value as LocalizedBorderRadius).bottomEnd); 1256 } 1257 return !((this.stageValue as BorderRadiuses).topLeft === (this.value as BorderRadiuses).topLeft && 1258 (this.stageValue as BorderRadiuses).topRight === (this.value as BorderRadiuses).topRight && 1259 (this.stageValue as BorderRadiuses).bottomLeft === (this.value as BorderRadiuses).bottomLeft && 1260 (this.stageValue as BorderRadiuses).bottomRight === (this.value as BorderRadiuses).bottomRight); 1261 } else { 1262 return true; 1263 } 1264 } 1265} 1266 1267 1268class TextInputBackgroundColorModifier extends ModifierWithKey<ResourceColor> { 1269 constructor(value: ResourceColor) { 1270 super(value); 1271 } 1272 static identity: Symbol = Symbol('textInputBackgroundColor'); 1273 applyPeer(node: KNode, reset: boolean): void { 1274 if (reset) { 1275 getUINativeModule().textInput.resetBackgroundColor(node); 1276 } else { 1277 getUINativeModule().textInput.setBackgroundColor(node, this.value); 1278 } 1279 } 1280} 1281 1282class TextInputPlaceholderModifier extends ModifierWithKey<ResourceStr> { 1283 constructor(value: ResourceStr) { 1284 super(value); 1285 } 1286 static identity: Symbol = Symbol('textInputPlaceholder'); 1287 applyPeer(node: KNode, reset: boolean): void { 1288 if (reset) { 1289 getUINativeModule().textInput.resetPlaceholder(node); 1290 } else { 1291 getUINativeModule().textInput.setPlaceholder(node, this.value!); 1292 } 1293 } 1294 1295 checkObjectDiff(): boolean { 1296 return !isBaseOrResourceEqual(this.stageValue, this.value); 1297 } 1298} 1299 1300 1301class TextInputMarginModifier extends ModifierWithKey<ArkPadding> { 1302 constructor(value: ArkPadding) { 1303 super(value); 1304 } 1305 static identity: Symbol = Symbol('textInputMargin'); 1306 applyPeer(node: KNode, reset: boolean): void { 1307 if (reset) { 1308 getUINativeModule().textInput.resetMargin(node); 1309 } else { 1310 getUINativeModule().textInput.setMargin(node, this.value.top, 1311 this.value.right, this.value.bottom, this.value.left); 1312 } 1313 } 1314 1315 checkObjectDiff(): boolean { 1316 return !isBaseOrResourceEqual(this.stageValue.top, this.value.top) || 1317 !isBaseOrResourceEqual(this.stageValue.right, this.value.right) || 1318 !isBaseOrResourceEqual(this.stageValue.bottom, this.value.bottom) || 1319 !isBaseOrResourceEqual(this.stageValue.left, this.value.left); 1320 } 1321} 1322 1323class TextInputControllerModifier extends ModifierWithKey<TextInputController> { 1324 constructor(value: TextInputController) { 1325 super(value); 1326 } 1327 static identity: Symbol = Symbol('textInputController'); 1328 applyPeer(node: KNode, reset: boolean): void { 1329 if (reset) { 1330 getUINativeModule().textInput.resetController(node); 1331 } else { 1332 getUINativeModule().textInput.setController(node, this.value!); 1333 } 1334 } 1335 1336} 1337 1338class TextInputOnWillChangeModifier extends ModifierWithKey<Callback<ChangeValueInfo, boolean>> { 1339 constructor(value: Callback<ChangeValueInfo, boolean>) { 1340 super(value); 1341 } 1342 static identity = Symbol('textInputOnWillChange'); 1343 applyPeer(node: KNode, reset: boolean): void { 1344 if (reset) { 1345 getUINativeModule().textInput.resetOnWillChange(node); 1346 } else { 1347 getUINativeModule().textInput.setOnWillChange(node, this.value); 1348 } 1349 } 1350} 1351 1352class TextInputOnWillInsertModifier extends ModifierWithKey<Callback<InsertValue, boolean>> { 1353 constructor(value: Callback<InsertValue, boolean>) { 1354 super(value); 1355 } 1356 static identity = Symbol('textInputOnWillInsert'); 1357 applyPeer(node: KNode, reset: boolean): void { 1358 if (reset) { 1359 getUINativeModule().textInput.resetOnWillInsert(node); 1360 } else { 1361 getUINativeModule().textInput.setOnWillInsert(node, this.value); 1362 } 1363 } 1364} 1365 1366class TextInputOnDidInsertModifier extends ModifierWithKey<Callback<InsertValue>> { 1367 constructor(value: Callback<InsertValue>) { 1368 super(value); 1369 } 1370 static identity = Symbol('textInputOnDidInsert'); 1371 applyPeer(node: KNode, reset: boolean): void { 1372 if (reset) { 1373 getUINativeModule().textInput.resetOnDidInsert(node); 1374 } else { 1375 getUINativeModule().textInput.setOnDidInsert(node, this.value); 1376 } 1377 } 1378} 1379 1380class TextInputOnWillDeleteModifier extends ModifierWithKey<Callback<DeleteValue, boolean>> { 1381 constructor(value: Callback<DeleteValue, boolean>) { 1382 super(value); 1383 } 1384 static identity = Symbol('textInputOnWillDelete'); 1385 applyPeer(node: KNode, reset: boolean): void { 1386 if (reset) { 1387 getUINativeModule().textInput.resetOnWillDelete(node); 1388 } else { 1389 getUINativeModule().textInput.setOnWillDelete(node, this.value); 1390 } 1391 } 1392} 1393 1394class TextInputOnDidDeleteModifier extends ModifierWithKey<Callback<DeleteValue>> { 1395 constructor(value: Callback<DeleteValue>) { 1396 super(value); 1397 } 1398 static identity = Symbol('textInputOnDidDelete'); 1399 applyPeer(node: KNode, reset: boolean): void { 1400 if (reset) { 1401 getUINativeModule().textInput.resetOnDidDelete(node); 1402 } else { 1403 getUINativeModule().textInput.setOnDidDelete(node, this.value); 1404 } 1405 } 1406} 1407 1408class TextInputEnablePreviewTextModifier extends ModifierWithKey<boolean> { 1409 constructor(value: boolean) { 1410 super(value); 1411 } 1412 static identity: Symbol = Symbol('textInputEnablePreviewText'); 1413 applyPeer(node: KNode, reset: boolean): void { 1414 if (reset) { 1415 getUINativeModule().textInput.resetEnablePreviewText(node); 1416 } else { 1417 getUINativeModule().textInput.setEnablePreviewText(node, this.value!); 1418 } 1419 } 1420 checkObjectDiff(): boolean { 1421 return !isBaseOrResourceEqual(this.stageValue, this.value); 1422 } 1423} 1424 1425class TextInputEditMenuOptionsModifier extends ModifierWithKey<EditMenuOptions> { 1426 constructor(value: EditMenuOptions) { 1427 super(value); 1428 } 1429 static identity: Symbol = Symbol('textEditMenuOptions'); 1430 applyPeer(node: KNode, reset: boolean): void { 1431 if (reset) { 1432 getUINativeModule().textInput.resetSelectionMenuOptions(node); 1433 } else { 1434 getUINativeModule().textInput.setSelectionMenuOptions(node, this.value); 1435 } 1436 } 1437} 1438 1439class TextInputEnableHapticFeedbackModifier extends ModifierWithKey<boolean> { 1440 constructor(value: boolean) { 1441 super(value); 1442 } 1443 static identity: Symbol = Symbol('textInputEnableHapticFeedback'); 1444 applyPeer(node: KNode, reset: boolean): void { 1445 if (reset) { 1446 getUINativeModule().textInput.resetEnableHapticFeedback(node); 1447 } else { 1448 getUINativeModule().textInput.setEnableHapticFeedback(node, this.value!); 1449 } 1450 } 1451 checkObjectDiff(): boolean { 1452 return !isBaseOrResourceEqual(this.stageValue, this.value); 1453 } 1454} 1455 1456class TextInputEllipsisModeModifier extends ModifierWithKey<EllipsisMode> { 1457 constructor(value: EllipsisMode) { 1458 super(value); 1459 } 1460 static identity: Symbol = Symbol('textInputEllipsisMode'); 1461 applyPeer(node: KNode, reset: boolean): void { 1462 if (reset) { 1463 getUINativeModule().textInput.resetEllipsisMode(node); 1464 } else { 1465 getUINativeModule().textInput.setEllipsisMode(node, this.value!); 1466 } 1467 } 1468 checkObjectDiff(): boolean { 1469 return !isBaseOrResourceEqual(this.stageValue, this.value); 1470 } 1471} 1472 1473interface TextInputParam { 1474 placeholder?: ResourceStr; 1475 text?: ResourceStr; 1476 controller?: TextInputController; 1477} 1478 1479class ArkTextInputComponent extends ArkComponent implements CommonMethod<TextInputAttribute> { 1480 constructor(nativePtr: KNode, classType?: ModifierType) { 1481 super(nativePtr, classType); 1482 } 1483 initialize(value: Object[]): TextInputAttribute { 1484 if (value[0] !== undefined) { 1485 this.setPlaceholder((value[0] as TextInputParam).placeholder); 1486 this.setText((value[0] as TextInputParam).text); 1487 this.setController((value[0] as TextInputParam).controller); 1488 } 1489 return this; 1490 } 1491 setText(value: ResourceStr): TextInputAttribute { 1492 modifierWithKey(this._modifiersWithKeys, TextInputTextModifier.identity, 1493 TextInputTextModifier, value); 1494 return this; 1495 } 1496 setPlaceholder(value: ResourceStr): TextInputAttribute { 1497 modifierWithKey(this._modifiersWithKeys, TextInputPlaceholderModifier.identity, 1498 TextInputPlaceholderModifier, value); 1499 return this; 1500 } 1501 setController(value: TextInputController): TextInputAttribute { 1502 modifierWithKey(this._modifiersWithKeys, TextInputControllerModifier.identity, 1503 TextInputControllerModifier, value); 1504 return this; 1505 } 1506 cancelButton(value: { style?: CancelButtonStyle, icon?: IconOptions }): TextInputAttribute { 1507 modifierWithKey(this._modifiersWithKeys, TextInputCancelButtonModifier.identity, 1508 TextInputCancelButtonModifier, value); 1509 return this; 1510 } 1511 selectAll(value: boolean): TextInputAttribute { 1512 modifierWithKey(this._modifiersWithKeys, TextInputSelectAllModifier.identity, 1513 TextInputSelectAllModifier, value); 1514 return this; 1515 } 1516 enableAutoFill(value: boolean): TextInputAttribute { 1517 modifierWithKey(this._modifiersWithKeys, TextInputEnableAutoFillModifier.identity, 1518 TextInputEnableAutoFillModifier, value); 1519 return this; 1520 } 1521 passwordRules(value: string): TextInputAttribute { 1522 modifierWithKey(this._modifiersWithKeys, TextInputPasswordRulesModifier.identity, 1523 TextInputPasswordRulesModifier, value); 1524 return this; 1525 } 1526 showCounter(value: boolean, options?: InputCounterOptions): TextInputAttribute { 1527 let arkValue: ArkTextFieldShowCounter = new ArkTextFieldShowCounter(); 1528 arkValue.value = value; 1529 arkValue.highlightBorder = options?.highlightBorder; 1530 arkValue.thresholdPercentage = options?.thresholdPercentage; 1531 modifierWithKey(this._modifiersWithKeys, TextInputShowCounterModifier.identity, 1532 TextInputShowCounterModifier, arkValue); 1533 return this; 1534 } 1535 1536 type(value: InputType): TextInputAttribute { 1537 1538 modifierWithKey(this._modifiersWithKeys, TextInputTypeModifier.identity, 1539 TextInputTypeModifier, value); 1540 return this; 1541 } 1542 1543 placeholderColor(value: ResourceColor): TextInputAttribute { 1544 modifierWithKey(this._modifiersWithKeys, TextInputPlaceholderColorModifier.identity, 1545 TextInputPlaceholderColorModifier, value); 1546 return this; 1547 } 1548 1549 placeholderFont(value?: Font): TextInputAttribute { 1550 modifierWithKey(this._modifiersWithKeys, TextInputPlaceholderFontModifier.identity, 1551 TextInputPlaceholderFontModifier, value); 1552 return this; 1553 } 1554 enterKeyType(value: EnterKeyType): TextInputAttribute { 1555 modifierWithKey(this._modifiersWithKeys, TextInputEnterKeyTypeModifier.identity, 1556 TextInputEnterKeyTypeModifier, value); 1557 return this; 1558 } 1559 caretColor(value: ResourceColor): TextInputAttribute { 1560 modifierWithKey(this._modifiersWithKeys, TextInputCaretColorModifier.identity, 1561 TextInputCaretColorModifier, value); 1562 return this; 1563 } 1564 onEditChanged(callback: (isEditing: boolean) => void): TextInputAttribute { 1565 modifierWithKey(this._modifiersWithKeys, TextInputOnEditChangeModifier.identity, 1566 TextInputOnEditChangeModifier, callback); 1567 return this; 1568 } 1569 onEditChange(callback: (isEditing: boolean) => void): TextInputAttribute { 1570 modifierWithKey(this._modifiersWithKeys, TextInputOnEditChangeModifier.identity, 1571 TextInputOnEditChangeModifier, callback); 1572 return this; 1573 } 1574 onSubmit(callback: (enterKey: EnterKeyType, event: SubmitEvent) => void): TextInputAttribute { 1575 modifierWithKey(this._modifiersWithKeys, TextInputOnSubmitModifier.identity, 1576 TextInputOnSubmitModifier, callback); 1577 return this; 1578 } 1579 onChange(callback: (value: ChangeValueInfo) => void): TextInputAttribute { 1580 modifierWithKey(this._modifiersWithKeys, TextInputOnChangeModifier.identity, 1581 TextInputOnChangeModifier, callback); 1582 return this; 1583 } 1584 onTextSelectionChange(callback: (selectionStart: number, selectionEnd: number) => void): TextInputAttribute { 1585 modifierWithKey(this._modifiersWithKeys, TextInputOnTextSelectionChangeModifier.identity, 1586 TextInputOnTextSelectionChangeModifier, callback); 1587 return this; 1588 } 1589 onContentScroll(callback: (totalOffsetX: number, totalOffsetY: number) => void): TextInputAttribute { 1590 modifierWithKey(this._modifiersWithKeys, TextInputOnContentScrollModifier.identity, 1591 TextInputOnContentScrollModifier, callback); 1592 return this; 1593 } 1594 maxLength(value: number): TextInputAttribute { 1595 modifierWithKey(this._modifiersWithKeys, TextInputMaxLengthModifier.identity, 1596 TextInputMaxLengthModifier, value); 1597 return this; 1598 } 1599 fontColor(value: ResourceColor): TextInputAttribute { 1600 modifierWithKey(this._modifiersWithKeys, TextInputFontColorModifier.identity, 1601 TextInputFontColorModifier, value); 1602 return this; 1603 } 1604 1605 fontSize(value: Length): TextInputAttribute { 1606 modifierWithKey(this._modifiersWithKeys, TextInputFontSizeModifier.identity, 1607 TextInputFontSizeModifier, value); 1608 return this; 1609 } 1610 fontStyle(value: FontStyle): TextInputAttribute { 1611 modifierWithKey(this._modifiersWithKeys, TextInputFontStyleModifier.identity, 1612 TextInputFontStyleModifier, value); 1613 return this; 1614 } 1615 fontWeight(value: number | FontWeight | string): TextInputAttribute { 1616 modifierWithKey(this._modifiersWithKeys, TextInputFontWeightModifier.identity, 1617 TextInputFontWeightModifier, value); 1618 return this; 1619 } 1620 1621 fontFamily(value: ResourceStr): TextInputAttribute { 1622 modifierWithKey(this._modifiersWithKeys, TextInputFontFamilyModifier.identity, 1623 TextInputFontFamilyModifier, value); 1624 return this; 1625 } 1626 inputFilter(value: ResourceStr, error?: (value: string) => void): TextInputAttribute { 1627 let arkValue = new ArkTextInputFilter(); 1628 arkValue.value = value; 1629 arkValue.error = error; 1630 modifierWithKey(this._modifiersWithKeys, TextInputFilterModifier.identity, 1631 TextInputFilterModifier, arkValue); 1632 return this; 1633 } 1634 onCopy(callback: (value: string) => void): TextInputAttribute { 1635 modifierWithKey(this._modifiersWithKeys, TextInputOnCopyModifier.identity, 1636 TextInputOnCopyModifier, callback); 1637 return this; 1638 } 1639 onCut(callback: (value: string) => void): TextInputAttribute { 1640 modifierWithKey(this._modifiersWithKeys, TextInputOnCutModifier.identity, 1641 TextInputOnCutModifier, callback); 1642 return this; 1643 } 1644 onPaste(callback: (value: string) => void): TextInputAttribute { 1645 modifierWithKey(this._modifiersWithKeys, TextInputOnPasteModifier.identity, 1646 TextInputOnPasteModifier, callback); 1647 return this; 1648 } 1649 copyOption(value: CopyOptions): TextInputAttribute { 1650 modifierWithKey(this._modifiersWithKeys, TextInputCopyOptionModifier.identity, 1651 TextInputCopyOptionModifier, value); 1652 return this; 1653 } 1654 1655 showPasswordIcon(value: boolean): TextInputAttribute { 1656 modifierWithKey(this._modifiersWithKeys, TextInputShowPasswordIconModifier.identity, 1657 TextInputShowPasswordIconModifier, value); 1658 return this; 1659 } 1660 showPassword(value: boolean): TextInputAttribute { 1661 modifierWithKey(this._modifiersWithKeys, TextInputShowPasswordModifier.identity, 1662 TextInputShowPasswordModifier, value); 1663 return this; 1664 } 1665 textAlign(value: TextAlign): TextInputAttribute { 1666 modifierWithKey(this._modifiersWithKeys, TextInputTextAlignModifier.identity, 1667 TextInputTextAlignModifier, value); 1668 return this; 1669 } 1670 style(value: TextInputStyle | TextContentStyle): TextInputAttribute { 1671 modifierWithKey(this._modifiersWithKeys, TextInputStyleModifier.identity, 1672 TextInputStyleModifier, value); 1673 return this; 1674 } 1675 caretStyle(value: CaretStyle) { 1676 modifierWithKey(this._modifiersWithKeys, TextInputCaretStyleModifier.identity, 1677 TextInputCaretStyleModifier, value); 1678 return this; 1679 } 1680 1681 selectedBackgroundColor(value: ResourceColor): TextInputAttribute { 1682 modifierWithKey(this._modifiersWithKeys, TextInputSelectedBackgroundColorModifier.identity, 1683 TextInputSelectedBackgroundColorModifier, value); 1684 return this; 1685 } 1686 caretPosition(value: number): TextInputAttribute { 1687 modifierWithKey(this._modifiersWithKeys, TextInputCaretPositionModifier.identity, 1688 TextInputCaretPositionModifier, value); 1689 return this; 1690 } 1691 enableKeyboardOnFocus(value: boolean): TextInputAttribute { 1692 modifierWithKey(this._modifiersWithKeys, TextInputEnableKeyboardOnFocusModifier.identity, 1693 TextInputEnableKeyboardOnFocusModifier, value); 1694 return this; 1695 } 1696 1697 passwordIcon(value: PasswordIcon): TextInputAttribute { 1698 modifierWithKey(this._modifiersWithKeys, TextInputPasswordIconModifier.identity, 1699 TextInputPasswordIconModifier, value); 1700 return this; 1701 } 1702 showError(value: ResourceStr | undefined): TextInputAttribute { 1703 modifierWithKey(this._modifiersWithKeys, TextInputShowErrorModifier.identity, 1704 TextInputShowErrorModifier, value); 1705 return this; 1706 } 1707 showUnit(event: () => void): TextInputAttribute { 1708 throw new Error('Method not implemented.'); 1709 } 1710 showUnderline(value: boolean): TextInputAttribute { 1711 modifierWithKey(this._modifiersWithKeys, TextInputShowUnderlineModifier.identity, 1712 TextInputShowUnderlineModifier, value); 1713 return this; 1714 } 1715 selectionMenuHidden(value: boolean): TextInputAttribute { 1716 modifierWithKey(this._modifiersWithKeys, TextInputSelectionMenuHiddenModifier.identity, TextInputSelectionMenuHiddenModifier, value); 1717 return this; 1718 } 1719 barState(value: BarState): TextInputAttribute { 1720 modifierWithKey(this._modifiersWithKeys, TextInputBarStateModifier.identity, TextInputBarStateModifier, value); 1721 return this; 1722 } 1723 maxLines(value: number): TextInputAttribute { 1724 modifierWithKey(this._modifiersWithKeys, TextInputMaxLinesModifier.identity, TextInputMaxLinesModifier, value); 1725 return this; 1726 } 1727 fontFeature(value: FontFeature): TextInputAttribute { 1728 modifierWithKey(this._modifiersWithKeys, TextInputFontFeatureModifier.identity, TextInputFontFeatureModifier, value); 1729 return this; 1730 } 1731 customKeyboard(event: () => void): TextInputAttribute { 1732 throw new Error('Method not implemented.'); 1733 } 1734 decoration(value: { type: TextDecorationType; color?: ResourceColor; style?: TextDecorationStyle }): TextInputAttribute { 1735 modifierWithKey(this._modifiersWithKeys, TextInputDecorationModifier.identity, TextInputDecorationModifier, value); 1736 return this; 1737 } 1738 letterSpacing(value: number | string): this { 1739 modifierWithKey(this._modifiersWithKeys, TextInputLetterSpacingModifier.identity, TextInputLetterSpacingModifier, value); 1740 return this; 1741 } 1742 lineHeight(value: number | string | Resource): this { 1743 modifierWithKey(this._modifiersWithKeys, TextInputLineHeightModifier.identity, TextInputLineHeightModifier, value); 1744 return this; 1745 } 1746 halfLeading(value: boolean): this { 1747 modifierWithKey(this._modifiersWithKeys, TextInputHalfLeadingModifier.identity, TextInputHalfLeadingModifier, value); 1748 return this; 1749 } 1750 underlineColor(value: ResourceColor | UnderlineColor | undefined): TextInputAttribute { 1751 modifierWithKey(this._modifiersWithKeys, TextInputUnderlineColorModifier.identity, TextInputUnderlineColorModifier, value); 1752 return this; 1753 } 1754 wordBreak(value: WordBreak): TextInputAttribute { 1755 modifierWithKey(this._modifiersWithKeys, TextInputWordBreakModifier.identity, TextInputWordBreakModifier, value); 1756 return this; 1757 } 1758 lineBreakStrategy(value: LineBreakStrategy): TextInputAttribute { 1759 modifierWithKey(this._modifiersWithKeys, TextInputLineBreakStrategyModifier.identity, 1760 TextInputLineBreakStrategyModifier, value); 1761 return this; 1762 } 1763 minFontSize(value: number | string | Resource): TextInputAttribute { 1764 modifierWithKey(this._modifiersWithKeys, TextInputMinFontSizeModifier.identity, TextInputMinFontSizeModifier, value); 1765 return this; 1766 } 1767 maxFontSize(value: number | string | Resource): TextInputAttribute { 1768 modifierWithKey(this._modifiersWithKeys, TextInputMaxFontSizeModifier.identity, TextInputMaxFontSizeModifier, value); 1769 return this; 1770 } 1771 minFontScale(value: number | Resource): TextInputAttribute { 1772 modifierWithKey(this._modifiersWithKeys, TextInputMinFontScaleModifier.identity, TextInputMinFontScaleModifier, value); 1773 return this; 1774 } 1775 maxFontScale(value: number | Resource): TextInputAttribute { 1776 modifierWithKey(this._modifiersWithKeys, TextInputMaxFontScaleModifier.identity, TextInputMaxFontScaleModifier, value); 1777 return this; 1778 } 1779 heightAdaptivePolicy(value: TextHeightAdaptivePolicy): TextInputAttribute { 1780 modifierWithKey(this._modifiersWithKeys, TextInputHeightAdaptivePolicyModifier.identity, TextInputHeightAdaptivePolicyModifier, value); 1781 return this; 1782 } 1783 textOverflow(value: TextOverflow): this { 1784 modifierWithKey(this._modifiersWithKeys, TextInputTextOverflowModifier.identity, TextInputTextOverflowModifier, value); 1785 return this; 1786 } 1787 textIndent(value: Dimension): this { 1788 modifierWithKey(this._modifiersWithKeys, TextInputTextIndentModifier.identity, TextInputTextIndentModifier, value); 1789 return this; 1790 } 1791 ellipsisMode(value: EllipsisMode): this { 1792 modifierWithKey(this._modifiersWithKeys, TextInputEllipsisModeModifier.identity, TextInputEllipsisModeModifier, value); 1793 return this; 1794 } 1795 padding(value: Padding | Length): this { 1796 let arkValue = new ArkPadding(); 1797 if (value !== null && value !== undefined) { 1798 if (isLengthType(value) || isResource(value)) { 1799 arkValue.top = value; 1800 arkValue.right = value; 1801 arkValue.bottom = value; 1802 arkValue.left = value; 1803 } 1804 else { 1805 arkValue.top = value.top; 1806 arkValue.bottom = value.bottom; 1807 if (Object.keys(value).indexOf('right') >= 0) { 1808 arkValue.right = value.right; 1809 } 1810 if (Object.keys(value).indexOf('end') >= 0) { 1811 arkValue.right = value.end; 1812 } 1813 if (Object.keys(value).indexOf('left') >= 0) { 1814 arkValue.left = value.left; 1815 } 1816 if (Object.keys(value).indexOf('start') >= 0) { 1817 arkValue.left = value.start; 1818 } 1819 } 1820 modifierWithKey(this._modifiersWithKeys, TextInputPaddingModifier.identity, TextInputPaddingModifier, arkValue); 1821 } 1822 else { 1823 modifierWithKey(this._modifiersWithKeys, TextInputPaddingModifier.identity, TextInputPaddingModifier, undefined); 1824 } 1825 return this; 1826 } 1827 contentType(value: ContentType): this { 1828 modifierWithKey(this._modifiersWithKeys, TextInputContentTypeModifier.identity, TextInputContentTypeModifier, value); 1829 return this; 1830 } 1831 border(value: BorderOptions): this { 1832 let borderValue = new ArkBorder(); 1833 if (isUndefined(value)) { 1834 borderValue = undefined; 1835 } 1836 1837 if (!isUndefined(value?.width) && value?.width !== null) { 1838 if (isNumber(value.width) || isString(value.width) || isResource(value.width)) { 1839 borderValue.arkWidth.left = value.width; 1840 borderValue.arkWidth.right = value.width; 1841 borderValue.arkWidth.top = value.width; 1842 borderValue.arkWidth.bottom = value.width; 1843 } else { 1844 borderValue.arkWidth.left = (value.width as EdgeWidths).left; 1845 borderValue.arkWidth.right = (value.width as EdgeWidths).right; 1846 borderValue.arkWidth.top = (value.width as EdgeWidths).top; 1847 borderValue.arkWidth.bottom = (value.width as EdgeWidths).bottom; 1848 } 1849 } 1850 if (!isUndefined(value?.color) && value?.color !== null) { 1851 if (isNumber(value.color) || isString(value.color) || isResource(value.color)) { 1852 borderValue.arkColor.leftColor = value.color; 1853 borderValue.arkColor.rightColor = value.color; 1854 borderValue.arkColor.topColor = value.color; 1855 borderValue.arkColor.bottomColor = value.color; 1856 } else { 1857 borderValue.arkColor.leftColor = (value.color as EdgeColors).left; 1858 borderValue.arkColor.rightColor = (value.color as EdgeColors).right; 1859 borderValue.arkColor.topColor = (value.color as EdgeColors).top; 1860 borderValue.arkColor.bottomColor = (value.color as EdgeColors).bottom; 1861 } 1862 } 1863 if (!isUndefined(value?.radius) && value?.radius !== null) { 1864 if (isNumber(value.radius) || isString(value.radius) || isResource(value.radius)) { 1865 borderValue.arkRadius.topLeft = value.radius; 1866 borderValue.arkRadius.topRight = value.radius; 1867 borderValue.arkRadius.bottomLeft = value.radius; 1868 borderValue.arkRadius.bottomRight = value.radius; 1869 } else { 1870 borderValue.arkRadius.topLeft = (value.radius as BorderRadiuses)?.topLeft; 1871 borderValue.arkRadius.topRight = (value.radius as BorderRadiuses)?.topRight; 1872 borderValue.arkRadius.bottomLeft = (value.radius as BorderRadiuses)?.bottomLeft; 1873 borderValue.arkRadius.bottomRight = (value.radius as BorderRadiuses)?.bottomRight; 1874 } 1875 } 1876 if (!isUndefined(value?.style) && value?.style !== null) { 1877 let arkBorderStyle = new ArkBorderStyle(); 1878 if (arkBorderStyle.parseBorderStyle(value.style)) { 1879 if (!isUndefined(arkBorderStyle.style)) { 1880 borderValue.arkStyle.top = arkBorderStyle.style; 1881 borderValue.arkStyle.left = arkBorderStyle.style; 1882 borderValue.arkStyle.bottom = arkBorderStyle.style; 1883 borderValue.arkStyle.right = arkBorderStyle.style; 1884 } else { 1885 borderValue.arkStyle.top = arkBorderStyle.top; 1886 borderValue.arkStyle.left = arkBorderStyle.left; 1887 borderValue.arkStyle.bottom = arkBorderStyle.bottom; 1888 borderValue.arkStyle.right = arkBorderStyle.right; 1889 } 1890 } 1891 } 1892 if (!isUndefined(value?.dashGap) && value?.dashGap !== null) { 1893 if (isNumber(value.dashGap) || isString(value.dashGap) || isResource(value.dashGap) || 1894 isObject(value.dashGap) && isNumber(value.dashGap.value)) { 1895 borderValue.arkDashGap.left = value.dashGap; 1896 borderValue.arkDashGap.right = value.dashGap; 1897 borderValue.arkDashGap.top = value.dashGap; 1898 borderValue.arkDashGap.bottom = value.dashGap; 1899 } else { 1900 borderValue.arkDashGap.left = (value.dashGap as EdgeWidths).left; 1901 borderValue.arkDashGap.right = (value.dashGap as EdgeWidths).right; 1902 borderValue.arkDashGap.top = (value.dashGap as EdgeWidths).top; 1903 borderValue.arkDashGap.bottom = (value.dashGap as EdgeWidths).bottom; 1904 borderValue.arkDashGap.start = (value.dashGap as LocalizedEdgeWidths).start; 1905 borderValue.arkDashGap.end = (value.dashGap as LocalizedEdgeWidths).end; 1906 } 1907 } 1908 if (!isUndefined(value?.dashWidth) && value?.dashWidth !== null) { 1909 if (isNumber(value.dashWidth) || isString(value.dashWidth) || isResource(value.dashWidth) || 1910 isObject(value.dashWidth) && isNumber(value.dashWidth.value)) { 1911 borderValue.arkDashWidth.left = value.dashWidth; 1912 borderValue.arkDashWidth.right = value.dashWidth; 1913 borderValue.arkDashWidth.top = value.dashWidth; 1914 borderValue.arkDashWidth.bottom = value.dashWidth; 1915 } else { 1916 borderValue.arkDashWidth.left = (value.dashWidth as EdgeWidths).left; 1917 borderValue.arkDashWidth.right = (value.dashWidth as EdgeWidths).right; 1918 borderValue.arkDashWidth.top = (value.dashWidth as EdgeWidths).top; 1919 borderValue.arkDashWidth.bottom = (value.dashWidth as EdgeWidths).bottom; 1920 borderValue.arkDashWidth.start = (value.dashWidth as EdgeWidths).start; 1921 borderValue.arkDashWidth.end = (value.dashWidth as EdgeWidths).end; 1922 } 1923 } 1924 modifierWithKey(this._modifiersWithKeys, TextInputBorderModifier.identity, TextInputBorderModifier, borderValue); 1925 return this; 1926 } 1927 borderWidth(value: Length | EdgeWidths): this { 1928 modifierWithKey(this._modifiersWithKeys, TextInputBorderWidthModifier.identity, TextInputBorderWidthModifier, value); 1929 return this; 1930 } 1931 borderColor(value: ResourceColor | EdgeColors): this { 1932 modifierWithKey(this._modifiersWithKeys, TextInputBorderColorModifier.identity, TextInputBorderColorModifier, value); 1933 return this; 1934 } 1935 borderStyle(value: BorderStyle | EdgeStyles): this { 1936 modifierWithKey(this._modifiersWithKeys, TextInputBorderStyleModifier.identity, TextInputBorderStyleModifier, value); 1937 return this; 1938 } 1939 borderRadius(value: Length | BorderRadiuses): this { 1940 modifierWithKey(this._modifiersWithKeys, TextInputBorderRadiusModifier.identity, TextInputBorderRadiusModifier, value); 1941 return this; 1942 } 1943 backgroundColor(value: ResourceColor): this { 1944 modifierWithKey(this._modifiersWithKeys, TextInputBackgroundColorModifier.identity, TextInputBackgroundColorModifier, value); 1945 return this; 1946 } 1947 margin(value: Margin | Length): this { 1948 let arkValue = new ArkPadding(); 1949 if (value !== null && value !== undefined) { 1950 if (isLengthType(value) || isResource(value)) { 1951 arkValue.top = <Length>value; 1952 arkValue.right = <Length>value; 1953 arkValue.bottom = <Length>value; 1954 arkValue.left = <Length>value; 1955 } else { 1956 arkValue.top = value.top; 1957 arkValue.bottom = value.bottom; 1958 if (Object.keys(value).indexOf('right') >= 0) { 1959 arkValue.right = value.right; 1960 } 1961 if (Object.keys(value).indexOf('end') >= 0) { 1962 arkValue.right = value.end; 1963 } 1964 if (Object.keys(value).indexOf('left') >= 0) { 1965 arkValue.left = value.left; 1966 } 1967 if (Object.keys(value).indexOf('start') >= 0) { 1968 arkValue.left = value.start; 1969 } 1970 } 1971 modifierWithKey(this._modifiersWithKeys, TextInputMarginModifier.identity, TextInputMarginModifier, arkValue); 1972 } else { 1973 modifierWithKey(this._modifiersWithKeys, TextInputMarginModifier.identity, TextInputMarginModifier, undefined); 1974 } 1975 return this; 1976 } 1977 onWillChange(callback: Callback<ChangeValueInfo, boolean>): this { 1978 modifierWithKey(this._modifiersWithKeys, TextInputOnWillChangeModifier.identity, TextInputOnWillChangeModifier, callback); 1979 return this; 1980 } 1981 onWillInsert(callback: Callback<InsertValue, boolean>): this { 1982 modifierWithKey(this._modifiersWithKeys, TextInputOnWillInsertModifier.identity, TextInputOnWillInsertModifier, callback); 1983 return this; 1984 } 1985 onDidInsert(callback: Callback<InsertValue>): this { 1986 modifierWithKey(this._modifiersWithKeys, TextInputOnDidInsertModifier.identity, TextInputOnDidInsertModifier, callback); 1987 return this; 1988 } 1989 onWillDelete(callback: Callback<DeleteValue, boolean>): this { 1990 modifierWithKey(this._modifiersWithKeys, TextInputOnWillDeleteModifier.identity, TextInputOnWillDeleteModifier, callback); 1991 return this; 1992 } 1993 onDidDelete(callback: Callback<DeleteValue>): this { 1994 modifierWithKey(this._modifiersWithKeys, TextInputOnDidDeleteModifier.identity, TextInputOnDidDeleteModifier, callback); 1995 return this; 1996 } 1997 enablePreviewText(value: boolean): this { 1998 modifierWithKey(this._modifiersWithKeys, TextInputEnablePreviewTextModifier.identity, TextInputEnablePreviewTextModifier, value); 1999 return this; 2000 } 2001 editMenuOptions(value: EditMenuOptions): this { 2002 modifierWithKey(this._modifiersWithKeys, TextInputEditMenuOptionsModifier.identity, 2003 TextInputEditMenuOptionsModifier, value); 2004 return this; 2005 } 2006 enableHapticFeedback(value: boolean): this { 2007 modifierWithKey(this._modifiersWithKeys, TextInputEnableHapticFeedbackModifier.identity, TextInputEnableHapticFeedbackModifier, value); 2008 return this; 2009 } 2010} 2011// @ts-ignore 2012globalThis.TextInput.attributeModifier = function (modifier: ArkComponent): void { 2013 attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => { 2014 return new ArkTextInputComponent(nativePtr); 2015 }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => { 2016 return new modifierJS.TextInputModifier(nativePtr, classType); 2017 }); 2018}; 2019