@mapomodule/uikit 2.0.0-beta.13 → 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.
- package/README.md +46 -184
- package/dist/__tests__/MapoConfirmDialog.component.test.d.ts +2 -0
- package/dist/__tests__/MapoConfirmDialog.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoDetail.component.test.d.ts +2 -0
- package/dist/__tests__/MapoDetail.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoDetailLangSwitch.component.test.d.ts +2 -0
- package/dist/__tests__/MapoDetailLangSwitch.component.test.d.ts.map +1 -0
- package/dist/__tests__/MapoListTable.component.test.d.ts +2 -0
- package/dist/__tests__/MapoListTable.component.test.d.ts.map +1 -0
- package/dist/__tests__/__mocks__/nuxt-app.d.ts +9 -0
- package/dist/__tests__/__mocks__/nuxt-app.d.ts.map +1 -0
- package/dist/__tests__/listTable.test.d.ts +2 -0
- package/dist/__tests__/listTable.test.d.ts.map +1 -0
- package/dist/module.json +1 -1
- package/dist/runtime/assets/main.css +1 -1
- package/dist/runtime/components/MapoConfirmDialog.vue +18 -1
- package/dist/runtime/components/MapoConfirmDialog.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoDetail.vue +43 -11
- package/dist/runtime/components/MapoDetail.vue.d.ts +76 -0
- package/dist/runtime/components/MapoDetail.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoDetailLangSwitch.vue +21 -25
- package/dist/runtime/components/MapoDetailLangSwitch.vue.d.ts +4 -3
- package/dist/runtime/components/MapoDetailLangSwitch.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoList.vue +3 -2
- package/dist/runtime/components/MapoList.vue.d.ts +9 -4
- package/dist/runtime/components/MapoList.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListTable.vue +98 -32
- package/dist/runtime/components/MapoListTable.vue.d.ts +11 -6
- package/dist/runtime/components/MapoListTable.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaPreview.vue.d.ts +1 -1
- package/dist/runtime/components/MapoMediaPreview.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaUploader.vue +21 -21
- package/dist/runtime/components/MapoMediaUploader.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMenuManager.vue.d.ts +1 -1
- package/dist/runtime/components/MapoMenuManager.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMenuTreeview.vue.d.ts +1 -1
- package/dist/runtime/components/MapoMenuTreeview.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMenuTreeviewNode.vue.d.ts +2 -2
- package/dist/runtime/stores/media.d.ts +2 -2
- package/dist/runtime/types/list.d.ts +10 -2
- package/dist/runtime/types/list.d.ts.map +1 -1
- package/dist/runtime/utils/listTable.d.ts +29 -0
- package/dist/runtime/utils/listTable.d.ts.map +1 -0
- package/dist/runtime/utils/listTable.js +21 -0
- package/package.json +6 -6
- package/src/__tests__/MapoConfirmDialog.component.test.ts +165 -0
- package/src/__tests__/MapoDetail.component.test.ts +293 -0
- package/src/__tests__/MapoDetailLangSwitch.component.test.ts +145 -0
- package/src/__tests__/MapoListTable.component.test.ts +504 -0
- package/src/__tests__/__mocks__/nuxt-app.ts +8 -0
- package/src/__tests__/listTable.test.ts +82 -0
- package/src/runtime/assets/main.css +9 -0
- package/src/runtime/components/MapoConfirmDialog.vue +28 -1
- package/src/runtime/components/MapoDetail.vue +78 -11
- package/src/runtime/components/MapoDetailLangSwitch.vue +26 -27
- package/src/runtime/components/MapoList.vue +13 -5
- package/src/runtime/components/MapoListTable.vue +128 -41
- package/src/runtime/components/MapoMediaUploader.vue +25 -21
- package/src/runtime/types/list.ts +10 -2
- package/src/runtime/utils/listTable.ts +54 -0
package/README.md
CHANGED
|
@@ -1,209 +1,71 @@
|
|
|
1
1
|
# @mapomodule/uikit
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
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 @
|
|
10
|
+
pnpm add mapomodule@next @nuxt/ui
|
|
13
11
|
```
|
|
14
12
|
|
|
15
13
|
```ts
|
|
16
|
-
// nuxt.config.ts
|
|
14
|
+
// nuxt.config.ts
|
|
17
15
|
export default defineNuxtConfig({
|
|
18
|
-
modules: ["@nuxt/ui", "
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
| `MapoLangSwitcher` | Interface locale switcher over the `@nuxtjs/i18n` locales, with flag emoji |
|
|
50
|
-
| `MapoLogoutButton` | Standalone logout button with `variant`, `color`, `size`, `iconOnly` props |
|
|
51
|
-
|
|
52
|
-
#### Feedback
|
|
53
|
-
|
|
54
|
-
| Component | Description |
|
|
55
|
-
| -------------------- | --------------------------------------------------------- |
|
|
56
|
-
| `MapoLogin` | Split-panel login form; slots: `brand`, `panel`, `footer` |
|
|
57
|
-
| `MapoSnackBar` | Imperative snackbar driven by `useSnackStore` |
|
|
58
|
-
| `MapoConfirmDialog` | Promise-based confirm dialog driven by `useConfirmStore` |
|
|
59
|
-
| `MapoRootComponents` | Mounts `MapoSnackBar` + `MapoConfirmDialog` in the layout |
|
|
60
|
-
|
|
61
|
-
#### List engine
|
|
62
|
-
|
|
63
|
-
| Component | Description |
|
|
64
|
-
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
65
|
-
| `MapoList` | Full list shell: composes head, filters, actions, tabs, table, and quick-edit. URL state (page, sort, search, filters, tab) synced automatically. |
|
|
66
|
-
| `MapoListHead` | Title, search bar, and primary action button row |
|
|
67
|
-
| `MapoListFilters` | Filter panel driven by `FilterDescriptor[]`. v1 backend contract (`key=v1,v2`); per-filter override slots (`filter.{value}` / `.title` / `.content` / `.icon`) |
|
|
68
|
-
| `MapoListActions` | Bulk-action toolbar (delete, reorder) — appears on selection. Supports `ActionDescriptor.dangerous` to render Apply/confirm with error styling for destructive actions. |
|
|
69
|
-
| `MapoListTabs` | Tabbed status filter via `meta.tabs` |
|
|
70
|
-
| `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. |
|
|
71
|
-
| `MapoListQuickEdit` | Quick-edit modal driven by the same `FieldDescriptor[]` as the detail form |
|
|
72
|
-
|
|
73
|
-
#### Media Manager
|
|
74
|
-
|
|
75
|
-
| Component | Description |
|
|
76
|
-
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
77
|
-
| `MapoDropArea` | Standalone drag-and-drop area (reusable outside media manager) |
|
|
78
|
-
| `MapoMediaPreview` | MIME-aware preview: `image` → `<img>`, `video` → `<video>`, other → file icon |
|
|
79
|
-
| `MapoMediaBreadcrumbs` | Folder navigation breadcrumb |
|
|
80
|
-
| `MapoMediaFolders` | Folder sidebar with MIME filters (image/video/audio/document) |
|
|
81
|
-
| `MapoMediaGallery` | Responsive CSS Grid gallery with bulk selection and pagination |
|
|
82
|
-
| `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 |
|
|
83
|
-
| `MapoMediaFileChanger` | Replace an existing file while optionally preserving its URL |
|
|
84
|
-
| `MapoMediaUploader` | Upload queue with per-file progress, inline metadata (title/alt/description), and destination-folder selection |
|
|
85
|
-
| `MapoMediaManager` | Main orchestrator shell (sidebar + gallery + uploader + editor drawer) |
|
|
86
|
-
| `MapoMediaManagerDialog` | `UModal` wrapper for picker mode — single or multi selection with confirm |
|
|
87
|
-
|
|
88
|
-
**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.
|
|
89
|
-
|
|
90
|
-
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).
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
mapo: {
|
|
94
|
-
uikit: {
|
|
95
|
-
media: {
|
|
96
|
-
endpoints: { media: "/api/media", folders: "/api/media-folders" },
|
|
97
|
-
maxImageSize: 10, // MB
|
|
98
|
-
maxVideoSize: 100, // MB
|
|
99
|
-
permissionsModel: "media", // Django model for editor change/delete checks
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
#### Detail shell
|
|
106
|
-
|
|
107
|
-
| Component | Description |
|
|
108
|
-
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
109
|
-
| `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 languages derived from the endpoint's OPTIONS `lang_info` (overridable with `languages` / `forceLanguages`). |
|
|
110
|
-
| `MapoDetailLangSwitch` | Language tabs with per-language error badge — syncs the `?lang=` query param |
|
|
111
|
-
|
|
112
|
-
#### Menu manager
|
|
113
|
-
|
|
114
|
-
| Component | Description |
|
|
115
|
-
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
116
|
-
| `MapoMenuManager` | Split-pane menu editor: `useCrud` load/save, per-language node trees (`translatable`), differential save (`usePatch`), permission gating (`permissionModel`) |
|
|
117
|
-
| `MapoMenuTreeview` | Left pane — drag-and-drop node tree with nesting limit (`maxDepth`) and confirm-on-delete |
|
|
118
|
-
| `MapoMenuTreeviewNode` | Recursive node renderer: nested drag lists for re-parenting, inline rename, per-node error badge |
|
|
119
|
-
| `MapoMenuNodeEditor` | Right pane — `MapoForm` for the selected node (title, link type, style, new tab, page picker, static URL); `coreFields` / `additionalFields` swap the field set |
|
|
120
|
-
|
|
121
|
-
### Layout slots (`mapo-default`)
|
|
122
|
-
|
|
123
|
-
| Slot | Renders in |
|
|
124
|
-
| -------------------- | ---------------------------------------------------- |
|
|
125
|
-
| `sidebar:logo` | Sidebar header — replaces the default logo/name link |
|
|
126
|
-
| `sidebar:nav-top` | Above the auto-generated nav list |
|
|
127
|
-
| `sidebar:nav-bottom` | Below the nav list, above the footer row |
|
|
128
|
-
| `sidebar:footer` | Replaces the user avatar + logout row |
|
|
129
|
-
| `topbar:left` | Immediately after the drawer toggle button |
|
|
130
|
-
| `topbar` | Center area of the topbar (flex-1) |
|
|
131
|
-
| `topbar:right` | Right cluster of the topbar |
|
|
132
|
-
|
|
133
|
-
## Theming
|
|
134
|
-
|
|
135
|
-
### ① CSS token override
|
|
136
|
-
|
|
137
|
-
Pass a CSS file via `mapo.uikit.css`. It is loaded **after** the base uikit CSS so your values always win:
|
|
138
|
-
|
|
139
|
-
```css
|
|
140
|
-
/* assets/css/theme.css */
|
|
141
|
-
@import "tailwindcss";
|
|
142
|
-
@import "@nuxt/ui";
|
|
143
|
-
|
|
144
|
-
:root {
|
|
145
|
-
--color-primary-500: oklch(0.59 0.25 290); /* violet */
|
|
146
|
-
--ui-radius: var(--radius-lg);
|
|
147
|
-
--ui-bg: var(--color-neutral-50);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.dark {
|
|
151
|
-
--ui-bg: var(--color-neutral-950);
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### ② Nuxt UI component defaults
|
|
156
|
-
|
|
157
|
-
Pass a partial Nuxt UI config via `mapo.uikit.ui`. Deep-merged into `nuxt.options.ui`:
|
|
158
|
-
|
|
159
|
-
```ts
|
|
160
|
-
mapo: {
|
|
161
|
-
uikit: {
|
|
162
|
-
ui: {
|
|
163
|
-
button: { defaultVariants: { color: "primary", variant: "solid" } },
|
|
164
|
-
card: { slots: { root: "rounded-xl shadow-md" } },
|
|
165
|
-
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
|
+
},
|
|
166
23
|
},
|
|
167
24
|
},
|
|
168
|
-
}
|
|
25
|
+
});
|
|
169
26
|
```
|
|
170
27
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
Create a file in `app/mapooverride/` matching any Mapo component name to replace it entirely at build time:
|
|
174
|
-
|
|
175
|
-
```
|
|
176
|
-
app/
|
|
177
|
-
└── mapooverride/
|
|
178
|
-
├── MapoTopbar.vue ← replaces MapoTopbar globally
|
|
179
|
-
├── MapoSidebar.vue
|
|
180
|
-
└── MapoLogin.vue
|
|
181
|
-
```
|
|
28
|
+
Mapo v2 is published on the `next` dist-tag while it is in beta.
|
|
182
29
|
|
|
183
|
-
|
|
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 |
|
|
184
39
|
|
|
185
|
-
|
|
40
|
+
## What you get
|
|
186
41
|
|
|
187
|
-
|
|
42
|
+
Components are auto-imported.
|
|
188
43
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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` |
|
|
192
52
|
|
|
193
|
-
|
|
194
|
-
pnpm dev:uikit
|
|
195
|
-
```
|
|
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.
|
|
196
54
|
|
|
197
|
-
|
|
55
|
+
## Customization
|
|
198
56
|
|
|
199
|
-
|
|
200
|
-
# terminal 1
|
|
201
|
-
pnpm dev:uikit
|
|
57
|
+
Pick the lightest layer that does the job:
|
|
202
58
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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.
|
|
206
63
|
|
|
207
|
-
##
|
|
64
|
+
## Documentation
|
|
208
65
|
|
|
209
|
-
|
|
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 @@
|
|
|
1
|
+
{"version":3,"file":"MapoConfirmDialog.component.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/MapoConfirmDialog.component.test.ts"],"names":[],"mappings":""}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"MapoDetailLangSwitch.component.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/MapoDetailLangSwitch.component.test.ts"],"names":[],"mappings":""}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"listTable.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/listTable.test.ts"],"names":[],"mappings":""}
|
package/dist/module.json
CHANGED
|
@@ -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
|
|
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":"
|
|
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
|
|
73
|
-
const
|
|
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
|
-
|
|
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)
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
321
|
+
leaving = leave();
|
|
311
322
|
} catch (err) {
|
|
312
323
|
snack.show(getErrorDetail(err) ?? t("mapo.deleteError"), "error");
|
|
313
324
|
} finally {
|
|
314
|
-
|
|
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="
|
|
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="
|
|
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
|
>
|