• 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 * The alignment of dialog,
18 *
19 * @enum { number }
20 * @syscap SystemCapability.ArkUI.ArkUI.Full
21 * @since 7
22 */
23/**
24 * The alignment of dialog,
25 *
26 * @enum { number }
27 * @syscap SystemCapability.ArkUI.ArkUI.Full
28 * @crossplatform
29 * @since 10
30 */
31declare enum DialogAlignment {
32  /**
33   * Vertical top alignment.
34   *
35   * @syscap SystemCapability.ArkUI.ArkUI.Full
36   * @since 7
37   */
38  /**
39   * Vertical top alignment.
40   *
41   * @syscap SystemCapability.ArkUI.ArkUI.Full
42   * @crossplatform
43   * @since 10
44   */
45  Top,
46
47  /**
48   * Align vertically to the center.
49   *
50   * @syscap SystemCapability.ArkUI.ArkUI.Full
51   * @since 7
52   */
53  /**
54   * Align vertically to the center.
55   *
56   * @syscap SystemCapability.ArkUI.ArkUI.Full
57   * @crossplatform
58   * @since 10
59   */
60  Center,
61
62  /**
63   * Vertical bottom alignment.
64   *
65   * @syscap SystemCapability.ArkUI.ArkUI.Full
66   * @since 7
67   */
68  /**
69   * Vertical bottom alignment.
70   *
71   * @syscap SystemCapability.ArkUI.ArkUI.Full
72   * @crossplatform
73   * @since 10
74   */
75  Bottom,
76
77  /**
78   * Default alignment.
79   *
80   * @syscap SystemCapability.ArkUI.ArkUI.Full
81   * @since 7
82   */
83  /**
84   * Default alignment.
85   *
86   * @syscap SystemCapability.ArkUI.ArkUI.Full
87   * @crossplatform
88   * @since 10
89   */
90  Default,
91
92  /**
93   * Align the upper left corner.
94   *
95   * @syscap SystemCapability.ArkUI.ArkUI.Full
96   * @since 8
97   */
98  /**
99   * Align the upper left corner.
100   *
101   * @syscap SystemCapability.ArkUI.ArkUI.Full
102   * @crossplatform
103   * @since 10
104   */
105  TopStart,
106
107  /**
108   * Align the upper right corner.
109   *
110   * @syscap SystemCapability.ArkUI.ArkUI.Full
111   * @since 8
112   */
113  /**
114   * Align the upper right corner.
115   *
116   * @syscap SystemCapability.ArkUI.ArkUI.Full
117   * @crossplatform
118   * @since 10
119   */
120  TopEnd,
121
122  /**
123   * Left center alignment.
124   *
125   * @syscap SystemCapability.ArkUI.ArkUI.Full
126   * @since 8
127   */
128  /**
129   * Left center alignment.
130   *
131   * @syscap SystemCapability.ArkUI.ArkUI.Full
132   * @crossplatform
133   * @since 10
134   */
135  CenterStart,
136
137  /**
138   * Right center alignment.
139   *
140   * @syscap SystemCapability.ArkUI.ArkUI.Full
141   * @since 8
142   */
143  /**
144   * Right center alignment.
145   *
146   * @syscap SystemCapability.ArkUI.ArkUI.Full
147   * @crossplatform
148   * @since 10
149   */
150  CenterEnd,
151
152  /**
153   * Align the lower left corner.
154   *
155   * @syscap SystemCapability.ArkUI.ArkUI.Full
156   * @since 8
157   */
158  /**
159   * Align the lower left corner.
160   *
161   * @syscap SystemCapability.ArkUI.ArkUI.Full
162   * @crossplatform
163   * @since 10
164   */
165  BottomStart,
166
167  /**
168   * Align the lower right corner.
169   *
170   * @syscap SystemCapability.ArkUI.ArkUI.Full
171   * @since 8
172   */
173  /**
174   * Align the lower right corner.
175   *
176   * @syscap SystemCapability.ArkUI.ArkUI.Full
177   * @crossplatform
178   * @since 10
179   */
180  BottomEnd,
181}
182
183/**
184* The arrangement of buttons in dialog.
185*
186* @enum { number }
187* @syscap SystemCapability.ArkUI.ArkUI.Full
188* @crossplatform
189* @since 10
190*/
191declare enum DialogButtonDirection {
192  /**
193   * Two or fewer buttons are arranged horizontally,
194   * and two or more buttons are arranged vertically.
195   * @syscap SystemCapability.ArkUI.ArkUI.Full
196   * @crossplatform
197   * @since 10
198   */
199  AUTO = 0,
200
201  /**
202   * Buttons are arranged horizontally.
203   *
204   * @syscap SystemCapability.ArkUI.ArkUI.Full
205   * @crossplatform
206   * @since 10
207   */
208  HORIZONTAL = 1,
209
210  /**
211   * Buttons are arranged vertically.
212   *
213   * @syscap SystemCapability.ArkUI.ArkUI.Full
214   * @crossplatform
215   * @since 10
216   */
217  VERTICAL = 2,
218}
219
220/**
221 * Base button param used for AlertDialogParamWithOptions.
222 *
223 * @interface AlertDialogButtonOptions
224 * @syscap SystemCapability.ArkUI.ArkUI.Full
225 * @crossplatform
226 * @since 10
227 */
228declare interface AlertDialogButtonOptions {
229  /**
230   * Enable switch of button.
231   *
232   * @type { ?boolean }
233   * @default true
234   * @syscap SystemCapability.ArkUI.ArkUI.Full
235   * @crossplatform
236   * @since 10
237   */
238  enabled?: boolean;
239
240  /**
241   * Default focus switch of button.
242   *
243   * @type { ?boolean }
244   * @default false
245   * @syscap SystemCapability.ArkUI.ArkUI.Full
246   * @crossplatform
247   * @since 10
248   */
249  defaultFocus?: boolean;
250
251  /**
252   * Style of button.
253   *
254   * @type { ?DialogButtonStyle }
255   * @default -
256   * @syscap SystemCapability.ArkUI.ArkUI.Full
257   * @crossplatform
258   * @since 10
259   */
260  style?: DialogButtonStyle;
261
262  /**
263   * Text content of button.
264   *
265   * @type { ResourceStr }
266   * @syscap SystemCapability.ArkUI.ArkUI.Full
267   * @crossplatform
268   * @since 10
269   */
270  value: ResourceStr;
271
272  /**
273   * Text color of button.
274   *
275   * @type { ?ResourceColor }
276   * @syscap SystemCapability.ArkUI.ArkUI.Full
277   * @crossplatform
278   * @since 10
279   */
280  fontColor?: ResourceColor;
281
282  /**
283   * Background color of button.
284   *
285   * @type { ?ResourceColor }
286   * @syscap SystemCapability.ArkUI.ArkUI.Full
287   * @crossplatform
288   * @since 10
289   */
290  backgroundColor?: ResourceColor;
291
292  /**
293   * Method executed by the callback.
294   *
295   * @type { function }
296   * @syscap SystemCapability.ArkUI.ArkUI.Full
297   * @crossplatform
298   * @since 10
299   */
300  action: () => void;
301}
302
303/**
304 * Base param used for AlertDialog.show method.
305 *
306 * @interface AlertDialogParam
307 * @syscap SystemCapability.ArkUI.ArkUI.Full
308 * @since 7
309 */
310/**
311 * Base param used for AlertDialog.show method.
312 *
313 * @interface AlertDialogParam
314 * @syscap SystemCapability.ArkUI.ArkUI.Full
315 * @crossplatform
316 * @since 10
317 */
318declare interface AlertDialogParam {
319  /**
320   * Title Properties
321   *
322   * @type { ?ResourceStr }
323   * @syscap SystemCapability.ArkUI.ArkUI.Full
324   * @since 7
325   */
326  /**
327   * Title Properties
328   *
329   * @type { ?ResourceStr }
330   * @syscap SystemCapability.ArkUI.ArkUI.Full
331   * @crossplatform
332   * @since 10
333   */
334  title?: ResourceStr;
335
336  /**
337   * Subtitle Properties
338   * @type { ?ResourceStr }
339   * @syscap SystemCapability.ArkUI.ArkUI.Full
340   * @crossplatform
341   * @since 10
342   */
343  subtitle?: ResourceStr;
344
345  /**
346   * message Properties
347   *
348   * @type { ResourceStr }
349   * @syscap SystemCapability.ArkUI.ArkUI.Full
350   * @since 7
351   */
352  /**
353   * message Properties
354   *
355   * @type { ResourceStr }
356   * @syscap SystemCapability.ArkUI.ArkUI.Full
357   * @crossplatform
358   * @since 10
359   */
360  message: ResourceStr;
361
362  /**
363   * Allows users to click the mask layer to exit.
364   *
365   * @type { ?boolean }
366   * @syscap SystemCapability.ArkUI.ArkUI.Full
367   * @since 7
368   */
369  /**
370   * Allows users to click the mask layer to exit.
371   *
372   * @type { ?boolean }
373   * @syscap SystemCapability.ArkUI.ArkUI.Full
374   * @crossplatform
375   * @since 10
376   */
377  autoCancel?: boolean;
378
379  /**
380   * Execute Cancel Function.
381   *
382   * @type { ?function }
383   * @syscap SystemCapability.ArkUI.ArkUI.Full
384   * @since 7
385   */
386  /**
387   * Execute Cancel Function.
388   *
389   * @type { ?function }
390   * @syscap SystemCapability.ArkUI.ArkUI.Full
391   * @crossplatform
392   * @since 10
393   */
394  cancel?: () => void;
395
396  /**
397   * Alignment in the vertical direction.
398   *
399   * @type { ?DialogAlignment }
400   * @syscap SystemCapability.ArkUI.ArkUI.Full
401   * @since 7
402   */
403  /**
404   * Alignment in the vertical direction.
405   *
406   * @type { ?DialogAlignment }
407   * @syscap SystemCapability.ArkUI.ArkUI.Full
408   * @crossplatform
409   * @since 10
410   */
411  alignment?: DialogAlignment;
412
413  /**
414   * Offset of the pop-up window relative to the alignment position.
415   *
416   * @type { ?Offset }
417   * @syscap SystemCapability.ArkUI.ArkUI.Full
418   * @since 7
419   */
420  /**
421   * Offset of the pop-up window relative to the alignment position.
422   *
423   * @type { ?Offset }
424   * @syscap SystemCapability.ArkUI.ArkUI.Full
425   * @crossplatform
426   * @since 10
427   */
428  offset?: Offset;
429
430  /**
431   * Grid count of dialog.
432   *
433   * @type { ?number }
434   * @syscap SystemCapability.ArkUI.ArkUI.Full
435   * @since 7
436   */
437  /**
438   * Grid count of dialog.
439   *
440   * @type { ?number }
441   * @syscap SystemCapability.ArkUI.ArkUI.Full
442   * @crossplatform
443   * @since 10
444   */
445  gridCount?: number;
446
447  /**
448   * Mask Region of dialog. The size cannot exceed the main window.
449   *
450   * @type { ?Rectangle }
451   * @syscap SystemCapability.ArkUI.ArkUI.Full
452   * @crossplatform
453   * @since 10
454   */
455  maskRect?: Rectangle;
456}
457
458/**
459 * Defines the AlertDialog with confirm button.
460 *
461 * @interface AlertDialogParamWithConfirm
462 * @syscap SystemCapability.ArkUI.ArkUI.Full
463 * @since 7
464 */
465/**
466 * Defines the AlertDialog with confirm button.
467 *
468 * @interface AlertDialogParamWithConfirm
469 * @syscap SystemCapability.ArkUI.ArkUI.Full
470 * @crossplatform
471 * @since 10
472 */
473declare interface AlertDialogParamWithConfirm extends AlertDialogParam {
474  /**
475   * Invoke the commit function.
476   *
477   * @type { ?object }
478   * @syscap SystemCapability.ArkUI.ArkUI.Full
479   * @since 7
480   */
481  /**
482   * Invoke the commit function.
483   *
484   * @type { ?object }
485   * @syscap SystemCapability.ArkUI.ArkUI.Full
486   * @crossplatform
487   * @since 10
488   */
489  confirm?: {
490    /**
491     * Enable switch of confirmation button
492     * @type { ?boolean }
493     * @default true
494     * @syscap SystemCapability.ArkUI.ArkUI.Full
495     * @crossplatform
496     * @since 10
497     */
498    enabled?: boolean;
499
500    /**
501     * Default focus switch of confirmation button
502     * @type { ?boolean }
503     * @default false
504     * @syscap SystemCapability.ArkUI.ArkUI.Full
505     * @crossplatform
506     * @since 10
507     */
508    defaultFocus?: boolean;
509
510    /**
511     * Style of confirmation button.
512     * @type { ?DialogButtonStyle }
513     * @default DialogButtonStyle.DEFAULT
514     * @syscap SystemCapability.ArkUI.ArkUI.Full
515     * @crossplatform
516     * @since 10
517     */
518    style?: DialogButtonStyle;
519
520    /**
521     * Text content of the confirmation button.
522     *
523     * @type { ResourceStr }
524     * @syscap SystemCapability.ArkUI.ArkUI.Full
525     * @since 7
526     */
527    /**
528     * Text content of the confirmation button.
529     *
530     * @type { ResourceStr }
531     * @syscap SystemCapability.ArkUI.ArkUI.Full
532     * @crossplatform
533     * @since 10
534     */
535    value: ResourceStr;
536
537    /**
538     * Text color of the confirmation button.
539     *
540     * @type { ?ResourceColor }
541     * @syscap SystemCapability.ArkUI.ArkUI.Full
542     * @since 7
543     */
544    /**
545     * Text color of the confirmation button.
546     *
547     * @type { ?ResourceColor }
548     * @syscap SystemCapability.ArkUI.ArkUI.Full
549     * @crossplatform
550     * @since 10
551     */
552    fontColor?: ResourceColor;
553
554    /**
555     * Background color of the confirmation button.
556     *
557     * @type { ?ResourceColor }
558     * @syscap SystemCapability.ArkUI.ArkUI.Full
559     * @since 7
560     */
561    /**
562     * Background color of the confirmation button.
563     *
564     * @type { ?ResourceColor }
565     * @syscap SystemCapability.ArkUI.ArkUI.Full
566     * @crossplatform
567     * @since 10
568     */
569    backgroundColor?: ResourceColor;
570
571    /**
572     * Method executed by the callback.
573     *
574     * @type { function }
575     * @syscap SystemCapability.ArkUI.ArkUI.Full
576     * @since 7
577     */
578    /**
579     * Method executed by the callback.
580     *
581     * @type { function }
582     * @syscap SystemCapability.ArkUI.ArkUI.Full
583     * @crossplatform
584     * @since 10
585     */
586    action: () => void;
587  };
588}
589
590/**
591 * Defines the dialog param with buttons.
592 *
593 * @interface AlertDialogParamWithButtons
594 * @syscap SystemCapability.ArkUI.ArkUI.Full
595 * @since 7
596 */
597/**
598 * Defines the dialog param with buttons.
599 *
600 * @interface AlertDialogParamWithButtons
601 * @syscap SystemCapability.ArkUI.ArkUI.Full
602 * @crossplatform
603 * @since 10
604 */
605declare interface AlertDialogParamWithButtons extends AlertDialogParam {
606  /**
607   * First button.
608   *
609   * @type { object }
610   * @syscap SystemCapability.ArkUI.ArkUI.Full
611   * @since 7
612   */
613  /**
614   * First button.
615   *
616   * @type { object }
617   * @syscap SystemCapability.ArkUI.ArkUI.Full
618   * @crossplatform
619   * @since 10
620   */
621  primaryButton: {
622    /**
623     * Enable switch of primaryButton
624     * @type { ?boolean }
625     * @default true
626     * @syscap SystemCapability.ArkUI.ArkUI.Full
627     * @crossplatform
628     * @since 10
629     */
630    enabled?: boolean;
631
632    /**
633     * Default focus switch of primaryButton button
634     * @type { ?boolean }
635     * @default false
636     * @syscap SystemCapability.ArkUI.ArkUI.Full
637     * @crossplatform
638     * @since 10
639     */
640    defaultFocus?: boolean;
641
642    /**
643     * Style of primaryButton button.
644     * @type { ?DialogButtonStyle }
645     * @default DialogButtonStyle.DEFAULT
646     * @syscap SystemCapability.ArkUI.ArkUI.Full
647     * @crossplatform
648     * @since 10
649     */
650    style?: DialogButtonStyle;
651
652    /**
653     * Text content of the confirmation button.
654     *
655     * @type { ResourceStr }
656     * @syscap SystemCapability.ArkUI.ArkUI.Full
657     * @since 7
658     */
659    /**
660     * Text content of the confirmation button.
661     *
662     * @type { ResourceStr }
663     * @syscap SystemCapability.ArkUI.ArkUI.Full
664     * @crossplatform
665     * @since 10
666     */
667    value: ResourceStr;
668
669    /**
670     * Text color of the confirmation button.
671     *
672     * @type { ?ResourceColor }
673     * @syscap SystemCapability.ArkUI.ArkUI.Full
674     * @since 7
675     */
676    /**
677     * Text color of the confirmation button.
678     *
679     * @type { ?ResourceColor }
680     * @syscap SystemCapability.ArkUI.ArkUI.Full
681     * @crossplatform
682     * @since 10
683     */
684    fontColor?: ResourceColor;
685
686    /**
687     * Background color of the confirmation button.
688     *
689     * @type { ?ResourceColor }
690     * @syscap SystemCapability.ArkUI.ArkUI.Full
691     * @since 7
692     */
693    /**
694     * Background color of the confirmation button.
695     *
696     * @type { ?ResourceColor }
697     * @syscap SystemCapability.ArkUI.ArkUI.Full
698     * @crossplatform
699     * @since 10
700     */
701    backgroundColor?: ResourceColor;
702
703    /**
704     * Method executed by the callback.
705     *
706     * @type { function }
707     * @syscap SystemCapability.ArkUI.ArkUI.Full
708     * @since 7
709     */
710    /**
711     * Method executed by the callback.
712     *
713     * @type { function }
714     * @syscap SystemCapability.ArkUI.ArkUI.Full
715     * @crossplatform
716     * @since 10
717     */
718    action: () => void;
719  };
720
721  /**
722   * Second button.
723   *
724   * @type { object }
725   * @syscap SystemCapability.ArkUI.ArkUI.Full
726   * @since 7
727   */
728  /**
729   * Second button.
730   *
731   * @type { object }
732   * @syscap SystemCapability.ArkUI.ArkUI.Full
733   * @crossplatform
734   * @since 10
735   */
736  secondaryButton: {
737    /**
738     * Enable switch of secondaryButton
739     * @type { ?boolean }
740     * @default true
741     * @syscap SystemCapability.ArkUI.ArkUI.Full
742     * @crossplatform
743     * @since 10
744     */
745    enabled?: boolean;
746
747    /**
748     * Default focus switch of secondaryButton button
749     * @type { ?boolean }
750     * @default false
751     * @syscap SystemCapability.ArkUI.ArkUI.Full
752     * @crossplatform
753     * @since 10
754     */
755    defaultFocus?: boolean;
756
757    /**
758     * Style of secondaryButton button.
759     * @type { ?DialogButtonStyle }
760     * @default DialogButtonStyle.DEFAULT
761     * @syscap SystemCapability.ArkUI.ArkUI.Full
762     * @crossplatform
763     * @since 10
764     */
765    style?: DialogButtonStyle;
766
767    /**
768     * Text content of the confirmation button.
769     *
770     * @type { ResourceStr }
771     * @syscap SystemCapability.ArkUI.ArkUI.Full
772     * @since 7
773     */
774    /**
775     * Text content of the confirmation button.
776     *
777     * @type { ResourceStr }
778     * @syscap SystemCapability.ArkUI.ArkUI.Full
779     * @crossplatform
780     * @since 10
781     */
782    value: ResourceStr;
783
784    /**
785     * Text color of the confirmation button.
786     *
787     * @type { ?ResourceColor }
788     * @syscap SystemCapability.ArkUI.ArkUI.Full
789     * @since 7
790     */
791    /**
792     * Text color of the confirmation button.
793     *
794     * @type { ?ResourceColor }
795     * @syscap SystemCapability.ArkUI.ArkUI.Full
796     * @crossplatform
797     * @since 10
798     */
799    fontColor?: ResourceColor;
800
801    /**
802     * Background color of the confirmation button.
803     *
804     * @type { ?ResourceColor }
805     * @syscap SystemCapability.ArkUI.ArkUI.Full
806     * @since 7
807     */
808    /**
809     * Background color of the confirmation button.
810     *
811     * @type { ?ResourceColor }
812     * @syscap SystemCapability.ArkUI.ArkUI.Full
813     * @crossplatform
814     * @since 10
815     */
816    backgroundColor?: ResourceColor;
817
818    /**
819     * Method executed by the callback.
820     *
821     * @type { function }
822     * @syscap SystemCapability.ArkUI.ArkUI.Full
823     * @since 7
824     */
825    /**
826     * Method executed by the callback.
827     *
828     * @type { function }
829     * @syscap SystemCapability.ArkUI.ArkUI.Full
830     * @crossplatform
831     * @since 10
832     */
833    action: () => void;
834  };
835}
836
837/**
838 * Defines the dialog param with options.
839 *
840 * @interface AlertDialogParamWithOptions
841 * @syscap SystemCapability.ArkUI.ArkUI.Full
842 * @crossplatform
843 * @since 10
844 */
845declare interface AlertDialogParamWithOptions extends AlertDialogParam {
846  /**
847   * The array of buttons.
848   * @type { Array<AlertDialogButtonOptions> }
849   * @syscap SystemCapability.ArkUI.ArkUI.Full
850   * @crossplatform
851   * @since 10
852   */
853  buttons: Array<AlertDialogButtonOptions>;
854
855  /**
856   * The arrangement of buttons.
857   * @type { ?DialogButtonDirection }
858   * @default DialogButtonDirection.AUTO
859   * @syscap SystemCapability.ArkUI.ArkUI.Full
860   * @crossplatform
861   * @since 10
862   */
863  buttonDirection?: DialogButtonDirection;
864}
865
866/**
867 * Defines AlertDialog which uses show method to show alert dialog.
868 *
869 * @syscap SystemCapability.ArkUI.ArkUI.Full
870 * @since 7
871 */
872/**
873 * Defines AlertDialog which uses show method to show alert dialog.
874 *
875 * @syscap SystemCapability.ArkUI.ArkUI.Full
876 * @crossplatform
877 * @since 10
878 */
879declare class AlertDialog {
880  /**
881   * Invoking method display.
882   *
883   * @param { AlertDialogParamWithConfirm | AlertDialogParamWithButtons } value
884   * @syscap SystemCapability.ArkUI.ArkUI.Full
885   * @since 7
886   */
887  /**
888   * Invoking method display.
889   *
890   * @param { AlertDialogParamWithConfirm | AlertDialogParamWithButtons | AlertDialogParamWithOptions} value
891   * @syscap SystemCapability.ArkUI.ArkUI.Full
892   * @crossplatform
893   * @since 10
894   */
895  static show(value: AlertDialogParamWithConfirm | AlertDialogParamWithButtons | AlertDialogParamWithOptions);
896}
897
898declare module "AlertDialogParam" {
899  module "AlertDialogParam" {
900    // @ts-ignore
901    export { AlertDialogParamWithConfirm, AlertDialogParamWithButtons, DialogAlignment, DialogButtonDirection, AlertDialogParamWithOptions };
902  }
903}
904