@yinuo-ngm/server 1.0.15 → 1.0.16

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 (326) hide show
  1. package/lib/plugins/error-handler.plugin.js +5 -0
  2. package/lib/routes/api-client/hub-token.routes.js +22 -0
  3. package/lib/routes/index.js +2 -0
  4. package/lib/routes/node-version.routes.d.ts +2 -0
  5. package/lib/routes/node-version.routes.js +56 -0
  6. package/lib/routes/project.routes.js +5 -0
  7. package/lib/routes/sprite-browse.routes.js +19 -5
  8. package/lib/routes/sprite.routes.js +17 -11
  9. package/lib/routes/static-files.routes.js +16 -0
  10. package/lib/routes/task.routes.js +7 -0
  11. package/package.json +3 -3
  12. package/www/3rdpartylicenses.txt +14 -66
  13. package/www/browser/chunk-2BZRE4G7.js +1 -0
  14. package/www/browser/chunk-2X3MRS27.js +1 -0
  15. package/www/browser/chunk-4KETC6EB.js +1 -0
  16. package/www/browser/chunk-5T5KA5PG.js +1 -0
  17. package/www/browser/chunk-6CGHNKJI.js +1 -0
  18. package/www/browser/chunk-76TVIB33.js +63 -0
  19. package/www/browser/chunk-7J24TP36.js +1 -0
  20. package/www/browser/chunk-ACAZUX6C.js +1 -0
  21. package/www/browser/chunk-B6MBYCXI.js +1 -0
  22. package/www/browser/chunk-BYEU6KGP.js +2 -0
  23. package/www/browser/chunk-CZ5AZ3VW.js +1 -0
  24. package/www/browser/chunk-DW7F5PEA.js +1 -0
  25. package/www/browser/chunk-DXF7BVK5.js +1 -0
  26. package/www/browser/chunk-EEVPZGEY.js +1 -0
  27. package/www/browser/chunk-G2W3B7TJ.js +1 -0
  28. package/www/browser/chunk-GDWS2L66.js +1 -0
  29. package/www/browser/chunk-HFZLJHYR.js +1 -0
  30. package/www/browser/chunk-HGONFYP6.js +1 -0
  31. package/www/browser/chunk-HHBPULJW.js +2 -0
  32. package/www/browser/chunk-HRXCR3IN.js +1 -0
  33. package/www/browser/chunk-INL2PELS.js +1 -0
  34. package/www/browser/chunk-JHMEKUZ5.js +1 -0
  35. package/www/browser/chunk-JU3TEDBV.js +37 -0
  36. package/www/browser/chunk-JZULA5JV.js +1 -0
  37. package/www/browser/chunk-KVFR7GFV.js +20 -0
  38. package/www/browser/chunk-L5D75AMV.js +1 -0
  39. package/www/browser/chunk-L7TMCSHV.js +1 -0
  40. package/www/browser/chunk-LQ5OXSW7.js +3 -0
  41. package/www/browser/chunk-MVQTKINJ.js +1 -0
  42. package/www/browser/chunk-N4LRZJBP.js +1 -0
  43. package/www/browser/chunk-O2EYEF7J.js +1 -0
  44. package/www/browser/chunk-OMDHJIUB.js +1 -0
  45. package/www/browser/chunk-OWUAAOHW.js +2 -0
  46. package/www/browser/chunk-PIK5YPIB.js +1 -0
  47. package/www/browser/chunk-RHLQRQDK.js +9 -0
  48. package/www/browser/chunk-RW2JPJV7.js +1 -0
  49. package/www/browser/chunk-S3SJ4VVM.js +11 -0
  50. package/www/browser/chunk-SIVPP74B.js +0 -0
  51. package/www/browser/chunk-SPRWNZHF.js +15 -0
  52. package/www/browser/chunk-SQQNR223.js +1 -0
  53. package/www/browser/chunk-SVQWPHF5.js +1 -0
  54. package/www/browser/chunk-SYCNSLAW.js +4 -0
  55. package/www/browser/chunk-T3KK7ZXB.js +2 -0
  56. package/www/browser/chunk-TMX5TTV3.js +1 -0
  57. package/www/browser/chunk-UFY3FLDK.js +1 -0
  58. package/www/browser/chunk-UJOHBN2Y.js +1 -0
  59. package/www/browser/chunk-UQGCUFNM.js +1 -0
  60. package/www/browser/chunk-UXXWRMM6.js +1 -0
  61. package/www/browser/chunk-UZRJGJTD.js +2 -0
  62. package/www/browser/chunk-WD4IAQR3.js +1 -0
  63. package/www/browser/chunk-WF2QTF5L.js +1 -0
  64. package/www/browser/chunk-WI67LAOV.js +4 -0
  65. package/www/browser/chunk-WNCM6QKB.js +1 -0
  66. package/www/browser/chunk-XJ5KZQNN.js +1 -0
  67. package/www/browser/chunk-YETDFSQE.js +1 -0
  68. package/www/browser/chunk-YMTC5GZK.js +1 -0
  69. package/www/browser/chunk-YVZHJ76K.js +1 -0
  70. package/www/browser/chunk-ZNTJRLVH.js +1 -0
  71. package/www/browser/dark.css +1 -30433
  72. package/www/browser/default.css +1 -30149
  73. package/www/browser/index.html +3 -3
  74. package/www/browser/main-6LN5C22E.js +34 -0
  75. package/www/browser/scripts-U25HCVEI.js +6 -0
  76. package/www/browser/styles-ROAHD7MY.css +1 -0
  77. package/www/browser/add-widget-drawer.component.css.map +0 -7
  78. package/www/browser/advanced-editor.component.css.map +0 -7
  79. package/www/browser/api-client.component.css.map +0 -7
  80. package/www/browser/api-history-drawer.component.css.map +0 -7
  81. package/www/browser/app.css.map +0 -7
  82. package/www/browser/attachment-viewer.component.css.map +0 -7
  83. package/www/browser/auth-editor.component.css.map +0 -7
  84. package/www/browser/body-editor.component.css.map +0 -7
  85. package/www/browser/chunk-2YSUXBGC.js +0 -627
  86. package/www/browser/chunk-2YSUXBGC.js.map +0 -1
  87. package/www/browser/chunk-3G2GEOPV.js +0 -456
  88. package/www/browser/chunk-3G2GEOPV.js.map +0 -1
  89. package/www/browser/chunk-3L72DF3R.js +0 -1683
  90. package/www/browser/chunk-3L72DF3R.js.map +0 -1
  91. package/www/browser/chunk-3MCIETCQ.js +0 -8279
  92. package/www/browser/chunk-3MCIETCQ.js.map +0 -1
  93. package/www/browser/chunk-665WC4RU.js +0 -5383
  94. package/www/browser/chunk-665WC4RU.js.map +0 -1
  95. package/www/browser/chunk-6QMSEZPT.js +0 -10044
  96. package/www/browser/chunk-6QMSEZPT.js.map +0 -1
  97. package/www/browser/chunk-6TBQERYX.js +0 -280
  98. package/www/browser/chunk-6TBQERYX.js.map +0 -1
  99. package/www/browser/chunk-6UW4MRJZ.js +0 -43
  100. package/www/browser/chunk-6UW4MRJZ.js.map +0 -7
  101. package/www/browser/chunk-6XUMIL3W.js +0 -5495
  102. package/www/browser/chunk-6XUMIL3W.js.map +0 -1
  103. package/www/browser/chunk-724YOJI3.js +0 -903
  104. package/www/browser/chunk-724YOJI3.js.map +0 -1
  105. package/www/browser/chunk-766T7YES.js +0 -437
  106. package/www/browser/chunk-766T7YES.js.map +0 -1
  107. package/www/browser/chunk-7FC7DN65.js +0 -728
  108. package/www/browser/chunk-7FC7DN65.js.map +0 -1
  109. package/www/browser/chunk-APGQRYWX.js +0 -156
  110. package/www/browser/chunk-APGQRYWX.js.map +0 -7
  111. package/www/browser/chunk-AQHSGTHS.js +0 -1960
  112. package/www/browser/chunk-AQHSGTHS.js.map +0 -1
  113. package/www/browser/chunk-CTOEAJQK.js +0 -40
  114. package/www/browser/chunk-CTOEAJQK.js.map +0 -7
  115. package/www/browser/chunk-DEGQJKKZ.js +0 -409
  116. package/www/browser/chunk-DEGQJKKZ.js.map +0 -1
  117. package/www/browser/chunk-DIJX2663.js +0 -1166
  118. package/www/browser/chunk-DIJX2663.js.map +0 -1
  119. package/www/browser/chunk-E4XD4GLT.js +0 -427
  120. package/www/browser/chunk-E4XD4GLT.js.map +0 -1
  121. package/www/browser/chunk-EQOY6A3M.js +0 -212
  122. package/www/browser/chunk-EQOY6A3M.js.map +0 -1
  123. package/www/browser/chunk-ETTBRXVA.js +0 -2643
  124. package/www/browser/chunk-ETTBRXVA.js.map +0 -1
  125. package/www/browser/chunk-FLSUSPBD.js +0 -5569
  126. package/www/browser/chunk-FLSUSPBD.js.map +0 -1
  127. package/www/browser/chunk-FZNHBEAZ.js +0 -102
  128. package/www/browser/chunk-FZNHBEAZ.js.map +0 -1
  129. package/www/browser/chunk-GJC7CZIJ.js +0 -361
  130. package/www/browser/chunk-GJC7CZIJ.js.map +0 -7
  131. package/www/browser/chunk-GMCNMOTD.js +0 -844
  132. package/www/browser/chunk-GMCNMOTD.js.map +0 -7
  133. package/www/browser/chunk-H43HGCRW.js +0 -198
  134. package/www/browser/chunk-H43HGCRW.js.map +0 -7
  135. package/www/browser/chunk-J447GBHM.js +0 -160
  136. package/www/browser/chunk-J447GBHM.js.map +0 -1
  137. package/www/browser/chunk-JN3VOWP7.js +0 -384
  138. package/www/browser/chunk-JN3VOWP7.js.map +0 -1
  139. package/www/browser/chunk-KSHAGY2M.js +0 -399
  140. package/www/browser/chunk-KSHAGY2M.js.map +0 -7
  141. package/www/browser/chunk-KV72AKOD.js +0 -59
  142. package/www/browser/chunk-KV72AKOD.js.map +0 -7
  143. package/www/browser/chunk-LAVMY2SJ.js +0 -26
  144. package/www/browser/chunk-LAVMY2SJ.js.map +0 -7
  145. package/www/browser/chunk-LLRVGHG5.js +0 -73
  146. package/www/browser/chunk-LLRVGHG5.js.map +0 -7
  147. package/www/browser/chunk-LPME4AJ3.js +0 -196
  148. package/www/browser/chunk-LPME4AJ3.js.map +0 -1
  149. package/www/browser/chunk-LVPSURVU.js +0 -4615
  150. package/www/browser/chunk-LVPSURVU.js.map +0 -1
  151. package/www/browser/chunk-MMPO7QLO.js +0 -4146
  152. package/www/browser/chunk-MMPO7QLO.js.map +0 -7
  153. package/www/browser/chunk-O7LB6VFM.js +0 -1953
  154. package/www/browser/chunk-O7LB6VFM.js.map +0 -1
  155. package/www/browser/chunk-P5CWA4FO.js +0 -685
  156. package/www/browser/chunk-P5CWA4FO.js.map +0 -1
  157. package/www/browser/chunk-RBWIWNTL.js +0 -203
  158. package/www/browser/chunk-RBWIWNTL.js.map +0 -7
  159. package/www/browser/chunk-RUXJCM3V.js +0 -26199
  160. package/www/browser/chunk-RUXJCM3V.js.map +0 -1
  161. package/www/browser/chunk-S77VVYUZ.js +0 -168
  162. package/www/browser/chunk-S77VVYUZ.js.map +0 -1
  163. package/www/browser/chunk-SCXPYFOB.js +0 -4316
  164. package/www/browser/chunk-SCXPYFOB.js.map +0 -1
  165. package/www/browser/chunk-SS73S33S.js +0 -471
  166. package/www/browser/chunk-SS73S33S.js.map +0 -7
  167. package/www/browser/chunk-T6UAOWNP.js +0 -600
  168. package/www/browser/chunk-T6UAOWNP.js.map +0 -1
  169. package/www/browser/chunk-TEW4MY4J.js +0 -148
  170. package/www/browser/chunk-TEW4MY4J.js.map +0 -7
  171. package/www/browser/chunk-TVORF3SF.js +0 -82
  172. package/www/browser/chunk-TVORF3SF.js.map +0 -7
  173. package/www/browser/chunk-UAN42EUZ.js +0 -2147
  174. package/www/browser/chunk-UAN42EUZ.js.map +0 -1
  175. package/www/browser/chunk-ULOHDK7Y.js +0 -1
  176. package/www/browser/chunk-ULOHDK7Y.js.map +0 -7
  177. package/www/browser/chunk-UYJ3FVRV.js +0 -3978
  178. package/www/browser/chunk-UYJ3FVRV.js.map +0 -1
  179. package/www/browser/chunk-VXHZMSDM.js +0 -5509
  180. package/www/browser/chunk-VXHZMSDM.js.map +0 -1
  181. package/www/browser/chunk-VYNQPZQO.js +0 -281
  182. package/www/browser/chunk-VYNQPZQO.js.map +0 -1
  183. package/www/browser/chunk-W3J23PZI.js +0 -9213
  184. package/www/browser/chunk-W3J23PZI.js.map +0 -1
  185. package/www/browser/chunk-W5HGHCQT.js +0 -1642
  186. package/www/browser/chunk-W5HGHCQT.js.map +0 -7
  187. package/www/browser/chunk-XF5H7E4L.js +0 -4723
  188. package/www/browser/chunk-XF5H7E4L.js.map +0 -1
  189. package/www/browser/chunk-XNFNEBMY.js +0 -398
  190. package/www/browser/chunk-XNFNEBMY.js.map +0 -7
  191. package/www/browser/chunk-XQY5SPGI.js +0 -30811
  192. package/www/browser/chunk-XQY5SPGI.js.map +0 -1
  193. package/www/browser/chunk-Y7JBZHNK.js +0 -514
  194. package/www/browser/chunk-Y7JBZHNK.js.map +0 -1
  195. package/www/browser/chunk-YWHRP4X3.js +0 -406
  196. package/www/browser/chunk-YWHRP4X3.js.map +0 -1
  197. package/www/browser/chunk-Z7FJIV62.js +0 -95
  198. package/www/browser/chunk-Z7FJIV62.js.map +0 -7
  199. package/www/browser/chunk-ZBZHXS46.js +0 -1674
  200. package/www/browser/chunk-ZBZHXS46.js.map +0 -1
  201. package/www/browser/chunk-ZZA5NVAI.js +0 -735
  202. package/www/browser/chunk-ZZA5NVAI.js.map +0 -1
  203. package/www/browser/collection-modal.component.css.map +0 -7
  204. package/www/browser/collection-tree-item.component.css.map +0 -7
  205. package/www/browser/collection-tree.component.css.map +0 -7
  206. package/www/browser/config-change-bar-component.css.map +0 -7
  207. package/www/browser/config-item-component.css.map +0 -7
  208. package/www/browser/config-nav-component.css.map +0 -7
  209. package/www/browser/config-section-component.css.map +0 -7
  210. package/www/browser/create-summary-aside.component.css.map +0 -7
  211. package/www/browser/curl-actions.component.css.map +0 -7
  212. package/www/browser/dark.css.map +0 -7
  213. package/www/browser/dashboard-canvas.component.css.map +0 -7
  214. package/www/browser/dashboard.component.css.map +0 -7
  215. package/www/browser/default.css.map +0 -7
  216. package/www/browser/detail-item-card.component.css.map +0 -7
  217. package/www/browser/ellipsis-text.component.css.map +0 -7
  218. package/www/browser/env-modal.component.css.map +0 -7
  219. package/www/browser/env-picker.component.css.map +0 -7
  220. package/www/browser/feedback.component.css.map +0 -7
  221. package/www/browser/fs-explorer.component.css.map +0 -7
  222. package/www/browser/git-import-modal.component.css.map +0 -7
  223. package/www/browser/hub-v2-personal-token-modal.component.css.map +0 -7
  224. package/www/browser/issue-action-area.component.css.map +0 -7
  225. package/www/browser/issue-add-participants-dialog.component.css.map +0 -7
  226. package/www/browser/issue-assign-dialog.component.css.map +0 -7
  227. package/www/browser/issue-attachment-area.component.css.map +0 -7
  228. package/www/browser/issue-base-info-area.component.css.map +0 -7
  229. package/www/browser/issue-branches.component.css.map +0 -7
  230. package/www/browser/issue-close-dialog.component.css.map +0 -7
  231. package/www/browser/issue-collaborators-panel.component.css.map +0 -7
  232. package/www/browser/issue-comment-editor.component.css.map +0 -7
  233. package/www/browser/issue-create-branch-dialog.component.css.map +0 -7
  234. package/www/browser/issue-description-area.component.css.map +0 -7
  235. package/www/browser/issue-detail.component.css.map +0 -7
  236. package/www/browser/issue-resolve-dialog.component.css.map +0 -7
  237. package/www/browser/issue-start-own-branch-dialog.component.css.map +0 -7
  238. package/www/browser/issues-list-table.component.css.map +0 -7
  239. package/www/browser/issues.component.css.map +0 -7
  240. package/www/browser/kill-port-widget.component.css.map +0 -7
  241. package/www/browser/kv-table.component.css.map +0 -7
  242. package/www/browser/layout-footer.component.css.map +0 -7
  243. package/www/browser/layout-header.component.css.map +0 -7
  244. package/www/browser/layout-menu.component.css.map +0 -7
  245. package/www/browser/layout-project-nav.component.css.map +0 -7
  246. package/www/browser/layout-sidebar.component.css.map +0 -7
  247. package/www/browser/layout.component.css.map +0 -7
  248. package/www/browser/less-viewport-component.css.map +0 -7
  249. package/www/browser/main.js +0 -1872
  250. package/www/browser/main.js.map +0 -1
  251. package/www/browser/markdown-viewer.component.css.map +0 -7
  252. package/www/browser/news-feed-widget.component.css.map +0 -7
  253. package/www/browser/ng-devtool.component.css.map +0 -7
  254. package/www/browser/nginx-config-editor.component.css.map +0 -7
  255. package/www/browser/nginx-log-viewer.component.css.map +0 -7
  256. package/www/browser/nginx-secondary-logs-tab.component.css.map +0 -7
  257. package/www/browser/nginx-secondary-perf-tab.component.css.map +0 -7
  258. package/www/browser/nginx-secondary-settings-tab.component.css.map +0 -7
  259. package/www/browser/nginx-secondary-ssl-tab.component.css.map +0 -7
  260. package/www/browser/nginx-secondary-test-tab.component.css.map +0 -7
  261. package/www/browser/nginx-secondary-traffic-tab.component.css.map +0 -7
  262. package/www/browser/nginx-secondary-upstream-tab.component.css.map +0 -7
  263. package/www/browser/nginx-section-card.component.css.map +0 -7
  264. package/www/browser/nginx-server-drawer.component.css.map +0 -7
  265. package/www/browser/nginx-server-list.component.css.map +0 -7
  266. package/www/browser/nginx-stat-card.component.css.map +0 -7
  267. package/www/browser/nginx.component.css.map +0 -7
  268. package/www/browser/page-layout.component.css.map +0 -7
  269. package/www/browser/pick-workspace-modal.component.css.map +0 -7
  270. package/www/browser/polyfills.js +0 -26584
  271. package/www/browser/polyfills.js.map +0 -7
  272. package/www/browser/project-conf.component.css.map +0 -7
  273. package/www/browser/project-create-modal.component.css.map +0 -7
  274. package/www/browser/project-create.component.css.map +0 -7
  275. package/www/browser/project-deps.component.css.map +0 -7
  276. package/www/browser/project-edit-modal.component.css.map +0 -7
  277. package/www/browser/project-import.component.css.map +0 -7
  278. package/www/browser/project-item-popover.component.css.map +0 -7
  279. package/www/browser/project-item.component.css.map +0 -7
  280. package/www/browser/project-list.component.css.map +0 -7
  281. package/www/browser/projects.component.css.map +0 -7
  282. package/www/browser/quick-task-widget.component.css.map +0 -7
  283. package/www/browser/rd-action-area.component.css.map +0 -7
  284. package/www/browser/rd-advance-stage-dialog.component.css.map +0 -7
  285. package/www/browser/rd-block-dialog.component.css.map +0 -7
  286. package/www/browser/rd-create-dialog.component.css.map +0 -7
  287. package/www/browser/rd-detail.component.css.map +0 -7
  288. package/www/browser/rd-item-card.component.css.map +0 -7
  289. package/www/browser/rd-list-board.component.css.map +0 -7
  290. package/www/browser/rd-list-table.component.css.map +0 -7
  291. package/www/browser/rd.component.css.map +0 -7
  292. package/www/browser/request-collections.component.css.map +0 -7
  293. package/www/browser/request-editor.component.css.map +0 -7
  294. package/www/browser/request-list-item.component.css.map +0 -7
  295. package/www/browser/request-list.component.css.map +0 -7
  296. package/www/browser/request-tabs-bar.component.css.map +0 -7
  297. package/www/browser/request-tabs.component.css.map +0 -7
  298. package/www/browser/request-urlbar.component.css.map +0 -7
  299. package/www/browser/response-viewer.component.css.map +0 -7
  300. package/www/browser/scripts.js +0 -245
  301. package/www/browser/scripts.js.map +0 -7
  302. package/www/browser/setting.component.css.map +0 -7
  303. package/www/browser/sprite-conf-modal.component.css.map +0 -7
  304. package/www/browser/sprite-icons-panel-component.css.map +0 -7
  305. package/www/browser/sprite-images-panel-component.css.map +0 -7
  306. package/www/browser/sprite-result-tabs.component.css.map +0 -7
  307. package/www/browser/sprite-viewport-component.css.map +0 -7
  308. package/www/browser/sprite.component.css.map +0 -7
  309. package/www/browser/step-advance.component.css.map +0 -7
  310. package/www/browser/step-basic.component.css.map +0 -7
  311. package/www/browser/step-config.component.css.map +0 -7
  312. package/www/browser/step-features.component.css.map +0 -7
  313. package/www/browser/step-preset.component.css.map +0 -7
  314. package/www/browser/step-summary-aside.component.css.map +0 -7
  315. package/www/browser/styles.css +0 -258
  316. package/www/browser/styles.css.map +0 -7
  317. package/www/browser/system-log.component.css.map +0 -7
  318. package/www/browser/task-actions.component.css.map +0 -7
  319. package/www/browser/task-console.component.css.map +0 -7
  320. package/www/browser/task-header.component.css.map +0 -7
  321. package/www/browser/task-list.component.css.map +0 -7
  322. package/www/browser/tasks.component.css.map +0 -7
  323. package/www/browser/terminal-view.component.css.map +0 -7
  324. package/www/browser/welcome-widget.component.css.map +0 -7
  325. package/www/browser/widget-base.component.css.map +0 -7
  326. package/www/browser/widget-host.component.css.map +0 -7
@@ -1,4615 +0,0 @@
1
- import {
2
- TaskActionsComponent
3
- } from "./chunk-TVORF3SF.js";
4
- import "./chunk-Y7JBZHNK.js";
5
- import "./chunk-Z7FJIV62.js";
6
- import {
7
- NzDrawerModule
8
- } from "./chunk-7FC7DN65.js";
9
- import {
10
- NzModalModule
11
- } from "./chunk-FLSUSPBD.js";
12
- import {
13
- TaskStateService
14
- } from "./chunk-SS73S33S.js";
15
- import {
16
- NzCardModule
17
- } from "./chunk-ZZA5NVAI.js";
18
- import {
19
- NzSelectModule
20
- } from "./chunk-ETTBRXVA.js";
21
- import {
22
- PageLayoutComponent
23
- } from "./chunk-6QMSEZPT.js";
24
- import "./chunk-RBWIWNTL.js";
25
- import {
26
- NzBadgeModule
27
- } from "./chunk-DEGQJKKZ.js";
28
- import {
29
- ProjectContextStore
30
- } from "./chunk-TEW4MY4J.js";
31
- import "./chunk-APGQRYWX.js";
32
- import {
33
- ApiClient,
34
- NzMessageService
35
- } from "./chunk-2YSUXBGC.js";
36
- import {
37
- FormsModule,
38
- NzButtonModule,
39
- NzIconModule,
40
- NzInputModule,
41
- NzSpaceModule,
42
- NzTooltipModule
43
- } from "./chunk-RUXJCM3V.js";
44
- import "./chunk-VYNQPZQO.js";
45
- import {
46
- Router
47
- } from "./chunk-665WC4RU.js";
48
- import {
49
- CommonModule,
50
- HttpParams,
51
- NgStyle
52
- } from "./chunk-3MCIETCQ.js";
53
- import {
54
- ChangeDetectionStrategy,
55
- ChangeDetectorRef,
56
- Component,
57
- ElementRef,
58
- EnvironmentInjector,
59
- EventEmitter,
60
- FactoryTarget,
61
- HostBinding,
62
- Inject,
63
- Injectable,
64
- Input,
65
- NgModule,
66
- NgZone,
67
- Output,
68
- Renderer2,
69
- Subject,
70
- ViewChild,
71
- ViewEncapsulation,
72
- __decorate,
73
- __spreadProps,
74
- __spreadValues,
75
- afterNextRender,
76
- computed,
77
- core_exports,
78
- debounceTime,
79
- effect,
80
- firstValueFrom,
81
- forwardRef,
82
- inject,
83
- runInInjectionContext,
84
- signal,
85
- switchMap,
86
- takeUntil,
87
- timer,
88
- untracked,
89
- viewChild,
90
- ɵɵngDeclareClassMetadata,
91
- ɵɵngDeclareComponent,
92
- ɵɵngDeclareFactory,
93
- ɵɵngDeclareInjector,
94
- ɵɵngDeclareNgModule
95
- } from "./chunk-XQY5SPGI.js";
96
-
97
- // angular:jit:style:inline:src\app\pages\dashboard\dashboard.component.ts;CiAgICA6aG9zdHsKICAgICAgaGVpZ2h0OiAxMDAlOwogICAgICBkaXNwbGF5OiBibG9jazsKICAgICAgcG9zaXRpb246IHJlbGF0aXZlOwogICAgICB0cmFuc2l0aW9uOiB3aWR0aCAwLjJzOwogICAgfQogICAgOmhvc3QuY29sbGFwc2VkIHsKICAgICAgd2lkdGg6IGNhbGMoMTAwJSAtIDM2MHB4KTsKICAgIH0KICAgIC5zaWRlLXBhbmVsIHsKICAgICAgcG9zaXRpb246IGZpeGVkOwogICAgICB0b3A6IDA7CiAgICAgIHJpZ2h0OiAwOwogICAgICBoZWlnaHQ6IDEwMHZoOwogICAgICB3aWR0aDogMzYwcHg7CiAgICAgIGJhY2tncm91bmQ6ICNmZmY7CiAgICAgIGJveC1zaGFkb3c6IC04cHggMCAyNHB4IHJnYmEoMCwwLDAsLjEyKTsKICAgICAgdHJhbnNmb3JtOiB0cmFuc2xhdGVYKDEwMCUpOwogICAgICB0cmFuc2l0aW9uOiB0cmFuc2Zvcm0gMC4ycyBlYXNlOwogICAgICB6LWluZGV4OiAxMDAwOwogICAgICBkaXNwbGF5OiBmbGV4OwogICAgICBmbGV4LWRpcmVjdGlvbjogY29sdW1uOwogICAgfQogICAgLnNpZGUtcGFuZWwub3BlbiB7CiAgICAgIHRyYW5zZm9ybTogdHJhbnNsYXRlWCgwKTsKICAgIH0KCiAgICAuc2lkZS1oZWFkZXJ7CiAgICAgIGhlaWdodDogNTZweDsKICAgICAgcGFkZGluZzogMCAxMnB4OwogICAgICBkaXNwbGF5OiBmbGV4OwogICAgICBhbGlnbi1pdGVtczogY2VudGVyOwogICAgICBqdXN0aWZ5LWNvbnRlbnQ6IHNwYWNlLWJldHdlZW47CiAgICAgIGJvcmRlci1ib3R0b206IDFweCBzb2xpZCByZ2JhKDAsMCwwLC4wNik7CiAgICB9CiAgICAuc2lkZS1ib2R5ewogICAgICBmbGV4OiAxOwogICAgICBvdmVyZmxvdzogaGlkZGVuOwogICAgfQogIA==
98
- var dashboard_component_default = "/* angular:styles/component:less;d3a924ccfa0f5b8e2ab6167ab3b23f602bd22a2b18b4453a2443a23049360ad0;D:\\ng-manager\\webapp\\src\\app\\pages\\dashboard\\dashboard.component.ts */\n:host {\n height: 100%;\n display: block;\n position: relative;\n transition: width 0.2s;\n}\n:host.collapsed {\n width: calc(100% - 360px);\n}\n.side-panel {\n position: fixed;\n top: 0;\n right: 0;\n height: 100vh;\n width: 360px;\n background: #fff;\n box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);\n transform: translateX(100%);\n transition: transform 0.2s ease;\n z-index: 1000;\n display: flex;\n flex-direction: column;\n}\n.side-panel.open {\n transform: translateX(0);\n}\n.side-header {\n height: 56px;\n padding: 0 12px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n border-bottom: 1px solid rgba(0, 0, 0, 0.06);\n}\n.side-body {\n flex: 1;\n overflow: hidden;\n}\n/*# sourceMappingURL=dashboard.component.css.map */\n";
99
-
100
- // angular:jit:style:src\app\pages\dashboard\components\add-widget-drawer\add-widget-drawer.component.less
101
- var add_widget_drawer_component_default = "/* src/app/pages/dashboard/components/add-widget-drawer/add-widget-drawer.component.less */\n.list {\n height: 100%;\n width: 100%;\n display: flex;\n flex-direction: column;\n}\n.list .topbar {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 10px 16px;\n}\n.list .topbar nz-input-wrapper {\n width: 100%;\n border-radius: 18px;\n}\n.list .items {\n flex: 1 1 auto;\n overflow: auto;\n height: 0;\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 8px;\n overflow-x: hidden;\n overflow-y: auto;\n}\n.list .items .item {\n border-radius: 3px;\n padding: 10px 10px;\n cursor: pointer;\n}\n.list .items .item:hover,\n.list .items .item.active {\n background: var(--app-primary-3);\n}\n.list .items .item .row {\n display: flex;\n gap: 10px;\n align-items: center;\n overflow: hidden;\n justify-content: space-between;\n}\n.list .items .item .row .icon {\n font-size: 28px;\n flex: 0 0 auto;\n position: relative;\n border-radius: 50% 50%;\n width: 48px;\n height: 48px;\n display: flex;\n align-items: center;\n justify-content: center;\n background: var(--app-primary-1);\n}\n.list .items .item .row .info {\n flex: 1 1 auto;\n display: flex;\n flex-direction: column;\n gap: 4px;\n overflow: hidden;\n}\n.list .items .item .row .info .name {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.list .items .item .row .info .description {\n font-size: 13px;\n color: var(--app-text-secondary);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.list .items .item .row .actions {\n flex: 0 0 auto;\n}\n/*# sourceMappingURL=add-widget-drawer.component.css.map */\n";
102
-
103
- // src/app/pages/dashboard/services/dashboard-api.service.ts
104
- var DashboardApiService = class DashboardApiService2 {
105
- api = inject(ApiClient);
106
- getInfo(projectId) {
107
- return this.api.get(`/api/dashboard/getInfo/${projectId}`);
108
- }
109
- update(projectId, doc) {
110
- return this.api.post(`/api/dashboard/update/${projectId}`, doc);
111
- }
112
- widgets(projectId) {
113
- return this.api.get(`/api/dashboard/widgets/${projectId}`);
114
- }
115
- addWidget(projectId, data) {
116
- const { x, y } = data;
117
- return this.api.get(`/api/dashboard/addWidget/${projectId}/${data.widgetKey}/${x}/${y}`);
118
- }
119
- removeWidget(projectId, widgetId) {
120
- return this.api.delete(`/api/dashboard/removeWidget/${projectId}/${widgetId}`);
121
- }
122
- updateItemConfig(projectId, widgetId, config) {
123
- return this.api.post(`/api/dashboard/updateItemConfig/${projectId}/${widgetId}`, config);
124
- }
125
- killPort(port) {
126
- return this.api.get(`/api/dashboard/killPort/${port}`);
127
- }
128
- };
129
- DashboardApiService = __decorate([
130
- Injectable({
131
- providedIn: "root"
132
- })
133
- ], DashboardApiService);
134
-
135
- // src/app/pages/dashboard/services/dashboard-layout.service.ts
136
- var DashboardLayoutService = class DashboardLayoutService2 {
137
- api = inject(DashboardApiService);
138
- _doc = signal(null);
139
- items = computed(() => this._doc()?.items ?? []);
140
- updatedAt = computed(() => this._doc()?.updatedAt ?? 0);
141
- widgets = signal([]);
142
- saveTimer = null;
143
- async load(projectId) {
144
- try {
145
- const doc = await firstValueFrom(this.api.getInfo(projectId));
146
- this._doc.set(doc);
147
- return;
148
- } catch {
149
- this._doc.set({
150
- version: 1,
151
- projectId,
152
- updatedAt: Date.now(),
153
- items: []
154
- });
155
- }
156
- }
157
- setItems(projectId, items) {
158
- const cur = this._doc();
159
- if (!cur)
160
- return;
161
- this._doc.set(__spreadProps(__spreadValues({}, cur), { items }));
162
- this.scheduleAutoSave(projectId);
163
- }
164
- /**
165
- * 调度一次自动保存(防抖)
166
- * @param projectId
167
- * @param ms 毫秒,默认 10 秒
168
- */
169
- scheduleAutoSave(projectId, ms = 1e4) {
170
- if (this.saveTimer)
171
- clearTimeout(this.saveTimer);
172
- this.saveTimer = setTimeout(() => {
173
- this.flushSave(projectId).catch(() => void 0);
174
- }, ms);
175
- }
176
- async flushSave(projectId) {
177
- if (this.saveTimer) {
178
- clearTimeout(this.saveTimer);
179
- this.saveTimer = null;
180
- }
181
- const doc = this._doc();
182
- if (!doc)
183
- return;
184
- const saved = await firstValueFrom(this.api.update(projectId, doc));
185
- this._doc.set(saved);
186
- return;
187
- }
188
- add(widget) {
189
- console.log("add widget", widget);
190
- const cur = this._doc();
191
- if (!cur)
192
- return;
193
- this._doc.set(__spreadProps(__spreadValues({}, cur), {
194
- items: [...cur.items, widget]
195
- }));
196
- setTimeout(() => {
197
- const { x, y } = widget;
198
- this.api.addWidget(cur.projectId, {
199
- widgetKey: widget.key,
200
- x,
201
- y
202
- }).subscribe((doc) => {
203
- this._doc.set(doc);
204
- this.getWidgets();
205
- });
206
- }, 0);
207
- }
208
- remove(widgetId) {
209
- const cur = this._doc();
210
- if (!cur)
211
- return;
212
- this.api.removeWidget(cur.projectId, widgetId).subscribe((doc) => {
213
- this._doc.set(doc);
214
- this.getWidgets();
215
- });
216
- }
217
- killProcess(port) {
218
- this.api.killPort(Number(port)).subscribe((res) => {
219
- console.log("Killed port", port);
220
- });
221
- }
222
- getWidgets() {
223
- const cur = this._doc();
224
- ;
225
- if (!cur)
226
- return;
227
- this.api.widgets(cur.projectId).subscribe((widgets) => {
228
- this.widgets.set(widgets);
229
- });
230
- }
231
- updateConfig(projectId, widgetId, config) {
232
- const cur = this._doc();
233
- if (!cur)
234
- return;
235
- this.api.updateItemConfig(projectId, widgetId, config).subscribe((doc) => {
236
- this._doc.set(doc);
237
- });
238
- }
239
- };
240
- DashboardLayoutService = __decorate([
241
- Injectable({ providedIn: "root" })
242
- ], DashboardLayoutService);
243
-
244
- // src/app/pages/dashboard/components/add-widget-drawer/add-widget-drawer.component.ts
245
- var AddWidgetDrawerComponent = class AddWidgetDrawerComponent2 {
246
- layout = inject(DashboardLayoutService);
247
- add = new EventEmitter();
248
- keyword = signal("");
249
- widgets = this.layout.widgets;
250
- filtered = computed(() => {
251
- const k = this.keyword().trim().toLowerCase();
252
- if (!k)
253
- return this.widgets();
254
- return this.widgets().filter((w) => (w.title + (w.desc ?? "")).toLowerCase().includes(k));
255
- });
256
- constructor() {
257
- }
258
- addWidget(widget) {
259
- this.add.emit(widget);
260
- }
261
- static ctorParameters = () => [];
262
- static propDecorators = {
263
- add: [{ type: Output }]
264
- };
265
- };
266
- AddWidgetDrawerComponent = __decorate([
267
- Component({
268
- selector: "app-add-widget-drawer",
269
- changeDetection: ChangeDetectionStrategy.OnPush,
270
- imports: [
271
- CommonModule,
272
- FormsModule,
273
- NzIconModule,
274
- NzInputModule,
275
- NzButtonModule,
276
- NzTooltipModule
277
- ],
278
- template: `
279
- <div class="list">
280
- <div class="topbar">
281
- <nz-input-wrapper>
282
- <nz-icon class="search-icon" nzInputPrefix nzType="search" />
283
- <input
284
- nz-input
285
- placeholder=""
286
- [ngModel]="keyword()"
287
- (ngModelChange)="keyword.set($event)"
288
- />
289
- </nz-input-wrapper>
290
- </div>
291
- <div class="items">
292
- @for (it of filtered(); track it.key) {
293
- <div
294
- class="item"
295
- >
296
- <div class="row">
297
- <div class="icon">
298
- <nz-icon
299
- [nzType]="it.icon || 'appstore'"
300
- nzTheme="outline"
301
- />
302
- </div>
303
- <div class="info">
304
- <div class="name">{{ it.title }}</div>
305
- <div class="description">{{ it.desc }}</div>
306
- </div>
307
- <div class="actions">
308
- <button nz-button nzType="primary" nzSize="small" nzTooltip="\u6DFB\u52A0\u90E8\u4EF6" (click)="addWidget(it)">
309
- <nz-icon nzType="plus" />
310
- </button>
311
- </div>
312
- </div>
313
- </div>
314
- }
315
- </div>
316
- </div>
317
- `,
318
- styles: [add_widget_drawer_component_default]
319
- })
320
- ], AddWidgetDrawerComponent);
321
-
322
- // angular:jit:style:inline:src\app\pages\dashboard\components\dashboard-canvas\dashboard-canvas.component.ts;CiAgICA6aG9zdCB7IGRpc3BsYXk6IGJsb2NrOyBoZWlnaHQ6IDEwMCU7IH0KICAgIGdyaWRzdGVyIHsgZGlzcGxheTpibG9jazsgaGVpZ2h0OjEwMCU7YmFja2dyb3VuZDogdmFyKC0tYXBwLXByaW1hcnktMSk7IH0KICAgIGdyaWRzdGVyLWl0ZW17CiAgICAgIGJvcmRlci1yYWRpdXM6IDEwcHg7CiAgICB9CiAgICAuY2FyZCB7CiAgICAgIGhlaWdodDogMTAwJTsKICAgICAgYmFja2dyb3VuZDogI2ZmZjsKICAgICAgYm9yZGVyLXJhZGl1czogMTBweDsKICAgICAgYm94LXNoYWRvdzogMCAycHggMTBweCByZ2JhKDAsMCwwLC4wNik7CiAgICAgIG92ZXJmbG93OiBoaWRkZW47CiAgICAgIHBvc2l0aW9uOiByZWxhdGl2ZTsKICAgIH0KCiAgICAuY2FyZC5lZGl0LW1vZGUgeyB1c2VyLXNlbGVjdDogbm9uZTsgfQoKICAgIC8qIG92ZXJsYXkg5Y+q5YGa6KeG6KeJ5bGC77yM5LiN5oum5oiq5LqL5Lu2ICovCiAgICAuY2FyZC1vdmVybGF5ewogICAgICBwb3NpdGlvbjphYnNvbHV0ZTsgaW5zZXQ6MDsKICAgICAgYmFja2dyb3VuZDogcmdiYSgyNTUsMjU1LDI1NSwwLjU1KTsKICAgICAgZGlzcGxheTpmbGV4OyBqdXN0aWZ5LWNvbnRlbnQ6Y2VudGVyOyBhbGlnbi1pdGVtczpjZW50ZXI7CiAgICAgIHBvaW50ZXItZXZlbnRzOm5vbmU7CiAgICAgIHotaW5kZXg6IDI7CiAgICB9CiAgICAucmVtb3ZlLWJ1dHRvbnsKICAgICAgcG9zaXRpb246IGFic29sdXRlOwogICAgICByaWdodDogMTZweDsKICAgICAgdG9wOiAxNnB4OwogICAgICB6LWluZGV4OiAzOwogICAgICBiYWNrZ3JvdW5kOiB2YXIoLS1hcHAtcHJpbWFyeS0xKTsKICAgICAgY29sb3I6IHZhcigtLWFwcC1wcmltYXJ5KTsKICAgICAgdHJhbnNpdGlvbjogYWxsIDAuM3M7CiAgICAgICY6aG92ZXJ7CiAgICAgICAgYmFja2dyb3VuZDogdmFyKC0tYXBwLXByaW1hcnkpOwogICAgICAgIGNvbG9yOiAjZmZmOwogICAgICB9CiAgICB9CiAgICAuY2FyZC1vdmVybGF5IGJ1dHRvbiB7IHBvaW50ZXItZXZlbnRzOm5vbmU7IGJvcmRlci1yYWRpdXM6IDIwcHg7IH0KICAgIC50aXRsZXsgZm9udC1zaXplOiAxMnB4OyBjb2xvcjogcmdiYSgwLDAsMCwuNzUpOyB9CgogICAgLmNhcmQtYm9keXsKICAgICAgcG9zaXRpb246IHJlbGF0aXZlOwogICAgICBoZWlnaHQ6IDEwMCU7CiAgICB9CiAgICAuY2FyZC5lZGl0LW1vZGUgLmNhcmQtYm9keSB7Y3Vyc29yOiBtb3ZlO3BvaW50ZXItZXZlbnRzOiBub25lO29wYWNpdHk6IDAuODt9CiAg
323
- var dashboard_canvas_component_default = "/* angular:styles/component:less;3ab85a83069fb8a7a44891e4777bc7750f9c48bc10e18ecb82108c144f5f463c;D:\\ng-manager\\webapp\\src\\app\\pages\\dashboard\\components\\dashboard-canvas\\dashboard-canvas.component.ts */\n:host {\n display: block;\n height: 100%;\n}\ngridster {\n display: block;\n height: 100%;\n background: var(--app-primary-1);\n}\ngridster-item {\n border-radius: 10px;\n}\n.card {\n height: 100%;\n background: #fff;\n border-radius: 10px;\n box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);\n overflow: hidden;\n position: relative;\n}\n.card.edit-mode {\n -webkit-user-select: none;\n user-select: none;\n}\n.card-overlay {\n position: absolute;\n inset: 0;\n background: rgba(255, 255, 255, 0.55);\n display: flex;\n justify-content: center;\n align-items: center;\n pointer-events: none;\n z-index: 2;\n}\n.remove-button {\n position: absolute;\n right: 16px;\n top: 16px;\n z-index: 3;\n background: var(--app-primary-1);\n color: var(--app-primary);\n transition: all 0.3s;\n}\n.remove-button:hover {\n background: var(--app-primary);\n color: #fff;\n}\n.card-overlay button {\n pointer-events: none;\n border-radius: 20px;\n}\n.title {\n font-size: 12px;\n color: rgba(0, 0, 0, 0.75);\n}\n.card-body {\n position: relative;\n height: 100%;\n}\n.card.edit-mode .card-body {\n cursor: move;\n pointer-events: none;\n opacity: 0.8;\n}\n/*# sourceMappingURL=dashboard-canvas.component.css.map */\n";
324
-
325
- // node_modules/angular-gridster2/fesm2022/angular-gridster2.mjs
326
- var GridType;
327
- (function(GridType2) {
328
- GridType2["Fit"] = "fit";
329
- GridType2["ScrollVertical"] = "scrollVertical";
330
- GridType2["ScrollHorizontal"] = "scrollHorizontal";
331
- GridType2["Fixed"] = "fixed";
332
- GridType2["VerticalFixed"] = "verticalFixed";
333
- GridType2["HorizontalFixed"] = "horizontalFixed";
334
- })(GridType || (GridType = {}));
335
- var DisplayGrid;
336
- (function(DisplayGrid2) {
337
- DisplayGrid2["Always"] = "always";
338
- DisplayGrid2["OnDragAndResize"] = "onDrag&Resize";
339
- DisplayGrid2["None"] = "none";
340
- })(DisplayGrid || (DisplayGrid = {}));
341
- var CompactType;
342
- (function(CompactType2) {
343
- CompactType2["None"] = "none";
344
- CompactType2["CompactUp"] = "compactUp";
345
- CompactType2["CompactLeft"] = "compactLeft";
346
- CompactType2["CompactUpAndLeft"] = "compactUp&Left";
347
- CompactType2["CompactLeftAndUp"] = "compactLeft&Up";
348
- CompactType2["CompactRight"] = "compactRight";
349
- CompactType2["CompactUpAndRight"] = "compactUp&Right";
350
- CompactType2["CompactRightAndUp"] = "compactRight&Up";
351
- CompactType2["CompactDown"] = "compactDown";
352
- CompactType2["CompactDownAndLeft"] = "compactDown&Left";
353
- CompactType2["CompactLeftAndDown"] = "compactLeft&Down";
354
- CompactType2["CompactDownAndRight"] = "compactDown&Right";
355
- CompactType2["CompactRightAndDown"] = "compactRight&Down";
356
- CompactType2["CompactGrid"] = "compactGrid";
357
- })(CompactType || (CompactType = {}));
358
- var DirTypes;
359
- (function(DirTypes2) {
360
- DirTypes2["LTR"] = "ltr";
361
- DirTypes2["RTL"] = "rtl";
362
- })(DirTypes || (DirTypes = {}));
363
- var GridsterCompact = class {
364
- gridster;
365
- constructor(gridster) {
366
- this.gridster = gridster;
367
- }
368
- destroy() {
369
- this.gridster = null;
370
- }
371
- checkCompact() {
372
- if (this.gridster.$options.compactType !== CompactType.None) {
373
- if (this.gridster.$options.compactType === CompactType.CompactUp) {
374
- this.checkCompactMovement("y", -1);
375
- } else if (this.gridster.$options.compactType === CompactType.CompactLeft) {
376
- this.checkCompactMovement("x", -1);
377
- } else if (this.gridster.$options.compactType === CompactType.CompactUpAndLeft) {
378
- this.checkCompactMovement("y", -1);
379
- this.checkCompactMovement("x", -1);
380
- } else if (this.gridster.$options.compactType === CompactType.CompactLeftAndUp) {
381
- this.checkCompactMovement("x", -1);
382
- this.checkCompactMovement("y", -1);
383
- } else if (this.gridster.$options.compactType === CompactType.CompactRight) {
384
- this.checkCompactMovement("x", 1);
385
- } else if (this.gridster.$options.compactType === CompactType.CompactUpAndRight) {
386
- this.checkCompactMovement("y", -1);
387
- this.checkCompactMovement("x", 1);
388
- } else if (this.gridster.$options.compactType === CompactType.CompactRightAndUp) {
389
- this.checkCompactMovement("x", 1);
390
- this.checkCompactMovement("y", -1);
391
- } else if (this.gridster.$options.compactType === CompactType.CompactDown) {
392
- this.checkCompactMovement("y", 1);
393
- } else if (this.gridster.$options.compactType === CompactType.CompactDownAndLeft) {
394
- this.checkCompactMovement("y", 1);
395
- this.checkCompactMovement("x", -1);
396
- } else if (this.gridster.$options.compactType === CompactType.CompactDownAndRight) {
397
- this.checkCompactMovement("y", 1);
398
- this.checkCompactMovement("x", 1);
399
- } else if (this.gridster.$options.compactType === CompactType.CompactLeftAndDown) {
400
- this.checkCompactMovement("x", -1);
401
- this.checkCompactMovement("y", 1);
402
- } else if (this.gridster.$options.compactType === CompactType.CompactRightAndDown) {
403
- this.checkCompactMovement("x", 1);
404
- this.checkCompactMovement("y", 1);
405
- } else if (this.gridster.$options.compactType === CompactType.CompactGrid) {
406
- this.checkCompactGrid();
407
- }
408
- }
409
- }
410
- checkCompactItem(item) {
411
- if (this.gridster.$options.compactType !== CompactType.None) {
412
- if (this.gridster.$options.compactType === CompactType.CompactUp) {
413
- this.moveTillCollision(item, "y", -1);
414
- } else if (this.gridster.$options.compactType === CompactType.CompactLeft) {
415
- this.moveTillCollision(item, "x", -1);
416
- } else if (this.gridster.$options.compactType === CompactType.CompactUpAndLeft) {
417
- this.moveTillCollision(item, "y", -1);
418
- this.moveTillCollision(item, "x", -1);
419
- } else if (this.gridster.$options.compactType === CompactType.CompactLeftAndUp) {
420
- this.moveTillCollision(item, "x", -1);
421
- this.moveTillCollision(item, "y", -1);
422
- } else if (this.gridster.$options.compactType === CompactType.CompactUpAndRight) {
423
- this.moveTillCollision(item, "y", -1);
424
- this.moveTillCollision(item, "x", 1);
425
- } else if (this.gridster.$options.compactType === CompactType.CompactDown) {
426
- this.moveTillCollision(item, "y", 1);
427
- } else if (this.gridster.$options.compactType === CompactType.CompactDownAndLeft) {
428
- this.moveTillCollision(item, "y", 1);
429
- this.moveTillCollision(item, "x", -1);
430
- } else if (this.gridster.$options.compactType === CompactType.CompactLeftAndDown) {
431
- this.moveTillCollision(item, "x", -1);
432
- this.moveTillCollision(item, "y", 1);
433
- } else if (this.gridster.$options.compactType === CompactType.CompactDownAndRight) {
434
- this.moveTillCollision(item, "y", 1);
435
- this.moveTillCollision(item, "x", 1);
436
- } else if (this.gridster.$options.compactType === CompactType.CompactRightAndDown) {
437
- this.moveTillCollision(item, "x", 1);
438
- this.moveTillCollision(item, "y", 1);
439
- } else if (this.gridster.$options.compactType === CompactType.CompactGrid) {
440
- this.moveToGridPosition(item);
441
- }
442
- }
443
- }
444
- checkCompactMovement(direction, delta) {
445
- let widgetMoved = false;
446
- this.gridster.grid.forEach((widget) => {
447
- if (widget.$item.compactEnabled !== false) {
448
- const moved = this.moveTillCollision(widget.$item, direction, delta);
449
- if (moved) {
450
- widgetMoved = true;
451
- widget.item[direction] = widget.$item[direction];
452
- widget.itemChanged();
453
- }
454
- }
455
- });
456
- if (widgetMoved) {
457
- this.checkCompact();
458
- }
459
- }
460
- moveTillCollision(item, direction, delta) {
461
- item[direction] += delta;
462
- if (this.gridster.checkCollision(item)) {
463
- item[direction] -= delta;
464
- return false;
465
- } else {
466
- this.moveTillCollision(item, direction, delta);
467
- return true;
468
- }
469
- }
470
- checkCompactGrid() {
471
- const sortedItems = this.gridster.grid.filter((widget) => widget.$item.compactEnabled !== false).sort((a, b) => {
472
- if (a.$item.y !== b.$item.y) {
473
- return a.$item.y - b.$item.y;
474
- }
475
- return a.$item.x - b.$item.x;
476
- });
477
- let currentY = 0;
478
- let currentX = 0;
479
- let maxYInRow = 0;
480
- sortedItems.forEach((widget) => {
481
- const item = widget.$item;
482
- if (currentX + item.cols > this.gridster.columns) {
483
- currentY = maxYInRow;
484
- currentX = 0;
485
- maxYInRow = currentY;
486
- }
487
- const oldX = item.x;
488
- const oldY = item.y;
489
- item.x = currentX;
490
- item.y = currentY;
491
- if (oldX !== item.x || oldY !== item.y) {
492
- widget.item.x = item.x;
493
- widget.item.y = item.y;
494
- widget.itemChanged();
495
- }
496
- currentX += item.cols;
497
- maxYInRow = Math.max(maxYInRow, currentY + item.rows);
498
- });
499
- }
500
- moveToGridPosition(item) {
501
- let currentY = 0;
502
- let currentX = 0;
503
- let maxYInRow = 0;
504
- const sortedItems = this.gridster.grid.filter((widget) => widget.$item !== item).sort((a, b) => {
505
- if (a.$item.y !== b.$item.y) {
506
- return a.$item.y - b.$item.y;
507
- }
508
- return a.$item.x - b.$item.x;
509
- });
510
- for (const widget of sortedItems) {
511
- const existingItem = widget.$item;
512
- if (currentX + existingItem.cols > this.gridster.columns) {
513
- currentY = maxYInRow;
514
- currentX = 0;
515
- maxYInRow = currentY;
516
- }
517
- if (currentY < existingItem.y + existingItem.rows && currentY + item.rows > existingItem.y && currentX < existingItem.x + existingItem.cols && currentX + item.cols > existingItem.x) {
518
- currentX = existingItem.x + existingItem.cols;
519
- currentY = existingItem.y;
520
- maxYInRow = Math.max(maxYInRow, currentY + existingItem.rows);
521
- } else {
522
- currentX += existingItem.cols;
523
- maxYInRow = Math.max(maxYInRow, currentY + existingItem.rows);
524
- }
525
- }
526
- if (currentX + item.cols > this.gridster.columns) {
527
- currentY = maxYInRow;
528
- currentX = 0;
529
- }
530
- item.x = currentX;
531
- item.y = currentY;
532
- }
533
- };
534
- var GridsterConfigService = {
535
- gridType: GridType.Fit,
536
- // 'fit' will fit the items in the container without scroll;
537
- scale: 1,
538
- // scale param to zoom in/zoom out
539
- // 'scrollVertical' will fit on width and height of the items will be the same as the width
540
- // 'scrollHorizontal' will fit on height and width of the items will be the same as the height
541
- // 'fixed' will set the rows and columns dimensions based on fixedColWidth and fixedRowHeight options
542
- // 'verticalFixed' will set the rows to fixedRowHeight and columns width will fit the space available
543
- // 'horizontalFixed' will set the columns to fixedColWidth and rows height will fit the space available
544
- fixedColWidth: 250,
545
- // fixed col width for gridType: 'fixed'
546
- fixedRowHeight: 250,
547
- // fixed row height for gridType: 'fixed'
548
- keepFixedHeightInMobile: false,
549
- // keep the height from fixed gridType in mobile layout
550
- keepFixedWidthInMobile: false,
551
- // keep the width from fixed gridType in mobile layout
552
- setGridSize: false,
553
- // sets grid size depending on content
554
- compactType: CompactType.None,
555
- // compact items: 'none' | 'compactUp' | 'compactLeft' | 'compactUp&Left' | 'compactLeft&Up'
556
- mobileBreakpoint: 640,
557
- // if the screen is not wider that this, remove the grid layout and stack the items
558
- useBodyForBreakpoint: false,
559
- // whether to use the body width to determine the mobile breakpoint. Uses the element width when false.
560
- allowMultiLayer: false,
561
- defaultLayerIndex: 0,
562
- maxLayerIndex: 2,
563
- baseLayerIndex: 1,
564
- minCols: 1,
565
- // minimum amount of columns in the grid
566
- maxCols: 100,
567
- // maximum amount of columns in the grid
568
- minRows: 1,
569
- // minimum amount of rows in the grid
570
- maxRows: 100,
571
- // maximum amount of rows in the grid
572
- defaultItemCols: 1,
573
- // default width of an item in columns
574
- defaultItemRows: 1,
575
- // default height of an item in rows
576
- itemAspectRatio: void 0,
577
- // set a fixed aspect ratio for an item to have in cols/rows e.g. 1/1 or 4/3 or 16/9
578
- maxItemCols: 50,
579
- // max item number of cols
580
- maxItemRows: 50,
581
- // max item number of rows
582
- minItemCols: 1,
583
- // min item number of columns
584
- minItemRows: 1,
585
- // min item number of rows
586
- minItemArea: 1,
587
- // min item area: cols * rows
588
- maxItemArea: 2500,
589
- // max item area: cols * rows
590
- addEmptyRowsCount: 0,
591
- // add a number of extra empty rows at the end
592
- rowHeightRatio: 1,
593
- // row height ratio from column width
594
- margin: 10,
595
- // margin between grid items
596
- outerMargin: true,
597
- // if margins will apply to the sides of the container
598
- outerMarginTop: null,
599
- // override outer margin for grid
600
- outerMarginRight: null,
601
- // override outer margin for grid
602
- outerMarginBottom: null,
603
- // override outer margin for grid
604
- outerMarginLeft: null,
605
- // override outer margin for grid
606
- useTransformPositioning: true,
607
- // toggle between transform or top/left positioning of items
608
- scrollSensitivity: 10,
609
- // margin of the dashboard where to start scrolling
610
- scrollSpeed: 20,
611
- // how much to scroll each mouse move when in the scrollSensitivity zone
612
- initCallback: void 0,
613
- // callback to call after grid has initialized. Arguments: gridsterComponent
614
- destroyCallback: void 0,
615
- // callback to call after grid has destroyed. Arguments: gridsterComponent
616
- gridSizeChangedCallback: void 0,
617
- // callback to call after grid has changed size. Arguments: gridsterComponent
618
- itemChangeCallback: void 0,
619
- // callback to call for each item when is changes x, y, rows, cols.
620
- // Arguments: gridsterItem, gridsterItemComponent
621
- itemResizeCallback: void 0,
622
- // callback to call for each item when width/height changes.
623
- // Arguments: gridsterItem, gridsterItemComponent
624
- itemInitCallback: void 0,
625
- // callback to call for each item when is initialized.
626
- // Arguments: gridsterItem, gridsterItemComponent
627
- itemRemovedCallback: void 0,
628
- // callback to call for each item when is initialized.
629
- // Arguments: gridsterItem, gridsterItemComponent
630
- itemValidateCallback: void 0,
631
- // callback to call to validate item position/size. Return true if valid.
632
- // Arguments: gridsterItem
633
- enableEmptyCellClick: false,
634
- // enable empty cell click events
635
- enableEmptyCellContextMenu: false,
636
- // enable empty cell context menu (right click) events
637
- enableEmptyCellDrop: false,
638
- // enable empty cell drop events
639
- enableEmptyCellDrag: false,
640
- // enable empty cell drag events
641
- enableOccupiedCellDrop: false,
642
- // enable occupied cell drop events
643
- emptyCellClickCallback: void 0,
644
- // empty cell click callback
645
- emptyCellContextMenuCallback: void 0,
646
- // empty cell context menu (right click) callback
647
- emptyCellDropCallback: void 0,
648
- // empty cell drag drop callback. HTML5 Drag & Drop
649
- emptyCellDragCallback: void 0,
650
- // empty cell drag and create item like excel cell selection
651
- emptyCellDragMaxCols: 50,
652
- // limit empty cell drag max cols
653
- emptyCellDragMaxRows: 50,
654
- // limit empty cell drag max rows
655
- // Arguments: event, gridsterItem{x, y, rows: defaultItemRows, cols: defaultItemCols}
656
- ignoreMarginInRow: false,
657
- // ignore the gap between rows for items which span multiple rows (see #162, #224)
658
- draggable: {
659
- delayStart: 0,
660
- // milliseconds to delay the start of drag, useful for touch interaction
661
- enabled: false,
662
- // enable/disable draggable items
663
- ignoreContentClass: "gridster-item-content",
664
- // default content class to ignore the drag event from
665
- ignoreContent: false,
666
- // if true drag will start only from elements from `dragHandleClass`
667
- dragHandleClass: "drag-handler",
668
- // drag event only from this class. If `ignoreContent` is true.
669
- stop: void 0,
670
- // callback when dragging an item stops. Accepts Promise return to cancel/approve drag.
671
- start: void 0,
672
- // callback when dragging an item starts.
673
- // Arguments: item, gridsterItem, event
674
- dropOverItems: false,
675
- // enable drop items on top other item
676
- dropOverItemsCallback: void 0
677
- // callback on drop over another item
678
- // Arguments: source, target, gridComponent
679
- },
680
- resizable: {
681
- delayStart: 0,
682
- // milliseconds to delay the start of resize, useful for touch interaction
683
- enabled: false,
684
- // enable/disable resizable items
685
- handles: {
686
- s: true,
687
- e: true,
688
- n: true,
689
- w: true,
690
- se: true,
691
- ne: true,
692
- sw: true,
693
- nw: true
694
- },
695
- // resizable edges of an item
696
- stop: void 0,
697
- // callback when resizing an item stops. Accepts Promise return to cancel/approve resize.
698
- start: void 0
699
- // callback when resizing an item starts.
700
- // Arguments: item, gridsterItem, event
701
- },
702
- swap: true,
703
- // allow items to switch position if drop on top of another
704
- swapWhileDragging: false,
705
- // allow items to switch position while dragging
706
- pushItems: false,
707
- // push items when resizing and dragging
708
- disablePushOnDrag: false,
709
- // disable push on drag
710
- disablePushOnResize: false,
711
- // disable push on resize
712
- pushDirections: { north: true, east: true, south: true, west: true },
713
- // control the directions items are pushed
714
- pushResizeItems: false,
715
- // on resize of item will shrink adjacent items
716
- displayGrid: DisplayGrid.OnDragAndResize,
717
- // display background grid of rows and columns
718
- disableWindowResize: false,
719
- // disable the window on resize listener. This will stop grid to recalculate on window resize.
720
- disableWarnings: false,
721
- // disable console log warnings about misplacement of grid items
722
- scrollToNewItems: false,
723
- // scroll to new items placed in a scrollable view
724
- disableScrollHorizontal: false,
725
- // disable horizontal scrolling
726
- disableScrollVertical: false,
727
- // disable vertical scrolling
728
- enableBoundaryControl: false,
729
- // enable boundary control while dragging items
730
- disableAutoPositionOnConflict: false,
731
- // disable auto-position of items on conflict state,
732
- dirType: DirTypes.LTR
733
- // page direction, rtl=right to left ltr= left to right, if you use rtl language set dirType to rtl
734
- };
735
- var GridsterUtils = class _GridsterUtils {
736
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
737
- static merge(obj1, obj2, properties) {
738
- for (const p in obj2) {
739
- if (obj2[p] !== void 0 && properties.hasOwnProperty(p)) {
740
- if (typeof obj2[p] === "object") {
741
- if (!(p in obj1)) {
742
- obj1[p] = {};
743
- }
744
- obj1[p] = _GridsterUtils.merge(obj1[p], obj2[p], properties[p]);
745
- } else {
746
- obj1[p] = obj2[p];
747
- }
748
- }
749
- }
750
- return obj1;
751
- }
752
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
753
- static checkTouchEvent(e) {
754
- if (e.clientX === void 0 && e.touches) {
755
- if (e.touches && e.touches.length) {
756
- e.clientX = e.touches[0].clientX;
757
- e.clientY = e.touches[0].clientY;
758
- } else if (e.changedTouches && e.changedTouches.length) {
759
- e.clientX = e.changedTouches[0].clientX;
760
- e.clientY = e.changedTouches[0].clientY;
761
- }
762
- }
763
- }
764
- static checkContentClassForEvent(gridster, e) {
765
- if (gridster.$options.draggable.ignoreContent) {
766
- if (!_GridsterUtils.checkDragHandleClass(e.target, e.currentTarget, gridster.$options.draggable.dragHandleClass, gridster.$options.draggable.ignoreContentClass)) {
767
- return true;
768
- }
769
- } else {
770
- if (_GridsterUtils.checkContentClass(e.target, e.currentTarget, gridster.$options.draggable.ignoreContentClass)) {
771
- return true;
772
- }
773
- }
774
- return false;
775
- }
776
- static checkContentClassForEmptyCellClickEvent(gridster, e) {
777
- return _GridsterUtils.checkContentClass(e.target, e.currentTarget, gridster.$options.draggable.ignoreContentClass) || _GridsterUtils.checkContentClass(e.target, e.currentTarget, gridster.$options.draggable.dragHandleClass);
778
- }
779
- static checkDragHandleClass(target, current, dragHandleClass, ignoreContentClass) {
780
- if (!target || target === current) {
781
- return false;
782
- }
783
- if (target.hasAttribute("class")) {
784
- const classnames = target.getAttribute("class").split(" ");
785
- if (classnames.indexOf(dragHandleClass) > -1) {
786
- return true;
787
- }
788
- if (classnames.indexOf(ignoreContentClass) > -1) {
789
- return false;
790
- }
791
- }
792
- return _GridsterUtils.checkDragHandleClass(target.parentNode, current, dragHandleClass, ignoreContentClass);
793
- }
794
- static checkContentClass(target, current, contentClass) {
795
- if (!target || target === current) {
796
- return false;
797
- }
798
- if (target.hasAttribute("class") && target.getAttribute("class").split(" ").indexOf(contentClass) > -1) {
799
- return true;
800
- } else {
801
- return _GridsterUtils.checkContentClass(target.parentNode, current, contentClass);
802
- }
803
- }
804
- static compareItems(a, b) {
805
- if (a.y > b.y) {
806
- return -1;
807
- } else if (a.y < b.y) {
808
- return 1;
809
- } else if (a.x > b.x) {
810
- return -1;
811
- } else {
812
- return 1;
813
- }
814
- }
815
- };
816
- var GridsterEmptyCell = class {
817
- gridster;
818
- initialItem;
819
- removeEmptyCellClickListenerFn;
820
- removeEmptyCellTouchendListenerFn;
821
- removeEmptyCellContextMenuListenerFn;
822
- removeEmptyCellDropListenerFn;
823
- removeEmptyCellMousedownListenerFn;
824
- removeEmptyCellTouchstartListenerFn;
825
- removeWindowMousemoveListenerFn;
826
- removeWindowTouchmoveListenerFn;
827
- removeWindowMouseupListenerFn;
828
- removeWindowTouchendListenerFn;
829
- removeEmptyCellDragoverListenerFn;
830
- removeDocumentDragendListenerFn;
831
- constructor(gridster) {
832
- this.gridster = gridster;
833
- }
834
- destroy() {
835
- if (this.gridster.previewStyle) {
836
- this.gridster.previewStyle();
837
- }
838
- this.gridster.movingItem = null;
839
- this.initialItem = this.gridster = null;
840
- if (this.removeDocumentDragendListenerFn) {
841
- this.removeDocumentDragendListenerFn();
842
- this.removeDocumentDragendListenerFn = null;
843
- }
844
- }
845
- updateOptions() {
846
- if (this.gridster.$options.enableEmptyCellClick && !this.removeEmptyCellClickListenerFn && this.gridster.options.emptyCellClickCallback) {
847
- this.removeEmptyCellClickListenerFn = this.gridster.renderer.listen(this.gridster.el, "click", this.emptyCellClickCb);
848
- this.removeEmptyCellTouchendListenerFn = this.gridster.renderer.listen(this.gridster.el, "touchend", this.emptyCellClickCb);
849
- } else if (!this.gridster.$options.enableEmptyCellClick && this.removeEmptyCellClickListenerFn && this.removeEmptyCellTouchendListenerFn) {
850
- this.removeEmptyCellClickListenerFn();
851
- this.removeEmptyCellTouchendListenerFn();
852
- this.removeEmptyCellClickListenerFn = null;
853
- this.removeEmptyCellTouchendListenerFn = null;
854
- }
855
- if (this.gridster.$options.enableEmptyCellContextMenu && !this.removeEmptyCellContextMenuListenerFn && this.gridster.options.emptyCellContextMenuCallback) {
856
- this.removeEmptyCellContextMenuListenerFn = this.gridster.renderer.listen(this.gridster.el, "contextmenu", this.emptyCellContextMenuCb);
857
- } else if (!this.gridster.$options.enableEmptyCellContextMenu && this.removeEmptyCellContextMenuListenerFn) {
858
- this.removeEmptyCellContextMenuListenerFn();
859
- this.removeEmptyCellContextMenuListenerFn = null;
860
- }
861
- if (this.gridster.$options.enableEmptyCellDrop && !this.removeEmptyCellDropListenerFn && this.gridster.options.emptyCellDropCallback) {
862
- this.removeEmptyCellDropListenerFn = this.gridster.renderer.listen(this.gridster.el, "drop", this.emptyCellDragDrop);
863
- this.gridster.zone.runOutsideAngular(() => {
864
- this.removeEmptyCellDragoverListenerFn = this.gridster.renderer.listen(this.gridster.el, "dragover", this.emptyCellDragOver);
865
- });
866
- this.removeDocumentDragendListenerFn = this.gridster.renderer.listen("document", "dragend", () => {
867
- this.gridster.movingItem = null;
868
- this.gridster.previewStyle();
869
- });
870
- } else if (!this.gridster.$options.enableEmptyCellDrop && this.removeEmptyCellDropListenerFn && this.removeEmptyCellDragoverListenerFn && this.removeDocumentDragendListenerFn) {
871
- this.removeEmptyCellDropListenerFn();
872
- this.removeEmptyCellDragoverListenerFn();
873
- this.removeDocumentDragendListenerFn();
874
- this.removeEmptyCellDragoverListenerFn = null;
875
- this.removeEmptyCellDropListenerFn = null;
876
- this.removeDocumentDragendListenerFn = null;
877
- }
878
- if (this.gridster.$options.enableEmptyCellDrag && !this.removeEmptyCellMousedownListenerFn && this.gridster.options.emptyCellDragCallback) {
879
- this.removeEmptyCellMousedownListenerFn = this.gridster.renderer.listen(this.gridster.el, "mousedown", this.emptyCellMouseDown);
880
- this.removeEmptyCellTouchstartListenerFn = this.gridster.renderer.listen(this.gridster.el, "touchstart", this.emptyCellMouseDown);
881
- } else if (!this.gridster.$options.enableEmptyCellDrag && this.removeEmptyCellMousedownListenerFn && this.removeEmptyCellTouchstartListenerFn) {
882
- this.removeEmptyCellMousedownListenerFn();
883
- this.removeEmptyCellTouchstartListenerFn();
884
- this.removeEmptyCellMousedownListenerFn = null;
885
- this.removeEmptyCellTouchstartListenerFn = null;
886
- }
887
- }
888
- emptyCellClickCb = (e) => {
889
- if (!this.gridster || this.gridster.movingItem || GridsterUtils.checkContentClassForEmptyCellClickEvent(this.gridster, e)) {
890
- return;
891
- }
892
- const item = this.getValidItemFromEvent(e);
893
- if (!item) {
894
- return;
895
- }
896
- if (this.gridster.options.emptyCellClickCallback) {
897
- this.gridster.options.emptyCellClickCallback(e, item);
898
- }
899
- this.gridster.cdRef.markForCheck();
900
- };
901
- emptyCellContextMenuCb = (e) => {
902
- if (this.gridster.movingItem || GridsterUtils.checkContentClassForEmptyCellClickEvent(this.gridster, e)) {
903
- return;
904
- }
905
- e.preventDefault();
906
- e.stopPropagation();
907
- const item = this.getValidItemFromEvent(e);
908
- if (!item) {
909
- return;
910
- }
911
- if (this.gridster.options.emptyCellContextMenuCallback) {
912
- this.gridster.options.emptyCellContextMenuCallback(e, item);
913
- }
914
- this.gridster.cdRef.markForCheck();
915
- };
916
- emptyCellDragDrop = (e) => {
917
- const item = this.getValidItemFromEvent(e);
918
- if (!item) {
919
- return;
920
- }
921
- if (this.gridster.options.emptyCellDropCallback) {
922
- this.gridster.options.emptyCellDropCallback(e, item);
923
- }
924
- this.gridster.cdRef.markForCheck();
925
- };
926
- emptyCellDragOver = (e) => {
927
- e.preventDefault();
928
- e.stopPropagation();
929
- const item = this.getValidItemFromEvent(e);
930
- if (item) {
931
- if (e.dataTransfer) {
932
- e.dataTransfer.dropEffect = "move";
933
- }
934
- this.gridster.movingItem = item;
935
- } else {
936
- if (e.dataTransfer) {
937
- e.dataTransfer.dropEffect = "none";
938
- }
939
- this.gridster.movingItem = null;
940
- }
941
- this.gridster.previewStyle();
942
- };
943
- emptyCellMouseDown = (e) => {
944
- if (GridsterUtils.checkContentClassForEmptyCellClickEvent(this.gridster, e)) {
945
- return;
946
- }
947
- e.preventDefault();
948
- e.stopPropagation();
949
- const item = this.getValidItemFromEvent(e);
950
- const leftMouseButtonCode = 1;
951
- if (!item || e.buttons !== leftMouseButtonCode && !(e instanceof TouchEvent)) {
952
- return;
953
- }
954
- this.initialItem = item;
955
- this.gridster.movingItem = item;
956
- this.gridster.previewStyle();
957
- this.gridster.zone.runOutsideAngular(() => {
958
- this.removeWindowMousemoveListenerFn = this.gridster.renderer.listen("window", "mousemove", this.emptyCellMouseMove);
959
- this.removeWindowTouchmoveListenerFn = this.gridster.renderer.listen("window", "touchmove", this.emptyCellMouseMove);
960
- });
961
- this.removeWindowMouseupListenerFn = this.gridster.renderer.listen("window", "mouseup", this.emptyCellMouseUp);
962
- this.removeWindowTouchendListenerFn = this.gridster.renderer.listen("window", "touchend", this.emptyCellMouseUp);
963
- };
964
- emptyCellMouseMove = (e) => {
965
- e.preventDefault();
966
- e.stopPropagation();
967
- const item = this.getValidItemFromEvent(e, this.initialItem);
968
- if (!item) {
969
- return;
970
- }
971
- this.gridster.movingItem = item;
972
- this.gridster.previewStyle();
973
- };
974
- emptyCellMouseUp = (e) => {
975
- this.removeWindowMousemoveListenerFn();
976
- this.removeWindowTouchmoveListenerFn();
977
- this.removeWindowMouseupListenerFn();
978
- this.removeWindowTouchendListenerFn();
979
- const item = this.getValidItemFromEvent(e, this.initialItem);
980
- if (item) {
981
- this.gridster.movingItem = item;
982
- }
983
- if (this.gridster.options.emptyCellDragCallback && this.gridster.movingItem) {
984
- this.gridster.options.emptyCellDragCallback(e, this.gridster.movingItem);
985
- }
986
- setTimeout(() => {
987
- this.initialItem = null;
988
- if (this.gridster) {
989
- this.gridster.movingItem = null;
990
- this.gridster.previewStyle();
991
- }
992
- });
993
- this.gridster.cdRef.markForCheck();
994
- };
995
- getPixelsX(e, rect) {
996
- const scale = this.gridster.options.scale;
997
- if (scale) {
998
- return (e.clientX - rect.left) / scale + this.gridster.el.scrollLeft - this.gridster.gridRenderer.getLeftMargin();
999
- }
1000
- return e.clientX + this.gridster.el.scrollLeft - rect.left - this.gridster.gridRenderer.getLeftMargin();
1001
- }
1002
- getPixelsY(e, rect) {
1003
- const scale = this.gridster.options.scale;
1004
- if (scale) {
1005
- return (e.clientY - rect.top) / scale + this.gridster.el.scrollTop - this.gridster.gridRenderer.getTopMargin();
1006
- }
1007
- return e.clientY + this.gridster.el.scrollTop - rect.top - this.gridster.gridRenderer.getTopMargin();
1008
- }
1009
- getValidItemFromEvent(e, oldItem) {
1010
- e.preventDefault();
1011
- e.stopPropagation();
1012
- GridsterUtils.checkTouchEvent(e);
1013
- const rect = this.gridster.el.getBoundingClientRect();
1014
- const x = this.getPixelsX(e, rect);
1015
- const y = this.getPixelsY(e, rect);
1016
- const item = {
1017
- x: this.gridster.pixelsToPositionX(x, Math.floor, true),
1018
- y: this.gridster.pixelsToPositionY(y, Math.floor, true),
1019
- cols: this.gridster.$options.defaultItemCols,
1020
- rows: this.gridster.$options.defaultItemRows
1021
- };
1022
- if (oldItem) {
1023
- item.cols = Math.min(Math.abs(oldItem.x - item.x) + 1, this.gridster.$options.emptyCellDragMaxCols);
1024
- item.rows = Math.min(Math.abs(oldItem.y - item.y) + 1, this.gridster.$options.emptyCellDragMaxRows);
1025
- if (oldItem.x < item.x) {
1026
- item.x = oldItem.x;
1027
- } else if (oldItem.x - item.x > this.gridster.$options.emptyCellDragMaxCols - 1) {
1028
- item.x = this.gridster.movingItem ? this.gridster.movingItem.x : 0;
1029
- }
1030
- if (oldItem.y < item.y) {
1031
- item.y = oldItem.y;
1032
- } else if (oldItem.y - item.y > this.gridster.$options.emptyCellDragMaxRows - 1) {
1033
- item.y = this.gridster.movingItem ? this.gridster.movingItem.y : 0;
1034
- }
1035
- }
1036
- if (!this.gridster.$options.enableOccupiedCellDrop && this.gridster.checkCollision(item)) {
1037
- return;
1038
- }
1039
- return item;
1040
- }
1041
- };
1042
- var GridsterRenderer = class {
1043
- gridster;
1044
- /**
1045
- * Caches the last grid column styles.
1046
- * This improves the grid responsiveness by caching and reusing the last style object instead of creating a new one.
1047
- */
1048
- lastGridColumnStyles = {};
1049
- /**
1050
- * Caches the last grid column styles.
1051
- * This improves the grid responsiveness by caching and reusing the last style object instead of creating a new one.
1052
- */
1053
- lastGridRowStyles = {};
1054
- constructor(gridster) {
1055
- this.gridster = gridster;
1056
- }
1057
- destroy() {
1058
- this.gridster = null;
1059
- }
1060
- updateItem(el, item, renderer) {
1061
- if (this.gridster.mobile) {
1062
- this.clearCellPosition(renderer, el);
1063
- if (this.gridster.$options.keepFixedHeightInMobile) {
1064
- renderer.setStyle(el, "height", (item.rows - 1) * this.gridster.$options.margin + item.rows * this.gridster.$options.fixedRowHeight + "px");
1065
- } else {
1066
- renderer.setStyle(el, "height", item.rows * this.gridster.curWidth / item.cols + "px");
1067
- }
1068
- if (this.gridster.$options.keepFixedWidthInMobile) {
1069
- renderer.setStyle(el, "width", this.gridster.$options.fixedColWidth + "px");
1070
- } else {
1071
- renderer.setStyle(el, "width", "");
1072
- }
1073
- renderer.setStyle(el, "margin-bottom", this.gridster.$options.margin + "px");
1074
- renderer.setStyle(el, DirTypes.LTR ? "margin-right" : "margin-left", "");
1075
- } else {
1076
- const x = Math.round(this.gridster.curColWidth * item.x);
1077
- const y = Math.round(this.gridster.curRowHeight * item.y);
1078
- const width = this.gridster.curColWidth * item.cols - this.gridster.$options.margin;
1079
- const height = this.gridster.curRowHeight * item.rows - this.gridster.$options.margin;
1080
- this.setCellPosition(renderer, el, x, y);
1081
- renderer.setStyle(el, "width", width + "px");
1082
- renderer.setStyle(el, "height", height + "px");
1083
- let marginBottom = null;
1084
- let marginRight = null;
1085
- if (this.gridster.$options.outerMargin) {
1086
- if (this.gridster.rows === item.rows + item.y) {
1087
- if (this.gridster.$options.outerMarginBottom !== null) {
1088
- marginBottom = this.gridster.$options.outerMarginBottom + "px";
1089
- } else {
1090
- marginBottom = this.gridster.$options.margin + "px";
1091
- }
1092
- }
1093
- if (this.gridster.columns === item.cols + item.x) {
1094
- if (this.gridster.$options.outerMarginBottom !== null) {
1095
- marginRight = this.gridster.$options.outerMarginRight + "px";
1096
- } else {
1097
- marginRight = this.gridster.$options.margin + "px";
1098
- }
1099
- }
1100
- }
1101
- renderer.setStyle(el, "margin-bottom", marginBottom);
1102
- renderer.setStyle(el, this.gridster.$options.dirType === DirTypes.LTR ? "margin-right" : "margin-left", marginRight);
1103
- }
1104
- }
1105
- updateGridster() {
1106
- let addClass = "";
1107
- let removeClass1 = "";
1108
- let removeClass2 = "";
1109
- let removeClass3 = "";
1110
- if (this.gridster.$options.gridType === GridType.Fit) {
1111
- addClass = GridType.Fit;
1112
- removeClass1 = GridType.ScrollVertical;
1113
- removeClass2 = GridType.ScrollHorizontal;
1114
- removeClass3 = GridType.Fixed;
1115
- } else if (this.gridster.$options.gridType === GridType.ScrollVertical) {
1116
- this.gridster.curRowHeight = this.gridster.curColWidth * this.gridster.$options.rowHeightRatio;
1117
- addClass = GridType.ScrollVertical;
1118
- removeClass1 = GridType.Fit;
1119
- removeClass2 = GridType.ScrollHorizontal;
1120
- removeClass3 = GridType.Fixed;
1121
- } else if (this.gridster.$options.gridType === GridType.ScrollHorizontal) {
1122
- const widthRatio = this.gridster.$options.rowHeightRatio;
1123
- const calWidthRatio = widthRatio >= 1 ? widthRatio : widthRatio + 1;
1124
- this.gridster.curColWidth = this.gridster.curRowHeight * calWidthRatio;
1125
- addClass = GridType.ScrollHorizontal;
1126
- removeClass1 = GridType.Fit;
1127
- removeClass2 = GridType.ScrollVertical;
1128
- removeClass3 = GridType.Fixed;
1129
- } else if (this.gridster.$options.gridType === GridType.Fixed) {
1130
- this.gridster.curColWidth = this.gridster.$options.fixedColWidth + (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin);
1131
- this.gridster.curRowHeight = this.gridster.$options.fixedRowHeight + (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin);
1132
- addClass = GridType.Fixed;
1133
- removeClass1 = GridType.Fit;
1134
- removeClass2 = GridType.ScrollVertical;
1135
- removeClass3 = GridType.ScrollHorizontal;
1136
- } else if (this.gridster.$options.gridType === GridType.VerticalFixed) {
1137
- this.gridster.curRowHeight = this.gridster.$options.fixedRowHeight + (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin);
1138
- addClass = GridType.ScrollVertical;
1139
- removeClass1 = GridType.Fit;
1140
- removeClass2 = GridType.ScrollHorizontal;
1141
- removeClass3 = GridType.Fixed;
1142
- } else if (this.gridster.$options.gridType === GridType.HorizontalFixed) {
1143
- this.gridster.curColWidth = this.gridster.$options.fixedColWidth + (this.gridster.$options.ignoreMarginInRow ? 0 : this.gridster.$options.margin);
1144
- addClass = GridType.ScrollHorizontal;
1145
- removeClass1 = GridType.Fit;
1146
- removeClass2 = GridType.ScrollVertical;
1147
- removeClass3 = GridType.Fixed;
1148
- }
1149
- if (this.gridster.mobile || this.gridster.$options.setGridSize && this.gridster.$options.gridType !== GridType.Fit) {
1150
- this.gridster.renderer.removeClass(this.gridster.el, addClass);
1151
- } else {
1152
- this.gridster.renderer.addClass(this.gridster.el, addClass);
1153
- }
1154
- this.gridster.renderer.removeClass(this.gridster.el, removeClass1);
1155
- this.gridster.renderer.removeClass(this.gridster.el, removeClass2);
1156
- this.gridster.renderer.removeClass(this.gridster.el, removeClass3);
1157
- }
1158
- getGridColumnStyle(i) {
1159
- const newPos = {
1160
- left: this.gridster.curColWidth * i,
1161
- width: this.gridster.curColWidth - this.gridster.$options.margin,
1162
- height: this.gridster.gridRows.length * this.gridster.curRowHeight - this.gridster.$options.margin,
1163
- style: {}
1164
- };
1165
- newPos.style = __spreadProps(__spreadValues({}, this.getLeftPosition(newPos.left)), {
1166
- width: newPos.width + "px",
1167
- height: newPos.height + "px"
1168
- });
1169
- const last = this.lastGridColumnStyles[i];
1170
- if (last && last.left === newPos.left && last.width === newPos.width && last.height === newPos.height) {
1171
- return last.style;
1172
- }
1173
- this.lastGridColumnStyles[i] = newPos;
1174
- return newPos.style;
1175
- }
1176
- getGridRowStyle(i) {
1177
- const newPos = {
1178
- top: this.gridster.curRowHeight * i,
1179
- width: this.gridster.gridColumns.length * this.gridster.curColWidth + this.gridster.$options.margin,
1180
- height: this.gridster.curRowHeight - this.gridster.$options.margin,
1181
- style: {}
1182
- };
1183
- newPos.style = __spreadProps(__spreadValues({}, this.getTopPosition(newPos.top)), {
1184
- width: newPos.width + "px",
1185
- height: newPos.height + "px"
1186
- });
1187
- const last = this.lastGridRowStyles[i];
1188
- if (last && last.top === newPos.top && last.width === newPos.width && last.height === newPos.height) {
1189
- return last.style;
1190
- }
1191
- this.lastGridRowStyles[i] = newPos;
1192
- return newPos.style;
1193
- }
1194
- getLeftPosition(d) {
1195
- const dPosition = this.gridster.$options.dirType === DirTypes.RTL ? -d : d;
1196
- if (this.gridster.$options.useTransformPositioning) {
1197
- return {
1198
- transform: "translateX(" + dPosition + "px)"
1199
- };
1200
- } else {
1201
- return {
1202
- left: this.getLeftMargin() + dPosition + "px"
1203
- };
1204
- }
1205
- }
1206
- getTopPosition(d) {
1207
- if (this.gridster.$options.useTransformPositioning) {
1208
- return {
1209
- transform: "translateY(" + d + "px)"
1210
- };
1211
- } else {
1212
- return {
1213
- top: this.getTopMargin() + d + "px"
1214
- };
1215
- }
1216
- }
1217
- clearCellPosition(renderer, el) {
1218
- if (this.gridster.$options.useTransformPositioning) {
1219
- renderer.setStyle(el, "transform", "");
1220
- } else {
1221
- renderer.setStyle(el, "top", "");
1222
- renderer.setStyle(el, "left", "");
1223
- }
1224
- }
1225
- setCellPosition(renderer, el, x, y) {
1226
- const xPosition = this.gridster.$options.dirType === DirTypes.RTL ? -x : x;
1227
- if (this.gridster.$options.useTransformPositioning) {
1228
- const transform = "translate3d(" + xPosition + "px, " + y + "px, 0)";
1229
- renderer.setStyle(el, "transform", transform);
1230
- } else {
1231
- renderer.setStyle(el, "left", this.getLeftMargin() + xPosition + "px");
1232
- renderer.setStyle(el, "top", this.getTopMargin() + y + "px");
1233
- }
1234
- }
1235
- getLeftMargin() {
1236
- if (this.gridster.$options.outerMargin) {
1237
- if (this.gridster.$options.outerMarginLeft !== null) {
1238
- return this.gridster.$options.outerMarginLeft;
1239
- } else {
1240
- return this.gridster.$options.margin;
1241
- }
1242
- } else {
1243
- return 0;
1244
- }
1245
- }
1246
- getTopMargin() {
1247
- if (this.gridster.$options.outerMargin) {
1248
- if (this.gridster.$options.outerMarginTop !== null) {
1249
- return this.gridster.$options.outerMarginTop;
1250
- } else {
1251
- return this.gridster.$options.margin;
1252
- }
1253
- } else {
1254
- return 0;
1255
- }
1256
- }
1257
- };
1258
- var GridsterPreviewComponent = class _GridsterPreviewComponent {
1259
- renderer;
1260
- gridRenderer;
1261
- el;
1262
- constructor(el, renderer) {
1263
- this.renderer = renderer;
1264
- this.el = el.nativeElement;
1265
- }
1266
- previewStyle(item) {
1267
- if (item) {
1268
- this.renderer.setStyle(this.el, "display", "block");
1269
- this.gridRenderer.updateItem(this.el, item, this.renderer);
1270
- } else {
1271
- this.renderer.setStyle(this.el, "display", "");
1272
- }
1273
- }
1274
- static \u0275fac = \u0275\u0275ngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: core_exports, type: _GridsterPreviewComponent, deps: [{ token: ElementRef }, { token: Renderer2 }], target: FactoryTarget.Component });
1275
- static \u0275cmp = \u0275\u0275ngDeclareComponent({ minVersion: "14.0.0", version: "20.3.13", type: _GridsterPreviewComponent, isStandalone: true, selector: "gridster-preview", inputs: { gridRenderer: "gridRenderer" }, ngImport: core_exports, template: "", isInline: true, styles: ["gridster-preview{position:absolute;display:none;background:#00000026}\n"], encapsulation: ViewEncapsulation.None });
1276
- };
1277
- \u0275\u0275ngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: core_exports, type: GridsterPreviewComponent, decorators: [{
1278
- type: Component,
1279
- args: [{ selector: "gridster-preview", template: "", encapsulation: ViewEncapsulation.None, styles: ["gridster-preview{position:absolute;display:none;background:#00000026}\n"] }]
1280
- }], ctorParameters: () => [{ type: ElementRef }, { type: Renderer2 }], propDecorators: { gridRenderer: [{
1281
- type: Input
1282
- }] } });
1283
- var GridsterComponent = class _GridsterComponent {
1284
- renderer;
1285
- cdRef;
1286
- zone;
1287
- gridsterPreview = viewChild.required(GridsterPreviewComponent);
1288
- options;
1289
- movingItem;
1290
- el;
1291
- $options;
1292
- mobile;
1293
- curWidth;
1294
- curHeight;
1295
- grid;
1296
- columns = 0;
1297
- rows = 0;
1298
- curColWidth;
1299
- curRowHeight;
1300
- gridColumns = [];
1301
- gridRows = [];
1302
- windowResize;
1303
- dragInProgress;
1304
- emptyCell;
1305
- compact;
1306
- gridRenderer;
1307
- calculateLayout$ = new Subject();
1308
- resize$ = new Subject();
1309
- destroy$ = new Subject();
1310
- constructor(el, renderer, cdRef, zone) {
1311
- this.renderer = renderer;
1312
- this.cdRef = cdRef;
1313
- this.zone = zone;
1314
- this.el = el.nativeElement;
1315
- this.$options = JSON.parse(JSON.stringify(GridsterConfigService));
1316
- this.mobile = false;
1317
- this.curWidth = 0;
1318
- this.curHeight = 0;
1319
- this.grid = [];
1320
- this.curColWidth = 0;
1321
- this.curRowHeight = 0;
1322
- this.dragInProgress = false;
1323
- this.emptyCell = new GridsterEmptyCell(this);
1324
- this.compact = new GridsterCompact(this);
1325
- this.gridRenderer = new GridsterRenderer(this);
1326
- }
1327
- // ------ Function for swapWhileDragging option
1328
- // identical to checkCollision() except that here we add boundaries.
1329
- static checkCollisionTwoItemsForSwaping(item, item2) {
1330
- const horizontalBoundaryItem1 = item.cols === 1 ? 0 : 1;
1331
- const horizontalBoundaryItem2 = item2.cols === 1 ? 0 : 1;
1332
- const verticalBoundaryItem1 = item.rows === 1 ? 0 : 1;
1333
- const verticalBoundaryItem2 = item2.rows === 1 ? 0 : 1;
1334
- return item.x + horizontalBoundaryItem1 < item2.x + item2.cols && item.x + item.cols > item2.x + horizontalBoundaryItem2 && item.y + verticalBoundaryItem1 < item2.y + item2.rows && item.y + item.rows > item2.y + verticalBoundaryItem2;
1335
- }
1336
- checkCollisionTwoItems(item, item2) {
1337
- const collision = item.x < item2.x + item2.cols && item.x + item.cols > item2.x && item.y < item2.y + item2.rows && item.y + item.rows > item2.y;
1338
- if (!collision) {
1339
- return false;
1340
- }
1341
- if (!this.$options.allowMultiLayer) {
1342
- return true;
1343
- }
1344
- const defaultLayerIndex = this.$options.defaultLayerIndex;
1345
- const layerIndex = item.layerIndex === void 0 ? defaultLayerIndex : item.layerIndex;
1346
- const layerIndex2 = item2.layerIndex === void 0 ? defaultLayerIndex : item2.layerIndex;
1347
- return layerIndex === layerIndex2;
1348
- }
1349
- ngOnInit() {
1350
- if (this.options.initCallback) {
1351
- this.options.initCallback(this);
1352
- }
1353
- this.calculateLayout$.pipe(debounceTime(0), takeUntil(this.destroy$)).subscribe(() => this.calculateLayout());
1354
- this.resize$.pipe(
1355
- // Cancel previously scheduled DOM timer if `calculateLayout()` has been called
1356
- // within this time range.
1357
- switchMap(() => timer(100)),
1358
- takeUntil(this.destroy$)
1359
- ).subscribe(() => this.resize());
1360
- }
1361
- ngOnChanges(changes) {
1362
- if (changes.options) {
1363
- this.setOptions();
1364
- this.options.api = {
1365
- optionsChanged: this.optionsChanged,
1366
- resize: this.onResize,
1367
- getNextPossiblePosition: this.getNextPossiblePosition,
1368
- getFirstPossiblePosition: this.getFirstPossiblePosition,
1369
- getLastPossiblePosition: this.getLastPossiblePosition,
1370
- getItemComponent: (item) => this.getItemComponent(item)
1371
- };
1372
- this.columns = this.$options.minCols;
1373
- this.rows = this.$options.minRows + this.$options.addEmptyRowsCount;
1374
- this.setGridSize();
1375
- this.calculateLayout();
1376
- }
1377
- }
1378
- resize() {
1379
- let height;
1380
- let width;
1381
- if (this.$options.gridType === "fit" && !this.mobile) {
1382
- width = this.el.offsetWidth;
1383
- height = this.el.offsetHeight;
1384
- } else {
1385
- width = this.el.clientWidth;
1386
- height = this.el.clientHeight;
1387
- }
1388
- if ((width !== this.curWidth || height !== this.curHeight) && this.checkIfToResize()) {
1389
- this.onResize();
1390
- }
1391
- }
1392
- setOptions() {
1393
- this.$options = GridsterUtils.merge(this.$options, this.options, this.$options);
1394
- if (!this.$options.disableWindowResize && !this.windowResize) {
1395
- this.windowResize = this.renderer.listen("window", "resize", this.onResize);
1396
- } else if (this.$options.disableWindowResize && this.windowResize) {
1397
- this.windowResize();
1398
- this.windowResize = null;
1399
- }
1400
- this.emptyCell.updateOptions();
1401
- }
1402
- optionsChanged = () => {
1403
- this.setOptions();
1404
- let widgetsIndex = this.grid.length - 1;
1405
- let widget;
1406
- for (; widgetsIndex >= 0; widgetsIndex--) {
1407
- widget = this.grid[widgetsIndex];
1408
- widget.updateOptions();
1409
- }
1410
- this.calculateLayout();
1411
- };
1412
- ngOnDestroy() {
1413
- this.destroy$.next();
1414
- if (this.windowResize) {
1415
- this.windowResize();
1416
- }
1417
- if (this.options && this.options.destroyCallback) {
1418
- this.options.destroyCallback(this);
1419
- }
1420
- if (this.options && this.options.api) {
1421
- this.options.api.resize = void 0;
1422
- this.options.api.optionsChanged = void 0;
1423
- this.options.api.getNextPossiblePosition = void 0;
1424
- this.options.api = void 0;
1425
- }
1426
- this.emptyCell.destroy();
1427
- this.emptyCell = null;
1428
- this.compact.destroy();
1429
- this.compact = null;
1430
- }
1431
- onResize = () => {
1432
- if (this.el.clientWidth) {
1433
- if (this.options.setGridSize) {
1434
- this.renderer.setStyle(this.el, "width", "");
1435
- this.renderer.setStyle(this.el, "height", "");
1436
- }
1437
- this.setGridSize();
1438
- this.calculateLayout();
1439
- }
1440
- };
1441
- checkIfToResize() {
1442
- const clientWidth = this.el.clientWidth;
1443
- const offsetWidth = this.el.offsetWidth;
1444
- const scrollWidth = this.el.scrollWidth;
1445
- const clientHeight = this.el.clientHeight;
1446
- const offsetHeight = this.el.offsetHeight;
1447
- const scrollHeight = this.el.scrollHeight;
1448
- const verticalScrollPresent = clientWidth < offsetWidth && scrollHeight > offsetHeight && scrollHeight - offsetHeight < offsetWidth - clientWidth;
1449
- const horizontalScrollPresent = clientHeight < offsetHeight && scrollWidth > offsetWidth && scrollWidth - offsetWidth < offsetHeight - clientHeight;
1450
- if (verticalScrollPresent) {
1451
- return false;
1452
- }
1453
- return !horizontalScrollPresent;
1454
- }
1455
- checkIfMobile() {
1456
- if (this.$options.useBodyForBreakpoint) {
1457
- return this.$options.mobileBreakpoint > document.body.clientWidth;
1458
- } else {
1459
- return this.$options.mobileBreakpoint > this.curWidth;
1460
- }
1461
- }
1462
- setGridSize() {
1463
- const el = this.el;
1464
- let width;
1465
- let height;
1466
- if (this.$options.setGridSize || this.$options.gridType === GridType.Fit && !this.mobile) {
1467
- width = el.offsetWidth;
1468
- height = el.offsetHeight;
1469
- } else {
1470
- width = el.clientWidth;
1471
- height = el.clientHeight;
1472
- }
1473
- this.curWidth = width;
1474
- this.curHeight = height;
1475
- }
1476
- setGridDimensions() {
1477
- this.setGridSize();
1478
- if (!this.mobile && this.checkIfMobile()) {
1479
- this.mobile = !this.mobile;
1480
- this.renderer.addClass(this.el, "mobile");
1481
- } else if (this.mobile && !this.checkIfMobile()) {
1482
- this.mobile = !this.mobile;
1483
- this.renderer.removeClass(this.el, "mobile");
1484
- }
1485
- let rows = this.$options.minRows;
1486
- let columns = this.$options.minCols;
1487
- let widgetsIndex = this.grid.length - 1;
1488
- let widget;
1489
- for (; widgetsIndex >= 0; widgetsIndex--) {
1490
- widget = this.grid[widgetsIndex];
1491
- if (!widget.notPlaced) {
1492
- rows = Math.max(rows, widget.$item.y + widget.$item.rows);
1493
- columns = Math.max(columns, widget.$item.x + widget.$item.cols);
1494
- }
1495
- }
1496
- rows += this.$options.addEmptyRowsCount;
1497
- if (this.columns !== columns || this.rows !== rows) {
1498
- this.columns = columns;
1499
- this.rows = rows;
1500
- if (this.options.gridSizeChangedCallback) {
1501
- this.options.gridSizeChangedCallback(this);
1502
- }
1503
- }
1504
- }
1505
- calculateLayout() {
1506
- if (this.compact) {
1507
- this.compact.checkCompact();
1508
- }
1509
- this.setGridDimensions();
1510
- if (this.$options.outerMargin) {
1511
- let marginWidth = -this.$options.margin;
1512
- if (this.$options.outerMarginLeft !== null) {
1513
- marginWidth += this.$options.outerMarginLeft;
1514
- this.renderer.setStyle(this.el, "padding-left", this.$options.outerMarginLeft + "px");
1515
- } else {
1516
- marginWidth += this.$options.margin;
1517
- this.renderer.setStyle(this.el, "padding-left", this.$options.margin + "px");
1518
- }
1519
- if (this.$options.outerMarginRight !== null) {
1520
- marginWidth += this.$options.outerMarginRight;
1521
- this.renderer.setStyle(this.el, "padding-right", this.$options.outerMarginRight + "px");
1522
- } else {
1523
- marginWidth += this.$options.margin;
1524
- this.renderer.setStyle(this.el, "padding-right", this.$options.margin + "px");
1525
- }
1526
- this.curColWidth = (this.curWidth - marginWidth) / this.columns;
1527
- let marginHeight = -this.$options.margin;
1528
- if (this.$options.outerMarginTop !== null) {
1529
- marginHeight += this.$options.outerMarginTop;
1530
- this.renderer.setStyle(this.el, "padding-top", this.$options.outerMarginTop + "px");
1531
- } else {
1532
- marginHeight += this.$options.margin;
1533
- this.renderer.setStyle(this.el, "padding-top", this.$options.margin + "px");
1534
- }
1535
- if (this.$options.outerMarginBottom !== null) {
1536
- marginHeight += this.$options.outerMarginBottom;
1537
- this.renderer.setStyle(this.el, "padding-bottom", this.$options.outerMarginBottom + "px");
1538
- } else {
1539
- marginHeight += this.$options.margin;
1540
- this.renderer.setStyle(this.el, "padding-bottom", this.$options.margin + "px");
1541
- }
1542
- this.curRowHeight = (this.curHeight - marginHeight) / this.rows * this.$options.rowHeightRatio;
1543
- } else {
1544
- this.curColWidth = (this.curWidth + this.$options.margin) / this.columns;
1545
- this.curRowHeight = (this.curHeight + this.$options.margin) / this.rows * this.$options.rowHeightRatio;
1546
- this.renderer.setStyle(this.el, "padding-left", "0px");
1547
- this.renderer.setStyle(this.el, "padding-right", "0px");
1548
- this.renderer.setStyle(this.el, "padding-top", "0px");
1549
- this.renderer.setStyle(this.el, "padding-bottom", "0px");
1550
- }
1551
- this.gridRenderer.updateGridster();
1552
- if (this.$options.setGridSize) {
1553
- this.renderer.addClass(this.el, "gridSize");
1554
- if (!this.mobile) {
1555
- this.renderer.setStyle(this.el, "width", this.columns * this.curColWidth + this.$options.margin + "px");
1556
- this.renderer.setStyle(this.el, "height", this.rows * this.curRowHeight + this.$options.margin + "px");
1557
- }
1558
- } else {
1559
- this.renderer.removeClass(this.el, "gridSize");
1560
- this.renderer.setStyle(this.el, "width", "");
1561
- this.renderer.setStyle(this.el, "height", "");
1562
- }
1563
- this.updateGrid();
1564
- let widgetsIndex = this.grid.length - 1;
1565
- let widget;
1566
- for (; widgetsIndex >= 0; widgetsIndex--) {
1567
- widget = this.grid[widgetsIndex];
1568
- widget.setSize();
1569
- widget.drag.toggle();
1570
- widget.resize.toggle();
1571
- }
1572
- this.resize$.next();
1573
- }
1574
- updateGrid() {
1575
- if (this.$options.displayGrid === "always" && !this.mobile) {
1576
- this.renderer.addClass(this.el, "display-grid");
1577
- } else if (this.$options.displayGrid === "onDrag&Resize" && this.dragInProgress) {
1578
- this.renderer.addClass(this.el, "display-grid");
1579
- } else if (this.$options.displayGrid === "none" || !this.dragInProgress || this.mobile) {
1580
- this.renderer.removeClass(this.el, "display-grid");
1581
- }
1582
- this.setGridDimensions();
1583
- this.gridColumns.length = _GridsterComponent.getNewArrayLength(this.columns, this.curWidth, this.curColWidth);
1584
- this.gridRows.length = _GridsterComponent.getNewArrayLength(this.rows, this.curHeight, this.curRowHeight);
1585
- this.cdRef.markForCheck();
1586
- }
1587
- addItem(itemComponent) {
1588
- if (itemComponent.$item.cols === void 0) {
1589
- itemComponent.$item.cols = this.$options.defaultItemCols;
1590
- itemComponent.item.cols = itemComponent.$item.cols;
1591
- itemComponent.itemChanged();
1592
- }
1593
- if (itemComponent.$item.rows === void 0) {
1594
- itemComponent.$item.rows = this.$options.defaultItemRows;
1595
- itemComponent.item.rows = itemComponent.$item.rows;
1596
- itemComponent.itemChanged();
1597
- }
1598
- if (itemComponent.$item.x === -1 || itemComponent.$item.y === -1) {
1599
- this.autoPositionItem(itemComponent);
1600
- } else if (this.checkCollision(itemComponent.$item)) {
1601
- if (!this.$options.disableWarnings) {
1602
- itemComponent.notPlaced = true;
1603
- console.warn("Can't be placed in the bounds of the dashboard, trying to auto position!/n" + JSON.stringify(itemComponent.item, ["cols", "rows", "x", "y"]));
1604
- }
1605
- if (!this.$options.disableAutoPositionOnConflict) {
1606
- this.autoPositionItem(itemComponent);
1607
- } else {
1608
- itemComponent.notPlaced = true;
1609
- }
1610
- }
1611
- this.grid.push(itemComponent);
1612
- this.calculateLayout$.next();
1613
- }
1614
- removeItem(itemComponent) {
1615
- this.grid.splice(this.grid.indexOf(itemComponent), 1);
1616
- this.calculateLayout$.next();
1617
- if (this.options.itemRemovedCallback) {
1618
- this.options.itemRemovedCallback(itemComponent.item, itemComponent);
1619
- }
1620
- if (this.movingItem && this.movingItem === itemComponent.$item) {
1621
- this.movingItem = null;
1622
- this.previewStyle();
1623
- }
1624
- }
1625
- checkCollision(item, checkRatio) {
1626
- let collision = false;
1627
- if (this.options.itemValidateCallback) {
1628
- collision = !this.options.itemValidateCallback(item);
1629
- }
1630
- if (!collision && this.checkGridCollision(item, checkRatio)) {
1631
- collision = true;
1632
- }
1633
- if (!collision) {
1634
- const c = this.findItemWithItem(item);
1635
- if (c) {
1636
- collision = c;
1637
- }
1638
- }
1639
- return collision;
1640
- }
1641
- checkGridCollision(item, checkRatio = false) {
1642
- const noNegativePosition = item.y > -1 && item.x > -1;
1643
- const maxGridCols = item.cols + item.x <= this.$options.maxCols;
1644
- const maxGridRows = item.rows + item.y <= this.$options.maxRows;
1645
- const maxItemCols = item.maxItemCols === void 0 ? this.$options.maxItemCols : item.maxItemCols;
1646
- const minItemCols = item.minItemCols === void 0 ? this.$options.minItemCols : item.minItemCols;
1647
- const maxItemRows = item.maxItemRows === void 0 ? this.$options.maxItemRows : item.maxItemRows;
1648
- const minItemRows = item.minItemRows === void 0 ? this.$options.minItemRows : item.minItemRows;
1649
- const inColsLimits = item.cols <= maxItemCols && item.cols >= minItemCols;
1650
- const inRowsLimits = item.rows <= maxItemRows && item.rows >= minItemRows;
1651
- let inRatio = true;
1652
- if (checkRatio) {
1653
- const itemAspectRatio = item.itemAspectRatio || this.$options.itemAspectRatio;
1654
- if (itemAspectRatio) {
1655
- inRatio = item.cols / item.rows === itemAspectRatio;
1656
- }
1657
- }
1658
- const minAreaLimit = item.minItemArea === void 0 ? this.$options.minItemArea : item.minItemArea;
1659
- const maxAreaLimit = item.maxItemArea === void 0 ? this.$options.maxItemArea : item.maxItemArea;
1660
- const area = item.cols * item.rows;
1661
- const inMinArea = minAreaLimit <= area;
1662
- const inMaxArea = maxAreaLimit >= area;
1663
- return !(noNegativePosition && maxGridCols && maxGridRows && inRatio && inColsLimits && inRowsLimits && inMinArea && inMaxArea);
1664
- }
1665
- findItemWithItem(item) {
1666
- let widgetsIndex = 0;
1667
- let widget;
1668
- for (; widgetsIndex < this.grid.length; widgetsIndex++) {
1669
- widget = this.grid[widgetsIndex];
1670
- if (widget.$item !== item && this.checkCollisionTwoItems(widget.$item, item)) {
1671
- return widget;
1672
- }
1673
- }
1674
- return false;
1675
- }
1676
- findItemsWithItem(item) {
1677
- const a = [];
1678
- let widgetsIndex = 0;
1679
- let widget;
1680
- for (; widgetsIndex < this.grid.length; widgetsIndex++) {
1681
- widget = this.grid[widgetsIndex];
1682
- if (widget.$item !== item && this.checkCollisionTwoItems(widget.$item, item)) {
1683
- a.push(widget);
1684
- }
1685
- }
1686
- return a;
1687
- }
1688
- autoPositionItem(itemComponent) {
1689
- if (this.getNextPossiblePosition(itemComponent.$item)) {
1690
- itemComponent.notPlaced = false;
1691
- itemComponent.item.x = itemComponent.$item.x;
1692
- itemComponent.item.y = itemComponent.$item.y;
1693
- itemComponent.itemChanged();
1694
- } else {
1695
- itemComponent.notPlaced = true;
1696
- if (!this.$options.disableWarnings) {
1697
- console.warn("Can't be placed in the bounds of the dashboard!/n" + JSON.stringify(itemComponent.item, ["cols", "rows", "x", "y"]));
1698
- }
1699
- }
1700
- }
1701
- getNextPossiblePosition = (newItem, startingFrom = {}) => {
1702
- if (newItem.cols === -1) {
1703
- newItem.cols = this.$options.defaultItemCols;
1704
- }
1705
- if (newItem.rows === -1) {
1706
- newItem.rows = this.$options.defaultItemRows;
1707
- }
1708
- this.setGridDimensions();
1709
- let rowsIndex = startingFrom.y || 0;
1710
- let colsIndex;
1711
- for (; rowsIndex < this.rows; rowsIndex++) {
1712
- newItem.y = rowsIndex;
1713
- colsIndex = startingFrom.x || 0;
1714
- for (; colsIndex < this.columns; colsIndex++) {
1715
- newItem.x = colsIndex;
1716
- if (!this.checkCollision(newItem)) {
1717
- return true;
1718
- }
1719
- }
1720
- }
1721
- const canAddToRows = this.$options.maxRows >= this.rows + newItem.rows;
1722
- const canAddToColumns = this.$options.maxCols >= this.columns + newItem.cols;
1723
- const addToRows = this.rows <= this.columns && canAddToRows;
1724
- if (!addToRows && canAddToColumns) {
1725
- newItem.x = this.columns;
1726
- newItem.y = 0;
1727
- return true;
1728
- } else if (canAddToRows) {
1729
- newItem.y = this.rows;
1730
- newItem.x = 0;
1731
- return true;
1732
- }
1733
- return false;
1734
- };
1735
- getFirstPossiblePosition = (item) => {
1736
- const tmpItem = Object.assign({}, item);
1737
- this.getNextPossiblePosition(tmpItem);
1738
- return tmpItem;
1739
- };
1740
- getLastPossiblePosition = (item) => {
1741
- let farthestItem = { y: 0, x: 0 };
1742
- farthestItem = this.grid.reduce((prev, curr) => {
1743
- const currCoords = {
1744
- y: curr.$item.y + curr.$item.rows - 1,
1745
- x: curr.$item.x + curr.$item.cols - 1
1746
- };
1747
- if (GridsterUtils.compareItems(prev, currCoords) === 1) {
1748
- return currCoords;
1749
- } else {
1750
- return prev;
1751
- }
1752
- }, farthestItem);
1753
- const tmpItem = Object.assign({}, item);
1754
- this.getNextPossiblePosition(tmpItem, farthestItem);
1755
- return tmpItem;
1756
- };
1757
- pixelsToPositionX(x, roundingMethod, noLimit) {
1758
- const position = roundingMethod(x / this.curColWidth);
1759
- if (noLimit) {
1760
- return position;
1761
- } else {
1762
- return Math.max(position, 0);
1763
- }
1764
- }
1765
- pixelsToPositionY(y, roundingMethod, noLimit) {
1766
- const position = roundingMethod(y / this.curRowHeight);
1767
- if (noLimit) {
1768
- return position;
1769
- } else {
1770
- return Math.max(position, 0);
1771
- }
1772
- }
1773
- positionXToPixels(x) {
1774
- return x * this.curColWidth;
1775
- }
1776
- positionYToPixels(y) {
1777
- return y * this.curRowHeight;
1778
- }
1779
- getItemComponent(item) {
1780
- return this.grid.find((c) => c.item === item);
1781
- }
1782
- // ------ Functions for swapWhileDragging option
1783
- // identical to checkCollision() except that this function calls findItemWithItemForSwaping() instead of findItemWithItem()
1784
- checkCollisionForSwaping(item) {
1785
- let collision = false;
1786
- if (this.options.itemValidateCallback) {
1787
- collision = !this.options.itemValidateCallback(item);
1788
- }
1789
- if (!collision && this.checkGridCollision(item)) {
1790
- collision = true;
1791
- }
1792
- if (!collision) {
1793
- const c = this.findItemWithItemForSwapping(item);
1794
- if (c) {
1795
- collision = c;
1796
- }
1797
- }
1798
- return collision;
1799
- }
1800
- // identical to findItemWithItem() except that this function calls checkCollisionTwoItemsForSwaping() instead of checkCollisionTwoItems()
1801
- findItemWithItemForSwapping(item) {
1802
- let widgetsIndex = this.grid.length - 1;
1803
- let widget;
1804
- for (; widgetsIndex > -1; widgetsIndex--) {
1805
- widget = this.grid[widgetsIndex];
1806
- if (widget.$item !== item && _GridsterComponent.checkCollisionTwoItemsForSwaping(widget.$item, item)) {
1807
- return widget;
1808
- }
1809
- }
1810
- return false;
1811
- }
1812
- previewStyle(drag = false) {
1813
- const preview = this.gridsterPreview();
1814
- if (this.movingItem) {
1815
- if (this.compact && drag) {
1816
- this.compact.checkCompactItem(this.movingItem);
1817
- }
1818
- preview.previewStyle(this.movingItem);
1819
- } else {
1820
- preview.previewStyle(null);
1821
- }
1822
- }
1823
- // ------ End of functions for swapWhileDragging option
1824
- // eslint-disable-next-line @typescript-eslint/member-ordering
1825
- static getNewArrayLength(length, overallSize, size) {
1826
- const newLength = Math.max(length, Math.floor(overallSize / size));
1827
- if (newLength < 0) {
1828
- return 0;
1829
- }
1830
- if (Number.isFinite(newLength)) {
1831
- return Math.floor(newLength);
1832
- }
1833
- return 0;
1834
- }
1835
- static \u0275fac = \u0275\u0275ngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: core_exports, type: _GridsterComponent, deps: [{ token: ElementRef }, { token: Renderer2 }, { token: ChangeDetectorRef }, { token: NgZone }], target: FactoryTarget.Component });
1836
- static \u0275cmp = \u0275\u0275ngDeclareComponent({ minVersion: "17.0.0", version: "20.3.13", type: _GridsterComponent, isStandalone: true, selector: "gridster", inputs: { options: "options" }, viewQueries: [{ propertyName: "gridsterPreview", first: true, predicate: GridsterPreviewComponent, descendants: true, isSignal: true }], usesOnChanges: true, ngImport: core_exports, template: '@for (column of gridColumns; track i; let i = $index) {\n<div\n class="gridster-column"\n [ngStyle]="gridRenderer.getGridColumnStyle(i)"\n></div>\n} @for (row of gridRows; track i; let i = $index) {\n<div class="gridster-row" [ngStyle]="gridRenderer.getGridRowStyle(i)"></div>\n}\n<ng-content></ng-content>\n<gridster-preview\n [gridRenderer]="gridRenderer"\n class="gridster-preview"\n></gridster-preview>\n', styles: ["gridster{position:relative;box-sizing:border-box;background:gray;width:100%;height:100%;-webkit-user-select:none;user-select:none;display:block}gridster.fit{overflow-x:hidden;overflow-y:hidden}gridster.scrollVertical{overflow-x:hidden;overflow-y:auto}gridster.scrollHorizontal{overflow-x:auto;overflow-y:hidden}gridster.fixed{overflow:auto}gridster.mobile{overflow-x:hidden;overflow-y:auto}gridster.mobile gridster-item{position:relative}gridster.gridSize{height:initial;width:initial}gridster.gridSize.fit{height:100%;width:100%}gridster .gridster-column,gridster .gridster-row{position:absolute;display:none;transition:.3s;box-sizing:border-box}gridster.display-grid .gridster-column,gridster.display-grid .gridster-row{display:block}gridster .gridster-column{border-left:1px solid white;border-right:1px solid white}gridster .gridster-row{border-top:1px solid white;border-bottom:1px solid white}\n"], dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: GridsterPreviewComponent, selector: "gridster-preview", inputs: ["gridRenderer"] }], encapsulation: ViewEncapsulation.None });
1837
- };
1838
- \u0275\u0275ngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: core_exports, type: GridsterComponent, decorators: [{
1839
- type: Component,
1840
- args: [{ selector: "gridster", encapsulation: ViewEncapsulation.None, imports: [NgStyle, GridsterPreviewComponent], template: '@for (column of gridColumns; track i; let i = $index) {\n<div\n class="gridster-column"\n [ngStyle]="gridRenderer.getGridColumnStyle(i)"\n></div>\n} @for (row of gridRows; track i; let i = $index) {\n<div class="gridster-row" [ngStyle]="gridRenderer.getGridRowStyle(i)"></div>\n}\n<ng-content></ng-content>\n<gridster-preview\n [gridRenderer]="gridRenderer"\n class="gridster-preview"\n></gridster-preview>\n', styles: ["gridster{position:relative;box-sizing:border-box;background:gray;width:100%;height:100%;-webkit-user-select:none;user-select:none;display:block}gridster.fit{overflow-x:hidden;overflow-y:hidden}gridster.scrollVertical{overflow-x:hidden;overflow-y:auto}gridster.scrollHorizontal{overflow-x:auto;overflow-y:hidden}gridster.fixed{overflow:auto}gridster.mobile{overflow-x:hidden;overflow-y:auto}gridster.mobile gridster-item{position:relative}gridster.gridSize{height:initial;width:initial}gridster.gridSize.fit{height:100%;width:100%}gridster .gridster-column,gridster .gridster-row{position:absolute;display:none;transition:.3s;box-sizing:border-box}gridster.display-grid .gridster-column,gridster.display-grid .gridster-row{display:block}gridster .gridster-column{border-left:1px solid white;border-right:1px solid white}gridster .gridster-row{border-top:1px solid white;border-bottom:1px solid white}\n"] }]
1841
- }], ctorParameters: () => [{ type: ElementRef, decorators: [{
1842
- type: Inject,
1843
- args: [ElementRef]
1844
- }] }, { type: Renderer2, decorators: [{
1845
- type: Inject,
1846
- args: [Renderer2]
1847
- }] }, { type: ChangeDetectorRef, decorators: [{
1848
- type: Inject,
1849
- args: [ChangeDetectorRef]
1850
- }] }, { type: NgZone, decorators: [{
1851
- type: Inject,
1852
- args: [NgZone]
1853
- }] }], propDecorators: { gridsterPreview: [{ type: ViewChild, args: [forwardRef(() => GridsterPreviewComponent), { isSignal: true }] }], options: [{
1854
- type: Input
1855
- }] } });
1856
- var GridsterPush = class {
1857
- fromSouth;
1858
- fromNorth;
1859
- fromEast;
1860
- fromWest;
1861
- pushedItems;
1862
- pushedItemsTemp;
1863
- pushedItemsTempPath;
1864
- pushedItemsPath;
1865
- gridsterItem;
1866
- gridster;
1867
- pushedItemsOrder;
1868
- tryPattern;
1869
- iteration = 0;
1870
- constructor(gridsterItem) {
1871
- this.pushedItems = [];
1872
- this.pushedItemsTemp = [];
1873
- this.pushedItemsTempPath = [];
1874
- this.pushedItemsPath = [];
1875
- this.gridsterItem = gridsterItem;
1876
- this.gridster = gridsterItem.gridster;
1877
- this.tryPattern = {
1878
- fromEast: [this.tryWest, this.trySouth, this.tryNorth, this.tryEast],
1879
- fromWest: [this.tryEast, this.trySouth, this.tryNorth, this.tryWest],
1880
- fromNorth: [this.trySouth, this.tryEast, this.tryWest, this.tryNorth],
1881
- fromSouth: [this.tryNorth, this.tryEast, this.tryWest, this.trySouth]
1882
- };
1883
- this.fromSouth = "fromSouth";
1884
- this.fromNorth = "fromNorth";
1885
- this.fromEast = "fromEast";
1886
- this.fromWest = "fromWest";
1887
- }
1888
- destroy() {
1889
- this.gridster = this.gridsterItem = null;
1890
- }
1891
- pushItems(direction, disable) {
1892
- if (this.gridster.$options.pushItems && !disable) {
1893
- this.pushedItemsOrder = [];
1894
- this.iteration = 0;
1895
- const pushed = this.push(this.gridsterItem, direction);
1896
- if (!pushed) {
1897
- this.restoreTempItems();
1898
- }
1899
- this.pushedItemsOrder = [];
1900
- this.pushedItemsTemp = [];
1901
- this.pushedItemsTempPath = [];
1902
- return pushed;
1903
- } else {
1904
- return false;
1905
- }
1906
- }
1907
- restoreTempItems() {
1908
- let i = this.pushedItemsTemp.length - 1;
1909
- for (; i > -1; i--) {
1910
- this.removeFromTempPushed(this.pushedItemsTemp[i]);
1911
- }
1912
- }
1913
- restoreItems() {
1914
- let i = 0;
1915
- const l = this.pushedItems.length;
1916
- let pushedItem;
1917
- for (; i < l; i++) {
1918
- pushedItem = this.pushedItems[i];
1919
- pushedItem.$item.x = pushedItem.item.x || 0;
1920
- pushedItem.$item.y = pushedItem.item.y || 0;
1921
- pushedItem.setSize();
1922
- }
1923
- this.pushedItems = [];
1924
- this.pushedItemsPath = [];
1925
- }
1926
- setPushedItems() {
1927
- let i = 0;
1928
- const l = this.pushedItems.length;
1929
- let pushedItem;
1930
- for (; i < l; i++) {
1931
- pushedItem = this.pushedItems[i];
1932
- pushedItem.checkItemChanges(pushedItem.$item, pushedItem.item);
1933
- }
1934
- this.pushedItems = [];
1935
- this.pushedItemsPath = [];
1936
- }
1937
- checkPushBack() {
1938
- let i = this.pushedItems.length - 1;
1939
- let change = false;
1940
- for (; i > -1; i--) {
1941
- if (this.checkPushedItem(this.pushedItems[i], i)) {
1942
- change = true;
1943
- }
1944
- }
1945
- if (change) {
1946
- this.checkPushBack();
1947
- }
1948
- }
1949
- push(gridsterItem, direction) {
1950
- if (this.iteration > 100) {
1951
- console.warn("max iteration reached");
1952
- return false;
1953
- }
1954
- if (this.gridster.checkGridCollision(gridsterItem.$item)) {
1955
- return false;
1956
- }
1957
- if (direction === "") {
1958
- return false;
1959
- }
1960
- const conflicts = this.gridster.findItemsWithItem(gridsterItem.$item);
1961
- const invert = direction === this.fromNorth || direction === this.fromWest;
1962
- conflicts.sort((a, b) => {
1963
- if (invert) {
1964
- return b.$item.y - a.$item.y || b.$item.x - a.$item.x;
1965
- } else {
1966
- return a.$item.y - b.$item.y || a.$item.x - b.$item.x;
1967
- }
1968
- });
1969
- let i = 0;
1970
- let itemCollision;
1971
- let makePush = true;
1972
- const pushedItems = [];
1973
- for (; i < conflicts.length; i++) {
1974
- itemCollision = conflicts[i];
1975
- if (itemCollision === this.gridsterItem) {
1976
- continue;
1977
- }
1978
- if (!itemCollision.canBeDragged()) {
1979
- makePush = false;
1980
- break;
1981
- }
1982
- const p = this.pushedItemsTemp.indexOf(itemCollision);
1983
- if (p > -1 && this.pushedItemsTempPath[p].length > 10) {
1984
- makePush = false;
1985
- break;
1986
- }
1987
- if (this.tryPattern[direction][0].call(this, itemCollision, gridsterItem)) {
1988
- this.pushedItemsOrder.push(itemCollision);
1989
- pushedItems.push(itemCollision);
1990
- } else if (this.tryPattern[direction][1].call(this, itemCollision, gridsterItem)) {
1991
- this.pushedItemsOrder.push(itemCollision);
1992
- pushedItems.push(itemCollision);
1993
- } else if (this.tryPattern[direction][2].call(this, itemCollision, gridsterItem)) {
1994
- this.pushedItemsOrder.push(itemCollision);
1995
- pushedItems.push(itemCollision);
1996
- } else if (this.tryPattern[direction][3].call(this, itemCollision, gridsterItem)) {
1997
- this.pushedItemsOrder.push(itemCollision);
1998
- pushedItems.push(itemCollision);
1999
- } else {
2000
- makePush = false;
2001
- break;
2002
- }
2003
- }
2004
- if (!makePush) {
2005
- i = this.pushedItemsOrder.lastIndexOf(pushedItems[0]);
2006
- if (i > -1) {
2007
- let j = this.pushedItemsOrder.length - 1;
2008
- for (; j >= i; j--) {
2009
- itemCollision = this.pushedItemsOrder[j];
2010
- this.pushedItemsOrder.pop();
2011
- this.removeFromTempPushed(itemCollision);
2012
- this.removeFromPushedItem(itemCollision);
2013
- }
2014
- }
2015
- }
2016
- this.iteration++;
2017
- return makePush;
2018
- }
2019
- trySouth(gridsterItemCollide, gridsterItem) {
2020
- if (!this.gridster.$options.pushDirections.south) {
2021
- return false;
2022
- }
2023
- this.addToTempPushed(gridsterItemCollide);
2024
- gridsterItemCollide.$item.y = gridsterItem.$item.y + gridsterItem.$item.rows;
2025
- if (this.push(gridsterItemCollide, this.fromNorth)) {
2026
- gridsterItemCollide.setSize();
2027
- this.addToPushed(gridsterItemCollide);
2028
- return true;
2029
- } else {
2030
- this.removeFromTempPushed(gridsterItemCollide);
2031
- }
2032
- return false;
2033
- }
2034
- tryNorth(gridsterItemCollide, gridsterItem) {
2035
- if (!this.gridster.$options.pushDirections.north) {
2036
- return false;
2037
- }
2038
- this.addToTempPushed(gridsterItemCollide);
2039
- gridsterItemCollide.$item.y = gridsterItem.$item.y - gridsterItemCollide.$item.rows;
2040
- if (this.push(gridsterItemCollide, this.fromSouth)) {
2041
- gridsterItemCollide.setSize();
2042
- this.addToPushed(gridsterItemCollide);
2043
- return true;
2044
- } else {
2045
- this.removeFromTempPushed(gridsterItemCollide);
2046
- }
2047
- return false;
2048
- }
2049
- tryEast(gridsterItemCollide, gridsterItem) {
2050
- if (!this.gridster.$options.pushDirections.east) {
2051
- return false;
2052
- }
2053
- this.addToTempPushed(gridsterItemCollide);
2054
- gridsterItemCollide.$item.x = gridsterItem.$item.x + gridsterItem.$item.cols;
2055
- if (this.push(gridsterItemCollide, this.fromWest)) {
2056
- gridsterItemCollide.setSize();
2057
- this.addToPushed(gridsterItemCollide);
2058
- return true;
2059
- } else {
2060
- this.removeFromTempPushed(gridsterItemCollide);
2061
- }
2062
- return false;
2063
- }
2064
- tryWest(gridsterItemCollide, gridsterItem) {
2065
- if (!this.gridster.$options.pushDirections.west) {
2066
- return false;
2067
- }
2068
- this.addToTempPushed(gridsterItemCollide);
2069
- gridsterItemCollide.$item.x = gridsterItem.$item.x - gridsterItemCollide.$item.cols;
2070
- if (this.push(gridsterItemCollide, this.fromEast)) {
2071
- gridsterItemCollide.setSize();
2072
- this.addToPushed(gridsterItemCollide);
2073
- return true;
2074
- } else {
2075
- this.removeFromTempPushed(gridsterItemCollide);
2076
- }
2077
- return false;
2078
- }
2079
- addToTempPushed(gridsterItem) {
2080
- let i = this.pushedItemsTemp.indexOf(gridsterItem);
2081
- if (i === -1) {
2082
- i = this.pushedItemsTemp.push(gridsterItem) - 1;
2083
- this.pushedItemsTempPath[i] = [];
2084
- }
2085
- this.pushedItemsTempPath[i].push({
2086
- x: gridsterItem.$item.x,
2087
- y: gridsterItem.$item.y
2088
- });
2089
- }
2090
- removeFromTempPushed(gridsterItem) {
2091
- const i = this.pushedItemsTemp.indexOf(gridsterItem);
2092
- const tempPosition = this.pushedItemsTempPath[i].pop();
2093
- if (!tempPosition) {
2094
- return;
2095
- }
2096
- gridsterItem.$item.x = tempPosition.x;
2097
- gridsterItem.$item.y = tempPosition.y;
2098
- gridsterItem.setSize();
2099
- if (!this.pushedItemsTempPath[i].length) {
2100
- this.pushedItemsTemp.splice(i, 1);
2101
- this.pushedItemsTempPath.splice(i, 1);
2102
- }
2103
- }
2104
- addToPushed(gridsterItem) {
2105
- if (this.pushedItems.indexOf(gridsterItem) < 0) {
2106
- this.pushedItems.push(gridsterItem);
2107
- this.pushedItemsPath.push([
2108
- { x: gridsterItem.item.x || 0, y: gridsterItem.item.y || 0 },
2109
- { x: gridsterItem.$item.x, y: gridsterItem.$item.y }
2110
- ]);
2111
- } else {
2112
- const i = this.pushedItems.indexOf(gridsterItem);
2113
- this.pushedItemsPath[i].push({
2114
- x: gridsterItem.$item.x,
2115
- y: gridsterItem.$item.y
2116
- });
2117
- }
2118
- }
2119
- removeFromPushed(i) {
2120
- if (i > -1) {
2121
- this.pushedItems.splice(i, 1);
2122
- this.pushedItemsPath.splice(i, 1);
2123
- }
2124
- }
2125
- removeFromPushedItem(gridsterItem) {
2126
- const i = this.pushedItems.indexOf(gridsterItem);
2127
- if (i > -1) {
2128
- this.pushedItemsPath[i].pop();
2129
- if (!this.pushedItemsPath.length) {
2130
- this.pushedItems.splice(i, 1);
2131
- this.pushedItemsPath.splice(i, 1);
2132
- }
2133
- }
2134
- }
2135
- checkPushedItem(pushedItem, i) {
2136
- const path = this.pushedItemsPath[i];
2137
- let j = path.length - 2;
2138
- let lastPosition;
2139
- let x;
2140
- let y;
2141
- let change = false;
2142
- for (; j > -1; j--) {
2143
- lastPosition = path[j];
2144
- x = pushedItem.$item.x;
2145
- y = pushedItem.$item.y;
2146
- pushedItem.$item.x = lastPosition.x;
2147
- pushedItem.$item.y = lastPosition.y;
2148
- if (!this.gridster.findItemWithItem(pushedItem.$item)) {
2149
- pushedItem.setSize();
2150
- path.splice(j + 1, path.length - j - 1);
2151
- change = true;
2152
- } else {
2153
- pushedItem.$item.x = x;
2154
- pushedItem.$item.y = y;
2155
- }
2156
- }
2157
- if (path.length < 2) {
2158
- this.removeFromPushed(i);
2159
- }
2160
- return change;
2161
- }
2162
- };
2163
- var scrollSensitivity;
2164
- var scrollSpeed;
2165
- var intervalDuration = 50;
2166
- var gridsterElement;
2167
- var resizeEvent;
2168
- var resizeEventType;
2169
- var intervalE;
2170
- var intervalW;
2171
- var intervalN;
2172
- var intervalS;
2173
- function scroll(gridster, left, top, width, height, event, lastMouse, calculateItemPosition, resize, resizeEventScrollType) {
2174
- scrollSensitivity = gridster.$options.scrollSensitivity;
2175
- scrollSpeed = gridster.$options.scrollSpeed;
2176
- gridsterElement = gridster.el;
2177
- resizeEvent = resize;
2178
- resizeEventType = resizeEventScrollType;
2179
- const offsetWidth = gridsterElement.offsetWidth;
2180
- const offsetHeight = gridsterElement.offsetHeight;
2181
- const offsetLeft = gridsterElement.scrollLeft;
2182
- const offsetTop = gridsterElement.scrollTop;
2183
- const elemTopOffset = top - offsetTop;
2184
- const elemBottomOffset = offsetHeight + offsetTop - top - height;
2185
- const { clientX, clientY } = event;
2186
- if (!gridster.$options.disableScrollVertical) {
2187
- if (lastMouse.clientY < clientY && elemBottomOffset < scrollSensitivity) {
2188
- cancelN();
2189
- if (resizeEvent && resizeEventType && !resizeEventType.south || intervalS) {
2190
- return;
2191
- }
2192
- intervalS = startVertical(1, calculateItemPosition, lastMouse);
2193
- } else if (lastMouse.clientY > clientY && offsetTop > 0 && elemTopOffset < scrollSensitivity) {
2194
- cancelS();
2195
- if (resizeEvent && resizeEventType && !resizeEventType.north || intervalN) {
2196
- return;
2197
- }
2198
- intervalN = startVertical(-1, calculateItemPosition, lastMouse);
2199
- } else if (lastMouse.clientY !== clientY) {
2200
- cancelVertical();
2201
- }
2202
- }
2203
- const elemRightOffset = offsetLeft + offsetWidth - left - width;
2204
- const elemLeftOffset = left - offsetLeft;
2205
- if (!gridster.$options.disableScrollHorizontal) {
2206
- const isRTL = gridster.$options.dirType === DirTypes.RTL;
2207
- const moveRight = lastMouse.clientX < clientX;
2208
- const moveLeft = lastMouse.clientX > clientX;
2209
- const shouldScrollRight = isRTL ? moveLeft : moveRight;
2210
- const shouldScrollLeft = isRTL ? moveRight : moveLeft;
2211
- if (shouldScrollRight && elemRightOffset <= scrollSensitivity) {
2212
- cancelW();
2213
- if (resizeEvent && resizeEventType && !resizeEventType.east || intervalE)
2214
- return;
2215
- intervalE = startHorizontal(1, calculateItemPosition, lastMouse, isRTL);
2216
- } else if (shouldScrollLeft && offsetLeft > 0 && elemLeftOffset < scrollSensitivity) {
2217
- cancelE();
2218
- if (resizeEvent && resizeEventType && !resizeEventType.west || intervalW)
2219
- return;
2220
- intervalW = startHorizontal(-1, calculateItemPosition, lastMouse, isRTL);
2221
- } else if (lastMouse.clientX !== clientX) {
2222
- cancelHorizontal();
2223
- }
2224
- }
2225
- }
2226
- function startVertical(sign, calculateItemPosition, lastMouse) {
2227
- let clientY = lastMouse.clientY;
2228
- return window.setInterval(() => {
2229
- if (!gridsterElement || sign === -1 && gridsterElement.scrollTop - scrollSpeed < 0) {
2230
- cancelVertical();
2231
- }
2232
- gridsterElement.scrollTop += sign * scrollSpeed;
2233
- clientY += sign * scrollSpeed;
2234
- calculateItemPosition({ clientX: lastMouse.clientX, clientY });
2235
- }, intervalDuration);
2236
- }
2237
- function startHorizontal(sign, calculateItemPosition, lastMouse, isRTL) {
2238
- let clientX = lastMouse.clientX;
2239
- return window.setInterval(() => {
2240
- if (!gridsterElement) {
2241
- cancelHorizontal();
2242
- return;
2243
- }
2244
- const scrollAmount = sign * scrollSpeed;
2245
- const left = isRTL ? -scrollAmount : scrollAmount;
2246
- gridsterElement.scrollBy({ left, behavior: "auto" });
2247
- clientX += left;
2248
- calculateItemPosition({ clientX, clientY: lastMouse.clientY });
2249
- }, intervalDuration);
2250
- }
2251
- function cancelScroll() {
2252
- cancelHorizontal();
2253
- cancelVertical();
2254
- gridsterElement = null;
2255
- }
2256
- function cancelHorizontal() {
2257
- cancelE();
2258
- cancelW();
2259
- }
2260
- function cancelVertical() {
2261
- cancelN();
2262
- cancelS();
2263
- }
2264
- function cancelE() {
2265
- if (intervalE) {
2266
- clearInterval(intervalE);
2267
- intervalE = 0;
2268
- }
2269
- }
2270
- function cancelW() {
2271
- if (intervalW) {
2272
- clearInterval(intervalW);
2273
- intervalW = 0;
2274
- }
2275
- }
2276
- function cancelS() {
2277
- if (intervalS) {
2278
- clearInterval(intervalS);
2279
- intervalS = 0;
2280
- }
2281
- }
2282
- function cancelN() {
2283
- if (intervalN) {
2284
- clearInterval(intervalN);
2285
- intervalN = 0;
2286
- }
2287
- }
2288
- var GridsterSwap = class {
2289
- swapedItem;
2290
- gridsterItem;
2291
- gridster;
2292
- constructor(gridsterItem) {
2293
- this.gridsterItem = gridsterItem;
2294
- this.gridster = gridsterItem.gridster;
2295
- }
2296
- destroy() {
2297
- this.gridster = this.gridsterItem = this.swapedItem = null;
2298
- }
2299
- swapItems() {
2300
- if (this.gridster.$options.swap) {
2301
- this.checkSwapBack();
2302
- this.checkSwap(this.gridsterItem);
2303
- }
2304
- }
2305
- checkSwapBack() {
2306
- if (this.swapedItem) {
2307
- const x = this.swapedItem.$item.x;
2308
- const y = this.swapedItem.$item.y;
2309
- this.swapedItem.$item.x = this.swapedItem.item.x || 0;
2310
- this.swapedItem.$item.y = this.swapedItem.item.y || 0;
2311
- if (this.gridster.checkCollision(this.swapedItem.$item)) {
2312
- this.swapedItem.$item.x = x;
2313
- this.swapedItem.$item.y = y;
2314
- } else {
2315
- this.swapedItem.setSize();
2316
- this.gridsterItem.$item.x = this.gridsterItem.item.x || 0;
2317
- this.gridsterItem.$item.y = this.gridsterItem.item.y || 0;
2318
- this.swapedItem = void 0;
2319
- }
2320
- }
2321
- }
2322
- restoreSwapItem() {
2323
- if (this.swapedItem) {
2324
- this.swapedItem.$item.x = this.swapedItem.item.x || 0;
2325
- this.swapedItem.$item.y = this.swapedItem.item.y || 0;
2326
- this.swapedItem.setSize();
2327
- this.swapedItem = void 0;
2328
- }
2329
- }
2330
- setSwapItem() {
2331
- if (this.swapedItem) {
2332
- this.swapedItem.checkItemChanges(this.swapedItem.$item, this.swapedItem.item);
2333
- this.swapedItem = void 0;
2334
- }
2335
- }
2336
- checkSwap(pushedBy) {
2337
- let gridsterItemCollision;
2338
- if (this.gridster.$options.swapWhileDragging) {
2339
- gridsterItemCollision = this.gridster.checkCollisionForSwaping(pushedBy.$item);
2340
- } else {
2341
- gridsterItemCollision = this.gridster.checkCollision(pushedBy.$item);
2342
- }
2343
- if (gridsterItemCollision && gridsterItemCollision !== true && gridsterItemCollision.canBeDragged()) {
2344
- const gridsterItemCollide = gridsterItemCollision;
2345
- const copyCollisionX = gridsterItemCollide.$item.x;
2346
- const copyCollisionY = gridsterItemCollide.$item.y;
2347
- const copyX = pushedBy.$item.x;
2348
- const copyY = pushedBy.$item.y;
2349
- const diffX = copyX - copyCollisionX;
2350
- const diffY = copyY - copyCollisionY;
2351
- gridsterItemCollide.$item.x = pushedBy.item.x - diffX;
2352
- gridsterItemCollide.$item.y = pushedBy.item.y - diffY;
2353
- pushedBy.$item.x = gridsterItemCollide.item.x + diffX;
2354
- pushedBy.$item.y = gridsterItemCollide.item.y + diffY;
2355
- if (this.gridster.checkCollision(gridsterItemCollide.$item) || this.gridster.checkCollision(pushedBy.$item)) {
2356
- pushedBy.$item.x = copyX;
2357
- pushedBy.$item.y = copyY;
2358
- gridsterItemCollide.$item.x = copyCollisionX;
2359
- gridsterItemCollide.$item.y = copyCollisionY;
2360
- } else {
2361
- gridsterItemCollide.setSize();
2362
- this.swapedItem = gridsterItemCollide;
2363
- if (this.gridster.$options.swapWhileDragging) {
2364
- this.gridsterItem.checkItemChanges(this.gridsterItem.$item, this.gridsterItem.item);
2365
- this.setSwapItem();
2366
- }
2367
- }
2368
- }
2369
- }
2370
- };
2371
- var GRIDSTER_ITEM_RESIZABLE_HANDLER_CLASS = "gridster-item-resizable-handler";
2372
- var Direction;
2373
- (function(Direction2) {
2374
- Direction2["UP"] = "UP";
2375
- Direction2["DOWN"] = "DOWN";
2376
- Direction2["LEFT"] = "LEFT";
2377
- Direction2["RIGHT"] = "RIGHT";
2378
- })(Direction || (Direction = {}));
2379
- var GridsterDraggable = class {
2380
- zone;
2381
- gridsterItem;
2382
- gridster;
2383
- lastMouse;
2384
- offsetLeft;
2385
- offsetTop;
2386
- margin;
2387
- outerMarginTop;
2388
- outerMarginRight;
2389
- outerMarginBottom;
2390
- outerMarginLeft;
2391
- diffTop;
2392
- diffLeft;
2393
- originalClientX;
2394
- originalClientY;
2395
- top;
2396
- left;
2397
- height;
2398
- width;
2399
- positionX;
2400
- positionY;
2401
- positionXBackup;
2402
- positionYBackup;
2403
- enabled;
2404
- mousemove;
2405
- mouseup;
2406
- mouseleave;
2407
- cancelOnBlur;
2408
- touchmove;
2409
- touchend;
2410
- touchcancel;
2411
- mousedown;
2412
- touchstart;
2413
- push;
2414
- swap;
2415
- path;
2416
- collision = false;
2417
- constructor(gridsterItem, gridster, zone) {
2418
- this.zone = zone;
2419
- this.gridsterItem = gridsterItem;
2420
- this.gridster = gridster;
2421
- this.lastMouse = {
2422
- clientX: 0,
2423
- clientY: 0
2424
- };
2425
- this.path = [];
2426
- }
2427
- destroy() {
2428
- if (this.gridster.previewStyle) {
2429
- this.gridster.previewStyle(true);
2430
- }
2431
- this.gridsterItem = this.gridster = this.collision = null;
2432
- if (this.mousedown) {
2433
- this.mousedown();
2434
- this.touchstart();
2435
- }
2436
- }
2437
- dragStart(e) {
2438
- if (e.which && e.which !== 1 || this.gridster.dragInProgress) {
2439
- return;
2440
- }
2441
- if (this.gridster.options.draggable && this.gridster.options.draggable.start) {
2442
- this.gridster.options.draggable.start(this.gridsterItem.item, this.gridsterItem, e);
2443
- }
2444
- e.stopPropagation();
2445
- e.preventDefault();
2446
- this.zone.runOutsideAngular(() => {
2447
- this.mousemove = this.gridsterItem.renderer.listen("document", "mousemove", this.dragMove);
2448
- this.touchmove = this.gridster.renderer.listen(this.gridster.el, "touchmove", this.dragMove);
2449
- });
2450
- this.mouseup = this.gridsterItem.renderer.listen("document", "mouseup", this.dragStop);
2451
- this.mouseleave = this.gridsterItem.renderer.listen("document", "mouseleave", this.dragStop);
2452
- this.cancelOnBlur = this.gridsterItem.renderer.listen("window", "blur", this.dragStop);
2453
- this.touchend = this.gridsterItem.renderer.listen("document", "touchend", this.dragStop);
2454
- this.touchcancel = this.gridsterItem.renderer.listen("document", "touchcancel", this.dragStop);
2455
- this.gridsterItem.renderer.addClass(this.gridsterItem.el, "gridster-item-moving");
2456
- this.margin = this.gridster.$options.margin;
2457
- this.outerMarginTop = this.gridster.$options.outerMarginTop;
2458
- this.outerMarginRight = this.gridster.$options.outerMarginRight;
2459
- this.outerMarginBottom = this.gridster.$options.outerMarginBottom;
2460
- this.outerMarginLeft = this.gridster.$options.outerMarginLeft;
2461
- this.offsetLeft = this.gridster.el.scrollLeft - this.gridster.el.offsetLeft;
2462
- this.offsetTop = this.gridster.el.scrollTop - this.gridster.el.offsetTop;
2463
- this.left = this.gridsterItem.left - this.margin;
2464
- this.top = this.gridsterItem.top - this.margin;
2465
- this.originalClientX = e.clientX;
2466
- this.originalClientY = e.clientY;
2467
- this.width = this.gridsterItem.width;
2468
- this.height = this.gridsterItem.height;
2469
- if (this.gridster.$options.dirType === DirTypes.RTL) {
2470
- this.diffLeft = e.clientX - this.gridster.el.scrollWidth + this.gridsterItem.left;
2471
- } else {
2472
- this.diffLeft = e.clientX + this.offsetLeft - this.margin - this.left;
2473
- }
2474
- this.diffTop = e.clientY + this.offsetTop - this.margin - this.top;
2475
- this.gridster.movingItem = this.gridsterItem.$item;
2476
- this.gridster.previewStyle(true);
2477
- this.push = new GridsterPush(this.gridsterItem);
2478
- this.swap = new GridsterSwap(this.gridsterItem);
2479
- this.gridster.dragInProgress = true;
2480
- this.gridster.updateGrid();
2481
- this.path.push({
2482
- x: this.gridsterItem.item.x || 0,
2483
- y: this.gridsterItem.item.y || 0
2484
- });
2485
- }
2486
- dragMove = (e) => {
2487
- e.stopPropagation();
2488
- e.preventDefault();
2489
- GridsterUtils.checkTouchEvent(e);
2490
- let directions = this.getDirections(e);
2491
- if (this.gridster.options.enableBoundaryControl) {
2492
- if (directions.includes(Direction.UP) && this.gridsterItem.el.getBoundingClientRect().top < this.gridster.el.getBoundingClientRect().top + (this.outerMarginTop ?? this.margin)) {
2493
- directions = directions.filter((direction) => direction != Direction.UP);
2494
- e = new MouseEvent(e.type, {
2495
- clientX: e.clientX,
2496
- clientY: this.lastMouse.clientY
2497
- });
2498
- }
2499
- if (directions.includes(Direction.LEFT) && this.gridsterItem.el.getBoundingClientRect().left < this.gridster.el.getBoundingClientRect().left + (this.outerMarginLeft ?? this.margin)) {
2500
- directions = directions.filter((direction) => direction != Direction.LEFT);
2501
- e = new MouseEvent(e.type, {
2502
- clientX: this.lastMouse.clientX,
2503
- clientY: e.clientY
2504
- });
2505
- }
2506
- if (directions.includes(Direction.RIGHT) && this.gridsterItem.el.getBoundingClientRect().right > this.gridster.el.getBoundingClientRect().right - (this.outerMarginRight ?? this.margin)) {
2507
- directions = directions.filter((direction) => direction != Direction.RIGHT);
2508
- e = new MouseEvent(e.type, {
2509
- clientX: this.lastMouse.clientX,
2510
- clientY: e.clientY
2511
- });
2512
- }
2513
- if (directions.includes(Direction.DOWN) && this.gridsterItem.el.getBoundingClientRect().bottom > this.gridster.el.getBoundingClientRect().bottom - (this.outerMarginBottom ?? this.margin)) {
2514
- directions = directions.filter((direction) => direction != Direction.DOWN);
2515
- e = new MouseEvent(e.type, {
2516
- clientX: e.clientX,
2517
- clientY: this.lastMouse.clientY
2518
- });
2519
- }
2520
- }
2521
- if (directions.length) {
2522
- this.offsetLeft = this.gridster.el.scrollLeft - this.gridster.el.offsetLeft;
2523
- this.offsetTop = this.gridster.el.scrollTop - this.gridster.el.offsetTop;
2524
- scroll(this.gridster, this.left, this.top, this.width, this.height, e, this.lastMouse, this.calculateItemPositionFromMousePosition);
2525
- this.calculateItemPositionFromMousePosition(e);
2526
- }
2527
- };
2528
- calculateItemPositionFromMousePosition = (e) => {
2529
- if (this.gridster.options.scale) {
2530
- this.calculateItemPositionWithScale(e, this.gridster.options.scale);
2531
- } else {
2532
- this.calculateItemPositionWithoutScale(e);
2533
- }
2534
- this.calculateItemPosition();
2535
- this.lastMouse.clientX = e.clientX;
2536
- this.lastMouse.clientY = e.clientY;
2537
- this.zone.run(() => {
2538
- this.gridster.updateGrid();
2539
- });
2540
- };
2541
- calculateItemPositionWithScale(e, scale) {
2542
- if (this.gridster.$options.dirType === DirTypes.RTL) {
2543
- this.left = this.gridster.el.scrollWidth - this.originalClientX + (e.clientX - this.originalClientX) / scale + this.diffLeft;
2544
- } else {
2545
- this.left = this.originalClientX + (e.clientX - this.originalClientX) / scale + this.offsetLeft - this.diffLeft;
2546
- }
2547
- this.top = this.originalClientY + (e.clientY - this.originalClientY) / scale + this.offsetTop - this.diffTop;
2548
- }
2549
- calculateItemPositionWithoutScale(e) {
2550
- const isRTL = this.gridster.$options.dirType === DirTypes.RTL;
2551
- if (isRTL) {
2552
- this.left = this.gridster.el.offsetWidth - (e.clientX + this.offsetLeft - this.diffLeft);
2553
- } else {
2554
- this.left = e.clientX + this.offsetLeft - this.diffLeft;
2555
- }
2556
- this.top = e.clientY + this.offsetTop - this.diffTop;
2557
- }
2558
- dragStop = (e) => {
2559
- e.stopPropagation();
2560
- e.preventDefault();
2561
- cancelScroll();
2562
- this.cancelOnBlur();
2563
- this.mousemove();
2564
- this.mouseup();
2565
- this.mouseleave();
2566
- this.touchmove();
2567
- this.touchend();
2568
- this.touchcancel();
2569
- this.gridsterItem.renderer.removeClass(this.gridsterItem.el, "gridster-item-moving");
2570
- this.gridster.dragInProgress = false;
2571
- this.gridster.updateGrid();
2572
- this.path = [];
2573
- if (this.gridster.options.draggable && this.gridster.options.draggable.stop) {
2574
- Promise.resolve(this.gridster.options.draggable.stop(this.gridsterItem.item, this.gridsterItem, e)).then(this.makeDrag, this.cancelDrag);
2575
- } else {
2576
- this.makeDrag();
2577
- }
2578
- setTimeout(() => {
2579
- if (this.gridster) {
2580
- this.gridster.movingItem = null;
2581
- this.gridster.previewStyle(true);
2582
- }
2583
- });
2584
- };
2585
- cancelDrag = () => {
2586
- this.gridsterItem.$item.x = this.gridsterItem.item.x || 0;
2587
- this.gridsterItem.$item.y = this.gridsterItem.item.y || 0;
2588
- this.gridsterItem.setSize();
2589
- if (this.push) {
2590
- this.push.restoreItems();
2591
- }
2592
- if (this.swap) {
2593
- this.swap.restoreSwapItem();
2594
- }
2595
- if (this.push) {
2596
- this.push.destroy();
2597
- this.push = null;
2598
- }
2599
- if (this.swap) {
2600
- this.swap.destroy();
2601
- this.swap = null;
2602
- }
2603
- };
2604
- makeDrag = () => {
2605
- if (this.gridster.$options.draggable.dropOverItems && this.gridster.options.draggable && this.gridster.options.draggable.dropOverItemsCallback && this.collision && this.collision !== true && this.collision.$item) {
2606
- this.gridster.options.draggable.dropOverItemsCallback(this.gridsterItem.item, this.collision.item, this.gridster);
2607
- }
2608
- this.collision = false;
2609
- this.gridsterItem.setSize();
2610
- this.gridsterItem.checkItemChanges(this.gridsterItem.$item, this.gridsterItem.item);
2611
- if (this.push) {
2612
- this.push.setPushedItems();
2613
- }
2614
- if (this.swap) {
2615
- this.swap.setSwapItem();
2616
- }
2617
- if (this.push) {
2618
- this.push.destroy();
2619
- this.push = null;
2620
- }
2621
- if (this.swap) {
2622
- this.swap.destroy();
2623
- this.swap = null;
2624
- }
2625
- };
2626
- calculateItemPosition() {
2627
- this.gridster.movingItem = this.gridsterItem.$item;
2628
- this.positionX = this.gridster.pixelsToPositionX(this.left, Math.round);
2629
- this.positionY = this.gridster.pixelsToPositionY(this.top, Math.round);
2630
- this.positionXBackup = this.gridsterItem.$item.x;
2631
- this.positionYBackup = this.gridsterItem.$item.y;
2632
- this.gridsterItem.$item.x = this.positionX;
2633
- if (this.gridster.checkGridCollision(this.gridsterItem.$item)) {
2634
- this.gridsterItem.$item.x = this.positionXBackup;
2635
- }
2636
- this.gridsterItem.$item.y = this.positionY;
2637
- if (this.gridster.checkGridCollision(this.gridsterItem.$item)) {
2638
- this.gridsterItem.$item.y = this.positionYBackup;
2639
- }
2640
- this.gridster.gridRenderer.setCellPosition(this.gridsterItem.renderer, this.gridsterItem.el, this.left, this.top);
2641
- if (this.positionXBackup !== this.gridsterItem.$item.x || this.positionYBackup !== this.gridsterItem.$item.y) {
2642
- const lastPosition = this.path[this.path.length - 1];
2643
- let direction = "";
2644
- if (lastPosition.x < this.gridsterItem.$item.x) {
2645
- direction = this.push.fromWest;
2646
- } else if (lastPosition.x > this.gridsterItem.$item.x) {
2647
- direction = this.push.fromEast;
2648
- } else if (lastPosition.y < this.gridsterItem.$item.y) {
2649
- direction = this.push.fromNorth;
2650
- } else if (lastPosition.y > this.gridsterItem.$item.y) {
2651
- direction = this.push.fromSouth;
2652
- }
2653
- this.push.pushItems(direction, this.gridster.$options.disablePushOnDrag);
2654
- this.swap.swapItems();
2655
- this.collision = this.gridster.checkCollision(this.gridsterItem.$item);
2656
- if (this.collision) {
2657
- this.gridsterItem.$item.x = this.positionXBackup;
2658
- this.gridsterItem.$item.y = this.positionYBackup;
2659
- if (this.gridster.$options.draggable.dropOverItems && this.collision !== true && this.collision.$item) {
2660
- this.gridster.movingItem = null;
2661
- }
2662
- } else {
2663
- this.path.push({
2664
- x: this.gridsterItem.$item.x,
2665
- y: this.gridsterItem.$item.y
2666
- });
2667
- }
2668
- this.push.checkPushBack();
2669
- } else {
2670
- this.collision = false;
2671
- }
2672
- this.gridster.previewStyle(true);
2673
- }
2674
- toggle() {
2675
- const enableDrag = this.gridsterItem.canBeDragged();
2676
- if (!this.enabled && enableDrag) {
2677
- this.enabled = !this.enabled;
2678
- this.mousedown = this.gridsterItem.renderer.listen(this.gridsterItem.el, "mousedown", this.dragStartDelay);
2679
- this.touchstart = this.gridsterItem.renderer.listen(this.gridsterItem.el, "touchstart", this.dragStartDelay);
2680
- } else if (this.enabled && !enableDrag) {
2681
- this.enabled = !this.enabled;
2682
- this.mousedown();
2683
- this.touchstart();
2684
- }
2685
- }
2686
- dragStartDelay = (e) => {
2687
- const target = e.target;
2688
- if (target.classList.contains(GRIDSTER_ITEM_RESIZABLE_HANDLER_CLASS)) {
2689
- return;
2690
- }
2691
- if (GridsterUtils.checkContentClassForEvent(this.gridster, e)) {
2692
- return;
2693
- }
2694
- GridsterUtils.checkTouchEvent(e);
2695
- if (!this.gridster.$options.draggable.delayStart) {
2696
- this.dragStart(e);
2697
- return;
2698
- }
2699
- const timeout = setTimeout(() => {
2700
- this.dragStart(e);
2701
- cancelDrag();
2702
- }, this.gridster.$options.draggable.delayStart);
2703
- const cancelMouse = this.gridsterItem.renderer.listen("document", "mouseup", cancelDrag);
2704
- const cancelMouseLeave = this.gridsterItem.renderer.listen("document", "mouseleave", cancelDrag);
2705
- const cancelOnBlur = this.gridsterItem.renderer.listen("window", "blur", cancelDrag);
2706
- const cancelTouchMove = this.gridsterItem.renderer.listen("document", "touchmove", cancelMove);
2707
- const cancelTouchEnd = this.gridsterItem.renderer.listen("document", "touchend", cancelDrag);
2708
- const cancelTouchCancel = this.gridsterItem.renderer.listen("document", "touchcancel", cancelDrag);
2709
- function cancelMove(eventMove) {
2710
- GridsterUtils.checkTouchEvent(eventMove);
2711
- if (Math.abs(eventMove.clientX - e.clientX) > 9 || Math.abs(eventMove.clientY - e.clientY) > 9) {
2712
- cancelDrag();
2713
- }
2714
- }
2715
- function cancelDrag() {
2716
- clearTimeout(timeout);
2717
- cancelOnBlur();
2718
- cancelMouse();
2719
- cancelMouseLeave();
2720
- cancelTouchMove();
2721
- cancelTouchEnd();
2722
- cancelTouchCancel();
2723
- }
2724
- };
2725
- /**
2726
- * Returns the list of directions for given mouse event
2727
- * @param e Mouse event
2728
- * */
2729
- getDirections(e) {
2730
- const directions = [];
2731
- if (this.lastMouse.clientX === 0 && this.lastMouse.clientY === 0) {
2732
- this.lastMouse.clientY = e.clientY;
2733
- this.lastMouse.clientX = e.clientX;
2734
- }
2735
- if (this.lastMouse.clientY > e.clientY) {
2736
- directions.push(Direction.UP);
2737
- }
2738
- if (this.lastMouse.clientY < e.clientY) {
2739
- directions.push(Direction.DOWN);
2740
- }
2741
- if (this.lastMouse.clientX < e.clientX) {
2742
- directions.push(Direction.RIGHT);
2743
- }
2744
- if (this.lastMouse.clientX > e.clientX) {
2745
- directions.push(Direction.LEFT);
2746
- }
2747
- return directions;
2748
- }
2749
- };
2750
- var GridsterPushResize = class {
2751
- fromSouth;
2752
- fromNorth;
2753
- fromEast;
2754
- fromWest;
2755
- pushedItems;
2756
- pushedItemsPath;
2757
- gridsterItem;
2758
- gridster;
2759
- tryPattern;
2760
- constructor(gridsterItem) {
2761
- this.pushedItems = [];
2762
- this.pushedItemsPath = [];
2763
- this.gridsterItem = gridsterItem;
2764
- this.gridster = gridsterItem.gridster;
2765
- this.tryPattern = {
2766
- fromEast: this.tryWest,
2767
- fromWest: this.tryEast,
2768
- fromNorth: this.trySouth,
2769
- fromSouth: this.tryNorth
2770
- };
2771
- this.fromSouth = "fromSouth";
2772
- this.fromNorth = "fromNorth";
2773
- this.fromEast = "fromEast";
2774
- this.fromWest = "fromWest";
2775
- }
2776
- destroy() {
2777
- this.gridster = this.gridsterItem = null;
2778
- }
2779
- pushItems(direction) {
2780
- if (this.gridster.$options.pushResizeItems) {
2781
- return this.push(this.gridsterItem, direction);
2782
- } else {
2783
- return false;
2784
- }
2785
- }
2786
- restoreItems() {
2787
- let i = 0;
2788
- const l = this.pushedItems.length;
2789
- let pushedItem;
2790
- for (; i < l; i++) {
2791
- pushedItem = this.pushedItems[i];
2792
- pushedItem.$item.x = pushedItem.item.x || 0;
2793
- pushedItem.$item.y = pushedItem.item.y || 0;
2794
- pushedItem.$item.cols = pushedItem.item.cols || 1;
2795
- pushedItem.$item.row = pushedItem.item.row || 1;
2796
- pushedItem.setSize();
2797
- }
2798
- this.pushedItems = [];
2799
- this.pushedItemsPath = [];
2800
- }
2801
- setPushedItems() {
2802
- let i = 0;
2803
- const l = this.pushedItems.length;
2804
- let pushedItem;
2805
- for (; i < l; i++) {
2806
- pushedItem = this.pushedItems[i];
2807
- pushedItem.checkItemChanges(pushedItem.$item, pushedItem.item);
2808
- }
2809
- this.pushedItems = [];
2810
- this.pushedItemsPath = [];
2811
- }
2812
- checkPushBack() {
2813
- let i = this.pushedItems.length - 1;
2814
- let change = false;
2815
- for (; i > -1; i--) {
2816
- if (this.checkPushedItem(this.pushedItems[i], i)) {
2817
- change = true;
2818
- }
2819
- }
2820
- if (change) {
2821
- this.checkPushBack();
2822
- }
2823
- }
2824
- push(gridsterItem, direction) {
2825
- const gridsterItemCollision = this.gridster.checkCollision(gridsterItem.$item);
2826
- if (gridsterItemCollision && gridsterItemCollision !== true && gridsterItemCollision !== this.gridsterItem && gridsterItemCollision.canBeResized()) {
2827
- if (this.tryPattern[direction].call(this, gridsterItemCollision, gridsterItem, direction)) {
2828
- return true;
2829
- }
2830
- } else if (gridsterItemCollision === false) {
2831
- return true;
2832
- }
2833
- return false;
2834
- }
2835
- trySouth(gridsterItemCollide, gridsterItem, direction) {
2836
- const backUpY = gridsterItemCollide.$item.y;
2837
- const backUpRows = gridsterItemCollide.$item.rows;
2838
- gridsterItemCollide.$item.y = gridsterItem.$item.y + gridsterItem.$item.rows;
2839
- gridsterItemCollide.$item.rows = backUpRows + backUpY - gridsterItemCollide.$item.y;
2840
- if (!this.gridster.checkCollisionTwoItems(gridsterItemCollide.$item, gridsterItem.$item) && !this.gridster.checkGridCollision(gridsterItemCollide.$item)) {
2841
- gridsterItemCollide.setSize();
2842
- this.addToPushed(gridsterItemCollide);
2843
- this.push(gridsterItem, direction);
2844
- return true;
2845
- } else {
2846
- gridsterItemCollide.$item.y = backUpY;
2847
- gridsterItemCollide.$item.rows = backUpRows;
2848
- }
2849
- return false;
2850
- }
2851
- tryNorth(gridsterItemCollide, gridsterItem, direction) {
2852
- const backUpRows = gridsterItemCollide.$item.rows;
2853
- gridsterItemCollide.$item.rows = gridsterItem.$item.y - gridsterItemCollide.$item.y;
2854
- if (!this.gridster.checkCollisionTwoItems(gridsterItemCollide.$item, gridsterItem.$item) && !this.gridster.checkGridCollision(gridsterItemCollide.$item)) {
2855
- gridsterItemCollide.setSize();
2856
- this.addToPushed(gridsterItemCollide);
2857
- this.push(gridsterItem, direction);
2858
- return true;
2859
- } else {
2860
- gridsterItemCollide.$item.rows = backUpRows;
2861
- }
2862
- return false;
2863
- }
2864
- tryEast(gridsterItemCollide, gridsterItem, direction) {
2865
- const backUpX = gridsterItemCollide.$item.x;
2866
- const backUpCols = gridsterItemCollide.$item.cols;
2867
- gridsterItemCollide.$item.x = gridsterItem.$item.x + gridsterItem.$item.cols;
2868
- gridsterItemCollide.$item.cols = backUpCols + backUpX - gridsterItemCollide.$item.x;
2869
- if (!this.gridster.checkCollisionTwoItems(gridsterItemCollide.$item, gridsterItem.$item) && !this.gridster.checkGridCollision(gridsterItemCollide.$item)) {
2870
- gridsterItemCollide.setSize();
2871
- this.addToPushed(gridsterItemCollide);
2872
- this.push(gridsterItem, direction);
2873
- return true;
2874
- } else {
2875
- gridsterItemCollide.$item.x = backUpX;
2876
- gridsterItemCollide.$item.cols = backUpCols;
2877
- }
2878
- return false;
2879
- }
2880
- tryWest(gridsterItemCollide, gridsterItem, direction) {
2881
- const backUpCols = gridsterItemCollide.$item.cols;
2882
- gridsterItemCollide.$item.cols = gridsterItem.$item.x - gridsterItemCollide.$item.x;
2883
- if (!this.gridster.checkCollisionTwoItems(gridsterItemCollide.$item, gridsterItem.$item) && !this.gridster.checkGridCollision(gridsterItemCollide.$item)) {
2884
- gridsterItemCollide.setSize();
2885
- this.addToPushed(gridsterItemCollide);
2886
- this.push(gridsterItem, direction);
2887
- return true;
2888
- } else {
2889
- gridsterItemCollide.$item.cols = backUpCols;
2890
- }
2891
- return false;
2892
- }
2893
- addToPushed(gridsterItem) {
2894
- if (this.pushedItems.indexOf(gridsterItem) < 0) {
2895
- this.pushedItems.push(gridsterItem);
2896
- this.pushedItemsPath.push([
2897
- {
2898
- x: gridsterItem.item.x || 0,
2899
- y: gridsterItem.item.y || 0,
2900
- cols: gridsterItem.item.cols || 0,
2901
- rows: gridsterItem.item.rows || 0
2902
- },
2903
- {
2904
- x: gridsterItem.$item.x,
2905
- y: gridsterItem.$item.y,
2906
- cols: gridsterItem.$item.cols,
2907
- rows: gridsterItem.$item.rows
2908
- }
2909
- ]);
2910
- } else {
2911
- const i = this.pushedItems.indexOf(gridsterItem);
2912
- this.pushedItemsPath[i].push({
2913
- x: gridsterItem.$item.x,
2914
- y: gridsterItem.$item.y,
2915
- cols: gridsterItem.$item.cols,
2916
- rows: gridsterItem.$item.rows
2917
- });
2918
- }
2919
- }
2920
- removeFromPushed(i) {
2921
- if (i > -1) {
2922
- this.pushedItems.splice(i, 1);
2923
- this.pushedItemsPath.splice(i, 1);
2924
- }
2925
- }
2926
- checkPushedItem(pushedItem, i) {
2927
- const path = this.pushedItemsPath[i];
2928
- let j = path.length - 2;
2929
- let lastPosition;
2930
- let x;
2931
- let y;
2932
- let cols;
2933
- let rows;
2934
- for (; j > -1; j--) {
2935
- lastPosition = path[j];
2936
- x = pushedItem.$item.x;
2937
- y = pushedItem.$item.y;
2938
- cols = pushedItem.$item.cols;
2939
- rows = pushedItem.$item.rows;
2940
- pushedItem.$item.x = lastPosition.x;
2941
- pushedItem.$item.y = lastPosition.y;
2942
- pushedItem.$item.cols = lastPosition.cols;
2943
- pushedItem.$item.rows = lastPosition.rows;
2944
- if (!this.gridster.findItemWithItem(pushedItem.$item)) {
2945
- pushedItem.setSize();
2946
- path.splice(j + 1, path.length - 1 - j);
2947
- } else {
2948
- pushedItem.$item.x = x;
2949
- pushedItem.$item.y = y;
2950
- pushedItem.$item.cols = cols;
2951
- pushedItem.$item.rows = rows;
2952
- }
2953
- }
2954
- if (path.length < 2) {
2955
- this.removeFromPushed(i);
2956
- return true;
2957
- }
2958
- return false;
2959
- }
2960
- };
2961
- var GridsterResizable = class {
2962
- zone;
2963
- gridsterItem;
2964
- gridster;
2965
- lastMouse;
2966
- itemBackup = { x: 0, y: 0, cols: 0, rows: 0 };
2967
- resizeEventScrollType;
2968
- /**
2969
- * The direction function may reference any of the `GridsterResizable` class methods, that are
2970
- * responsible for gridster resize when the `dragmove` event is being handled. E.g. it may reference
2971
- * the `handleNorth` method when the north handle is pressed and moved by a mouse.
2972
- */
2973
- directionFunction = null;
2974
- resizeEnabled;
2975
- resizableHandles;
2976
- mousemove;
2977
- mouseup;
2978
- mouseleave;
2979
- cancelOnBlur;
2980
- touchmove;
2981
- touchend;
2982
- touchcancel;
2983
- push;
2984
- pushResize;
2985
- minHeight;
2986
- minWidth;
2987
- offsetTop;
2988
- offsetLeft;
2989
- diffTop;
2990
- diffLeft;
2991
- diffRight;
2992
- diffBottom;
2993
- margin;
2994
- outerMarginTop;
2995
- outerMarginRight;
2996
- outerMarginBottom;
2997
- outerMarginLeft;
2998
- originalClientX;
2999
- originalClientY;
3000
- top;
3001
- left;
3002
- bottom;
3003
- right;
3004
- width;
3005
- height;
3006
- hasRatio;
3007
- constructor(gridsterItem, gridster, zone) {
3008
- this.zone = zone;
3009
- this.gridsterItem = gridsterItem;
3010
- this.gridster = gridster;
3011
- this.lastMouse = {
3012
- clientX: 0,
3013
- clientY: 0
3014
- };
3015
- this.resizeEventScrollType = {
3016
- west: false,
3017
- east: false,
3018
- north: false,
3019
- south: false
3020
- };
3021
- }
3022
- destroy() {
3023
- this.gridster?.previewStyle();
3024
- this.gridster = this.gridsterItem = null;
3025
- }
3026
- dragStart(e) {
3027
- if (e.which && e.which !== 1 || this.gridster.dragInProgress) {
3028
- return;
3029
- }
3030
- if (this.gridster.options.resizable && this.gridster.options.resizable.start) {
3031
- this.gridster.options.resizable.start(this.gridsterItem.item, this.gridsterItem, e);
3032
- }
3033
- e.stopPropagation();
3034
- e.preventDefault();
3035
- this.zone.runOutsideAngular(() => {
3036
- this.mousemove = this.gridsterItem.renderer.listen("document", "mousemove", this.dragMove);
3037
- this.touchmove = this.gridster.renderer.listen(this.gridster.el, "touchmove", this.dragMove);
3038
- });
3039
- this.mouseup = this.gridsterItem.renderer.listen("document", "mouseup", this.dragStop);
3040
- this.mouseleave = this.gridsterItem.renderer.listen("document", "mouseleave", this.dragStop);
3041
- this.cancelOnBlur = this.gridsterItem.renderer.listen("window", "blur", this.dragStop);
3042
- this.touchend = this.gridsterItem.renderer.listen("document", "touchend", this.dragStop);
3043
- this.touchcancel = this.gridsterItem.renderer.listen("document", "touchcancel", this.dragStop);
3044
- this.gridsterItem.renderer.addClass(this.gridsterItem.el, "gridster-item-resizing");
3045
- this.lastMouse.clientX = e.clientX;
3046
- this.lastMouse.clientY = e.clientY;
3047
- this.left = this.gridsterItem.left;
3048
- this.top = this.gridsterItem.top;
3049
- this.originalClientX = e.clientX;
3050
- this.originalClientY = e.clientY;
3051
- this.width = this.gridsterItem.width;
3052
- this.height = this.gridsterItem.height;
3053
- this.bottom = this.gridsterItem.top + this.gridsterItem.height;
3054
- this.right = this.gridsterItem.left + this.gridsterItem.width;
3055
- this.margin = this.gridster.$options.margin;
3056
- this.outerMarginTop = this.gridster.$options.outerMarginTop;
3057
- this.outerMarginRight = this.gridster.$options.outerMarginRight;
3058
- this.outerMarginBottom = this.gridster.$options.outerMarginBottom;
3059
- this.outerMarginLeft = this.gridster.$options.outerMarginLeft;
3060
- this.offsetLeft = this.gridster.el.scrollLeft - this.gridster.el.offsetLeft;
3061
- this.offsetTop = this.gridster.el.scrollTop - this.gridster.el.offsetTop;
3062
- this.diffLeft = e.clientX + this.offsetLeft - this.left;
3063
- this.diffRight = e.clientX + this.offsetLeft - this.right;
3064
- this.diffTop = e.clientY + this.offsetTop - this.top;
3065
- this.diffBottom = e.clientY + this.offsetTop - this.bottom;
3066
- this.minHeight = this.gridster.positionYToPixels(this.gridsterItem.$item.minItemRows || this.gridster.$options.minItemRows) - this.margin;
3067
- this.minWidth = this.gridster.positionXToPixels(this.gridsterItem.$item.minItemCols || this.gridster.$options.minItemCols) - this.margin;
3068
- this.gridster.movingItem = this.gridsterItem.$item;
3069
- this.gridster.previewStyle();
3070
- this.push = new GridsterPush(this.gridsterItem);
3071
- this.pushResize = new GridsterPushResize(this.gridsterItem);
3072
- this.gridster.dragInProgress = true;
3073
- this.hasRatio = !!(this.gridster.$options.itemAspectRatio || this.gridsterItem.$item.itemAspectRatio);
3074
- this.itemBackup = { x: 0, y: 0, cols: 0, rows: 0 };
3075
- this.gridster.updateGrid();
3076
- const { classList } = e.target;
3077
- if (classList.contains("handle-n")) {
3078
- this.resizeEventScrollType.north = true;
3079
- this.directionFunction = this.handleNorth;
3080
- } else if (classList.contains("handle-w")) {
3081
- if (this.gridster.$options.dirType === DirTypes.RTL) {
3082
- this.resizeEventScrollType.east = true;
3083
- this.directionFunction = this.handleEast;
3084
- } else {
3085
- this.resizeEventScrollType.west = true;
3086
- this.directionFunction = this.handleWest;
3087
- }
3088
- } else if (classList.contains("handle-s")) {
3089
- this.resizeEventScrollType.south = true;
3090
- this.directionFunction = this.handleSouth;
3091
- } else if (classList.contains("handle-e")) {
3092
- if (this.gridster.$options.dirType === DirTypes.RTL) {
3093
- this.resizeEventScrollType.west = true;
3094
- this.directionFunction = this.handleWest;
3095
- } else {
3096
- this.resizeEventScrollType.east = true;
3097
- this.directionFunction = this.handleEast;
3098
- }
3099
- } else if (classList.contains("handle-nw")) {
3100
- if (this.gridster.$options.dirType === DirTypes.RTL) {
3101
- this.resizeEventScrollType.north = true;
3102
- this.resizeEventScrollType.east = true;
3103
- this.directionFunction = this.handleNorthEast;
3104
- } else {
3105
- this.resizeEventScrollType.north = true;
3106
- this.resizeEventScrollType.west = true;
3107
- this.directionFunction = this.handleNorthWest;
3108
- }
3109
- } else if (classList.contains("handle-ne")) {
3110
- if (this.gridster.$options.dirType === DirTypes.RTL) {
3111
- this.resizeEventScrollType.north = true;
3112
- this.resizeEventScrollType.west = true;
3113
- this.directionFunction = this.handleNorthWest;
3114
- } else {
3115
- this.resizeEventScrollType.north = true;
3116
- this.resizeEventScrollType.east = true;
3117
- this.directionFunction = this.handleNorthEast;
3118
- }
3119
- } else if (classList.contains("handle-sw")) {
3120
- if (this.gridster.$options.dirType === DirTypes.RTL) {
3121
- this.resizeEventScrollType.south = true;
3122
- this.resizeEventScrollType.east = true;
3123
- this.directionFunction = this.handleSouthEast;
3124
- } else {
3125
- this.resizeEventScrollType.south = true;
3126
- this.resizeEventScrollType.west = true;
3127
- this.directionFunction = this.handleSouthWest;
3128
- }
3129
- } else if (classList.contains("handle-se")) {
3130
- if (this.gridster.$options.dirType === DirTypes.RTL) {
3131
- this.resizeEventScrollType.south = true;
3132
- this.resizeEventScrollType.west = true;
3133
- this.directionFunction = this.handleSouthWest;
3134
- } else {
3135
- this.resizeEventScrollType.south = true;
3136
- this.resizeEventScrollType.east = true;
3137
- this.directionFunction = this.handleSouthEast;
3138
- }
3139
- }
3140
- }
3141
- dragMove = (e) => {
3142
- if (this.directionFunction === null) {
3143
- throw new Error("The `directionFunction` has not been set before calling `dragMove`.");
3144
- }
3145
- e.stopPropagation();
3146
- e.preventDefault();
3147
- GridsterUtils.checkTouchEvent(e);
3148
- this.offsetTop = this.gridster.el.scrollTop - this.gridster.el.offsetTop;
3149
- this.offsetLeft = this.gridster.el.scrollLeft - this.gridster.el.offsetLeft;
3150
- scroll(this.gridster, this.left, this.top, this.width, this.height, e, this.lastMouse, this.directionFunction, true, this.resizeEventScrollType);
3151
- const scale = this.gridster.options.scale || 1;
3152
- this.directionFunction({
3153
- clientX: this.originalClientX + (e.clientX - this.originalClientX) / scale,
3154
- clientY: this.originalClientY + (e.clientY - this.originalClientY) / scale
3155
- });
3156
- this.lastMouse.clientX = e.clientX;
3157
- this.lastMouse.clientY = e.clientY;
3158
- this.zone.run(() => {
3159
- this.gridster.updateGrid();
3160
- });
3161
- };
3162
- dragStop = (e) => {
3163
- e.stopPropagation();
3164
- e.preventDefault();
3165
- cancelScroll();
3166
- this.mousemove();
3167
- this.mouseup();
3168
- this.mouseleave();
3169
- this.cancelOnBlur();
3170
- this.touchmove();
3171
- this.touchend();
3172
- this.touchcancel();
3173
- this.gridster.dragInProgress = false;
3174
- this.resizeEventScrollType = {
3175
- west: false,
3176
- east: false,
3177
- north: false,
3178
- south: false
3179
- };
3180
- this.gridster.updateGrid();
3181
- if (this.gridster.options.resizable && this.gridster.options.resizable.stop) {
3182
- Promise.resolve(this.gridster.options.resizable.stop(this.gridsterItem.item, this.gridsterItem, e)).then(this.makeResize, this.cancelResize);
3183
- } else {
3184
- this.makeResize();
3185
- }
3186
- setTimeout(() => {
3187
- this.gridsterItem.renderer.removeClass(this.gridsterItem.el, "gridster-item-resizing");
3188
- if (this.gridster) {
3189
- this.gridster.movingItem = null;
3190
- this.gridster.previewStyle();
3191
- }
3192
- });
3193
- };
3194
- cancelResize = () => {
3195
- this.gridsterItem.$item.cols = this.gridsterItem.item.cols || 1;
3196
- this.gridsterItem.$item.rows = this.gridsterItem.item.rows || 1;
3197
- this.gridsterItem.$item.x = this.gridsterItem.item.x || 0;
3198
- this.gridsterItem.$item.y = this.gridsterItem.item.y || 0;
3199
- this.gridsterItem.setSize();
3200
- this.push.restoreItems();
3201
- this.pushResize.restoreItems();
3202
- this.push.destroy();
3203
- this.push = null;
3204
- this.pushResize.destroy();
3205
- this.pushResize = null;
3206
- };
3207
- makeResize = () => {
3208
- this.gridsterItem.setSize();
3209
- this.gridsterItem.checkItemChanges(this.gridsterItem.$item, this.gridsterItem.item);
3210
- this.push.setPushedItems();
3211
- this.pushResize.setPushedItems();
3212
- this.push.destroy();
3213
- this.push = null;
3214
- this.pushResize.destroy();
3215
- this.pushResize = null;
3216
- };
3217
- check = (direction) => {
3218
- this.hasRatio && this.enforceAspectRatio();
3219
- this.pushResize.pushItems(direction);
3220
- this.push.pushItems(direction, this.gridster.$options.disablePushOnResize);
3221
- if (this.gridster.checkCollision(this.gridsterItem.$item, true)) {
3222
- this.resetItem(this.hasRatio);
3223
- return false;
3224
- }
3225
- this.gridster.previewStyle();
3226
- this.pushResize.checkPushBack();
3227
- this.push.checkPushBack();
3228
- return true;
3229
- };
3230
- getNewNorthPosition = (e) => {
3231
- this.top = e.clientY + this.offsetTop - this.diffTop;
3232
- this.height = this.bottom - this.top;
3233
- if (this.minHeight > this.height) {
3234
- this.height = this.minHeight;
3235
- this.top = this.bottom - this.minHeight;
3236
- } else if (this.gridster.options.enableBoundaryControl) {
3237
- this.top = Math.max(0, this.top);
3238
- this.height = this.bottom - this.top;
3239
- }
3240
- const marginTop = this.gridster.options.pushItems ? this.margin : 0;
3241
- return this.gridster.pixelsToPositionY(this.top + marginTop, Math.floor);
3242
- };
3243
- handleNorth = (e) => {
3244
- const newPosition = this.getNewNorthPosition(e);
3245
- if (this.gridsterItem.$item.y !== newPosition) {
3246
- this.makeItemBackup();
3247
- this.gridsterItem.$item.rows += this.gridsterItem.$item.y - newPosition;
3248
- this.gridsterItem.$item.y = newPosition;
3249
- if (!this.check(this.pushResize.fromSouth)) {
3250
- return;
3251
- }
3252
- }
3253
- this.setItemTop(this.top);
3254
- this.setItemHeight(this.height);
3255
- };
3256
- getNewWestPosition = (e) => {
3257
- const clientX = this.gridster.$options.dirType === DirTypes.RTL ? this.originalClientX + (this.originalClientX - e.clientX) : e.clientX;
3258
- this.left = clientX + this.offsetLeft - this.diffLeft;
3259
- this.width = this.right - this.left;
3260
- if (this.minWidth > this.width) {
3261
- this.width = this.minWidth;
3262
- this.left = this.right - this.minWidth;
3263
- } else if (this.gridster.options.enableBoundaryControl) {
3264
- this.left = Math.max(0, this.left);
3265
- this.width = this.right - this.left;
3266
- }
3267
- const marginLeft = this.gridster.options.pushItems ? this.margin : 0;
3268
- return this.gridster.pixelsToPositionX(this.left + marginLeft, Math.floor);
3269
- };
3270
- handleWest = (e) => {
3271
- const newPosition = this.getNewWestPosition(e);
3272
- if (this.gridsterItem.$item.x !== newPosition) {
3273
- this.makeItemBackup();
3274
- this.gridsterItem.$item.cols += this.gridsterItem.$item.x - newPosition;
3275
- this.gridsterItem.$item.x = newPosition;
3276
- if (!this.check(this.pushResize.fromEast)) {
3277
- return;
3278
- }
3279
- }
3280
- this.setItemLeft(this.left);
3281
- this.setItemWidth(this.width);
3282
- };
3283
- getNewSouthPosition = (e) => {
3284
- this.height = e.clientY + this.offsetTop - this.diffBottom - this.top;
3285
- if (this.minHeight > this.height) {
3286
- this.height = this.minHeight;
3287
- }
3288
- this.bottom = this.top + this.height;
3289
- if (this.gridster.options.enableBoundaryControl) {
3290
- const margin = this.outerMarginBottom ?? this.margin;
3291
- const box = this.gridster.el.getBoundingClientRect();
3292
- this.bottom = Math.min(this.bottom, box.bottom - box.top - 2 * margin);
3293
- this.height = this.bottom - this.top;
3294
- }
3295
- const marginBottom = this.gridster.options.pushItems ? 0 : this.margin;
3296
- return this.gridster.pixelsToPositionY(this.bottom + marginBottom, Math.ceil);
3297
- };
3298
- handleSouth = (e) => {
3299
- const newPosition = this.getNewSouthPosition(e);
3300
- if (this.gridsterItem.$item.y + this.gridsterItem.$item.rows !== newPosition) {
3301
- this.makeItemBackup();
3302
- this.gridsterItem.$item.rows = newPosition - this.gridsterItem.$item.y;
3303
- if (!this.check(this.pushResize.fromNorth)) {
3304
- return;
3305
- }
3306
- }
3307
- this.setItemHeight(this.height);
3308
- };
3309
- getNewEastPosition = (e) => {
3310
- const clientX = this.gridster.$options.dirType === DirTypes.RTL ? this.originalClientX + (this.originalClientX - e.clientX) : e.clientX;
3311
- this.width = clientX + this.offsetLeft - this.diffRight - this.left;
3312
- if (this.minWidth > this.width) {
3313
- this.width = this.minWidth;
3314
- }
3315
- this.right = this.left + this.width;
3316
- if (this.gridster.options.enableBoundaryControl) {
3317
- const margin = this.outerMarginRight ?? this.margin;
3318
- const box = this.gridster.el.getBoundingClientRect();
3319
- this.right = Math.min(this.right, box.right - box.left - 2 * margin);
3320
- this.width = this.right - this.left;
3321
- }
3322
- const marginRight = this.gridster.options.pushItems ? 0 : this.margin;
3323
- return this.gridster.pixelsToPositionX(this.right + marginRight, Math.ceil);
3324
- };
3325
- handleEast = (e) => {
3326
- const newPosition = this.getNewEastPosition(e);
3327
- if (this.gridsterItem.$item.x + this.gridsterItem.$item.cols !== newPosition) {
3328
- this.makeItemBackup();
3329
- this.gridsterItem.$item.cols = newPosition - this.gridsterItem.$item.x;
3330
- if (!this.check(this.pushResize.fromWest)) {
3331
- return;
3332
- }
3333
- }
3334
- this.setItemWidth(this.width);
3335
- };
3336
- handleNorthWest = (e) => {
3337
- const newNorth = this.getNewNorthPosition(e);
3338
- const newWest = this.getNewWestPosition(e);
3339
- if (this.gridsterItem.$item.y !== newNorth || this.gridsterItem.$item.x !== newWest) {
3340
- this.makeItemBackup();
3341
- this.gridsterItem.$item.rows += this.gridsterItem.$item.y - newNorth;
3342
- this.gridsterItem.$item.y = newNorth;
3343
- this.gridsterItem.$item.cols += this.gridsterItem.$item.x - newWest;
3344
- this.gridsterItem.$item.x = newWest;
3345
- if (!this.check(this.pushResize.fromSouth)) {
3346
- return;
3347
- }
3348
- }
3349
- this.setItemTop(this.top);
3350
- this.setItemHeight(this.height);
3351
- this.setItemLeft(this.left);
3352
- this.setItemWidth(this.width);
3353
- };
3354
- handleNorthEast = (e) => {
3355
- const newNorth = this.getNewNorthPosition(e);
3356
- const newEast = this.getNewEastPosition(e);
3357
- if (this.gridsterItem.$item.y !== newNorth || this.gridsterItem.$item.x + this.gridsterItem.$item.cols !== newEast) {
3358
- this.makeItemBackup();
3359
- this.gridsterItem.$item.rows += this.gridsterItem.$item.y - newNorth;
3360
- this.gridsterItem.$item.y = newNorth;
3361
- this.gridsterItem.$item.cols = newEast - this.gridsterItem.$item.x;
3362
- if (!this.check(this.pushResize.fromSouth)) {
3363
- return;
3364
- }
3365
- }
3366
- this.setItemTop(this.top);
3367
- this.setItemHeight(this.height);
3368
- this.setItemWidth(this.width);
3369
- };
3370
- handleSouthWest = (e) => {
3371
- const newSouth = this.getNewSouthPosition(e);
3372
- const newWest = this.getNewWestPosition(e);
3373
- if (this.gridsterItem.$item.y + this.gridsterItem.$item.rows !== newSouth || this.gridsterItem.$item.x !== newWest) {
3374
- this.makeItemBackup();
3375
- this.gridsterItem.$item.rows = newSouth - this.gridsterItem.$item.y;
3376
- this.gridsterItem.$item.cols += this.gridsterItem.$item.x - newWest;
3377
- this.gridsterItem.$item.x = newWest;
3378
- if (!this.check(this.pushResize.fromNorth)) {
3379
- return;
3380
- }
3381
- }
3382
- this.setItemLeft(this.left);
3383
- this.setItemHeight(this.height);
3384
- this.setItemWidth(this.width);
3385
- };
3386
- handleSouthEast = (e) => {
3387
- const newSouth = this.getNewSouthPosition(e);
3388
- const newEast = this.getNewEastPosition(e);
3389
- if (this.gridsterItem.$item.y + this.gridsterItem.$item.rows !== newSouth || this.gridsterItem.$item.x + this.gridsterItem.$item.cols !== newEast) {
3390
- this.makeItemBackup();
3391
- this.gridsterItem.$item.rows = newSouth - this.gridsterItem.$item.y;
3392
- this.gridsterItem.$item.cols = newEast - this.gridsterItem.$item.x;
3393
- if (!this.check(this.pushResize.fromNorth)) {
3394
- return;
3395
- }
3396
- }
3397
- this.setItemHeight(this.height);
3398
- this.setItemWidth(this.width);
3399
- };
3400
- makeItemBackup() {
3401
- this.itemBackup.x = this.gridsterItem.$item.x;
3402
- this.itemBackup.y = this.gridsterItem.$item.y;
3403
- this.itemBackup.cols = this.gridsterItem.$item.cols;
3404
- this.itemBackup.rows = this.gridsterItem.$item.rows;
3405
- }
3406
- resetItem(soft = false) {
3407
- if (this.gridsterItem.$item.x !== this.itemBackup.x) {
3408
- this.gridsterItem.$item.x = this.itemBackup.x;
3409
- if (!soft) {
3410
- this.left = this.gridster.positionXToPixels(this.gridsterItem.$item.x);
3411
- this.setItemLeft(this.left);
3412
- }
3413
- }
3414
- if (this.gridsterItem.$item.y !== this.itemBackup.y) {
3415
- this.gridsterItem.$item.y = this.itemBackup.y;
3416
- if (!soft) {
3417
- this.top = this.gridster.positionYToPixels(this.gridsterItem.$item.y);
3418
- this.setItemTop(this.top);
3419
- }
3420
- }
3421
- if (this.gridsterItem.$item.cols !== this.itemBackup.cols) {
3422
- this.gridsterItem.$item.cols = this.itemBackup.cols;
3423
- if (!soft) {
3424
- this.setItemWidth(this.gridster.positionXToPixels(this.gridsterItem.$item.cols) - this.margin);
3425
- }
3426
- }
3427
- if (this.gridsterItem.$item.rows !== this.itemBackup.rows) {
3428
- this.gridsterItem.$item.rows = this.itemBackup.rows;
3429
- if (!soft) {
3430
- this.setItemHeight(this.gridster.positionYToPixels(this.gridsterItem.$item.rows) - this.margin);
3431
- }
3432
- }
3433
- }
3434
- toggle() {
3435
- this.resizeEnabled = this.gridsterItem.canBeResized();
3436
- this.resizableHandles = this.gridsterItem.getResizableHandles();
3437
- }
3438
- dragStartDelay(e) {
3439
- GridsterUtils.checkTouchEvent(e);
3440
- if (!this.gridster.$options.resizable.delayStart) {
3441
- this.dragStart(e);
3442
- return;
3443
- }
3444
- const timeout = setTimeout(() => {
3445
- this.dragStart(e);
3446
- cancelDrag();
3447
- }, this.gridster.$options.resizable.delayStart);
3448
- const { cancelMouse, cancelMouseLeave, cancelOnBlur, cancelTouchMove, cancelTouchEnd, cancelTouchCancel } = this.zone.runOutsideAngular(() => {
3449
- const cancelMouse2 = this.gridsterItem.renderer.listen("document", "mouseup", cancelDrag);
3450
- const cancelMouseLeave2 = this.gridsterItem.renderer.listen("document", "mouseleave", cancelDrag);
3451
- const cancelOnBlur2 = this.gridsterItem.renderer.listen("window", "blur", cancelDrag);
3452
- const cancelTouchMove2 = this.gridsterItem.renderer.listen("document", "touchmove", cancelMove);
3453
- const cancelTouchEnd2 = this.gridsterItem.renderer.listen("document", "touchend", cancelDrag);
3454
- const cancelTouchCancel2 = this.gridsterItem.renderer.listen("document", "touchcancel", cancelDrag);
3455
- return {
3456
- cancelMouse: cancelMouse2,
3457
- cancelMouseLeave: cancelMouseLeave2,
3458
- cancelOnBlur: cancelOnBlur2,
3459
- cancelTouchMove: cancelTouchMove2,
3460
- cancelTouchEnd: cancelTouchEnd2,
3461
- cancelTouchCancel: cancelTouchCancel2
3462
- };
3463
- });
3464
- function cancelMove(eventMove) {
3465
- GridsterUtils.checkTouchEvent(eventMove);
3466
- if (Math.abs(eventMove.clientX - e.clientX) > 9 || Math.abs(eventMove.clientY - e.clientY) > 9) {
3467
- cancelDrag();
3468
- }
3469
- }
3470
- function cancelDrag() {
3471
- clearTimeout(timeout);
3472
- cancelOnBlur();
3473
- cancelMouse();
3474
- cancelMouseLeave();
3475
- cancelTouchMove();
3476
- cancelTouchEnd();
3477
- cancelTouchCancel();
3478
- }
3479
- }
3480
- setItemTop(top) {
3481
- this.gridster.gridRenderer.setCellPosition(this.gridsterItem.renderer, this.gridsterItem.el, this.left, top);
3482
- }
3483
- setItemLeft(left) {
3484
- this.gridster.gridRenderer.setCellPosition(this.gridsterItem.renderer, this.gridsterItem.el, left, this.top);
3485
- }
3486
- setItemHeight(height) {
3487
- this.gridsterItem.renderer.setStyle(this.gridsterItem.el, "height", height + "px");
3488
- }
3489
- setItemWidth(width) {
3490
- this.gridsterItem.renderer.setStyle(this.gridsterItem.el, "width", width + "px");
3491
- }
3492
- /**
3493
- * Enforces the aspect ratio by recalculating grid positions based on current pixel dimensions
3494
- */
3495
- enforceAspectRatio() {
3496
- const aspectRatio = this.gridsterItem.$item.itemAspectRatio || this.gridster.$options.itemAspectRatio;
3497
- if (!aspectRatio) {
3498
- return;
3499
- }
3500
- const targetRatio = aspectRatio * (this.gridster.curColWidth / this.gridster.curRowHeight);
3501
- const minCols = this.gridsterItem.$item.minItemCols || this.gridster.$options.minItemCols;
3502
- const minRows = this.gridsterItem.$item.minItemRows || this.gridster.$options.minItemRows;
3503
- const minWidth = this.gridster.positionXToPixels(minCols) - this.margin;
3504
- const minHeight = this.gridster.positionYToPixels(minRows) - this.margin;
3505
- const maxCols = this.gridsterItem.$item.maxItemCols || this.gridster.$options.maxItemCols || 0;
3506
- const maxRows = this.gridsterItem.$item.maxItemRows || this.gridster.$options.maxItemRows || 0;
3507
- const maxWidth = maxCols ? this.gridster.positionXToPixels(maxCols) - this.margin : Number.MAX_VALUE;
3508
- const maxHeight = maxRows ? this.gridster.positionYToPixels(maxRows) - this.margin : Number.MAX_VALUE;
3509
- let newWidth = this.width;
3510
- let newHeight = this.height;
3511
- if (this.resizeEventScrollType.north || this.resizeEventScrollType.south) {
3512
- newWidth = this.height * targetRatio;
3513
- if (newWidth < minWidth) {
3514
- newWidth = minWidth;
3515
- newHeight = minWidth / targetRatio;
3516
- } else if (newWidth > maxWidth) {
3517
- newWidth = maxWidth;
3518
- newHeight = maxWidth / targetRatio;
3519
- }
3520
- } else if (this.resizeEventScrollType.east || this.resizeEventScrollType.west) {
3521
- newHeight = this.width / targetRatio;
3522
- if (newHeight < minHeight) {
3523
- newHeight = minHeight;
3524
- newWidth = minHeight * targetRatio;
3525
- } else if (newHeight > maxHeight) {
3526
- newHeight = maxHeight;
3527
- newWidth = maxHeight * targetRatio;
3528
- }
3529
- }
3530
- if (this.gridster.options.enableBoundaryControl) {
3531
- const box = this.gridster.el.getBoundingClientRect();
3532
- const margin = Math.max(this.outerMarginTop || this.margin, this.outerMarginRight || this.margin, this.outerMarginBottom || this.margin, this.outerMarginLeft || this.margin);
3533
- const maxRight = box.width - 2 * margin;
3534
- const maxBottom = box.height - 2 * margin;
3535
- if (this.resizeEventScrollType.west) {
3536
- if (this.right - newWidth < 0) {
3537
- newWidth = this.right;
3538
- newHeight = newWidth / targetRatio;
3539
- }
3540
- } else if (this.resizeEventScrollType.east) {
3541
- if (this.left + newWidth > maxRight) {
3542
- newWidth = maxRight - this.left;
3543
- newHeight = newWidth / targetRatio;
3544
- }
3545
- }
3546
- if (this.resizeEventScrollType.north) {
3547
- if (this.bottom - newHeight < 0) {
3548
- newHeight = this.bottom;
3549
- newWidth = newHeight * targetRatio;
3550
- }
3551
- } else if (this.resizeEventScrollType.south) {
3552
- if (this.top + newHeight > maxBottom) {
3553
- newHeight = maxBottom - this.top;
3554
- newWidth = newHeight * targetRatio;
3555
- }
3556
- }
3557
- }
3558
- this.width = newWidth;
3559
- this.height = newHeight;
3560
- if (this.resizeEventScrollType.west) {
3561
- this.left = this.right - this.width;
3562
- }
3563
- if (this.resizeEventScrollType.north) {
3564
- this.top = this.bottom - this.height;
3565
- }
3566
- const marginLeft = this.gridster.options.pushItems ? 0 : this.margin;
3567
- const marginTop = this.gridster.options.pushItems ? 0 : this.margin;
3568
- const marginRight = this.gridster.options.pushItems ? this.margin : 0;
3569
- const marginBottom = this.gridster.options.pushItems ? this.margin : 0;
3570
- this.gridsterItem.$item.x = this.gridster.pixelsToPositionX(this.left + marginLeft, Math.floor);
3571
- this.gridsterItem.$item.y = this.gridster.pixelsToPositionY(this.top + marginTop, Math.floor);
3572
- this.gridsterItem.$item.cols = this.gridster.pixelsToPositionX(this.width + marginRight, Math.ceil);
3573
- this.gridsterItem.$item.rows = this.gridster.pixelsToPositionY(this.height + marginBottom, Math.ceil);
3574
- this.setItemTop(this.top);
3575
- this.setItemLeft(this.left);
3576
- this.setItemWidth(this.width);
3577
- this.setItemHeight(this.height);
3578
- }
3579
- };
3580
- var GridsterItemComponent = class _GridsterItemComponent {
3581
- renderer;
3582
- zone;
3583
- item;
3584
- itemInit = new EventEmitter();
3585
- itemChange = new EventEmitter();
3586
- itemResize = new EventEmitter();
3587
- $item;
3588
- el;
3589
- gridster;
3590
- top;
3591
- left;
3592
- width;
3593
- height;
3594
- drag;
3595
- resize;
3596
- notPlaced;
3597
- init;
3598
- get zIndex() {
3599
- return this.getLayerIndex() + this.gridster.$options.baseLayerIndex;
3600
- }
3601
- constructor(el, gridster, renderer, zone) {
3602
- this.renderer = renderer;
3603
- this.zone = zone;
3604
- this.el = el.nativeElement;
3605
- this.$item = {
3606
- cols: -1,
3607
- rows: -1,
3608
- x: -1,
3609
- y: -1
3610
- };
3611
- this.gridster = gridster;
3612
- this.drag = new GridsterDraggable(this, gridster, this.zone);
3613
- this.resize = new GridsterResizable(this, gridster, this.zone);
3614
- }
3615
- ngOnInit() {
3616
- this.gridster.addItem(this);
3617
- }
3618
- ngOnChanges(changes) {
3619
- if (changes.item) {
3620
- this.updateOptions();
3621
- if (!this.init) {
3622
- this.gridster.calculateLayout$.next();
3623
- }
3624
- }
3625
- if (changes.item && changes.item.previousValue) {
3626
- this.setSize();
3627
- }
3628
- }
3629
- updateOptions() {
3630
- this.$item = GridsterUtils.merge(this.$item, this.item, {
3631
- cols: void 0,
3632
- rows: void 0,
3633
- x: void 0,
3634
- y: void 0,
3635
- layerIndex: void 0,
3636
- dragEnabled: void 0,
3637
- resizeEnabled: void 0,
3638
- compactEnabled: void 0,
3639
- itemAspectRatio: void 0,
3640
- maxItemRows: void 0,
3641
- minItemRows: void 0,
3642
- maxItemCols: void 0,
3643
- minItemCols: void 0,
3644
- maxItemArea: void 0,
3645
- minItemArea: void 0,
3646
- resizableHandles: {
3647
- s: void 0,
3648
- e: void 0,
3649
- n: void 0,
3650
- w: void 0,
3651
- se: void 0,
3652
- ne: void 0,
3653
- sw: void 0,
3654
- nw: void 0
3655
- }
3656
- });
3657
- }
3658
- ngOnDestroy() {
3659
- this.gridster.removeItem(this);
3660
- this.drag.destroy();
3661
- this.resize.destroy();
3662
- this.gridster = this.drag = this.resize = null;
3663
- }
3664
- setSize() {
3665
- this.renderer.setStyle(this.el, "display", this.notPlaced ? "" : "block");
3666
- this.gridster.gridRenderer.updateItem(this.el, this.$item, this.renderer);
3667
- this.updateItemSize();
3668
- }
3669
- updateItemSize() {
3670
- const top = this.$item.y * this.gridster.curRowHeight;
3671
- const left = this.$item.x * this.gridster.curColWidth;
3672
- const width = this.$item.cols * this.gridster.curColWidth - this.gridster.$options.margin;
3673
- const height = this.$item.rows * this.gridster.curRowHeight - this.gridster.$options.margin;
3674
- this.top = top;
3675
- this.left = left;
3676
- if (!this.init && width > 0 && height > 0) {
3677
- this.init = true;
3678
- if (this.item.initCallback) {
3679
- this.item.initCallback(this.item, this);
3680
- }
3681
- if (this.gridster.options.itemInitCallback) {
3682
- this.gridster.options.itemInitCallback(this.item, this);
3683
- }
3684
- this.itemInit.next({ item: this.item, itemComponent: this });
3685
- if (this.gridster.$options.scrollToNewItems) {
3686
- this.el.scrollIntoView({
3687
- block: "end",
3688
- inline: "nearest",
3689
- behavior: "smooth"
3690
- });
3691
- }
3692
- }
3693
- if (width !== this.width || height !== this.height) {
3694
- this.width = width;
3695
- this.height = height;
3696
- if (this.gridster.options.itemResizeCallback) {
3697
- this.gridster.options.itemResizeCallback(this.item, this);
3698
- }
3699
- this.itemResize.next({ item: this.item, itemComponent: this });
3700
- }
3701
- }
3702
- itemChanged() {
3703
- if (this.gridster.options.itemChangeCallback) {
3704
- this.gridster.options.itemChangeCallback(this.item, this);
3705
- }
3706
- this.itemChange.next({ item: this.item, itemComponent: this });
3707
- }
3708
- checkItemChanges(newValue, oldValue) {
3709
- if (newValue.rows === oldValue.rows && newValue.cols === oldValue.cols && newValue.x === oldValue.x && newValue.y === oldValue.y) {
3710
- return;
3711
- }
3712
- if (this.gridster.checkCollision(this.$item)) {
3713
- this.$item.x = oldValue.x || 0;
3714
- this.$item.y = oldValue.y || 0;
3715
- this.$item.cols = oldValue.cols || 1;
3716
- this.$item.rows = oldValue.rows || 1;
3717
- this.setSize();
3718
- } else {
3719
- this.item.cols = this.$item.cols;
3720
- this.item.rows = this.$item.rows;
3721
- this.item.x = this.$item.x;
3722
- this.item.y = this.$item.y;
3723
- this.gridster.calculateLayout$.next();
3724
- this.itemChanged();
3725
- }
3726
- }
3727
- canBeDragged() {
3728
- const gridDragEnabled = this.gridster.$options.draggable.enabled;
3729
- const itemDragEnabled = this.$item.dragEnabled === void 0 ? gridDragEnabled : this.$item.dragEnabled;
3730
- return !this.gridster.mobile && gridDragEnabled && itemDragEnabled;
3731
- }
3732
- canBeResized() {
3733
- const gridResizable = this.gridster.$options.resizable.enabled;
3734
- const itemResizable = this.$item.resizeEnabled === void 0 ? gridResizable : this.$item.resizeEnabled;
3735
- return !this.gridster.mobile && gridResizable && itemResizable;
3736
- }
3737
- getResizableHandles() {
3738
- const gridResizableHandles = this.gridster.$options.resizable.handles;
3739
- const itemResizableHandles = this.$item.resizableHandles;
3740
- if (itemResizableHandles === void 0) {
3741
- return gridResizableHandles;
3742
- }
3743
- return __spreadValues(__spreadValues({}, gridResizableHandles), itemResizableHandles);
3744
- }
3745
- bringToFront(offset) {
3746
- if (offset && offset <= 0) {
3747
- return;
3748
- }
3749
- const layerIndex = this.getLayerIndex();
3750
- const topIndex = this.gridster.$options.maxLayerIndex;
3751
- if (layerIndex < topIndex) {
3752
- const targetIndex = offset ? layerIndex + offset : topIndex;
3753
- this.item.layerIndex = this.$item.layerIndex = targetIndex > topIndex ? topIndex : targetIndex;
3754
- }
3755
- }
3756
- sendToBack(offset) {
3757
- if (offset && offset <= 0) {
3758
- return;
3759
- }
3760
- const layerIndex = this.getLayerIndex();
3761
- if (layerIndex > 0) {
3762
- const targetIndex = offset ? layerIndex - offset : 0;
3763
- this.item.layerIndex = this.$item.layerIndex = targetIndex < 0 ? 0 : targetIndex;
3764
- }
3765
- }
3766
- getLayerIndex() {
3767
- if (this.item.layerIndex !== void 0) {
3768
- return this.item.layerIndex;
3769
- }
3770
- if (this.gridster.$options.defaultLayerIndex !== void 0) {
3771
- return this.gridster.$options.defaultLayerIndex;
3772
- }
3773
- return 0;
3774
- }
3775
- static \u0275fac = \u0275\u0275ngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: core_exports, type: _GridsterItemComponent, deps: [{ token: ElementRef }, { token: GridsterComponent }, { token: Renderer2 }, { token: NgZone }], target: FactoryTarget.Component });
3776
- static \u0275cmp = \u0275\u0275ngDeclareComponent({ minVersion: "17.0.0", version: "20.3.13", type: _GridsterItemComponent, isStandalone: true, selector: "gridster-item", inputs: { item: "item" }, outputs: { itemInit: "itemInit", itemChange: "itemChange", itemResize: "itemResize" }, host: { properties: { "style.z-index": "this.zIndex" } }, usesOnChanges: true, ngImport: core_exports, template: '<ng-content></ng-content>\n@if (resize.resizableHandles?.s && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-s"\n></div>\n} @if (resize.resizableHandles?.e && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-e"\n></div>\n} @if (resize.resizableHandles?.n && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-n"\n></div>\n} @if (resize.resizableHandles?.w && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-w"\n></div>\n} @if (resize.resizableHandles?.se && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-se"\n></div>\n} @if (resize.resizableHandles?.ne && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-ne"\n></div>\n} @if (resize.resizableHandles?.sw && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-sw"\n></div>\n} @if (resize.resizableHandles?.nw && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-nw"\n></div>\n}\n', styles: ["gridster-item{box-sizing:border-box;z-index:1;position:absolute;overflow:hidden;transition:.3s;display:none;background:#fff;-webkit-user-select:text;user-select:text}gridster-item.gridster-item-moving{cursor:move}gridster-item.gridster-item-resizing,gridster-item.gridster-item-moving{transition:0s;z-index:2;box-shadow:0 0 5px 5px #0003,0 6px 10px #00000024,0 1px 18px #0000001f}.gridster-item-resizable-handler{position:absolute;z-index:2}.gridster-item-resizable-handler.handle-n{cursor:ns-resize;height:10px;right:0;top:0;left:0}.gridster-item-resizable-handler.handle-e{cursor:ew-resize;width:10px;bottom:0;right:0;top:0}.gridster-item-resizable-handler.handle-s{cursor:ns-resize;height:10px;right:0;bottom:0;left:0}.gridster-item-resizable-handler.handle-w{cursor:ew-resize;width:10px;left:0;top:0;bottom:0}.gridster-item-resizable-handler.handle-ne{cursor:ne-resize;width:10px;height:10px;right:0;top:0}.gridster-item-resizable-handler.handle-nw{cursor:nw-resize;width:10px;height:10px;left:0;top:0}.gridster-item-resizable-handler.handle-se{cursor:se-resize;width:0;height:0;right:0;bottom:0;border-style:solid;border-width:0 0 10px 10px;border-color:transparent}.gridster-item-resizable-handler.handle-sw{cursor:sw-resize;width:10px;height:10px;left:0;bottom:0}gridster-item:hover .gridster-item-resizable-handler.handle-se{border-color:transparent transparent #ccc}\n"], encapsulation: ViewEncapsulation.None });
3777
- };
3778
- \u0275\u0275ngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: core_exports, type: GridsterItemComponent, decorators: [{
3779
- type: Component,
3780
- args: [{ selector: "gridster-item", encapsulation: ViewEncapsulation.None, standalone: true, template: '<ng-content></ng-content>\n@if (resize.resizableHandles?.s && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-s"\n></div>\n} @if (resize.resizableHandles?.e && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-e"\n></div>\n} @if (resize.resizableHandles?.n && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-n"\n></div>\n} @if (resize.resizableHandles?.w && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-w"\n></div>\n} @if (resize.resizableHandles?.se && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-se"\n></div>\n} @if (resize.resizableHandles?.ne && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-ne"\n></div>\n} @if (resize.resizableHandles?.sw && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-sw"\n></div>\n} @if (resize.resizableHandles?.nw && resize.resizeEnabled) {\n<div\n (mousedown)="resize.dragStartDelay($event)"\n (touchstart)="resize.dragStartDelay($event)"\n class="gridster-item-resizable-handler handle-nw"\n></div>\n}\n', styles: ["gridster-item{box-sizing:border-box;z-index:1;position:absolute;overflow:hidden;transition:.3s;display:none;background:#fff;-webkit-user-select:text;user-select:text}gridster-item.gridster-item-moving{cursor:move}gridster-item.gridster-item-resizing,gridster-item.gridster-item-moving{transition:0s;z-index:2;box-shadow:0 0 5px 5px #0003,0 6px 10px #00000024,0 1px 18px #0000001f}.gridster-item-resizable-handler{position:absolute;z-index:2}.gridster-item-resizable-handler.handle-n{cursor:ns-resize;height:10px;right:0;top:0;left:0}.gridster-item-resizable-handler.handle-e{cursor:ew-resize;width:10px;bottom:0;right:0;top:0}.gridster-item-resizable-handler.handle-s{cursor:ns-resize;height:10px;right:0;bottom:0;left:0}.gridster-item-resizable-handler.handle-w{cursor:ew-resize;width:10px;left:0;top:0;bottom:0}.gridster-item-resizable-handler.handle-ne{cursor:ne-resize;width:10px;height:10px;right:0;top:0}.gridster-item-resizable-handler.handle-nw{cursor:nw-resize;width:10px;height:10px;left:0;top:0}.gridster-item-resizable-handler.handle-se{cursor:se-resize;width:0;height:0;right:0;bottom:0;border-style:solid;border-width:0 0 10px 10px;border-color:transparent}.gridster-item-resizable-handler.handle-sw{cursor:sw-resize;width:10px;height:10px;left:0;bottom:0}gridster-item:hover .gridster-item-resizable-handler.handle-se{border-color:transparent transparent #ccc}\n"] }]
3781
- }], ctorParameters: () => [{ type: ElementRef, decorators: [{
3782
- type: Inject,
3783
- args: [ElementRef]
3784
- }] }, { type: GridsterComponent }, { type: Renderer2, decorators: [{
3785
- type: Inject,
3786
- args: [Renderer2]
3787
- }] }, { type: NgZone, decorators: [{
3788
- type: Inject,
3789
- args: [NgZone]
3790
- }] }], propDecorators: { item: [{
3791
- type: Input
3792
- }], itemInit: [{
3793
- type: Output
3794
- }], itemChange: [{
3795
- type: Output
3796
- }], itemResize: [{
3797
- type: Output
3798
- }], zIndex: [{
3799
- type: HostBinding,
3800
- args: ["style.z-index"]
3801
- }] } });
3802
- var GridsterModule = class _GridsterModule {
3803
- static \u0275fac = \u0275\u0275ngDeclareFactory({ minVersion: "12.0.0", version: "20.3.13", ngImport: core_exports, type: _GridsterModule, deps: [], target: FactoryTarget.NgModule });
3804
- static \u0275mod = \u0275\u0275ngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.13", ngImport: core_exports, type: _GridsterModule, imports: [GridsterComponent, GridsterItemComponent], exports: [GridsterComponent, GridsterItemComponent] });
3805
- static \u0275inj = \u0275\u0275ngDeclareInjector({ minVersion: "12.0.0", version: "20.3.13", ngImport: core_exports, type: _GridsterModule });
3806
- };
3807
- \u0275\u0275ngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.13", ngImport: core_exports, type: GridsterModule, decorators: [{
3808
- type: NgModule,
3809
- args: [{
3810
- imports: [GridsterComponent, GridsterItemComponent],
3811
- exports: [GridsterComponent, GridsterItemComponent]
3812
- }]
3813
- }] });
3814
-
3815
- // angular:jit:style:inline:src\app\pages\dashboard\components\widget-host\widget-host.component.ts;CiAgICA6aG9zdCB7IGRpc3BsYXk6YmxvY2s7IHdpZHRoOjEwMCU7IGhlaWdodDoxMDAlOyB9CiAgICAud2lkZ2V0LXNoZWxsIHsgd2lkdGg6MTAwJTsgaGVpZ2h0OjEwMCU7IH0KICAgIC53aWRnZXQtc2hlbGxbZGF0YS1maXQ9InNjcm9sbCJdIHsgb3ZlcmZsb3c6IGF1dG87IH0KICAgIC53aWRnZXQtc2hlbGxbZGF0YS1maXQ9InJlc3BvbnNpdmUiXSB7IG92ZXJmbG93OiBoaWRkZW47IH0KICAgIC53aWRnZXQtc2hlbGxbZGF0YS1maXQ9InNjYWxlIl0geyBvdmVyZmxvdzogaGlkZGVuOyB9CiAgICAud2lkZ2V0LXNjYWxlIHsgd2lkdGg6MTAwJTsgaGVpZ2h0OjEwMCU7IH0KICAgIA==
3816
- var widget_host_component_default = "/* angular:styles/component:less;eedd081fc02c0d27f6ae4957e9501c8e6c07e15b995f5314c47fc7628829f6cd;D:\\ng-manager\\webapp\\src\\app\\pages\\dashboard\\components\\widget-host\\widget-host.component.ts */\n:host {\n display: block;\n width: 100%;\n height: 100%;\n}\n.widget-shell {\n width: 100%;\n height: 100%;\n}\n.widget-shell[data-fit=scroll] {\n overflow: auto;\n}\n.widget-shell[data-fit=responsive] {\n overflow: hidden;\n}\n.widget-shell[data-fit=scale] {\n overflow: hidden;\n}\n.widget-scale {\n width: 100%;\n height: 100%;\n}\n/*# sourceMappingURL=widget-host.component.css.map */\n";
3817
-
3818
- // angular:jit:style:inline:src\app\pages\dashboard\components\widgets\kill-port\kill-port-widget.component.ts;CiAgICAgIC5sb2dvIHsKICAgICAgICBkaXNwbGF5OiBmbGV4OwogICAgICAgIGFsaWduLWl0ZW1zOiBjZW50ZXI7CiAgICAgICAgZ2FwOiA4cHg7CiAgICAgICAgcGFkZGluZzogMTJweCAyNHB4OwogICAgICAgIC5pY29uLXdyYXBwZXJ7CiAgICAgICAgICB3aWR0aDogMzJweDsKICAgICAgICAgIGhlaWdodDogMzJweDsKICAgICAgICAgIGZsZXg6IDAgMCBhdXRvOwogICAgICAgICAgZGlzcGxheTogZmxleDsKICAgICAgICAgIGFsaWduLWl0ZW1zOiBjZW50ZXI7CiAgICAgICAgICBqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjsKICAgICAgICAgIGJhY2tncm91bmQtY29sb3I6IHZhcigtLWFwcC1ncmF5KTsKICAgICAgICAgIGJvcmRlci1yYWRpdXM6IDUwJSA1MCU7CiAgICAgICAgICBuei1pY29uIHsKICAgICAgICAgICAgZm9udC1zaXplOiAyMHB4OwogICAgICAgICAgIGNvbG9yOiB2YXIoLS1hcHAtcHJpbWFyeS01KTsKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaDN7CiAgICAgICAgICBmbGV4OjEgMSBhdXRvOwogICAgICAgICAgZm9udC1zaXplOiAxOHB4OwogICAgICAgICAgbWFyZ2luOiAwOwogICAgICAgICAgZm9udC13ZWlnaHQ6IDUwMDsKICAgICAgICB9CiAgICAgIH0KICAgIA==
3819
- var kill_port_widget_component_default = "/* angular:styles/component:less;e7a36c16014557c6fe4d8b012f4dd11a3014b7fe15e959c779063758022e9dcd;D:\\ng-manager\\webapp\\src\\app\\pages\\dashboard\\components\\widgets\\kill-port\\kill-port-widget.component.ts */\n.logo {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 12px 24px;\n}\n.logo .icon-wrapper {\n width: 32px;\n height: 32px;\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: var(--app-gray);\n border-radius: 50% 50%;\n}\n.logo .icon-wrapper nz-icon {\n font-size: 20px;\n color: var(--app-primary-5);\n}\n.logo h3 {\n flex: 1 1 auto;\n font-size: 18px;\n margin: 0;\n font-weight: 500;\n}\n/*# sourceMappingURL=kill-port-widget.component.css.map */\n";
3820
-
3821
- // angular:jit:style:inline:src\app\pages\dashboard\components\widgets\widget-base.component.ts;CiAgICA6aG9zdCB7CiAgICAgICAgZGlzcGxheTogYmxvY2s7CiAgICAgICAgaGVpZ2h0OiAxMDAlOwogICAgfQoKICAgIC53aWRnZXQgewogICAgICAgIGhlaWdodDogMTAwJTsKICAgICAgICBwYWRkaW5nOiAxMnB4IDA7CiAgICAgICAgZGlzcGxheTogZmxleDsKICAgICAgICBmbGV4LWRpcmVjdGlvbjogY29sdW1uOwogICAgfQogICAgLmhlYWRlciB7CiAgICAgICAgZmxleCA6IDAgMCBhdXRvOwogICAgICAgIHBhZGRpbmc6MCAgMTZweDsKICAgICAgICBkaXNwbGF5OiBmbGV4OwogICAgICAgIGFsaWduLWl0ZW1zOiBjZW50ZXI7CiAgICAgICAganVzdGlmeS1jb250ZW50OiBzcGFjZS1iZXR3ZWVuOwogICAgfQogICAgLnRpdGxlIHsKICAgICAgICBmb250LXNpemU6IDE4cHg7CiAgICAgICAgZm9udC13ZWlnaHQ6IDYwMDsKICAgICAgICBmbGV4OiAxIDEgYXV0bzsKICAgICAgICBvcGFjaXR5OiAwLjU7CiAgICB9CgogICAgLmFjdGlvbnMgewogICAgICAgIGZsZXg6IDAgMCBhdXRvOwogICAgfQoKICAgIC5jb250ZW50IHsKICAgICAgICBmbGV4OiAxIDEgYXV0bzsKICAgICAgICBkaXNwbGF5OiBmbGV4OwogICAgICAgIGZsZXgtZGlyZWN0aW9uOiBjb2x1bW47CiAgICAgICAgd2lkdGg6IDEwMCU7CiAgICAgICAgaGVpZ2h0OiAwOwogICAgICAgIG92ZXJmbG93OiBoaWRkZW47IAogICAgfQogIA==
3822
- var widget_base_component_default = "/* angular:styles/component:less;2c8ea08b71cb50bfb6e4b8048c789ba51268fb2af60482ef9226740649d8d8de;D:\\ng-manager\\webapp\\src\\app\\pages\\dashboard\\components\\widgets\\widget-base.component.ts */\n:host {\n display: block;\n height: 100%;\n}\n.widget {\n height: 100%;\n padding: 12px 0;\n display: flex;\n flex-direction: column;\n}\n.header {\n flex: 0 0 auto;\n padding: 0 16px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n.title {\n font-size: 18px;\n font-weight: 600;\n flex: 1 1 auto;\n opacity: 0.5;\n}\n.actions {\n flex: 0 0 auto;\n}\n.content {\n flex: 1 1 auto;\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 0;\n overflow: hidden;\n}\n/*# sourceMappingURL=widget-base.component.css.map */\n";
3823
-
3824
- // src/app/pages/dashboard/components/widgets/widget-base.component.ts
3825
- var WidgetBaseComponent = class WidgetBaseComponent2 {
3826
- item;
3827
- static propDecorators = {
3828
- item: [{ type: Input }]
3829
- };
3830
- };
3831
- WidgetBaseComponent = __decorate([
3832
- Component({
3833
- selector: "app-widget-base",
3834
- imports: [CommonModule, NzButtonModule, NzIconModule],
3835
- template: `
3836
- <div class="widget">
3837
- <div class="header">
3838
- <div class="title">{{ item.title }}</div>
3839
- @if(item.configurable){
3840
- <div class="actions">
3841
- <ng-content select="actions"></ng-content>
3842
- </div>
3843
- }
3844
- </div>
3845
- <div class="content">
3846
- <ng-content></ng-content>
3847
- </div>
3848
- </div>
3849
- `,
3850
- styles: [widget_base_component_default]
3851
- })
3852
- ], WidgetBaseComponent);
3853
-
3854
- // src/app/pages/dashboard/components/widgets/kill-port/kill-port-widget.component.ts
3855
- var KillPortWidgetComponent = class KillPortWidgetComponent2 {
3856
- item;
3857
- port = "";
3858
- api = inject(DashboardApiService);
3859
- msg = inject(NzMessageService);
3860
- spin = signal(false);
3861
- isPortValid() {
3862
- const portNumber = Number(this.port);
3863
- return Number.isInteger(portNumber) && portNumber > 0 && portNumber <= 65535;
3864
- }
3865
- killPort() {
3866
- if (!this.isPortValid()) {
3867
- this.msg.error("\u8BF7\u8F93\u5165\u6709\u6548\u7684\u7AEF\u53E3\u53F7\uFF081-65535\uFF09");
3868
- return;
3869
- }
3870
- this.spin.set(true);
3871
- this.api.killPort(Number(this.port)).subscribe({
3872
- next: (res) => {
3873
- if (res.killed.length === 0) {
3874
- this.msg.info(`\u7AEF\u53E3 ${this.port} \u6CA1\u6709\u88AB\u4EFB\u4F55\u8FDB\u7A0B\u5360\u7528`);
3875
- return;
3876
- }
3877
- this.port = "";
3878
- this.msg.success(`\u7AEF\u53E3 ${this.port} \u5DF2\u88AB\u7EC8\u6B62`);
3879
- },
3880
- error: (err) => {
3881
- console.error("Kill port error", err);
3882
- this.msg.error(`\u65E0\u6CD5\u7EC8\u6B62\u7AEF\u53E3 ${this.port}\uFF1A${err.message || err}`);
3883
- },
3884
- complete: () => {
3885
- this.spin.set(false);
3886
- }
3887
- });
3888
- }
3889
- static propDecorators = {
3890
- item: [{ type: Input }]
3891
- };
3892
- };
3893
- KillPortWidgetComponent = __decorate([
3894
- Component({
3895
- selector: "app-kill-port-widget",
3896
- changeDetection: ChangeDetectionStrategy.OnPush,
3897
- imports: [
3898
- CommonModule,
3899
- FormsModule,
3900
- WidgetBaseComponent,
3901
- NzIconModule,
3902
- NzInputModule,
3903
- NzSpaceModule,
3904
- NzButtonModule
3905
- ],
3906
- template: `
3907
- <app-widget-base [item]="item">
3908
- <div class="logo">
3909
- <div class="icon-wrapper">
3910
- <nz-icon nzType="thunderbolt" nzTheme="outline" />
3911
- </div>
3912
- <h3>\u51C6\u5907\u597D\u7EC8\u6B62</h3>
3913
- </div>
3914
- <nz-space style="padding: 12px 24px;">
3915
- <input nz-input placeholder="\u8F93\u5165\u4E00\u4E2A\u7F51\u7EDC\u7AEF\u53E3" name="port" [(ngModel)]="port" (keydown.enter)="killPort()" />
3916
- <button nz-button nzType="primary" (click)="killPort()">
3917
- <nz-icon [nzType]="spin()?'loading' : 'thunderbolt'" nzTheme="outline" />
3918
- \u7EC8\u6B62
3919
- </button>
3920
- </nz-space>
3921
- </app-widget-base>
3922
- `,
3923
- styles: [kill_port_widget_component_default]
3924
- })
3925
- ], KillPortWidgetComponent);
3926
-
3927
- // angular:jit:template:src\app\pages\dashboard\components\widgets\news-feed\news-feed-widget.component.html
3928
- var news_feed_widget_component_default = `<app-widget-base [item]="item">\r
3929
- <ng-container ngProjectAs="actions">\r
3930
- <button nz-button nzType="link" nzSize="small" (click)="reload()">\r
3931
- <nz-icon [nzType]="loading() ? 'loading' : 'reload'" nzTheme="outline" />\r
3932
- </button>\r
3933
- <button nz-button nzType="link" nzSize="small" (click)="openConfig()">\r
3934
- <nz-icon nzType="setting" nzTheme="outline" />\r
3935
- </button>\r
3936
- <!-- <button nz-button nzType="link" nzSize="small">\r
3937
- <nz-icon nzType="fullscreen" nzTheme="outline" />\r
3938
- </button> -->\r
3939
- </ng-container>\r
3940
- <div class="news-feed-widget">\r
3941
- @if (!hasConfig()) {\r
3942
- <div class="empty">\r
3943
- <div class="hint">\u672A\u914D\u7F6E RSS \u6E90</div>\r
3944
- <button nz-button nzType="default" nzSize="small" (click)="openConfig()">\u53BB\u914D\u7F6E</button>\r
3945
- </div>\r
3946
- } @else {\r
3947
- @if (errorMsg()) {\r
3948
- <div class="error">\r
3949
- <p>{{ errorMsg() }}</p>\r
3950
- <button nz-button nzType="link" nzSize="small" (click)="reload(true)">\u91CD\u8BD5</button>\r
3951
- </div>\r
3952
- } @else {\r
3953
- <div class="list">\r
3954
- @for (it of feedItems(); track it.link) {\r
3955
- <a class="row" [href]="it.link" target="_blank" rel="noreferrer">\r
3956
- <div class="t">{{ it.title }}</div>\r
3957
- <div class="m">\r
3958
- @if (it.pubDate) {\r
3959
- <span class="d">{{ it.pubDate | date: 'yyyy-MM-dd HH:mm' }}</span>\r
3960
- }\r
3961
- @if (it.author) {\r
3962
- <span class="a">{{ it.author }}</span>\r
3963
- }\r
3964
- </div>\r
3965
- </a>\r
3966
- }\r
3967
- </div>\r
3968
- }\r
3969
- }\r
3970
- </div>\r
3971
- </app-widget-base>\r
3972
- <nz-modal\r
3973
- nzCentered\r
3974
- [(nzVisible)]="isModalVisible"\r
3975
- nzTitle="\u914D\u7F6E\u90E8\u4EF6"\r
3976
- (nzOnCancel)="isModalVisible.set(false)"\r
3977
- [nzMaskClosable]="false"\r
3978
- >\r
3979
- <ng-container *nzModalContent>\r
3980
- <div class="modal-body">\r
3981
- <label>RSS\u6E90\u5730\u5740</label>\r
3982
- <nz-input-wrapper>\r
3983
- <input nz-input placeholder="\u8BF7\u8F93\u5165RSS\u6E90\u5730\u5740" [(ngModel)]="rssUrl" style="width: 100%" />\r
3984
- <nz-icon nzType="global" nzTheme="outline" nzInputPrefix />\r
3985
- </nz-input-wrapper>\r
3986
- </div>\r
3987
- </ng-container>\r
3988
- \r
3989
- <ng-container *nzModalFooter>\r
3990
- <button nz-button nzType="primary" (click)="save()" [disabled]="!rssUrl().trim()">\u4FDD\u5B58</button>\r
3991
- </ng-container>\r
3992
- </nz-modal>\r
3993
- `;
3994
-
3995
- // angular:jit:style:src\app\pages\dashboard\components\widgets\news-feed\news-feed-widget.component.less
3996
- var news_feed_widget_component_default2 = "/* src/app/pages/dashboard/components/widgets/news-feed/news-feed-widget.component.less */\n.news-feed-widget {\n padding: 8px 12px;\n height: 100%;\n overflow: auto;\n}\n.empty {\n display: flex;\n flex-direction: column;\n gap: 8px;\n align-items: center;\n justify-content: center;\n height: 100%;\n opacity: 0.75;\n}\n.list {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.row {\n display: block;\n padding: 8px;\n border-radius: 8px;\n text-decoration: none;\n border: 1px solid rgba(0, 0, 0, 0.06);\n}\n.row:hover {\n background: rgba(0, 0, 0, 0.02);\n}\n.t {\n font-size: 13px;\n line-height: 1.3;\n color: rgba(0, 0, 0, 0.88);\n}\n.m {\n margin-top: 4px;\n display: flex;\n gap: 10px;\n font-size: 12px;\n color: rgba(0, 0, 0, 0.45);\n}\n.error {\n display: flex;\n gap: 8px;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n color: #d4380d;\n}\n.error p {\n width: 100%;\n white-space: pre-wrap;\n word-break: break-word;\n}\n.loading {\n display: flex;\n gap: 8px;\n align-items: center;\n opacity: 0.75;\n}\n.modal-body {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n}\n.modal-body label {\n flex: 0 0 auto;\n margin-right: 16px;\n display: inline-block;\n width: 100px;\n}\n.modal-body input {\n flex: 1;\n margin-left: 16px;\n}\n/*# sourceMappingURL=news-feed-widget.component.css.map */\n";
3997
-
3998
- // src/app/pages/dashboard/services/rss.service.ts
3999
- var RssService = class RssService2 {
4000
- api = inject(ApiClient);
4001
- /**
4002
- * 预览 RSS 订阅源
4003
- * @param url RSS 订阅源 URL
4004
- * @param opts 选项
4005
- * - limit: 限制返回的条目数量,默认 20
4006
- * - force: 是否强制刷新,默认 false
4007
- * - cacheSec: 缓存时间,单位秒,默认 300
4008
- * @returns RSS 订阅源内容
4009
- */
4010
- preview(url, opts) {
4011
- let params = new HttpParams().set("url", url);
4012
- if (opts?.limit)
4013
- params = params.set("limit", String(opts.limit));
4014
- if (opts?.cacheSec)
4015
- params = params.set("cacheSec", String(opts.cacheSec));
4016
- if (opts?.force)
4017
- params = params.set("force", "1");
4018
- return this.api.get("/api/rss/preview", params);
4019
- }
4020
- };
4021
- RssService = __decorate([
4022
- Injectable({
4023
- providedIn: "root"
4024
- })
4025
- ], RssService);
4026
-
4027
- // src/app/pages/dashboard/components/widgets/news-feed/news-feed-widget.component.ts
4028
- var NewsFeedWidgetComponent = class NewsFeedWidgetComponent2 {
4029
- item;
4030
- layout = inject(DashboardLayoutService);
4031
- rss = inject(RssService);
4032
- cdr = inject(ChangeDetectorRef);
4033
- curConfig = signal(null);
4034
- rssUrl = signal("");
4035
- isModalVisible = signal(false);
4036
- loading = signal(false);
4037
- feedTitle = signal("");
4038
- feedItems = signal([]);
4039
- errorMsg = signal("");
4040
- hasConfig = computed(() => !!this.curConfig()?.rssUrl?.trim());
4041
- ngOnChanges(changes) {
4042
- if (changes["item"] && changes["item"].currentValue) {
4043
- const cfg = this.item?.config;
4044
- this.curConfig.set(cfg ? __spreadValues({}, cfg) : null);
4045
- if (cfg?.rssUrl)
4046
- this.reload(false);
4047
- }
4048
- }
4049
- openConfig() {
4050
- const cfg = this.item?.config;
4051
- this.rssUrl.set(cfg?.rssUrl ?? "");
4052
- this.isModalVisible.set(true);
4053
- }
4054
- reload(force = true) {
4055
- const cfg = this.curConfig() ?? this.item?.config;
4056
- const url = (cfg?.rssUrl ?? "").trim();
4057
- if (!url)
4058
- return;
4059
- this.loading.set(true);
4060
- this.errorMsg.set("");
4061
- const limit = cfg?.limit ?? 20;
4062
- const cacheSec = cfg?.cacheSec ?? 300;
4063
- this.rss.preview(url, { limit, cacheSec, force }).subscribe({
4064
- next: (data) => {
4065
- this.loading.set(false);
4066
- this.feedTitle.set(data.title ?? "");
4067
- this.feedItems.set(data.items ?? []);
4068
- if (this.feedTitle()) {
4069
- this.item.title = this.feedTitle();
4070
- this.cdr.markForCheck();
4071
- }
4072
- },
4073
- error: (err) => {
4074
- this.errorMsg.set(err?.error?.detail || err?.message || "\u52A0\u8F7D\u5931\u8D25");
4075
- this.loading.set(false);
4076
- }
4077
- });
4078
- }
4079
- save() {
4080
- const pid = this.item.projectId;
4081
- const rssUrl = (this.rssUrl() ?? "").trim();
4082
- if (!pid || !rssUrl)
4083
- return;
4084
- const prev = this.item?.config ?? {};
4085
- const next = __spreadProps(__spreadValues({}, prev), {
4086
- rssUrl,
4087
- limit: prev.limit ?? 20,
4088
- cacheSec: prev.cacheSec ?? 300
4089
- });
4090
- this.item.config = next;
4091
- this.curConfig.set(next);
4092
- this.layout.updateConfig(pid, this.item.id, next);
4093
- this.isModalVisible.set(false);
4094
- this.reload(true);
4095
- }
4096
- static propDecorators = {
4097
- item: [{ type: Input }]
4098
- };
4099
- };
4100
- NewsFeedWidgetComponent = __decorate([
4101
- Component({
4102
- selector: "app-news-feed-widget",
4103
- imports: [
4104
- CommonModule,
4105
- FormsModule,
4106
- NzInputModule,
4107
- NzButtonModule,
4108
- WidgetBaseComponent,
4109
- NzModalModule,
4110
- NzIconModule
4111
- ],
4112
- template: news_feed_widget_component_default,
4113
- styles: [news_feed_widget_component_default2]
4114
- })
4115
- ], NewsFeedWidgetComponent);
4116
-
4117
- // angular:jit:template:src\app\pages\dashboard\components\widgets\quick-task\quick-task-widget.component.html
4118
- var quick_task_widget_component_default = `<app-widget-base [item]="item">\r
4119
- <ng-container ngProjectAs="actions">\r
4120
- <button nz-button nzType="link" nzSize="small" (click)="openConfig()">\r
4121
- <nz-icon nzType="setting" nzTheme="outline" />\r
4122
- </button>\r
4123
- </ng-container>\r
4124
- @if (item.configurable) {\r
4125
- <div class="configured-info" [class.no-config]="curConfig() === null">\r
4126
- @if (curConfig() === null) {\r
4127
- <nz-icon nzType="setting" nzTheme="fill" />\r
4128
- <button nz-button (click)="openConfig()" nzType="primary">\u914D\u7F6E\u90E8\u4EF6</button>\r
4129
- } @else {\r
4130
- <div class="item">\r
4131
- <div class="row" [nz-tooltip]="curConfig()?.description ?? ''" nzTooltipPlacement="right">\r
4132
- <div class="icon">\r
4133
- <nz-icon nzType="codepen-circle" nzTheme="outline" />\r
4134
- @if (curRuntime().status === 'running') {\r
4135
- <nz-badge nzStatus="processing" />\r
4136
- } @else if (curRuntime().status === 'stopping') {\r
4137
- <nz-badge nzStatus="warning" />\r
4138
- } @else {\r
4139
- <nz-badge nzStatus="default" />\r
4140
- }\r
4141
- </div>\r
4142
- \r
4143
- <div class="info">\r
4144
- <div class="name" [title]="curConfig()?.taskName">{{ curConfig()?.taskName }}</div>\r
4145
- <div class="description">\r
4146
- {{\r
4147
- curRuntime().status === 'running'\r
4148
- ? '\u8FD0\u884C\u4E2D'\r
4149
- : curRuntime().status === 'stopping'\r
4150
- ? '\u505C\u6B62\u4E2D'\r
4151
- : curRuntime().status === 'stopped'\r
4152
- ? '\u5DF2\u505C\u6B62'\r
4153
- : curConfig()?.description || '\u7A7A\u95F2\u4E2D'\r
4154
- }}\r
4155
- </div>\r
4156
- </div>\r
4157
- </div>\r
4158
- </div>\r
4159
- <div class="actions">\r
4160
- <app-task-actions\r
4161
- [isRunning]="isRunning()"\r
4162
- [isStopping]="isStopping()"\r
4163
- [isStopped]="isStopped()"\r
4164
- (toggle)="toggleTask()"\r
4165
- ></app-task-actions>\r
4166
- <button nz-button (click)="goToTask()" nzType="default">\r
4167
- <nz-icon nzType="schedule" nzTheme="outline" />\r
4168
- \u524D\u5F80\u4EFB\u52A1\u9875\r
4169
- </button>\r
4170
- </div>\r
4171
- }\r
4172
- </div>\r
4173
- }\r
4174
- </app-widget-base>\r
4175
- <nz-modal\r
4176
- nzCentered\r
4177
- [(nzVisible)]="isModalVisible"\r
4178
- nzTitle="\u914D\u7F6E\u90E8\u4EF6"\r
4179
- (nzOnCancel)="isModalVisible.set(false)"\r
4180
- [nzMaskClosable]="false"\r
4181
- >\r
4182
- <ng-container *nzModalContent>\r
4183
- <div class="modal-body">\r
4184
- <label>\u9009\u62E9\u4E00\u9879\u4EFB\u52A1</label>\r
4185
- <nz-select\r
4186
- nzPlaceHolder="\u8BF7\u9009\u62E9\u4EFB\u52A1"\r
4187
- [(ngModel)]="selectedTaskId"\r
4188
- [nzLoading]="loading()"\r
4189
- [nzDisabled]="loading()"\r
4190
- style="width: 100%"\r
4191
- >\r
4192
- @for (opt of taskOptions(); track opt.value) {\r
4193
- <nz-option [nzLabel]="opt.label" [nzValue]="opt.value"></nz-option>\r
4194
- }\r
4195
- </nz-select>\r
4196
- </div>\r
4197
- </ng-container>\r
4198
- \r
4199
- <ng-container *nzModalFooter>\r
4200
- <button nz-button nzType="primary" (click)="save()" [disabled]="!selectedTaskId">\u4FDD\u5B58</button>\r
4201
- </ng-container>\r
4202
- </nz-modal>\r
4203
- `;
4204
-
4205
- // angular:jit:style:src\app\pages\dashboard\components\widgets\quick-task\quick-task-widget.component.less
4206
- var quick_task_widget_component_default2 = '/* src/app/pages/dashboard/components/widgets/quick-task/quick-task-widget.component.less */\n.configured-info {\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 12px;\n width: 100%;\n height: 100%;\n}\n.configured-info.no-config {\n gap: 20px;\n}\n.configured-info.no-config nz-icon {\n font-size: 48px;\n color: var(--app-gray);\n}\n.configured-info .actions {\n display: flex;\n align-items: center;\n width: 100%;\n justify-content: center;\n gap: 8px;\n}\n.item {\n width: 100%;\n padding: 12px 16px;\n cursor: pointer;\n}\n.item:hover,\n.item.active {\n background: var(--app-primary-3);\n}\n.item .row {\n display: flex;\n gap: 10px;\n align-items: center;\n overflow: hidden;\n justify-content: space-between;\n}\n.item .row .icon {\n font-size: 36px;\n flex: 0 0 auto;\n position: relative;\n}\n.item .row .info {\n flex: 1 1 auto;\n display: flex;\n flex-direction: column;\n gap: 4px;\n overflow: hidden;\n}\n.item .row .info .name {\n font-weight: 600;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.item .row .info .description {\n font-size: 13px;\n color: var(--app-text-secondary);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.item .badge {\n font-size: 12px;\n padding: 2px 8px;\n border-radius: 999px;\n border: 1px solid rgba(0, 0, 0, 0.2);\n opacity: 0.85;\n}\n.item .badge[data-status=running] {\n font-weight: 700;\n}\n.item .badge[data-status=stopped] {\n opacity: 0.7;\n}\n.item .badge[data-status=failed] {\n font-weight: 700;\n}\n.item .meta {\n margin-top: 6px;\n font-size: 12px;\n opacity: 0.75;\n display: flex;\n align-items: center;\n gap: 6px;\n}\n.item .meta .mono {\n font-family:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Consolas,\n "Liberation Mono",\n monospace;\n}\n.item .meta .sep {\n opacity: 0.5;\n}\n.modal-body {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n}\n.modal-body label {\n flex: 0 0 auto;\n margin-right: 16px;\n display: inline-block;\n width: 120px;\n}\n.modal-body nz-select {\n flex: 1;\n margin-left: 16px;\n}\n/*# sourceMappingURL=quick-task-widget.component.css.map */\n';
4207
-
4208
- // src/app/pages/dashboard/components/widgets/quick-task/quick-task-widget.component.ts
4209
- var QuickTaskWidgetComponent = class QuickTaskWidgetComponent2 {
4210
- item;
4211
- taskState = inject(TaskStateService);
4212
- layout = inject(DashboardLayoutService);
4213
- router = inject(Router);
4214
- isModalVisible = signal(false);
4215
- loading = signal(false);
4216
- curConfig = signal(null);
4217
- curRuntime = computed(() => {
4218
- const cfg = this.curConfig();
4219
- if (!cfg)
4220
- return { status: "idle" };
4221
- const taskId = cfg.taskId;
4222
- return this.taskState.getRuntime(taskId) || { status: "idle" };
4223
- });
4224
- isRunning = computed(() => this.curRuntime().status === "running");
4225
- isStopping = computed(() => this.curRuntime().status === "stopping");
4226
- isStopped = computed(() => {
4227
- const st = this.curRuntime().status;
4228
- return st === "idle" || st === "stopped" || st === "failed" || st === "success";
4229
- });
4230
- selectedTaskId = "";
4231
- /** 当前项目任务 rows */
4232
- rowsOfProject = computed(() => {
4233
- const pid = this.item.projectId;
4234
- if (!pid)
4235
- return [];
4236
- return this.taskState.rowsViewOf(pid)();
4237
- });
4238
- taskOptions = computed(() => {
4239
- const rows = this.rowsOfProject();
4240
- return rows.map((r) => ({
4241
- value: r.spec.id,
4242
- label: r.spec.name ?? r.spec.id,
4243
- description: r.spec.description ?? ""
4244
- }));
4245
- });
4246
- ngOnChanges(changes) {
4247
- if (changes["item"]) {
4248
- const cfg = this.item?.config;
4249
- this.curConfig.set(cfg ? __spreadValues({}, cfg) : null);
4250
- }
4251
- }
4252
- async openConfig() {
4253
- const pid = this.item.projectId;
4254
- if (!pid) {
4255
- this.isModalVisible.set(false);
4256
- return;
4257
- }
4258
- const cfg = this.item?.config;
4259
- this.selectedTaskId = cfg?.taskId ?? "";
4260
- this.isModalVisible.set(true);
4261
- this.loading.set(true);
4262
- try {
4263
- await this.taskState.ensureProjectLoaded(pid);
4264
- } finally {
4265
- this.loading.set(false);
4266
- }
4267
- }
4268
- save() {
4269
- const pid = this.item.projectId;
4270
- const taskId = (this.selectedTaskId ?? "").trim();
4271
- if (!pid || !taskId)
4272
- return;
4273
- const taskItem = this.rowsOfProject().find((r) => r.spec.id === taskId);
4274
- const taskName = taskItem?.spec.name ?? "";
4275
- const description = taskItem?.spec.description ?? "";
4276
- const next = { taskId, taskName, description };
4277
- this.item.config = next;
4278
- this.curConfig.set(next);
4279
- this.layout.updateConfig(pid, this.item.id, next);
4280
- this.isModalVisible.set(false);
4281
- }
4282
- toggleTask() {
4283
- if (this.curConfig() == null || !this.curConfig().taskId)
4284
- return;
4285
- const taskId = this.curConfig().taskId;
4286
- if (this.isRunning()) {
4287
- this.taskState.stopSelected(taskId);
4288
- } else if (this.isStopped()) {
4289
- this.taskState.startSelected(taskId);
4290
- }
4291
- this.goToTask();
4292
- }
4293
- async goToTask() {
4294
- const cfg = this.curConfig();
4295
- if (!cfg)
4296
- return;
4297
- const taskId = cfg.taskId;
4298
- this.taskState.select(taskId);
4299
- await this.router.navigate(["/tasks"]);
4300
- }
4301
- static propDecorators = {
4302
- item: [{ type: Input }]
4303
- };
4304
- };
4305
- QuickTaskWidgetComponent = __decorate([
4306
- Component({
4307
- selector: "app-quick-task-widget",
4308
- imports: [
4309
- CommonModule,
4310
- FormsModule,
4311
- WidgetBaseComponent,
4312
- NzButtonModule,
4313
- NzIconModule,
4314
- NzModalModule,
4315
- NzSelectModule,
4316
- NzBadgeModule,
4317
- NzTooltipModule,
4318
- TaskActionsComponent
4319
- ],
4320
- template: quick_task_widget_component_default,
4321
- styles: [quick_task_widget_component_default2]
4322
- })
4323
- ], QuickTaskWidgetComponent);
4324
-
4325
- // angular:jit:style:src\app\pages\dashboard\components\widgets\welcome\welcome-widget.component.less
4326
- var welcome_widget_component_default = "/* src/app/pages/dashboard/components/widgets/welcome/welcome-widget.component.less */\n.logo {\n width: 70px;\n height: 70px;\n border-radius: 50% 50%;\n background-color: var(--app-primary-2);\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0 auto 16px auto;\n}\n.logo nz-icon {\n font-size: 50px;\n}\nh2 {\n text-align: center;\n font-weight: 600;\n flex: 0 0 auto;\n margin-bottom: 8px;\n}\n.footer {\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 30px 0;\n}\n.item {\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 24px 16px;\n}\n.item p {\n margin-bottom: 0;\n}\n.item .icon-wrapper {\n width: 50px;\n height: 50px;\n margin-right: 12px;\n flex: 0 0 auto;\n background-color: var(--app-gray);\n border-radius: 50% 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n.item .icon-wrapper nz-icon {\n font-size: 24px;\n color: var(--app-primary-5);\n}\n/*# sourceMappingURL=welcome-widget.component.css.map */\n";
4327
-
4328
- // src/app/pages/dashboard/components/widgets/welcome/welcome-widget.component.ts
4329
- var WelcomeWidgetComponent = class WelcomeWidgetComponent2 {
4330
- item;
4331
- removeWidget = new EventEmitter();
4332
- static propDecorators = {
4333
- item: [{ type: Input }],
4334
- removeWidget: [{ type: Output }]
4335
- };
4336
- };
4337
- WelcomeWidgetComponent = __decorate([
4338
- Component({
4339
- selector: "app-welcome-widget",
4340
- imports: [
4341
- CommonModule,
4342
- NzIconModule,
4343
- NzButtonModule,
4344
- WidgetBaseComponent
4345
- ],
4346
- template: `
4347
- <app-widget-base [item]="item">
4348
- <div class="logo">
4349
- <nz-icon nzType="proj:angular" nzTheme="outline" />
4350
- </div>
4351
- <h2>\u6B22\u8FCE\u6765\u5230\u65B0\u9879\u76EE\uFF01</h2>
4352
- <div class="item">
4353
- <div class="icon-wrapper">
4354
- <nz-icon nzType="dashboard" nzTheme="outline" />
4355
- </div>
4356
- <p>\u8FD9\u91CC\u662F\u9879\u76EE\u4EEA\u8868\u76D8\uFF0C\u4F60\u53EF\u4EE5\u70B9\u51FB\u53F3\u4E0A\u65B9\u7684\u201C\u81EA\u5B9A\u4E49\u201D\u6309\u94AE\u6765\u6DFB\u52A0\u90E8\u4EF6\u3002\u4F60\u7684\u6539\u52A8\u5C06\u4F1A\u81EA\u52A8\u4FDD\u5B58\u3002</p>
4357
- </div>
4358
- <div class="item">
4359
- <div class="icon-wrapper">
4360
- <nz-icon nzType="arrow-left" nzTheme="outline" />
4361
- </div>
4362
- <p>\u5DE6\u4FA7\u662F\u5404\u4E2A\u7BA1\u7406\u9875\u9762\u3002\u5728\u300C\u63D2\u4EF6\u300D\u9875\u9762\u53EF\u4EE5\u6DFB\u52A0\u65B0\u7684 Vue CLI \u63D2\u4EF6\uFF0C\u300C\u4F9D\u8D56\u300D\u9875\u9762\u7528\u4E8E\u7BA1\u7406\u9879\u76EE\u7684\u4F9D\u8D56\u5305\uFF0C\u300C\u914D\u7F6E\u300D\u9875\u9762\u7528\u4E8E\u914D\u7F6E\u5404\u79CD\u5DE5\u5177\uFF0C\u300C\u4EFB\u52A1\u300D\u9875\u9762\u7528\u4E8E\u8FD0\u884C\u5404\u4E2A\u811A\u672C\uFF08\u6BD4\u5982 webpack \u6253\u5305\uFF09\u3002</p>
4363
- </div>
4364
- <div class="item">
4365
- <div class="icon-wrapper">
4366
- <nz-icon nzType="home" nzTheme="outline" />
4367
- </div>
4368
- <p>\u70B9\u51FB\u5DE6\u4E0A\u65B9\u7684\u4E0B\u62C9\u83DC\u5355\u6216\u72B6\u6001\u680F\u4E0A\u7684\u5C0F\u623F\u5B50\u6309\u94AE\u6765\u8FD4\u56DE\u5230\u9879\u76EE\u7BA1\u7406\u5668\u3002</p>
4369
- </div>
4370
- <div class="footer">
4371
- <button nz-button nzType="primary" routerLink="/projects" nzSize="large" (click)="removeWidget.emit()">
4372
- <nz-icon nzType="check" nzTheme="outline" />
4373
- <span> \u4E86\u89E3 </span>
4374
- </button>
4375
- </div>
4376
- </app-widget-base>
4377
- `,
4378
- styles: [welcome_widget_component_default]
4379
- })
4380
- ], WelcomeWidgetComponent);
4381
-
4382
- // src/app/pages/dashboard/components/widget-host/widget-host.component.ts
4383
- var WidgetHostComponent = class WidgetHostComponent2 {
4384
- item;
4385
- editMode = false;
4386
- remove = new EventEmitter();
4387
- static propDecorators = {
4388
- item: [{ type: Input }],
4389
- editMode: [{ type: Input }],
4390
- remove: [{ type: Output }]
4391
- };
4392
- };
4393
- WidgetHostComponent = __decorate([
4394
- Component({
4395
- selector: "app-widget-host",
4396
- imports: [
4397
- CommonModule,
4398
- WelcomeWidgetComponent,
4399
- QuickTaskWidgetComponent,
4400
- KillPortWidgetComponent,
4401
- NewsFeedWidgetComponent
4402
- ],
4403
- template: `
4404
- @if(item){
4405
- @switch (item.key) {
4406
- @case ('welcome') { <app-welcome-widget [item]="item" (removeWidget)="remove.emit(item)"></app-welcome-widget> }
4407
- @case ('quickTasks') { <app-quick-task-widget [item]="item"></app-quick-task-widget> }
4408
- @case ('killPort') { <app-kill-port-widget [item]="item"></app-kill-port-widget> }
4409
- @case ('newsFeed') { <app-news-feed-widget [item]="item"></app-news-feed-widget> }
4410
- }
4411
- }
4412
- `,
4413
- styles: [widget_host_component_default]
4414
- })
4415
- ], WidgetHostComponent);
4416
-
4417
- // src/app/pages/dashboard/components/dashboard-canvas/dashboard-canvas.component.ts
4418
- var DashboardCanvasComponent = class DashboardCanvasComponent2 {
4419
- editMode = false;
4420
- items = [];
4421
- itemsChange = new EventEmitter();
4422
- remove = new EventEmitter();
4423
- kill = new EventEmitter();
4424
- patch = /* @__PURE__ */ new Map();
4425
- itemChange = (item, itemComp) => {
4426
- const id = itemComp.item.id;
4427
- if (!id)
4428
- return;
4429
- this.patch.set(id, {
4430
- x: item.x ?? itemComp.item.x,
4431
- y: item.y ?? itemComp.item.y,
4432
- cols: item.cols ?? itemComp.item.cols,
4433
- rows: item.rows ?? itemComp.item.rows
4434
- });
4435
- };
4436
- itemResize = (item, itemComp) => {
4437
- };
4438
- options = {
4439
- gridType: GridType.Fixed,
4440
- fixedColWidth: 90,
4441
- fixedRowHeight: 90,
4442
- margin: 10,
4443
- outerMargin: true,
4444
- compactType: CompactType.None,
4445
- pushItems: true,
4446
- // 调试时可开网格线,正式关掉
4447
- displayGrid: DisplayGrid.None,
4448
- resizable: {
4449
- enabled: true,
4450
- stop: () => this.emitSync()
4451
- },
4452
- draggable: {
4453
- enabled: false,
4454
- // ignoreContent: true,
4455
- // dragHandleClass: 'drag-handle', // 只允许手柄拖动
4456
- stop: () => this.emitSync()
4457
- },
4458
- itemChangeCallback: this.itemChange,
4459
- itemResizeCallback: this.itemResize
4460
- };
4461
- ngOnChanges(changes) {
4462
- const editMode = changes["editMode"];
4463
- if (editMode && editMode.currentValue != editMode.previousValue) {
4464
- this.options = __spreadProps(__spreadValues({}, this.options), {
4465
- draggable: __spreadProps(__spreadValues({}, this.options.draggable), { enabled: this.editMode }),
4466
- resizable: __spreadProps(__spreadValues({}, this.options.resizable), { enabled: this.editMode }),
4467
- fixedColWidth: this.editMode ? 70 : 90,
4468
- fixedRowHeight: this.editMode ? 70 : 90
4469
- });
4470
- }
4471
- }
4472
- emitSync() {
4473
- const next = this.items.map((it) => {
4474
- const p = this.patch.get(it.id);
4475
- return p ? __spreadValues(__spreadValues({}, it), p) : it;
4476
- });
4477
- this.patch.clear();
4478
- this.itemsChange.emit(next);
4479
- }
4480
- static propDecorators = {
4481
- editMode: [{ type: Input }],
4482
- items: [{ type: Input }],
4483
- itemsChange: [{ type: Output }],
4484
- remove: [{ type: Output }],
4485
- kill: [{ type: Output }]
4486
- };
4487
- };
4488
- DashboardCanvasComponent = __decorate([
4489
- Component({
4490
- selector: "app-dashboard-canvas",
4491
- standalone: true,
4492
- imports: [
4493
- CommonModule,
4494
- NzButtonModule,
4495
- NzIconModule,
4496
- GridsterComponent,
4497
- GridsterItemComponent,
4498
- WidgetHostComponent
4499
- ],
4500
- template: `
4501
- <gridster [options]="options">
4502
- @for (it of items; track it.id) {
4503
- <gridster-item [item]="it">
4504
- <div class="card" [class.edit-mode]="editMode">
4505
- <!-- \u7F16\u8F91\u6001\u906E\u7F69 -->
4506
- @if (editMode) {
4507
- <div class="card-overlay" aria-hidden="true">
4508
- <button nz-button nzType="primary" nzSize="large">
4509
- <i nz-icon [nzType]="it.icon || 'appstore'" nzTheme="outline"></i>
4510
- {{ it.title }}
4511
- </button>
4512
- </div>
4513
- <button nz-button nzType="text" nzSize="small" nz-tooltip="\u79FB\u9664\u90E8\u4EF6" class="remove-button" (click)="remove.emit(it.id)">
4514
- <nz-icon nzType="close" nzTheme="outline" />
4515
- </button>
4516
- }
4517
- <div class="card-body">
4518
- <app-widget-host [item]="it" [editMode]="editMode" (remove)="remove.emit($event.id)"></app-widget-host>
4519
- </div>
4520
- </div>
4521
- </gridster-item>
4522
- }
4523
- </gridster>
4524
- `,
4525
- styles: [dashboard_canvas_component_default]
4526
- })
4527
- ], DashboardCanvasComponent);
4528
-
4529
- // src/app/pages/dashboard/dashboard.component.ts
4530
- var DashboardComponent = class DashboardComponent2 {
4531
- projectContext = inject(ProjectContextStore);
4532
- layout = inject(DashboardLayoutService);
4533
- envInjector = inject(EnvironmentInjector);
4534
- projectId = computed(() => this.projectContext.currentProjectId() || "");
4535
- editMode = signal(false);
4536
- items = computed(() => this.layout.items());
4537
- constructor() {
4538
- effect(() => {
4539
- const pid = this.projectId();
4540
- if (!pid)
4541
- return;
4542
- untracked(() => this.layout.load(pid));
4543
- runInInjectionContext(this.envInjector, () => {
4544
- afterNextRender(() => {
4545
- queueMicrotask(() => this.editMode.set(false));
4546
- });
4547
- });
4548
- });
4549
- }
4550
- toggleEdit() {
4551
- const next = !this.editMode();
4552
- this.editMode.set(next);
4553
- if (!next) {
4554
- this.layout.flushSave(this.projectId());
4555
- } else {
4556
- this.layout.getWidgets();
4557
- }
4558
- }
4559
- onItemsChange(next) {
4560
- this.layout.setItems(this.projectId(), next);
4561
- }
4562
- static ctorParameters = () => [];
4563
- };
4564
- DashboardComponent = __decorate([
4565
- Component({
4566
- selector: "app-dashboard.component",
4567
- imports: [
4568
- CommonModule,
4569
- NzButtonModule,
4570
- NzIconModule,
4571
- NzCardModule,
4572
- NzDrawerModule,
4573
- PageLayoutComponent,
4574
- DashboardCanvasComponent,
4575
- AddWidgetDrawerComponent
4576
- ],
4577
- host: {
4578
- "[class.collapsed]": "editMode()"
4579
- },
4580
- template: `
4581
- <app-page-layout [title]="'\u9879\u76EE\u4EEA\u8868\u76D8'" [isFullscreen]="true">
4582
- <ng-container ngProjectAs="actions">
4583
- <button nz-button nzType="primary" (click)="toggleEdit()">
4584
- <nz-icon [nzType]="editMode() ? 'check' : 'edit'" nzTheme="outline"></nz-icon>
4585
- {{ editMode() ? '\u5B8C\u6210' : '\u81EA\u5B9A\u4E49' }}
4586
- </button>
4587
- </ng-container>
4588
-
4589
- <app-dashboard-canvas
4590
- [editMode]="editMode()"
4591
- [items]="items()"
4592
- (itemsChange)="onItemsChange($event)"
4593
- (remove)="layout.remove($event)"
4594
- (kill)="layout.killProcess($event)"
4595
- ></app-dashboard-canvas>
4596
- </app-page-layout>
4597
- <div class="side-panel" [class.open]="editMode()">
4598
- <div class="side-header">
4599
- <div class="title">\u6DFB\u52A0\u90E8\u4EF6</div>
4600
- <button nz-button nzType="text" (click)="editMode.set(false)">
4601
- <nz-icon nzType="close"></nz-icon>
4602
- </button>
4603
- </div>
4604
- <div class="side-body">
4605
- <app-add-widget-drawer (add)="layout.add($event)"></app-add-widget-drawer>
4606
- </div>
4607
- </div>
4608
- `,
4609
- styles: [dashboard_component_default]
4610
- })
4611
- ], DashboardComponent);
4612
- export {
4613
- DashboardComponent
4614
- };
4615
- //# sourceMappingURL=chunk-LVPSURVU.js.map