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