@mapomodule/uikit 1.0.0 → 2.0.0-beta.10

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 (427) hide show
  1. package/README.md +199 -0
  2. package/dist/index.d.mts +5 -0
  3. package/dist/index.d.ts +6 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.mjs +1 -0
  6. package/dist/module.d.mts +60 -0
  7. package/dist/module.d.ts +55 -0
  8. package/dist/module.d.ts.map +1 -0
  9. package/dist/module.json +9 -0
  10. package/dist/module.mjs +179 -0
  11. package/dist/runtime/adapters/defaultMediaAdapter.d.ts +14 -0
  12. package/dist/runtime/adapters/defaultMediaAdapter.d.ts.map +1 -0
  13. package/dist/runtime/adapters/defaultMediaAdapter.js +30 -0
  14. package/dist/runtime/assets/main.css +1 -0
  15. package/dist/runtime/components/MapoConfirmDialog.vue +35 -0
  16. package/dist/runtime/components/MapoConfirmDialog.vue.d.ts +4 -0
  17. package/dist/runtime/components/MapoConfirmDialog.vue.d.ts.map +1 -0
  18. package/dist/runtime/components/MapoDetail.vue +606 -0
  19. package/dist/runtime/components/MapoDetail.vue.d.ts +401 -0
  20. package/dist/runtime/components/MapoDetail.vue.d.ts.map +1 -0
  21. package/dist/runtime/components/MapoDetailLangSwitch.vue +126 -0
  22. package/dist/runtime/components/MapoDetailLangSwitch.vue.d.ts +23 -0
  23. package/dist/runtime/components/MapoDetailLangSwitch.vue.d.ts.map +1 -0
  24. package/dist/runtime/components/MapoDropArea.vue +99 -0
  25. package/dist/runtime/components/MapoDropArea.vue.d.ts +33 -0
  26. package/dist/runtime/components/MapoDropArea.vue.d.ts.map +1 -0
  27. package/dist/runtime/components/MapoLangSwitcher.vue +39 -0
  28. package/dist/runtime/components/MapoLangSwitcher.vue.d.ts +18 -0
  29. package/dist/runtime/components/MapoLangSwitcher.vue.d.ts.map +1 -0
  30. package/dist/runtime/components/MapoList.vue +191 -0
  31. package/dist/runtime/components/MapoList.vue.d.ts +111 -0
  32. package/dist/runtime/components/MapoList.vue.d.ts.map +1 -0
  33. package/dist/runtime/components/MapoListActions.vue +119 -0
  34. package/dist/runtime/components/MapoListActions.vue.d.ts +33 -0
  35. package/dist/runtime/components/MapoListActions.vue.d.ts.map +1 -0
  36. package/dist/runtime/components/MapoListFilters.vue +246 -0
  37. package/dist/runtime/components/MapoListFilters.vue.d.ts +38 -0
  38. package/dist/runtime/components/MapoListFilters.vue.d.ts.map +1 -0
  39. package/dist/runtime/components/MapoListHead.vue +9 -0
  40. package/dist/runtime/components/MapoListHead.vue.d.ts +14 -0
  41. package/dist/runtime/components/MapoListHead.vue.d.ts.map +1 -0
  42. package/dist/runtime/components/MapoListQuickEdit.vue +123 -0
  43. package/dist/runtime/components/MapoListQuickEdit.vue.d.ts +47 -0
  44. package/dist/runtime/components/MapoListQuickEdit.vue.d.ts.map +1 -0
  45. package/dist/runtime/components/MapoListTable.vue +665 -0
  46. package/dist/runtime/components/MapoListTable.vue.d.ts +105 -0
  47. package/dist/runtime/components/MapoListTable.vue.d.ts.map +1 -0
  48. package/dist/runtime/components/MapoListTabs.vue +38 -0
  49. package/dist/runtime/components/MapoListTabs.vue.d.ts +26 -0
  50. package/dist/runtime/components/MapoListTabs.vue.d.ts.map +1 -0
  51. package/dist/runtime/components/MapoLogin.vue +196 -0
  52. package/dist/runtime/components/MapoLogin.vue.d.ts +22 -0
  53. package/dist/runtime/components/MapoLogin.vue.d.ts.map +1 -0
  54. package/dist/runtime/components/MapoLogoutButton.vue +27 -0
  55. package/dist/runtime/components/MapoLogoutButton.vue.d.ts +29 -0
  56. package/dist/runtime/components/MapoLogoutButton.vue.d.ts.map +1 -0
  57. package/dist/runtime/components/MapoMediaBreadcrumbs.vue +47 -0
  58. package/dist/runtime/components/MapoMediaBreadcrumbs.vue.d.ts +4 -0
  59. package/dist/runtime/components/MapoMediaBreadcrumbs.vue.d.ts.map +1 -0
  60. package/dist/runtime/components/MapoMediaEditor.vue +320 -0
  61. package/dist/runtime/components/MapoMediaEditor.vue.d.ts +8 -0
  62. package/dist/runtime/components/MapoMediaEditor.vue.d.ts.map +1 -0
  63. package/dist/runtime/components/MapoMediaFileChanger.vue +112 -0
  64. package/dist/runtime/components/MapoMediaFileChanger.vue.d.ts +15 -0
  65. package/dist/runtime/components/MapoMediaFileChanger.vue.d.ts.map +1 -0
  66. package/dist/runtime/components/MapoMediaFolders.vue +220 -0
  67. package/dist/runtime/components/MapoMediaFolders.vue.d.ts +4 -0
  68. package/dist/runtime/components/MapoMediaFolders.vue.d.ts.map +1 -0
  69. package/dist/runtime/components/MapoMediaGallery.vue +219 -0
  70. package/dist/runtime/components/MapoMediaGallery.vue.d.ts +4 -0
  71. package/dist/runtime/components/MapoMediaGallery.vue.d.ts.map +1 -0
  72. package/dist/runtime/components/MapoMediaManager.vue +140 -0
  73. package/dist/runtime/components/MapoMediaManager.vue.d.ts +35 -0
  74. package/dist/runtime/components/MapoMediaManager.vue.d.ts.map +1 -0
  75. package/dist/runtime/components/MapoMediaManagerDialog.vue +116 -0
  76. package/dist/runtime/components/MapoMediaManagerDialog.vue.d.ts +41 -0
  77. package/dist/runtime/components/MapoMediaManagerDialog.vue.d.ts.map +1 -0
  78. package/dist/runtime/components/MapoMediaPreview.vue +92 -0
  79. package/dist/runtime/components/MapoMediaPreview.vue.d.ts +19 -0
  80. package/dist/runtime/components/MapoMediaPreview.vue.d.ts.map +1 -0
  81. package/dist/runtime/components/MapoMediaUploader.vue +290 -0
  82. package/dist/runtime/components/MapoMediaUploader.vue.d.ts +8 -0
  83. package/dist/runtime/components/MapoMediaUploader.vue.d.ts.map +1 -0
  84. package/dist/runtime/components/MapoMenuManager.vue +273 -0
  85. package/dist/runtime/components/MapoMenuManager.vue.d.ts +92 -0
  86. package/dist/runtime/components/MapoMenuManager.vue.d.ts.map +1 -0
  87. package/dist/runtime/components/MapoMenuNodeEditor.vue +201 -0
  88. package/dist/runtime/components/MapoMenuNodeEditor.vue.d.ts +61 -0
  89. package/dist/runtime/components/MapoMenuNodeEditor.vue.d.ts.map +1 -0
  90. package/dist/runtime/components/MapoMenuTreeview.vue +181 -0
  91. package/dist/runtime/components/MapoMenuTreeview.vue.d.ts +57 -0
  92. package/dist/runtime/components/MapoMenuTreeview.vue.d.ts.map +1 -0
  93. package/dist/runtime/components/MapoMenuTreeviewNode.vue +175 -0
  94. package/dist/runtime/components/MapoMenuTreeviewNode.vue.d.ts +27 -0
  95. package/dist/runtime/components/MapoMenuTreeviewNode.vue.d.ts.map +1 -0
  96. package/dist/runtime/components/MapoRootComponents.vue +9 -0
  97. package/dist/runtime/components/MapoRootComponents.vue.d.ts +4 -0
  98. package/dist/runtime/components/MapoRootComponents.vue.d.ts.map +1 -0
  99. package/dist/runtime/components/MapoSidebar.vue +89 -0
  100. package/dist/runtime/components/MapoSidebar.vue.d.ts +22 -0
  101. package/dist/runtime/components/MapoSidebar.vue.d.ts.map +1 -0
  102. package/dist/runtime/components/MapoSidebarList.vue +27 -0
  103. package/dist/runtime/components/MapoSidebarList.vue.d.ts +8 -0
  104. package/dist/runtime/components/MapoSidebarList.vue.d.ts.map +1 -0
  105. package/dist/runtime/components/MapoSidebarListItem.vue +74 -0
  106. package/dist/runtime/components/MapoSidebarListItem.vue.d.ts +9 -0
  107. package/dist/runtime/components/MapoSidebarListItem.vue.d.ts.map +1 -0
  108. package/dist/runtime/components/MapoSidebarProfile.vue +55 -0
  109. package/dist/runtime/components/MapoSidebarProfile.vue.d.ts +10 -0
  110. package/dist/runtime/components/MapoSidebarProfile.vue.d.ts.map +1 -0
  111. package/dist/runtime/components/MapoSnackBar.vue +38 -0
  112. package/dist/runtime/components/MapoSnackBar.vue.d.ts +4 -0
  113. package/dist/runtime/components/MapoSnackBar.vue.d.ts.map +1 -0
  114. package/dist/runtime/components/MapoThemeToggle.vue +23 -0
  115. package/dist/runtime/components/MapoThemeToggle.vue.d.ts +4 -0
  116. package/dist/runtime/components/MapoThemeToggle.vue.d.ts.map +1 -0
  117. package/dist/runtime/components/MapoTopbar.vue +30 -0
  118. package/dist/runtime/components/MapoTopbar.vue.d.ts +15 -0
  119. package/dist/runtime/components/MapoTopbar.vue.d.ts.map +1 -0
  120. package/dist/runtime/components/menuDndContext.d.ts +19 -0
  121. package/dist/runtime/components/menuDndContext.d.ts.map +1 -0
  122. package/dist/runtime/components/menuDndContext.js +3 -0
  123. package/dist/runtime/layouts/default.vue +43 -0
  124. package/dist/runtime/layouts/default.vue.d.ts +20 -0
  125. package/dist/runtime/layouts/default.vue.d.ts.map +1 -0
  126. package/dist/runtime/layouts/empty.vue +9 -0
  127. package/dist/runtime/layouts/empty.vue.d.ts +14 -0
  128. package/dist/runtime/layouts/empty.vue.d.ts.map +1 -0
  129. package/dist/runtime/page-meta.nuxt.d.ts +45 -0
  130. package/dist/runtime/pages/index.vue +14 -0
  131. package/dist/runtime/pages/index.vue.d.ts +4 -0
  132. package/dist/runtime/pages/index.vue.d.ts.map +1 -0
  133. package/dist/runtime/pages/login.vue +3 -0
  134. package/dist/runtime/pages/login.vue.d.ts +4 -0
  135. package/dist/runtime/pages/login.vue.d.ts.map +1 -0
  136. package/dist/runtime/plugins/media-adapter.d.ts +18 -0
  137. package/dist/runtime/plugins/media-adapter.d.ts.map +1 -0
  138. package/dist/runtime/plugins/media-adapter.js +8 -0
  139. package/dist/runtime/stores/media.d.ts +462 -0
  140. package/dist/runtime/stores/media.d.ts.map +1 -0
  141. package/dist/runtime/stores/media.js +344 -0
  142. package/dist/runtime/types/list.d.ts +59 -0
  143. package/dist/runtime/types/list.d.ts.map +1 -0
  144. package/dist/runtime/types/list.js +0 -0
  145. package/dist/runtime/types/media.d.ts +116 -0
  146. package/dist/runtime/types/media.d.ts.map +1 -0
  147. package/dist/runtime/types/media.js +0 -0
  148. package/dist/runtime/types/menu.d.ts +66 -0
  149. package/dist/runtime/types/menu.d.ts.map +1 -0
  150. package/dist/runtime/types/menu.js +30 -0
  151. package/dist/types.d.mts +9 -0
  152. package/package.json +67 -12
  153. package/src/index.ts +30 -0
  154. package/src/module.ts +311 -0
  155. package/src/runtime/adapters/defaultMediaAdapter.ts +57 -0
  156. package/src/runtime/assets/main.css +59 -0
  157. package/src/runtime/components/MapoConfirmDialog.vue +36 -0
  158. package/src/runtime/components/MapoDetail.vue +864 -0
  159. package/src/runtime/components/MapoDetailLangSwitch.vue +166 -0
  160. package/src/runtime/components/MapoDropArea.vue +127 -0
  161. package/src/runtime/components/MapoLangSwitcher.vue +74 -0
  162. package/src/runtime/components/MapoList.vue +339 -0
  163. package/src/runtime/components/MapoListActions.vue +158 -0
  164. package/src/runtime/components/MapoListFilters.vue +292 -0
  165. package/src/runtime/components/MapoListHead.vue +12 -0
  166. package/src/runtime/components/MapoListQuickEdit.vue +166 -0
  167. package/src/runtime/components/MapoListTable.vue +931 -0
  168. package/src/runtime/components/MapoListTabs.vue +48 -0
  169. package/src/runtime/components/MapoLogin.vue +212 -0
  170. package/src/runtime/components/MapoLogoutButton.vue +48 -0
  171. package/src/runtime/components/MapoMediaBreadcrumbs.vue +53 -0
  172. package/src/runtime/components/MapoMediaEditor.vue +350 -0
  173. package/src/runtime/components/MapoMediaFileChanger.vue +136 -0
  174. package/src/runtime/components/MapoMediaFolders.vue +239 -0
  175. package/src/runtime/components/MapoMediaGallery.vue +239 -0
  176. package/src/runtime/components/MapoMediaManager.vue +180 -0
  177. package/src/runtime/components/MapoMediaManagerDialog.vue +148 -0
  178. package/src/runtime/components/MapoMediaPreview.vue +111 -0
  179. package/src/runtime/components/MapoMediaUploader.vue +351 -0
  180. package/src/runtime/components/MapoMenuManager.vue +402 -0
  181. package/src/runtime/components/MapoMenuNodeEditor.vue +282 -0
  182. package/src/runtime/components/MapoMenuTreeview.vue +264 -0
  183. package/src/runtime/components/MapoMenuTreeviewNode.vue +234 -0
  184. package/src/runtime/components/MapoRootComponents.vue +9 -0
  185. package/src/runtime/components/MapoSidebar.vue +114 -0
  186. package/src/runtime/components/MapoSidebarList.vue +35 -0
  187. package/src/runtime/components/MapoSidebarListItem.vue +79 -0
  188. package/src/runtime/components/MapoSidebarProfile.vue +61 -0
  189. package/src/runtime/components/MapoSnackBar.vue +42 -0
  190. package/src/runtime/components/MapoThemeToggle.vue +27 -0
  191. package/src/runtime/components/MapoTopbar.vue +36 -0
  192. package/src/runtime/components/menuDndContext.ts +22 -0
  193. package/src/runtime/layouts/default.vue +53 -0
  194. package/src/runtime/layouts/empty.vue +9 -0
  195. package/src/runtime/page-meta.nuxt.d.ts +45 -0
  196. package/src/runtime/pages/index.vue +15 -0
  197. package/src/runtime/pages/login.vue +3 -0
  198. package/src/runtime/plugins/media-adapter.ts +33 -0
  199. package/src/runtime/stores/media.ts +474 -0
  200. package/src/runtime/types/list.ts +64 -0
  201. package/src/runtime/types/media.ts +126 -0
  202. package/src/runtime/types/menu.ts +105 -0
  203. package/CHANGELOG.md +0 -1030
  204. package/assets/mixins.scss +0 -22
  205. package/assets/variables.scss +0 -18
  206. package/components/ConfirmDialog.vue +0 -173
  207. package/components/Detail/Detail.vue +0 -696
  208. package/components/Detail/DetailLangSwitch.vue +0 -79
  209. package/components/DropArea.vue +0 -257
  210. package/components/Form/Form.vue +0 -218
  211. package/components/Form/FormField.vue +0 -216
  212. package/components/Form/FormGroup.vue +0 -146
  213. package/components/Form/FormTabs.vue +0 -188
  214. package/components/Form/defaults.js +0 -98
  215. package/components/Form/fields/ColorField.vue +0 -79
  216. package/components/Form/fields/DateField.vue +0 -77
  217. package/components/Form/fields/DateTimeField.vue +0 -271
  218. package/components/Form/fields/EnhancedMediaField.vue +0 -224
  219. package/components/Form/fields/FileField.vue +0 -125
  220. package/components/Form/fields/FksField.vue +0 -115
  221. package/components/Form/fields/MediaField.vue +0 -159
  222. package/components/Form/fields/MediaM2mField.vue +0 -149
  223. package/components/Form/fields/Repeater.vue +0 -618
  224. package/components/Form/fields/SeoPreview.vue +0 -89
  225. package/components/Form/fields/TimeField.vue +0 -154
  226. package/components/Form/fields/mapField/leaflet.injector.js +0 -39
  227. package/components/Form/fields/mapField/mapField.vue +0 -350
  228. package/components/Form/fields/wygEditor/defaults.js +0 -25
  229. package/components/Form/fields/wygEditor/utils/events.js +0 -64
  230. package/components/Form/fields/wygEditor/utils/mapomedia.plugin.js +0 -32
  231. package/components/Form/fields/wygEditor/utils/tinymce.injector.js +0 -29
  232. package/components/Form/fields/wygEditor/wygEditor.vue +0 -285
  233. package/components/Form/fields/wygEditorCKE/defaults.js +0 -103
  234. package/components/Form/fields/wygEditorCKE/utils/ckeditor.injector.js +0 -29
  235. package/components/Form/fields/wygEditorCKE/wygEditorCKE.vue +0 -270
  236. package/components/LangSwitcher.vue +0 -44
  237. package/components/List/List.vue +0 -271
  238. package/components/List/ListActions.vue +0 -164
  239. package/components/List/ListFilters.vue +0 -372
  240. package/components/List/ListHead.vue +0 -67
  241. package/components/List/ListQuickEdit.vue +0 -228
  242. package/components/List/ListTable.vue +0 -484
  243. package/components/List/ListTabs.vue +0 -65
  244. package/components/Login.vue +0 -125
  245. package/components/Logo.vue +0 -79
  246. package/components/LogoutButton.vue +0 -54
  247. package/components/MediaManager/MediaBreadcrumbs.vue +0 -45
  248. package/components/MediaManager/MediaEditor.vue +0 -340
  249. package/components/MediaManager/MediaFileChanger.vue +0 -78
  250. package/components/MediaManager/MediaFolders.vue +0 -287
  251. package/components/MediaManager/MediaGallery.vue +0 -281
  252. package/components/MediaManager/MediaManager.vue +0 -159
  253. package/components/MediaManager/MediaManagerDialog.vue +0 -104
  254. package/components/MediaManager/MediaPreview.vue +0 -258
  255. package/components/MediaManager/MediaUploader.vue +0 -163
  256. package/components/MenuManager/MenuManager.vue +0 -332
  257. package/components/MenuManager/MenuNodeEditor.vue +0 -270
  258. package/components/MenuManager/MenuTreeview.vue +0 -237
  259. package/components/MenuManager/MenuTreeviewNode.vue +0 -208
  260. package/components/PagePreview.vue +0 -58
  261. package/components/RootComponents.vue +0 -25
  262. package/components/SnackBar.vue +0 -69
  263. package/components/ThemeToggle.vue +0 -13
  264. package/components/layout/Sidebar/Sidebar.vue +0 -89
  265. package/components/layout/Sidebar/SidebarList.vue +0 -49
  266. package/components/layout/Sidebar/SidebarListItem.vue +0 -185
  267. package/components/layout/Sidebar/SidebarProfile.vue +0 -42
  268. package/components/layout/Sidebar/SidebarTitle.vue +0 -45
  269. package/components/layout/Topbar/Topbar.vue +0 -29
  270. package/components/layout/routebuilder.js +0 -48
  271. package/defaults/i18n.js +0 -37
  272. package/defaults/vuetify.js +0 -34
  273. package/layouts/default.vue +0 -47
  274. package/layouts/empty.vue +0 -16
  275. package/module.js +0 -80
  276. package/pages/index.vue +0 -37
  277. package/pages/login.vue +0 -10
  278. package/static/mapo/ckeditor/plugins/image2/dev/assets/image1.jpg +0 -0
  279. package/static/mapo/ckeditor/plugins/image2/dev/assets/image2.jpg +0 -0
  280. package/static/mapo/ckeditor/plugins/image2/dev/contents.css +0 -35
  281. package/static/mapo/ckeditor/plugins/image2/dev/image2.html +0 -338
  282. package/static/mapo/ckeditor/plugins/image2/dialogs/image2.js +0 -557
  283. package/static/mapo/ckeditor/plugins/image2/icons/hidpi/image.png +0 -0
  284. package/static/mapo/ckeditor/plugins/image2/icons/image.png +0 -0
  285. package/static/mapo/ckeditor/plugins/image2/lang/af.js +0 -21
  286. package/static/mapo/ckeditor/plugins/image2/lang/ar.js +0 -21
  287. package/static/mapo/ckeditor/plugins/image2/lang/az.js +0 -21
  288. package/static/mapo/ckeditor/plugins/image2/lang/bg.js +0 -21
  289. package/static/mapo/ckeditor/plugins/image2/lang/bn.js +0 -21
  290. package/static/mapo/ckeditor/plugins/image2/lang/bs.js +0 -21
  291. package/static/mapo/ckeditor/plugins/image2/lang/ca.js +0 -21
  292. package/static/mapo/ckeditor/plugins/image2/lang/cs.js +0 -21
  293. package/static/mapo/ckeditor/plugins/image2/lang/cy.js +0 -21
  294. package/static/mapo/ckeditor/plugins/image2/lang/da.js +0 -21
  295. package/static/mapo/ckeditor/plugins/image2/lang/de-ch.js +0 -21
  296. package/static/mapo/ckeditor/plugins/image2/lang/de.js +0 -21
  297. package/static/mapo/ckeditor/plugins/image2/lang/el.js +0 -21
  298. package/static/mapo/ckeditor/plugins/image2/lang/en-au.js +0 -21
  299. package/static/mapo/ckeditor/plugins/image2/lang/en-ca.js +0 -21
  300. package/static/mapo/ckeditor/plugins/image2/lang/en-gb.js +0 -21
  301. package/static/mapo/ckeditor/plugins/image2/lang/en.js +0 -21
  302. package/static/mapo/ckeditor/plugins/image2/lang/eo.js +0 -21
  303. package/static/mapo/ckeditor/plugins/image2/lang/es-mx.js +0 -21
  304. package/static/mapo/ckeditor/plugins/image2/lang/es.js +0 -21
  305. package/static/mapo/ckeditor/plugins/image2/lang/et.js +0 -21
  306. package/static/mapo/ckeditor/plugins/image2/lang/eu.js +0 -21
  307. package/static/mapo/ckeditor/plugins/image2/lang/fa.js +0 -21
  308. package/static/mapo/ckeditor/plugins/image2/lang/fi.js +0 -21
  309. package/static/mapo/ckeditor/plugins/image2/lang/fo.js +0 -21
  310. package/static/mapo/ckeditor/plugins/image2/lang/fr-ca.js +0 -21
  311. package/static/mapo/ckeditor/plugins/image2/lang/fr.js +0 -21
  312. package/static/mapo/ckeditor/plugins/image2/lang/gl.js +0 -21
  313. package/static/mapo/ckeditor/plugins/image2/lang/gu.js +0 -21
  314. package/static/mapo/ckeditor/plugins/image2/lang/he.js +0 -21
  315. package/static/mapo/ckeditor/plugins/image2/lang/hi.js +0 -21
  316. package/static/mapo/ckeditor/plugins/image2/lang/hr.js +0 -21
  317. package/static/mapo/ckeditor/plugins/image2/lang/hu.js +0 -21
  318. package/static/mapo/ckeditor/plugins/image2/lang/id.js +0 -21
  319. package/static/mapo/ckeditor/plugins/image2/lang/is.js +0 -21
  320. package/static/mapo/ckeditor/plugins/image2/lang/it.js +0 -21
  321. package/static/mapo/ckeditor/plugins/image2/lang/ja.js +0 -21
  322. package/static/mapo/ckeditor/plugins/image2/lang/ka.js +0 -21
  323. package/static/mapo/ckeditor/plugins/image2/lang/km.js +0 -21
  324. package/static/mapo/ckeditor/plugins/image2/lang/ko.js +0 -21
  325. package/static/mapo/ckeditor/plugins/image2/lang/ku.js +0 -21
  326. package/static/mapo/ckeditor/plugins/image2/lang/lt.js +0 -21
  327. package/static/mapo/ckeditor/plugins/image2/lang/lv.js +0 -21
  328. package/static/mapo/ckeditor/plugins/image2/lang/mk.js +0 -21
  329. package/static/mapo/ckeditor/plugins/image2/lang/mn.js +0 -21
  330. package/static/mapo/ckeditor/plugins/image2/lang/ms.js +0 -21
  331. package/static/mapo/ckeditor/plugins/image2/lang/nb.js +0 -21
  332. package/static/mapo/ckeditor/plugins/image2/lang/nl.js +0 -21
  333. package/static/mapo/ckeditor/plugins/image2/lang/no.js +0 -21
  334. package/static/mapo/ckeditor/plugins/image2/lang/oc.js +0 -21
  335. package/static/mapo/ckeditor/plugins/image2/lang/pl.js +0 -21
  336. package/static/mapo/ckeditor/plugins/image2/lang/pt-br.js +0 -21
  337. package/static/mapo/ckeditor/plugins/image2/lang/pt.js +0 -21
  338. package/static/mapo/ckeditor/plugins/image2/lang/ro.js +0 -21
  339. package/static/mapo/ckeditor/plugins/image2/lang/ru.js +0 -21
  340. package/static/mapo/ckeditor/plugins/image2/lang/si.js +0 -21
  341. package/static/mapo/ckeditor/plugins/image2/lang/sk.js +0 -21
  342. package/static/mapo/ckeditor/plugins/image2/lang/sl.js +0 -21
  343. package/static/mapo/ckeditor/plugins/image2/lang/sq.js +0 -21
  344. package/static/mapo/ckeditor/plugins/image2/lang/sr-latn.js +0 -21
  345. package/static/mapo/ckeditor/plugins/image2/lang/sr.js +0 -21
  346. package/static/mapo/ckeditor/plugins/image2/lang/sv.js +0 -21
  347. package/static/mapo/ckeditor/plugins/image2/lang/th.js +0 -21
  348. package/static/mapo/ckeditor/plugins/image2/lang/tr.js +0 -21
  349. package/static/mapo/ckeditor/plugins/image2/lang/tt.js +0 -21
  350. package/static/mapo/ckeditor/plugins/image2/lang/ug.js +0 -21
  351. package/static/mapo/ckeditor/plugins/image2/lang/uk.js +0 -21
  352. package/static/mapo/ckeditor/plugins/image2/lang/vi.js +0 -21
  353. package/static/mapo/ckeditor/plugins/image2/lang/zh-cn.js +0 -21
  354. package/static/mapo/ckeditor/plugins/image2/lang/zh.js +0 -21
  355. package/static/mapo/ckeditor/plugins/image2/plugin.js +0 -1798
  356. package/static/mapo/ckeditor/plugins/image2/samples/assets/image1.jpg +0 -0
  357. package/static/mapo/ckeditor/plugins/image2/samples/assets/image2.jpg +0 -0
  358. package/static/mapo/ckeditor/plugins/image2/samples/image2.html +0 -68
  359. package/static/mapo/ckeditor/skins/moono/dev/icons16.png +0 -0
  360. package/static/mapo/ckeditor/skins/moono/dev/icons16.svg +0 -2374
  361. package/static/mapo/ckeditor/skins/moono/dev/icons32.png +0 -0
  362. package/static/mapo/ckeditor/skins/moono/dev/icons32.svg +0 -2722
  363. package/static/mapo/ckeditor/skins/moono/dev/locations.json +0 -144
  364. package/static/mapo/ckeditor/skins/moono/dialog.css +0 -5
  365. package/static/mapo/ckeditor/skins/moono/dialog_ie.css +0 -5
  366. package/static/mapo/ckeditor/skins/moono/dialog_ie7.css +0 -5
  367. package/static/mapo/ckeditor/skins/moono/dialog_ie8.css +0 -5
  368. package/static/mapo/ckeditor/skins/moono/dialog_iequirks.css +0 -5
  369. package/static/mapo/ckeditor/skins/moono/editor.css +0 -5
  370. package/static/mapo/ckeditor/skins/moono/editor_gecko.css +0 -5
  371. package/static/mapo/ckeditor/skins/moono/editor_ie.css +0 -5
  372. package/static/mapo/ckeditor/skins/moono/editor_ie7.css +0 -5
  373. package/static/mapo/ckeditor/skins/moono/editor_ie8.css +0 -5
  374. package/static/mapo/ckeditor/skins/moono/editor_iequirks.css +0 -5
  375. package/static/mapo/ckeditor/skins/moono/icons.png +0 -0
  376. package/static/mapo/ckeditor/skins/moono/icons_hidpi.png +0 -0
  377. package/static/mapo/ckeditor/skins/moono/images/anchor.png +0 -0
  378. package/static/mapo/ckeditor/skins/moono/images/arrow.png +0 -0
  379. package/static/mapo/ckeditor/skins/moono/images/close.png +0 -0
  380. package/static/mapo/ckeditor/skins/moono/images/hidpi/anchor.png +0 -0
  381. package/static/mapo/ckeditor/skins/moono/images/hidpi/close.png +0 -0
  382. package/static/mapo/ckeditor/skins/moono/images/hidpi/lock-open.png +0 -0
  383. package/static/mapo/ckeditor/skins/moono/images/hidpi/lock.png +0 -0
  384. package/static/mapo/ckeditor/skins/moono/images/hidpi/refresh.png +0 -0
  385. package/static/mapo/ckeditor/skins/moono/images/lock-open.png +0 -0
  386. package/static/mapo/ckeditor/skins/moono/images/lock.png +0 -0
  387. package/static/mapo/ckeditor/skins/moono/images/refresh.png +0 -0
  388. package/static/mapo/ckeditor/skins/moono/images/spinner.gif +0 -0
  389. package/static/mapo/ckeditor/skins/moono/readme.md +0 -49
  390. package/static/mapo/ckeditor/skins/moono/skin.js +0 -10
  391. package/static/mapo/ckeditor/skins/moono-dark/dialog.css +0 -5
  392. package/static/mapo/ckeditor/skins/moono-dark/dialog_ie.css +0 -5
  393. package/static/mapo/ckeditor/skins/moono-dark/dialog_ie7.css +0 -5
  394. package/static/mapo/ckeditor/skins/moono-dark/dialog_ie8.css +0 -5
  395. package/static/mapo/ckeditor/skins/moono-dark/dialog_iequirks.css +0 -5
  396. package/static/mapo/ckeditor/skins/moono-dark/editor.css +0 -5
  397. package/static/mapo/ckeditor/skins/moono-dark/editor_gecko.css +0 -5
  398. package/static/mapo/ckeditor/skins/moono-dark/editor_ie.css +0 -5
  399. package/static/mapo/ckeditor/skins/moono-dark/editor_ie7.css +0 -5
  400. package/static/mapo/ckeditor/skins/moono-dark/editor_ie8.css +0 -5
  401. package/static/mapo/ckeditor/skins/moono-dark/editor_iequirks.css +0 -5
  402. package/static/mapo/ckeditor/skins/moono-dark/icons.png +0 -0
  403. package/static/mapo/ckeditor/skins/moono-dark/icons_hidpi.png +0 -0
  404. package/static/mapo/ckeditor/skins/moono-dark/images/arrow.png +0 -0
  405. package/static/mapo/ckeditor/skins/moono-dark/images/close.png +0 -0
  406. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/close.png +0 -0
  407. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/lock-open.png +0 -0
  408. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/lock.png +0 -0
  409. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/refresh.png +0 -0
  410. package/static/mapo/ckeditor/skins/moono-dark/images/lock-open.png +0 -0
  411. package/static/mapo/ckeditor/skins/moono-dark/images/lock.png +0 -0
  412. package/static/mapo/ckeditor/skins/moono-dark/images/refresh.png +0 -0
  413. package/static/mapo/ckeditor/skins/moono-dark/readme.md +0 -51
  414. package/static/mapo/ckeditor/skins/moono-dark/skin.js +0 -5
  415. package/static/mapo/favicon.ico +0 -0
  416. package/static/mapo/tinymce-skins/mapo-dark/content.inline.min.css +0 -7
  417. package/static/mapo/tinymce-skins/mapo-dark/content.min.css +0 -7
  418. package/static/mapo/tinymce-skins/mapo-dark/content.mobile.min.css +0 -7
  419. package/static/mapo/tinymce-skins/mapo-dark/skin.min.css +0 -7
  420. package/static/mapo/tinymce-skins/mapo-dark/skin.mobile.min.css +0 -7
  421. package/static/mapo/tinymce-skins/mapo-light/content.inline.min.css +0 -7
  422. package/static/mapo/tinymce-skins/mapo-light/content.min.css +0 -7
  423. package/static/mapo/tinymce-skins/mapo-light/content.mobile.min.css +0 -7
  424. package/static/mapo/tinymce-skins/mapo-light/skin.min.css +0 -7
  425. package/static/mapo/tinymce-skins/mapo-light/skin.mobile.min.css +0 -7
  426. package/translations/en-US.js +0 -177
  427. package/translations/it-IT.js +0 -180
@@ -0,0 +1,931 @@
1
+ <script setup lang="ts" generic="T extends object">
2
+ import {
3
+ ref,
4
+ shallowRef,
5
+ computed,
6
+ watch,
7
+ h,
8
+ resolveComponent,
9
+ useSlots,
10
+ } from "vue";
11
+ import type { Ref } from "vue";
12
+ import { useI18n } from "vue-i18n";
13
+ import type { TableColumn } from "@nuxt/ui";
14
+ import type { SortingState, PaginationState } from "@tanstack/vue-table";
15
+ import type { ListColumn } from "../types/list.js";
16
+ import { useSnackStore } from "@mapomodule/store/runtime/stores/snack";
17
+ import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
18
+ import { usePermissions } from "@mapomodule/store/runtime/composables/usePermissions";
19
+ import { useCrud } from "@mapomodule/core/runtime/api/crud";
20
+ import type { AnyFieldDescriptor, FieldRegistry } from "@mapomodule/form/types";
21
+ import { debounce, splitEndpointParams } from "@mapomodule/utils";
22
+ import { useRoute, useRouter } from "#app";
23
+
24
+ const props = withDefaults(
25
+ defineProps<{
26
+ endpoint?: string;
27
+ /**
28
+ * Offline mode: when provided, the table renders this array and applies
29
+ * search/filter/sort/pagination/drag/delete in memory — no API calls.
30
+ * Mutations (drag reorder, delete, quick-edit) emit `update:items` so the
31
+ * parent owns the source of truth.
32
+ */
33
+ items?: T[];
34
+ /**
35
+ * Clean endpoint used for detail / delete / updateOrder CRUD operations.
36
+ * Defaults to `endpoint` with the query string stripped.
37
+ * Pass this explicitly when `endpoint` carries user-configured query params
38
+ * (e.g. `?fields=id,title`) that must not be included in mutation URLs.
39
+ */
40
+ crudEndpoint?: string;
41
+ /**
42
+ * Extra query params merged into every `list()` call (on top of pagination /
43
+ * sort / search). Used by the parent `MapoList` to pass active filter values
44
+ * and tab params without baking them into the endpoint string.
45
+ */
46
+ filterParams?: Record<string, unknown>;
47
+ /** Initial page size. Default: 20. */
48
+ defaultPageSize?: number;
49
+ /** Page size options shown in the per-page selector. Default: [10, 20, 50, 100]. */
50
+ pageSizeOptions?: number[];
51
+ /**
52
+ * Custom response parser. When provided it replaces the built-in DRF / flat-array
53
+ * detection. Return `{ items, total }` from any shape your backend returns.
54
+ * @example (raw) => ({ items: raw.data, total: raw.meta.total })
55
+ */
56
+ responseAdapter?: (raw: unknown) => { items: T[]; total: number };
57
+ /**
58
+ * Custom pagination query params factory. When provided it replaces the default
59
+ * `{ page, page_size }` params. Use this to support offset/limit or cursor pagination.
60
+ * @example ({ page, pageSize }) => ({ offset: (page - 1) * pageSize, limit: pageSize })
61
+ */
62
+ paginationParams?: (state: {
63
+ page: number;
64
+ pageSize: number;
65
+ }) => Record<string, unknown>;
66
+ /**
67
+ * Hybrid mode: when true and `endpoint` is set, the table fetches the
68
+ * full dataset ONCE (no pagination/sort/filter params) and then runs
69
+ * search/filter/sort/pagination locally. Mutations (delete, drag, quick-edit)
70
+ * still hit the backend, then re-fetch. Ignored when `items` is provided.
71
+ */
72
+ clientSide?: boolean;
73
+ columns: ListColumn<T>[];
74
+ lookup?: string;
75
+ searchable?: boolean;
76
+ draggable?: boolean;
77
+ positionField?: string;
78
+ editFields?: AnyFieldDescriptor<T>[];
79
+ languages?: string[];
80
+ registry?: FieldRegistry;
81
+ /** Base path for the detail page. If set, each row shows a link button → `${detailBase}/${item[lookup]}`. */
82
+ detailBase?: string;
83
+ /**
84
+ * Django model name for permission gating (e.g. `"article"`).
85
+ * When provided, the edit and delete row buttons are hidden when the user
86
+ * lacks the corresponding `change` / `delete` permission.
87
+ */
88
+ permissionModel?: string;
89
+ }>(),
90
+ {
91
+ endpoint: "",
92
+ items: undefined,
93
+ clientSide: false,
94
+ lookup: "id",
95
+ searchable: true,
96
+ draggable: false,
97
+ positionField: "position",
98
+ editFields: () => [],
99
+ defaultPageSize: 20,
100
+ pageSizeOptions: () => [10, 20, 50, 100],
101
+ },
102
+ );
103
+
104
+ const offlineMode = computed(() => Array.isArray(props.items));
105
+ const hybridMode = computed(() => !offlineMode.value && props.clientSide);
106
+
107
+ const emit = defineEmits<{
108
+ "update:selection": [value: T[] | "all"];
109
+ "update:selectionQuery": [value: URLSearchParams];
110
+ "update:items": [value: T[]];
111
+ }>();
112
+
113
+ defineExpose({ refresh });
114
+
115
+ defineSlots<
116
+ {
117
+ /** Extra content rendered alongside the search input in the toolbar. */
118
+ "dtable.toolbar"(): any;
119
+ /** Override for the empty state displayed when no rows are found. */
120
+ "dtable.empty"(): any;
121
+ /** Override for the loading skeleton displayed while data is being fetched. */
122
+ "dtable.loading"(): any;
123
+ /** Catch-all for slots forwarded dynamically (e.g. `qedit.*`). */
124
+ [K: string]: (...args: any[]) => any;
125
+ } & {
126
+ /**
127
+ * Per-column cell override. Slot name: `cell.{column.key}`.
128
+ */
129
+ [K in keyof T as `cell.${K & string}`]: (props: {
130
+ item: T;
131
+ value: T[K];
132
+ }) => any;
133
+ }
134
+ >();
135
+
136
+ const slots = useSlots();
137
+
138
+ // T extends object but not Record<string,unknown>, so dynamic key access needs a cast.
139
+ // Casting the key to keyof T returns the union of all property types rather than `unknown`,
140
+ // which is both accurate and avoids any implicit-any errors at the call sites.
141
+ const atKey = (item: T, key: string): T[keyof T] => item[key as keyof T];
142
+
143
+ const { t } = useI18n();
144
+ const snack = useSnackStore();
145
+ const confirm = useConfirmStore();
146
+
147
+ // --- URL state (read once on mount, write on change) ---
148
+ const route = useRoute();
149
+ const router = useRouter();
150
+
151
+ // `crudBase` is the clean endpoint path used for detail / delete / updateOrder.
152
+ // It strips any query string from `endpoint` so mutations are never sent to a
153
+ // URL like `/api/case/?fields=id,title/1/`.
154
+ const crudBase =
155
+ props.crudEndpoint ??
156
+ (splitEndpointParams(props.endpoint).path || props.endpoint);
157
+ const crud = useCrud<T>(crudBase);
158
+
159
+ // --- Permissions ---
160
+ const { canChange, canDelete: canDeletePerm } = usePermissions();
161
+ const canEditRow = computed(
162
+ () => !props.permissionModel || canChange(props.permissionModel),
163
+ );
164
+ const canDeleteRow = computed(
165
+ () => !props.permissionModel || canDeletePerm(props.permissionModel),
166
+ );
167
+
168
+ // --- Data state ---
169
+ // `rows` holds the slice currently rendered (post search/filter/sort/pagination).
170
+ // In offline mode, the parent's full array lives in `props.items` and is the
171
+ // source of truth; this ref always holds the displayed page.
172
+ // shallowRef: rows are always reassigned wholesale (never mutated in place), so
173
+ // deep reactivity would only add per-cell Proxy overhead with no benefit.
174
+ const rows = shallowRef<T[]>([]) as Ref<T[]>;
175
+ // `fullDataset` caches the full server response in hybrid mode. Refilled on
176
+ // endpoint change or after a mutation; reused for every filter/sort/page change.
177
+ // shallowRef for the same reason — it holds a potentially large dataset that is
178
+ // only ever replaced as a whole by `fetchAll`.
179
+ const fullDataset = shallowRef<T[]>([]) as Ref<T[]>;
180
+ const hybridLoaded = ref(false);
181
+ const total = ref(0);
182
+ const loading = ref(false);
183
+
184
+ function toPositiveNumber(value: unknown, fallback: number): number {
185
+ const n = Number(value);
186
+ return Number.isFinite(n) && n > 0 ? n : fallback;
187
+ }
188
+
189
+ // --- Pagination (restored from URL) ---
190
+ const pagination = ref<PaginationState>({
191
+ pageIndex: route.query.page
192
+ ? Math.max(0, toPositiveNumber(route.query.page, 1) - 1)
193
+ : 0,
194
+ pageSize: route.query.page_size
195
+ ? toPositiveNumber(route.query.page_size, props.defaultPageSize)
196
+ : props.defaultPageSize,
197
+ });
198
+
199
+ // --- Sorting (restored from URL) ---
200
+ const sorting = ref<SortingState>(
201
+ route.query.ordering
202
+ ? String(route.query.ordering)
203
+ .split(",")
204
+ .map((o) => ({
205
+ id: o.startsWith("-") ? o.slice(1) : o,
206
+ desc: o.startsWith("-"),
207
+ }))
208
+ : [],
209
+ );
210
+
211
+ // --- Search (restored from URL) ---
212
+ const search = ref(route.query.search ? String(route.query.search) : "");
213
+
214
+ // Debounce the search input through the shared util (same mechanism as writeUrlState),
215
+ // resetting to the first page so results aren't hidden on a stale page index.
216
+ const onSearchInput = debounce((val: unknown) => {
217
+ search.value = String(val ?? "");
218
+ pagination.value = { ...pagination.value, pageIndex: 0 };
219
+ }, 350);
220
+
221
+ // Write pagination / sorting / search to the URL (debounced to avoid history spam).
222
+ const writeUrlState = debounce(() => {
223
+ const query: Record<string, string | undefined> = {
224
+ ...(route.query as Record<string, string>),
225
+ };
226
+ const page = pagination.value.pageIndex + 1;
227
+ if (page > 1) query.page = String(page);
228
+ else delete query.page;
229
+ if (pagination.value.pageSize !== props.defaultPageSize)
230
+ query.page_size = String(pagination.value.pageSize);
231
+ else delete query.page_size;
232
+ if (search.value) query.search = search.value;
233
+ else delete query.search;
234
+ if (sorting.value.length)
235
+ query.ordering = sorting.value
236
+ .map((s: { id: string; desc: boolean }) => `${s.desc ? "-" : ""}${s.id}`)
237
+ .join(",");
238
+ else delete query.ordering;
239
+ router.replace({ query });
240
+ }, 150);
241
+
242
+ watch([pagination, search, sorting], writeUrlState, { deep: true });
243
+
244
+ // --- Row selection ---
245
+ // Selection is keyed by primary key (lookup), not by row index, so pagination/sort/refresh
246
+ // changes do not affect which rows are marked as selected.
247
+ const rowSelection = ref<Record<string, boolean>>({});
248
+ const pkOf = (row: T) => String(atKey(row, props.lookup));
249
+ const isAllSelected = computed(
250
+ () =>
251
+ rows.value.length > 0 &&
252
+ rows.value.every((r) => rowSelection.value[pkOf(r)]),
253
+ );
254
+ const isIndeterminate = computed(() => {
255
+ const some = rows.value.some((r) => rowSelection.value[pkOf(r)]);
256
+ return some && !isAllSelected.value;
257
+ });
258
+
259
+ const selectedRows = computed<T[]>(() =>
260
+ rows.value.filter((r) => rowSelection.value[pkOf(r)]),
261
+ );
262
+ watch(selectedRows, (rows) => {
263
+ emit("update:selection", rows);
264
+ emit("update:selectionQuery", buildSelectionQuery());
265
+ });
266
+
267
+ function buildSelectionQuery(): URLSearchParams {
268
+ const params = new URLSearchParams();
269
+ params.set("page_size", String(pagination.value.pageSize));
270
+ if (search.value) params.set("search", search.value);
271
+ sorting.value.forEach((s) =>
272
+ params.set("ordering", `${s.desc ? "-" : ""}${s.id}`),
273
+ );
274
+ return params;
275
+ }
276
+
277
+ function toggleAll() {
278
+ if (isAllSelected.value) {
279
+ const next = { ...rowSelection.value };
280
+ for (const r of rows.value) delete next[pkOf(r)];
281
+ rowSelection.value = next;
282
+ } else {
283
+ const next = { ...rowSelection.value };
284
+ for (const r of rows.value) next[pkOf(r)] = true;
285
+ rowSelection.value = next;
286
+ }
287
+ }
288
+
289
+ function toggleRowByKey(key: string) {
290
+ const next = { ...rowSelection.value };
291
+ if (next[key]) delete next[key];
292
+ else next[key] = true;
293
+ rowSelection.value = next;
294
+ }
295
+
296
+ // --- Quick edit ---
297
+ const quickEditOpen = ref(false);
298
+ const quickEditId = ref<string | number | null>(null);
299
+
300
+ function openQuickEdit(id: string | number) {
301
+ quickEditId.value = id;
302
+ quickEditOpen.value = true;
303
+ }
304
+
305
+ // In offline mode, the quick-edit modal emits the locally edited item; we
306
+ // splice it back into the parent's array and emit `update:items` (no BE call).
307
+ function onQuickEditSaved(updated: T) {
308
+ if (offlineMode.value) {
309
+ const lk = props.lookup;
310
+ const next = (props.items ?? []).map((r) =>
311
+ String(atKey(r, lk)) === String(atKey(updated, lk)) ? updated : r,
312
+ );
313
+ emit("update:items", next);
314
+ return;
315
+ }
316
+ if (hybridMode.value) hybridLoaded.value = false;
317
+ refresh();
318
+ }
319
+
320
+ // Look up the item currently being edited in the source array (offline mode only).
321
+ const quickEditLocalItem = computed<T | null>(() => {
322
+ if (!offlineMode.value || quickEditId.value == null) return null;
323
+ return (
324
+ (props.items ?? []).find(
325
+ (r) => String(atKey(r, props.lookup)) === String(quickEditId.value),
326
+ ) ?? null
327
+ );
328
+ });
329
+
330
+ // --- Delete ---
331
+ async function deleteRow(item: T) {
332
+ const ok = await confirm.ask({
333
+ title: t("mapo.listTable.deleteItemTitle"),
334
+ message: t("mapo.confirmDelete"),
335
+ confirmText: t("mapo.delete"),
336
+ dangerous: true,
337
+ });
338
+ if (!ok) return;
339
+ if (offlineMode.value) {
340
+ const next = (props.items ?? []).filter(
341
+ (r) =>
342
+ String(atKey(r, props.lookup)) !== String(atKey(item, props.lookup)),
343
+ );
344
+ emit("update:items", next);
345
+ snack.show(t("mapo.listTable.itemDeleted"), "success");
346
+ return;
347
+ }
348
+ try {
349
+ await crud.delete(atKey(item, props.lookup) as string | number);
350
+ snack.show(t("mapo.listTable.itemDeleted"), "success");
351
+ if (hybridMode.value) hybridLoaded.value = false;
352
+ refresh();
353
+ } catch {
354
+ snack.show(t("mapo.listTable.deleteItemError"), "error");
355
+ }
356
+ }
357
+
358
+ // --- Drag reorder ---
359
+ // Reorder is only meaningful in the natural order, so it is disabled while a search or
360
+ // column sort is active (the displayed order would not match the persisted one).
361
+ const canReorder = computed(
362
+ () => props.draggable && !search.value && sorting.value.length === 0,
363
+ );
364
+
365
+ const tableWrapper = ref<HTMLElement | null>(null);
366
+ const dragFrom = ref<number | null>(null);
367
+ const dragOverIndex = ref<number | null>(null);
368
+
369
+ function rowElements(): HTMLElement[] {
370
+ return tableWrapper.value
371
+ ? Array.from(tableWrapper.value.querySelectorAll<HTMLElement>("tbody tr"))
372
+ : [];
373
+ }
374
+
375
+ function clearRowClasses() {
376
+ for (const el of rowElements())
377
+ el.classList.remove(
378
+ "mapo-drop-before",
379
+ "mapo-drop-after",
380
+ "mapo-drag-source",
381
+ );
382
+ }
383
+
384
+ function clearDragState() {
385
+ clearRowClasses();
386
+ dragFrom.value = null;
387
+ dragOverIndex.value = null;
388
+ }
389
+
390
+ function onDragStart(idx: number) {
391
+ if (!canReorder.value) return;
392
+ dragFrom.value = idx;
393
+ }
394
+
395
+ // Drop area = the whole row. UTable owns the <tr>, so drag events are delegated on the
396
+ // wrapper and the target row is resolved from the event target.
397
+ function onRowDragOver(e: DragEvent) {
398
+ if (dragFrom.value === null) return;
399
+ e.preventDefault(); // required to allow a drop
400
+ const tr = (e.target as HTMLElement | null)?.closest(
401
+ "tbody tr",
402
+ ) as HTMLElement | null;
403
+ if (!tr) return;
404
+ const els = rowElements();
405
+ const idx = els.indexOf(tr);
406
+ if (idx < 0) return;
407
+ const rect = tr.getBoundingClientRect();
408
+ const before = e.clientY < rect.top + rect.height / 2;
409
+ clearRowClasses();
410
+ tr.classList.add(before ? "mapo-drop-before" : "mapo-drop-after");
411
+ els[dragFrom.value]?.classList.add("mapo-drag-source");
412
+ dragOverIndex.value = idx;
413
+ }
414
+
415
+ function onRowDrop(e: DragEvent) {
416
+ e.preventDefault();
417
+ const from = dragFrom.value;
418
+ const to = dragOverIndex.value;
419
+ clearDragState();
420
+ if (from !== null && to !== null) void onDrop(from, to);
421
+ }
422
+
423
+ function onDragEnd() {
424
+ clearDragState();
425
+ }
426
+
427
+ async function onDrop(fromIdx: number, toIdx: number) {
428
+ if (fromIdx === toIdx) return;
429
+ const arr = [...rows.value];
430
+ const moved = arr[fromIdx]!;
431
+ const target = arr[toIdx]!;
432
+ arr.splice(fromIdx, 1);
433
+ arr.splice(toIdx, 0, moved);
434
+ rows.value = arr as T[];
435
+ if (offlineMode.value) {
436
+ // Reorder against the parent's full array (rows is only the current page).
437
+ const lk = props.lookup;
438
+ const full = [...(props.items ?? [])];
439
+ const fIdx = full.findIndex(
440
+ (r) => String(atKey(r, lk)) === String(atKey(moved, lk)),
441
+ );
442
+ const tIdx = full.findIndex(
443
+ (r) => String(atKey(r, lk)) === String(atKey(target, lk)),
444
+ );
445
+ if (fIdx >= 0 && tIdx >= 0) {
446
+ const [m] = full.splice(fIdx, 1);
447
+ full.splice(tIdx, 0, m!);
448
+ emit("update:items", full);
449
+ }
450
+ return;
451
+ }
452
+ // Persist the new order in a single request: the backend (Camomilla updateOrder)
453
+ // recalculates positions server-side, avoiding N parallel PATCHes and race conditions.
454
+ try {
455
+ await crud.updateOrder(
456
+ atKey(moved, props.lookup) as string | number,
457
+ atKey(target, props.lookup) as string | number,
458
+ );
459
+ snack.show(t("mapo.listTable.orderSaved"), "success");
460
+ if (hybridMode.value) {
461
+ hybridLoaded.value = false;
462
+ refresh();
463
+ }
464
+ } catch {
465
+ snack.show(t("mapo.listTable.orderError"), "error");
466
+ refresh();
467
+ }
468
+ }
469
+
470
+ // --- Offline pipeline: apply search/filter/sort/pagination in memory. ---
471
+ function applyOffline(source: T[]) {
472
+ let arr = [...source];
473
+
474
+ // Search: case-insensitive substring across all declared column keys.
475
+ if (search.value) {
476
+ const q = search.value.toLowerCase();
477
+ arr = arr.filter((row) =>
478
+ props.columns.some((c) =>
479
+ String(row[c.key] ?? "")
480
+ .toLowerCase()
481
+ .includes(q),
482
+ ),
483
+ );
484
+ }
485
+
486
+ // Filters + tab (filterParams): values use the v1 comma-joined format.
487
+ // - two ISO dates → inclusive [start, end] range (datepicker filter)
488
+ // - multiple values → set inclusion (multi-choice filter)
489
+ // - single value → equality
490
+ for (const [key, rawVal] of Object.entries(props.filterParams ?? {})) {
491
+ if (rawVal == null || rawVal === "") continue;
492
+ const parts = String(rawVal).split(",");
493
+ const isDateRange =
494
+ parts.length === 2 && parts.every((p) => !Number.isNaN(Date.parse(p)));
495
+ if (isDateRange) {
496
+ const [start, end] = parts;
497
+ arr = arr.filter((row) => {
498
+ const v = atKey(row, key);
499
+ if (v == null) return false;
500
+ const s = String(v);
501
+ return s >= start! && s <= end!;
502
+ });
503
+ } else if (parts.length > 1) {
504
+ const set = new Set(parts);
505
+ arr = arr.filter((row) => set.has(String(atKey(row, key))));
506
+ } else {
507
+ arr = arr.filter((row) => String(atKey(row, key)) === parts[0]);
508
+ }
509
+ }
510
+
511
+ // Sort: multi-column. Sorting columns are applied in order, each acting as
512
+ // a tiebreaker for the previous one (matches TanStack's default behavior).
513
+ if (sorting.value.length) {
514
+ const sortDefs = sorting.value;
515
+ arr.sort((a, b) => {
516
+ for (const s of sortDefs) {
517
+ const av = atKey(a, s.id);
518
+ const bv = atKey(b, s.id);
519
+ if (av == null && bv == null) continue;
520
+ if (av == null) return 1;
521
+ if (bv == null) return -1;
522
+ if (av < bv) return s.desc ? 1 : -1;
523
+ if (av > bv) return s.desc ? -1 : 1;
524
+ }
525
+ return 0;
526
+ });
527
+ }
528
+
529
+ total.value = arr.length;
530
+
531
+ // Recover from a stale page index (e.g. URL ?page=99 on a 3-row dataset).
532
+ const start = pagination.value.pageIndex * pagination.value.pageSize;
533
+ if (arr.length > 0 && start >= arr.length) {
534
+ pagination.value = { ...pagination.value, pageIndex: 0 };
535
+ rows.value = arr.slice(0, pagination.value.pageSize) as T[];
536
+ return;
537
+ }
538
+
539
+ rows.value = arr.slice(start, start + pagination.value.pageSize) as T[];
540
+ }
541
+
542
+ // --- Hybrid: fetch the full dataset once, then run applyOffline on it. ---
543
+ async function fetchAll() {
544
+ loading.value = true;
545
+ try {
546
+ const endpointParams = splitEndpointParams(props.endpoint).params;
547
+ const res = await crud.list(endpointParams as Record<string, string>);
548
+ let nextItems: T[] = [];
549
+ if (props.responseAdapter) {
550
+ nextItems = props.responseAdapter(res).items;
551
+ } else if (res && typeof res === "object" && "results" in res) {
552
+ nextItems = (res as { results: T[] }).results;
553
+ } else {
554
+ nextItems = res as unknown as T[];
555
+ }
556
+ fullDataset.value = nextItems;
557
+ hybridLoaded.value = true;
558
+ } catch {
559
+ snack.show(t("mapo.loadError"), "error");
560
+ } finally {
561
+ loading.value = false;
562
+ }
563
+ }
564
+
565
+ // --- Fetch ---
566
+ async function refresh() {
567
+ if (offlineMode.value) {
568
+ applyOffline(props.items ?? []);
569
+ return;
570
+ }
571
+ if (hybridMode.value) {
572
+ if (!hybridLoaded.value) await fetchAll();
573
+ applyOffline(fullDataset.value);
574
+ return;
575
+ }
576
+ loading.value = true;
577
+ try {
578
+ // Extract any query params the caller baked into the endpoint (e.g. ?fields=id,title).
579
+ const endpointParams = splitEndpointParams(props.endpoint).params;
580
+
581
+ const pageState = {
582
+ page: pagination.value.pageIndex + 1,
583
+ pageSize: pagination.value.pageSize,
584
+ };
585
+ const paginationP = props.paginationParams
586
+ ? props.paginationParams(pageState)
587
+ : { page: pageState.page, page_size: pageState.pageSize };
588
+
589
+ const params: Record<string, unknown> = {
590
+ ...endpointParams,
591
+ ...(props.filterParams ?? {}),
592
+ ...paginationP,
593
+ };
594
+ if (search.value) params.search = search.value;
595
+ if (sorting.value.length)
596
+ params.ordering = sorting.value
597
+ .map((s) => `${s.desc ? "-" : ""}${s.id}`)
598
+ .join(",");
599
+
600
+ const res = await crud.list(params as Record<string, string>);
601
+
602
+ let nextItems: T[] = [];
603
+ let nextTotal = 0;
604
+
605
+ if (props.responseAdapter) {
606
+ const adapted = props.responseAdapter(res);
607
+ nextItems = adapted.items;
608
+ nextTotal = adapted.total;
609
+ } else if (res && typeof res === "object" && "results" in res) {
610
+ nextItems = (res as { results: T[]; count: number }).results;
611
+ nextTotal = (res as { results: T[]; count: number }).count;
612
+ } else {
613
+ nextItems = res as unknown as T[];
614
+ nextTotal = (res as unknown as T[]).length;
615
+ }
616
+
617
+ // Recover from stale URL pagination (e.g. page=99) that yields an empty
618
+ // page while the dataset still has rows. Reset to first page and re-fetch.
619
+ if (
620
+ nextItems.length === 0 &&
621
+ nextTotal > 0 &&
622
+ pagination.value.pageIndex > 0
623
+ ) {
624
+ pagination.value = { ...pagination.value, pageIndex: 0 };
625
+ return;
626
+ }
627
+
628
+ rows.value = nextItems;
629
+ total.value = nextTotal;
630
+ } catch {
631
+ snack.show(t("mapo.loadError"), "error");
632
+ } finally {
633
+ loading.value = false;
634
+ }
635
+ }
636
+
637
+ // Invalidate the hybrid cache whenever the endpoint or mode changes.
638
+ watch([() => props.endpoint, () => props.clientSide], () => {
639
+ hybridLoaded.value = false;
640
+ });
641
+
642
+ // Serialize filterParams to detect deep changes without a deep watcher on the array.
643
+ const filterParamsKey = computed(() =>
644
+ JSON.stringify(props.filterParams ?? {}),
645
+ );
646
+
647
+ // Watch all sources that should trigger a refresh.
648
+ // When the endpoint or filter context changes, reset to page 1 first.
649
+ watch(
650
+ [
651
+ () => props.endpoint,
652
+ () => props.items,
653
+ filterParamsKey,
654
+ () => pagination.value.pageIndex,
655
+ () => pagination.value.pageSize,
656
+ sorting,
657
+ search,
658
+ ],
659
+ ([newEndpoint, , newFilters], [oldEndpoint, , oldFilters]) => {
660
+ const contextChanged =
661
+ newEndpoint !== oldEndpoint || newFilters !== oldFilters;
662
+ if (contextChanged && pagination.value.pageIndex !== 0) {
663
+ pagination.value = { ...pagination.value, pageIndex: 0 };
664
+ } else {
665
+ refresh();
666
+ }
667
+ },
668
+ { immediate: true, deep: true },
669
+ );
670
+
671
+ // --- TanStack column defs ---
672
+ const UCheckbox = resolveComponent("UCheckbox");
673
+ const UButton = resolveComponent("UButton");
674
+ const UIcon = resolveComponent("UIcon");
675
+
676
+ const tableColumns = computed<TableColumn<T>[]>(() => {
677
+ const cols: TableColumn<T>[] = [];
678
+
679
+ // Checkbox column
680
+ cols.push({
681
+ id: "__select__",
682
+ header: () =>
683
+ h(UCheckbox, {
684
+ modelValue: isAllSelected.value,
685
+ indeterminate: isIndeterminate.value,
686
+ "onUpdate:modelValue": toggleAll,
687
+ ariaLabel: t("mapo.listTable.selectAllRows"),
688
+ }),
689
+ cell: ({ row }: { row: { original: T } }) => {
690
+ const k = pkOf(row.original);
691
+ return h(UCheckbox, {
692
+ modelValue: !!rowSelection.value[k],
693
+ "onUpdate:modelValue": () => toggleRowByKey(k),
694
+ ariaLabel: t("mapo.listTable.selectRow"),
695
+ });
696
+ },
697
+ meta: { class: { th: "w-10", td: "w-10" } },
698
+ } as TableColumn<T>);
699
+
700
+ // Drag handle column
701
+ if (props.draggable) {
702
+ cols.push({
703
+ id: "__drag__",
704
+ header: "",
705
+ cell: ({ row }: { row: { index: number } }) =>
706
+ h(
707
+ "span",
708
+ {
709
+ class: canReorder.value
710
+ ? "cursor-grab text-muted"
711
+ : "cursor-not-allowed text-muted opacity-30",
712
+ draggable: canReorder.value,
713
+ title: canReorder.value
714
+ ? t("mapo.listTable.dragToReorder")
715
+ : t("mapo.listTable.clearToReorder"),
716
+ onDragstart: (e: DragEvent) => {
717
+ e.dataTransfer?.setData("text/plain", "");
718
+ onDragStart(row.index);
719
+ },
720
+ },
721
+ h(UIcon, { name: "i-lucide-grip-vertical", class: "h-4 w-4" }),
722
+ ),
723
+ meta: { class: { th: "w-8", td: "w-8" } },
724
+ } as TableColumn<T>);
725
+ }
726
+
727
+ // Data columns — the first column gets a navigation link when `detailBase` is set.
728
+ // Any column can be overridden with a `cell.{key}` slot (receives `{ item, value }`).
729
+ const NuxtLink = resolveComponent("NuxtLink");
730
+ for (let i = 0; i < props.columns.length; i++) {
731
+ const col = props.columns[i]!;
732
+ const isFirst = i === 0 && !!props.detailBase;
733
+ cols.push({
734
+ accessorKey: col.key,
735
+ header: col.label,
736
+ cell: ({ row }: { row: { original: T } }) => {
737
+ const cellSlot = slots[`cell.${col.key}`];
738
+ if (cellSlot)
739
+ return cellSlot({
740
+ item: row.original,
741
+ value: atKey(row.original, col.key),
742
+ });
743
+ const cellVal = atKey(row.original, col.key);
744
+ if (isFirst) {
745
+ return h(
746
+ NuxtLink,
747
+ {
748
+ to: `${props.detailBase}/${atKey(row.original, props.lookup)}`,
749
+ class: "font-medium hover:underline",
750
+ },
751
+ () => String(cellVal ?? "—"),
752
+ );
753
+ }
754
+ return String(cellVal ?? "—");
755
+ },
756
+ meta: { class: { td: col.class ?? "" } },
757
+ } as TableColumn<T>);
758
+ }
759
+
760
+ // Actions column
761
+ cols.push({
762
+ id: "__actions__",
763
+ header: "",
764
+ cell: ({ row }: { row: { original: T } }) => {
765
+ const buttons: ReturnType<typeof h>[] = [];
766
+ if (props.editFields.length > 0 && canEditRow.value) {
767
+ buttons.push(
768
+ h(UButton, {
769
+ size: "xs",
770
+ variant: "ghost",
771
+ color: "neutral",
772
+ icon: "i-lucide-pencil",
773
+ onClick: () =>
774
+ openQuickEdit(
775
+ atKey(row.original, props.lookup) as string | number,
776
+ ),
777
+ }),
778
+ );
779
+ }
780
+ if (canDeleteRow.value) {
781
+ buttons.push(
782
+ h(UButton, {
783
+ size: "xs",
784
+ variant: "ghost",
785
+ color: "error",
786
+ icon: "i-lucide-trash-2",
787
+ onClick: () => deleteRow(row.original),
788
+ }),
789
+ );
790
+ }
791
+ return h(
792
+ "div",
793
+ { class: "flex items-center gap-1 justify-end" },
794
+ buttons,
795
+ );
796
+ },
797
+ meta: { class: { th: "text-right", td: "text-right" } },
798
+ } as TableColumn<T>);
799
+
800
+ return cols;
801
+ });
802
+
803
+ // --- Pagination for UTable ---
804
+ const paginationOptions = computed(() => ({
805
+ manualPagination: true,
806
+ rowCount: total.value,
807
+ }));
808
+
809
+ const sortingOptions = computed(() => ({
810
+ manualSorting: true,
811
+ }));
812
+ </script>
813
+
814
+ <template>
815
+ <div class="mapo-list-table space-y-3">
816
+ <!-- Search -->
817
+ <div v-if="searchable" class="flex items-center gap-2">
818
+ <UInput
819
+ :model-value="search"
820
+ :placeholder="t('mapo.search')"
821
+ icon="i-lucide-search"
822
+ size="sm"
823
+ class="max-w-xs"
824
+ @update:model-value="onSearchInput"
825
+ />
826
+ <slot name="dtable.toolbar" />
827
+ </div>
828
+
829
+ <!-- Table — the drop area spans the whole row via delegated DnD on this wrapper. -->
830
+ <div
831
+ ref="tableWrapper"
832
+ @dragover="onRowDragOver"
833
+ @drop="onRowDrop"
834
+ @dragend="onDragEnd"
835
+ >
836
+ <UTable
837
+ :data="rows"
838
+ :columns="tableColumns"
839
+ :loading="loading"
840
+ :pagination="pagination"
841
+ :pagination-options="paginationOptions"
842
+ :sorting="sorting"
843
+ :sorting-options="sortingOptions"
844
+ :empty="t('mapo.listTable.noItems')"
845
+ @update:pagination="pagination = $event ?? pagination"
846
+ @update:sorting="sorting = $event ?? sorting"
847
+ >
848
+ <template #empty>
849
+ <slot name="dtable.empty">
850
+ <div class="flex flex-col items-center gap-2 py-8 text-muted">
851
+ <UIcon name="i-lucide-inbox" class="h-8 w-8" />
852
+ <span class="text-sm">{{ t("mapo.listTable.noItems") }}</span>
853
+ </div>
854
+ </slot>
855
+ </template>
856
+
857
+ <template #loading>
858
+ <slot name="dtable.loading">
859
+ <div class="flex justify-center py-8">
860
+ <UIcon
861
+ name="i-lucide-loader-circle"
862
+ class="h-6 w-6 animate-spin text-muted"
863
+ />
864
+ </div>
865
+ </slot>
866
+ </template>
867
+ </UTable>
868
+ </div>
869
+
870
+ <!-- Pagination controls -->
871
+ <div class="flex items-center justify-between text-sm text-muted">
872
+ <span>{{ t("mapo.listTable.totalItems", { total }) }}</span>
873
+ <UPagination
874
+ :model-value="pagination.pageIndex + 1"
875
+ :total="total"
876
+ :items-per-page="pagination.pageSize"
877
+ size="sm"
878
+ @update:model-value="
879
+ pagination = { ...pagination, pageIndex: $event - 1 }
880
+ "
881
+ />
882
+ <USelect
883
+ :model-value="pagination.pageSize"
884
+ :items="
885
+ pageSizeOptions.map((n) => ({
886
+ label: t('mapo.listTable.perPage', { n }),
887
+ value: n,
888
+ }))
889
+ "
890
+ size="xs"
891
+ class="w-28"
892
+ @update:model-value="
893
+ pagination = { pageIndex: 0, pageSize: Number($event) }
894
+ "
895
+ />
896
+ </div>
897
+
898
+ <!-- Quick edit modal -->
899
+ <MapoListQuickEdit
900
+ v-if="editFields.length > 0"
901
+ v-model:open="quickEditOpen"
902
+ :endpoint="crudBase"
903
+ :item-id="quickEditId"
904
+ :edit-fields="editFields"
905
+ :lookup="lookup"
906
+ :languages="languages"
907
+ :registry="registry"
908
+ :offline="offlineMode"
909
+ :local-item="quickEditLocalItem"
910
+ @saved="onQuickEditSaved"
911
+ >
912
+ <template v-for="(_, name) in $slots" #[name]="slotProps">
913
+ <slot :name="`qedit.${String(name)}`" v-bind="slotProps ?? {}" />
914
+ </template>
915
+ </MapoListQuickEdit>
916
+ </div>
917
+ </template>
918
+
919
+ <style scoped>
920
+ /* Drag-reorder visual feedback. Classes are toggled imperatively on UTable's <tr>
921
+ elements (UTable owns that DOM), so :deep() is required to reach them. */
922
+ .mapo-list-table :deep(tbody tr.mapo-drag-source) {
923
+ opacity: 0.4;
924
+ }
925
+ .mapo-list-table :deep(tbody tr.mapo-drop-before > td) {
926
+ box-shadow: inset 0 2px 0 0 var(--ui-primary, #3b82f6);
927
+ }
928
+ .mapo-list-table :deep(tbody tr.mapo-drop-after > td) {
929
+ box-shadow: inset 0 -2px 0 0 var(--ui-primary, #3b82f6);
930
+ }
931
+ </style>