1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/// <reference path='./import.ts' /> 17 18function calArkBorderWidth(value: BorderOptions): ArkBorderWidth { 19 let arkWidth = new ArkBorderWidth(); 20 if (!isUndefined(value?.width) && value?.width !== null) { 21 if (isNumber(value.width) || isString(value.width) || isResource(value.width)) { 22 arkWidth.left = value.width; 23 arkWidth.right = value.width; 24 arkWidth.top = value.width; 25 arkWidth.bottom = value.width; 26 } else { 27 arkWidth.left = (value.width as EdgeWidths).left; 28 arkWidth.right = (value.width as EdgeWidths).right; 29 arkWidth.top = (value.width as EdgeWidths).top; 30 arkWidth.bottom = (value.width as EdgeWidths).bottom; 31 } 32 } 33 return arkWidth; 34} 35 36function calArkBorderColor(value: BorderOptions): ArkBorderColor { 37 let arkColor = new ArkBorderColor(); 38 if (!isUndefined(value?.color) && value?.color !== null) { 39 if (isNumber(value.color) || isString(value.color) || isResource(value.color)) { 40 arkColor.leftColor = value.color; 41 arkColor.rightColor = value.color; 42 arkColor.topColor = value.color; 43 arkColor.bottomColor = value.color; 44 } else { 45 arkColor.leftColor = (value.color as EdgeColors).left; 46 arkColor.rightColor = (value.color as EdgeColors).right; 47 arkColor.topColor = (value.color as EdgeColors).top; 48 arkColor.bottomColor = (value.color as EdgeColors).bottom; 49 } 50 } 51 return arkColor; 52} 53 54function calArkBorderRadius(value: BorderOptions): ArkBorderRadius { 55 let arkRadius = new ArkBorderRadius(); 56 if (!isUndefined(value?.radius) && value?.radius !== null) { 57 if (isNumber(value.radius) || isString(value.radius) || isResource(value.radius)) { 58 arkRadius.topLeft = value.radius; 59 arkRadius.topRight = value.radius; 60 arkRadius.bottomLeft = value.radius; 61 arkRadius.bottomRight = value.radius; 62 } else { 63 arkRadius.topLeft = (value.radius as BorderRadiuses)?.topLeft; 64 arkRadius.topRight = (value.radius as BorderRadiuses)?.topRight; 65 arkRadius.bottomLeft = (value.radius as BorderRadiuses)?.bottomLeft; 66 arkRadius.bottomRight = (value.radius as BorderRadiuses)?.bottomRight; 67 } 68 } 69 return arkRadius; 70} 71 72function calArkBorderStyle(value: BorderOptions): ArkBorderStyle { 73 let arkStyle = new ArkBorderStyle(); 74 if (!isUndefined(value?.style) && value?.style !== null) { 75 let arkBorderStyle = new ArkBorderStyle(); 76 if (arkBorderStyle.parseBorderStyle(value.style)) { 77 if (!isUndefined(arkBorderStyle.style)) { 78 arkStyle.top = arkBorderStyle.style; 79 arkStyle.left = arkBorderStyle.style; 80 arkStyle.bottom = arkBorderStyle.style; 81 arkStyle.right = arkBorderStyle.style; 82 } else { 83 arkStyle.top = arkBorderStyle.top; 84 arkStyle.left = arkBorderStyle.left; 85 arkStyle.bottom = arkBorderStyle.bottom; 86 arkStyle.right = arkBorderStyle.right; 87 } 88 } 89 } 90 return arkStyle; 91} 92 93function valueToArkBorder(value: BorderOptions): ArkBorder { 94 let borderValue = new ArkBorder(); 95 if (isUndefined(value)) { 96 borderValue = undefined; 97 } else { 98 borderValue.arkWidth = calArkBorderWidth(value); 99 borderValue.arkColor = calArkBorderColor(value); 100 borderValue.arkRadius = calArkBorderRadius(value); 101 borderValue.arkStyle = calArkBorderStyle(value); 102 } 103 return borderValue; 104} 105 106class TextAreaFontStyleModifier extends ModifierWithKey<FontStyle> { 107 static identity: Symbol = Symbol('textAreaFontStyle'); 108 applyPeer(node: KNode, reset: boolean): void { 109 if (reset) { 110 getUINativeModule().textArea.resetFontStyle(node); 111 } else { 112 getUINativeModule().textArea.setFontStyle(node, this.value!); 113 } 114 } 115 checkObjectDiff(): boolean { 116 return !isBaseOrResourceEqual(this.stageValue, this.value); 117 } 118} 119 120class TextAreaDecorationModifier extends ModifierWithKey<{ type: TextDecorationType; color?: ResourceColor; style?: TextDecorationStyle }> { 121 constructor(value: { type: TextDecorationType; color?: ResourceColor; style?: TextDecorationStyle }) { 122 super(value); 123 } 124 static identity: Symbol = Symbol('textAreaDecoration'); 125 applyPeer(node: KNode, reset: boolean): void { 126 if (reset) { 127 getUINativeModule().textArea.resetDecoration(node); 128 } else { 129 getUINativeModule().textArea.setDecoration(node, this.value!.type, this.value!.color, this.value!.style); 130 } 131 } 132 133 checkObjectDiff(): boolean { 134 if (this.stageValue.type !== this.value.type || this.stageValue.style !== this.value.style) { 135 return true; 136 } 137 if (isResource(this.stageValue.color) && isResource(this.value.color)) { 138 return !isResourceEqual(this.stageValue.color, this.value.color); 139 } else if (!isResource(this.stageValue.color) && !isResource(this.value.color)) { 140 return !(this.stageValue.color === this.value.color); 141 } else { 142 return true; 143 } 144 } 145} 146 147class TextAreaLetterSpacingModifier extends ModifierWithKey<number | string> { 148 constructor(value: number | string) { 149 super(value); 150 } 151 static identity: Symbol = Symbol('textAreaLetterSpacing'); 152 applyPeer(node: KNode, reset: boolean): void { 153 if (reset) { 154 getUINativeModule().textArea.resetLetterSpacing(node); 155 } else { 156 getUINativeModule().textArea.setLetterSpacing(node, this.value); 157 } 158 } 159 160 checkObjectDiff(): boolean { 161 return !isBaseOrResourceEqual(this.stageValue, this.value); 162 } 163} 164 165class TextAreaLineSpacingModifier extends ModifierWithKey<LengthMetrics> { 166 constructor(value: LengthMetrics) { 167 super(value); 168 } 169 static identity: Symbol = Symbol('textAreaLineSpacing'); 170 applyPeer(node: KNode, reset: boolean): void { 171 if (reset) { 172 getUINativeModule().textArea.resetLineSpacing(node); 173 } else if (!isObject(this.value)) { 174 getUINativeModule().textArea.resetLineSpacing(node); 175 } else { 176 getUINativeModule().textArea.setLineSpacing(node, this.value.value, this.value.unit); 177 } 178 } 179 180 checkObjectDiff(): boolean { 181 return !isBaseOrResourceEqual(this.stageValue, this.value); 182 } 183} 184 185class TextAreaLineHeightModifier extends ModifierWithKey<number | string | Resource> { 186 constructor(value: number | string | Resource) { 187 super(value); 188 } 189 static identity: Symbol = Symbol('textAreaLineHeight'); 190 applyPeer(node: KNode, reset: boolean): void { 191 if (reset) { 192 getUINativeModule().textArea.resetLineHeight(node); 193 } else { 194 getUINativeModule().textArea.setLineHeight(node, this.value); 195 } 196 } 197 198 checkObjectDiff(): boolean { 199 return !isBaseOrResourceEqual(this.stageValue, this.value); 200 } 201} 202 203class TextAreaWordBreakModifier extends ModifierWithKey<WordBreak> { 204 constructor(value: WordBreak) { 205 super(value); 206 } 207 static identity: Symbol = Symbol('textAreaWordBreak'); 208 applyPeer(node: KNode, reset: boolean): void { 209 if (reset) { 210 getUINativeModule().textArea.resetWordBreak(node); 211 } else { 212 getUINativeModule().textArea.setWordBreak(node, this.value!); 213 } 214 } 215 checkObjectDiff(): boolean { 216 return !isBaseOrResourceEqual(this.stageValue, this.value); 217 } 218} 219 220class TextAreaLineBreakStrategyModifier extends ModifierWithKey<LineBreakStrategy> { 221 constructor(value: LineBreakStrategy) { 222 super(value); 223 } 224 static identity: Symbol = Symbol('textAreaLineBreakStrategy'); 225 applyPeer(node: KNode, reset: boolean): void { 226 if (reset) { 227 getUINativeModule().textArea.resetLineBreakStrategy(node); 228 } else { 229 getUINativeModule().textArea.setLineBreakStrategy(node, this.value!); 230 } 231 } 232 checkObjectDiff(): boolean { 233 return !isBaseOrResourceEqual(this.stageValue, this.value); 234 } 235} 236 237class TextAreaCopyOptionModifier extends ModifierWithKey<CopyOptions> { 238 static identity: Symbol = Symbol('textAreaCopyOption'); 239 applyPeer(node: KNode, reset: boolean): void { 240 if (reset) { 241 getUINativeModule().textArea.resetCopyOption(node); 242 } else { 243 getUINativeModule().textArea.setCopyOption(node, this.value!); 244 } 245 } 246 checkObjectDiff(): boolean { 247 return !isBaseOrResourceEqual(this.stageValue, this.value); 248 } 249} 250 251class TextAreaMaxLinesModifier extends ModifierWithKey<number | undefined> { 252 static identity: Symbol = Symbol('textAreaMaxLines'); 253 applyPeer(node: KNode, reset: boolean): void { 254 if (reset) { 255 getUINativeModule().textArea.resetMaxLines(node); 256 } else { 257 getUINativeModule().textArea.setMaxLines(node, this.value!); 258 } 259 } 260 checkObjectDiff(): boolean { 261 return !isBaseOrResourceEqual(this.stageValue, this.value); 262 } 263} 264 265class TextAreaMinFontSizeModifier extends ModifierWithKey<number | string | Resource> { 266 constructor(value: number | string | Resource) { 267 super(value); 268 } 269 static identity: Symbol = Symbol('textAreaMinFontSize'); 270 applyPeer(node: KNode, reset: boolean): void { 271 if (reset) { 272 getUINativeModule().textArea.resetMinFontSize(node); 273 } else { 274 getUINativeModule().textArea.setMinFontSize(node, this.value!); 275 } 276 } 277 checkObjectDiff(): boolean { 278 return !isBaseOrResourceEqual(this.stageValue, this.value); 279 } 280} 281 282class TextAreaMaxFontSizeModifier extends ModifierWithKey<number | string | Resource> { 283 constructor(value: number | string | Resource) { 284 super(value); 285 } 286 static identity: Symbol = Symbol('textAreaMaxFontSize'); 287 applyPeer(node: KNode, reset: boolean): void { 288 if (reset) { 289 getUINativeModule().textArea.resetMaxFontSize(node); 290 } else { 291 getUINativeModule().textArea.setMaxFontSize(node, this.value!); 292 } 293 } 294 checkObjectDiff(): boolean { 295 return !isBaseOrResourceEqual(this.stageValue, this.value); 296 } 297} 298 299class TextAreaHeightAdaptivePolicyModifier extends ModifierWithKey<TextHeightAdaptivePolicy> { 300 constructor(value: TextHeightAdaptivePolicy) { 301 super(value); 302 } 303 static identity: Symbol = Symbol('textAreaHeightAdaptivePolicy'); 304 applyPeer(node: KNode, reset: boolean): void { 305 if (reset) { 306 getUINativeModule().textArea.resetHeightAdaptivePolicy(node); 307 } else { 308 getUINativeModule().textArea.setHeightAdaptivePolicy(node, this.value!); 309 } 310 } 311 checkObjectDiff(): boolean { 312 return !isBaseOrResourceEqual(this.stageValue, this.value); 313 } 314} 315 316class TextAreaFontSizeModifier extends ModifierWithKey<string | number> { 317 static identity: Symbol = Symbol('textAreaFontSize'); 318 applyPeer(node: KNode, reset: boolean): void { 319 if (reset) { 320 getUINativeModule().textArea.resetFontSize(node); 321 } else { 322 getUINativeModule().textArea.setFontSize(node, this.value!); 323 } 324 } 325 checkObjectDiff(): boolean { 326 return !isBaseOrResourceEqual(this.stageValue, this.value); 327 } 328} 329 330class TextAreaPlaceholderColorModifier extends ModifierWithKey<ResourceColor> { 331 static identity: Symbol = Symbol('textAreaPlaceholderColor'); 332 applyPeer(node: KNode, reset: boolean): void { 333 if (reset) { 334 getUINativeModule().textArea.resetPlaceholderColor(node); 335 } else { 336 getUINativeModule().textArea.setPlaceholderColor(node, this.value!); 337 } 338 } 339 checkObjectDiff(): boolean { 340 return !isBaseOrResourceEqual(this.stageValue, this.value); 341 } 342} 343 344class TextAreaFontColorModifier extends ModifierWithKey<ResourceColor> { 345 static identity: Symbol = Symbol('textAreaFontColor'); 346 applyPeer(node: KNode, reset: boolean): void { 347 if (reset) { 348 getUINativeModule().textArea.resetFontColor(node); 349 } else { 350 getUINativeModule().textArea.setFontColor(node, this.value!); 351 } 352 } 353 checkObjectDiff(): boolean { 354 return !isBaseOrResourceEqual(this.stageValue, this.value); 355 } 356} 357 358class TextAreaFontWeightModifier extends ModifierWithKey<number | FontWeight | string> { 359 static identity: Symbol = Symbol('textAreaFontWeight'); 360 applyPeer(node: KNode, reset: boolean): void { 361 if (reset) { 362 getUINativeModule().textArea.resetFontWeight(node); 363 } else { 364 getUINativeModule().textArea.setFontWeight(node, this.value!); 365 } 366 } 367 checkObjectDiff(): boolean { 368 return !isBaseOrResourceEqual(this.stageValue, this.value); 369 } 370} 371 372class TextAreaBarStateModifier extends ModifierWithKey<BarState> { 373 static identity: Symbol = Symbol('textAreaBarState'); 374 applyPeer(node: KNode, reset: boolean): void { 375 if (reset) { 376 getUINativeModule().textArea.resetBarState(node); 377 } else { 378 getUINativeModule().textArea.setBarState(node, this.value!); 379 } 380 } 381 checkObjectDiff(): boolean { 382 return !isBaseOrResourceEqual(this.stageValue, this.value); 383 } 384} 385 386class TextAreaEnableKeyboardOnFocusModifier extends ModifierWithKey<boolean> { 387 static identity: Symbol = Symbol('textAreaEnableKeyboardOnFocus'); 388 applyPeer(node: KNode, reset: boolean): void { 389 if (reset) { 390 getUINativeModule().textArea.resetEnableKeyboardOnFocus(node); 391 } else { 392 getUINativeModule().textArea.setEnableKeyboardOnFocus(node, this.value!); 393 } 394 } 395 checkObjectDiff(): boolean { 396 return !isBaseOrResourceEqual(this.stageValue, this.value); 397 } 398} 399 400class TextAreaFontFamilyModifier extends ModifierWithKey<ResourceColor | string> { 401 static identity: Symbol = Symbol('textAreaFontFamily'); 402 applyPeer(node: KNode, reset: boolean): void { 403 if (reset) { 404 getUINativeModule().textArea.resetFontFamily(node); 405 } else { 406 getUINativeModule().textArea.setFontFamily(node, this.value!); 407 } 408 } 409 410 checkObjectDiff(): boolean { 411 return !isBaseOrResourceEqual(this.stageValue, this.value); 412 } 413} 414 415class TextAreaCaretColorModifier extends ModifierWithKey<ResourceColor> { 416 static identity: Symbol = Symbol('textAreaCaretColor'); 417 applyPeer(node: KNode, reset: boolean): void { 418 if (reset) { 419 getUINativeModule().textArea.resetCaretColor(node); 420 } else { 421 getUINativeModule().textArea.setCaretColor(node, this.value!); 422 } 423 } 424 checkObjectDiff(): boolean { 425 return !isBaseOrResourceEqual(this.stageValue, this.value); 426 } 427} 428 429class TextAreaMaxLengthModifier extends ModifierWithKey<number> { 430 static identity: Symbol = Symbol('textAreaMaxLength'); 431 applyPeer(node: KNode, reset: boolean): void { 432 if (reset) { 433 getUINativeModule().textArea.resetMaxLength(node); 434 } else { 435 getUINativeModule().textArea.setMaxLength(node, this.value!); 436 } 437 } 438 checkObjectDiff(): boolean { 439 return !isBaseOrResourceEqual(this.stageValue, this.value); 440 } 441} 442 443class TextAreaStyleModifier extends ModifierWithKey<TextContentStyle> { 444 static identity: Symbol = Symbol('textAreaStyle'); 445 applyPeer(node: KNode, reset: boolean): void { 446 if (reset) { 447 getUINativeModule().textArea.resetStyle(node); 448 } else { 449 getUINativeModule().textArea.setStyle(node, this.value!); 450 } 451 } 452 checkObjectDiff(): boolean { 453 return !isBaseOrResourceEqual(this.stageValue, this.value); 454 } 455} 456 457class TextAreaSelectionMenuHiddenModifier extends ModifierWithKey<boolean> { 458 static identity: Symbol = Symbol('textAreaSelectionMenuHidden'); 459 applyPeer(node: KNode, reset: boolean): void { 460 if (reset) { 461 getUINativeModule().textArea.resetSelectionMenuHidden(node); 462 } else { 463 getUINativeModule().textArea.setSelectionMenuHidden(node, this.value!); 464 } 465 } 466 checkObjectDiff(): boolean { 467 return !isBaseOrResourceEqual(this.stageValue, this.value); 468 } 469} 470 471class TextAreaPlaceholderFontModifier extends ModifierWithKey<Font> { 472 static identity: Symbol = Symbol('textAreaPlaceholderFont'); 473 applyPeer(node: KNode, reset: boolean): void { 474 if (reset) { 475 getUINativeModule().textArea.resetPlaceholderFont(node); 476 } else { 477 getUINativeModule().textArea.setPlaceholderFont(node, this.value.size, 478 this.value.weight, this.value.family, this.value.style); 479 } 480 } 481 482 checkObjectDiff(): boolean { 483 if (!(this.stageValue.weight === this.value.weight && 484 this.stageValue.style === this.value.style)) { 485 return true; 486 } else { 487 return !isBaseOrResourceEqual(this.stageValue.size, this.value.size) || 488 !isBaseOrResourceEqual(this.stageValue.family, this.value.family); 489 } 490 } 491} 492 493class TextAreaTextAlignModifier extends ModifierWithKey<TextAlign> { 494 constructor(value: TextAlign) { 495 super(value); 496 } 497 static identity: Symbol = Symbol('textAreaTextAlign'); 498 applyPeer(node: KNode, reset: boolean): void { 499 if (reset) { 500 getUINativeModule().textArea.resetTextAlign(node); 501 } else { 502 getUINativeModule().textArea.setTextAlign(node, this.value!); 503 } 504 } 505 checkObjectDiff(): boolean { 506 return !isBaseOrResourceEqual(this.stageValue, this.value); 507 } 508} 509 510class TextAreaShowCounterModifier extends ModifierWithKey<ArkTextFieldShowCounter> { 511 constructor(value: ArkTextFieldShowCounter) { 512 super(value); 513 } 514 static identity: Symbol = Symbol('textAreaShowCounter'); 515 applyPeer(node: KNode, reset: boolean): void { 516 if (reset) { 517 getUINativeModule().textArea.resetShowCounter(node); 518 } else { 519 getUINativeModule().textArea.setShowCounter(node, this.value.value!, this.value.highlightBorder, this.value.thresholdPercentage); 520 } 521 } 522 checkObjectDiff(): boolean { 523 return !isBaseOrResourceEqual(this.stageValue.value, this.value.value) || 524 !isBaseOrResourceEqual(this.stageValue.highlightBorder, this.value.highlightBorder) || 525 !isBaseOrResourceEqual(this.stageValue.thresholdPercentage, this.value.thresholdPercentage); 526 } 527} 528 529class TextAreaFontFeatureModifier extends ModifierWithKey<FontFeature> { 530 constructor(value: FontFeature) { 531 super(value); 532 } 533 static identity: Symbol = Symbol('textAreaFontFeature'); 534 applyPeer(node: KNode, reset: boolean): void { 535 if (reset) { 536 getUINativeModule().textArea.resetFontFeature(node); 537 } else { 538 getUINativeModule().textArea.setFontFeature(node, this.value!); 539 } 540 } 541 checkObjectDiff(): boolean { 542 return !isBaseOrResourceEqual(this.stageValue, this.value); 543 } 544} 545 546class TextAreaSelectedBackgroundColorModifier extends ModifierWithKey<ResourceColor> { 547 constructor(value: ResourceColor) { 548 super(value); 549 } 550 static identity: Symbol = Symbol('textAreaSelectedBackgroundColor'); 551 applyPeer(node: KNode, reset: boolean): void { 552 if (reset) { 553 getUINativeModule().textArea.resetSelectedBackgroundColor(node); 554 } else { 555 getUINativeModule().textArea.setSelectedBackgroundColor(node, this.value!); 556 } 557 } 558 checkObjectDiff(): boolean { 559 return !isBaseOrResourceEqual(this.stageValue, this.value); 560 } 561} 562 563class TextAreaCaretStyleModifier extends ModifierWithKey<CaretStyle> { 564 constructor(value: CaretStyle) { 565 super(value); 566 } 567 static identity: Symbol = Symbol('textAreaCaretStyle'); 568 applyPeer(node: KNode, reset: boolean): void { 569 if (reset) { 570 getUINativeModule().textArea.resetCaretStyle(node); 571 } else { 572 getUINativeModule().textArea.setCaretStyle(node, this.value.width!, 573 this.value.color); 574 } 575 } 576 checkObjectDiff(): boolean { 577 return this.stageValue !== this.value; 578 } 579} 580 581class TextAreaTextOverflowModifier extends ModifierWithKey<TextOverflow> { 582 constructor(value: TextOverflow) { 583 super(value); 584 } 585 static identity: Symbol = Symbol('textAreaTextOverflow'); 586 applyPeer(node: KNode, reset: boolean): void { 587 if (reset) { 588 getUINativeModule().textArea.resetTextOverflow(node); 589 } else { 590 getUINativeModule().textArea.setTextOverflow(node, this.value!); 591 } 592 } 593 checkObjectDiff(): boolean { 594 return this.stageValue !== this.value; 595 } 596} 597 598class TextAreaTextIndentModifier extends ModifierWithKey<Dimension> { 599 constructor(value: Dimension) { 600 super(value); 601 } 602 static identity: Symbol = Symbol('textAreaTextIndent'); 603 applyPeer(node: KNode, reset: boolean): void { 604 if (reset) { 605 getUINativeModule().textArea.resetTextIndent(node); 606 } else { 607 getUINativeModule().textArea.setTextIndent(node, this.value!); 608 } 609 } 610 checkObjectDiff(): boolean { 611 return !isBaseOrResourceEqual(this.stageValue, this.value); 612 } 613} 614 615class TextAreaOnChangeModifier extends ModifierWithKey<(value: string) => void> { 616 constructor(value: (value: string) => void) { 617 super(value); 618 } 619 static identity = Symbol('textAreaOnChange'); 620 applyPeer(node: KNode, reset: boolean): void { 621 if (reset) { 622 getUINativeModule().textArea.resetOnChange(node); 623 } else { 624 getUINativeModule().textArea.setOnChange(node, this.value); 625 } 626 } 627} 628 629class TextAreaEnterKeyTypeModifier extends ModifierWithKey<number> { 630 constructor(value: number) { 631 super(value); 632 } 633 static identity: Symbol = Symbol('textAreaEnterKeyType'); 634 applyPeer(node: KNode, reset: boolean): void { 635 if (reset) { 636 getUINativeModule().textArea.resetEnterKeyType(node); 637 } else { 638 getUINativeModule().textArea.setEnterKeyType(node, this.value); 639 } 640 } 641 checkObjectDiff(): boolean { 642 return !isBaseOrResourceEqual(this.stageValue, this.value); 643 } 644} 645 646class TextAreaInputFilterModifier extends ModifierWithKey<ArkTextInputFilter> { 647 constructor(value: ArkTextInputFilter) { 648 super(value); 649 } 650 static identity = Symbol('textAreaInputFilter'); 651 applyPeer(node: KNode, reset: boolean): void { 652 if (reset) { 653 getUINativeModule().textArea.resetInputFilter(node); 654 } 655 else { 656 getUINativeModule().textArea.setInputFilter(node, this.value.value, this.value.error); 657 } 658 } 659 checkObjectDiff(): boolean { 660 return !isBaseOrResourceEqual(this.stageValue.value, this.value.value) || 661 !isBaseOrResourceEqual(this.stageValue.error, this.value.error); 662 } 663} 664 665class TextAreaOnTextSelectionChangeModifier extends ModifierWithKey<(selectionStart: number, selectionEnd: number) => void> { 666 constructor(value: (selectionStart: number, selectionEnd: number) => void) { 667 super(value); 668 } 669 static identity = Symbol('textAreaOnTextSelectionChange'); 670 applyPeer(node: KNode, reset: boolean): void { 671 if (reset) { 672 getUINativeModule().textArea.resetOnTextSelectionChange(node); 673 } else { 674 getUINativeModule().textArea.setOnTextSelectionChange(node, this.value); 675 } 676 } 677} 678 679class TextAreaOnContentScrollModifier extends ModifierWithKey<(totalOffsetX: number, totalOffsetY: number) => void> { 680 constructor(value: (totalOffsetX: number, totalOffsetY: number) => void) { 681 super(value); 682 } 683 static identity = Symbol('textAreaOnContentScroll'); 684 applyPeer(node: KNode, reset: boolean): void { 685 if (reset) { 686 getUINativeModule().textArea.resetOnContentScroll(node); 687 } else { 688 getUINativeModule().textArea.setOnContentScroll(node, this.value); 689 } 690 } 691} 692 693class TextAreaOnEditChangeModifier extends ModifierWithKey<(isEditing: boolean) => void> { 694 constructor(value: (isEditing: boolean) => void) { 695 super(value); 696 } 697 static identity = Symbol('textAreaOnEditChange'); 698 applyPeer(node: KNode, reset: boolean): void { 699 if (reset) { 700 getUINativeModule().textArea.resetOnEditChange(node); 701 } else { 702 getUINativeModule().textArea.setOnEditChange(node, this.value); 703 } 704 } 705} 706 707class TextAreaOnCopyModifier extends ModifierWithKey<(value: string) => void> { 708 constructor(value: (value: string) => void) { 709 super(value); 710 } 711 static identity = Symbol('textAreaOnCopy'); 712 applyPeer(node: KNode, reset: boolean): void { 713 if (reset) { 714 getUINativeModule().textArea.resetOnCopy(node); 715 } else { 716 getUINativeModule().textArea.setOnCopy(node, this.value); 717 } 718 } 719} 720 721class TextAreaOnCutModifier extends ModifierWithKey<(value: string) => void> { 722 constructor(value: (value: string) => void) { 723 super(value); 724 } 725 static identity = Symbol('textAreaOnCut'); 726 applyPeer(node: KNode, reset: boolean): void { 727 if (reset) { 728 getUINativeModule().textArea.resetOnCut(node); 729 } else { 730 getUINativeModule().textArea.setOnCut(node, this.value); 731 } 732 } 733} 734 735class TextAreaOnPasteModifier extends ModifierWithKey<(value: string, event: PasteEvent) => void> { 736 constructor(value: (value: string, event: PasteEvent) => void) { 737 super(value); 738 } 739 static identity = Symbol('textAreaOnPaste'); 740 applyPeer(node: KNode, reset: boolean): void { 741 if (reset) { 742 getUINativeModule().textArea.resetOnPaste(node); 743 } else { 744 getUINativeModule().textArea.setOnPaste(node, this.value); 745 } 746 } 747} 748 749class TextAreaTypeModifier extends ModifierWithKey<TextAreaType> { 750 constructor(value: TextAreaType) { 751 super(value); 752 } 753 static identity: Symbol = Symbol('textAreaType'); 754 applyPeer(node: KNode, reset: boolean): void { 755 if (reset) { 756 getUINativeModule().textArea.resetType(node); 757 } 758 else { 759 getUINativeModule().textArea.setType(node, this.value); 760 } 761 } 762 checkObjectDiff(): boolean { 763 return !isBaseOrResourceEqual(this.stageValue, this.value); 764 } 765} 766 767class TextAreaPaddingModifier extends ModifierWithKey<ArkPadding> { 768 constructor(value: ArkPadding) { 769 super(value); 770 } 771 static identity: Symbol = Symbol('textAreaPadding'); 772 applyPeer(node: KNode, reset: boolean): void { 773 if (reset) { 774 getUINativeModule().textArea.resetPadding(node); 775 } 776 else { 777 getUINativeModule().textArea.setPadding(node, this.value.top, this.value.right, this.value.bottom, this.value.left); 778 } 779 } 780 checkObjectDiff(): boolean { 781 return !isBaseOrResourceEqual(this.stageValue.top, this.value.top) || 782 !isBaseOrResourceEqual(this.stageValue.right, this.value.right) || 783 !isBaseOrResourceEqual(this.stageValue.bottom, this.value.bottom) || 784 !isBaseOrResourceEqual(this.stageValue.left, this.value.left); 785 } 786} 787 788class TextAreaOnSubmitModifier extends ModifierWithKey<(enterKey: EnterKeyType, event: SubmitEvent) => void> { 789 constructor(value: (enterKey: EnterKeyType, event: SubmitEvent) => void) { 790 super(value); 791 } 792 static identity = Symbol('textAreaOnSubmit'); 793 applyPeer(node: KNode, reset: boolean): void { 794 if (reset) { 795 getUINativeModule().textArea.resetOnSubmit(node); 796 } else { 797 getUINativeModule().textArea.setOnSubmit(node, this.value); 798 } 799 } 800} 801 802class TextAreaContentTypeModifier extends ModifierWithKey<ContentType> { 803 constructor(value: ContentType) { 804 super(value); 805 } 806 static identity: Symbol = Symbol('textAreaContentType'); 807 applyPeer(node: KNode, reset: boolean): void { 808 if (reset) { 809 getUINativeModule().textArea.resetContentType(node); 810 } 811 else { 812 getUINativeModule().textArea.setContentType(node, this.value); 813 } 814 } 815 checkObjectDiff(): boolean { 816 return !isBaseOrResourceEqual(this.stageValue, this.value); 817 } 818} 819 820class TextAreaEnableAutoFillModifier extends ModifierWithKey<boolean> { 821 constructor(value: boolean) { 822 super(value); 823 } 824 static identity: Symbol = Symbol('textAreaEnableAutoFill'); 825 applyPeer(node: KNode, reset: boolean): void { 826 if (reset) { 827 getUINativeModule().textArea.resetEnableAutoFill(node); 828 } else { 829 getUINativeModule().textArea.setEnableAutoFill(node, this.value!); 830 } 831 } 832 checkObjectDiff(): boolean { 833 return !isBaseOrResourceEqual(this.stageValue, this.value); 834 } 835} 836 837class TextAreaBorderModifier extends ModifierWithKey<ArkBorder> { 838 constructor(value: ArkBorder) { 839 super(value); 840 } 841 static identity: Symbol = Symbol('textAreaBorder'); 842 applyPeer(node: KNode, reset: boolean): void { 843 if (reset) { 844 getUINativeModule().textArea.resetBorder(node); 845 } else { 846 getUINativeModule().textArea.setBorder(node, 847 this.value.arkWidth.left, this.value.arkWidth.right, this.value.arkWidth.top, this.value.arkWidth.bottom, 848 this.value.arkColor.leftColor, this.value.arkColor.rightColor, this.value.arkColor.topColor, this.value.arkColor.bottomColor, 849 this.value.arkRadius.topLeft, this.value.arkRadius.topRight, this.value.arkRadius.bottomLeft, this.value.arkRadius.bottomRight, 850 this.value.arkStyle.top, this.value.arkStyle.right, this.value.arkStyle.bottom, this.value.arkStyle.left); 851 } 852 } 853 checkObjectDiff(): boolean { 854 return this.value.checkObjectDiff(this.stageValue); 855 } 856} 857 858class TextAreaBorderWidthModifier extends ModifierWithKey<Length | EdgeWidths> { 859 constructor(value: Length | EdgeWidths) { 860 super(value); 861 } 862 static identity: Symbol = Symbol('textAreaBorderWidth'); 863 applyPeer(node: KNode, reset: boolean): void { 864 if (reset) { 865 getUINativeModule().textArea.resetBorderWidth(node); 866 } else { 867 if (isNumber(this.value) || isString(this.value) || isResource(this.value)) { 868 getUINativeModule().textArea.setBorderWidth(node, this.value, this.value, this.value, this.value); 869 } else { 870 getUINativeModule().textArea.setBorderWidth(node, 871 (this.value as EdgeWidths).top, 872 (this.value as EdgeWidths).right, 873 (this.value as EdgeWidths).bottom, 874 (this.value as EdgeWidths).left); 875 } 876 } 877 } 878 checkObjectDiff(): boolean { 879 if (isResource(this.stageValue) && isResource(this.value)) { 880 return !isResourceEqual(this.stageValue, this.value); 881 } else if (!isResource(this.stageValue) && !isResource(this.value)) { 882 return !((this.stageValue as EdgeWidths).left === (this.value as EdgeWidths).left && 883 (this.stageValue as EdgeWidths).right === (this.value as EdgeWidths).right && 884 (this.stageValue as EdgeWidths).top === (this.value as EdgeWidths).top && 885 (this.stageValue as EdgeWidths).bottom === (this.value as EdgeWidths).bottom); 886 } else { 887 return true; 888 } 889 } 890} 891 892class TextAreaBorderColorModifier extends ModifierWithKey<ResourceColor | EdgeColors> { 893 constructor(value: ResourceColor | EdgeColors) { 894 super(value); 895 } 896 static identity: Symbol = Symbol('textAreaBorderColor'); 897 applyPeer(node: KNode, reset: boolean): void { 898 if (reset) { 899 getUINativeModule().textArea.resetBorderColor(node); 900 } else { 901 const valueType: string = typeof this.value; 902 if (valueType === 'number' || valueType === 'string' || isResource(this.value)) { 903 getUINativeModule().textArea.setBorderColor(node, this.value, this.value, this.value, this.value); 904 } else { 905 getUINativeModule().textArea.setBorderColor(node, (this.value as EdgeColors).top, 906 (this.value as EdgeColors).right, (this.value as EdgeColors).bottom, 907 (this.value as EdgeColors).left); 908 } 909 } 910 } 911 checkObjectDiff(): boolean { 912 if (isResource(this.stageValue) && isResource(this.value)) { 913 return !isResourceEqual(this.stageValue, this.value); 914 } else if (!isResource(this.stageValue) && !isResource(this.value)) { 915 return !((this.stageValue as EdgeColors).left === (this.value as EdgeColors).left && 916 (this.stageValue as EdgeColors).right === (this.value as EdgeColors).right && 917 (this.stageValue as EdgeColors).top === (this.value as EdgeColors).top && 918 (this.stageValue as EdgeColors).bottom === (this.value as EdgeColors).bottom); 919 } else { 920 return true; 921 } 922 } 923} 924 925class TextAreaBorderStyleModifier extends ModifierWithKey<BorderStyle | EdgeStyles> { 926 constructor(value: BorderStyle | EdgeStyles) { 927 super(value); 928 } 929 static identity: Symbol = Symbol('textAreaBorderStyle'); 930 applyPeer(node: KNode, reset: boolean): void { 931 if (reset) { 932 getUINativeModule().textArea.resetBorderStyle(node); 933 } else { 934 let type: boolean; 935 let style: BorderStyle; 936 let top: BorderStyle; 937 let right: BorderStyle; 938 let bottom: BorderStyle; 939 let left: BorderStyle; 940 if (isNumber(this.value)) { 941 style = this.value as BorderStyle; 942 type = true; 943 } else if (isObject(this.value)) { 944 top = (this.value as EdgeStyles)?.top; 945 right = (this.value as EdgeStyles)?.right; 946 bottom = (this.value as EdgeStyles)?.bottom; 947 left = (this.value as EdgeStyles)?.left; 948 type = true; 949 } 950 if (type === true) { 951 getUINativeModule().textArea.setBorderStyle(node, type, style, top, right, bottom, left); 952 } else { 953 getUINativeModule().textArea.resetBorderStyle(node); 954 } 955 } 956 } 957 checkObjectDiff(): boolean { 958 return !((this.value as EdgeStyles)?.top === (this.stageValue as EdgeStyles)?.top && 959 (this.value as EdgeStyles)?.right === (this.stageValue as EdgeStyles)?.right && 960 (this.value as EdgeStyles)?.bottom === (this.stageValue as EdgeStyles)?.bottom && 961 (this.value as EdgeStyles)?.left === (this.stageValue as EdgeStyles)?.left); 962 } 963} 964 965class TextAreaBorderRadiusModifier extends ModifierWithKey<Length | BorderRadiuses> { 966 constructor(value: Length | BorderRadiuses) { 967 super(value); 968 } 969 static identity: Symbol = Symbol('textAreaBorderRadius'); 970 applyPeer(node: KNode, reset: boolean): void { 971 if (reset) { 972 getUINativeModule().textArea.resetBorderRadius(node); 973 } else { 974 if (isNumber(this.value) || isString(this.value) || isResource(this.value)) { 975 getUINativeModule().textArea.setBorderRadius(node, this.value, this.value, this.value, this.value); 976 } else { 977 getUINativeModule().textArea.setBorderRadius(node, 978 (this.value as BorderRadiuses).topLeft, 979 (this.value as BorderRadiuses).topRight, 980 (this.value as BorderRadiuses).bottomLeft, 981 (this.value as BorderRadiuses).bottomRight); 982 } 983 } 984 } 985 checkObjectDiff(): boolean { 986 if (isResource(this.stageValue) && isResource(this.value)) { 987 return !isResourceEqual(this.stageValue, this.value); 988 } else if (!isResource(this.stageValue) && !isResource(this.value)) { 989 return !((this.stageValue as BorderRadiuses).topLeft === (this.value as BorderRadiuses).topLeft && 990 (this.stageValue as BorderRadiuses).topRight === (this.value as BorderRadiuses).topRight && 991 (this.stageValue as BorderRadiuses).bottomLeft === (this.value as BorderRadiuses).bottomLeft && 992 (this.stageValue as BorderRadiuses).bottomRight === (this.value as BorderRadiuses).bottomRight); 993 } else { 994 return true; 995 } 996 } 997} 998 999class TextAreaBackgroundColorModifier extends ModifierWithKey<ResourceColor> { 1000 constructor(value: ResourceColor) { 1001 super(value); 1002 } 1003 static identity: Symbol = Symbol('textAreaBackgroundColor'); 1004 applyPeer(node: KNode, reset: boolean): void { 1005 if (reset) { 1006 getUINativeModule().textArea.resetBackgroundColor(node); 1007 } else { 1008 getUINativeModule().textArea.setBackgroundColor(node, this.value); 1009 } 1010 } 1011 1012 checkObjectDiff(): boolean { 1013 return !isBaseOrResourceEqual(this.stageValue, this.value); 1014 } 1015} 1016 1017class TextAreaMarginModifier extends ModifierWithKey<ArkPadding> { 1018 constructor(value: ArkPadding) { 1019 super(value); 1020 } 1021 static identity: Symbol = Symbol('textAreaMargin'); 1022 applyPeer(node: KNode, reset: boolean): void { 1023 if (reset) { 1024 getUINativeModule().textArea.resetMargin(node); 1025 } else { 1026 getUINativeModule().textArea.setMargin(node, this.value.top, 1027 this.value.right, this.value.bottom, this.value.left); 1028 } 1029 } 1030 1031 checkObjectDiff(): boolean { 1032 return !isBaseOrResourceEqual(this.stageValue.top, this.value.top) || 1033 !isBaseOrResourceEqual(this.stageValue.right, this.value.right) || 1034 !isBaseOrResourceEqual(this.stageValue.bottom, this.value.bottom) || 1035 !isBaseOrResourceEqual(this.stageValue.left, this.value.left); 1036 } 1037} 1038 1039class TextAreaOnWillInsertModifier extends ModifierWithKey<Callback<InsertValue, boolean>> { 1040 constructor(value: Callback<InsertValue, boolean>) { 1041 super(value); 1042 } 1043 static identity = Symbol('textAreaOnWillInsert'); 1044 applyPeer(node: KNode, reset: boolean): void { 1045 if (reset) { 1046 getUINativeModule().textArea.resetOnWillInsert(node); 1047 } else { 1048 getUINativeModule().textArea.setOnWillInsert(node, this.value); 1049 } 1050 } 1051} 1052 1053class TextAreaOnDidInsertModifier extends ModifierWithKey<Callback<InsertValue>> { 1054 constructor(value: Callback<InsertValue>) { 1055 super(value); 1056 } 1057 static identity = Symbol('textAreaOnDidInsert'); 1058 applyPeer(node: KNode, reset: boolean): void { 1059 if (reset) { 1060 getUINativeModule().textArea.resetOnDidInsert(node); 1061 } else { 1062 getUINativeModule().textArea.setOnDidInsert(node, this.value); 1063 } 1064 } 1065} 1066 1067class TextAreaOnWillDeleteModifier extends ModifierWithKey<Callback<DeleteValue, boolean>> { 1068 constructor(value: Callback<DeleteValue, boolean>) { 1069 super(value); 1070 } 1071 static identity = Symbol('textAreaOnWillDelete'); 1072 applyPeer(node: KNode, reset: boolean): void { 1073 if (reset) { 1074 getUINativeModule().textArea.resetOnWillDelete(node); 1075 } else { 1076 getUINativeModule().textArea.setOnWillDelete(node, this.value); 1077 } 1078 } 1079} 1080 1081class TextAreaOnDidDeleteModifier extends ModifierWithKey<Callback<DeleteValue>> { 1082 constructor(value: Callback<DeleteValue>) { 1083 super(value); 1084 } 1085 static identity = Symbol('textAreaOnDidDelete'); 1086 applyPeer(node: KNode, reset: boolean): void { 1087 if (reset) { 1088 getUINativeModule().textArea.resetOnDidDelete(node); 1089 } else { 1090 getUINativeModule().textArea.setOnDidDelete(node, this.value); 1091 } 1092 } 1093} 1094 1095class TextAreaEnablePreviewTextModifier extends ModifierWithKey<boolean> { 1096 constructor(value: boolean) { 1097 super(value); 1098 } 1099 static identity: Symbol = Symbol('textAreaEnablePreviewText'); 1100 applyPeer(node: KNode, reset: boolean): void { 1101 if (reset) { 1102 getUINativeModule().textArea.resetEnablePreviewText(node); 1103 } else { 1104 getUINativeModule().textArea.setEnablePreviewText(node, this.value!); 1105 } 1106 } 1107 checkObjectDiff(): boolean { 1108 return !isBaseOrResourceEqual(this.stageValue, this.value); 1109 } 1110} 1111 1112class TextAreaEditMenuOptionsModifier extends ModifierWithKey<EditMenuOptions> { 1113 constructor(value: EditMenuOptions) { 1114 super(value); 1115 } 1116 static identity: Symbol = Symbol('textEditMenuOptions'); 1117 applyPeer(node: KNode, reset: boolean): void { 1118 if (reset) { 1119 getUINativeModule().textArea.resetSelectionMenuOptions(node); 1120 } else { 1121 getUINativeModule().textArea.setSelectionMenuOptions(node, this.value); 1122 } 1123 } 1124} 1125 1126class TextAreaEnableHapticFeedbackModifier extends ModifierWithKey<boolean> { 1127 constructor(value: boolean) { 1128 super(value); 1129 } 1130 static identity: Symbol = Symbol('textAreaEnableHapticFeedback'); 1131 applyPeer(node: KNode, reset: boolean): void { 1132 if (reset) { 1133 getUINativeModule().textArea.resetEnableHapticFeedback(node); 1134 } else { 1135 getUINativeModule().textArea.setEnableHapticFeedback(node, this.value!); 1136 } 1137 } 1138 checkObjectDiff(): boolean { 1139 return !isBaseOrResourceEqual(this.stageValue, this.value); 1140 } 1141} 1142 1143class TextAreaInitializeModifier extends ModifierWithKey<TextAreaOptions> { 1144 constructor(value: TextAreaOptions) { 1145 super(value); 1146 } 1147 static identity: Symbol = Symbol('textAreaInitialize'); 1148 applyPeer(node: KNode, reset: boolean): void { 1149 if (reset) { 1150 getUINativeModule().textArea.setTextAreaInitialize(node, undefined, undefined, undefined); 1151 } else { 1152 getUINativeModule().textArea.setTextAreaInitialize(node, this.value?.placeholder, this.value?.text, this.value?.controller); 1153 } 1154 } 1155 checkObjectDiff(): boolean { 1156 return !isBaseOrResourceEqual(this.stageValue?.placeholder, this.value?.placeholder) || 1157 !isBaseOrResourceEqual(this.stageValue?.text, this.value?.text) || 1158 !isBaseOrResourceEqual(this.stageValue?.controller, this.value?.controller); 1159 } 1160} 1161 1162class ArkTextAreaComponent extends ArkComponent implements CommonMethod<TextAreaAttribute> { 1163 constructor(nativePtr: KNode, classType?: ModifierType) { 1164 super(nativePtr, classType); 1165 } 1166 allowChildCount(): number { 1167 return 0; 1168 } 1169 initialize(value: Object[]): TextAreaAttribute { 1170 if (value.length === 1 && isObject(value[0])) { 1171 modifierWithKey(this._modifiersWithKeys, TextAreaInitializeModifier.identity, TextAreaInitializeModifier, value[0]); 1172 } 1173 return this; 1174 } 1175 type(value: TextAreaType): TextAreaAttribute { 1176 modifierWithKey(this._modifiersWithKeys, TextAreaTypeModifier.identity, TextAreaTypeModifier, value); 1177 return this; 1178 } 1179 placeholderColor(value: ResourceColor): TextAreaAttribute { 1180 modifierWithKey(this._modifiersWithKeys, TextAreaPlaceholderColorModifier.identity, TextAreaPlaceholderColorModifier, value); 1181 return this; 1182 } 1183 placeholderFont(value: Font): TextAreaAttribute { 1184 modifierWithKey(this._modifiersWithKeys, TextAreaPlaceholderFontModifier.identity, TextAreaPlaceholderFontModifier, value); 1185 return this; 1186 } 1187 1188 textAlign(value: TextAlign): TextAreaAttribute { 1189 modifierWithKey(this._modifiersWithKeys, TextAreaTextAlignModifier.identity, TextAreaTextAlignModifier, value); 1190 return this; 1191 } 1192 caretColor(value: ResourceColor): TextAreaAttribute { 1193 modifierWithKey(this._modifiersWithKeys, TextAreaCaretColorModifier.identity, TextAreaCaretColorModifier, value); 1194 return this; 1195 } 1196 fontColor(value: ResourceColor): TextAreaAttribute { 1197 modifierWithKey(this._modifiersWithKeys, TextAreaFontColorModifier.identity, TextAreaFontColorModifier, value); 1198 return this; 1199 } 1200 fontSize(value: Length): TextAreaAttribute { 1201 modifierWithKey(this._modifiersWithKeys, TextAreaFontSizeModifier.identity, TextAreaFontSizeModifier, value); 1202 return this; 1203 } 1204 fontStyle(value: FontStyle): TextAreaAttribute { 1205 modifierWithKey(this._modifiersWithKeys, TextAreaFontStyleModifier.identity, TextAreaFontStyleModifier, value); 1206 return this; 1207 } 1208 fontWeight(value: number | FontWeight | string): TextAreaAttribute { 1209 modifierWithKey(this._modifiersWithKeys, TextAreaFontWeightModifier.identity, TextAreaFontWeightModifier, value); 1210 return this; 1211 } 1212 fontFamily(value: ResourceStr): TextAreaAttribute { 1213 modifierWithKey(this._modifiersWithKeys, TextAreaFontFamilyModifier.identity, TextAreaFontFamilyModifier, value); 1214 return this; 1215 } 1216 inputFilter(value: ResourceStr, error?: (value: string) => void): TextAreaAttribute { 1217 let arkValue = new ArkTextInputFilter(); 1218 arkValue.value = value; 1219 arkValue.error = error; 1220 modifierWithKey(this._modifiersWithKeys, TextAreaInputFilterModifier.identity, TextAreaInputFilterModifier, arkValue); 1221 return this; 1222 } 1223 onChange(callback: (value: string) => void): TextAreaAttribute { 1224 modifierWithKey(this._modifiersWithKeys, TextAreaOnChangeModifier.identity, 1225 TextAreaOnChangeModifier, callback); 1226 return this; 1227 } 1228 onTextSelectionChange(callback: (selectionStart: number, selectionEnd: number) => void): TextAreaAttribute { 1229 modifierWithKey(this._modifiersWithKeys, TextAreaOnTextSelectionChangeModifier.identity, 1230 TextAreaOnTextSelectionChangeModifier, callback); 1231 return this; 1232 } 1233 onContentScroll(callback: (totalOffsetX: number, totalOffsetY: number) => void): TextAreaAttribute { 1234 modifierWithKey(this._modifiersWithKeys, TextAreaOnContentScrollModifier.identity, 1235 TextAreaOnContentScrollModifier, callback); 1236 return this; 1237 } 1238 onEditChange(callback: (isEditing: boolean) => void): TextAreaAttribute { 1239 modifierWithKey(this._modifiersWithKeys, TextAreaOnEditChangeModifier.identity, 1240 TextAreaOnEditChangeModifier, callback); 1241 return this; 1242 } 1243 onCopy(callback: (value: string) => void): TextAreaAttribute { 1244 modifierWithKey(this._modifiersWithKeys, TextAreaOnCopyModifier.identity, 1245 TextAreaOnCopyModifier, callback); 1246 return this; 1247 } 1248 onCut(callback: (value: string) => void): TextAreaAttribute { 1249 modifierWithKey(this._modifiersWithKeys, TextAreaOnCutModifier.identity, 1250 TextAreaOnCutModifier, callback); 1251 return this; 1252 } 1253 onPaste(callback: (value: string) => void): TextAreaAttribute { 1254 modifierWithKey(this._modifiersWithKeys, TextAreaOnPasteModifier.identity, 1255 TextAreaOnPasteModifier, callback); 1256 return this; 1257 } 1258 copyOption(value: CopyOptions): TextAreaAttribute { 1259 modifierWithKey(this._modifiersWithKeys, TextAreaCopyOptionModifier.identity, TextAreaCopyOptionModifier, value); 1260 return this; 1261 } 1262 1263 enableKeyboardOnFocus(value: boolean): TextAreaAttribute { 1264 modifierWithKey(this._modifiersWithKeys, TextAreaEnableKeyboardOnFocusModifier.identity, TextAreaEnableKeyboardOnFocusModifier, value); 1265 return this; 1266 } 1267 1268 maxLength(value: number): TextAreaAttribute { 1269 modifierWithKey(this._modifiersWithKeys, TextAreaMaxLengthModifier.identity, TextAreaMaxLengthModifier, value); 1270 return this; 1271 } 1272 showCounter(value: boolean, options?: InputCounterOptions): TextAreaAttribute { 1273 let arkValue: ArkTextFieldShowCounter = new ArkTextFieldShowCounter(); 1274 arkValue.value = value; 1275 arkValue.highlightBorder = options?.highlightBorder; 1276 arkValue.thresholdPercentage = options?.thresholdPercentage; 1277 modifierWithKey(this._modifiersWithKeys, TextAreaShowCounterModifier.identity, TextAreaShowCounterModifier, arkValue); 1278 return this; 1279 } 1280 style(value: TextContentStyle): TextAreaAttribute { 1281 modifierWithKey(this._modifiersWithKeys, TextAreaStyleModifier.identity, TextAreaStyleModifier, value); 1282 return this; 1283 } 1284 barState(value: BarState): TextAreaAttribute { 1285 modifierWithKey(this._modifiersWithKeys, TextAreaBarStateModifier.identity, TextAreaBarStateModifier, value); 1286 return this; 1287 } 1288 selectionMenuHidden(value: boolean): TextAreaAttribute { 1289 modifierWithKey(this._modifiersWithKeys, TextAreaSelectionMenuHiddenModifier.identity, TextAreaSelectionMenuHiddenModifier, value); 1290 return this; 1291 } 1292 maxLines(value: number): TextAreaAttribute { 1293 modifierWithKey(this._modifiersWithKeys, TextAreaMaxLinesModifier.identity, TextAreaMaxLinesModifier, value); 1294 return this; 1295 } 1296 fontFeature(value: FontFeature): TextAreaAttribute { 1297 modifierWithKey(this._modifiersWithKeys, TextAreaFontFeatureModifier.identity, TextAreaFontFeatureModifier, value); 1298 return this; 1299 } 1300 customKeyboard(value: CustomBuilder): TextAreaAttribute { 1301 throw new Error('Method not implemented.'); 1302 } 1303 decoration(value: { type: TextDecorationType; color?: ResourceColor; style?: TextDecorationStyle }): TextAreaAttribute { 1304 modifierWithKey(this._modifiersWithKeys, TextAreaDecorationModifier.identity, TextAreaDecorationModifier, value); 1305 return this; 1306 } 1307 letterSpacing(value: number | string): this { 1308 modifierWithKey(this._modifiersWithKeys, TextAreaLetterSpacingModifier.identity, TextAreaLetterSpacingModifier, value); 1309 return this; 1310 } 1311 lineHeight(value: number | string | Resource): this { 1312 modifierWithKey(this._modifiersWithKeys, TextAreaLineHeightModifier.identity, TextAreaLineHeightModifier, value); 1313 return this; 1314 } 1315 lineSpacing(value: LengthMetrics): this { 1316 modifierWithKey(this._modifiersWithKeys, TextAreaLineSpacingModifier.identity, TextAreaLineSpacingModifier, value); 1317 return this; 1318 } 1319 wordBreak(value: WordBreak): this { 1320 modifierWithKey(this._modifiersWithKeys, TextAreaWordBreakModifier.identity, TextAreaWordBreakModifier, value); 1321 return this; 1322 } 1323 lineBreakStrategy(value: LineBreakStrategy): this { 1324 modifierWithKey(this._modifiersWithKeys, TextAreaLineBreakStrategyModifier.identity, 1325 TextAreaLineBreakStrategyModifier, value); 1326 return this; 1327 } 1328 minFontSize(value: number | string | Resource): TextAreaAttribute { 1329 modifierWithKey(this._modifiersWithKeys, TextAreaMinFontSizeModifier.identity, TextAreaMinFontSizeModifier, value); 1330 return this; 1331 } 1332 maxFontSize(value: number | string | Resource): TextAreaAttribute { 1333 modifierWithKey(this._modifiersWithKeys, TextAreaMaxFontSizeModifier.identity, TextAreaMaxFontSizeModifier, value); 1334 return this; 1335 } 1336 heightAdaptivePolicy(value: TextHeightAdaptivePolicy): TextAreaAttribute { 1337 modifierWithKey(this._modifiersWithKeys, TextAreaHeightAdaptivePolicyModifier.identity, TextAreaHeightAdaptivePolicyModifier, value); 1338 return this; 1339 } 1340 selectedBackgroundColor(value: ResourceColor): this { 1341 modifierWithKey(this._modifiersWithKeys, TextAreaSelectedBackgroundColorModifier.identity, TextAreaSelectedBackgroundColorModifier, value); 1342 return this; 1343 } 1344 caretStyle(value: CaretStyle): this { 1345 modifierWithKey(this._modifiersWithKeys, TextAreaCaretStyleModifier.identity, TextAreaCaretStyleModifier, value); 1346 return this; 1347 } 1348 textOverflow(value: TextOverflow): this { 1349 modifierWithKey(this._modifiersWithKeys, TextAreaTextOverflowModifier.identity, TextAreaTextOverflowModifier, value); 1350 return this; 1351 } 1352 textIndent(value: Dimension): this { 1353 modifierWithKey(this._modifiersWithKeys, TextAreaTextIndentModifier.identity, TextAreaTextIndentModifier, value); 1354 return this; 1355 } 1356 enterKeyType(value: EnterKeyType): TextAreaAttribute { 1357 modifierWithKey(this._modifiersWithKeys, TextAreaEnterKeyTypeModifier.identity, 1358 TextAreaEnterKeyTypeModifier, value); 1359 return this; 1360 } 1361 padding(value: Padding | Length): this { 1362 let arkValue = new ArkPadding(); 1363 if (value !== null && value !== undefined) { 1364 if (isLengthType(value) || isResource(value)) { 1365 arkValue.top = value; 1366 arkValue.right = value; 1367 arkValue.bottom = value; 1368 arkValue.left = value; 1369 } 1370 else { 1371 arkValue.top = value.top; 1372 arkValue.right = value.right; 1373 arkValue.bottom = value.bottom; 1374 arkValue.left = value.left; 1375 } 1376 modifierWithKey(this._modifiersWithKeys, TextAreaPaddingModifier.identity, TextAreaPaddingModifier, arkValue); 1377 } 1378 else { 1379 modifierWithKey(this._modifiersWithKeys, TextAreaPaddingModifier.identity, TextAreaPaddingModifier, undefined); 1380 } 1381 return this; 1382 } 1383 onSubmit(callback: (enterKey: EnterKeyType, event: SubmitEvent) => void): this { 1384 modifierWithKey(this._modifiersWithKeys, TextAreaOnSubmitModifier.identity, 1385 TextAreaOnSubmitModifier, callback); 1386 return this; 1387 } 1388 contentType(value: ContentType): this { 1389 modifierWithKey(this._modifiersWithKeys, TextAreaContentTypeModifier.identity, 1390 TextAreaContentTypeModifier, value); 1391 return this; 1392 } 1393 enableAutoFill(value: boolean): this { 1394 modifierWithKey(this._modifiersWithKeys, TextAreaEnableAutoFillModifier.identity, 1395 TextAreaEnableAutoFillModifier, value); 1396 return this; 1397 } 1398 border(value: BorderOptions): this { 1399 let borderValue = valueToArkBorder(value); 1400 modifierWithKey(this._modifiersWithKeys, TextAreaBorderModifier.identity, TextAreaBorderModifier, borderValue); 1401 return this; 1402 } 1403 borderWidth(value: Length | EdgeWidths): this { 1404 modifierWithKey(this._modifiersWithKeys, TextAreaBorderWidthModifier.identity, TextAreaBorderWidthModifier, value); 1405 return this; 1406 } 1407 borderColor(value: ResourceColor | EdgeColors): this { 1408 modifierWithKey(this._modifiersWithKeys, TextAreaBorderColorModifier.identity, TextAreaBorderColorModifier, value); 1409 return this; 1410 } 1411 borderStyle(value: BorderStyle | EdgeStyles): this { 1412 modifierWithKey(this._modifiersWithKeys, TextAreaBorderStyleModifier.identity, TextAreaBorderStyleModifier, value); 1413 return this; 1414 } 1415 borderRadius(value: Length | BorderRadiuses): this { 1416 modifierWithKey(this._modifiersWithKeys, TextAreaBorderRadiusModifier.identity, TextAreaBorderRadiusModifier, value); 1417 return this; 1418 } 1419 backgroundColor(value: ResourceColor): this { 1420 modifierWithKey(this._modifiersWithKeys, TextAreaBackgroundColorModifier.identity, TextAreaBackgroundColorModifier, value); 1421 return this; 1422 } 1423 margin(value: Margin | Length): this { 1424 let arkValue = new ArkPadding(); 1425 if (value !== null && value !== undefined) { 1426 if (isLengthType(value) || isResource(value)) { 1427 arkValue.top = <Length>value; 1428 arkValue.right = <Length>value; 1429 arkValue.bottom = <Length>value; 1430 arkValue.left = <Length>value; 1431 } else { 1432 arkValue.top = (<Margin>value).top; 1433 arkValue.right = (<Margin>value).right; 1434 arkValue.bottom = (<Margin>value).bottom; 1435 arkValue.left = (<Margin>value).left; 1436 } 1437 modifierWithKey(this._modifiersWithKeys, TextAreaMarginModifier.identity, TextAreaMarginModifier, arkValue); 1438 } else { 1439 modifierWithKey(this._modifiersWithKeys, TextAreaMarginModifier.identity, TextAreaMarginModifier, undefined); 1440 } 1441 return this; 1442 } 1443 onWillInsert(callback: Callback<InsertValue, boolean>): this { 1444 modifierWithKey(this._modifiersWithKeys, TextAreaOnWillInsertModifier.identity, TextAreaOnWillInsertModifier, callback); 1445 return this; 1446 } 1447 onDidInsert(callback: Callback<InsertValue>): this { 1448 modifierWithKey(this._modifiersWithKeys, TextAreaOnDidInsertModifier.identity, TextAreaOnDidInsertModifier, callback); 1449 return this; 1450 } 1451 onWillDelete(callback: Callback<DeleteValue, boolean>): this { 1452 modifierWithKey(this._modifiersWithKeys, TextAreaOnWillDeleteModifier.identity, TextAreaOnWillDeleteModifier, callback); 1453 return this; 1454 } 1455 onDidDelete(callback: Callback<DeleteValue>): this { 1456 modifierWithKey(this._modifiersWithKeys, TextAreaOnDidDeleteModifier.identity, TextAreaOnDidDeleteModifier, callback); 1457 return this; 1458 } 1459 enablePreviewText(value: boolean): this { 1460 modifierWithKey(this._modifiersWithKeys, TextAreaEnablePreviewTextModifier.identity, TextAreaEnablePreviewTextModifier, value); 1461 return this; 1462 } 1463 editMenuOptions(value: EditMenuOptions): this { 1464 modifierWithKey(this._modifiersWithKeys, TextAreaEditMenuOptionsModifier.identity, 1465 TextAreaEditMenuOptionsModifier, value); 1466 return this; 1467 } 1468 enableHapticFeedback(value: boolean): this { 1469 modifierWithKey(this._modifiersWithKeys, TextAreaEnableHapticFeedbackModifier.identity, TextAreaEnableHapticFeedbackModifier, value); 1470 return this; 1471 } 1472} 1473// @ts-ignore 1474globalThis.TextArea.attributeModifier = function (modifier: ArkComponent): void { 1475 attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => { 1476 return new ArkTextAreaComponent(nativePtr); 1477 }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => { 1478 return new modifierJS.TextAreaModifier(nativePtr, classType); 1479 }); 1480}; 1481