@mapomodule/uikit 1.0.0 → 2.0.0-beta.2

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