underpost 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/.dockerignore +14 -0
  2. package/.env.development +8 -0
  3. package/.env.production +8 -0
  4. package/.env.test +8 -0
  5. package/.nycrc +9 -0
  6. package/.prettierignore +13 -0
  7. package/.prettierrc +9 -0
  8. package/.vscode/extensions.json +72 -0
  9. package/.vscode/settings.json +99 -0
  10. package/Dockerfile +88 -0
  11. package/LICENSE +21 -0
  12. package/README.md +51 -0
  13. package/bin/db.js +119 -0
  14. package/bin/deploy.js +600 -0
  15. package/bin/dns.js +1 -0
  16. package/bin/file.js +92 -0
  17. package/bin/help.js +110 -0
  18. package/bin/index.js +29 -0
  19. package/bin/install.js +357 -0
  20. package/bin/shortcut.js +44 -0
  21. package/bin/ssl.js +61 -0
  22. package/bin/util.js +182 -0
  23. package/bin/vs.js +35 -0
  24. package/conf.js +244 -0
  25. package/docker-compose.yml +67 -0
  26. package/jsconfig.json +7 -0
  27. package/jsdoc.json +32 -0
  28. package/nodemon.json +6 -0
  29. package/package.json +128 -0
  30. package/prometheus.yml +36 -0
  31. package/setup.sh +25 -0
  32. package/src/api/core/core.controller.js +69 -0
  33. package/src/api/core/core.model.js +11 -0
  34. package/src/api/core/core.router.js +23 -0
  35. package/src/api/core/core.service.js +29 -0
  36. package/src/api/crypto/crypto.controller.js +51 -0
  37. package/src/api/crypto/crypto.model.js +23 -0
  38. package/src/api/crypto/crypto.router.js +20 -0
  39. package/src/api/crypto/crypto.service.js +64 -0
  40. package/src/api/default/default.controller.js +69 -0
  41. package/src/api/default/default.model.js +20 -0
  42. package/src/api/default/default.router.js +23 -0
  43. package/src/api/default/default.service.js +31 -0
  44. package/src/api/file/file.controller.js +51 -0
  45. package/src/api/file/file.model.js +19 -0
  46. package/src/api/file/file.router.js +20 -0
  47. package/src/api/file/file.service.js +70 -0
  48. package/src/api/instance/instance.controller.js +69 -0
  49. package/src/api/instance/instance.model.js +36 -0
  50. package/src/api/instance/instance.router.js +33 -0
  51. package/src/api/instance/instance.service.js +48 -0
  52. package/src/api/test/test.controller.js +59 -0
  53. package/src/api/test/test.model.js +14 -0
  54. package/src/api/test/test.router.js +21 -0
  55. package/src/api/test/test.service.js +35 -0
  56. package/src/api/user/user.controller.js +70 -0
  57. package/src/api/user/user.model.js +65 -0
  58. package/src/api/user/user.router.js +345 -0
  59. package/src/api/user/user.service.js +479 -0
  60. package/src/api.js +23 -0
  61. package/src/client/Default.index.js +40 -0
  62. package/src/client/components/core/Account.js +290 -0
  63. package/src/client/components/core/AgGrid.js +160 -0
  64. package/src/client/components/core/Auth.js +19 -0
  65. package/src/client/components/core/Badge.js +32 -0
  66. package/src/client/components/core/BlockChain.js +41 -0
  67. package/src/client/components/core/Blog.js +9 -0
  68. package/src/client/components/core/BtnIcon.js +91 -0
  69. package/src/client/components/core/CalendarCore.js +319 -0
  70. package/src/client/components/core/Chat.js +64 -0
  71. package/src/client/components/core/ColorPalette.js +5267 -0
  72. package/src/client/components/core/CommonJs.js +708 -0
  73. package/src/client/components/core/Content.js +49 -0
  74. package/src/client/components/core/Css.js +1027 -0
  75. package/src/client/components/core/CssCore.js +792 -0
  76. package/src/client/components/core/D3Chart.js +44 -0
  77. package/src/client/components/core/Docs.js +130 -0
  78. package/src/client/components/core/DropDown.js +164 -0
  79. package/src/client/components/core/EventsUI.js +54 -0
  80. package/src/client/components/core/FileExplorer.js +624 -0
  81. package/src/client/components/core/FullScreen.js +45 -0
  82. package/src/client/components/core/Input.js +259 -0
  83. package/src/client/components/core/JoyStick.js +77 -0
  84. package/src/client/components/core/Keyboard.js +73 -0
  85. package/src/client/components/core/LoadingAnimation.js +157 -0
  86. package/src/client/components/core/LogIn.js +181 -0
  87. package/src/client/components/core/LogOut.js +52 -0
  88. package/src/client/components/core/Logger.js +26 -0
  89. package/src/client/components/core/Modal.js +1596 -0
  90. package/src/client/components/core/NotificationManager.js +84 -0
  91. package/src/client/components/core/Panel.js +413 -0
  92. package/src/client/components/core/Polyhedron.js +162 -0
  93. package/src/client/components/core/Recover.js +204 -0
  94. package/src/client/components/core/Responsive.js +53 -0
  95. package/src/client/components/core/RichText.js +27 -0
  96. package/src/client/components/core/Router.js +77 -0
  97. package/src/client/components/core/SignUp.js +125 -0
  98. package/src/client/components/core/SocketIo.js +72 -0
  99. package/src/client/components/core/Stream.js +113 -0
  100. package/src/client/components/core/ToggleSwitch.js +87 -0
  101. package/src/client/components/core/ToolTip.js +26 -0
  102. package/src/client/components/core/Translate.js +408 -0
  103. package/src/client/components/core/Validator.js +100 -0
  104. package/src/client/components/core/VanillaJs.js +454 -0
  105. package/src/client/components/core/Wallet.js +106 -0
  106. package/src/client/components/core/Webhook.js +25 -0
  107. package/src/client/components/core/Worker.js +272 -0
  108. package/src/client/components/default/CommonDefault.js +29 -0
  109. package/src/client/components/default/CssDefault.js +13 -0
  110. package/src/client/components/default/ElementsDefault.js +38 -0
  111. package/src/client/components/default/LogInDefault.js +41 -0
  112. package/src/client/components/default/LogOutDefault.js +28 -0
  113. package/src/client/components/default/MenuDefault.js +389 -0
  114. package/src/client/components/default/RoutesDefault.js +48 -0
  115. package/src/client/components/default/SettingsDefault.js +16 -0
  116. package/src/client/components/default/SignUpDefault.js +9 -0
  117. package/src/client/components/default/SocketIoDefault.js +54 -0
  118. package/src/client/components/default/TranslateDefault.js +7 -0
  119. package/src/client/public/default/android-chrome-144x144.png +0 -0
  120. package/src/client/public/default/android-chrome-192x192.png +0 -0
  121. package/src/client/public/default/android-chrome-256x256.png +0 -0
  122. package/src/client/public/default/android-chrome-36x36.png +0 -0
  123. package/src/client/public/default/android-chrome-384x384.png +0 -0
  124. package/src/client/public/default/android-chrome-48x48.png +0 -0
  125. package/src/client/public/default/android-chrome-512x512.png +0 -0
  126. package/src/client/public/default/android-chrome-72x72.png +0 -0
  127. package/src/client/public/default/android-chrome-96x96.png +0 -0
  128. package/src/client/public/default/apple-touch-icon-1024x1024.png +0 -0
  129. package/src/client/public/default/apple-touch-icon-114x114.png +0 -0
  130. package/src/client/public/default/apple-touch-icon-120x120.png +0 -0
  131. package/src/client/public/default/apple-touch-icon-144x144.png +0 -0
  132. package/src/client/public/default/apple-touch-icon-152x152.png +0 -0
  133. package/src/client/public/default/apple-touch-icon-167x167.png +0 -0
  134. package/src/client/public/default/apple-touch-icon-180x180.png +0 -0
  135. package/src/client/public/default/apple-touch-icon-57x57.png +0 -0
  136. package/src/client/public/default/apple-touch-icon-60x60.png +0 -0
  137. package/src/client/public/default/apple-touch-icon-72x72.png +0 -0
  138. package/src/client/public/default/apple-touch-icon-76x76.png +0 -0
  139. package/src/client/public/default/apple-touch-icon-precomposed.png +0 -0
  140. package/src/client/public/default/apple-touch-icon.png +0 -0
  141. package/src/client/public/default/apple-touch-startup-image-1125x2436.png +0 -0
  142. package/src/client/public/default/apple-touch-startup-image-1136x640.png +0 -0
  143. package/src/client/public/default/apple-touch-startup-image-1170x2532.png +0 -0
  144. package/src/client/public/default/apple-touch-startup-image-1179x2556.png +0 -0
  145. package/src/client/public/default/apple-touch-startup-image-1242x2208.png +0 -0
  146. package/src/client/public/default/apple-touch-startup-image-1242x2688.png +0 -0
  147. package/src/client/public/default/apple-touch-startup-image-1284x2778.png +0 -0
  148. package/src/client/public/default/apple-touch-startup-image-1290x2796.png +0 -0
  149. package/src/client/public/default/apple-touch-startup-image-1334x750.png +0 -0
  150. package/src/client/public/default/apple-touch-startup-image-1488x2266.png +0 -0
  151. package/src/client/public/default/apple-touch-startup-image-1536x2048.png +0 -0
  152. package/src/client/public/default/apple-touch-startup-image-1620x2160.png +0 -0
  153. package/src/client/public/default/apple-touch-startup-image-1640x2160.png +0 -0
  154. package/src/client/public/default/apple-touch-startup-image-1668x2224.png +0 -0
  155. package/src/client/public/default/apple-touch-startup-image-1668x2388.png +0 -0
  156. package/src/client/public/default/apple-touch-startup-image-1792x828.png +0 -0
  157. package/src/client/public/default/apple-touch-startup-image-2048x1536.png +0 -0
  158. package/src/client/public/default/apple-touch-startup-image-2048x2732.png +0 -0
  159. package/src/client/public/default/apple-touch-startup-image-2160x1620.png +0 -0
  160. package/src/client/public/default/apple-touch-startup-image-2160x1640.png +0 -0
  161. package/src/client/public/default/apple-touch-startup-image-2208x1242.png +0 -0
  162. package/src/client/public/default/apple-touch-startup-image-2224x1668.png +0 -0
  163. package/src/client/public/default/apple-touch-startup-image-2266x1488.png +0 -0
  164. package/src/client/public/default/apple-touch-startup-image-2388x1668.png +0 -0
  165. package/src/client/public/default/apple-touch-startup-image-2436x1125.png +0 -0
  166. package/src/client/public/default/apple-touch-startup-image-2532x1170.png +0 -0
  167. package/src/client/public/default/apple-touch-startup-image-2556x1179.png +0 -0
  168. package/src/client/public/default/apple-touch-startup-image-2688x1242.png +0 -0
  169. package/src/client/public/default/apple-touch-startup-image-2732x2048.png +0 -0
  170. package/src/client/public/default/apple-touch-startup-image-2778x1284.png +0 -0
  171. package/src/client/public/default/apple-touch-startup-image-2796x1290.png +0 -0
  172. package/src/client/public/default/apple-touch-startup-image-640x1136.png +0 -0
  173. package/src/client/public/default/apple-touch-startup-image-750x1334.png +0 -0
  174. package/src/client/public/default/apple-touch-startup-image-828x1792.png +0 -0
  175. package/src/client/public/default/assets/background/white.jpg +0 -0
  176. package/src/client/public/default/assets/background/white0-min.jpg +0 -0
  177. package/src/client/public/default/assets/background/white0.jpg +0 -0
  178. package/src/client/public/default/assets/logo/base-icon.png +0 -0
  179. package/src/client/public/default/browserconfig.xml +12 -0
  180. package/src/client/public/default/favicon-16x16.png +0 -0
  181. package/src/client/public/default/favicon-32x32.png +0 -0
  182. package/src/client/public/default/favicon-48x48.png +0 -0
  183. package/src/client/public/default/favicon.ico +0 -0
  184. package/src/client/public/default/manifest.webmanifest +69 -0
  185. package/src/client/public/default/mstile-144x144.png +0 -0
  186. package/src/client/public/default/mstile-150x150.png +0 -0
  187. package/src/client/public/default/mstile-310x150.png +0 -0
  188. package/src/client/public/default/mstile-310x310.png +0 -0
  189. package/src/client/public/default/mstile-70x70.png +0 -0
  190. package/src/client/public/default/sitemap +148 -0
  191. package/src/client/public/default/yandex-browser-50x50.png +0 -0
  192. package/src/client/public/default/yandex-browser-manifest.json +9 -0
  193. package/src/client/public/doc/favicon.ico +0 -0
  194. package/src/client/public/doc/sitemap +148 -0
  195. package/src/client/public/test/favicon.ico +0 -0
  196. package/src/client/public/test/sitemap +148 -0
  197. package/src/client/services/core/core.service.js +152 -0
  198. package/src/client/services/crypto/crypto.service.js +70 -0
  199. package/src/client/services/default/default.management.js +345 -0
  200. package/src/client/services/default/default.service.js +89 -0
  201. package/src/client/services/file/file.service.js +70 -0
  202. package/src/client/services/instance/instance.management.js +74 -0
  203. package/src/client/services/instance/instance.service.js +89 -0
  204. package/src/client/services/test/test.service.js +70 -0
  205. package/src/client/services/user/user.management.js +50 -0
  206. package/src/client/services/user/user.service.js +89 -0
  207. package/src/client/ssr/Render.js +16 -0
  208. package/src/client/ssr/body-components/CacheControl.js +113 -0
  209. package/src/client/ssr/body-components/DefaultSplashScreen.js +79 -0
  210. package/src/client/ssr/email-components/DefaultRecoverEmail.js +21 -0
  211. package/src/client/ssr/email-components/DefaultVerifyEmail.js +17 -0
  212. package/src/client/ssr/head-components/Css.js +241 -0
  213. package/src/client/ssr/head-components/DefaultScripts.js +3 -0
  214. package/src/client/ssr/head-components/Microdata.js +11 -0
  215. package/src/client/ssr/head-components/Production.js +1 -0
  216. package/src/client/ssr/head-components/PwaDefault.js +60 -0
  217. package/src/client/ssr/head-components/Seo.js +14 -0
  218. package/src/client/sw/default.sw.js +201 -0
  219. package/src/client/sw/template.sw.js +84 -0
  220. package/src/client.build.js +22 -0
  221. package/src/client.dev.js +21 -0
  222. package/src/cron.js +25 -0
  223. package/src/db/DataBaseProvider.js +34 -0
  224. package/src/db/mariadb/MariaDB.js +33 -0
  225. package/src/db/mongo/MongooseDB.js +46 -0
  226. package/src/dns.js +22 -0
  227. package/src/mailer/EmailRender.js +69 -0
  228. package/src/mailer/MailerProvider.js +96 -0
  229. package/src/proxy.js +22 -0
  230. package/src/runtime/lampp/Lampp.js +44 -0
  231. package/src/runtime/nginx/Nginx.js +3 -0
  232. package/src/runtime/xampp/Xampp.js +49 -0
  233. package/src/server/auth.js +204 -0
  234. package/src/server/backup.js +83 -0
  235. package/src/server/client-build-live.js +72 -0
  236. package/src/server/client-build.js +688 -0
  237. package/src/server/client-dev-server.js +58 -0
  238. package/src/server/client-formatted.js +48 -0
  239. package/src/server/client-icons.js +150 -0
  240. package/src/server/conf.js +611 -0
  241. package/src/server/dns.js +87 -0
  242. package/src/server/downloader.js +42 -0
  243. package/src/server/logger.js +135 -0
  244. package/src/server/network.js +122 -0
  245. package/src/server/peer.js +33 -0
  246. package/src/server/process.js +66 -0
  247. package/src/server/proxy.js +118 -0
  248. package/src/server/runtime.js +393 -0
  249. package/src/server/ssl.js +107 -0
  250. package/src/server.js +25 -0
  251. package/src/ws/IoInterface.js +45 -0
  252. package/src/ws/IoServer.js +39 -0
  253. package/src/ws/core/channels/core.ws.chat.js +23 -0
  254. package/src/ws/core/channels/core.ws.mailer.js +35 -0
  255. package/src/ws/core/channels/core.ws.stream.js +31 -0
  256. package/src/ws/core/core.ws.connection.js +28 -0
  257. package/src/ws/core/core.ws.emit.js +14 -0
  258. package/src/ws/core/core.ws.server.js +24 -0
  259. package/src/ws/core/management/core.ws.chat.js +8 -0
  260. package/src/ws/core/management/core.ws.mailer.js +16 -0
  261. package/src/ws/core/management/core.ws.stream.js +8 -0
  262. package/src/ws/default/channels/default.ws.main.js +16 -0
  263. package/src/ws/default/default.ws.connection.js +22 -0
  264. package/src/ws/default/default.ws.emit.js +14 -0
  265. package/src/ws/default/default.ws.server.js +20 -0
  266. package/src/ws/default/management/default.ws.main.js +8 -0
  267. package/startup.js +11 -0
  268. package/supervisord-openssh-server.conf +5 -0
  269. package/test/api.test.js +60 -0
@@ -0,0 +1,1596 @@
1
+ import { cap, getId, newInstance } from './CommonJs.js';
2
+ import { Draggable } from '@neodrag/vanilla';
3
+ import {
4
+ append,
5
+ s,
6
+ prepend,
7
+ setPath,
8
+ getProxyPath,
9
+ htmls,
10
+ sa,
11
+ getAllChildNodes,
12
+ getCurrentTrace,
13
+ isActiveElement,
14
+ } from './VanillaJs.js';
15
+ import { BtnIcon } from './BtnIcon.js';
16
+ import { Responsive } from './Responsive.js';
17
+ import { loggerFactory } from './Logger.js';
18
+ import {
19
+ Css,
20
+ ThemeEvents,
21
+ Themes,
22
+ ThemesScope,
23
+ darkTheme,
24
+ renderStyleTag,
25
+ renderStatus,
26
+ renderCssAttr,
27
+ } from './Css.js';
28
+ import { setDocTitle } from './Router.js';
29
+ import { NotificationManager } from './NotificationManager.js';
30
+ import { EventsUI } from './EventsUI.js';
31
+ import { Translate } from './Translate.js';
32
+ import { Input } from './Input.js';
33
+ import { Validator } from './Validator.js';
34
+ import { DropDown } from './DropDown.js';
35
+ import { Keyboard } from './Keyboard.js';
36
+ import { Badge } from './Badge.js';
37
+ import { Worker } from './Worker.js';
38
+
39
+ const logger = loggerFactory(import.meta);
40
+
41
+ const Modal = {
42
+ Data: {},
43
+ Render: async function (
44
+ options = {
45
+ id: '',
46
+ barConfig: {},
47
+ title: '',
48
+ html: '',
49
+ handleType: 'bar',
50
+ mode: '' /* slide-menu */,
51
+ RouterInstance: {},
52
+ disableTools: [],
53
+ },
54
+ ) {
55
+ if (options.heightBottomBar === undefined) options.heightBottomBar = 50;
56
+ if (options.heightTopBar === undefined) options.heightTopBar = 50;
57
+ let originHeightBottomBar = options.heightBottomBar ? newInstance(options.heightBottomBar) : 0;
58
+ let originHeightTopBar = options.heightTopBar ? newInstance(options.heightTopBar) : 0;
59
+ let width = 300;
60
+ let height = 400;
61
+ let top = 0;
62
+ let left = 0;
63
+ const topBottomBarEnable = options && options.barMode && options.barMode === 'top-bottom-bar';
64
+ if (!topBottomBarEnable) {
65
+ options.heightTopBar = options.heightTopBar + options.heightBottomBar;
66
+ options.heightBottomBar = 0;
67
+ }
68
+ const setCenterRestore = () => {
69
+ const ResponsiveData = Responsive.getResponsiveData();
70
+ top = `${ResponsiveData.height / 2 - height / 2}px`;
71
+ left = `${ResponsiveData.width / 2 - width / 2}px`;
72
+ };
73
+ setCenterRestore();
74
+ let transition = `opacity 0.3s, box-shadow 0.3s, bottom 0.3s`;
75
+ const originSlideMenuWidth = 320;
76
+ const collapseSlideMenuWidth = 50;
77
+ let slideMenuWidth = originSlideMenuWidth;
78
+ const minWidth = width;
79
+ const heightDefaultTopBar = 0;
80
+ const heightDefaultBottomBar = 0;
81
+ const idModal = options && 'id' in options ? options.id : getId(this.Data, 'modal-');
82
+ this.Data[idModal] = {
83
+ options,
84
+ onCloseListener: {},
85
+ onMenuListener: {},
86
+ onDragEndListener: {},
87
+ onObserverListener: {},
88
+ onClickListener: {},
89
+ };
90
+ if (options && 'mode' in options) {
91
+ this.Data[idModal][options.mode] = {};
92
+ switch (options.mode) {
93
+ case 'view':
94
+ if (options && options.slideMenu) s(`.btn-close-${options.slideMenu}`).click();
95
+ options.zIndexSync = true;
96
+
97
+ options.style = {
98
+ ...options.style,
99
+ 'min-width': `${minWidth}px`,
100
+ };
101
+
102
+ if (this.mobileModal()) {
103
+ options.barConfig.buttons.restore.disabled = true;
104
+ options.barConfig.buttons.minimize.disabled = true;
105
+ options.dragDisabled = true;
106
+ options.style.resize = 'none';
107
+ }
108
+
109
+ Responsive.Event[`view-${idModal}`] = () => {
110
+ if (!this.Data[idModal]) return delete Responsive.Event[`view-${idModal}`];
111
+ if (this.Data[idModal].slideMenu)
112
+ s(`.${idModal}`).style.height = `${
113
+ window.innerHeight -
114
+ (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
115
+ (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
116
+ }px`;
117
+ };
118
+ Responsive.Event[`view-${idModal}`]();
119
+
120
+ // Router
121
+ if (options.route)
122
+ (() => {
123
+ let path = window.location.pathname;
124
+ if (path !== '/' && path[path.length - 1] === '/') path = path.slice(0, -1);
125
+ const proxyPath = getProxyPath();
126
+ const newPath = `${proxyPath}${options.route}`;
127
+ if (path !== newPath) {
128
+ // console.warn('SET MODAL URI', newPath);
129
+ setPath(`${newPath}`); // ${location.search}
130
+ setDocTitle({ ...options.RouterInstance, route: options.route });
131
+ }
132
+ })();
133
+
134
+ break;
135
+ case 'slide-menu':
136
+ case 'slide-menu-right':
137
+ case 'slide-menu-left':
138
+ (async () => {
139
+ const { barConfig } = options;
140
+ options.style = {
141
+ position: 'absolute',
142
+ height: `${
143
+ window.innerHeight -
144
+ (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
145
+ (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
146
+ }px`,
147
+ width: `${slideMenuWidth}px`,
148
+ // 'overflow-x': 'hidden',
149
+ // overflow: 'visible', // required for tooltip
150
+ 'z-index': 6,
151
+ resize: 'none',
152
+ top: `${options.heightTopBar ? options.heightTopBar : heightDefaultTopBar}px`,
153
+ };
154
+ options.mode === 'slide-menu-right' ? (options.style.right = '0px') : (options.style.left = '0px');
155
+ const contentIconClass = 'abs center';
156
+
157
+ options.dragDisabled = true;
158
+ options.titleClass = 'hide';
159
+ top = '0px';
160
+ left = 'auto';
161
+ width = 'auto';
162
+ // barConfig.buttons.maximize.disabled = true;
163
+ // barConfig.buttons.minimize.disabled = true;
164
+ // barConfig.buttons.restore.disabled = true;
165
+ // barConfig.buttons.menu.disabled = true;
166
+ // barConfig.buttons.close.disabled = true;
167
+ options.btnBarModalClass = 'hide';
168
+ Responsive.Event[`slide-menu-${idModal}`] = () => {
169
+ for (const _idModal of Object.keys(this.Data)) {
170
+ if (this.Data[_idModal].slideMenu && this.Data[_idModal].slideMenu.id === idModal)
171
+ this.Data[_idModal].slideMenu.callBack();
172
+ }
173
+ s(`.${idModal}`).style.height = `${
174
+ window.innerHeight -
175
+ (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
176
+ (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
177
+ }px`;
178
+ if (s(`.main-body-top`)) {
179
+ if (Modal.mobileModal()) {
180
+ if (s(`.btn-menu-${idModal}`).classList.contains('hide') && collapseSlideMenuWidth !== slideMenuWidth)
181
+ s(`.main-body-top`).classList.remove('hide');
182
+ if (s(`.btn-close-${idModal}`).classList.contains('hide')) s(`.main-body-top`).classList.add('hide');
183
+ } else if (!s(`.main-body-top`).classList.contains('hide')) s(`.main-body-top`).classList.add('hide');
184
+ }
185
+ };
186
+ barConfig.buttons.menu.onClick = () => {
187
+ this.Data[idModal][options.mode].width = slideMenuWidth;
188
+ s(`.btn-menu-${idModal}`).classList.add('hide');
189
+ s(`.btn-close-${idModal}`).classList.remove('hide');
190
+ s(`.${idModal}`).style.width = `${this.Data[idModal][options.mode].width}px`;
191
+ s(`.html-${idModal}`).style.display = 'block';
192
+ // s(`.title-modal-${idModal}`).style.display = 'block';
193
+ if (s(`.main-body-top`)) {
194
+ s(`.btn-bar-center-icon-close`).classList.remove('hide');
195
+ s(`.btn-bar-center-icon-menu`).classList.add('hide');
196
+ }
197
+
198
+ Responsive.Event[`slide-menu-${idModal}`]();
199
+ };
200
+ barConfig.buttons.close.onClick = () => {
201
+ this.Data[idModal][options.mode].width = 0;
202
+ s(`.btn-close-${idModal}`).classList.add('hide');
203
+ s(`.btn-menu-${idModal}`).classList.remove('hide');
204
+ s(`.${idModal}`).style.width = `${this.Data[idModal][options.mode].width}px`;
205
+ s(`.html-${idModal}`).style.display = 'none';
206
+ if (s(`.main-body-top`)) {
207
+ s(`.btn-bar-center-icon-menu`).classList.remove('hide');
208
+ s(`.btn-bar-center-icon-close`).classList.add('hide');
209
+ }
210
+ // s(`.title-modal-${idModal}`).style.display = 'none';
211
+ Responsive.Event[`slide-menu-${idModal}`]();
212
+ };
213
+ transition += `, width 0.3s`;
214
+
215
+ const inputSearchBoxId = `top-bar-search-box`;
216
+ append(
217
+ 'body',
218
+ html` <div class="fix modal slide-menu-top-bar">
219
+ <div
220
+ class="fl top-bar ${options.barClass ? options.barClass : ''}"
221
+ style="height: ${originHeightTopBar}px;"
222
+ >
223
+ ${await BtnIcon.Render({
224
+ style: `height: 100%`,
225
+ class: 'in fll main-btn-menu action-bar-box action-btn-close hide',
226
+ label: html` <div class="${contentIconClass} action-btn-close-render">
227
+ <i class="fa-solid fa-xmark"></i>
228
+ </div>`,
229
+ })}
230
+ ${await BtnIcon.Render({
231
+ style: `height: 100%`,
232
+ class: `in fll main-btn-menu action-bar-box action-btn-app-icon ${
233
+ options?.disableTools?.includes('app-icon') ? 'hide' : ''
234
+ }`,
235
+ label: html` <div class="${contentIconClass} action-btn-app-icon-render"></div>`,
236
+ })}
237
+ <form
238
+ class="in fll top-bar-search-box-container hover ${options?.disableTools?.includes('text-box')
239
+ ? 'hide'
240
+ : ''}"
241
+ >
242
+ ${await Input.Render({
243
+ id: inputSearchBoxId,
244
+ placeholder: Modal.mobileModal() ? Translate.Render('search', '.top-bar-search-box') : undefined, // html`<i class="fa-solid fa-magnifying-glass"></i> ${Translate.Render('search')}`,
245
+ placeholderIcon: html`<div
246
+ class="in fll"
247
+ style="width: ${originHeightTopBar}px; height: ${originHeightTopBar}px;"
248
+ >
249
+ <div class="abs center"><i class="fa-solid fa-magnifying-glass"></i></div>
250
+ ${!Modal.mobileModal()
251
+ ? html` <div
252
+ class="inl wfm key-shortcut-container-info"
253
+ style="${renderCssAttr({ style: { top: '10px', left: '60px' } })}"
254
+ >
255
+ ${await Badge.Render({
256
+ id: 'shortcut-key-info-search',
257
+ text: 'Shift',
258
+ classList: 'inl',
259
+ style: { 'z-index': 1 },
260
+ })}
261
+ ${await Badge.Render({
262
+ id: 'shortcut-key-info-search',
263
+ text: '+',
264
+ classList: 'inl',
265
+ style: { 'z-index': 1, background: 'none', color: '#5f5f5f' },
266
+ })}
267
+ ${await Badge.Render({
268
+ id: 'shortcut-key-info-search',
269
+ text: 'k',
270
+ classList: 'inl',
271
+ style: { 'z-index': 1 },
272
+ })}
273
+ </div>`
274
+ : ''}
275
+ </div>`,
276
+ inputClass: 'in fll',
277
+ // containerClass: '',
278
+ })}
279
+ </form>
280
+ <div
281
+ class="abs top-box-profile-container ${options?.disableTools?.includes('profile') ? 'hide' : ''}"
282
+ >
283
+ ${await BtnIcon.Render({
284
+ style: `height: 100%`,
285
+ class: 'in fll session-in-log-in main-btn-menu action-bar-box action-btn-profile-log-in',
286
+ label: html` <div class="${contentIconClass} action-btn-profile-log-in-render"></div>`,
287
+ })}
288
+ ${await BtnIcon.Render({
289
+ style: `height: 100%`,
290
+ class: 'in fll session-in-log-out main-btn-menu action-bar-box action-btn-profile-log-out',
291
+ label: html` <div class="${contentIconClass} action-btn-profile-log-out-render">
292
+ <i class="fas fa-user-plus"></i>
293
+ </div>`,
294
+ })}
295
+ </div>
296
+ </div>
297
+ </div>`,
298
+ );
299
+ EventsUI.onClick(`.action-btn-profile-log-in`, () => {
300
+ s(`.main-btn-account`).click();
301
+ });
302
+ EventsUI.onClick(`.action-btn-profile-log-out`, () => {
303
+ s(`.main-btn-sign-up`).click();
304
+ });
305
+ s(`.input-info-${inputSearchBoxId}`).style.textAlign = 'left';
306
+ htmls(`.input-info-${inputSearchBoxId}`, '');
307
+ const inputInfoNode = s(`.input-info-${inputSearchBoxId}`).cloneNode(true);
308
+ s(`.input-info-${inputSearchBoxId}`).remove();
309
+ {
310
+ const id = 'search-box-history';
311
+ const searchBoxHistoryId = id;
312
+ const formDataInfoNode = [
313
+ {
314
+ model: 'search-box',
315
+ id: inputSearchBoxId,
316
+ rules: [] /*{ type: 'isEmpty' }, { type: 'isEmail' }*/,
317
+ },
318
+ ];
319
+ let hoverHistBox = false;
320
+ let hoverInputBox = false;
321
+ let currentKeyBoardSearchBoxIndex = 0;
322
+ let results = [];
323
+ let historySearchBox = [];
324
+
325
+ const checkHistoryBoxTitleStatus = () => {
326
+ if (s(`.search-box-result-title`) && s(`.search-box-result-title`).classList) {
327
+ if (!s(`.${inputSearchBoxId}`).value.trim()) {
328
+ s(`.search-box-result-title`).classList.add('hide');
329
+ s(`.search-box-recent-title`).classList.remove('hide');
330
+ } else {
331
+ s(`.search-box-recent-title`).classList.add('hide');
332
+ s(`.search-box-result-title`).classList.remove('hide');
333
+ }
334
+ }
335
+ };
336
+
337
+ const checkShortcutContainerInfoEnabled = () => {
338
+ if (Modal.mobileModal() || !s(`.key-shortcut-container-info`)) return;
339
+ if (!s(`.${inputSearchBoxId}`).value) {
340
+ s(`.key-shortcut-container-info`).classList.remove('hide');
341
+ } else s(`.key-shortcut-container-info`).classList.add('hide');
342
+ };
343
+
344
+ const renderSearchResult = async (results) => {
345
+ htmls(`.html-${searchBoxHistoryId}`, '');
346
+ if (results.length === 0) {
347
+ append(
348
+ `.html-${searchBoxHistoryId}`,
349
+ await BtnIcon.Render({
350
+ label: html`<i class="fas fa-exclamation-circle"></i> ${Translate.Render('no-result-found')}`,
351
+ class: `wfa`,
352
+ style: renderCssAttr({
353
+ style: {
354
+ padding: '3px',
355
+ margin: '2px',
356
+ 'text-align': 'center',
357
+ border: 'none',
358
+ cursor: 'default',
359
+ background: 'none !important',
360
+ },
361
+ }),
362
+ }),
363
+ );
364
+ }
365
+ let indexResult = -1;
366
+ for (const result of results) {
367
+ indexResult++;
368
+ const indexRender = indexResult;
369
+ append(
370
+ `.html-${searchBoxHistoryId}`,
371
+ await BtnIcon.Render({
372
+ label: `${
373
+ result.fontAwesomeIcon
374
+ ? html`<i class="${result.fontAwesomeIcon.classList.toString()}"></i> `
375
+ : result.imgElement
376
+ ? html`<img
377
+ class="inl"
378
+ src="${result.imgElement.src}"
379
+ style="${renderCssAttr({ style: { width: '25px', height: '25px' } })}"
380
+ />`
381
+ : ''
382
+ } ${Translate.Render(result.routerId)}`,
383
+ class: `wfa search-result-btn-${result.routerId} ${
384
+ indexResult === currentKeyBoardSearchBoxIndex ? 'main-btn-menu-active' : ''
385
+ } search-result-btn-${indexResult}`,
386
+ style: renderCssAttr({
387
+ style: { padding: '3px', margin: '2px', 'text-align': 'left' },
388
+ }),
389
+ }),
390
+ );
391
+ s(`.search-result-btn-${result.routerId}`).onclick = () => {
392
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex].classList.remove(
393
+ `main-btn-menu-active`,
394
+ );
395
+ currentKeyBoardSearchBoxIndex = indexRender;
396
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex].classList.add(
397
+ `main-btn-menu-active`,
398
+ );
399
+ setSearchValue(`.search-result-btn-${result.routerId}`);
400
+ };
401
+ }
402
+ };
403
+
404
+ const getResultSearchBox = (validatorData) => {
405
+ const { model, id } = validatorData;
406
+ switch (model) {
407
+ case 'search-box':
408
+ {
409
+ if (
410
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex] &&
411
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex].classList
412
+ )
413
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex].classList.remove(
414
+ `main-btn-menu-active`,
415
+ );
416
+ currentKeyBoardSearchBoxIndex = 0;
417
+ if (
418
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex] &&
419
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex].classList
420
+ )
421
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex].classList.add(
422
+ `main-btn-menu-active`,
423
+ );
424
+ results = [];
425
+ const routerInstance = Worker.RouterInstance.Routes();
426
+ for (const _routerId of Object.keys(routerInstance)) {
427
+ const routerId = _routerId.slice(1);
428
+ if (routerId) {
429
+ if (
430
+ s(`.main-btn-${routerId}`) &&
431
+ (routerId.toLocaleLowerCase().match(s(`.${id}`).value.toLocaleLowerCase()) ||
432
+ (Translate.Data[routerId] &&
433
+ Object.keys(Translate.Data[routerId]).filter((keyLang) =>
434
+ Translate.Data[routerId][keyLang]
435
+ .toLocaleLowerCase()
436
+ .match(s(`.${id}`).value.toLocaleLowerCase()),
437
+ ).length > 0))
438
+ ) {
439
+ const fontAwesomeIcon = getAllChildNodes(s(`.main-btn-${routerId}`)).find((e) => {
440
+ return (
441
+ e.classList &&
442
+ Array.from(e.classList).find((e) => e.match('fa-') && !e.match('fa-grip-vertical'))
443
+ );
444
+ });
445
+ const imgElement = getAllChildNodes(s(`.main-btn-${routerId}`)).find((e) => {
446
+ return (
447
+ typeof e.src === 'string' &&
448
+ e.src.match(routerId) &&
449
+ e.classList &&
450
+ Array.from(e.classList).find((e) => e.match('img-btn-square-menu'))
451
+ );
452
+ });
453
+ if (imgElement || fontAwesomeIcon) {
454
+ results.push({
455
+ routerId,
456
+ fontAwesomeIcon: fontAwesomeIcon,
457
+ imgElement,
458
+ });
459
+ }
460
+ }
461
+ }
462
+ }
463
+ }
464
+ break;
465
+
466
+ default:
467
+ break;
468
+ }
469
+ if (s(`.${inputSearchBoxId}`).value.trim()) renderSearchResult(results);
470
+ else renderSearchResult(historySearchBox);
471
+ };
472
+
473
+ const searchBoxCallBack = async (validatorData) => {
474
+ const isSearchBoxActiveElement = isActiveElement(inputSearchBoxId);
475
+ checkHistoryBoxTitleStatus();
476
+ checkShortcutContainerInfoEnabled();
477
+ if (!isSearchBoxActiveElement && !hoverHistBox && !hoverInputBox) {
478
+ Modal.removeModal(searchBoxHistoryId);
479
+ return;
480
+ }
481
+ setTimeout(() => getResultSearchBox(validatorData));
482
+ };
483
+
484
+ const getDefaultSearchBoxSelector = () => `.search-result-btn-${currentKeyBoardSearchBoxIndex}`;
485
+
486
+ const updateSearchBoxValue = (selector) => {
487
+ if (!selector) selector = getDefaultSearchBoxSelector();
488
+ if (s(selector).childNodes) {
489
+ if (
490
+ s(selector).childNodes[s(selector).childNodes.length - 1] &&
491
+ s(selector).childNodes[s(selector).childNodes.length - 1].data &&
492
+ s(selector).childNodes[s(selector).childNodes.length - 1].data.trim()
493
+ ) {
494
+ s(`.${inputSearchBoxId}`).value =
495
+ s(selector).childNodes[s(selector).childNodes.length - 1].data.trim();
496
+ } else if (
497
+ s(selector).childNodes[s(selector).childNodes.length - 2] &&
498
+ s(selector).childNodes[s(selector).childNodes.length - 2].outerText &&
499
+ s(selector).childNodes[s(selector).childNodes.length - 2].outerText.trim()
500
+ ) {
501
+ s(`.${inputSearchBoxId}`).value =
502
+ s(selector).childNodes[s(selector).childNodes.length - 2].outerText.trim();
503
+ }
504
+ }
505
+ checkHistoryBoxTitleStatus();
506
+ checkShortcutContainerInfoEnabled();
507
+ };
508
+
509
+ const setSearchValue = (selector) => {
510
+ if (!selector) selector = getDefaultSearchBoxSelector();
511
+ historySearchBox = historySearchBox.filter(
512
+ (h) => h.routerId !== results[currentKeyBoardSearchBoxIndex].routerId,
513
+ );
514
+ historySearchBox.unshift(results[currentKeyBoardSearchBoxIndex]);
515
+ updateSearchBoxValue(selector);
516
+ s(`.main-btn-${results[currentKeyBoardSearchBoxIndex].routerId}`).click();
517
+ Modal.removeModal(searchBoxHistoryId);
518
+ };
519
+
520
+ const searchBoxHistoryOpen = async () => {
521
+ if (!s(`.${id}`)) {
522
+ const { barConfig } = await Themes[Css.currentTheme]();
523
+ barConfig.buttons.maximize.disabled = true;
524
+ barConfig.buttons.minimize.disabled = true;
525
+ barConfig.buttons.restore.disabled = true;
526
+ barConfig.buttons.menu.disabled = true;
527
+ barConfig.buttons.close.disabled = false;
528
+ await Modal.Render({
529
+ id,
530
+ barConfig,
531
+ title: html`<div class="search-box-recent-title">
532
+ ${renderViewTitle({
533
+ icon: html`<i class="fas fa-history mini-title"></i>`,
534
+ text: Translate.Render('recent'),
535
+ })}
536
+ </div>
537
+ <div class="search-box-result-title hide">
538
+ ${renderViewTitle({
539
+ icon: html`<i class="far fa-list-alt mini-title"></i>`,
540
+ text: Translate.Render('results'),
541
+ })}
542
+ </div>`,
543
+ html: () => html``,
544
+ titleClass: 'mini-title',
545
+ style: {
546
+ resize: 'none',
547
+ 'max-width': '450px',
548
+ height:
549
+ this.mobileModal() && window.innerWidth < 445
550
+ ? `${window.innerHeight - originHeightTopBar}px !important`
551
+ : '300px !important',
552
+ 'z-index': 7,
553
+ },
554
+ dragDisabled: true,
555
+ maximize: true,
556
+ heightBottomBar: 0,
557
+ heightTopBar: originHeightTopBar,
558
+ barMode: options.barMode,
559
+ });
560
+
561
+ const titleNode = s(`.title-modal-${id}`).cloneNode(true);
562
+ s(`.title-modal-${id}`).remove();
563
+ s(`.btn-bar-modal-container-render-${id}`).classList.add('in');
564
+ s(`.btn-bar-modal-container-render-${id}`).classList.add('fll');
565
+ s(`.btn-bar-modal-container-render-${id}`).appendChild(titleNode);
566
+
567
+ prepend(`.btn-bar-modal-container-${id}`, html`<div class="hide">${inputInfoNode.outerHTML}</div>`);
568
+
569
+ s(`.top-bar-search-box-container`).onmouseover = () => {
570
+ hoverInputBox = true;
571
+ };
572
+ s(`.top-bar-search-box-container`).onmouseout = () => {
573
+ hoverInputBox = false;
574
+ };
575
+ s(`.${id}`).onmouseover = () => {
576
+ hoverHistBox = true;
577
+ };
578
+ s(`.${id}`).onmouseout = () => {
579
+ hoverHistBox = false;
580
+ s(`.${inputSearchBoxId}`).focus();
581
+ };
582
+ }
583
+ };
584
+
585
+ s('.top-bar-search-box').oninput = () => {
586
+ searchBoxHistoryOpen();
587
+ searchBoxCallBack(formDataInfoNode[0]);
588
+ };
589
+ s('.top-bar-search-box').onfocus = () => {
590
+ searchBoxHistoryOpen();
591
+ searchBoxCallBack(formDataInfoNode[0]);
592
+ };
593
+ s('.top-bar-search-box').onblur = () => {
594
+ if (!hoverHistBox && !hoverInputBox && !isActiveElement(inputSearchBoxId)) {
595
+ Modal.removeModal(searchBoxHistoryId);
596
+ }
597
+ };
598
+ EventsUI.onClick(`.top-bar-search-box-container`, () => {
599
+ searchBoxHistoryOpen();
600
+ searchBoxCallBack(formDataInfoNode[0]);
601
+ });
602
+
603
+ const timePressDelay = 100;
604
+ Keyboard.instanceMultiPressKey({
605
+ id: 'input-search-shortcut-ArrowUp',
606
+ keys: ['ArrowUp'],
607
+ eventCallBack: () => {
608
+ if (s(`.${id}`)) {
609
+ if (
610
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex] &&
611
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex - 1]
612
+ ) {
613
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex].classList.remove(
614
+ `main-btn-menu-active`,
615
+ );
616
+ currentKeyBoardSearchBoxIndex--;
617
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex].classList.add(
618
+ `main-btn-menu-active`,
619
+ );
620
+ } else {
621
+ if (s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex])
622
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex].classList.remove(
623
+ `main-btn-menu-active`,
624
+ );
625
+ currentKeyBoardSearchBoxIndex = s(`.html-${searchBoxHistoryId}`).childNodes.length - 1;
626
+ if (s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex])
627
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex].classList.add(
628
+ `main-btn-menu-active`,
629
+ );
630
+ }
631
+ updateSearchBoxValue();
632
+ }
633
+ },
634
+ timePressDelay,
635
+ });
636
+
637
+ Keyboard.instanceMultiPressKey({
638
+ id: 'input-search-shortcut-ArrowDown',
639
+ keys: ['ArrowDown'],
640
+ eventCallBack: () => {
641
+ if (s(`.${id}`)) {
642
+ if (
643
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex] &&
644
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex + 1]
645
+ ) {
646
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex].classList.remove(
647
+ `main-btn-menu-active`,
648
+ );
649
+ currentKeyBoardSearchBoxIndex++;
650
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex].classList.add(
651
+ `main-btn-menu-active`,
652
+ );
653
+ } else {
654
+ if (s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex])
655
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex].classList.remove(
656
+ `main-btn-menu-active`,
657
+ );
658
+ currentKeyBoardSearchBoxIndex = 0;
659
+ if (s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex])
660
+ s(`.html-${searchBoxHistoryId}`).childNodes[currentKeyBoardSearchBoxIndex].classList.add(
661
+ `main-btn-menu-active`,
662
+ );
663
+ }
664
+ updateSearchBoxValue();
665
+ }
666
+ },
667
+ timePressDelay,
668
+ });
669
+
670
+ s(`.top-bar-search-box-container`).onsubmit = (e) => {
671
+ e.preventDefault();
672
+ setSearchValue();
673
+ };
674
+ }
675
+ setTimeout(async () => {
676
+ // clone and change position
677
+
678
+ // s(`.btn-close-${idModal}`);
679
+ // s(`.btn-menu-${idModal}`);
680
+ if (originHeightBottomBar === 0) {
681
+ const btnCloseNode = s(`.btn-close-${idModal}`).cloneNode(true);
682
+ s(`.btn-close-${idModal}`).remove();
683
+ s(`.top-bar`).appendChild(btnCloseNode);
684
+ s(`.btn-close-${idModal}`).onclick = btnCloseEvent;
685
+
686
+ const btnMenuNode = s(`.btn-menu-${idModal}`).cloneNode(true);
687
+ s(`.btn-menu-${idModal}`).remove();
688
+ s(`.top-bar`).appendChild(btnMenuNode);
689
+ s(`.btn-menu-${idModal}`).onclick = btnMenuEvent;
690
+ }
691
+
692
+ // const titleNode = s(`.title-modal-${idModal}`).cloneNode(true);
693
+ // s(`.title-modal-${idModal}`).remove();
694
+ // s(`.top-bar`).appendChild(titleNode);
695
+
696
+ s(`.slide-menu-top-bar`).style.zIndex = 7;
697
+
698
+ // s('body').removeChild(`.${idModal}`);
699
+ // while (s(`.top-modal`).firstChild) s(`.top-modal`).removeChild(s(`.top-modal`).firstChild);
700
+
701
+ {
702
+ const { barConfig } = await Themes[Css.currentTheme]();
703
+ barConfig.buttons.maximize.disabled = true;
704
+ barConfig.buttons.minimize.disabled = true;
705
+ barConfig.buttons.restore.disabled = true;
706
+ barConfig.buttons.menu.disabled = true;
707
+ barConfig.buttons.close.disabled = true;
708
+ const id = 'main-body';
709
+ await Modal.Render({
710
+ id,
711
+ barConfig,
712
+ html: options.htmlMainBody ? options.htmlMainBody : () => html``,
713
+ titleClass: 'hide',
714
+ style: {
715
+ // overflow: 'hidden',
716
+ background: 'none',
717
+ resize: 'none',
718
+ 'min-width': `${minWidth}px`,
719
+ width: '100%',
720
+ // border: '3px solid red',
721
+ },
722
+ dragDisabled: true,
723
+ maximize: true,
724
+ slideMenu: 'modal-menu',
725
+ heightTopBar: originHeightTopBar,
726
+ heightBottomBar: originHeightBottomBar,
727
+ barMode: options.barMode,
728
+ });
729
+ const maxWidthInputSearchBox = 450;
730
+ const paddingInputSearchBox = 5;
731
+ const paddingRightSearchBox = 50;
732
+ Responsive.Event[`view-${id}`] = () => {
733
+ if (!this.Data[id] || !s(`.${id}`)) return delete Responsive.Event[`view-${id}`];
734
+ const widthInputSearchBox =
735
+ window.innerWidth > maxWidthInputSearchBox ? maxWidthInputSearchBox : window.innerWidth;
736
+ s(`.top-bar-search-box-container`).style.width = `${
737
+ widthInputSearchBox - originHeightTopBar - paddingRightSearchBox - 1
738
+ }px`;
739
+ s(`.top-bar-search-box`).style.width = `${
740
+ widthInputSearchBox -
741
+ originHeightTopBar * 2 -
742
+ paddingRightSearchBox -
743
+ paddingInputSearchBox * 2 /*padding input*/ -
744
+ 10 /* right-margin */
745
+ }px`;
746
+ s(`.top-bar-search-box`).style.top = `${
747
+ (originHeightTopBar - s(`.top-bar-search-box`).clientHeight) / 2
748
+ }px`;
749
+ if (this.Data[id].slideMenu)
750
+ s(`.${id}`).style.height = `${
751
+ window.innerHeight -
752
+ (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
753
+ (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
754
+ }px`;
755
+ };
756
+ Responsive.Event[`view-${id}`]();
757
+ Keyboard.instanceMultiPressKey({
758
+ id: 'input-search-shortcut-k',
759
+ keys: [
760
+ ['Shift', 'k'],
761
+ ['Alt', 'k'],
762
+ ],
763
+ eventCallBack: () => {
764
+ if (s(`.top-bar-search-box`)) {
765
+ s(`.top-bar-search-box`).blur();
766
+ s(`.top-bar-search-box`).focus();
767
+ s(`.top-bar-search-box`).select();
768
+ }
769
+ },
770
+ });
771
+ }
772
+
773
+ {
774
+ const { barConfig } = await Themes[Css.currentTheme]();
775
+ barConfig.buttons.maximize.disabled = true;
776
+ barConfig.buttons.minimize.disabled = true;
777
+ barConfig.buttons.restore.disabled = true;
778
+ barConfig.buttons.menu.disabled = true;
779
+ barConfig.buttons.close.disabled = true;
780
+ const id = 'bottom-bar';
781
+ if (options && options.homeModals && !options.homeModals.includes(id)) options.homeModals.push(id);
782
+ else options.homeModals = [id];
783
+ const html = async () => html`
784
+ <style>
785
+ .top-bar-search-box-container {
786
+ height: 100%;
787
+ overflow: hidden;
788
+ }
789
+ .bottom-bar {
790
+ overflow: hidden;
791
+ }
792
+ .action-bar-box {
793
+ margin: 0px;
794
+ border: none;
795
+ width: 50px;
796
+ min-height: 50px;
797
+ }
798
+ </style>
799
+ <div
800
+ class="fl ${options.barClass ? options.barClass : ''}"
801
+ style="height: ${originHeightBottomBar}px;"
802
+ >
803
+ ${await BtnIcon.Render({
804
+ style: `height: 100%`,
805
+ class: `in fl${
806
+ options.mode === 'slide-menu-right' ? 'r' : 'l'
807
+ } main-btn-menu action-bar-box action-btn-center ${
808
+ options?.disableTools?.includes('center') ? 'hide' : ''
809
+ }`,
810
+ label: html`
811
+ <div class="${contentIconClass}">
812
+ <i class="far fa-square btn-bar-center-icon-square hide"></i>
813
+ <span class="btn-bar-center-icon-close hide">${barConfig.buttons.close.label}</span>
814
+ <span class="btn-bar-center-icon-menu">${barConfig.buttons.menu.label}</span>
815
+ </div>
816
+ `,
817
+ })}
818
+ ${await BtnIcon.Render({
819
+ style: `height: 100%`,
820
+ class: `in flr main-btn-menu action-bar-box action-btn-lang ${
821
+ options?.disableTools?.includes('lang') ? 'hide' : ''
822
+ }`,
823
+ label: html` <div class="${contentIconClass} action-btn-lang-render"></div>`,
824
+ })}
825
+ ${await BtnIcon.Render({
826
+ style: `height: 100%`,
827
+ class: `in flr main-btn-menu action-bar-box action-btn-theme ${
828
+ options?.disableTools?.includes('theme') ? 'hide' : ''
829
+ }`,
830
+ label: html` <div class="${contentIconClass} action-btn-theme-render"></div>`,
831
+ })}
832
+ ${await BtnIcon.Render({
833
+ style: `height: 100%`,
834
+ class: `in flr main-btn-menu action-bar-box action-btn-home ${
835
+ options?.disableTools?.includes('navigator') ? 'hide' : ''
836
+ }`,
837
+ label: html` <div class="${contentIconClass}"><i class="fas fa-home"></i></div>`,
838
+ })}
839
+ ${await BtnIcon.Render({
840
+ style: `height: 100%`,
841
+ class: `in flr main-btn-menu action-bar-box action-btn-right ${
842
+ options?.disableTools?.includes('navigator') ? 'hide' : ''
843
+ }`,
844
+ label: html` <div class="${contentIconClass}"><i class="fas fa-chevron-right"></i></div>`,
845
+ })}
846
+ ${await BtnIcon.Render({
847
+ style: `height: 100%`,
848
+ class: `in flr main-btn-menu action-bar-box action-btn-left ${
849
+ options?.disableTools?.includes('navigator') ? 'hide' : ''
850
+ }`,
851
+ label: html`<div class="${contentIconClass}"><i class="fas fa-chevron-left"></i></div>`,
852
+ })}
853
+ </div>
854
+ `;
855
+ if (options.heightBottomBar === 0 && options.heightTopBar > 0) {
856
+ append(`.slide-menu-top-bar`, html` <div class="in ${id}">${await html()}</div>`);
857
+ } else {
858
+ await Modal.Render({
859
+ id,
860
+ barConfig,
861
+ html,
862
+ titleClass: 'hide',
863
+ style: {
864
+ resize: 'none',
865
+ height: `${options.heightBottomBar}px`,
866
+ 'min-width': `${minWidth}px`,
867
+ 'z-index': 7,
868
+ },
869
+ dragDisabled: true,
870
+ maximize: true,
871
+ barMode: options.barMode,
872
+ });
873
+ Responsive.Event[`view-${id}`] = () => {
874
+ if (!this.Data[id] || !s(`.${id}`)) return delete Responsive.Event[`view-${id}`];
875
+ // <div class="in fll right-offset-menu-bottom-bar" style="height: 100%"></div>
876
+ // s(`.right-offset-menu-bottom-bar`).style.width = `${window.innerWidth - slideMenuWidth}px`;
877
+ s(`.${id}`).style.top = `${
878
+ window.innerHeight - (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
879
+ }px`;
880
+ };
881
+ Responsive.Event[`view-${id}`]();
882
+ }
883
+ EventsUI.onClick(`.action-btn-left`, (e) => {
884
+ e.preventDefault();
885
+ window.history.back();
886
+ });
887
+ EventsUI.onClick(`.action-btn-center`, (e) => {
888
+ e.preventDefault();
889
+ this.actionBtnCenter();
890
+ });
891
+ EventsUI.onClick(`.action-btn-right`, (e) => {
892
+ e.preventDefault();
893
+ window.history.forward();
894
+ });
895
+ EventsUI.onClick(`.action-btn-home`, () => s(`.main-btn-home`).click());
896
+ EventsUI.onClick(`.action-btn-app-icon`, () => s(`.action-btn-home`).click());
897
+ Keyboard.instanceMultiPressKey({
898
+ id: 'input-shortcut-global-escape',
899
+ keys: ['Escape'],
900
+ eventCallBack: () => {
901
+ // if (s(`.main-btn-home`)) s(`.main-btn-home`).click();
902
+
903
+ if (s(`.btn-close-${this.currentTopModalId}`)) s(`.btn-close-${this.currentTopModalId}`).click();
904
+ },
905
+ });
906
+ }
907
+
908
+ {
909
+ ThemeEvents['action-btn-theme'] = () => {
910
+ htmls(
911
+ `.action-btn-theme-render`,
912
+ html` ${darkTheme ? html` <i class="fas fa-moon"></i>` : html`<i class="far fa-sun"></i>`}`,
913
+ );
914
+ };
915
+ ThemeEvents['action-btn-theme']();
916
+
917
+ EventsUI.onClick(`.action-btn-theme`, async () => {
918
+ const themePair = ThemesScope.find((t) => t.theme === Css.currentTheme).themePair;
919
+ const theme = themePair ? themePair : ThemesScope.find((t) => t.dark === !darkTheme).theme;
920
+ if (s(`.dropdown-option-${theme}`))
921
+ DropDown.Tokens['settings-theme'].onClickEvents[`dropdown-option-${theme}`]();
922
+ else await Themes[theme]();
923
+ });
924
+ if (!(ThemesScope.find((t) => t.dark) && ThemesScope.find((t) => !t.dark))) {
925
+ s(`.action-btn-theme`).classList.add('hide');
926
+ }
927
+ }
928
+
929
+ {
930
+ htmls(`.action-btn-lang-render`, html` ${s('html').lang}`);
931
+ EventsUI.onClick(`.action-btn-lang`, () => {
932
+ let lang = 'en';
933
+ if (s('html').lang === 'en') lang = 'es';
934
+ if (s(`.dropdown-option-${lang}`))
935
+ DropDown.Tokens['settings-lang'].onClickEvents[`dropdown-option-${lang}`]();
936
+ else Translate.renderLang(lang);
937
+ });
938
+ }
939
+
940
+ {
941
+ const { barConfig } = await Themes[Css.currentTheme]();
942
+ barConfig.buttons.maximize.disabled = true;
943
+ barConfig.buttons.minimize.disabled = true;
944
+ barConfig.buttons.restore.disabled = true;
945
+ barConfig.buttons.menu.disabled = true;
946
+ barConfig.buttons.close.disabled = true;
947
+ const id = 'main-body-top';
948
+ await Modal.Render({
949
+ id,
950
+ barConfig,
951
+ html: () => html``,
952
+ titleClass: 'hide',
953
+ class: 'hide',
954
+ style: {
955
+ // overflow: 'hidden',
956
+ background: 'none',
957
+ resize: 'none',
958
+ 'min-width': `${minWidth}px`,
959
+ 'z-index': 5,
960
+ background: `rgba(61, 61, 61, 0.5)`,
961
+ // border: '3px solid red',
962
+ },
963
+ dragDisabled: true,
964
+ maximize: true,
965
+ heightTopBar: originHeightTopBar,
966
+ heightBottomBar: originHeightBottomBar,
967
+ barMode: options.barMode,
968
+ });
969
+
970
+ Responsive.Event[`view-${id}`] = () => {
971
+ if (!this.Data[id] || !s(`.${id}`)) return delete Responsive.Event[`view-${id}`];
972
+ s(`.${id}`).style.height = `${
973
+ window.innerHeight -
974
+ (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
975
+ (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
976
+ }px`;
977
+ };
978
+ Responsive.Event[`view-${id}`]();
979
+
980
+ s(`.main-body-top`).onclick = () => s(`.btn-close-modal-menu`).click();
981
+ }
982
+
983
+ await NotificationManager.RenderBoard(options);
984
+ });
985
+ })();
986
+ break;
987
+
988
+ case 'dropNotification':
989
+ (() => {
990
+ setTimeout(() => {
991
+ s(`.${idModal}`).style.top = 'auto';
992
+ s(`.${idModal}`).style.left = 'auto';
993
+ s(`.${idModal}`).style.height = 'auto';
994
+ s(`.${idModal}`).style.position = 'absolute';
995
+ let countDrop = 0;
996
+ Object.keys(this.Data)
997
+ .reverse()
998
+ .map((_idModal) => {
999
+ if (this.Data[_idModal][options.mode]) {
1000
+ s(`.${_idModal}`).style.bottom = `${countDrop * s(`.${_idModal}`).clientHeight * 1.05}px`;
1001
+ countDrop++;
1002
+ }
1003
+ });
1004
+ });
1005
+ })();
1006
+ break;
1007
+
1008
+ default:
1009
+ break;
1010
+ }
1011
+ }
1012
+ if (options.zIndexSync) this.zIndexSync({ idModal });
1013
+ if (s(`.${idModal}`)) {
1014
+ s(`.btn-maximize-${idModal}`).click();
1015
+ return;
1016
+ }
1017
+ if (options.slideMenu) {
1018
+ if (options.titleClass) options.titleClass = ' title-view-modal ' + options.titleClass;
1019
+ options.titleClass = ' title-view-modal ';
1020
+ }
1021
+
1022
+ const render = html` <style class="style-${idModal}">
1023
+ .${idModal} {
1024
+ width: ${width}px;
1025
+ height: ${height}px;
1026
+ top: ${top};
1027
+ left: ${left};
1028
+ overflow: auto; /* resizable required */
1029
+ resize: auto; /* resizable required */
1030
+ transition: ${transition};
1031
+ opacity: 0;
1032
+ z-index: 1;
1033
+ }
1034
+ .bar-default-modal-${idModal} {
1035
+ top: 0px;
1036
+ left: 0px;
1037
+ z-index: 3;
1038
+ }
1039
+
1040
+ .modal-html-${idModal} {
1041
+ }
1042
+
1043
+ .btn-modal-default-${idModal} {
1044
+ }
1045
+ .modal-handle-${idModal} {
1046
+ width: 90%;
1047
+ height: 90%;
1048
+ top: 5%;
1049
+ left: 5%;
1050
+ }
1051
+ </style>
1052
+ ${renderStyleTag(`style-${idModal}`, `.${idModal}`, options)}
1053
+ <div class="fix ${options && options.class ? options.class : ''} modal box-shadow ${idModal}">
1054
+ <div class="abs modal-handle-${idModal}"></div>
1055
+ <div class="in modal-html-${idModal}">
1056
+ <div class="stq bar-default-modal bar-default-modal-${idModal}">
1057
+ <div
1058
+ class="fl btn-bar-modal-container btn-bar-modal-container-${idModal} ${options?.btnBarModalClass
1059
+ ? options.btnBarModalClass
1060
+ : ''}"
1061
+ >
1062
+ <div class="btn-bar-modal-container-render-${idModal}"></div>
1063
+ <div class="in flr bar-default-modal" style="z-index: 1">
1064
+ ${await BtnIcon.Render({
1065
+ class: `btn-minimize-${idModal} btn-modal-default btn-modal-default-${idModal} ${
1066
+ options?.btnContainerClass ? options.btnContainerClass : ''
1067
+ } ${options?.barConfig?.buttons?.minimize?.disabled ? 'hide' : ''}`,
1068
+ label: html`<div class="${options?.btnIconContainerClass ? options.btnIconContainerClass : ''}">
1069
+ ${options?.barConfig?.buttons?.minimize?.label ? options.barConfig.buttons.minimize.label : html`_`}
1070
+ </div>`,
1071
+ })}
1072
+ ${await BtnIcon.Render({
1073
+ class: `btn-restore-${idModal} btn-modal-default btn-modal-default-${idModal} ${
1074
+ options?.btnContainerClass ? options.btnContainerClass : ''
1075
+ } ${options?.barConfig?.buttons?.restore?.disabled ? 'hide' : ''}`,
1076
+ label: html`<div class="${options?.btnIconContainerClass ? options.btnIconContainerClass : ''}">
1077
+ ${options?.barConfig?.buttons?.restore?.label ? options.barConfig.buttons.restore.label : html`□`}
1078
+ </div>`,
1079
+ style: 'display: none',
1080
+ })}
1081
+ ${await BtnIcon.Render({
1082
+ class: `btn-maximize-${idModal} btn-modal-default btn-modal-default-${idModal} ${
1083
+ options?.btnContainerClass ? options.btnContainerClass : ''
1084
+ } ${options?.barConfig?.buttons?.maximize?.disabled ? 'hide' : ''}`,
1085
+ label: html`<div class="${options?.btnIconContainerClass ? options.btnIconContainerClass : ''}">
1086
+ ${options?.barConfig?.buttons?.maximize?.label ? options.barConfig.buttons.maximize.label : html`▢`}
1087
+ </div>`,
1088
+ })}
1089
+ ${await BtnIcon.Render({
1090
+ class: `btn-close-${idModal} btn-modal-default btn-modal-default-${idModal} ${
1091
+ options?.btnContainerClass ? options.btnContainerClass : ''
1092
+ } ${options?.barConfig?.buttons?.close?.disabled ? 'hide' : ''}`,
1093
+ label: html`<div class="${options?.btnIconContainerClass ? options.btnIconContainerClass : ''}">
1094
+ ${options?.barConfig?.buttons?.close?.label ? options.barConfig.buttons.close.label : html`X`}
1095
+ </div>`,
1096
+ })}
1097
+ ${await BtnIcon.Render({
1098
+ class: `btn-menu-${idModal} btn-modal-default btn-modal-default-${idModal} ${
1099
+ options?.btnContainerClass ? options.btnContainerClass : ''
1100
+ } ${options?.barConfig?.buttons?.menu?.disabled ? 'hide' : ''}`,
1101
+ label: html`<div class="${options?.btnIconContainerClass ? options.btnIconContainerClass : ''}">
1102
+ ${options?.barConfig?.buttons?.menu?.label ? options.barConfig.buttons.menu.label : html`≡`}
1103
+ </div>`,
1104
+ })}
1105
+ </div>
1106
+ </div>
1107
+ ${options && options.status
1108
+ ? html` <div class="abs modal-icon-container">${renderStatus(options.status)}</div> `
1109
+ : ''}
1110
+ <div
1111
+ class="inl title-modal-${idModal} ${options && options.titleClass ? options.titleClass : 'title-modal'}"
1112
+ >
1113
+ ${options && options.titleRender ? options.titleRender() : options.title ? options.title : ''}
1114
+ </div>
1115
+ </div>
1116
+
1117
+ <div class="in html-${idModal}">
1118
+ ${options.mode && options.mode.match('slide-menu')
1119
+ ? html`<div class="in" style="${renderCssAttr({ style: { height: '50px' } })}">
1120
+ ${await BtnIcon.Render({
1121
+ style: renderCssAttr({ style: { height: '100%', color: '#5f5f5f' } }),
1122
+ class: `in flr main-btn-menu action-bar-box btn-icon-menu-mode`,
1123
+ label: html` <div class="abs center">
1124
+ <i
1125
+ class="fas fa-caret-right btn-icon-menu-mode-right ${options.mode && options.mode.match('right')
1126
+ ? ''
1127
+ : 'hide'}"
1128
+ ></i
1129
+ ><i
1130
+ class="fas fa-caret-left btn-icon-menu-mode-left ${options.mode && options.mode.match('right')
1131
+ ? 'hide'
1132
+ : ''}"
1133
+ ></i>
1134
+ </div>`,
1135
+ })}
1136
+ </div>`
1137
+ : ''}
1138
+ ${options && options.html ? (typeof options.html === 'function' ? await options.html() : options.html) : ''}
1139
+ </div>
1140
+ </div>
1141
+ </div>`;
1142
+ const selector = options && options.selector ? options.selector : 'body';
1143
+ if (options) {
1144
+ switch (options.renderType) {
1145
+ case 'prepend':
1146
+ prepend(selector, render);
1147
+ break;
1148
+ default:
1149
+ append(selector, render);
1150
+ break;
1151
+ }
1152
+ } else append(selector, render);
1153
+ let handle = [s(`.bar-default-modal-${idModal}`), s(`.modal-handle-${idModal}`), s(`.modal-html-${idModal}`)];
1154
+ if (options && 'handleType' in options) {
1155
+ switch (options.handleType) {
1156
+ case 'bar':
1157
+ handle = [s(`.bar-default-modal-${idModal}`)];
1158
+
1159
+ break;
1160
+
1161
+ default:
1162
+ break;
1163
+ }
1164
+ }
1165
+ switch (options.mode) {
1166
+ case 'slide-menu':
1167
+ case 'slide-menu-right':
1168
+ case 'slide-menu-left':
1169
+ s(`.main-btn-home`).onclick = () => {
1170
+ for (const keyModal of Object.keys(this.Data)) {
1171
+ if (
1172
+ ![idModal, 'main-body-top', 'main-body']
1173
+ .concat(options?.homeModals ? options.homeModals : [])
1174
+ .includes(keyModal)
1175
+ )
1176
+ s(`.btn-close-${keyModal}`).click();
1177
+ }
1178
+ s(`.btn-close-modal-menu`).click();
1179
+ };
1180
+ EventsUI.onClick(`.btn-icon-menu-mode`, () => {
1181
+ if (s(`.btn-icon-menu-mode-right`).classList.contains('hide')) {
1182
+ s(`.btn-icon-menu-mode-right`).classList.remove('hide');
1183
+ s(`.btn-icon-menu-mode-left`).classList.add('hide');
1184
+ } else {
1185
+ s(`.btn-icon-menu-mode-left`).classList.remove('hide');
1186
+ s(`.btn-icon-menu-mode-right`).classList.add('hide');
1187
+ }
1188
+ if (slideMenuWidth === originSlideMenuWidth) {
1189
+ slideMenuWidth = collapseSlideMenuWidth;
1190
+ if (!s(`.btn-bar-center-icon-close`).classList.contains('hide')) {
1191
+ sa(`.handle-btn-container`).forEach((el) => el.classList.add('hide'));
1192
+ sa(`.menu-label-text`).forEach((el) => el.classList.add('hide'));
1193
+ if (!Modal.mobileModal()) {
1194
+ sa(`.tooltip-menu`).forEach((el) => el.classList.remove('hide'));
1195
+ s(`.${idModal}`).style.overflow = 'visible';
1196
+ }
1197
+ }
1198
+ if (options.onCollapseMenu) options.onCollapseMenu();
1199
+ } else {
1200
+ slideMenuWidth = originSlideMenuWidth;
1201
+ sa(`.handle-btn-container`).forEach((el) => el.classList.remove('hide'));
1202
+ sa(`.menu-label-text`).forEach((el) => el.classList.remove('hide'));
1203
+ if (!Modal.mobileModal()) {
1204
+ sa(`.tooltip-menu`).forEach((el) => el.classList.add('hide'));
1205
+ s(`.${idModal}`).style.overflow = null;
1206
+ }
1207
+
1208
+ if (options.onExtendMenu) options.onExtendMenu();
1209
+ }
1210
+ // btn-bar-center-icon-menu
1211
+ this.actionBtnCenter();
1212
+ this.actionBtnCenter();
1213
+ });
1214
+
1215
+ break;
1216
+
1217
+ default:
1218
+ break;
1219
+ }
1220
+ let dragOptions = {
1221
+ // disabled: true,
1222
+ handle,
1223
+ onDragStart: (data) => {
1224
+ if (!s(`.${idModal}`)) return;
1225
+ // logger.info('Dragging started', data);
1226
+ s(`.${idModal}`).style.transition = null;
1227
+ },
1228
+ onDrag: (data) => {
1229
+ if (!s(`.${idModal}`)) return;
1230
+ // logger.info('Dragging', data);
1231
+ },
1232
+ onDragEnd: (data) => {
1233
+ if (!s(`.${idModal}`)) return;
1234
+ // logger.info('Dragging stopped', data);
1235
+ s(`.${idModal}`).style.transition = transition;
1236
+ Object.keys(this.Data[idModal].onDragEndListener).map((keyListener) =>
1237
+ this.Data[idModal].onDragEndListener[keyListener](),
1238
+ );
1239
+ },
1240
+ };
1241
+ let dragInstance;
1242
+ // new Draggable(s(`.${idModal}`), { disabled: true });
1243
+ const setDragInstance = () => (options?.dragDisabled ? null : new Draggable(s(`.${idModal}`), dragOptions));
1244
+ this.Data[idModal].setDragInstance = (updateDragOptions) => {
1245
+ dragOptions = {
1246
+ ...dragOptions,
1247
+ ...updateDragOptions,
1248
+ };
1249
+ dragInstance = setDragInstance();
1250
+ this.Data[idModal].dragInstance = dragInstance;
1251
+ this.Data[idModal].dragOptions = dragOptions;
1252
+ };
1253
+ s(`.${idModal}`).style.transition = '0.15s';
1254
+ setTimeout(() => (s(`.${idModal}`).style.opacity = '1'));
1255
+ setTimeout(() => (s(`.${idModal}`).style.transition = transition), 150);
1256
+
1257
+ const btnCloseEvent = () => {
1258
+ Object.keys(this.Data[idModal].onCloseListener).map((keyListener) =>
1259
+ this.Data[idModal].onCloseListener[keyListener](),
1260
+ );
1261
+ if (options && 'barConfig' in options && options.barConfig.buttons.close.onClick)
1262
+ return options.barConfig.buttons.close.onClick();
1263
+ s(`.${idModal}`).style.opacity = '0';
1264
+ if (this.Data[idModal].observer) {
1265
+ this.Data[idModal].observer.disconnect();
1266
+ // this.Data[idModal].observer.unobserve();
1267
+ }
1268
+ setTimeout(() => {
1269
+ if (!s(`.${idModal}`)) return;
1270
+ this.removeModal(idModal);
1271
+ // Router
1272
+ if (options.route)
1273
+ (() => {
1274
+ let path = window.location.pathname;
1275
+ if (path[path.length - 1] !== '/') path = `${path}/`;
1276
+ let newPath = `${getProxyPath()}`;
1277
+ if (path !== newPath) {
1278
+ for (const subIdModal of Object.keys(this.Data).reverse()) {
1279
+ if (this.Data[subIdModal].options.route) {
1280
+ newPath = `${newPath}${this.Data[subIdModal].options.route}`;
1281
+ // console.warn('SET MODAL URI', newPath);
1282
+ setPath(newPath);
1283
+ this.setTopModalCallback(subIdModal);
1284
+ return setDocTitle({ ...options.RouterInstance, route: this.Data[subIdModal].options.route });
1285
+ }
1286
+ }
1287
+ // console.warn('SET MODAL URI', newPath);
1288
+ setPath(newPath);
1289
+ return setDocTitle({ ...options.RouterInstance, route: '' });
1290
+ }
1291
+ })();
1292
+ }, 300);
1293
+ };
1294
+ s(`.btn-close-${idModal}`).onclick = btnCloseEvent;
1295
+
1296
+ s(`.btn-minimize-${idModal}`).onclick = () => {
1297
+ if (options.slideMenu) delete this.Data[idModal].slideMenu;
1298
+ s(`.${idModal}`).style.transition = '0.3s';
1299
+ s(`.btn-minimize-${idModal}`).style.display = 'none';
1300
+ s(`.btn-maximize-${idModal}`).style.display = null;
1301
+ s(`.btn-restore-${idModal}`).style.display = null;
1302
+ s(`.${idModal}`).style.height = `${s(`.bar-default-modal-${idModal}`).clientHeight}px`;
1303
+ setTimeout(() => (s(`.${idModal}`).style.transition = transition), 300);
1304
+ };
1305
+ s(`.btn-restore-${idModal}`).onclick = () => {
1306
+ if (options.slideMenu) delete this.Data[idModal].slideMenu;
1307
+ s(`.${idModal}`).style.transition = '0.3s';
1308
+ s(`.btn-restore-${idModal}`).style.display = 'none';
1309
+ s(`.btn-minimize-${idModal}`).style.display = null;
1310
+ s(`.btn-maximize-${idModal}`).style.display = null;
1311
+ s(`.${idModal}`).style.transform = null;
1312
+ s(`.${idModal}`).style.height = null;
1313
+ s(`.${idModal}`).style.width = null;
1314
+ setCenterRestore();
1315
+ s(`.${idModal}`).style.top = top;
1316
+ s(`.${idModal}`).style.left = left;
1317
+ dragInstance = setDragInstance();
1318
+ setTimeout(() => (s(`.${idModal}`).style.transition = transition), 300);
1319
+ };
1320
+ s(`.btn-maximize-${idModal}`).onclick = () => {
1321
+ s(`.${idModal}`).style.transition = '0.3s';
1322
+ setTimeout(() => (s(`.${idModal}`).style.transition = transition), 300);
1323
+ s(`.btn-maximize-${idModal}`).style.display = 'none';
1324
+ s(`.btn-restore-${idModal}`).style.display = null;
1325
+ s(`.btn-minimize-${idModal}`).style.display = null;
1326
+ s(`.${idModal}`).style.transform = null;
1327
+
1328
+ if (options.slideMenu) {
1329
+ const idSlide = this.Data[options.slideMenu]['slide-menu']
1330
+ ? 'slide-menu'
1331
+ : this.Data[options.slideMenu]['slide-menu-right']
1332
+ ? 'slide-menu-right'
1333
+ : 'slide-menu-left';
1334
+ const callBack = () => {
1335
+ s(`.${idModal}`).style.transition = '0.3s';
1336
+ s(`.${idModal}`).style.width = `${window.innerWidth - this.Data[options.slideMenu][idSlide].width}px`;
1337
+ s(`.${idModal}`).style.left =
1338
+ idSlide === 'slide-menu-right' ? `0px` : `${this.Data[options.slideMenu][idSlide].width}px`;
1339
+ setTimeout(() => (s(`.${idModal}`) ? (s(`.${idModal}`).style.transition = transition) : null), 300);
1340
+ };
1341
+
1342
+ callBack();
1343
+ this.Data[idModal].slideMenu = {
1344
+ callBack,
1345
+ id: options.slideMenu,
1346
+ };
1347
+ s(`.${idModal}`).style.height = `${
1348
+ window.innerHeight -
1349
+ (options.heightTopBar ? options.heightTopBar : heightDefaultTopBar) -
1350
+ (options.heightBottomBar ? options.heightBottomBar : heightDefaultBottomBar)
1351
+ }px`;
1352
+ s(`.${idModal}`).style.top = `${options.heightTopBar ? options.heightTopBar : heightDefaultTopBar}px`;
1353
+ } else {
1354
+ s(`.${idModal}`).style.width = '100%';
1355
+ s(`.${idModal}`).style.height = '100%';
1356
+ s(`.${idModal}`).style.top = `${options.heightTopBar ? options.heightTopBar : heightDefaultTopBar}px`;
1357
+ s(`.${idModal}`).style.left = `0px`;
1358
+ }
1359
+ dragInstance = setDragInstance();
1360
+ };
1361
+
1362
+ const btnMenuEvent = () => {
1363
+ Object.keys(this.Data[idModal].onMenuListener).map((keyListener) =>
1364
+ this.Data[idModal].onMenuListener[keyListener](),
1365
+ );
1366
+ if (options && 'barConfig' in options && options.barConfig.buttons.menu.onClick)
1367
+ return options.barConfig.buttons.menu.onClick();
1368
+ };
1369
+ s(`.btn-menu-${idModal}`).onclick = btnMenuEvent;
1370
+
1371
+ dragInstance = setDragInstance();
1372
+ if (options && options.maximize) s(`.btn-maximize-${idModal}`).click();
1373
+ if (options.observer) {
1374
+ this.Data[idModal].onObserverListener = {};
1375
+ this.Data[idModal].observerCallBack = () => {
1376
+ // logger.info('ResizeObserver', `.${idModal}`, s(`.${idModal}`).offsetWidth, s(`.${idModal}`).offsetHeight);
1377
+ if (this.Data[idModal] && this.Data[idModal].onObserverListener)
1378
+ Object.keys(this.Data[idModal].onObserverListener).map((eventKey) =>
1379
+ this.Data[idModal].onObserverListener[eventKey]({
1380
+ width: s(`.${idModal}`).offsetWidth,
1381
+ height: s(`.${idModal}`).offsetHeight,
1382
+ }),
1383
+ );
1384
+ else console.warn('observer not found', idModal);
1385
+ };
1386
+ this.Data[idModal].observer = new ResizeObserver(this.Data[idModal].observerCallBack);
1387
+ this.Data[idModal].observer.observe(s(`.${idModal}`));
1388
+ setTimeout(this.Data[idModal].observerCallBack);
1389
+ }
1390
+ // cancel: [cancel1, cancel2]
1391
+ s(`.${idModal}`).onclick = () => {
1392
+ this.Data[idModal]?.onClickListener
1393
+ ? Object.keys(this.Data[idModal].onClickListener).map((keyListener) =>
1394
+ this.Data[idModal].onClickListener[keyListener](),
1395
+ )
1396
+ : null;
1397
+ };
1398
+ return {
1399
+ id: idModal,
1400
+ ...this.Data[idModal],
1401
+ };
1402
+ },
1403
+ currentTopModalId: '',
1404
+ zIndexSync: function ({ idModal }) {
1405
+ setTimeout(() => {
1406
+ const cleanTopModal = () => {
1407
+ Object.keys(this.Data).map((_idModal) => {
1408
+ if (this.Data[_idModal].options.zIndexSync && s(`.${_idModal}`)) s(`.${_idModal}`).style.zIndex = '3';
1409
+ });
1410
+ };
1411
+ const setTopModal = () => {
1412
+ if (s(`.${idModal}`)) {
1413
+ this.setTopModalCallback(idModal);
1414
+ } else setTimeout(setTopModal, 100);
1415
+ };
1416
+ cleanTopModal();
1417
+ setTopModal();
1418
+ this.Data[idModal].onClickListener[`${idModal}-z-index`] = () => {
1419
+ if (s(`.${idModal}`) && s(`.${idModal}`).style.zIndex === '3') {
1420
+ if (this.Data[idModal].options.route) setPath(`${getProxyPath()}${this.Data[idModal].options.route}`);
1421
+ cleanTopModal();
1422
+ setTopModal();
1423
+ }
1424
+ };
1425
+ });
1426
+ },
1427
+ setTopModalCallback: function (idModal) {
1428
+ s(`.${idModal}`).style.zIndex = '4';
1429
+ this.currentTopModalId = `${idModal}`;
1430
+ },
1431
+ mobileModal: () => window.innerWidth < 600 || window.innerHeight < 600,
1432
+ writeHTML: ({ idModal, html }) => htmls(`.html-${idModal}`, html),
1433
+ viewModalOpen: function () {
1434
+ return Object.keys(this.Data).find((idModal) => s(`.${idModal}`) && this.Data[idModal].options.mode === 'view');
1435
+ },
1436
+ removeModal: function (idModal) {
1437
+ if (!s(`.${idModal}`)) return;
1438
+ s(`.${idModal}`).remove();
1439
+ sa(`.style-${idModal}`).forEach((element) => {
1440
+ element.remove();
1441
+ });
1442
+ delete this.Data[idModal];
1443
+ },
1444
+ RenderConfirm: async function (options) {
1445
+ const { id } = options;
1446
+ append(
1447
+ 'body',
1448
+ html`
1449
+ <div
1450
+ class="fix background-confirm-modal-${id}"
1451
+ style="${renderCssAttr({
1452
+ style: {
1453
+ 'z-index': '10',
1454
+ background: 'rgba(0,0,0,0.5)',
1455
+ width: '100%',
1456
+ height: '100%',
1457
+ top: '0px',
1458
+ left: '0px',
1459
+ transition: '0.3s',
1460
+ opacity: '1',
1461
+ },
1462
+ })}"
1463
+ ></div>
1464
+ `,
1465
+ );
1466
+ const removeBackgroundConfirmModal = () => {
1467
+ s(`.background-confirm-modal-${id}`).style.opacity = '0';
1468
+ setTimeout(() => {
1469
+ s(`.background-confirm-modal-${id}`).remove();
1470
+ });
1471
+ };
1472
+
1473
+ return new Promise(async (resolve, reject) => {
1474
+ const { barConfig } = await Themes[Css.currentTheme]();
1475
+ barConfig.buttons.maximize.disabled = true;
1476
+ barConfig.buttons.minimize.disabled = true;
1477
+ barConfig.buttons.restore.disabled = true;
1478
+ barConfig.buttons.menu.disabled = true;
1479
+ barConfig.buttons.close.disabled = false;
1480
+ const htmlRender = html`
1481
+ <br />
1482
+ <div class="in section-mp" style="font-size: 40px; text-align: center">
1483
+ <i class="fas fa-question-circle"></i>
1484
+ </div>
1485
+ ${await options.html()}
1486
+ <div class="in section-mp">
1487
+ ${await BtnIcon.Render({
1488
+ class: `in section-mp form-button btn-confirm-${id}`,
1489
+ label: Translate.Render('confirm'),
1490
+ type: 'submit',
1491
+ style: `margin: auto`,
1492
+ })}
1493
+ </div>
1494
+ <div class="in section-mp">
1495
+ ${await BtnIcon.Render({
1496
+ class: `in section-mp form-button btn-cancel-${id}`,
1497
+ label: Translate.Render('cancel'),
1498
+ type: 'submit',
1499
+ style: `margin: auto`,
1500
+ })}
1501
+ </div>
1502
+ `;
1503
+ await Modal.Render({
1504
+ id,
1505
+ barConfig,
1506
+ titleClass: 'hide',
1507
+ style: {
1508
+ width: '300px',
1509
+ height: '350px',
1510
+ overflow: 'hidden',
1511
+ 'z-index': '11',
1512
+ resize: 'none',
1513
+ },
1514
+ dragDisabled: true,
1515
+ ...options,
1516
+ html: htmlRender,
1517
+ });
1518
+
1519
+ const end = () => {
1520
+ removeBackgroundConfirmModal();
1521
+ Modal.removeModal(id);
1522
+ };
1523
+ barConfig.buttons.close.onClick = () => {
1524
+ end();
1525
+ resolve({ status: 'cancelled' });
1526
+ };
1527
+ s(`.background-confirm-modal-${id}`).onclick = () => {
1528
+ end();
1529
+ resolve({ status: 'cancelled' });
1530
+ };
1531
+ s(`.btn-cancel-${id}`).onclick = () => {
1532
+ end();
1533
+ resolve({ status: 'cancelled' });
1534
+ };
1535
+ s(`.btn-confirm-${id}`).onclick = () => {
1536
+ end();
1537
+ resolve({ status: 'confirm' });
1538
+ };
1539
+ });
1540
+ },
1541
+ headerTitleHeight: 40,
1542
+ actionBtnCenter: function () {
1543
+ // if (!s(`.btn-close-modal-menu`).classList.contains('hide')) return s(`.main-btn-home`).click();
1544
+ if (!s(`.btn-close-modal-menu`).classList.contains('hide')) return s(`.btn-close-modal-menu`).click();
1545
+ if (!s(`.btn-menu-modal-menu`).classList.contains('hide')) return s(`.btn-menu-modal-menu`).click();
1546
+ },
1547
+ };
1548
+
1549
+ const renderMenuLabel = ({ img, text, icon }) => {
1550
+ if (!img) return html`<span class="menu-btn-icon">${icon}</span> ${text}`;
1551
+ return html`<img class="abs center img-btn-square-menu" src="${getProxyPath()}assets/ui-icons/${img}" />
1552
+ <div class="abs center main-btn-menu-text">${text}</div>`;
1553
+ };
1554
+
1555
+ const renderViewTitle = (options = { icon: '', img: '', text: '', assetFolder: '', 'ui-icons': '', dim, top }) => {
1556
+ if (options.dim === undefined) options.dim = 60;
1557
+ const { img, text, icon, dim, top } = options;
1558
+ if (!img && !options['ui-icon']) return html`<span class="view-title-icon">${icon}</span> ${text}`;
1559
+ return html`<img
1560
+ class="abs img-btn-square-view-title"
1561
+ style="${renderCssAttr({
1562
+ style: { width: `${dim}px`, height: `${dim}px`, top: top !== undefined ? `${top}px` : `-${dim / 2}px` },
1563
+ })}"
1564
+ src="${options['ui-icon']
1565
+ ? `${getProxyPath()}assets/${options.assetFolder ? options.assetFolder : 'ui-icons'}/${options['ui-icon']}`
1566
+ : img}"
1567
+ />
1568
+ <div class="in text-btn-square-view-title" style="${renderCssAttr({ style: { 'padding-left': `${dim}px` } })}">
1569
+ ${text}
1570
+ </div>`;
1571
+ };
1572
+
1573
+ const buildBadgeToolTipMenuOption = (id, sideKey = 'left') => {
1574
+ const option = {
1575
+ id: `tooltip-content-main-btn-${id}`,
1576
+ text: `${Translate.Render(`${id}`)}`,
1577
+ classList: 'tooltip-menu hide',
1578
+ style: { top: `0px` },
1579
+ };
1580
+ switch (sideKey) {
1581
+ case 'left':
1582
+ option.style.left = '40px';
1583
+
1584
+ break;
1585
+
1586
+ case 'right':
1587
+ option.style.right = '80px';
1588
+ break;
1589
+
1590
+ default:
1591
+ break;
1592
+ }
1593
+ return option;
1594
+ };
1595
+
1596
+ export { Modal, renderMenuLabel, renderViewTitle, buildBadgeToolTipMenuOption };