• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
18class SearchSelectionMenuHiddenModifier extends ModifierWithKey<boolean> {
19  constructor(value: boolean) {
20    super(value);
21  }
22  static identity = Symbol('searchSelectionMenuHidden');
23  applyPeer(node: KNode, reset: boolean): void {
24    if (reset) {
25      getUINativeModule().search.resetSelectionMenuHidden(node);
26    } else {
27      getUINativeModule().search.setSelectionMenuHidden(node, this.value!);
28    }
29  }
30  checkObjectDiff(): boolean {
31    return this.stageValue !== this.value;
32  }
33}
34
35class SearchCaretStyleModifier extends ModifierWithKey<CaretStyle> {
36  constructor(value: CaretStyle) {
37    super(value);
38  }
39  static identity = Symbol('searchCaretStyle');
40  applyPeer(node: KNode, reset: boolean): void {
41    if (reset) {
42      getUINativeModule().search.resetCaretStyle(node);
43    } else {
44      getUINativeModule().search.setCaretStyle(node, this.value.width,
45        this.value.color);
46    }
47  }
48  checkObjectDiff(): boolean {
49    return !isBaseOrResourceEqual(this.stageValue.width, this.value.width) ||
50      !isBaseOrResourceEqual(this.stageValue.color, this.value.color);
51  }
52}
53
54class SearchEnableKeyboardOnFocusModifier extends ModifierWithKey<boolean> {
55  constructor(value: boolean) {
56    super(value);
57  }
58  static identity = Symbol('searchEnableKeyboardOnFocus');
59  applyPeer(node: KNode, reset: boolean): void {
60    if (reset) {
61      getUINativeModule().search.resetEnableKeyboardOnFocus(node);
62    } else {
63      getUINativeModule().search.setEnableKeyboardOnFocus(node, this.value!);
64    }
65  }
66  checkObjectDiff(): boolean {
67    return this.stageValue !== this.value;
68  }
69}
70
71class SearchSearchIconModifier extends ModifierWithKey<IconOptions> {
72  constructor(value: IconOptions) {
73    super(value);
74  }
75  static identity = Symbol('searchSearchIcon');
76  applyPeer(node: KNode, reset: boolean): void {
77    if (reset) {
78      getUINativeModule().search.resetSearchIcon(node);
79    } else {
80      getUINativeModule().search.setSearchIcon(node, this.value.size,
81        this.value.color, this.value.src);
82    }
83  }
84  checkObjectDiff(): boolean {
85    return !isBaseOrResourceEqual(this.stageValue.size, this.value.size) ||
86      !isBaseOrResourceEqual(this.stageValue.color, this.value.color) ||
87      !isBaseOrResourceEqual(this.stageValue.src, this.value.src);
88  }
89}
90
91class SearchPlaceholderFontModifier extends ModifierWithKey<Font> {
92  constructor(value: Font) {
93    super(value);
94  }
95  static identity = Symbol('searchPlaceholderFont');
96  applyPeer(node: KNode, reset: boolean): void {
97    if (reset) {
98      getUINativeModule().search.resetPlaceholderFont(node);
99    } else {
100      getUINativeModule().search.setPlaceholderFont(node, this.value.size,
101        this.value.weight, this.value.family, this.value.style);
102    }
103  }
104  checkObjectDiff(): boolean {
105    return this.stageValue.weight !== this.value.weight ||
106      this.stageValue.style !== this.value.style ||
107      !isBaseOrResourceEqual(this.stageValue.size, this.value.size) ||
108      !isBaseOrResourceEqual(this.stageValue.family, this.value.family);
109  }
110}
111
112class SearchSearchButtonModifier extends ModifierWithKey<ArkSearchButton> {
113  constructor(value: ArkSearchButton) {
114    super(value);
115  }
116  static identity = Symbol('searchSearchButton');
117  applyPeer(node: KNode, reset: boolean): void {
118    if (reset) {
119      getUINativeModule().search.resetSearchButton(node);
120    } else {
121      getUINativeModule().search.setSearchButton(node, this.value.value,
122        this.value.fontSize, this.value.fontColor);
123    }
124  }
125  checkObjectDiff(): boolean {
126    return this.stageValue.value !== this.value.value ||
127      !isBaseOrResourceEqual(this.stageValue.fontSize, this.value.fontSize) ||
128      !isBaseOrResourceEqual(this.stageValue.fontColor, this.value.fontColor);
129  }
130}
131
132class SearchFontColorModifier extends ModifierWithKey<ResourceColor> {
133  constructor(value: ResourceColor) {
134    super(value);
135  }
136  static identity = Symbol('searchFontColor');
137  applyPeer(node: KNode, reset: boolean): void {
138    if (reset) {
139      getUINativeModule().search.resetFontColor(node);
140    } else {
141      getUINativeModule().search.setFontColor(node, this.value!);
142    }
143  }
144  checkObjectDiff(): boolean {
145    return !isBaseOrResourceEqual(this.stageValue, this.value);
146  }
147}
148
149class SearchCopyOptionModifier extends ModifierWithKey<CopyOptions> {
150  constructor(value: CopyOptions) {
151    super(value);
152  }
153  static identity = Symbol('searchCopyOption');
154  applyPeer(node: KNode, reset: boolean): void {
155    if (reset) {
156      getUINativeModule().search.resetCopyOption(node);
157    } else {
158      getUINativeModule().search.setCopyOption(node, this.value!);
159    }
160  }
161  checkObjectDiff(): boolean {
162    return this.stageValue !== this.value;
163  }
164}
165
166class SearchTextFontModifier extends ModifierWithKey<Font> {
167  constructor(value: Font) {
168    super(value);
169  }
170  static identity = Symbol('searchTextFont');
171  applyPeer(node: KNode, reset: boolean): void {
172    if (reset) {
173      getUINativeModule().search.resetTextFont(node);
174    } else {
175      getUINativeModule().search.setTextFont(node, this.value.size, this.value.weight, this.value.family, this.value.style);
176    }
177  }
178  checkObjectDiff(): boolean {
179    return this.stageValue.weight !== this.value.weight ||
180      this.stageValue.style !== this.value.style ||
181      !isBaseOrResourceEqual(this.stageValue.size, this.value.size) ||
182      !isBaseOrResourceEqual(this.stageValue.family, this.value.family);
183  }
184}
185
186class SearchPlaceholderColorModifier extends ModifierWithKey<ResourceColor> {
187  constructor(value: ResourceColor) {
188    super(value);
189  }
190  static identity = Symbol('searchPlaceholderColor');
191  applyPeer(node: KNode, reset: boolean): void {
192    if (reset) {
193      getUINativeModule().search.resetPlaceholderColor(node);
194    } else {
195      getUINativeModule().search.setPlaceholderColor(node, this.value!);
196    }
197  }
198  checkObjectDiff(): boolean {
199    return !isBaseOrResourceEqual(this.stageValue, this.value);
200  }
201}
202
203class SearchCancelButtonModifier extends ModifierWithKey<{ style?: CancelButtonStyle, icon?: IconOptions }> {
204  constructor(value: { style?: CancelButtonStyle, icon?: IconOptions }) {
205    super(value);
206  }
207  static identity = Symbol('searchCancelButton');
208  applyPeer(node: KNode, reset: boolean): void {
209    if (reset) {
210      getUINativeModule().search.resetCancelButton(node);
211    } else {
212      getUINativeModule().search.setCancelButton(node, this.value.style,
213        this.value.icon?.size, this.value.icon?.color, this.value.icon?.src);
214    }
215  }
216  checkObjectDiff(): boolean {
217    return this.stageValue.style !== this.value.style ||
218      !isBaseOrResourceEqual(this.stageValue.icon?.size, this.value.icon?.size) ||
219      !isBaseOrResourceEqual(this.stageValue.icon?.color, this.value.icon?.color) ||
220      !isBaseOrResourceEqual(this.stageValue.icon?.src, this.value.icon?.src);
221  }
222}
223
224class SearchTextAlignModifier extends ModifierWithKey<TextAlign> {
225  constructor(value: TextAlign) {
226    super(value);
227  }
228  static identity = Symbol('searchTextAlign');
229  applyPeer(node: KNode, reset: boolean): void {
230    if (reset) {
231      getUINativeModule().search.resetTextAlign(node);
232    } else {
233      getUINativeModule().search.setTextAlign(node, this.value!);
234    }
235  }
236  checkObjectDiff(): boolean {
237    return this.stageValue !== this.value;
238  }
239}
240
241class SearchEnterKeyTypeModifier extends ModifierWithKey<number> {
242  constructor(value: number) {
243    super(value);
244  }
245  static identity: Symbol = Symbol('searchEnterKeyType');
246  applyPeer(node: KNode, reset: boolean): void {
247    if (reset) {
248      getUINativeModule().search.resetSearchEnterKeyType(node);
249    } else {
250      getUINativeModule().search.setSearchEnterKeyType(node, this.value);
251    }
252  }
253
254  checkObjectDiff(): boolean {
255    return !isBaseOrResourceEqual(this.stageValue, this.value);
256  }
257}
258
259class SearchHeightModifier extends ModifierWithKey<Length> {
260  constructor(value: Length) {
261    super(value);
262  }
263  static identity: Symbol = Symbol('searchHeight');
264  applyPeer(node: KNode, reset: boolean): void {
265    if (reset) {
266      getUINativeModule().search.resetSearchHeight(node);
267    } else {
268      getUINativeModule().search.setSearchHeight(node, this.value);
269    }
270  }
271
272  checkObjectDiff(): boolean {
273    return !isBaseOrResourceEqual(this.stageValue, this.value);
274  }
275}
276
277class SearchFontFeatureModifier extends ModifierWithKey<FontFeature> {
278  constructor(value: FontFeature) {
279    super(value);
280  }
281  static identity: Symbol = Symbol('searchFontFeature');
282  applyPeer(node: KNode, reset: boolean): void {
283    if (reset) {
284      getUINativeModule().search.resetFontFeature(node);
285    } else {
286      getUINativeModule().search.setFontFeature(node, this.value!);
287    }
288  }
289  checkObjectDiff(): boolean {
290    return !isBaseOrResourceEqual(this.stageValue, this.value);
291  }
292}
293
294class SearchDecorationModifier extends ModifierWithKey<{ type: TextDecorationType; color?: ResourceColor; style?: TextDecorationStyle }> {
295  constructor(value: { type: TextDecorationType; color?: ResourceColor; style?: TextDecorationStyle }) {
296    super(value);
297  }
298  static identity: Symbol = Symbol('searchDecoration');
299  applyPeer(node: KNode, reset: boolean): void {
300    if (reset) {
301      getUINativeModule().search.resetDecoration(node);
302    } else {
303      getUINativeModule().search.setDecoration(node, this.value!.type, this.value!.color, this.value!.style);
304    }
305  }
306
307  checkObjectDiff(): boolean {
308    if (this.stageValue.type !== this.value.type || this.stageValue.style !== this.value.style) {
309      return true;
310    }
311    if (isResource(this.stageValue.color) && isResource(this.value.color)) {
312      return !isResourceEqual(this.stageValue.color, this.value.color);
313    } else if (!isResource(this.stageValue.color) && !isResource(this.value.color)) {
314      return !(this.stageValue.color === this.value.color);
315    } else {
316      return true;
317    }
318  }
319}
320
321class SearchLetterSpacingModifier extends ModifierWithKey<number | string> {
322  constructor(value: number | string) {
323    super(value);
324  }
325  static identity: Symbol = Symbol('searchLetterSpacing');
326  applyPeer(node: KNode, reset: boolean): void {
327    if (reset) {
328      getUINativeModule().search.resetLetterSpacing(node);
329    } else {
330      getUINativeModule().search.setLetterSpacing(node, this.value);
331    }
332  }
333}
334class SearchIdModifier extends ModifierWithKey<string> {
335  constructor(value: string) {
336    super(value);
337  }
338  static identity: Symbol = Symbol('searchId');
339  applyPeer(node: KNode, reset: boolean): void {
340    if (reset) {
341      getUINativeModule().search.resetSearchInspectorId(node);
342    } else {
343      getUINativeModule().search.setSearchInspectorId(node, this.value);
344    }
345  }
346
347  checkObjectDiff(): boolean {
348    return !isBaseOrResourceEqual(this.stageValue, this.value);
349  }
350}
351
352class SearchMinFontSizeModifier extends ModifierWithKey<number | string | Resource> {
353  constructor(value: number | string | Resource) {
354    super(value);
355  }
356  static identity: Symbol = Symbol('searchMinFontSize');
357  applyPeer(node: KNode, reset: boolean): void {
358    if (reset) {
359      getUINativeModule().search.resetSearchMinFontSize(node);
360    } else {
361      getUINativeModule().search.setSearchMinFontSize(node, this.value);
362    }
363  }
364
365  checkObjectDiff(): boolean {
366    return !isBaseOrResourceEqual(this.stageValue, this.value);
367  }
368}
369
370class SearchLineHeightModifier extends ModifierWithKey<number | string | Resource> {
371  constructor(value: number | string | Resource) {
372    super(value);
373  }
374  static identity: Symbol = Symbol('searchLineHeight');
375  applyPeer(node: KNode, reset: boolean): void {
376    if (reset) {
377      getUINativeModule().search.resetLineHeight(node);
378    } else {
379      getUINativeModule().search.setLineHeight(node, this.value);
380    }
381  }
382
383  checkObjectDiff(): boolean {
384    return !isBaseOrResourceEqual(this.stageValue, this.value);
385  }
386}
387
388class SearchMaxFontSizeModifier extends ModifierWithKey<number | string | Resource> {
389  constructor(value: number | string | Resource) {
390    super(value);
391  }
392  static identity: Symbol = Symbol('searchMaxFontSize');
393  applyPeer(node: KNode, reset: boolean): void {
394    if (reset) {
395      getUINativeModule().search.resetSearchMaxFontSize(node);
396    } else {
397      getUINativeModule().search.setSearchMaxFontSize(node, this.value);
398    }
399  }
400
401  checkObjectDiff(): boolean {
402    return !isBaseOrResourceEqual(this.stageValue, this.value);
403  }
404}
405
406class SearchInputFilterModifier extends ModifierWithKey<ArkSearchInputFilter> {
407  constructor(value: ArkSearchInputFilter) {
408    super(value);
409  }
410  static identity: Symbol = Symbol('searchInputFilter');
411  applyPeer(node: KNode, reset: boolean): void {
412    if (reset) {
413      getUINativeModule().search.resetInputFilter(node);
414    } else {
415      getUINativeModule().search.setInputFilter(node, this.value.value, this.value.error);
416    }
417  }
418}
419
420class SearchSelectedBackgroundColorModifier extends ModifierWithKey<ResourceColor> {
421  constructor(value: ResourceColor) {
422    super(value);
423  }
424  static identity: Symbol = Symbol('searchSelectedBackgroundColor');
425  applyPeer(node: KNode, reset: boolean): void {
426    if (reset) {
427      getUINativeModule().search.resetSelectedBackgroundColor(node);
428    } else {
429      getUINativeModule().search.setSelectedBackgroundColor(node, this.value!);
430    }
431  }
432  checkObjectDiff(): boolean {
433    return !isBaseOrResourceEqual(this.stageValue, this.value);
434  }
435}
436
437class SearchTextIndentModifier extends ModifierWithKey<Dimension> {
438  constructor(value: Dimension) {
439    super(value);
440  }
441  static identity: Symbol = Symbol('searchTextIndent');
442  applyPeer(node: KNode, reset: boolean): void {
443    if (reset) {
444      getUINativeModule().search.resetTextIndent(node);
445    } else {
446      getUINativeModule().search.setTextIndent(node, this.value!);
447    }
448  }
449  checkObjectDiff(): boolean {
450    return !isBaseOrResourceEqual(this.stageValue, this.value);
451  }
452}
453
454class SearchMaxLengthModifier extends ModifierWithKey<number> {
455  constructor(value: number) {
456    super(value);
457  }
458  static identity: Symbol = Symbol('searchMaxLength');
459  applyPeer(node: KNode, reset: boolean): void {
460    if (reset) {
461      getUINativeModule().search.resetMaxLength(node);
462    } else {
463      getUINativeModule().search.setMaxLength(node, this.value!);
464    }
465  }
466  checkObjectDiff(): boolean {
467    return !isBaseOrResourceEqual(this.stageValue, this.value);
468  }
469}
470
471class SearchTypeModifier extends ModifierWithKey<number> {
472  constructor(value: number) {
473    super(value);
474  }
475  static identity: Symbol = Symbol('searchType');
476  applyPeer(node: KNode, reset: boolean): void {
477    if (reset) {
478      getUINativeModule().search.resetType(node);
479    } else {
480      getUINativeModule().search.setType(node, this.value!);
481    }
482  }
483  checkObjectDiff(): boolean {
484    return !isBaseOrResourceEqual(this.stageValue, this.value);
485  }
486}
487
488class SearchOnEditChangeModifier extends ModifierWithKey<(isEditing: boolean) => void> {
489  constructor(value: (isEditing: boolean) => void) {
490    super(value);
491  }
492  static identity = Symbol('searchOnEditChange');
493  applyPeer(node: KNode, reset: boolean): void {
494    if (reset) {
495      getUINativeModule().search.resetOnEditChange(node);
496    } else {
497      getUINativeModule().search.setOnEditChange(node, this.value);
498    }
499  }
500}
501
502class SearchOnSubmitModifier extends ModifierWithKey<(info: string, event?: SubmitEvent) => void> {
503  constructor(value: (info: string, event?: SubmitEvent) => void) {
504    super(value);
505  }
506  static identity = Symbol('searchOnSubmit');
507  applyPeer(node: KNode, reset: boolean): void {
508    if (reset) {
509      getUINativeModule().search.resetOnSubmit(node);
510    } else {
511      getUINativeModule().search.setOnSubmit(node, this.value);
512    }
513  }
514}
515
516class SearchOnCopyModifier extends ModifierWithKey<(value: string) => void> {
517  constructor(value: (value: string) => void) {
518    super(value);
519  }
520  static identity = Symbol('searchOnCopy');
521  applyPeer(node: KNode, reset: boolean): void {
522    if (reset) {
523      getUINativeModule().search.resetOnCopy(node);
524    } else {
525      getUINativeModule().search.setOnCopy(node, this.value);
526    }
527  }
528}
529
530class SearchOnCutModifier extends ModifierWithKey<(value: string) => void> {
531  constructor(value: (value: string) => void) {
532    super(value);
533  }
534  static identity = Symbol('searchOnCut');
535  applyPeer(node: KNode, reset: boolean): void {
536    if (reset) {
537      getUINativeModule().search.resetOnCut(node);
538    } else {
539      getUINativeModule().search.setOnCut(node, this.value);
540    }
541  }
542}
543
544class SearchOnPasteModifier extends ModifierWithKey<(value: string, event: PasteEvent) => void> {
545  constructor(value: (value: string, event: PasteEvent) => void) {
546    super(value);
547  }
548  static identity = Symbol('searchOnPaste');
549  applyPeer(node: KNode, reset: boolean): void {
550    if (reset) {
551      getUINativeModule().search.resetOnPaste(node);
552    } else {
553      getUINativeModule().search.setOnPaste(node, this.value);
554    }
555  }
556}
557
558class SearchOnChangeModifier extends ModifierWithKey<(value: ChangeValueInfo) => void> {
559  constructor(value: (value: ChangeValueInfo) => void) {
560    super(value);
561  }
562  static identity = Symbol('searchOnChange');
563  applyPeer(node: KNode, reset: boolean): void {
564    if (reset) {
565      getUINativeModule().search.resetOnChange(node);
566    } else {
567      getUINativeModule().search.setOnChange(node, this.value);
568    }
569  }
570}
571
572class SearchOnTextSelectionChangeModifier extends ModifierWithKey<(selectionStart: number, selectionEnd: number) => void> {
573  constructor(value: (selectionStart: number, selectionEnd: number) => void) {
574    super(value);
575  }
576  static identity = Symbol('searchOnTextSelectionChange');
577  applyPeer(node: KNode, reset: boolean): void {
578    if (reset) {
579      getUINativeModule().search.resetOnTextSelectionChange(node);
580    } else {
581      getUINativeModule().search.setOnTextSelectionChange(node, this.value);
582    }
583  }
584}
585
586class SearchOnContentScrollModifier extends ModifierWithKey<(totalOffsetX: number, totalOffsetY: number) => void> {
587  constructor(value: (totalOffsetX: number, totalOffsetY: number) => void) {
588    super(value);
589  }
590  static identity = Symbol('searchOnContentScroll');
591  applyPeer(node: KNode, reset: boolean): void {
592    if (reset) {
593      getUINativeModule().search.resetOnContentScroll(node);
594    } else {
595      getUINativeModule().search.setOnContentScroll(node, this.value);
596    }
597  }
598}
599
600class SearchShowCounterModifier extends ModifierWithKey<ArkTextFieldShowCounter> {
601  constructor(value: ArkTextFieldShowCounter) {
602    super(value);
603  }
604  static identity = Symbol('searchShowCounter');
605  applyPeer(node: KNode, reset: boolean): void {
606    if (reset) {
607      getUINativeModule().search.resetShowCounter(node);
608    }
609    else {
610      getUINativeModule().search.setShowCounter(node, this.value.value!, this.value.highlightBorder, this.value.thresholdPercentage);
611    }
612  }
613  checkObjectDiff(): boolean {
614    return !isBaseOrResourceEqual(this.stageValue.value, this.value.value) ||
615      !isBaseOrResourceEqual(this.stageValue.highlightBorder, this.value.highlightBorder) ||
616      !isBaseOrResourceEqual(this.stageValue.thresholdPercentage, this.value.thresholdPercentage);
617  }
618}
619
620class SearchInitializeModifier extends ModifierWithKey<SearchParam> {
621  constructor(value: SearchParam) {
622    super(value);
623  }
624  static identity: Symbol = Symbol('searchInitialize');
625  applyPeer(node: KNode, reset: boolean): void {
626    if (reset) {
627      getUINativeModule().search.resetSearchInitialize(node);
628    } else {
629      getUINativeModule().search.setSearchInitialize(node, this.value.value,
630        this.value.placeholder, this.value.icon, this.value.controller);
631    }
632  }
633}
634
635class SearchOnWillChangeModifier extends ModifierWithKey<Callback<ChangeValueInfo, boolean>> {
636  constructor(value: Callback<ChangeValueInfo, boolean>) {
637    super(value);
638  }
639  static identity = Symbol('searchOnWillChange');
640  applyPeer(node: KNode, reset: boolean): void {
641    if (reset) {
642      getUINativeModule().search.resetOnWillChange(node);
643    } else {
644      getUINativeModule().search.setOnWillChange(node, this.value);
645    }
646  }
647}
648
649class SearchOnWillInsertModifier extends ModifierWithKey<Callback<InsertValue, boolean>> {
650  constructor(value: Callback<InsertValue, boolean>) {
651    super(value);
652  }
653  static identity = Symbol('searchOnWillInsert');
654  applyPeer(node: KNode, reset: boolean): void {
655    if (reset) {
656      getUINativeModule().search.resetOnWillInsert(node);
657    } else {
658      getUINativeModule().search.setOnWillInsert(node, this.value);
659    }
660  }
661}
662
663class SearchOnDidInsertModifier extends ModifierWithKey<Callback<InsertValue>> {
664  constructor(value: Callback<InsertValue>) {
665    super(value);
666  }
667  static identity = Symbol('searchOnDidInsert');
668  applyPeer(node: KNode, reset: boolean): void {
669    if (reset) {
670      getUINativeModule().search.resetOnDidInsert(node);
671    } else {
672      getUINativeModule().search.setOnDidInsert(node, this.value);
673    }
674  }
675}
676
677class SearchOnWillDeleteModifier extends ModifierWithKey<Callback<DeleteValue, boolean>> {
678  constructor(value: Callback<DeleteValue, boolean>) {
679    super(value);
680  }
681  static identity = Symbol('searchOnWillDelete');
682  applyPeer(node: KNode, reset: boolean): void {
683    if (reset) {
684      getUINativeModule().search.resetOnWillDelete(node);
685    } else {
686      getUINativeModule().search.setOnWillDelete(node, this.value);
687    }
688  }
689}
690
691class SearchOnDidDeleteModifier extends ModifierWithKey<Callback<DeleteValue>> {
692  constructor(value: Callback<DeleteValue>) {
693    super(value);
694  }
695  static identity = Symbol('searchOnDidDelete');
696  applyPeer(node: KNode, reset: boolean): void {
697    if (reset) {
698      getUINativeModule().search.resetOnDidDelete(node);
699    } else {
700      getUINativeModule().search.setOnDidDelete(node, this.value);
701    }
702  }
703}
704
705class SearchEnablePreviewTextModifier extends ModifierWithKey<boolean> {
706  constructor(value: boolean) {
707    super(value);
708  }
709  static identity: Symbol = Symbol('searchEnablePreviewText');
710  applyPeer(node: KNode, reset: boolean): void {
711    if (reset) {
712      getUINativeModule().search.resetEnablePreviewText(node);
713    } else {
714      getUINativeModule().search.setEnablePreviewText(node, this.value!);
715    }
716  }
717  checkObjectDiff(): boolean {
718    return !isBaseOrResourceEqual(this.stageValue, this.value);
719  }
720}
721
722class SearchEditMenuOptionsModifier extends ModifierWithKey<EditMenuOptions> {
723  constructor(value: EditMenuOptions) {
724    super(value);
725  }
726  static identity: Symbol = Symbol('textEditMenuOptions');
727  applyPeer(node: KNode, reset: boolean): void {
728    if (reset) {
729      getUINativeModule().search.resetSelectionMenuOptions(node);
730    } else {
731      getUINativeModule().search.setSelectionMenuOptions(node, this.value);
732    }
733  }
734}
735
736class SearchEnableHapticFeedbackModifier extends ModifierWithKey<boolean> {
737  constructor(value: boolean) {
738    super(value);
739  }
740  static identity: Symbol = Symbol('searchEnableHapticFeedback');
741  applyPeer(node: KNode, reset: boolean): void {
742    if (reset) {
743      getUINativeModule().search.resetEnableHapticFeedback(node);
744    } else {
745      getUINativeModule().search.setEnableHapticFeedback(node, this.value!);
746    }
747  }
748  checkObjectDiff(): boolean {
749    return !isBaseOrResourceEqual(this.stageValue, this.value);
750  }
751}
752
753interface SearchParam {
754  value?: string;
755  placeholder?: ResourceStr;
756  icon?: string;
757  controller?: SearchController
758}
759
760class ArkSearchComponent extends ArkComponent implements CommonMethod<SearchAttribute> {
761  constructor(nativePtr: KNode, classType?: ModifierType) {
762    super(nativePtr, classType);
763  }
764  initialize(value: Object[]): SearchAttribute {
765    if (value[0] !== undefined) {
766      modifierWithKey(this._modifiersWithKeys, SearchInitializeModifier.identity,
767        SearchInitializeModifier, (value[0] as SearchParam));
768    } else {
769      modifierWithKey(this._modifiersWithKeys, SearchInitializeModifier.identity,
770        SearchInitializeModifier, null);
771    }
772    return this;
773  }
774  onEditChange(callback: (isEditing: boolean) => void): SearchAttribute {
775    modifierWithKey(this._modifiersWithKeys, SearchOnEditChangeModifier.identity,
776      SearchOnEditChangeModifier, callback);
777    return this;
778  }
779  type(value: SearchType): SearchAttribute {
780    modifierWithKey(this._modifiersWithKeys, SearchTypeModifier.identity,
781      SearchTypeModifier, value);
782    return this;
783  }
784  maxLength(value: number): SearchAttribute {
785    modifierWithKey(this._modifiersWithKeys, SearchMaxLengthModifier.identity,
786      SearchMaxLengthModifier, value);
787    return this;
788  }
789  onEditChanged(callback: (isEditing: boolean) => void): SearchAttribute {
790    modifierWithKey(this._modifiersWithKeys, SearchOnEditChangeModifier.identity,
791      SearchOnEditChangeModifier, callback);
792    return this;
793  }
794  customKeyboard(event: () => void): SearchAttribute {
795    throw new Error('Method not implemented.');
796  }
797  showUnit(event: () => void): SearchAttribute {
798    throw new Error('Method not implemented.');
799  }
800  onContentScroll(callback: (totalOffsetX: number, totalOffsetY: number) => void): SearchAttribute {
801    modifierWithKey(this._modifiersWithKeys, SearchOnContentScrollModifier.identity,
802      SearchOnContentScrollModifier, callback);
803    return this;
804  }
805  onChange(callback: (value: ChangeValueInfo) => void): SearchAttribute {
806    modifierWithKey(this._modifiersWithKeys, SearchOnChangeModifier.identity,
807      SearchOnChangeModifier, callback);
808    return this;
809  }
810  onTextSelectionChange(callback: (selectionStart: number, selectionEnd: number) => void): SearchAttribute {
811    modifierWithKey(this._modifiersWithKeys, SearchOnTextSelectionChangeModifier.identity,
812      SearchOnTextSelectionChangeModifier, callback);
813    return this;
814  }
815  onCopy(callback: (value: string) => void): SearchAttribute {
816    modifierWithKey(this._modifiersWithKeys, SearchOnCopyModifier.identity,
817      SearchOnCopyModifier, callback);
818    return this;
819  }
820  onCut(callback: (value: string) => void): SearchAttribute {
821    modifierWithKey(this._modifiersWithKeys, SearchOnCutModifier.identity,
822      SearchOnCutModifier, callback);
823    return this;
824  }
825  onSubmit(callback: (value: string, event?: SubmitEvent) => void): SearchAttribute {
826    modifierWithKey(this._modifiersWithKeys, SearchOnSubmitModifier.identity,
827      SearchOnSubmitModifier, callback);
828    return this;
829  }
830  onPaste(callback: (value: string) => void): SearchAttribute {
831    modifierWithKey(this._modifiersWithKeys, SearchOnPasteModifier.identity,
832      SearchOnPasteModifier, callback);
833    return this;
834  }
835  showCounter(value: boolean, options?: InputCounterOptions): SearchAttribute {
836    let arkValue: ArkTextFieldShowCounter = new ArkTextFieldShowCounter();
837    arkValue.value = value;
838    arkValue.highlightBorder = options?.highlightBorder;
839    arkValue.thresholdPercentage = options?.thresholdPercentage;
840    modifierWithKey(this._modifiersWithKeys, SearchShowCounterModifier.identity,
841      SearchShowCounterModifier, arkValue);
842    return this;
843  }
844  searchButton(value: string, option?: SearchButtonOptions): SearchAttribute {
845    let searchButton = new ArkSearchButton();
846    searchButton.value = value;
847    searchButton.fontColor = option?.fontColor;
848    searchButton.fontSize = option?.fontSize;
849    modifierWithKey(this._modifiersWithKeys, SearchSearchButtonModifier.identity, SearchSearchButtonModifier, searchButton);
850    return this;
851  }
852  selectionMenuHidden(value: boolean): SearchAttribute {
853    modifierWithKey(this._modifiersWithKeys, SearchSelectionMenuHiddenModifier.identity, SearchSelectionMenuHiddenModifier, value);
854    return this;
855  }
856  enableKeyboardOnFocus(value: boolean): SearchAttribute {
857    modifierWithKey(this._modifiersWithKeys, SearchEnableKeyboardOnFocusModifier.identity, SearchEnableKeyboardOnFocusModifier, value);
858    return this;
859  }
860  caretStyle(value: CaretStyle): SearchAttribute {
861    modifierWithKey(this._modifiersWithKeys, SearchCaretStyleModifier.identity, SearchCaretStyleModifier, value);
862    return this;
863  }
864  cancelButton(value: { style?: CancelButtonStyle, icon?: IconOptions }): SearchAttribute {
865    modifierWithKey(this._modifiersWithKeys, SearchCancelButtonModifier.identity, SearchCancelButtonModifier, value);
866    return this;
867  }
868  searchIcon(value: IconOptions): SearchAttribute {
869    modifierWithKey(this._modifiersWithKeys, SearchSearchIconModifier.identity, SearchSearchIconModifier, value);
870    return this;
871  }
872  fontColor(value: ResourceColor): SearchAttribute {
873    modifierWithKey(this._modifiersWithKeys, SearchFontColorModifier.identity, SearchFontColorModifier, value);
874    return this;
875  }
876  placeholderColor(value: ResourceColor): SearchAttribute {
877    modifierWithKey(this._modifiersWithKeys, SearchPlaceholderColorModifier.identity, SearchPlaceholderColorModifier, value);
878    return this;
879  }
880  placeholderFont(value?: Font): SearchAttribute {
881    modifierWithKey(this._modifiersWithKeys, SearchPlaceholderFontModifier.identity, SearchPlaceholderFontModifier, value);
882    return this;
883  }
884  textFont(value?: Font): SearchAttribute {
885    modifierWithKey(this._modifiersWithKeys, SearchTextFontModifier.identity, SearchTextFontModifier, value);
886    return this;
887  }
888  copyOption(value: CopyOptions): SearchAttribute {
889    modifierWithKey(this._modifiersWithKeys, SearchCopyOptionModifier.identity, SearchCopyOptionModifier, value);
890    return this;
891  }
892  textAlign(value: TextAlign): SearchAttribute {
893    modifierWithKey(this._modifiersWithKeys, SearchTextAlignModifier.identity, SearchTextAlignModifier, value);
894    return this;
895  }
896  fontFeature(value: FontFeature): SearchAttribute {
897    modifierWithKey(this._modifiersWithKeys, SearchFontFeatureModifier.identity, SearchFontFeatureModifier, value);
898    return this;
899  }
900  enterKeyType(value: EnterKeyType): SearchAttribute {
901    modifierWithKey(this._modifiersWithKeys, SearchEnterKeyTypeModifier.identity,
902      SearchEnterKeyTypeModifier, value);
903    return this;
904  }
905  height(value: Length): this {
906    modifierWithKey(this._modifiersWithKeys, SearchHeightModifier.identity, SearchHeightModifier, value);
907    return this;
908  }
909  decoration(value: { type: TextDecorationType; color?: ResourceColor; style?: TextDecorationStyle }): this {
910    modifierWithKey(this._modifiersWithKeys, SearchDecorationModifier.identity, SearchDecorationModifier, value);
911    return this;
912  }
913  letterSpacing(value: number | string): this {
914    modifierWithKey(this._modifiersWithKeys, SearchLetterSpacingModifier.identity, SearchLetterSpacingModifier, value);
915    return this;
916  }
917  lineHeight(value: number | string | Resource): this {
918    modifierWithKey(this._modifiersWithKeys, SearchLineHeightModifier.identity, SearchLineHeightModifier, value);
919    return this;
920  }
921  id(value: string): this {
922    modifierWithKey(this._modifiersWithKeys, SearchIdModifier.identity, SearchIdModifier, value);
923    return this;
924  }
925  key(value: string): this {
926    modifierWithKey(this._modifiersWithKeys, SearchIdModifier.identity, SearchIdModifier, value);
927    return this;
928  }
929  minFontSize(value: number | string | Resource): this {
930    modifierWithKey(this._modifiersWithKeys, SearchMinFontSizeModifier.identity, SearchMinFontSizeModifier, value);
931    return this;
932  }
933  maxFontSize(value: number | string | Resource): this {
934    modifierWithKey(this._modifiersWithKeys, SearchMaxFontSizeModifier.identity, SearchMaxFontSizeModifier, value);
935    return this;
936  }
937  inputFilter(value: ResourceStr, error?: (value: string) => void): this {
938    let searchInputFilter = new ArkSearchInputFilter();
939    searchInputFilter.value = value;
940    searchInputFilter.error = error;
941    modifierWithKey(this._modifiersWithKeys, SearchInputFilterModifier.identity, SearchInputFilterModifier, searchInputFilter);
942    return this;
943  }
944  selectedBackgroundColor(value: ResourceColor): this {
945    modifierWithKey(this._modifiersWithKeys, SearchSelectedBackgroundColorModifier.identity, SearchSelectedBackgroundColorModifier, value);
946    return this;
947  }
948  textIndent(value: Dimension): this {
949    modifierWithKey(this._modifiersWithKeys, SearchTextIndentModifier.identity, SearchTextIndentModifier, value);
950    return this;
951  }
952  onWillChange(callback: Callback<ChangeValueInfo, boolean>): this {
953    modifierWithKey(this._modifiersWithKeys, SearchOnWillChangeModifier.identity, SearchOnWillChangeModifier, callback);
954    return this;
955  }
956  onWillInsert(callback: Callback<InsertValue, boolean>): this {
957    modifierWithKey(this._modifiersWithKeys, SearchOnWillInsertModifier.identity, SearchOnWillInsertModifier, callback);
958    return this;
959  }
960  onDidInsert(callback: Callback<InsertValue>): this {
961    modifierWithKey(this._modifiersWithKeys, SearchOnDidInsertModifier.identity, SearchOnDidInsertModifier, callback);
962    return this;
963  }
964  onWillDelete(callback: Callback<DeleteValue, boolean>): this {
965    modifierWithKey(this._modifiersWithKeys, SearchOnWillDeleteModifier.identity, SearchOnWillDeleteModifier, callback);
966    return this;
967  }
968  onDidDelete(callback: Callback<DeleteValue>): this {
969    modifierWithKey(this._modifiersWithKeys, SearchOnDidDeleteModifier.identity, SearchOnDidDeleteModifier, callback);
970    return this;
971  }
972  enablePreviewText(value: boolean): this {
973    modifierWithKey(this._modifiersWithKeys, SearchEnablePreviewTextModifier.identity, SearchEnablePreviewTextModifier, value);
974    return this;
975  }
976  editMenuOptions(value: EditMenuOptions): this {
977    modifierWithKey(this._modifiersWithKeys, SearchEditMenuOptionsModifier.identity,
978      SearchEditMenuOptionsModifier, value);
979    return this;
980  }
981  enableHapticFeedback(value: boolean): this {
982    modifierWithKey(this._modifiersWithKeys, SearchEnableHapticFeedbackModifier.identity, SearchEnableHapticFeedbackModifier, value);
983    return this;
984  }
985}
986// @ts-ignore
987globalThis.Search.attributeModifier = function (modifier: ArkComponent): void {
988  attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => {
989    return new ArkSearchComponent(nativePtr);
990  }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => {
991    return new modifierJS.SearchModifier(nativePtr, classType);
992  });
993};
994