• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16const __prompt__ = requireInternal('promptAction');
17
18const CommonController = class CommonController {
19    constructor() {};
20    close() {};
21    getState() {};
22};
23
24const DialogController = class DialogController extends CommonController {
25    constructor() {
26        super();
27        __prompt__.PromptController.bindDialog(this);
28    }
29
30    close() {
31        __prompt__.PromptController.closeDialog(this);
32    }
33
34    getState() {
35        return __prompt__.PromptController.getState(this);
36    }
37};
38
39const showToast = function showToast(options) {
40    return __prompt__.showToast(options);
41};
42
43const openToast = function openToast(options) {
44    return __prompt__.openToast(options);
45};
46
47const closeToast = function closeToast(toastId) {
48    return __prompt__.closeToast(toastId);
49};
50
51const showDialog = function showDialog(options, callback) {
52    if (callback === undefined) {
53        return __prompt__.showDialog(options);
54    }
55    return __prompt__.showDialog(options, callback);
56};
57
58const showActionMenu = function showActionMenu(options, callback) {
59    if (callback === undefined) {
60        return __prompt__.showActionMenu(options);
61    }
62    return __prompt__.showActionMenu(options, callback);
63};
64
65const openCustomDialog = function openCustomDialog(content, options) {
66    if (options === undefined) {
67        return __prompt__.openCustomDialog(content);
68    }
69    return __prompt__.openCustomDialog(content, options);
70};
71
72const openCustomDialogWithController = function openCustomDialogWithController(content, controller, options) {
73    if (options === undefined) {
74        return __prompt__.openCustomDialogWithController(content, controller);
75    }
76    return __prompt__.openCustomDialogWithController(content, controller, options);
77};
78
79const presentCustomDialog = function presentCustomDialog(builder, controller, options) {
80    if (controller === undefined && options === undefined) {
81        return __prompt__.presentCustomDialog(builder);
82    }
83    if (options === undefined) {
84        return __prompt__.presentCustomDialog(builder, controller);
85    }
86    return __prompt__.presentCustomDialog(builder, controller, options);
87};
88
89const updateCustomDialog = function updateCustomDialog(content, options) {
90    return __prompt__.updateCustomDialog(content, options);
91};
92
93const closeCustomDialog = function closeCustomDialog(content) {
94    return __prompt__.closeCustomDialog(content);
95};
96
97const LevelOrder = class LevelOrder {
98    constructor() {};
99
100    static clamp(order) {
101        let levelOrder = new LevelOrder();
102        __prompt__.LevelOrder.clamp(levelOrder, order);
103        return levelOrder;
104    }
105
106    getOrder() {
107        return __prompt__.LevelOrder.getOrder(this);
108    }
109};
110
111const __getTopOrder__ = function getTopOrder() {
112    let topOrder = __prompt__.LevelOrder.getTopOrder();
113    if (typeof topOrder === 'undefined') {
114        return undefined;
115    }
116    return LevelOrder.clamp(topOrder);
117};
118
119const __getBottomOrder__ = function getBottomOrder() {
120    let bottomOrder = __prompt__.LevelOrder.getBottomOrder();
121    if (typeof bottomOrder === 'undefined') {
122        return undefined;
123    }
124    return LevelOrder.clamp(bottomOrder);
125};
126
127let LevelMode;
128(function (LevelMode) {
129    LevelMode[LevelMode.OVERLAY = 0] = 'OVERLAY';
130    LevelMode[LevelMode.EMBEDDED = 1] = 'EMBEDDED';
131})(LevelMode || (LevelMode = {}));
132
133let ImmersiveMode;
134(function (ImmersiveMode) {
135    ImmersiveMode[ImmersiveMode.DEFAULT = 0] = 'DEFAULT';
136    ImmersiveMode[ImmersiveMode.EXTEND = 1] = 'EXTEND';
137})(ImmersiveMode || (ImmersiveMode = {}));
138
139export default {
140    CommonController,
141    DialogController,
142    showToast,
143    openToast,
144    closeToast,
145    showDialog,
146    openCustomDialog,
147    openCustomDialogWithController,
148    presentCustomDialog,
149    updateCustomDialog,
150    closeCustomDialog,
151    showActionMenu,
152    ToastShowMode: __prompt__.ToastShowMode,
153    LevelOrder,
154    __getTopOrder__,
155    __getBottomOrder__,
156    LevelMode,
157    ImmersiveMode
158};
159