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,44 @@
1
+ import { connectedScatterplotChart } from '../chart/connectedScatterplotChart.js';
2
+
3
+ // https://takanori-fujiwara.github.io/d3-gallery-javascript/
4
+
5
+ const D3Chart = {
6
+ Render: async function () {
7
+ setTimeout(async () => {
8
+ const driving = await d3.csv('/data/driving.csv', d3.autoType);
9
+
10
+ const button = d3.select('.chart-panel').append('div').append('button').attr('type', 'button').text('Replay');
11
+
12
+ const play = () => {
13
+ const chart = connectedScatterplotChart(driving, {
14
+ svgId: 'connected-scatterplot',
15
+ x: (d) => d.miles,
16
+ y: (d) => d.gas,
17
+ title: (d) => d.year,
18
+ orient: (d) => d.side,
19
+ yFormat: '.2f',
20
+ xLabel: 'Miles driven (per capita per year) →',
21
+ yLabel: '↑ Price of gas (per gallon, adjusted average $)',
22
+ width: 1000,
23
+ height: 720,
24
+ duration: 5000, // for the intro animation; 0 to disable
25
+ });
26
+ d3.select('#connected-scatterplot').remove();
27
+ d3.select('.chart-container').append(() => chart);
28
+ };
29
+
30
+ play();
31
+
32
+ // replay
33
+ button.on('click', () => {
34
+ play();
35
+ });
36
+ });
37
+ return html`
38
+ <div class="in chart-container"></div>
39
+ <div class="in chart-panel"></div>
40
+ `;
41
+ },
42
+ };
43
+
44
+ export { D3Chart };
@@ -0,0 +1,130 @@
1
+ import { BtnIcon } from './BtnIcon.js';
2
+ import { Css, dynamicCol, Themes } from './Css.js';
3
+ import { DropDown } from './DropDown.js';
4
+ import { Modal, renderMenuLabel, renderViewTitle } from './Modal.js';
5
+ import { listenQueryPathInstance, setQueryPath } from './Router.js';
6
+ import { Translate } from './Translate.js';
7
+ import { getProxyPath, getQueryParams, htmls, s } from './VanillaJs.js';
8
+
9
+ // https://mintlify.com/docs/quickstart
10
+
11
+ const Docs = {
12
+ RenderModal: async function (type, modalOptions) {
13
+ const docData = this.Data.find((d) => d.type === type);
14
+ const ModalId = `modal-docs-${docData.type}`;
15
+ const { barConfig } = await Themes[Css.currentTheme]();
16
+ barConfig.buttons.close.onClick = () => {
17
+ setQueryPath({ path: 'docs' });
18
+ Modal.removeModal(ModalId);
19
+ };
20
+ await Modal.Render({
21
+ barConfig,
22
+ title: renderViewTitle(docData),
23
+ id: ModalId,
24
+ html: async () => {
25
+ return html`
26
+ <iframe class="in iframe-${ModalId}" style="width: 100%; border: none;" src="${docData.url()}"> </iframe>
27
+ `;
28
+ },
29
+ maximize: true,
30
+ mode: 'view',
31
+ slideMenu: 'modal-menu',
32
+ observer: true,
33
+ barMode: 'top-bottom-bar',
34
+ ...modalOptions,
35
+ });
36
+ Modal.Data[ModalId].onObserverListener[ModalId] = () => {
37
+ if (s(`.iframe-${ModalId}`))
38
+ s(`.iframe-${ModalId}`).style.height = `${s(`.${ModalId}`).offsetHeight - Modal.headerTitleHeight}px`;
39
+ };
40
+ Modal.Data[ModalId].onObserverListener[ModalId]();
41
+ },
42
+ Data: [
43
+ {
44
+ type: 'src',
45
+ icon: html`<i class="fa-brands fa-osi"></i>`,
46
+ text: 'Source Docs',
47
+ url: function () {
48
+ return `${getProxyPath()}docs/engine/2.6.2`;
49
+ },
50
+ },
51
+ {
52
+ type: 'api',
53
+ icon: html`<i class="fa-solid fa-arrows-turn-to-dots"></i>`,
54
+ text: `Api Docs`,
55
+ url: function () {
56
+ return `${getProxyPath()}api-docs`;
57
+ },
58
+ },
59
+ {
60
+ type: 'repo',
61
+ icon: html`<i class="fab fa-github"></i>`,
62
+ text: `Last Release`,
63
+ url: function () {
64
+ return `https://github.com/underpostnet/engine/`;
65
+ },
66
+ },
67
+ ],
68
+ Init: async function (options) {
69
+ const { idModal } = options;
70
+ setTimeout(() => {
71
+ s(`.btn-docs-src`).onclick = async () => {
72
+ setTimeout(() => setQueryPath({ path: 'docs', queryPath: 'src' }));
73
+ await this.RenderModal('src', options.modalOptions);
74
+ };
75
+ s(`.btn-docs-api`).onclick = async () => {
76
+ setTimeout(() => setQueryPath({ path: 'docs', queryPath: 'api' }));
77
+ await this.RenderModal('api', options.modalOptions);
78
+ };
79
+ s(`.btn-docs-repo`).onclick = () => {
80
+ const docData = this.Data.find((d) => d.type === 'repo');
81
+ location.href = docData.url();
82
+ };
83
+ // if (!getQueryParams().p) s(`.btn-docs-src`).click();
84
+ listenQueryPathInstance({
85
+ id: options.idModal,
86
+ routeId: 'docs',
87
+ event: (path) => {
88
+ if (s(`.btn-docs-${path}`)) s(`.btn-docs-${path}`).click();
89
+ },
90
+ });
91
+ });
92
+ let docMenuRender = '';
93
+ for (const docData of this.Data) {
94
+ docMenuRender += html` <div class="in">
95
+ ${await BtnIcon.Render({
96
+ class: `inl section-mp btn-custom btn-docs-${docData.type}`,
97
+ label: html`${docData.icon} ${docData.text}`,
98
+ })}
99
+ </div>`;
100
+ }
101
+ return html` <div class="in section-mp">${docMenuRender}</div>`;
102
+ return html` <div class="in section-mp">
103
+ ${await DropDown.Render({
104
+ id: 'dropdown-docs',
105
+ disableClose: true,
106
+ disableSelectLabel: true,
107
+ disableSelectOptionsLabel: true,
108
+ disableSearchBox: true,
109
+ open: true,
110
+ lastSelectClass: 'hover-active',
111
+ label: renderMenuLabel({
112
+ icon: html`<i class="fas fa-book"></i>`,
113
+ text: html`${Translate.Render('docs')}`,
114
+ }),
115
+ containerClass: '',
116
+ data: this.Data.map((docTypeData) => {
117
+ return {
118
+ display: docTypeData.label,
119
+ value: docTypeData.type,
120
+ onClick: async () => {
121
+ console.warn(this.viewUrl[docTypeData.type]());
122
+ },
123
+ };
124
+ }),
125
+ })}
126
+ </div>`;
127
+ },
128
+ };
129
+
130
+ export { Docs };
@@ -0,0 +1,164 @@
1
+ import { getId, newInstance } from './CommonJs.js';
2
+ import { Input } from './Input.js';
3
+ import { ToggleSwitch } from './ToggleSwitch.js';
4
+ import { Translate } from './Translate.js';
5
+ import { s, htmls } from './VanillaJs.js';
6
+
7
+ const DropDown = {
8
+ Tokens: {},
9
+ Render: async function (options) {
10
+ const id = options.id ? options.id : getId(this.Tokens, 'dropdown-');
11
+ this.Tokens[id] = { onClickEvents: {}, lastSelectValue: undefined };
12
+
13
+ options.data.push({
14
+ value: 'reset',
15
+ display: html`<i class="fa-solid fa-broom"></i> ${Translate.Render('clear')}`,
16
+ onClick: () => {
17
+ console.log('DropDown onClick', this.value);
18
+ if (options && options.resetOnClick) options.resetOnClick();
19
+ this.Tokens[id].value = undefined;
20
+ },
21
+ });
22
+
23
+ if (!(options && options.disableClose))
24
+ options.data.push({
25
+ value: 'close',
26
+ display: html`<i class="fa-solid fa-xmark"></i> ${Translate.Render('close')}`,
27
+ onClick: function () {
28
+ console.log('DropDown onClick', this.value);
29
+ },
30
+ });
31
+
32
+ const switchOptionsPanel = () => {
33
+ if (Array.from(s(`.dropdown-option-${id}`).classList).includes('hide'))
34
+ s(`.dropdown-option-${id}`).classList.remove('hide');
35
+ else s(`.dropdown-option-${id}`).classList.add('hide');
36
+ };
37
+
38
+ setTimeout(() => {
39
+ if (options.type === 'checkbox')
40
+ options.data.map((optionData) => {
41
+ const indexValue = options.data.findIndex((t) => optionData.checked && t.value === optionData.value);
42
+ if (indexValue > -1) setTimeout(() => s(`.dropdown-option-${id}-${indexValue}`).click());
43
+ });
44
+ else {
45
+ const indexValue = options.data.findIndex((t) => t.value === options.value);
46
+ if (indexValue > -1) setTimeout(() => s(`.dropdown-option-${id}-${indexValue}`).click());
47
+ }
48
+
49
+ s(`.dropdown-label-${id}`).onclick = switchOptionsPanel;
50
+ s(`.dropdown-current-${id}`).onclick = switchOptionsPanel;
51
+ if (options && options.open) switchOptionsPanel();
52
+ });
53
+
54
+ let render = '';
55
+ let index = -1;
56
+ for (const optionData of options.data) {
57
+ index++;
58
+ const i = index;
59
+ const valueDisplay = optionData.value.trim().replaceAll(' ', '-');
60
+ setTimeout(() => {
61
+ const onclick = (e) => {
62
+ if (options && options.lastSelectClass && s(`.dropdown-option-${this.Tokens[id].lastSelectValue}`)) {
63
+ s(`.dropdown-option-${this.Tokens[id].lastSelectValue}`).classList.remove(options.lastSelectClass);
64
+ }
65
+ this.Tokens[id].lastSelectValue = valueDisplay;
66
+ if (options && options.lastSelectClass && s(`.dropdown-option-${this.Tokens[id].lastSelectValue}`)) {
67
+ s(`.dropdown-option-${this.Tokens[id].lastSelectValue}`).classList.add(options.lastSelectClass);
68
+ }
69
+
70
+ if (
71
+ !(options && options.disableClose) &&
72
+ (options.type !== 'checkbox' || optionData.value === 'close' || optionData.value === 'reset')
73
+ )
74
+ s(`.dropdown-option-${id}`).classList.add('hide');
75
+
76
+ if (options.type === 'checkbox' && ToggleSwitch.Tokens[`checkbox-role-${valueDisplay}`])
77
+ ToggleSwitch.Tokens[`checkbox-role-${valueDisplay}`].click();
78
+ if (optionData.value !== 'close') {
79
+ if (optionData.value !== 'reset')
80
+ htmls(
81
+ `.dropdown-current-${id}`,
82
+ options.type === 'checkbox'
83
+ ? options.data
84
+ .filter((d) => d.checked)
85
+ .map((v, i, a) => `${v.display}${i < a.length - 1 ? ',' : ''}`)
86
+ .join('')
87
+ : optionData.display,
88
+ );
89
+ else htmls(`.dropdown-current-${id}`, '');
90
+
91
+ this.Tokens[id].value =
92
+ options.type === 'checkbox' ? options.data.filter((d) => d.checked).map((d) => d.data) : optionData.data;
93
+
94
+ console.warn('current value dropdown id:' + id, this.Tokens[id].value);
95
+
96
+ s(`.${id}`).value = this.Tokens[id].value;
97
+
98
+ optionData.onClick(e);
99
+ }
100
+ };
101
+
102
+ this.Tokens[id].onClickEvents[`dropdown-option-${id}-${i}`] = onclick;
103
+ this.Tokens[id].onClickEvents[`dropdown-option-${id}-${valueDisplay}`] = onclick;
104
+ this.Tokens[id].onClickEvents[`dropdown-option-${valueDisplay}`] = onclick;
105
+
106
+ s(`.dropdown-option-${id}-${i}`).onclick = onclick;
107
+ });
108
+ render += html`
109
+ <div
110
+ class="in dropdown-option dropdown-option-${id}-${i} dropdown-option-${id}-${valueDisplay} dropdown-option-${valueDisplay} ${valueDisplay ===
111
+ 'reset' &&
112
+ options &&
113
+ !(options.resetOption === true)
114
+ ? 'hide'
115
+ : ''}"
116
+ >
117
+ ${options.type === 'checkbox' && optionData.value !== 'close' && optionData.value !== 'reset'
118
+ ? html`
119
+ ${await ToggleSwitch.Render({
120
+ id: `checkbox-role-${valueDisplay}`,
121
+ type: 'checkbox',
122
+ disabledOnClick: true,
123
+ checked: optionData.checked,
124
+ on: {
125
+ unchecked: () => {
126
+ optionData.checked = false;
127
+ },
128
+ checked: () => {
129
+ optionData.checked = true;
130
+ },
131
+ },
132
+ })}
133
+ `
134
+ : ''}${optionData.display}
135
+ </div>
136
+ `;
137
+ }
138
+ return html`
139
+ <div class="inl dropdown-container ${id} ${options?.containerClass ? options.containerClass : ''}">
140
+ <div class="in dropdown-option dropdown-label-${id} ${options && options.disableSelectLabel ? 'hide' : ''}">
141
+ <i class="fa-solid fa-caret-down"> </i> ${options.label}
142
+ </div>
143
+ <div
144
+ class="in dropdown-option dropdown-current-${id} ${options && options.disableSelectOptionsLabel
145
+ ? 'hide'
146
+ : ''}"
147
+ ></div>
148
+ <div class="in dropdown-option-${id} hide">
149
+ <div class="in dropdown-option ${options && options.disableSearchBox ? 'hide' : ''}">
150
+ ${await Input.Render({
151
+ id: `search-box-${id}`,
152
+ label: html`<i class="fa-solid fa-magnifying-glass"></i> ${Translate.Render('search')}`,
153
+ containerClass: 'in',
154
+ placeholder: true,
155
+ })}
156
+ </div>
157
+ ${render}
158
+ </div>
159
+ </div>
160
+ `;
161
+ },
162
+ };
163
+
164
+ export { DropDown };
@@ -0,0 +1,54 @@
1
+ import { LoadingAnimation } from '../core/LoadingAnimation.js';
2
+ import { loggerFactory } from '../core/Logger.js';
3
+ import { cssEffect } from './Css.js';
4
+ import { NotificationManager } from './NotificationManager.js';
5
+ import { s } from './VanillaJs.js';
6
+
7
+ const logger = loggerFactory(import.meta);
8
+
9
+ const EventsUI = {
10
+ on: (id = '', logic = function (e) {}, type = 'onclick', options = {}) => {
11
+ const { loadingContainer, disableSpinner } = options;
12
+ if (!s(id)) return;
13
+ let complete = true;
14
+ s(id)[type] = async function (e) {
15
+ cssEffect(id, e);
16
+ if (complete) {
17
+ complete = false;
18
+ if (!disableSpinner) await LoadingAnimation.spinner.play(loadingContainer ? loadingContainer : id);
19
+ await LoadingAnimation.bar.play(id);
20
+ try {
21
+ await logic(e);
22
+ } catch (error) {
23
+ logger.error(error);
24
+ NotificationManager.Push({
25
+ status: 'error',
26
+ html: error?.message ? error.message : error ? error : 'Event error',
27
+ });
28
+ }
29
+ LoadingAnimation.bar.stop(id);
30
+ if (!disableSpinner) await LoadingAnimation.spinner.stop(loadingContainer ? loadingContainer : id);
31
+ complete = true;
32
+ return;
33
+ }
34
+ if (e && e.preventDefault) e.preventDefault();
35
+ logger.warn('in process', id);
36
+ };
37
+ },
38
+ onClick: async function (
39
+ id = '',
40
+ logic = async function (e) {},
41
+ options = { disableSpinner: false, loadingContainer: '' },
42
+ ) {
43
+ return await this.on(id, logic, 'onclick', options);
44
+ },
45
+ onChange: async function (
46
+ id = '',
47
+ logic = async function (e) {},
48
+ options = { disableSpinner: false, loadingContainer: '' },
49
+ ) {
50
+ return await this.on(id, logic, 'onchange', options);
51
+ },
52
+ };
53
+
54
+ export { EventsUI };