• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * Provides the method of switching the cursor position.
18 *
19 * @extends TextContentControllerBase
20 * @syscap SystemCapability.ArkUI.ArkUI.Full
21 * @since 8
22 */
23/**
24 * Provides the method of switching the cursor position.
25 *
26 * @extends TextContentControllerBase
27 * @syscap SystemCapability.ArkUI.ArkUI.Full
28 * @crossplatform
29 * @since 10
30 */
31declare class SearchController extends TextContentControllerBase {
32  /**
33   * constructor.
34   *
35   * @syscap SystemCapability.ArkUI.ArkUI.Full
36   * @since 8
37   */
38  /**
39   * constructor.
40   *
41   * @syscap SystemCapability.ArkUI.ArkUI.Full
42   * @crossplatform
43   * @since 10
44   */
45  constructor();
46
47  /**
48   * Called when the position of the insertion cursor is set.
49   *
50   * @param { number } value
51   * @syscap SystemCapability.ArkUI.ArkUI.Full
52   * @since 8
53   */
54  /**
55   * Called when the position of the insertion cursor is set.
56   *
57   * @param { number } value
58   * @syscap SystemCapability.ArkUI.ArkUI.Full
59   * @crossplatform
60   * @since 10
61   */
62  caretPosition(value: number): void;
63
64  /**
65   * Exit edit state.
66   *
67   * @syscap SystemCapability.ArkUI.ArkUI.Full
68   * @crossplatform
69   * @since 10
70   */
71  stopEditing(): void;
72}
73
74/**
75 * Enum for the style of cancel button
76 *
77 * @enum { number }
78 * @syscap SystemCapability.ArkUI.ArkUI.Full
79 * @crossplatform
80 * @since 10
81 */
82declare enum CancelButtonStyle {
83  /**
84   * The value of button style constant
85   *
86   * @syscap SystemCapability.ArkUI.ArkUI.Full
87   * @crossplatform
88   * @since 10
89   */
90  CONSTANT,
91
92  /**
93   * The value of button style invisible
94   *
95   * @syscap SystemCapability.ArkUI.ArkUI.Full
96   * @crossplatform
97   * @since 10
98   */
99  INVISIBLE,
100
101  /**
102   * The value of button style input
103   *
104   * @syscap SystemCapability.ArkUI.ArkUI.Full
105   * @crossplatform
106   * @since 10
107   */
108  INPUT
109}
110
111/**
112 * The construct function of search
113 *
114 * @interface SearchInterface
115 * @syscap SystemCapability.ArkUI.ArkUI.Full
116 * @since 8
117 */
118/**
119 * The construct function of search
120 *
121 * @interface SearchInterface
122 * @syscap SystemCapability.ArkUI.ArkUI.Full
123 * @crossplatform
124 * @since 10
125 */
126interface SearchInterface {
127  (options?: {
128    /**
129     * Text input in the search text box
130     *
131     * @type { ?string }
132     * @syscap SystemCapability.ArkUI.ArkUI.Full
133     * @since 8
134     */
135    value?: string;
136
137    /**
138     * Text displayed when there is no input
139     *
140     * @type { string }
141     * @syscap SystemCapability.ArkUI.ArkUI.Full
142     * @since 8
143     */
144    /**
145     * Text displayed when there is no input
146     *
147     * @type { ?ResourceStr }
148     * @syscap SystemCapability.ArkUI.ArkUI.Full
149     * @since 10
150     */
151    placeholder?: ResourceStr;
152
153    /**
154     * Path to the search icon
155     *
156     * @type { ?string }
157     * @syscap SystemCapability.ArkUI.ArkUI.Full
158     * @since 8
159     */
160    icon?: string;
161
162    /**
163     * Controller of the <Search> component
164     *
165     * @type { ?SearchController }
166     * @syscap SystemCapability.ArkUI.ArkUI.Full
167     * @since 8
168     */
169    controller?: SearchController
170  }): SearchAttribute;
171}
172
173/**
174 * Defines the icon options
175 *
176 * @interface IconOptions
177 * @syscap SystemCapability.ArkUI.ArkUI.Full
178 * @crossplatform
179 * @since 10
180 */
181interface IconOptions {
182  /**
183   * Set the icon size
184   *
185   * @type { ?Length }
186   * @syscap SystemCapability.ArkUI.ArkUI.Full
187   * @crossplatform
188   * @since 10
189   */
190  size?: Length;
191
192  /**
193   * Set the icon color
194   *
195   * @type { ?ResourceColor }
196   * @syscap SystemCapability.ArkUI.ArkUI.Full
197   * @crossplatform
198   * @since 10
199   */
200  color?: ResourceColor;
201
202  /**
203   * Set the icon resource
204   *
205   * @type { ?ResourceStr }
206   * @syscap SystemCapability.ArkUI.ArkUI.Full
207   * @crossplatform
208   * @since 10
209   */
210  src?: ResourceStr;
211}
212
213/**
214 * Defines the cursor style
215 *
216 * @interface CaretStyle
217 * @syscap SystemCapability.ArkUI.ArkUI.Full
218 * @crossplatform
219 * @since 10
220 */
221interface CaretStyle {
222  /**
223   * Set the cursor width
224   *
225   * @type { ?Length }
226   * @syscap SystemCapability.ArkUI.ArkUI.Full
227   * @crossplatform
228   * @since 10
229   */
230  width?: Length,
231
232  /**
233   * Set the cursor color
234   *
235   * @type { ?ResourceColor }
236   * @syscap SystemCapability.ArkUI.ArkUI.Full
237   * @crossplatform
238   * @since 10
239   */
240  color?: ResourceColor,
241}
242
243/**
244 * Defines the SearchButton options
245 *
246 * @interface SearchButtonOptions
247 * @syscap SystemCapability.ArkUI.ArkUI.Full
248 * @crossplatform
249 * @since 10
250 */
251interface SearchButtonOptions {
252  /**
253   * Set the SearchButton fontSize
254   *
255   * @type { ?Length }
256   * @syscap SystemCapability.ArkUI.ArkUI.Full
257   * @crossplatform
258   * @since 10
259   */
260  fontSize?: Length;
261
262  /**
263   * Set the SearchButton fontColor
264   *
265   * @type { ?ResourceColor }
266   * @syscap SystemCapability.ArkUI.ArkUI.Full
267   * @crossplatform
268   * @since 10
269   */
270  fontColor?: ResourceColor;
271}
272
273/**
274 * The attribute function of search
275 *
276 * @extends CommonMethod
277 * @syscap SystemCapability.ArkUI.ArkUI.Full
278 * @since 8
279 */
280/**
281 * The attribute function of search
282 *
283 * @extends CommonMethod
284 * @syscap SystemCapability.ArkUI.ArkUI.Full
285 * @crossplatform
286 * @since 10
287 */
288declare class SearchAttribute extends CommonMethod<SearchAttribute> {
289  /**
290   * Set the search button text
291   *
292   * @param { string } value - indicates the text of the search button.
293   * @param { SearchButtonOption } option
294   * @returns { SearchAttribute }
295   * @syscap SystemCapability.ArkUI.ArkUI.Full
296   * @since 8
297   */
298  /**
299   * Set the search button text, fontSize and fontColor
300   *
301   * @param { string } value - indicates the text of the search button.
302   * @param { SearchButtonOptions } option - indicates the fontSize and fontColor of the search button.
303   * @returns { SearchAttribute }
304   * @syscap SystemCapability.ArkUI.ArkUI.Full
305   * @crossplatform
306   * @since 10
307   */
308  searchButton(value: string, option?: SearchButtonOptions): SearchAttribute;
309
310  /**
311   * Set the text Color
312   *
313   * @param { ResourceColor } value - indicates the color of the text.
314   * @returns { SearchAttribute }
315   * @syscap SystemCapability.ArkUI.ArkUI.Full
316   * @crossplatform
317   * @since 10
318   */
319  fontColor(value: ResourceColor): SearchAttribute;
320
321  /**
322   * Set the search icon style
323   *
324   * @param { IconOptions } value - indicates the style of the search icon.
325   * @returns { SearchAttribute }
326   * @syscap SystemCapability.ArkUI.ArkUI.Full
327   * @crossplatform
328   * @since 10
329   */
330  searchIcon(value: IconOptions): SearchAttribute;
331
332  /**
333   * Set the cancel button style
334   *
335   * @param { object } value - indicates the style of the cancel button.
336   * @returns { SearchAttribute }
337   * @syscap SystemCapability.ArkUI.ArkUI.Full
338   * @crossplatform
339   * @since 10
340   */
341  cancelButton(value: { style?: CancelButtonStyle, icon?: IconOptions }): SearchAttribute;
342
343  /**
344   * Set the cursor style
345   *
346   * @param { CaretStyle } value - indicates the style of the cursor.
347   * @returns { SearchAttribute }
348   * @syscap SystemCapability.ArkUI.ArkUI.Full
349   * @crossplatform
350   * @since 10
351   */
352  caretStyle(value: CaretStyle): SearchAttribute;
353
354  /**
355   * Set the place hold text color
356   *
357   * @param { ResourceColor } value
358   * @returns { SearchAttribute }
359   * @syscap SystemCapability.ArkUI.ArkUI.Full
360   * @since 8
361   */
362  /**
363   * Set the place hold text color
364   *
365   * @param { ResourceColor } value
366   * @returns { SearchAttribute }
367   * @syscap SystemCapability.ArkUI.ArkUI.Full
368   * @crossplatform
369   * @since 10
370   */
371  placeholderColor(value: ResourceColor): SearchAttribute;
372
373  /**
374   * Set the font used for place holder text
375   *
376   * @param { Font } value
377   * @returns { SearchAttribute }
378   * @syscap SystemCapability.ArkUI.ArkUI.Full
379   * @since 8
380   */
381  /**
382   * Set the font used for place holder text
383   *
384   * @param { Font } value
385   * @returns { SearchAttribute }
386   * @syscap SystemCapability.ArkUI.ArkUI.Full
387   * @crossplatform
388   * @since 10
389   */
390  placeholderFont(value?: Font): SearchAttribute;
391
392  /**
393   * Set the font used for input text
394   *
395   * @param { Font } value
396   * @returns { SearchAttribute }
397   * @syscap SystemCapability.ArkUI.ArkUI.Full
398   * @since 8
399   */
400  /**
401   * Set the font used for input text
402   *
403   * @param { Font } value
404   * @returns { SearchAttribute }
405   * @syscap SystemCapability.ArkUI.ArkUI.Full
406   * @crossplatform
407   * @since 10
408   */
409  textFont(value?: Font): SearchAttribute;
410
411  /**
412   * Call the function when clicked the search button
413   *
414   * @param { function } callback
415   * @returns { SearchAttribute }
416   * @syscap SystemCapability.ArkUI.ArkUI.Full
417   * @since 8
418   */
419  /**
420   * Call the function when clicked the search button
421   *
422   * @param { function } callback
423   * @returns { SearchAttribute }
424   * @syscap SystemCapability.ArkUI.ArkUI.Full
425   * @crossplatform
426   * @since 10
427   */
428  onSubmit(callback: (value: string) => void): SearchAttribute;
429
430  /**
431   * Call the function when editing the input text
432   *
433   * @param { function } callback
434   * @returns { SearchAttribute }
435   * @syscap SystemCapability.ArkUI.ArkUI.Full
436   * @since 8
437   */
438  /**
439   * Call the function when editing the input text
440   *
441   * @param { function } callback
442   * @returns { SearchAttribute }
443   * @syscap SystemCapability.ArkUI.ArkUI.Full
444   * @crossplatform
445   * @since 10
446   */
447  onChange(callback: (value: string) => void): SearchAttribute;
448
449  /**
450   * Called when the text selection changes.
451   *
452   * @param { function } callback - callback of the listened event.
453   * @returns { SearchAttribute } returns the instance of the SearchAttribute.
454   * @syscap SystemCapability.ArkUI.ArkUI.Full
455   * @crossplatform
456   * @since 10
457   */
458  onTextSelectionChange(callback: (selectionStart: number, selectionEnd: number) => void): SearchAttribute;
459
460  /**
461   * Called when the content scrolls.
462   *
463   * @param { function } callback - callback of the listened event.
464   * @returns { SearchAttribute } returns the instance of the SearchAttribute.
465   * @syscap SystemCapability.ArkUI.ArkUI.Full
466   * @crossplatform
467   * @since 10
468   */
469  onContentScroll(callback: (totalOffsetX: number, totalOffsetY: number) => void): SearchAttribute;
470
471  /**
472   * Called when using the Clipboard menu
473   *
474   * @param { function } callback
475   * @returns { SearchAttribute }
476   * @syscap SystemCapability.ArkUI.ArkUI.Full
477   * @since 8
478   */
479  /**
480   * Called when using the Clipboard menu
481   *
482   * @param { function } callback
483   * @returns { SearchAttribute }
484   * @syscap SystemCapability.ArkUI.ArkUI.Full
485   * @crossplatform
486   * @since 10
487   */
488  onCopy(callback: (value: string) => void): SearchAttribute;
489
490  /**
491   * Called when using the Clipboard menu
492   *
493   * @param { function } callback
494   * @returns { SearchAttribute }
495   * @syscap SystemCapability.ArkUI.ArkUI.Full
496   * @since 8
497   */
498  /**
499   * Called when using the Clipboard menu
500   *
501   * @param { function } callback
502   * @returns { SearchAttribute }
503   * @syscap SystemCapability.ArkUI.ArkUI.Full
504   * @crossplatform
505   * @since 10
506   */
507  onCut(callback: (value: string) => void): SearchAttribute;
508
509  /**
510   * Called when using the Clipboard menu
511   *
512   * @param { function } callback
513   * @returns { SearchAttribute }
514   * @syscap SystemCapability.ArkUI.ArkUI.Full
515   * @since 8
516   */
517  /**
518   * Called when using the Clipboard menu
519   *
520   * @param { function } callback
521   * @returns { SearchAttribute }
522   * @syscap SystemCapability.ArkUI.ArkUI.Full
523   * @crossplatform
524   * @since 10
525   */
526  onPaste(callback: (value: string) => void): SearchAttribute;
527
528  /**
529   * Called when the copy option is set.
530   *
531   * @param { CopyOptions } value
532   * @returns { SearchAttribute }
533   * @syscap SystemCapability.ArkUI.ArkUI.Full
534   * @since 9
535   */
536  /**
537   * Called when the copy option is set.
538   *
539   * @param { CopyOptions } value
540   * @returns { SearchAttribute }
541   * @syscap SystemCapability.ArkUI.ArkUI.Full
542   * @crossplatform
543   * @since 10
544   */
545  copyOption(value: CopyOptions): SearchAttribute;
546
547  /**
548   * Called when the text align is set.
549   *
550   * @param { TextAlign } value
551   * @returns { SearchAttribute }
552   * @syscap SystemCapability.ArkUI.ArkUI.Full
553   * @since 9
554   */
555  /**
556   * Called when the text align is set.
557   *
558   * @param { TextAlign } value
559   * @returns { SearchAttribute }
560   * @syscap SystemCapability.ArkUI.ArkUI.Full
561   * @crossplatform
562   * @since 10
563   */
564  textAlign(value: TextAlign): SearchAttribute;
565
566  /**
567   * Sets whether request keyboard or not when on focus.
568   *
569   * @param { boolean } value
570   * @returns { SearchAttribute } Returns the instance of the SearchAttribute.
571   * @syscap SystemCapability.ArkUI.ArkUI.Full
572   * @crossplatform
573   * @since 10
574   */
575  enableKeyboardOnFocus(value: boolean): SearchAttribute;
576
577  /**
578   * Controls whether the selection menu pops up.
579   *
580   * @param { boolean } value
581   * @returns { SearchAttribute } returns the instance of the SearchAttribute.
582   * @syscap SystemCapability.ArkUI.ArkUI.Full
583   * @crossplatform
584   * @since 10
585   */
586  selectionMenuHidden(value: boolean): SearchAttribute;
587
588  /**
589   * Define custom keyboard.
590   *
591   * @param { CustomBuilder } value
592   * @returns { SearchAttribute } returns the instance of the SearchAttribute.
593   * @syscap SystemCapability.ArkUI.ArkUI.Full
594   * @since 10
595   */
596  customKeyboard(value: CustomBuilder): SearchAttribute;
597}
598
599/**
600 * Defines Search Component.
601 *
602 * @syscap SystemCapability.ArkUI.ArkUI.Full
603 * @since 8
604 */
605/**
606 * Defines Search Component.
607 *
608 * @syscap SystemCapability.ArkUI.ArkUI.Full
609 * @crossplatform
610 * @since 10
611 */
612declare const Search: SearchInterface;
613
614/**
615 * Defines Search Component instance.
616 *
617 * @syscap SystemCapability.ArkUI.ArkUI.Full
618 * @since 8
619 */
620/**
621 * Defines Search Component instance.
622 *
623 * @syscap SystemCapability.ArkUI.ArkUI.Full
624 * @crossplatform
625 * @since 10
626 */
627declare const SearchInstance: SearchAttribute;
628