@mapomodule/uikit 2.0.0-beta.7 → 2.0.0-beta.8
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/dist/index.d.mts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/module.d.mts +1 -0
- package/dist/module.d.ts.map +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +13 -2
- package/dist/runtime/components/MapoConfirmDialog.vue +5 -3
- package/dist/runtime/components/MapoConfirmDialog.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoDetail.vue +40 -32
- package/dist/runtime/components/MapoDetail.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoDetailLangSwitch.vue +1 -1
- package/dist/runtime/components/MapoDropArea.vue +5 -1
- package/dist/runtime/components/MapoDropArea.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoLangSwitcher.vue +39 -0
- package/dist/runtime/components/MapoLangSwitcher.vue.d.ts +18 -0
- package/dist/runtime/components/MapoLangSwitcher.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoList.vue +2 -2
- package/dist/runtime/components/MapoListActions.vue +15 -8
- package/dist/runtime/components/MapoListActions.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListFilters.vue +4 -2
- package/dist/runtime/components/MapoListFilters.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListQuickEdit.vue +13 -9
- package/dist/runtime/components/MapoListQuickEdit.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoListTable.vue +25 -20
- package/dist/runtime/components/MapoListTable.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoLogin.vue +13 -10
- package/dist/runtime/components/MapoLogin.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoLogoutButton.vue +4 -2
- package/dist/runtime/components/MapoLogoutButton.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaBreadcrumbs.vue +3 -1
- package/dist/runtime/components/MapoMediaBreadcrumbs.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaEditor.vue +26 -16
- package/dist/runtime/components/MapoMediaEditor.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaFileChanger.vue +8 -4
- package/dist/runtime/components/MapoMediaFileChanger.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaFolders.vue +36 -14
- package/dist/runtime/components/MapoMediaFolders.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaGallery.vue +15 -5
- package/dist/runtime/components/MapoMediaGallery.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaManager.vue +18 -8
- package/dist/runtime/components/MapoMediaManager.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaManagerDialog.vue +9 -5
- package/dist/runtime/components/MapoMediaManagerDialog.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMediaPreview.vue +1 -1
- package/dist/runtime/components/MapoMediaUploader.vue +40 -16
- package/dist/runtime/components/MapoMediaUploader.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoMenuManager.vue +273 -0
- package/dist/runtime/components/MapoMenuManager.vue.d.ts +92 -0
- package/dist/runtime/components/MapoMenuManager.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMenuNodeEditor.vue +201 -0
- package/dist/runtime/components/MapoMenuNodeEditor.vue.d.ts +61 -0
- package/dist/runtime/components/MapoMenuNodeEditor.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMenuTreeview.vue +181 -0
- package/dist/runtime/components/MapoMenuTreeview.vue.d.ts +57 -0
- package/dist/runtime/components/MapoMenuTreeview.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMenuTreeviewNode.vue +175 -0
- package/dist/runtime/components/MapoMenuTreeviewNode.vue.d.ts +27 -0
- package/dist/runtime/components/MapoMenuTreeviewNode.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoSidebar.vue +3 -1
- package/dist/runtime/components/MapoSidebar.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoSidebarList.vue +1 -1
- package/dist/runtime/components/MapoSidebarProfile.vue +6 -2
- package/dist/runtime/components/MapoSidebarProfile.vue.d.ts.map +1 -1
- package/dist/runtime/components/MapoThemeToggle.vue +5 -1
- package/dist/runtime/components/MapoThemeToggle.vue.d.ts.map +1 -1
- package/dist/runtime/components/menuDndContext.d.ts +19 -0
- package/dist/runtime/components/menuDndContext.d.ts.map +1 -0
- package/dist/runtime/components/menuDndContext.js +3 -0
- package/dist/runtime/pages/index.vue +4 -2
- package/dist/runtime/pages/index.vue.d.ts.map +1 -1
- package/dist/runtime/plugins/media-adapter.d.ts.map +1 -1
- package/dist/runtime/plugins/media-adapter.js +2 -1
- package/dist/runtime/stores/media.d.ts.map +1 -1
- package/dist/runtime/stores/media.js +29 -13
- package/dist/runtime/types/menu.d.ts +66 -0
- package/dist/runtime/types/menu.d.ts.map +1 -0
- package/dist/runtime/types/menu.js +30 -0
- package/package.json +11 -8
- package/src/index.ts +12 -0
- package/src/module.ts +17 -0
- package/src/runtime/components/MapoConfirmDialog.vue +5 -3
- package/src/runtime/components/MapoDetail.vue +39 -36
- package/src/runtime/components/MapoDetailLangSwitch.vue +1 -1
- package/src/runtime/components/MapoDropArea.vue +6 -1
- package/src/runtime/components/MapoLangSwitcher.vue +74 -0
- package/src/runtime/components/MapoList.vue +1 -1
- package/src/runtime/components/MapoListActions.vue +16 -10
- package/src/runtime/components/MapoListFilters.vue +5 -2
- package/src/runtime/components/MapoListQuickEdit.vue +12 -9
- package/src/runtime/components/MapoListTable.vue +25 -20
- package/src/runtime/components/MapoLogin.vue +13 -10
- package/src/runtime/components/MapoLogoutButton.vue +4 -2
- package/src/runtime/components/MapoMediaBreadcrumbs.vue +3 -1
- package/src/runtime/components/MapoMediaEditor.vue +26 -16
- package/src/runtime/components/MapoMediaFileChanger.vue +8 -3
- package/src/runtime/components/MapoMediaFolders.vue +37 -15
- package/src/runtime/components/MapoMediaGallery.vue +17 -5
- package/src/runtime/components/MapoMediaManager.vue +17 -7
- package/src/runtime/components/MapoMediaManagerDialog.vue +10 -4
- package/src/runtime/components/MapoMediaUploader.vue +43 -16
- package/src/runtime/components/MapoMenuManager.vue +402 -0
- package/src/runtime/components/MapoMenuNodeEditor.vue +282 -0
- package/src/runtime/components/MapoMenuTreeview.vue +264 -0
- package/src/runtime/components/MapoMenuTreeviewNode.vue +234 -0
- package/src/runtime/components/MapoSidebar.vue +3 -1
- package/src/runtime/components/MapoSidebarList.vue +1 -1
- package/src/runtime/components/MapoSidebarProfile.vue +6 -2
- package/src/runtime/components/MapoThemeToggle.vue +5 -1
- package/src/runtime/components/menuDndContext.ts +22 -0
- package/src/runtime/pages/index.vue +5 -2
- package/src/runtime/plugins/media-adapter.ts +9 -5
- package/src/runtime/stores/media.ts +29 -13
- package/src/runtime/types/menu.ts +105 -0
|
@@ -4,6 +4,7 @@ import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
|
|
|
4
4
|
import { useSnackStore } from "@mapomodule/store/runtime/stores/snack";
|
|
5
5
|
import { normalizeEndpoint } from "@mapomodule/utils";
|
|
6
6
|
import { useCrud } from "@mapomodule/core/runtime/api/crud";
|
|
7
|
+
import { useMapoT } from "@mapomodule/i18n/runtime/composables/useMapoT";
|
|
7
8
|
import { applyMultipartPolicy } from "@mapomodule/core/runtime/api/multipart";
|
|
8
9
|
import { useNuxtApp, useRuntimeConfig } from "#app";
|
|
9
10
|
import { defaultMediaAdapter } from "../adapters/defaultMediaAdapter.js";
|
|
@@ -130,7 +131,7 @@ export const useMediaStore = defineStore("mapo-media", () => {
|
|
|
130
131
|
const payload = (a.buildMediaPatchPayload ?? defaultMediaAdapter.buildMediaPatchPayload)(media);
|
|
131
132
|
const updated = await mediaCrud().partialUpdate(media.id, payload);
|
|
132
133
|
if (editMedia.value?.id === media.id) editMedia.value = updated;
|
|
133
|
-
useSnackStore().show("
|
|
134
|
+
useSnackStore().show(useMapoT()("mapo.mediaManager.fileInfo"), "success");
|
|
134
135
|
await getRoot();
|
|
135
136
|
return updated;
|
|
136
137
|
}
|
|
@@ -156,10 +157,11 @@ export const useMediaStore = defineStore("mapo-media", () => {
|
|
|
156
157
|
await getRoot();
|
|
157
158
|
}
|
|
158
159
|
async function deleteFolder(folder) {
|
|
160
|
+
const t = useMapoT();
|
|
159
161
|
const confirmed = await useConfirmStore().ask({
|
|
160
|
-
title: "
|
|
161
|
-
message:
|
|
162
|
-
confirmText: "
|
|
162
|
+
title: t("mapo.mediaFolders.deleteTitle"),
|
|
163
|
+
message: t("mapo.mediaFolders.confirmDelete", { name: folder.name }),
|
|
164
|
+
confirmText: t("mapo.delete"),
|
|
163
165
|
dangerous: true
|
|
164
166
|
});
|
|
165
167
|
if (!confirmed) return;
|
|
@@ -167,10 +169,13 @@ export const useMediaStore = defineStore("mapo-media", () => {
|
|
|
167
169
|
await getRoot();
|
|
168
170
|
}
|
|
169
171
|
async function deleteMedia(media) {
|
|
172
|
+
const t = useMapoT();
|
|
170
173
|
const confirmed = await useConfirmStore().ask({
|
|
171
|
-
title: "
|
|
172
|
-
message:
|
|
173
|
-
|
|
174
|
+
title: t("mapo.mediaManager.deleteTitle"),
|
|
175
|
+
message: t("mapo.mediaEditor.confirmDelete", {
|
|
176
|
+
name: media.title || media.file
|
|
177
|
+
}),
|
|
178
|
+
confirmText: t("mapo.delete"),
|
|
174
179
|
dangerous: true
|
|
175
180
|
});
|
|
176
181
|
if (!confirmed) return;
|
|
@@ -220,16 +225,20 @@ export const useMediaStore = defineStore("mapo-media", () => {
|
|
|
220
225
|
async function deleteSelected() {
|
|
221
226
|
const count = editList.value.length;
|
|
222
227
|
if (count === 0) return;
|
|
228
|
+
const t = useMapoT();
|
|
223
229
|
const confirmed = await useConfirmStore().ask({
|
|
224
|
-
title: "
|
|
225
|
-
message:
|
|
226
|
-
confirmText:
|
|
230
|
+
title: t("mapo.mediaGallery.deleteTitle"),
|
|
231
|
+
message: t("mapo.mediaGallery.deleteSelected", { number: count }),
|
|
232
|
+
confirmText: t("mapo.delete"),
|
|
227
233
|
dangerous: true
|
|
228
234
|
});
|
|
229
235
|
if (!confirmed) return;
|
|
230
236
|
await Promise.all(editList.value.map((id) => mediaCrud().delete(id)));
|
|
231
237
|
editList.value = [];
|
|
232
|
-
useSnackStore().show(
|
|
238
|
+
useSnackStore().show(
|
|
239
|
+
t("mapo.mediaGallery.deleteSuccess", { number: count }),
|
|
240
|
+
"success"
|
|
241
|
+
);
|
|
233
242
|
await getRoot();
|
|
234
243
|
}
|
|
235
244
|
async function uploadMedia(payload, onProgress) {
|
|
@@ -254,10 +263,17 @@ export const useMediaStore = defineStore("mapo-media", () => {
|
|
|
254
263
|
resolve(xhr.response);
|
|
255
264
|
} else {
|
|
256
265
|
const detail = xhr.response?.detail;
|
|
257
|
-
reject(
|
|
266
|
+
reject(
|
|
267
|
+
new Error(
|
|
268
|
+
detail || `${useMapoT()("mapo.mediaUploader.uploadFailed")} (${xhr.status})`
|
|
269
|
+
)
|
|
270
|
+
);
|
|
258
271
|
}
|
|
259
272
|
});
|
|
260
|
-
xhr.addEventListener(
|
|
273
|
+
xhr.addEventListener(
|
|
274
|
+
"error",
|
|
275
|
+
() => reject(new Error(useMapoT()("mapo.mediaUploader.uploadFailed")))
|
|
276
|
+
);
|
|
261
277
|
xhr.send(formData);
|
|
262
278
|
});
|
|
263
279
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Menu Manager types — the canonical tree contract matches the Camomilla
|
|
3
|
+
* `/api/camomilla/menus` payload (v1 parity): a menu is a keyed collection
|
|
4
|
+
* of recursively nested nodes, optionally translated per language.
|
|
5
|
+
*/
|
|
6
|
+
/** Link carried by a menu node: relational (a CMS page) or static (raw URL). */
|
|
7
|
+
export interface MenuNodeLink {
|
|
8
|
+
/** `"RE"` = relational (page picked from the backend), `"ST"` = static URL. */
|
|
9
|
+
link_type?: "RE" | "ST";
|
|
10
|
+
/** Static URL used when `link_type === "ST"`. */
|
|
11
|
+
static?: string;
|
|
12
|
+
/** Content-type id used when `link_type === "RE"`. */
|
|
13
|
+
content_type?: number | string | null;
|
|
14
|
+
/** Routable node id of the linked page when `link_type === "RE"`. */
|
|
15
|
+
url_node?: number | string | null;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
/** A single node of the menu tree. */
|
|
19
|
+
export interface MenuTreeNode {
|
|
20
|
+
/**
|
|
21
|
+
* Node identity. Nodes created client-side get a random string id;
|
|
22
|
+
* the backend may replace it with a numeric one on save.
|
|
23
|
+
*/
|
|
24
|
+
id: string | number;
|
|
25
|
+
title: string;
|
|
26
|
+
link: MenuNodeLink;
|
|
27
|
+
/**
|
|
28
|
+
* Free-form node metadata (e.g. `style`, `target_bank`).
|
|
29
|
+
* `target_bank` keeps the v1/Camomilla key for data compatibility.
|
|
30
|
+
*/
|
|
31
|
+
meta: Record<string, unknown>;
|
|
32
|
+
/** Child nodes. */
|
|
33
|
+
nodes: MenuTreeNode[];
|
|
34
|
+
/** Per-field backend validation errors attached by the manager. */
|
|
35
|
+
errors?: Record<string, string[]>;
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
}
|
|
38
|
+
/** Per-language node tree used when the menu is translatable. */
|
|
39
|
+
export interface MenuTranslation {
|
|
40
|
+
nodes: MenuTreeNode[];
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
/** The full menu payload handled by `MapoMenuManager`. */
|
|
44
|
+
export interface MapoMenu {
|
|
45
|
+
id?: number | string;
|
|
46
|
+
/** Unique menu identifier (e.g. `"navbar"`, `"footer"`). */
|
|
47
|
+
key: string;
|
|
48
|
+
enabled?: boolean;
|
|
49
|
+
/** Node tree used when the menu is NOT translatable. */
|
|
50
|
+
nodes?: MenuTreeNode[];
|
|
51
|
+
/** Per-language node trees used when the menu IS translatable. */
|
|
52
|
+
translations?: Record<string, MenuTranslation>;
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
}
|
|
55
|
+
/** Create an empty client-side node with a unique temporary id. */
|
|
56
|
+
export declare function createMenuNode(partial?: Partial<MenuTreeNode>): MenuTreeNode;
|
|
57
|
+
/** Maximum nesting depth of a menu node tree (a flat list = depth 1). */
|
|
58
|
+
export declare function menuTreeDepth(nodes: MenuTreeNode[]): number;
|
|
59
|
+
/** Depth-first search for a node id. Returns the node and its ancestor chain. */
|
|
60
|
+
export declare function findMenuNode(nodes: MenuTreeNode[], id: string | number, parents?: MenuTreeNode[]): {
|
|
61
|
+
node: MenuTreeNode;
|
|
62
|
+
parents: MenuTreeNode[];
|
|
63
|
+
} | null;
|
|
64
|
+
/** Remove a node (by id) anywhere in the tree. Returns `true` when removed. */
|
|
65
|
+
export declare function removeMenuNode(nodes: MenuTreeNode[], id: string | number): boolean;
|
|
66
|
+
//# sourceMappingURL=menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../../src/runtime/types/menu.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,gFAAgF;AAChF,MAAM,WAAW,YAAY;IAC3B,+EAA+E;IAC/E,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACtC,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,sCAAsC;AACtC,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,YAAY,CAAC;IACnB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,mBAAmB;IACnB,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,iEAAiE;AACjE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,0DAA0D;AAC1D,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,4DAA4D;IAC5D,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wDAAwD;IACxD,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;IACvB,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC/C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,mEAAmE;AACnE,wBAAgB,cAAc,CAC5B,OAAO,GAAE,OAAO,CAAC,YAAY,CAAM,GAClC,YAAY,CASd;AAED,yEAAyE;AACzE,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,CAG3D;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAC1B,KAAK,EAAE,YAAY,EAAE,EACrB,EAAE,EAAE,MAAM,GAAG,MAAM,EACnB,OAAO,GAAE,YAAY,EAAO,GAC3B;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,YAAY,EAAE,CAAA;CAAE,GAAG,IAAI,CAOxD;AAED,+EAA+E;AAC/E,wBAAgB,cAAc,CAC5B,KAAK,EAAE,YAAY,EAAE,EACrB,EAAE,EAAE,MAAM,GAAG,MAAM,GAClB,OAAO,CAOT"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function createMenuNode(partial = {}) {
|
|
2
|
+
return {
|
|
3
|
+
id: Math.random().toString(36).slice(2),
|
|
4
|
+
title: "",
|
|
5
|
+
link: {},
|
|
6
|
+
meta: {},
|
|
7
|
+
nodes: [],
|
|
8
|
+
...partial
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function menuTreeDepth(nodes) {
|
|
12
|
+
if (!nodes.length) return 0;
|
|
13
|
+
return 1 + Math.max(...nodes.map((n) => menuTreeDepth(n.nodes ?? [])));
|
|
14
|
+
}
|
|
15
|
+
export function findMenuNode(nodes, id, parents = []) {
|
|
16
|
+
for (const node of nodes) {
|
|
17
|
+
if (String(node.id) === String(id)) return { node, parents };
|
|
18
|
+
const found = findMenuNode(node.nodes ?? [], id, [...parents, node]);
|
|
19
|
+
if (found) return found;
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
export function removeMenuNode(nodes, id) {
|
|
24
|
+
const index = nodes.findIndex((n) => String(n.id) === String(id));
|
|
25
|
+
if (index !== -1) {
|
|
26
|
+
nodes.splice(index, 1);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return nodes.some((n) => removeMenuNode(n.nodes ?? [], id));
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapomodule/uikit",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.8",
|
|
4
4
|
"description": "Mapo UI components: Sidebar, Topbar, Login, SnackBar, ConfirmDialog, List, Detail, Media",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,11 +46,14 @@
|
|
|
46
46
|
"lint": "eslint src"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@mapomodule/form": "2.0.0-beta.
|
|
49
|
+
"@mapomodule/form": "2.0.0-beta.6",
|
|
50
|
+
"@mapomodule/i18n": "workspace:*",
|
|
50
51
|
"@mapomodule/store": "2.0.0-beta.4",
|
|
51
|
-
"@mapomodule/utils": "2.0.0-beta.
|
|
52
|
-
"@mapomodule/core": "2.0.0-beta.
|
|
53
|
-
"tailwindcss": "^4.0.0"
|
|
52
|
+
"@mapomodule/utils": "2.0.0-beta.3",
|
|
53
|
+
"@mapomodule/core": "2.0.0-beta.6",
|
|
54
|
+
"tailwindcss": "^4.0.0",
|
|
55
|
+
"vue-draggable-plus": "^0.6.0",
|
|
56
|
+
"vue-i18n": "^11.4.0"
|
|
54
57
|
},
|
|
55
58
|
"peerDependencies": {
|
|
56
59
|
"@nuxt/ui": ">=4.0.0",
|
|
@@ -63,10 +66,10 @@
|
|
|
63
66
|
"@nuxt/schema": "4.4.2",
|
|
64
67
|
"@nuxt/ui": "^4.7.0",
|
|
65
68
|
"@tanstack/vue-table": "^8.21.3",
|
|
66
|
-
"nuxt": "^4.
|
|
69
|
+
"nuxt": "^4.5.1",
|
|
67
70
|
"pinia": "^3.0.4",
|
|
68
|
-
"vue": "^3.5.
|
|
69
|
-
"vue-router": "^5.0
|
|
71
|
+
"vue": "^3.5.40",
|
|
72
|
+
"vue-router": "^5.2.0",
|
|
70
73
|
"vue-tsc": "^3.3.4"
|
|
71
74
|
}
|
|
72
75
|
}
|
package/src/index.ts
CHANGED
|
@@ -16,3 +16,15 @@ export type {
|
|
|
16
16
|
MediaUploadPayload,
|
|
17
17
|
SelectMode,
|
|
18
18
|
} from "./runtime/types/media.js";
|
|
19
|
+
export type {
|
|
20
|
+
MapoMenu,
|
|
21
|
+
MenuTreeNode,
|
|
22
|
+
MenuNodeLink,
|
|
23
|
+
MenuTranslation,
|
|
24
|
+
} from "./runtime/types/menu.js";
|
|
25
|
+
export {
|
|
26
|
+
createMenuNode,
|
|
27
|
+
menuTreeDepth,
|
|
28
|
+
findMenuNode,
|
|
29
|
+
removeMenuNode,
|
|
30
|
+
} from "./runtime/types/menu.js";
|
package/src/module.ts
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
addTypeTemplate,
|
|
10
10
|
createResolver,
|
|
11
11
|
extendPages,
|
|
12
|
+
hasNuxtModule,
|
|
13
|
+
installModule,
|
|
12
14
|
} from "@nuxt/kit";
|
|
13
15
|
import type { NuxtModule } from "@nuxt/schema";
|
|
14
16
|
|
|
@@ -108,6 +110,13 @@ export default defineNuxtModule<MapoUikitOptions>({
|
|
|
108
110
|
/@mapomodule[\\/]uikit[\\/]/,
|
|
109
111
|
);
|
|
110
112
|
|
|
113
|
+
// UIKit components render every user-facing string through vue-i18n
|
|
114
|
+
// (`useI18n().t("mapo...")`). @mapomodule/i18n provides the catalogs and
|
|
115
|
+
// installs @nuxtjs/i18n unless the app manages it itself.
|
|
116
|
+
if (!hasNuxtModule("@mapomodule/i18n")) {
|
|
117
|
+
await installModule(await resolver.resolvePath("@mapomodule/i18n"));
|
|
118
|
+
}
|
|
119
|
+
|
|
111
120
|
addTypeTemplate({
|
|
112
121
|
filename: "types/mapo-uikit-page-meta.d.ts",
|
|
113
122
|
getContents: () =>
|
|
@@ -167,6 +176,8 @@ export default defineNuxtModule<MapoUikitOptions>({
|
|
|
167
176
|
"MapoLogoutButton",
|
|
168
177
|
"MapoSidebarProfile",
|
|
169
178
|
"MapoTopbar",
|
|
179
|
+
"MapoLangSwitcher",
|
|
180
|
+
"MapoThemeToggle",
|
|
170
181
|
// ─── CRUD / Detail / List ─────────────────────────────────────────────
|
|
171
182
|
"MapoDetail",
|
|
172
183
|
"MapoDetailLangSwitch",
|
|
@@ -186,6 +197,12 @@ export default defineNuxtModule<MapoUikitOptions>({
|
|
|
186
197
|
"MapoMediaEditor",
|
|
187
198
|
"MapoMediaUploader",
|
|
188
199
|
"MapoMediaManager",
|
|
200
|
+
"MapoMediaManagerDialog",
|
|
201
|
+
// ─── Menu Manager ─────────────────────────────────────────────────────
|
|
202
|
+
"MapoMenuTreeviewNode",
|
|
203
|
+
"MapoMenuTreeview",
|
|
204
|
+
"MapoMenuNodeEditor",
|
|
205
|
+
"MapoMenuManager",
|
|
189
206
|
];
|
|
190
207
|
|
|
191
208
|
for (const name of components) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
import { useI18n } from "vue-i18n";
|
|
2
3
|
import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
|
|
3
4
|
|
|
5
|
+
const { t } = useI18n();
|
|
4
6
|
const store = useConfirmStore();
|
|
5
7
|
</script>
|
|
6
8
|
|
|
@@ -10,7 +12,7 @@ const store = useConfirmStore();
|
|
|
10
12
|
<div class="p-6 space-y-4">
|
|
11
13
|
<div class="space-y-1">
|
|
12
14
|
<h3 class="text-base font-semibold text-highlighted">
|
|
13
|
-
{{ store.options?.title ?? "
|
|
15
|
+
{{ store.options?.title ?? t("mapo.confirm") }}
|
|
14
16
|
</h3>
|
|
15
17
|
<p class="text-sm text-muted">
|
|
16
18
|
{{ store.options?.message }}
|
|
@@ -19,13 +21,13 @@ const store = useConfirmStore();
|
|
|
19
21
|
|
|
20
22
|
<div class="flex justify-end gap-3">
|
|
21
23
|
<UButton variant="ghost" color="neutral" @click="store.cancel()">
|
|
22
|
-
{{ store.options?.cancelText ?? "
|
|
24
|
+
{{ store.options?.cancelText ?? t("mapo.cancel") }}
|
|
23
25
|
</UButton>
|
|
24
26
|
<UButton
|
|
25
27
|
:color="store.options?.dangerous ? 'error' : 'primary'"
|
|
26
28
|
@click="store.confirm()"
|
|
27
29
|
>
|
|
28
|
-
{{ store.options?.confirmText ?? "
|
|
30
|
+
{{ store.options?.confirmText ?? t("mapo.confirm") }}
|
|
29
31
|
</UButton>
|
|
30
32
|
</div>
|
|
31
33
|
</div>
|
|
@@ -11,10 +11,15 @@ import {
|
|
|
11
11
|
type Ref,
|
|
12
12
|
type VNode,
|
|
13
13
|
} from "vue";
|
|
14
|
-
import { useRouter, onBeforeRouteLeave } from "
|
|
15
|
-
import {
|
|
14
|
+
import { useRouter, onBeforeRouteLeave, useNuxtApp } from "#app";
|
|
15
|
+
import { useI18n } from "vue-i18n";
|
|
16
16
|
import { objectDiff, debounce, deepClone } from "@mapomodule/utils";
|
|
17
17
|
import { useCrud } from "@mapomodule/core/runtime/api/crud";
|
|
18
|
+
import {
|
|
19
|
+
getErrorData,
|
|
20
|
+
getErrorDetail,
|
|
21
|
+
getErrorStatus,
|
|
22
|
+
} from "@mapomodule/core/runtime/utils/fetchError";
|
|
18
23
|
import { useSnackStore } from "@mapomodule/store/runtime/stores/snack";
|
|
19
24
|
import { useConfirmStore } from "@mapomodule/store/runtime/stores/confirm";
|
|
20
25
|
import type { AnyFieldDescriptor, FieldRegistry } from "@mapomodule/form/types";
|
|
@@ -128,6 +133,7 @@ const { $mapoFormRegistry } = useNuxtApp() as unknown as {
|
|
|
128
133
|
};
|
|
129
134
|
const registry = computed(() => props.registry ?? $mapoFormRegistry);
|
|
130
135
|
|
|
136
|
+
const { t } = useI18n();
|
|
131
137
|
const router = useRouter();
|
|
132
138
|
const snack = useSnackStore();
|
|
133
139
|
const confirm = useConfirmStore();
|
|
@@ -343,12 +349,8 @@ async function fetchModel() {
|
|
|
343
349
|
}
|
|
344
350
|
checkDraft();
|
|
345
351
|
} catch (err: unknown) {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
const detail = (err as { response?: { data?: { detail?: string } } })
|
|
349
|
-
?.response?.data?.detail;
|
|
350
|
-
snack.show(detail ?? "Failed to load item", "error");
|
|
351
|
-
if (status === 404) router.back();
|
|
352
|
+
snack.show(getErrorDetail(err) ?? t("mapo.loadItemError"), "error");
|
|
353
|
+
if (getErrorStatus(err) === 404) router.back();
|
|
352
354
|
} finally {
|
|
353
355
|
isLoading.value = false;
|
|
354
356
|
}
|
|
@@ -365,7 +367,7 @@ async function save(andBack = false) {
|
|
|
365
367
|
);
|
|
366
368
|
const message = fieldErrors.length
|
|
367
369
|
? fieldErrors.map(([field, msg]) => `${field}: ${msg}`).join("\n")
|
|
368
|
-
: "
|
|
370
|
+
: t("mapo.fixErrors");
|
|
369
371
|
snack.show(message, "error");
|
|
370
372
|
return;
|
|
371
373
|
}
|
|
@@ -397,7 +399,7 @@ async function save(andBack = false) {
|
|
|
397
399
|
backup.value = deepClone(model.value) as T;
|
|
398
400
|
clearDraft();
|
|
399
401
|
snack.show(
|
|
400
|
-
isNew.value ? "
|
|
402
|
+
isNew.value ? t("mapo.createSuccess") : t("mapo.saveSuccess"),
|
|
401
403
|
"success",
|
|
402
404
|
);
|
|
403
405
|
emit("saved", model.value);
|
|
@@ -409,10 +411,8 @@ async function save(andBack = false) {
|
|
|
409
411
|
}
|
|
410
412
|
if (andBack) back();
|
|
411
413
|
} catch (err: unknown) {
|
|
412
|
-
const
|
|
413
|
-
|
|
414
|
-
const data = response?.data;
|
|
415
|
-
if (response?.status === 400 && data && typeof data === "object") {
|
|
414
|
+
const data = getErrorData(err);
|
|
415
|
+
if (getErrorStatus(err) === 400 && data && typeof data === "object") {
|
|
416
416
|
errors.value = data as Record<string, string[]>;
|
|
417
417
|
// Field-level errors: the useMapoForm watcher shows the detailed toast.
|
|
418
418
|
// Only surface a toast here if the response carries a top-level detail message.
|
|
@@ -420,7 +420,7 @@ async function save(andBack = false) {
|
|
|
420
420
|
if (detail) snack.show(detail, "error");
|
|
421
421
|
} else {
|
|
422
422
|
const detail = (data as { detail?: string } | undefined)?.detail;
|
|
423
|
-
snack.show(detail ?? "
|
|
423
|
+
snack.show(detail ?? t("mapo.saveError"), "error");
|
|
424
424
|
}
|
|
425
425
|
} finally {
|
|
426
426
|
isSaving.value = false;
|
|
@@ -436,10 +436,9 @@ function getPatch(): Partial<T> {
|
|
|
436
436
|
|
|
437
437
|
async function deleteItem() {
|
|
438
438
|
const ok = await confirm.ask({
|
|
439
|
-
title: "
|
|
440
|
-
message:
|
|
441
|
-
|
|
442
|
-
confirmText: "Delete",
|
|
439
|
+
title: t("mapo.delete"),
|
|
440
|
+
message: t("mapo.detail.deleteQuestion"),
|
|
441
|
+
confirmText: t("mapo.delete"),
|
|
443
442
|
dangerous: true,
|
|
444
443
|
});
|
|
445
444
|
if (!ok) return;
|
|
@@ -447,13 +446,11 @@ async function deleteItem() {
|
|
|
447
446
|
try {
|
|
448
447
|
await crud.delete(recordId());
|
|
449
448
|
backup.value = deepClone(model.value) as T; // clear dirty so guard doesn't fire
|
|
450
|
-
snack.show("
|
|
449
|
+
snack.show(t("mapo.deleteSuccess"), "success");
|
|
451
450
|
emit("deleted");
|
|
452
451
|
back();
|
|
453
452
|
} catch (err: unknown) {
|
|
454
|
-
|
|
455
|
-
?.response?.data?.detail;
|
|
456
|
-
snack.show(detail ?? "Failed to delete", "error");
|
|
453
|
+
snack.show(getErrorDetail(err) ?? t("mapo.deleteError"), "error");
|
|
457
454
|
} finally {
|
|
458
455
|
isDeleting.value = false;
|
|
459
456
|
}
|
|
@@ -468,9 +465,9 @@ function back() {
|
|
|
468
465
|
async function guardUnsaved(): Promise<boolean> {
|
|
469
466
|
if (!isDirty.value) return true;
|
|
470
467
|
return confirm.ask({
|
|
471
|
-
title: "
|
|
472
|
-
message: "
|
|
473
|
-
confirmText: "
|
|
468
|
+
title: t("mapo.unsavedData"),
|
|
469
|
+
message: t("mapo.confirmLeaveChanges"),
|
|
470
|
+
confirmText: t("mapo.leave"),
|
|
474
471
|
dangerous: true,
|
|
475
472
|
});
|
|
476
473
|
}
|
|
@@ -636,12 +633,16 @@ defineSlots<{
|
|
|
636
633
|
color="warning"
|
|
637
634
|
variant="subtle"
|
|
638
635
|
class="mb-3"
|
|
639
|
-
:title="
|
|
640
|
-
|
|
636
|
+
:title="
|
|
637
|
+
t('mapo.detail.draftSavedAt', {
|
|
638
|
+
date: draftBanner.savedAt.toLocaleString(),
|
|
639
|
+
})
|
|
640
|
+
"
|
|
641
|
+
:description="t('mapo.detail.draftFound')"
|
|
641
642
|
>
|
|
642
643
|
<template #actions>
|
|
643
644
|
<UButton size="xs" color="warning" @click="draftBanner?.restore()">
|
|
644
|
-
|
|
645
|
+
{{ t("mapo.restore") }}
|
|
645
646
|
</UButton>
|
|
646
647
|
<UButton
|
|
647
648
|
size="xs"
|
|
@@ -649,7 +650,7 @@ defineSlots<{
|
|
|
649
650
|
variant="ghost"
|
|
650
651
|
@click="draftBanner?.discard()"
|
|
651
652
|
>
|
|
652
|
-
|
|
653
|
+
{{ t("mapo.discard") }}
|
|
653
654
|
</UButton>
|
|
654
655
|
</template>
|
|
655
656
|
</UAlert>
|
|
@@ -659,7 +660,7 @@ defineSlots<{
|
|
|
659
660
|
<!-- Title -->
|
|
660
661
|
<slot name="title" v-bind="slotBindings">
|
|
661
662
|
<h1 class="text-2xl font-bold text-gray-900 dark:text-white mb-6">
|
|
662
|
-
{{ isNew ? "
|
|
663
|
+
{{ isNew ? t("mapo.new") : t("mapo.edit") }}
|
|
663
664
|
<span v-if="modelName"> {{ modelName }}</span>
|
|
664
665
|
</h1>
|
|
665
666
|
</slot>
|
|
@@ -718,7 +719,7 @@ defineSlots<{
|
|
|
718
719
|
icon="i-lucide-save"
|
|
719
720
|
@click="save(true)"
|
|
720
721
|
>
|
|
721
|
-
{{ isNew ? "
|
|
722
|
+
{{ isNew ? t("mapo.create") : t("mapo.save") }}
|
|
722
723
|
</UButton>
|
|
723
724
|
</slot>
|
|
724
725
|
|
|
@@ -731,7 +732,9 @@ defineSlots<{
|
|
|
731
732
|
icon="i-lucide-save"
|
|
732
733
|
@click="save(false)"
|
|
733
734
|
>
|
|
734
|
-
{{
|
|
735
|
+
{{
|
|
736
|
+
isNew ? t("mapo.createContinue") : t("mapo.saveContinue")
|
|
737
|
+
}}
|
|
735
738
|
</UButton>
|
|
736
739
|
</slot>
|
|
737
740
|
|
|
@@ -742,7 +745,7 @@ defineSlots<{
|
|
|
742
745
|
icon="i-lucide-arrow-left"
|
|
743
746
|
@click="back"
|
|
744
747
|
>
|
|
745
|
-
|
|
748
|
+
{{ t("mapo.back") }}
|
|
746
749
|
</UButton>
|
|
747
750
|
</slot>
|
|
748
751
|
</div>
|
|
@@ -805,7 +808,7 @@ defineSlots<{
|
|
|
805
808
|
icon="i-lucide-eye"
|
|
806
809
|
@click="previewOpen = true"
|
|
807
810
|
>
|
|
808
|
-
|
|
811
|
+
{{ t("mapo.preview") }}
|
|
809
812
|
</UButton>
|
|
810
813
|
|
|
811
814
|
<!-- Danger zone: delete action, visually separated from save actions -->
|
|
@@ -820,7 +823,7 @@ defineSlots<{
|
|
|
820
823
|
icon="i-lucide-trash-2"
|
|
821
824
|
@click="deleteItem"
|
|
822
825
|
>
|
|
823
|
-
|
|
826
|
+
{{ t("mapo.delete") }}
|
|
824
827
|
</UButton>
|
|
825
828
|
</slot>
|
|
826
829
|
</UCard>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ref } from "vue";
|
|
3
|
+
import { useI18n } from "vue-i18n";
|
|
4
|
+
|
|
5
|
+
const { t } = useI18n();
|
|
3
6
|
|
|
4
7
|
const props = withDefaults(
|
|
5
8
|
defineProps<{
|
|
@@ -103,7 +106,9 @@ defineExpose({ triggerPick });
|
|
|
103
106
|
>
|
|
104
107
|
<div class="flex flex-col items-center gap-2 text-primary">
|
|
105
108
|
<UIcon name="i-lucide-upload-cloud" class="size-10" />
|
|
106
|
-
<span class="text-sm font-medium">
|
|
109
|
+
<span class="text-sm font-medium">{{
|
|
110
|
+
t("mapo.dropArea.dropHere")
|
|
111
|
+
}}</span>
|
|
107
112
|
</div>
|
|
108
113
|
</div>
|
|
109
114
|
</Transition>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import type { Ref } from "vue";
|
|
4
|
+
import { useI18n } from "vue-i18n";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* UI locale switcher — lists the locales configured in `@nuxtjs/i18n`
|
|
8
|
+
* (via `@mapomodule/i18n`) and switches the interface language with
|
|
9
|
+
* cookie persistence. Port of the v1 `LangSwitcher`.
|
|
10
|
+
*/
|
|
11
|
+
const props = withDefaults(
|
|
12
|
+
defineProps<{
|
|
13
|
+
/** Show the flag emoji derived from the locale `language` tag. */
|
|
14
|
+
flags?: boolean;
|
|
15
|
+
/** Nuxt UI USelectMenu `size` prop. */
|
|
16
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl";
|
|
17
|
+
}>(),
|
|
18
|
+
{ flags: true, size: "sm" },
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
interface SwitcherLocale {
|
|
22
|
+
code: string;
|
|
23
|
+
name?: string;
|
|
24
|
+
language?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// `locales` and `setLocale` are @nuxtjs/i18n Composer extensions; the uikit
|
|
28
|
+
// package only depends on vue-i18n types, so they are typed structurally.
|
|
29
|
+
const { locale, locales, setLocale } = useI18n() as unknown as {
|
|
30
|
+
locale: Ref<string>;
|
|
31
|
+
locales: Ref<SwitcherLocale[]>;
|
|
32
|
+
setLocale: (code: string) => Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** Regional-indicator flag emoji from a BCP-47 tag (e.g. `en-US` → 🇺🇸). */
|
|
36
|
+
function getFlag(language?: string): string {
|
|
37
|
+
const region = language?.split("-").at(-1);
|
|
38
|
+
if (!region || region.length !== 2 || !/^[A-Za-z]+$/.test(region)) return "";
|
|
39
|
+
const codePoints = region
|
|
40
|
+
.toUpperCase()
|
|
41
|
+
.split("")
|
|
42
|
+
.map((char) => 127397 + char.charCodeAt(0));
|
|
43
|
+
return String.fromCodePoint(...codePoints);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const items = computed(() =>
|
|
47
|
+
locales.value.map((l) => ({
|
|
48
|
+
label:
|
|
49
|
+
props.flags && getFlag(l.language)
|
|
50
|
+
? `${getFlag(l.language)} ${l.name ?? l.code.toUpperCase()}`
|
|
51
|
+
: (l.name ?? l.code.toUpperCase()),
|
|
52
|
+
value: l.code,
|
|
53
|
+
})),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const current = computed({
|
|
57
|
+
get: () => locale.value,
|
|
58
|
+
set: (code: string) => {
|
|
59
|
+
if (code && code !== locale.value) setLocale(code);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<template>
|
|
65
|
+
<USelectMenu
|
|
66
|
+
v-model="current"
|
|
67
|
+
:items="items"
|
|
68
|
+
value-key="value"
|
|
69
|
+
label-key="label"
|
|
70
|
+
:size="size"
|
|
71
|
+
:search-input="false"
|
|
72
|
+
class="w-40"
|
|
73
|
+
/>
|
|
74
|
+
</template>
|
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
} from "../types/list.js";
|
|
12
12
|
import type { AnyFieldDescriptor, FieldRegistry } from "@mapomodule/form/types";
|
|
13
13
|
import { debounce } from "@mapomodule/utils";
|
|
14
|
-
import { useRoute, useRouter } from "
|
|
14
|
+
import { useRoute, useRouter } from "#app";
|
|
15
15
|
|
|
16
16
|
const props = withDefaults(
|
|
17
17
|
defineProps<{
|