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}; 22 23const DialogController = class DialogController extends CommonController { 24 constructor() { 25 super(); 26 __prompt__.PromptController.bindDialog(this); 27 } 28 29 close() { 30 __prompt__.PromptController.closeDialog(this); 31 } 32}; 33 34const showToast = function showToast(options) { 35 return __prompt__.showToast(options); 36}; 37 38const openToast = function openToast(options) { 39 return __prompt__.openToast(options); 40}; 41 42const closeToast = function closeToast(toastId) { 43 return __prompt__.closeToast(toastId); 44}; 45 46const showDialog = function showDialog(options, callback) { 47 if (callback === undefined) { 48 return __prompt__.showDialog(options); 49 } 50 return __prompt__.showDialog(options, callback); 51}; 52 53const showActionMenu = function showActionMenu(options, callback) { 54 if (callback === undefined) { 55 return __prompt__.showActionMenu(options); 56 } 57 return __prompt__.showActionMenu(options, callback); 58}; 59 60const openCustomDialog = function openCustomDialog(content, options) { 61 if (options === undefined) { 62 return __prompt__.openCustomDialog(content); 63 } 64 return __prompt__.openCustomDialog(content, options); 65}; 66 67const openCustomDialogWithController = function openCustomDialogWithController(content, controller, options) { 68 if (options === undefined) { 69 return __prompt__.openCustomDialogWithController(content, controller); 70 } 71 return __prompt__.openCustomDialogWithController(content, controller, options); 72}; 73 74const presentCustomDialog = function presentCustomDialog(builder, controller, options) { 75 if (controller === undefined && options === undefined) { 76 return __prompt__.presentCustomDialog(builder); 77 } 78 if (options === undefined) { 79 return __prompt__.presentCustomDialog(builder, controller); 80 } 81 return __prompt__.presentCustomDialog(builder, controller, options); 82}; 83 84const updateCustomDialog = function updateCustomDialog(content, options) { 85 return __prompt__.updateCustomDialog(content, options); 86}; 87 88const closeCustomDialog = function closeCustomDialog(content) { 89 return __prompt__.closeCustomDialog(content); 90}; 91 92const LevelOrder = class LevelOrder { 93 constructor() {}; 94 95 static clamp(order) { 96 let levelOrder = new LevelOrder(); 97 __prompt__.LevelOrder.clamp(levelOrder, order); 98 return levelOrder; 99 } 100 101 getOrder() { 102 return __prompt__.LevelOrder.getOrder(this); 103 } 104}; 105 106const __getTopOrder__ = function getTopOrder() { 107 let topOrder = __prompt__.LevelOrder.getTopOrder(); 108 if (typeof topOrder === 'undefined') { 109 return undefined; 110 } 111 return LevelOrder.clamp(topOrder); 112}; 113 114const __getBottomOrder__ = function getBottomOrder() { 115 let bottomOrder = __prompt__.LevelOrder.getBottomOrder(); 116 if (typeof bottomOrder === 'undefined') { 117 return undefined; 118 } 119 return LevelOrder.clamp(bottomOrder); 120}; 121 122let LevelMode; 123(function (LevelMode) { 124 LevelMode[LevelMode.OVERLAY = 0] = 'OVERLAY'; 125 LevelMode[LevelMode.EMBEDDED = 1] = 'EMBEDDED'; 126})(LevelMode || (LevelMode = {})); 127 128let ImmersiveMode; 129(function (ImmersiveMode) { 130 ImmersiveMode[ImmersiveMode.DEFAULT = 0] = 'DEFAULT'; 131 ImmersiveMode[ImmersiveMode.EXTEND = 1] = 'EXTEND'; 132})(ImmersiveMode || (ImmersiveMode = {})); 133 134export default { 135 CommonController, 136 DialogController, 137 showToast, 138 openToast, 139 closeToast, 140 showDialog, 141 openCustomDialog, 142 openCustomDialogWithController, 143 presentCustomDialog, 144 updateCustomDialog, 145 closeCustomDialog, 146 showActionMenu, 147 ToastShowMode: __prompt__.ToastShowMode, 148 LevelOrder, 149 __getTopOrder__, 150 __getBottomOrder__, 151 LevelMode, 152 ImmersiveMode 153}; 154