@mapomodule/uikit 2.0.0-beta.7 → 2.0.0-experimental.1

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 (199) hide show
  1. package/README.md +47 -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__/MapoListActions.component.test.d.ts +2 -0
  9. package/dist/__tests__/MapoListActions.component.test.d.ts.map +1 -0
  10. package/dist/__tests__/MapoListTable.component.test.d.ts +2 -0
  11. package/dist/__tests__/MapoListTable.component.test.d.ts.map +1 -0
  12. package/dist/__tests__/MapoSnackBar.component.test.d.ts +2 -0
  13. package/dist/__tests__/MapoSnackBar.component.test.d.ts.map +1 -0
  14. package/dist/__tests__/__mocks__/nuxt-app.d.ts +9 -0
  15. package/dist/__tests__/__mocks__/nuxt-app.d.ts.map +1 -0
  16. package/dist/__tests__/formValues.test.d.ts +2 -0
  17. package/dist/__tests__/formValues.test.d.ts.map +1 -0
  18. package/dist/__tests__/langInfo.test.d.ts +2 -0
  19. package/dist/__tests__/langInfo.test.d.ts.map +1 -0
  20. package/dist/__tests__/listTable.test.d.ts +2 -0
  21. package/dist/__tests__/listTable.test.d.ts.map +1 -0
  22. package/dist/__tests__/mediaLanguages.test.d.ts +2 -0
  23. package/dist/__tests__/mediaLanguages.test.d.ts.map +1 -0
  24. package/dist/__tests__/runtimePages.test.d.ts +2 -0
  25. package/dist/__tests__/runtimePages.test.d.ts.map +1 -0
  26. package/dist/index.d.mts +2 -0
  27. package/dist/index.d.ts +3 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.mjs +1 -1
  30. package/dist/module.d.mts +2 -0
  31. package/dist/module.d.ts.map +1 -1
  32. package/dist/module.json +1 -1
  33. package/dist/module.mjs +23 -2
  34. package/dist/runtime/assets/main.css +1 -1
  35. package/dist/runtime/components/MapoConfirmDialog.vue +23 -4
  36. package/dist/runtime/components/MapoConfirmDialog.vue.d.ts.map +1 -1
  37. package/dist/runtime/components/MapoDetail.vue +301 -63
  38. package/dist/runtime/components/MapoDetail.vue.d.ts +191 -9
  39. package/dist/runtime/components/MapoDetail.vue.d.ts.map +1 -1
  40. package/dist/runtime/components/MapoDetailExtensions.vue +24 -0
  41. package/dist/runtime/components/MapoDetailExtensions.vue.d.ts +15 -0
  42. package/dist/runtime/components/MapoDetailExtensions.vue.d.ts.map +1 -0
  43. package/dist/runtime/components/MapoDetailLangSwitch.vue +22 -26
  44. package/dist/runtime/components/MapoDetailLangSwitch.vue.d.ts +4 -3
  45. package/dist/runtime/components/MapoDetailLangSwitch.vue.d.ts.map +1 -1
  46. package/dist/runtime/components/MapoDropArea.vue +5 -1
  47. package/dist/runtime/components/MapoDropArea.vue.d.ts +1 -1
  48. package/dist/runtime/components/MapoDropArea.vue.d.ts.map +1 -1
  49. package/dist/runtime/components/MapoLangSwitcher.vue +39 -0
  50. package/dist/runtime/components/MapoLangSwitcher.vue.d.ts +18 -0
  51. package/dist/runtime/components/MapoLangSwitcher.vue.d.ts.map +1 -0
  52. package/dist/runtime/components/MapoList.vue +7 -3
  53. package/dist/runtime/components/MapoList.vue.d.ts +14 -4
  54. package/dist/runtime/components/MapoList.vue.d.ts.map +1 -1
  55. package/dist/runtime/components/MapoListActions.vue +27 -13
  56. package/dist/runtime/components/MapoListActions.vue.d.ts +4 -0
  57. package/dist/runtime/components/MapoListActions.vue.d.ts.map +1 -1
  58. package/dist/runtime/components/MapoListFilters.vue +4 -2
  59. package/dist/runtime/components/MapoListFilters.vue.d.ts.map +1 -1
  60. package/dist/runtime/components/MapoListQuickEdit.vue +12 -8
  61. package/dist/runtime/components/MapoListQuickEdit.vue.d.ts.map +1 -1
  62. package/dist/runtime/components/MapoListTable.vue +116 -45
  63. package/dist/runtime/components/MapoListTable.vue.d.ts +11 -6
  64. package/dist/runtime/components/MapoListTable.vue.d.ts.map +1 -1
  65. package/dist/runtime/components/MapoLogin.vue +13 -10
  66. package/dist/runtime/components/MapoLogin.vue.d.ts.map +1 -1
  67. package/dist/runtime/components/MapoLogoutButton.vue +4 -2
  68. package/dist/runtime/components/MapoLogoutButton.vue.d.ts.map +1 -1
  69. package/dist/runtime/components/MapoMediaBreadcrumbs.vue +3 -1
  70. package/dist/runtime/components/MapoMediaBreadcrumbs.vue.d.ts.map +1 -1
  71. package/dist/runtime/components/MapoMediaEditor.vue +36 -20
  72. package/dist/runtime/components/MapoMediaEditor.vue.d.ts +1 -0
  73. package/dist/runtime/components/MapoMediaEditor.vue.d.ts.map +1 -1
  74. package/dist/runtime/components/MapoMediaFileChanger.vue +7 -3
  75. package/dist/runtime/components/MapoMediaFileChanger.vue.d.ts.map +1 -1
  76. package/dist/runtime/components/MapoMediaFolders.vue +36 -14
  77. package/dist/runtime/components/MapoMediaFolders.vue.d.ts.map +1 -1
  78. package/dist/runtime/components/MapoMediaGallery.vue +15 -5
  79. package/dist/runtime/components/MapoMediaGallery.vue.d.ts.map +1 -1
  80. package/dist/runtime/components/MapoMediaManager.vue +17 -7
  81. package/dist/runtime/components/MapoMediaManager.vue.d.ts.map +1 -1
  82. package/dist/runtime/components/MapoMediaManagerDialog.vue +8 -4
  83. package/dist/runtime/components/MapoMediaManagerDialog.vue.d.ts.map +1 -1
  84. package/dist/runtime/components/MapoMediaUploader.vue +53 -29
  85. package/dist/runtime/components/MapoMediaUploader.vue.d.ts.map +1 -1
  86. package/dist/runtime/components/MapoMenuManager.vue +293 -0
  87. package/dist/runtime/components/MapoMenuManager.vue.d.ts +92 -0
  88. package/dist/runtime/components/MapoMenuManager.vue.d.ts.map +1 -0
  89. package/dist/runtime/components/MapoMenuNodeEditor.vue +201 -0
  90. package/dist/runtime/components/MapoMenuNodeEditor.vue.d.ts +61 -0
  91. package/dist/runtime/components/MapoMenuNodeEditor.vue.d.ts.map +1 -0
  92. package/dist/runtime/components/MapoMenuTreeview.vue +181 -0
  93. package/dist/runtime/components/MapoMenuTreeview.vue.d.ts +57 -0
  94. package/dist/runtime/components/MapoMenuTreeview.vue.d.ts.map +1 -0
  95. package/dist/runtime/components/MapoMenuTreeviewNode.vue +175 -0
  96. package/dist/runtime/components/MapoMenuTreeviewNode.vue.d.ts +27 -0
  97. package/dist/runtime/components/MapoMenuTreeviewNode.vue.d.ts.map +1 -0
  98. package/dist/runtime/components/MapoSidebar.vue +3 -1
  99. package/dist/runtime/components/MapoSidebar.vue.d.ts.map +1 -1
  100. package/dist/runtime/components/MapoSidebarList.vue +1 -1
  101. package/dist/runtime/components/MapoSidebarProfile.vue +6 -2
  102. package/dist/runtime/components/MapoSidebarProfile.vue.d.ts.map +1 -1
  103. package/dist/runtime/components/MapoSnackBar.vue +11 -0
  104. package/dist/runtime/components/MapoSnackBar.vue.d.ts.map +1 -1
  105. package/dist/runtime/components/MapoThemeToggle.vue +5 -1
  106. package/dist/runtime/components/MapoThemeToggle.vue.d.ts.map +1 -1
  107. package/dist/runtime/components/menuDndContext.d.ts +19 -0
  108. package/dist/runtime/components/menuDndContext.d.ts.map +1 -0
  109. package/dist/runtime/components/menuDndContext.js +3 -0
  110. package/dist/runtime/composables/defineDetailExtension.d.ts +32 -0
  111. package/dist/runtime/composables/defineDetailExtension.d.ts.map +1 -0
  112. package/dist/runtime/composables/defineDetailExtension.js +34 -0
  113. package/dist/runtime/composables/useMapoDetail.d.ts +18 -0
  114. package/dist/runtime/composables/useMapoDetail.d.ts.map +1 -0
  115. package/dist/runtime/composables/useMapoDetail.js +5 -0
  116. package/dist/runtime/page-meta.nuxt.d.ts +4 -0
  117. package/dist/runtime/pages/index.vue +4 -2
  118. package/dist/runtime/pages/index.vue.d.ts.map +1 -1
  119. package/dist/runtime/plugins/media-adapter.d.ts.map +1 -1
  120. package/dist/runtime/plugins/media-adapter.js +2 -1
  121. package/dist/runtime/stores/media.d.ts +8 -2
  122. package/dist/runtime/stores/media.d.ts.map +1 -1
  123. package/dist/runtime/stores/media.js +45 -13
  124. package/dist/runtime/types/detail.d.ts +167 -0
  125. package/dist/runtime/types/detail.d.ts.map +1 -0
  126. package/dist/runtime/types/detail.js +0 -0
  127. package/dist/runtime/types/list.d.ts +10 -2
  128. package/dist/runtime/types/list.d.ts.map +1 -1
  129. package/dist/runtime/types/menu.d.ts +66 -0
  130. package/dist/runtime/types/menu.d.ts.map +1 -0
  131. package/dist/runtime/types/menu.js +30 -0
  132. package/dist/runtime/utils/formValues.d.ts +8 -0
  133. package/dist/runtime/utils/formValues.d.ts.map +1 -0
  134. package/dist/runtime/utils/formValues.js +19 -0
  135. package/dist/runtime/utils/langInfo.d.ts +30 -0
  136. package/dist/runtime/utils/langInfo.d.ts.map +1 -0
  137. package/dist/runtime/utils/langInfo.js +8 -0
  138. package/dist/runtime/utils/listTable.d.ts +29 -0
  139. package/dist/runtime/utils/listTable.d.ts.map +1 -0
  140. package/dist/runtime/utils/listTable.js +21 -0
  141. package/package.json +12 -10
  142. package/src/__tests__/MapoConfirmDialog.component.test.ts +165 -0
  143. package/src/__tests__/MapoDetail.component.test.ts +1107 -0
  144. package/src/__tests__/MapoDetailLangSwitch.component.test.ts +145 -0
  145. package/src/__tests__/MapoListActions.component.test.ts +175 -0
  146. package/src/__tests__/MapoListTable.component.test.ts +504 -0
  147. package/src/__tests__/MapoSnackBar.component.test.ts +79 -0
  148. package/src/__tests__/__mocks__/nuxt-app.ts +8 -0
  149. package/src/__tests__/formValues.test.ts +31 -0
  150. package/src/__tests__/langInfo.test.ts +48 -0
  151. package/src/__tests__/listTable.test.ts +82 -0
  152. package/src/__tests__/mediaLanguages.test.ts +66 -0
  153. package/src/__tests__/runtimePages.test.ts +17 -0
  154. package/src/index.ts +20 -0
  155. package/src/module.ts +29 -0
  156. package/src/runtime/assets/main.css +13 -0
  157. package/src/runtime/components/MapoConfirmDialog.vue +33 -4
  158. package/src/runtime/components/MapoDetail.vue +520 -89
  159. package/src/runtime/components/MapoDetailExtensions.vue +39 -0
  160. package/src/runtime/components/MapoDetailLangSwitch.vue +27 -28
  161. package/src/runtime/components/MapoDropArea.vue +6 -1
  162. package/src/runtime/components/MapoLangSwitcher.vue +74 -0
  163. package/src/runtime/components/MapoList.vue +21 -6
  164. package/src/runtime/components/MapoListActions.vue +32 -14
  165. package/src/runtime/components/MapoListFilters.vue +5 -2
  166. package/src/runtime/components/MapoListQuickEdit.vue +12 -9
  167. package/src/runtime/components/MapoListTable.vue +147 -55
  168. package/src/runtime/components/MapoLogin.vue +13 -10
  169. package/src/runtime/components/MapoLogoutButton.vue +4 -2
  170. package/src/runtime/components/MapoMediaBreadcrumbs.vue +3 -1
  171. package/src/runtime/components/MapoMediaEditor.vue +43 -20
  172. package/src/runtime/components/MapoMediaFileChanger.vue +8 -3
  173. package/src/runtime/components/MapoMediaFolders.vue +37 -15
  174. package/src/runtime/components/MapoMediaGallery.vue +17 -5
  175. package/src/runtime/components/MapoMediaManager.vue +17 -7
  176. package/src/runtime/components/MapoMediaManagerDialog.vue +10 -4
  177. package/src/runtime/components/MapoMediaUploader.vue +60 -29
  178. package/src/runtime/components/MapoMenuManager.vue +437 -0
  179. package/src/runtime/components/MapoMenuNodeEditor.vue +282 -0
  180. package/src/runtime/components/MapoMenuTreeview.vue +264 -0
  181. package/src/runtime/components/MapoMenuTreeviewNode.vue +234 -0
  182. package/src/runtime/components/MapoSidebar.vue +3 -1
  183. package/src/runtime/components/MapoSidebarList.vue +1 -1
  184. package/src/runtime/components/MapoSidebarProfile.vue +6 -2
  185. package/src/runtime/components/MapoSnackBar.vue +12 -0
  186. package/src/runtime/components/MapoThemeToggle.vue +5 -1
  187. package/src/runtime/components/menuDndContext.ts +22 -0
  188. package/src/runtime/composables/defineDetailExtension.ts +78 -0
  189. package/src/runtime/composables/useMapoDetail.ts +24 -0
  190. package/src/runtime/page-meta.nuxt.d.ts +4 -0
  191. package/src/runtime/pages/index.vue +5 -2
  192. package/src/runtime/plugins/media-adapter.ts +9 -5
  193. package/src/runtime/stores/media.ts +61 -13
  194. package/src/runtime/types/detail.ts +178 -0
  195. package/src/runtime/types/list.ts +10 -2
  196. package/src/runtime/types/menu.ts +105 -0
  197. package/src/runtime/utils/formValues.ts +28 -0
  198. package/src/runtime/utils/langInfo.ts +38 -0
  199. package/src/runtime/utils/listTable.ts +54 -0
@@ -0,0 +1,34 @@
1
+ import { defineAsyncComponent, shallowReactive } from "vue";
2
+ import { useNuxtApp } from "#app";
3
+ const registries = /* @__PURE__ */ new WeakMap();
4
+ export function detailExtensions(nuxtApp = useNuxtApp()) {
5
+ let list = registries.get(nuxtApp);
6
+ if (!list) {
7
+ list = shallowReactive([]);
8
+ registries.set(nuxtApp, list);
9
+ }
10
+ return list;
11
+ }
12
+ function toComponent(entry) {
13
+ if (typeof entry !== "function") return entry;
14
+ const load = entry;
15
+ return defineAsyncComponent(async () => {
16
+ const loaded = await load();
17
+ const isModule = typeof loaded === "object" && "default" in loaded;
18
+ return isModule ? loaded.default : loaded;
19
+ });
20
+ }
21
+ export function defineDetailExtension(extension) {
22
+ const list = detailExtensions();
23
+ const entry = {
24
+ ...extension,
25
+ component: toComponent(extension.component)
26
+ };
27
+ const index = list.findIndex((item) => item.key === extension.key);
28
+ if (index >= 0) list.splice(index, 1, entry);
29
+ else list.push(entry);
30
+ return () => {
31
+ const at = list.indexOf(entry);
32
+ if (at >= 0) list.splice(at, 1);
33
+ };
34
+ }
@@ -0,0 +1,18 @@
1
+ import type { InjectionKey } from "vue";
2
+ import type { MapoDetailContext } from "../types/detail.js";
3
+ /** The key `MapoDetail` provides its context under. @internal */
4
+ export declare const DETAIL_KEY: InjectionKey<MapoDetailContext>;
5
+ /**
6
+ * The context of the `MapoDetail` around the calling component: record, fields,
7
+ * languages, state, `save()`, the annotations channel and the shared `OPTIONS`
8
+ * response. Use it in a slot, a field or an extension, instead of passing the
9
+ * same values down again.
10
+ *
11
+ * @returns The context, or `undefined` outside a `MapoDetail`.
12
+ *
13
+ * @example
14
+ * const detail = useMapoDetail<Article>();
15
+ * if (detail) detail.model.value.title = "Chi siamo";
16
+ */
17
+ export declare function useMapoDetail<T extends object = Record<string, unknown>>(): MapoDetailContext<T> | undefined;
18
+ //# sourceMappingURL=useMapoDetail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMapoDetail.d.ts","sourceRoot":"","sources":["../../../src/runtime/composables/useMapoDetail.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,iEAAiE;AACjE,eAAO,MAAM,UAAU,EAAE,YAAY,CAAC,iBAAiB,CAAwB,CAAC;AAEhF;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACpE,iBAAiB,CAAC,CAAC,CAAC,GACpB,SAAS,CAEZ"}
@@ -0,0 +1,5 @@
1
+ import { inject } from "vue";
2
+ export const DETAIL_KEY = Symbol("MapoDetail");
3
+ export function useMapoDetail() {
4
+ return inject(DETAIL_KEY, void 0);
5
+ }
@@ -10,6 +10,8 @@ declare module "#app" {
10
10
  parent?: string;
11
11
  /** Pin this page to the sidebar footer instead of the main navigation list. */
12
12
  sidebarFooter?: boolean;
13
+ /** Sort this page among siblings in the sidebar; lower values appear first. */
14
+ sidebarOrder?: number;
13
15
  }
14
16
  }
15
17
 
@@ -29,6 +31,8 @@ declare module "vue-router" {
29
31
  parent?: string;
30
32
  /** Pin this page to the sidebar footer instead of the main navigation list. */
31
33
  sidebarFooter?: boolean;
34
+ /** Sort this page among siblings in the sidebar; lower values appear first. */
35
+ sidebarOrder?: number;
32
36
  }
33
37
  }
34
38
 
@@ -1,12 +1,14 @@
1
1
  <script setup>
2
+ import { useI18n } from "vue-i18n";
2
3
  import { version } from "../../../package.json";
4
+ const { t } = useI18n();
3
5
  </script>
4
6
 
5
7
  <template>
6
8
  <div class="flex h-full items-center justify-center p-8">
7
9
  <div class="space-y-4 rounded-lg border bg-white p-8 text-center shadow">
8
- <h1 class="text-2xl font-bold">Mapo UI Kit</h1>
9
- <p class="text-gray-600">Version {{ version }}</p>
10
+ <h1 class="text-2xl font-bold">{{ t("mapo.index.welcomeMessage") }}</h1>
11
+ <p class="text-gray-600">Mapo UI Kit — {{ version }}</p>
10
12
  </div>
11
13
  </div>
12
14
  </template>
@@ -1 +1 @@
1
- {"version":3,"file":"index.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/pages/index.vue"],"names":[],"mappings":"AA+DA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
1
+ {"version":3,"file":"index.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/pages/index.vue"],"names":[],"mappings":"AAuEA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
@@ -1 +1 @@
1
- {"version":3,"file":"media-adapter.d.ts","sourceRoot":"","sources":["../../../src/runtime/plugins/media-adapter.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,OAAO;QACf,iBAAiB,EAAE,YAAY,CAAC;KACjC;CACF;AAED,OAAO,QAAQ,KAAK,CAAC;IACnB,UAAU,yBAAyB;QACjC,iBAAiB,EAAE,YAAY,CAAC;KACjC;CACF;;;;;;AAED,wBAIG"}
1
+ {"version":3,"file":"media-adapter.d.ts","sourceRoot":"","sources":["../../../src/runtime/plugins/media-adapter.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,OAAO;QACf,iBAAiB,EAAE,YAAY,CAAC;KACjC;CACF;AAED,OAAO,QAAQ,KAAK,CAAC;IACnB,UAAU,yBAAyB;QACjC,iBAAiB,EAAE,YAAY,CAAC;KACjC;CACF;;;;;;AAED,wBAKG"}
@@ -1,6 +1,7 @@
1
1
  import { defineNuxtPlugin } from "#app";
2
2
  import { defaultMediaAdapter } from "../adapters/defaultMediaAdapter.js";
3
- export default defineNuxtPlugin(() => {
3
+ export default defineNuxtPlugin((nuxtApp) => {
4
+ if ("$mapoMediaAdapter" in nuxtApp) return;
4
5
  return {
5
6
  provide: { mapoMediaAdapter: defaultMediaAdapter }
6
7
  };
@@ -120,6 +120,7 @@ export declare const useMediaStore: import("pinia").StoreDefinition<"mapo-media"
120
120
  selection: import("vue").ShallowRef<MediaItem | MediaItem[] | null, MediaItem | MediaItem[] | null>;
121
121
  editList: import("vue").Ref<number[], number[]>;
122
122
  selectMode: import("vue").Ref<SelectMode, SelectMode>;
123
+ languages: import("vue").Ref<string[], string[]>;
123
124
  parentFolder: import("vue").ComputedRef<{
124
125
  id: number;
125
126
  name: string;
@@ -133,6 +134,7 @@ export declare const useMediaStore: import("pinia").StoreDefinition<"mapo-media"
133
134
  outside: boolean;
134
135
  }>;
135
136
  getRoot: (params?: MediaGetRootParams) => Promise<void>;
137
+ deriveLanguages: () => Promise<void>;
136
138
  navigateToFolder: (folder: MediaFolder | null) => Promise<void>;
137
139
  openEditor: (media: MediaItem) => Promise<void>;
138
140
  closeEditor: () => void;
@@ -152,7 +154,7 @@ export declare const useMediaStore: import("pinia").StoreDefinition<"mapo-media"
152
154
  setMimeType: (mime: string | null) => void;
153
155
  lockMimeType: (mime: string | null) => void;
154
156
  reset: () => void;
155
- }, "pages" | "page" | "medias" | "folders" | "parentFolders" | "mimeType" | "lockedMime" | "loading" | "editMedia" | "selection" | "editList" | "selectMode">, Pick<{
157
+ }, "pages" | "page" | "languages" | "loading" | "selection" | "medias" | "folders" | "parentFolders" | "mimeType" | "lockedMime" | "editMedia" | "editList" | "selectMode">, Pick<{
156
158
  medias: import("vue").Ref<{
157
159
  id: number;
158
160
  file: string;
@@ -273,6 +275,7 @@ export declare const useMediaStore: import("pinia").StoreDefinition<"mapo-media"
273
275
  selection: import("vue").ShallowRef<MediaItem | MediaItem[] | null, MediaItem | MediaItem[] | null>;
274
276
  editList: import("vue").Ref<number[], number[]>;
275
277
  selectMode: import("vue").Ref<SelectMode, SelectMode>;
278
+ languages: import("vue").Ref<string[], string[]>;
276
279
  parentFolder: import("vue").ComputedRef<{
277
280
  id: number;
278
281
  name: string;
@@ -286,6 +289,7 @@ export declare const useMediaStore: import("pinia").StoreDefinition<"mapo-media"
286
289
  outside: boolean;
287
290
  }>;
288
291
  getRoot: (params?: MediaGetRootParams) => Promise<void>;
292
+ deriveLanguages: () => Promise<void>;
289
293
  navigateToFolder: (folder: MediaFolder | null) => Promise<void>;
290
294
  openEditor: (media: MediaItem) => Promise<void>;
291
295
  closeEditor: () => void;
@@ -426,6 +430,7 @@ export declare const useMediaStore: import("pinia").StoreDefinition<"mapo-media"
426
430
  selection: import("vue").ShallowRef<MediaItem | MediaItem[] | null, MediaItem | MediaItem[] | null>;
427
431
  editList: import("vue").Ref<number[], number[]>;
428
432
  selectMode: import("vue").Ref<SelectMode, SelectMode>;
433
+ languages: import("vue").Ref<string[], string[]>;
429
434
  parentFolder: import("vue").ComputedRef<{
430
435
  id: number;
431
436
  name: string;
@@ -439,6 +444,7 @@ export declare const useMediaStore: import("pinia").StoreDefinition<"mapo-media"
439
444
  outside: boolean;
440
445
  }>;
441
446
  getRoot: (params?: MediaGetRootParams) => Promise<void>;
447
+ deriveLanguages: () => Promise<void>;
442
448
  navigateToFolder: (folder: MediaFolder | null) => Promise<void>;
443
449
  openEditor: (media: MediaItem) => Promise<void>;
444
450
  closeEditor: () => void;
@@ -458,5 +464,5 @@ export declare const useMediaStore: import("pinia").StoreDefinition<"mapo-media"
458
464
  setMimeType: (mime: string | null) => void;
459
465
  lockMimeType: (mime: string | null) => void;
460
466
  reset: () => void;
461
- }, "getRoot" | "navigateToFolder" | "openEditor" | "closeEditor" | "setLang" | "updateMedia" | "replaceFile" | "updateOrCreateFolder" | "deleteFolder" | "deleteMedia" | "select" | "setSelectionMode" | "setSelection" | "editSelect" | "editSelectAll" | "deleteSelected" | "uploadMedia" | "setMimeType" | "lockMimeType" | "reset">>;
467
+ }, "select" | "reset" | "getRoot" | "deriveLanguages" | "navigateToFolder" | "openEditor" | "closeEditor" | "setLang" | "updateMedia" | "replaceFile" | "updateOrCreateFolder" | "deleteFolder" | "deleteMedia" | "setSelectionMode" | "setSelection" | "editSelect" | "editSelectAll" | "deleteSelected" | "uploadMedia" | "setMimeType" | "lockMimeType">>;
462
468
  //# sourceMappingURL=media.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/runtime/stores/media.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EAEX,kBAAkB,EAClB,kBAAkB,EAGlB,UAAU,EACX,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;iBAKxB,CAAC;oBACqB,CAAC;uBACT,CAAC;;;;;;;;;;;;;;;;;;;;iBAFf,CAAC;oBACqB,CAAC;uBACT,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAFf,CAAC;oBACqB,CAAC;uBACT,CAAC;;;;;;;;;;;;;;;;;;;;iBAFf,CAAC;oBACqB,CAAC;uBACT,CAAC;;;;;;;;;;;;;;eAmEN,OAAO;uBACC,OAAO;iBACb,OAAO;;uBAkDa,kBAAkB,KAAQ,OAAO,CAAC,IAAI,CAAC;+BAuC9B,WAAW,GAAG,IAAI,KAAG,OAAO,CAAC,IAAI,CAAC;wBAOzC,SAAS,KAAG,OA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AAS,KAAG,OAAO,CAAC,IAAI,CAAC;uBAalC,IAAI;oBAIL,MAAM,GAAG,SAAS,KAAG,IAAI;yBAId,SAAS,KAAG,OAAO,CAAC,SAAS,CAAC;2BAcrD,MAAM,QACT,IAAI,4BAET,OAAO,CAAC,SAAS,CAAC;mCAgBX,OAAO,CAAC,WAAW,CAAC,KAC3B,OAAO,CAAC,IAAI,CAAC;2BAYoB,WAAW,KAAG,OAAO,CAAC,IAAI,CAAC;yBAa7B,SAAS,KAAG,OAAO,CAAC,IAAI,CAAC;oBAgBpC,SAAS,KAAG,IAAI;6BAkBP,UAAU,KAAG,IAAI;0BAKpB,SAAS,GAAG,SAAS,EAAE,GAAG,IAAI,KAAG,IAAI;qBAI1C,MAAM,GAAG,MAAM,EAAE,KAAG,IAAI;yBAUtB,IAAI;0BAWG,OAAO,CAAC,IAAI,CAAC;2BAqBnC,kBAAkB,eACd,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,KACrC,OAAO,CAAC,SAAS,CAAC;wBA6CM,MAAM,GAAG,IAAI,KAAG,IAAI;yBAKnB,MAAM,GAAG,IAAI,KAAG,IAAI;iBAK9B,IAAI;4VA4DtB,CAAC"}
@@ -4,9 +4,11 @@ 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";
11
+ import { languagesFromMetadata } from "../utils/langInfo.js";
10
12
  export const useMediaStore = defineStore("mapo-media", () => {
11
13
  const runtimeConfig = useRuntimeConfig();
12
14
  const mediaConfig = runtimeConfig.public.mapoMedia ?? {};
@@ -39,6 +41,8 @@ export const useMediaStore = defineStore("mapo-media", () => {
39
41
  const _currentSearch = ref("");
40
42
  const _currentAll = ref(false);
41
43
  const _currentLang = ref(void 0);
44
+ const languages = ref([]);
45
+ let languagesPromise = null;
42
46
  const parentFolder = computed(
43
47
  () => parentFolders.value[parentFolders.value.length - 1] ?? null
44
48
  );
@@ -64,6 +68,17 @@ export const useMediaStore = defineStore("mapo-media", () => {
64
68
  function folderCrud() {
65
69
  return useCrud(endpoints.folders);
66
70
  }
71
+ async function deriveLanguages() {
72
+ if (languagesPromise) return languagesPromise;
73
+ languagesPromise = (async () => {
74
+ try {
75
+ languages.value = languagesFromMetadata(await mediaCrud().options());
76
+ } catch {
77
+ languagesPromise = null;
78
+ }
79
+ })();
80
+ return languagesPromise;
81
+ }
67
82
  function applyParentFolder(pf) {
68
83
  if (!pf) {
69
84
  parentFolders.value = [];
@@ -130,7 +145,7 @@ export const useMediaStore = defineStore("mapo-media", () => {
130
145
  const payload = (a.buildMediaPatchPayload ?? defaultMediaAdapter.buildMediaPatchPayload)(media);
131
146
  const updated = await mediaCrud().partialUpdate(media.id, payload);
132
147
  if (editMedia.value?.id === media.id) editMedia.value = updated;
133
- useSnackStore().show("Media updated", "success");
148
+ useSnackStore().show(useMapoT()("mapo.mediaManager.fileInfo"), "success");
134
149
  await getRoot();
135
150
  return updated;
136
151
  }
@@ -156,10 +171,11 @@ export const useMediaStore = defineStore("mapo-media", () => {
156
171
  await getRoot();
157
172
  }
158
173
  async function deleteFolder(folder) {
174
+ const t = useMapoT();
159
175
  const confirmed = await useConfirmStore().ask({
160
- title: "Delete folder",
161
- message: `Delete folder "${folder.name}"? Media inside it will not be deleted.`,
162
- confirmText: "Delete",
176
+ title: t("mapo.mediaFolders.deleteTitle"),
177
+ message: t("mapo.mediaFolders.confirmDelete", { name: folder.name }),
178
+ confirmText: t("mapo.delete"),
163
179
  dangerous: true
164
180
  });
165
181
  if (!confirmed) return;
@@ -167,10 +183,13 @@ export const useMediaStore = defineStore("mapo-media", () => {
167
183
  await getRoot();
168
184
  }
169
185
  async function deleteMedia(media) {
186
+ const t = useMapoT();
170
187
  const confirmed = await useConfirmStore().ask({
171
- title: "Delete media",
172
- message: `Delete "${media.title || media.file}"?`,
173
- confirmText: "Delete",
188
+ title: t("mapo.mediaManager.deleteTitle"),
189
+ message: t("mapo.mediaEditor.confirmDelete", {
190
+ name: media.title || media.file
191
+ }),
192
+ confirmText: t("mapo.delete"),
174
193
  dangerous: true
175
194
  });
176
195
  if (!confirmed) return;
@@ -220,16 +239,20 @@ export const useMediaStore = defineStore("mapo-media", () => {
220
239
  async function deleteSelected() {
221
240
  const count = editList.value.length;
222
241
  if (count === 0) return;
242
+ const t = useMapoT();
223
243
  const confirmed = await useConfirmStore().ask({
224
- title: "Delete selected media",
225
- message: `Delete ${count} selected media?`,
226
- confirmText: `Delete ${count}`,
244
+ title: t("mapo.mediaGallery.deleteTitle"),
245
+ message: t("mapo.mediaGallery.deleteSelected", { number: count }),
246
+ confirmText: t("mapo.delete"),
227
247
  dangerous: true
228
248
  });
229
249
  if (!confirmed) return;
230
250
  await Promise.all(editList.value.map((id) => mediaCrud().delete(id)));
231
251
  editList.value = [];
232
- useSnackStore().show(`${count} media deleted`, "success");
252
+ useSnackStore().show(
253
+ t("mapo.mediaGallery.deleteSuccess", { number: count }),
254
+ "success"
255
+ );
233
256
  await getRoot();
234
257
  }
235
258
  async function uploadMedia(payload, onProgress) {
@@ -254,10 +277,17 @@ export const useMediaStore = defineStore("mapo-media", () => {
254
277
  resolve(xhr.response);
255
278
  } else {
256
279
  const detail = xhr.response?.detail;
257
- reject(new Error(detail || `Upload failed (${xhr.status})`));
280
+ reject(
281
+ new Error(
282
+ detail || `${useMapoT()("mapo.mediaUploader.uploadFailed")} (${xhr.status})`
283
+ )
284
+ );
258
285
  }
259
286
  });
260
- xhr.addEventListener("error", () => reject(new Error("Upload failed")));
287
+ xhr.addEventListener(
288
+ "error",
289
+ () => reject(new Error(useMapoT()("mapo.mediaUploader.uploadFailed")))
290
+ );
261
291
  xhr.send(formData);
262
292
  });
263
293
  }
@@ -299,12 +329,14 @@ export const useMediaStore = defineStore("mapo-media", () => {
299
329
  selection,
300
330
  editList,
301
331
  selectMode,
332
+ languages,
302
333
  // getters
303
334
  parentFolder,
304
335
  editListSet,
305
336
  editListState,
306
337
  // actions
307
338
  getRoot,
339
+ deriveLanguages,
308
340
  navigateToFolder,
309
341
  openEditor,
310
342
  closeEditor,
@@ -0,0 +1,167 @@
1
+ import type { Component, ComputedRef, Ref } from "vue";
2
+ import type { AnyFieldDescriptor, FieldAnnotations, FieldRegistry } from "@mapomodule/form/types";
3
+ import type { JSONSchema } from "@mapomodule/utils";
4
+ /**
5
+ * What `MapoDetail` shares with the components inside it: its slots, its forms
6
+ * and the extensions it renders. Read it with `useMapoDetail()`.
7
+ */
8
+ export interface MapoDetailContext<T extends object = Record<string, unknown>> {
9
+ /** The REST endpoint of the record. */
10
+ endpoint: ComputedRef<string>;
11
+ /** The record id; `"new"` for a record not created yet. */
12
+ id: ComputedRef<string | number>;
13
+ isNew: ComputedRef<boolean>;
14
+ /**
15
+ * The name of the record's model for people, as the page titles it
16
+ * (`modelName`): "Article"; `null` without one. `MapoDetail` always gives
17
+ * it; optional, so a context built elsewhere, as a test's, still compiles.
18
+ */
19
+ modelName?: ComputedRef<string | null>;
20
+ /**
21
+ * The backend model the page checks the permissions of (`permissionModel`):
22
+ * `article`; `undefined` without one. `MapoDetail` always gives it;
23
+ * optional, as `modelName`.
24
+ */
25
+ permissionModel?: ComputedRef<string | undefined>;
26
+ /** The record being edited: write to it to change the values of the form. */
27
+ model: Ref<T>;
28
+ /** The body fields rendered: the `fields` prop, or the ones derived from the schema. */
29
+ fields: ComputedRef<AnyFieldDescriptor<T>[]>;
30
+ /** The sidebar fields rendered. */
31
+ sidebarFields: ComputedRef<AnyFieldDescriptor<T>[]>;
32
+ /** The languages of the record; empty when it is not translated. */
33
+ languages: ComputedRef<string[]>;
34
+ /** The language being edited: write to it to switch. */
35
+ currentLang: Ref<string>;
36
+ /** The field registry the forms use. */
37
+ registry: ComputedRef<FieldRegistry>;
38
+ /** Server errors by field path, as the last save returned them. */
39
+ errors: Readonly<Ref<Record<string, string[]>>>;
40
+ /** Whether the record is read-only for this user. */
41
+ readonly: ComputedRef<boolean>;
42
+ /** While the record loads. */
43
+ isLoading: Readonly<Ref<boolean>>;
44
+ /** From a save until it is done; after `save(true)`, until the page has gone back. */
45
+ isSaving: ComputedRef<boolean>;
46
+ /** While a save, a delete or a navigation back is under way. */
47
+ isBusy: ComputedRef<boolean>;
48
+ /**
49
+ * Whether the model differs from the record as loaded or last saved; for
50
+ * a new record, whether it holds a value it did not hold when the page
51
+ * opened (a blank text, an empty list or an empty object is none).
52
+ */
53
+ isDirty: ComputedRef<boolean>;
54
+ /**
55
+ * Marks set from inside the detail, shown with those of the `annotations`
56
+ * prop; on the same path the prop wins. Replace the map to change them.
57
+ */
58
+ annotations: Ref<FieldAnnotations>;
59
+ /** Which extensions the page allows: all, none, or the listed keys. */
60
+ extensions: ComputedRef<boolean | readonly string[]>;
61
+ /** Saves the record, as the Save buttons do; ignored while busy. */
62
+ save: (andBack?: boolean) => Promise<void>;
63
+ /** Goes back, as the Back button does; ignored while busy. */
64
+ back: () => void;
65
+ /**
66
+ * The endpoint's `OPTIONS` response, requested once per page and shared
67
+ * with `MapoDetail`, or `undefined` when the endpoint has none.
68
+ */
69
+ metadata: () => Promise<Record<string, unknown> | undefined>;
70
+ /**
71
+ * How the page turns the `OPTIONS` response into a JSON Schema
72
+ * (`schemaFromMetadata`), when it has its own way; `undefined`: Mapo's
73
+ * `metadataToJsonSchema`. `MapoDetail` always gives it; optional, as
74
+ * `modelName`.
75
+ */
76
+ schemaFromMetadata?: ComputedRef<((metadata: Record<string, unknown>) => JSONSchema | undefined) | undefined>;
77
+ /**
78
+ * Calls `handler` after each save that succeeds, with the record as the
79
+ * backend returned it, before the page moves to a new record's address
80
+ * or goes back. Returns the function that removes it; one registered in
81
+ * a component's setup goes with the component. A handler that throws
82
+ * leaves the save done. `MapoDetail` always gives it; optional, as
83
+ * `modelName`.
84
+ */
85
+ onSaved?: (handler: (record: T) => void) => () => void;
86
+ /**
87
+ * The detail's draft, for a component that keeps a state of its own
88
+ * beside the record's values: it is saved, restored, discarded and
89
+ * cleared with them. With drafts off nothing is kept. `MapoDetail` always
90
+ * gives it; optional, as `modelName`.
91
+ */
92
+ draft?: MapoDetailDraft;
93
+ /**
94
+ * Takes the operator to a field: the form that holds it, the body's or
95
+ * the sidebar's, opens its tab, group or sub-tab and repeater item,
96
+ * scrolls the field into view and puts the focus on its control. The
97
+ * path is the one of its mark: `title`, `translations.it.title`,
98
+ * `blocks.0.title`. Resolves whether the control took the focus: `false`
99
+ * for a field no form has or shows. `MapoDetail` always gives it;
100
+ * optional, as `modelName`.
101
+ */
102
+ revealField?: (path: string) => Promise<boolean>;
103
+ }
104
+ /**
105
+ * A part of the detail's draft: the state of a component inside it, saved
106
+ * and restored with the record's values.
107
+ */
108
+ export interface MapoDetailDraftPart {
109
+ /**
110
+ * What to keep, as data `JSON.stringify()` can write; `undefined` when
111
+ * there is nothing. Called each time the draft is saved; a part that
112
+ * throws is left out of that save.
113
+ */
114
+ save: () => unknown;
115
+ /**
116
+ * Puts back what `save()` returned, when the operator restores the
117
+ * draft, after the record's values; `undefined` when the draft holds
118
+ * nothing for the part, which then starts again from nothing. It comes
119
+ * from the browser's storage: read it as outside data.
120
+ */
121
+ restore: (data: unknown) => void;
122
+ }
123
+ /** The draft of a `MapoDetail`, for the components inside it. */
124
+ export interface MapoDetailDraft {
125
+ /**
126
+ * Keeps a part of the draft under `key`, one per detail: registering the
127
+ * key again replaces the part. The draft is saved when the record changed
128
+ * or a part has something to keep. A part registered after the draft was
129
+ * restored gets its data then. Returns the function that removes it; one
130
+ * registered in a component's setup goes with the component.
131
+ */
132
+ part: (key: string, part: MapoDetailDraftPart) => () => void;
133
+ /**
134
+ * Saves the draft soon, after a change of a part's state: a change of
135
+ * the record's values saves it by itself.
136
+ */
137
+ touch: () => void;
138
+ }
139
+ /**
140
+ * Where `MapoDetail` renders an extension: `actions`, the sidebar card above
141
+ * Save; `body-top`, above the body form.
142
+ */
143
+ export type DetailExtensionPlacement = "actions" | "body-top";
144
+ /** A component that loads another: `() => import("./MyAction.vue")`. */
145
+ export type DetailExtensionLoader = () => Promise<Component | {
146
+ default: Component;
147
+ }>;
148
+ /** A component added to every `MapoDetail`, registered with `defineDetailExtension()`. */
149
+ export interface DetailExtension {
150
+ /**
151
+ * Names the extension. A page picks extensions by key with the `extensions`
152
+ * prop, and registering a key again replaces the extension.
153
+ */
154
+ key: string;
155
+ /** Where the detail renders it. */
156
+ placement: DetailExtensionPlacement;
157
+ /**
158
+ * The component, or a loader of it. It reads the detail with
159
+ * `useMapoDetail()`. A function is always taken as a loader.
160
+ */
161
+ component: Component | DetailExtensionLoader;
162
+ /** Whether a detail page shows it. Default: always. */
163
+ visible?: (detail: MapoDetailContext) => boolean;
164
+ /** Order among the extensions of a placement, lower first. Default: `0`. */
165
+ order?: number;
166
+ }
167
+ //# sourceMappingURL=detail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detail.d.ts","sourceRoot":"","sources":["../../../src/runtime/types/detail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AACvD,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3E,uCAAuC;IACvC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,2DAA2D;IAC3D,EAAE,EAAE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D,wEAAwE;AACxE,MAAM,MAAM,qBAAqB,GAAG,MAAM,OAAO,CAC/C,SAAS,GAAG;IAAE,OAAO,EAAE,SAAS,CAAA;CAAE,CACnC,CAAC;AAEF,0FAA0F;AAC1F,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,mCAAmC;IACnC,SAAS,EAAE,wBAAwB,CAAC;IACpC;;;OAGG;IACH,SAAS,EAAE,SAAS,GAAG,qBAAqB,CAAC;IAC7C,uDAAuD;IACvD,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,OAAO,CAAC;IACjD,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
File without changes
@@ -1,8 +1,16 @@
1
1
  /** Defines a single column in the list table. */
2
2
  export interface ListColumn<T = Record<string, unknown>> {
3
- /** Property name on the row object. Must be a key of `T`. */
4
- key: keyof T & string;
3
+ /**
4
+ * Property of the row to show, a key of `T`. A dotted path (`category.name`)
5
+ * reads a field of a related object; it starts with a key of `T`.
6
+ */
7
+ key: (keyof T & string) | `${keyof T & string}.${string}`;
5
8
  label: string;
9
+ /**
10
+ * Turns the header into a button that cycles ascending, descending and
11
+ * unsorted. The list sends the order to the backend as `ordering`, or sorts
12
+ * in memory in offline and hybrid mode.
13
+ */
6
14
  sortable?: boolean;
7
15
  /** CSS class applied to the `<td>` cell. */
8
16
  class?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/runtime/types/list.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACrD,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4CAA4C;IAC5C,KAAK,CAA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M,WAAW,aAAa,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxD,4EAA4E;IAC5E,SAAS,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;IACtB,cAAc,EAAE,eAAe,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qEAAqE;AACrE,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACrD,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,8EAA8E;IAC9E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kFAAkF;IAClF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wFAAwF;IACxF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -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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