@mapomodule/uikit 2.0.0-beta.12 → 2.0.0-beta.14

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 (68) hide show
  1. package/README.md +46 -174
  2. package/dist/__tests__/MapoConfirmDialog.component.test.d.ts +2 -0
  3. package/dist/__tests__/MapoConfirmDialog.component.test.d.ts.map +1 -0
  4. package/dist/__tests__/MapoDetail.component.test.d.ts +2 -0
  5. package/dist/__tests__/MapoDetail.component.test.d.ts.map +1 -0
  6. package/dist/__tests__/MapoDetailLangSwitch.component.test.d.ts +2 -0
  7. package/dist/__tests__/MapoDetailLangSwitch.component.test.d.ts.map +1 -0
  8. package/dist/__tests__/MapoListTable.component.test.d.ts +2 -0
  9. package/dist/__tests__/MapoListTable.component.test.d.ts.map +1 -0
  10. package/dist/__tests__/__mocks__/nuxt-app.d.ts +9 -0
  11. package/dist/__tests__/__mocks__/nuxt-app.d.ts.map +1 -0
  12. package/dist/__tests__/listTable.test.d.ts +2 -0
  13. package/dist/__tests__/listTable.test.d.ts.map +1 -0
  14. package/dist/__tests__/mediaLanguages.test.d.ts +2 -0
  15. package/dist/__tests__/mediaLanguages.test.d.ts.map +1 -0
  16. package/dist/module.json +1 -1
  17. package/dist/runtime/assets/main.css +1 -1
  18. package/dist/runtime/components/MapoConfirmDialog.vue +18 -1
  19. package/dist/runtime/components/MapoConfirmDialog.vue.d.ts.map +1 -1
  20. package/dist/runtime/components/MapoDetail.vue +43 -11
  21. package/dist/runtime/components/MapoDetail.vue.d.ts +76 -0
  22. package/dist/runtime/components/MapoDetail.vue.d.ts.map +1 -1
  23. package/dist/runtime/components/MapoDetailLangSwitch.vue +21 -25
  24. package/dist/runtime/components/MapoDetailLangSwitch.vue.d.ts +4 -3
  25. package/dist/runtime/components/MapoDetailLangSwitch.vue.d.ts.map +1 -1
  26. package/dist/runtime/components/MapoList.vue +3 -2
  27. package/dist/runtime/components/MapoList.vue.d.ts +9 -4
  28. package/dist/runtime/components/MapoList.vue.d.ts.map +1 -1
  29. package/dist/runtime/components/MapoListTable.vue +98 -32
  30. package/dist/runtime/components/MapoListTable.vue.d.ts +11 -6
  31. package/dist/runtime/components/MapoListTable.vue.d.ts.map +1 -1
  32. package/dist/runtime/components/MapoMediaEditor.vue +10 -4
  33. package/dist/runtime/components/MapoMediaEditor.vue.d.ts +1 -0
  34. package/dist/runtime/components/MapoMediaEditor.vue.d.ts.map +1 -1
  35. package/dist/runtime/components/MapoMediaPreview.vue.d.ts +1 -1
  36. package/dist/runtime/components/MapoMediaPreview.vue.d.ts.map +1 -1
  37. package/dist/runtime/components/MapoMediaUploader.vue +21 -21
  38. package/dist/runtime/components/MapoMediaUploader.vue.d.ts.map +1 -1
  39. package/dist/runtime/components/MapoMenuTreeview.vue.d.ts +1 -1
  40. package/dist/runtime/components/MapoMenuTreeview.vue.d.ts.map +1 -1
  41. package/dist/runtime/components/MapoMenuTreeviewNode.vue.d.ts +2 -2
  42. package/dist/runtime/stores/media.d.ts +8 -2
  43. package/dist/runtime/stores/media.d.ts.map +1 -1
  44. package/dist/runtime/stores/media.js +16 -0
  45. package/dist/runtime/types/list.d.ts +10 -2
  46. package/dist/runtime/types/list.d.ts.map +1 -1
  47. package/dist/runtime/utils/listTable.d.ts +29 -0
  48. package/dist/runtime/utils/listTable.d.ts.map +1 -0
  49. package/dist/runtime/utils/listTable.js +21 -0
  50. package/package.json +6 -6
  51. package/src/__tests__/MapoConfirmDialog.component.test.ts +165 -0
  52. package/src/__tests__/MapoDetail.component.test.ts +293 -0
  53. package/src/__tests__/MapoDetailLangSwitch.component.test.ts +145 -0
  54. package/src/__tests__/MapoListTable.component.test.ts +504 -0
  55. package/src/__tests__/__mocks__/nuxt-app.ts +8 -0
  56. package/src/__tests__/listTable.test.ts +82 -0
  57. package/src/__tests__/mediaLanguages.test.ts +66 -0
  58. package/src/runtime/assets/main.css +9 -0
  59. package/src/runtime/components/MapoConfirmDialog.vue +28 -1
  60. package/src/runtime/components/MapoDetail.vue +78 -11
  61. package/src/runtime/components/MapoDetailLangSwitch.vue +26 -27
  62. package/src/runtime/components/MapoList.vue +13 -5
  63. package/src/runtime/components/MapoListTable.vue +128 -41
  64. package/src/runtime/components/MapoMediaEditor.vue +17 -4
  65. package/src/runtime/components/MapoMediaUploader.vue +25 -21
  66. package/src/runtime/stores/media.ts +32 -0
  67. package/src/runtime/types/list.ts +10 -2
  68. package/src/runtime/utils/listTable.ts +54 -0
package/README.md CHANGED
@@ -1,199 +1,71 @@
1
1
  # @mapomodule/uikit
2
2
 
3
- The UI shell of Mapo. Provides the admin layout, sidebar, topbar, login page, feedback components, and the **MapoOverride** system for full component replacement.
4
-
5
- Built on [Nuxt UI v3](https://ui.nuxt.com) + [Tailwind v4](https://tailwindcss.com).
3
+ Everything an admin user sees in Mapo: the layouts, sidebar, topbar and login page, the list and detail pages, the media manager, the menu editor and the feedback components, plus theming and the MapoOverride system. Built on Nuxt UI v4 and Tailwind CSS v4.
6
4
 
7
5
  ## Installation
8
6
 
9
- Typically installed via the meta-package [`mapomodule`](../../mapomodule/). Standalone:
7
+ Install it through the meta-package [`mapomodule`](https://www.npmjs.com/package/mapomodule), which also registers the `core`, `store`, `form` and `i18n` modules these components rely on. Configure it under `mapo.uikit`, and register `@nuxt/ui` before `mapomodule`:
10
8
 
11
9
  ```bash
12
- pnpm add @mapomodule/uikit @nuxt/ui
10
+ pnpm add mapomodule@next @nuxt/ui
13
11
  ```
14
12
 
15
13
  ```ts
16
- // nuxt.config.ts — @nuxt/ui MUST come before mapomodule
14
+ // nuxt.config.ts
17
15
  export default defineNuxtConfig({
18
- modules: ["@nuxt/ui", "@mapomodule/uikit"],
19
- mapoUikit: {
20
- css: "~/assets/css/theme.css", // optional CSS token override
21
- ui: { button: { defaultVariants: { color: "primary" } } }, // optional Nuxt UI defaults
22
- },
23
- });
24
- ```
25
-
26
- When installed via `mapomodule`, configure under `mapo.uikit` instead.
27
-
28
- ## What you get
29
-
30
- ### Layouts
31
-
32
- | Layout | Description |
33
- | -------------- | ------------------------------------------------------------------------ |
34
- | `mapo-default` | Full admin shell: collapsible sidebar + topbar + scrollable content area |
35
- | `mapo-empty` | Bare wrapper — used for the login page |
36
-
37
- ### Components (auto-imported)
38
-
39
- #### Layout & navigation
40
-
41
- | Component | Description |
42
- | --------------------- | ---------------------------------------------------------------------------- |
43
- | `MapoSidebar` | Collapsible sidebar with mini mode, auto-nav from route meta, footer section |
44
- | `MapoSidebarList` | Recursive nav tree built from `route.meta.label` / `meta.parent` |
45
- | `MapoSidebarListItem` | Single nav item with permission filtering and nested collapse |
46
- | `MapoSidebarProfile` | User profile row (avatar + username + logout) for the sidebar footer |
47
- | `MapoTopbar` | Top bar with drawer toggle and left/default/right slots |
48
- | `MapoThemeToggle` | Dark/light mode toggle via `useColorMode()` — drop-in for any slot |
49
- | `MapoLogoutButton` | Standalone logout button with `variant`, `color`, `size`, `iconOnly` props |
50
-
51
- #### Feedback
52
-
53
- | Component | Description |
54
- | -------------------- | --------------------------------------------------------- |
55
- | `MapoLogin` | Split-panel login form; slots: `brand`, `panel`, `footer` |
56
- | `MapoSnackBar` | Imperative snackbar driven by `useSnackStore` |
57
- | `MapoConfirmDialog` | Promise-based confirm dialog driven by `useConfirmStore` |
58
- | `MapoRootComponents` | Mounts `MapoSnackBar` + `MapoConfirmDialog` in the layout |
59
-
60
- #### List engine
61
-
62
- | Component | Description |
63
- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
64
- | `MapoList` | Full list shell: composes head, filters, actions, tabs, table, and quick-edit. URL state (page, sort, search, filters, tab) synced automatically. |
65
- | `MapoListHead` | Title, search bar, and primary action button row |
66
- | `MapoListFilters` | Filter panel driven by `FilterDescriptor[]`. v1 backend contract (`key=v1,v2`); per-filter override slots (`filter.{value}` / `.title` / `.content` / `.icon`) |
67
- | `MapoListActions` | Bulk-action toolbar (delete, reorder) — appears on selection. Supports `ActionDescriptor.dangerous` to render Apply/confirm with error styling for destructive actions. |
68
- | `MapoListTabs` | Tabbed status filter via `meta.tabs` |
69
- | `MapoListTable` | Data table with server-side pagination, sort, selection, and whole-row drag reorder (drop-line feedback; auto-disabled while a search/sort is active). Pass `permissionModel` to gate edit/delete row actions. |
70
- | `MapoListQuickEdit` | Quick-edit modal driven by the same `FieldDescriptor[]` as the detail form |
71
-
72
- #### Media Manager
73
-
74
- | Component | Description |
75
- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
76
- | `MapoDropArea` | Standalone drag-and-drop area (reusable outside media manager) |
77
- | `MapoMediaPreview` | MIME-aware preview: `image` → `<img>`, `video` → `<video>`, other → file icon |
78
- | `MapoMediaBreadcrumbs` | Folder navigation breadcrumb |
79
- | `MapoMediaFolders` | Folder sidebar with MIME filters (image/video/audio/document) |
80
- | `MapoMediaGallery` | Responsive CSS Grid gallery with bulk selection and pagination |
81
- | `MapoMediaEditor` | Right-side drawer for editing media metadata (title, alt text, translations); shows linked models, open-in-new-tab, and gates Edit/Delete on the media model permissions |
82
- | `MapoMediaFileChanger` | Replace an existing file while optionally preserving its URL |
83
- | `MapoMediaUploader` | Upload queue with per-file progress, inline metadata (title/alt/description), and destination-folder selection |
84
- | `MapoMediaManager` | Main orchestrator shell (sidebar + gallery + uploader + editor drawer) |
85
- | `MapoMediaManagerDialog` | `UModal` wrapper for picker mode — single or multi selection with confirm |
86
-
87
- **Form fields** — the `media`, `media-m2m`, and `enhanced-media` field types ship with [`@mapomodule/form`](../form/README.md) in its default registry; they drive the picker above and need this package installed to work.
88
-
89
- Media config (endpoints + upload limits) goes under `mapo.uikit.media`; backend-specific request/response transforms are handled by a pluggable `$mapoMediaAdapter` (Camomilla ships its own). See [docs/uikit/media.md](../../../docs/uikit/media.md).
90
-
91
- ```ts
92
- mapo: {
93
- uikit: {
94
- media: {
95
- endpoints: { media: "/api/media", folders: "/api/media-folders" },
96
- maxImageSize: 10, // MB
97
- maxVideoSize: 100, // MB
98
- permissionsModel: "media", // Django model for editor change/delete checks
99
- },
100
- },
101
- },
102
- ```
103
-
104
- #### Detail shell
105
-
106
- | Component | Description |
107
- | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
108
- | `MapoDetail` | Two-column detail shell: `useCrud` lifecycle, differential PATCH, error mapping, draft auto-save (`:draft="true"`). Supports permission gating (`permissionModel`), multipart control (`multipart`), live preview (`previewField`), and backend-derived languages (`forceLanguages`). |
109
- | `MapoDetailLangSwitch` | Language tabs with per-language error badge — syncs the `?lang=` query param |
110
-
111
- ### Layout slots (`mapo-default`)
112
-
113
- | Slot | Renders in |
114
- | -------------------- | ---------------------------------------------------- |
115
- | `sidebar:logo` | Sidebar header — replaces the default logo/name link |
116
- | `sidebar:nav-top` | Above the auto-generated nav list |
117
- | `sidebar:nav-bottom` | Below the nav list, above the footer row |
118
- | `sidebar:footer` | Replaces the user avatar + logout row |
119
- | `topbar:left` | Immediately after the drawer toggle button |
120
- | `topbar` | Center area of the topbar (flex-1) |
121
- | `topbar:right` | Right cluster of the topbar |
122
-
123
- ## Theming
124
-
125
- ### ① CSS token override
126
-
127
- Pass a CSS file via `mapo.uikit.css`. It is loaded **after** the base uikit CSS so your values always win:
128
-
129
- ```css
130
- /* assets/css/theme.css */
131
- @import "tailwindcss";
132
- @import "@nuxt/ui";
133
-
134
- :root {
135
- --color-primary-500: oklch(0.59 0.25 290); /* violet */
136
- --ui-radius: var(--radius-lg);
137
- --ui-bg: var(--color-neutral-50);
138
- }
139
-
140
- .dark {
141
- --ui-bg: var(--color-neutral-950);
142
- }
143
- ```
144
-
145
- ### ② Nuxt UI component defaults
146
-
147
- Pass a partial Nuxt UI config via `mapo.uikit.ui`. Deep-merged into `nuxt.options.ui`:
148
-
149
- ```ts
150
- mapo: {
151
- uikit: {
152
- ui: {
153
- button: { defaultVariants: { color: "primary", variant: "solid" } },
154
- card: { slots: { root: "rounded-xl shadow-md" } },
155
- input: { defaultVariants: { variant: "outline" } },
16
+ modules: ["@nuxt/ui", "mapomodule"],
17
+ mapo: {
18
+ uikit: {
19
+ css: "~/assets/css/theme.css",
20
+ media: {
21
+ endpoints: { media: "/api/media", folders: "/api/media-folders" },
22
+ },
156
23
  },
157
24
  },
158
- },
25
+ });
159
26
  ```
160
27
 
161
- ## MapoOverride — component replacement
28
+ Mapo v2 is published on the `next` dist-tag while it is in beta.
162
29
 
163
- Create a file in `app/mapooverride/` matching any Mapo component name to replace it entirely at build time:
30
+ | Option | Default | Description |
31
+ | ------------------------- | ---------------------- | --------------------------------------------------------------------------------------------- |
32
+ | `css` | — | Your CSS file, loaded after Mapo's base CSS so its tokens win |
33
+ | `ui` | `{}` | Nuxt UI component defaults, merged into `nuxt.options.ui`; keys the app sets there itself win |
34
+ | `media.endpoints.media` | `"/api/media"` | Media endpoint |
35
+ | `media.endpoints.folders` | `"/api/media-folders"` | Media folders endpoint |
36
+ | `media.maxImageSize` | `10` | Upload limit for images, in MB |
37
+ | `media.maxVideoSize` | `100` | Upload limit for videos, in MB |
38
+ | `media.permissionsModel` | `"media"` | Django model whose permissions gate editing and deleting in the media editor |
164
39
 
165
- ```
166
- app/
167
- └── mapooverride/
168
- ├── MapoTopbar.vue ← replaces MapoTopbar globally
169
- ├── MapoSidebar.vue
170
- └── MapoLogin.vue
171
- ```
40
+ ## What you get
172
41
 
173
- The `@mapomodule/uikit` module hooks into Nuxt's `components:extend` and swaps the `filePath` — no imports, no registration needed. Keep props and slots compatible with the original.
42
+ Components are auto-imported.
174
43
 
175
- Overridable components: `MapoTopbar`, `MapoSidebar`, `MapoSidebarList`, `MapoSidebarListItem`, `MapoSidebarProfile`, `MapoLogin`, `MapoLogoutButton`, `MapoThemeToggle`, `MapoSnackBar`, `MapoConfirmDialog`, `MapoRootComponents`, `MapoDetail`, `MapoDetailLangSwitch`, `MapoList`, `MapoListTable`, `MapoListFilters`, `MapoListActions`, `MapoListHead`, `MapoListQuickEdit`, `MapoMediaManager`, `MapoMediaManagerDialog`, `MapoMediaGallery`, `MapoMediaEditor`, `MapoMediaUploader`, `MapoMediaFolders`.
44
+ | Area | Components and APIs |
45
+ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
46
+ | Shell | The `mapo-default` and `mapo-empty` layouts, `MapoSidebar` (built from route metadata), `MapoTopbar`, `MapoLogin`, `MapoThemeToggle`, `MapoLangSwitcher`, `MapoLogoutButton`; a `/login` and a `/` page when the app has none |
47
+ | Lists | `MapoList`: server-side pagination, search, sorting, filters, tabs, bulk actions, drag reorder and quick edit, with the state synced to the URL |
48
+ | Details | `MapoDetail`: loads the record, renders the form, saves a differential `PATCH`, maps 400 errors onto fields, drafts and per-language editing |
49
+ | Media | `MapoMediaManager`, the `MapoMediaManagerDialog` picker, `useMediaStore`, and `$mapoMediaAdapter`, which backend integrations replace |
50
+ | Menus | `MapoMenuManager`: a drag-and-drop tree editor with per-language trees |
51
+ | Feedback | `MapoSnackBar` and `MapoConfirmDialog`, driven by the store and mounted by `MapoRootComponents` in `mapo-default` |
176
52
 
177
- ## Dev workflow
53
+ The layout exposes the slots `sidebar:logo`, `sidebar:nav-top`, `sidebar:nav-bottom`, `sidebar:footer`, `topbar:left`, `topbar` and `topbar:right`. Every component's props, events and slots are in the component API reference.
178
54
 
179
- ```bash
180
- # watch mode — rebuilds dist/ on every src/ change
181
- pnpm --filter @mapomodule/uikit dev
55
+ ## Customization
182
56
 
183
- # or from the monorepo root
184
- pnpm dev:uikit
185
- ```
57
+ Pick the lightest layer that does the job:
186
58
 
187
- Run alongside a demo app:
188
-
189
- ```bash
190
- # terminal 1
191
- pnpm dev:uikit
192
-
193
- # terminal 2
194
- pnpm dev:example-theme # theming demo at http://localhost:3001
195
- ```
59
+ 1. **CSS tokens** through `mapo.uikit.css`, for colours, radius and dark mode.
60
+ 2. **Nuxt UI defaults** through `mapo.uikit.ui`, for component variants across the app.
61
+ 3. **Slots** on the layout and on Mapo components, for structural additions.
62
+ 4. **MapoOverride**: a file at `app/mapooverride/<Name>.vue` replaces the registered component with that name at build time. Keep its props, events and slots compatible; from then on you own its updates.
196
63
 
197
- ## Reference
64
+ ## Documentation
198
65
 
199
- See [docs/uikit/](../../../docs/uikit/) for the full component and theming documentation.
66
+ - [UIKit](https://lotrekagency.github.io/mapo-new/uikit/)
67
+ - [Layout](https://lotrekagency.github.io/mapo-new/uikit/layout), [Sidebar](https://lotrekagency.github.io/mapo-new/uikit/sidebar), [Login](https://lotrekagency.github.io/mapo-new/uikit/login)
68
+ - [MapoList](https://lotrekagency.github.io/mapo-new/uikit/list), [MapoDetail](https://lotrekagency.github.io/mapo-new/uikit/detail)
69
+ - [Media Manager](https://lotrekagency.github.io/mapo-new/uikit/media), [Menu Manager](https://lotrekagency.github.io/mapo-new/uikit/menu-manager)
70
+ - [Theming](https://lotrekagency.github.io/mapo-new/uikit/theming), [MapoOverride System](https://lotrekagency.github.io/mapo-new/uikit/mapoverride)
71
+ - [UIKit — Component API Reference](https://lotrekagency.github.io/mapo-new/uikit/api)
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MapoConfirmDialog.component.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapoConfirmDialog.component.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/MapoConfirmDialog.component.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MapoDetail.component.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapoDetail.component.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/MapoDetail.component.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MapoDetailLangSwitch.component.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapoDetailLangSwitch.component.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/MapoDetailLangSwitch.component.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MapoListTable.component.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapoListTable.component.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/MapoListTable.component.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Placeholder for Nuxt's `#app` in component tests. Nuxt provides `#app` only
3
+ * inside a Nuxt build, but the client transform must resolve every import, so
4
+ * `vitest.config.ts` points `#app` here. It exports nothing on purpose: each test
5
+ * replaces it with `vi.mock("#app", factory)`, holding the composables the
6
+ * component under test calls.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=nuxt-app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nuxt-app.d.ts","sourceRoot":"","sources":["../../../src/__tests__/__mocks__/nuxt-app.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=listTable.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listTable.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/listTable.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mediaLanguages.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mediaLanguages.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/mediaLanguages.test.ts"],"names":[],"mappings":""}
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mapomodule/uikit",
3
3
  "configKey": "mapoUikit",
4
- "version": "2.0.0-beta.12",
4
+ "version": "2.0.0-beta.14",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -1 +1 @@
1
- @import "tailwindcss";@import "@nuxt/ui";@source "../components/**/*.vue";@source "../layouts/**/*.vue";@source "../pages/**/*.vue";@source "../../../../form/src/runtime/components/**/*.vue";@source "../../../../form/src/runtime/composables/**/*.ts";@source inline("col-span-1 col-span-2 col-span-3 col-span-4 col-span-5 col-span-6 col-span-7 col-span-8 col-span-9 col-span-10 col-span-11 col-span-12");@source inline("md:col-span-1 md:col-span-2 md:col-span-3 md:col-span-4 md:col-span-5 md:col-span-6 md:col-span-7 md:col-span-8 md:col-span-9 md:col-span-10 md:col-span-11 md:col-span-12");@source inline("grid-cols-12");@source inline("flex-1 min-h-0 h-full");.mapo-group-expand-body,.mapo-group-expand-body .mapo-form-field,.mapo-group-expand-body .mapo-form-field>div,.mapo-group-expand-body>*{flex:1;min-height:0}.mapo-group-expand-body [contenteditable],.mapo-group-expand-body textarea{height:100%!important;overflow-y:auto!important;resize:none!important}.mapo-group-expand-body .mapo-form-field>div>*{height:100%}@layer base{body,html{height:100%}:root{--mapo-topbar-height:56px}#__nuxt,#__nuxt>*{height:100%}}
1
+ @import "tailwindcss";@import "@nuxt/ui";@source "../components/**/*.vue";@source "../layouts/**/*.vue";@source "../pages/**/*.vue";@source "../../../../form/src/runtime/components/**/*.vue";@source "../../../../form/src/runtime/composables/**/*.ts";@source inline("col-span-1 col-span-2 col-span-3 col-span-4 col-span-5 col-span-6 col-span-7 col-span-8 col-span-9 col-span-10 col-span-11 col-span-12");@source inline("md:col-span-1 md:col-span-2 md:col-span-3 md:col-span-4 md:col-span-5 md:col-span-6 md:col-span-7 md:col-span-8 md:col-span-9 md:col-span-10 md:col-span-11 md:col-span-12");@source inline("grid-cols-12");@source inline("flex-1 min-h-0 h-full");.mapo-group-expand-body,.mapo-group-expand-body .mapo-form-field,.mapo-group-expand-body .mapo-form-field>div,.mapo-group-expand-body>*{flex:1;min-height:0}.mapo-group-expand-body [contenteditable],.mapo-group-expand-body textarea{height:100%!important;overflow-y:auto!important;resize:none!important}.mapo-group-expand-body .mapo-form-field>div>*{height:100%}@layer base{body,html{height:100%}:root{--mapo-topbar-height:56px}#__nuxt,#__nuxt>*{height:100%}[role=button]:not(:disabled),button:not(:disabled){cursor:pointer}}
@@ -1,12 +1,29 @@
1
1
  <script setup>
2
+ import { ref, watch } from "vue";
2
3
  import { useI18n } from "vue-i18n";
3
4
  import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
4
5
  const { t } = useI18n();
5
6
  const store = useConfirmStore();
7
+ const modalMounted = ref(store.active);
8
+ watch(
9
+ () => store.active,
10
+ (active) => {
11
+ if (active) modalMounted.value = true;
12
+ }
13
+ );
14
+ function onAfterLeave() {
15
+ if (store.active) return;
16
+ modalMounted.value = false;
17
+ }
6
18
  </script>
7
19
 
8
20
  <template>
9
- <UModal v-model:open="store.active" :dismissible="false">
21
+ <UModal
22
+ v-if="modalMounted"
23
+ v-model:open="store.active"
24
+ :dismissible="false"
25
+ @after:leave="onAfterLeave"
26
+ >
10
27
  <template #content>
11
28
  <div class="p-6 space-y-4">
12
29
  <div class="space-y-1">
@@ -1 +1 @@
1
- {"version":3,"file":"MapoConfirmDialog.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoConfirmDialog.vue"],"names":[],"mappings":"AA0KA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"MapoConfirmDialog.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoConfirmDialog.vue"],"names":[],"mappings":"AAyOA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -32,6 +32,7 @@ const props = defineProps({
32
32
  schemaFieldOptions: { type: Object, required: false, default: void 0 },
33
33
  sidebarFields: { type: Array, required: false, default: () => [] },
34
34
  languages: { type: Array, required: false, default: () => [] },
35
+ langThreshold: { type: Number, required: false, default: void 0 },
35
36
  modelName: { type: [String, null], required: false, default: null },
36
37
  sidebarCols: { type: Number, required: false, default: 4 },
37
38
  sticky: { type: Boolean, required: false, default: true },
@@ -69,8 +70,14 @@ function recordId() {
69
70
  const backup = ref(null);
70
71
  const errors = ref({});
71
72
  const isLoading = ref(String(props.id) !== "new");
72
- const isSaving = ref(false);
73
- const isDeleting = ref(false);
73
+ const pendingAction = ref(null);
74
+ const isBusy = computed(() => pendingAction.value !== null);
75
+ const isSaving = computed(() => {
76
+ const savingAndLeaving = pendingAction.value === "save";
77
+ const savingAndStaying = pendingAction.value === "saveContinue";
78
+ return savingAndLeaving || savingAndStaying;
79
+ });
80
+ const isDeleting = computed(() => pendingAction.value === "delete");
74
81
  const currentLang = ref(props.languages[0] ?? "");
75
82
  const draftBanner = ref(null);
76
83
  const isDirty = computed(
@@ -227,6 +234,7 @@ async function fetchModel() {
227
234
  }
228
235
  }
229
236
  async function save(andBack = false) {
237
+ if (isBusy.value) return;
230
238
  const validationResults = formValidators.map((fn) => fn());
231
239
  const allValid = validationResults.every((r) => r.valid);
232
240
  if (!allValid) {
@@ -238,7 +246,8 @@ async function save(andBack = false) {
238
246
  return;
239
247
  }
240
248
  errors.value = {};
241
- isSaving.value = true;
249
+ pendingAction.value = andBack ? "save" : "saveContinue";
250
+ let leaving = false;
242
251
  try {
243
252
  const multipartOpts = { multipart: props.multipart };
244
253
  let result;
@@ -274,7 +283,7 @@ async function save(andBack = false) {
274
283
  params: { id }
275
284
  });
276
285
  }
277
- if (andBack) back();
286
+ if (andBack) leaving = leave();
278
287
  } catch (err) {
279
288
  const data = getErrorData(err);
280
289
  if (getErrorStatus(err) === 400 && data && typeof data === "object") {
@@ -286,7 +295,7 @@ async function save(andBack = false) {
286
295
  snack.show(detail ?? t("mapo.saveError"), "error");
287
296
  }
288
297
  } finally {
289
- isSaving.value = false;
298
+ if (!leaving) pendingAction.value = null;
290
299
  }
291
300
  }
292
301
  function getPatch() {
@@ -294,6 +303,7 @@ function getPatch() {
294
303
  return objectDiff(backup.value, model.value);
295
304
  }
296
305
  async function deleteItem() {
306
+ if (isBusy.value) return;
297
307
  const ok = await confirm.ask({
298
308
  title: t("mapo.delete"),
299
309
  message: t("mapo.detail.deleteQuestion"),
@@ -301,21 +311,36 @@ async function deleteItem() {
301
311
  dangerous: true
302
312
  });
303
313
  if (!ok) return;
304
- isDeleting.value = true;
314
+ pendingAction.value = "delete";
315
+ let leaving = false;
305
316
  try {
306
317
  await crud.delete(recordId());
307
318
  backup.value = deepClone(model.value);
308
319
  snack.show(t("mapo.deleteSuccess"), "success");
309
320
  emit("deleted");
310
- back();
321
+ leaving = leave();
311
322
  } catch (err) {
312
323
  snack.show(getErrorDetail(err) ?? t("mapo.deleteError"), "error");
313
324
  } finally {
314
- isDeleting.value = false;
325
+ if (!leaving) pendingAction.value = null;
315
326
  }
316
327
  }
317
328
  function back() {
329
+ if (isBusy.value) return;
330
+ pendingAction.value = "back";
331
+ const leaving = leave();
332
+ if (!leaving) pendingAction.value = null;
333
+ }
334
+ function leave() {
335
+ const hasPreviousPage = router.options.history.state.back != null;
336
+ if (hasPreviousPage) {
337
+ const stopWatching = router.afterEach((_to, _from, failure) => {
338
+ stopWatching();
339
+ if (failure) pendingAction.value = null;
340
+ });
341
+ }
318
342
  router.back();
343
+ return hasPreviousPage;
319
344
  }
320
345
  async function guardUnsaved() {
321
346
  if (!isDirty.value) return true;
@@ -443,6 +468,7 @@ defineSlots();
443
468
  v-model="currentLang"
444
469
  :langs="activeLangs"
445
470
  :errors="errors"
471
+ :lang-threshold="langThreshold"
446
472
  />
447
473
  </slot>
448
474
 
@@ -475,7 +501,8 @@ defineSlots();
475
501
  <!-- Sidebar column -->
476
502
  <div :class="sidebarColsClass">
477
503
  <div :style="sidebarStyle" class="space-y-4">
478
- <!-- Action buttons (Save / Save&continue / Back — no delete here) -->
504
+ <!-- Action buttons (Save / Save&continue / Back — no delete here).
505
+ While one works, it spins and all of them are disabled. -->
479
506
  <slot name="side-buttons" v-bind="slotBindings">
480
507
  <UCard>
481
508
  <div class="flex flex-col gap-2">
@@ -483,7 +510,8 @@ defineSlots();
483
510
  <UButton
484
511
  v-if="!effectiveReadonly"
485
512
  block
486
- :loading="isSaving"
513
+ :loading="pendingAction === 'save'"
514
+ :disabled="isBusy"
487
515
  icon="i-lucide-save"
488
516
  @click="save(true)"
489
517
  >
@@ -496,7 +524,8 @@ defineSlots();
496
524
  v-if="!effectiveReadonly"
497
525
  block
498
526
  variant="soft"
499
- :loading="isSaving"
527
+ :loading="pendingAction === 'saveContinue'"
528
+ :disabled="isBusy"
500
529
  icon="i-lucide-save"
501
530
  @click="save(false)"
502
531
  >
@@ -511,6 +540,8 @@ defineSlots();
511
540
  block
512
541
  variant="ghost"
513
542
  icon="i-lucide-arrow-left"
543
+ :loading="pendingAction === 'back'"
544
+ :disabled="isBusy"
514
545
  @click="back"
515
546
  >
516
547
  {{ t("mapo.back") }}
@@ -588,6 +619,7 @@ defineSlots();
588
619
  color="error"
589
620
  variant="soft"
590
621
  :loading="isDeleting"
622
+ :disabled="isBusy"
591
623
  icon="i-lucide-trash-2"
592
624
  @click="deleteItem"
593
625
  >