@mapomodule/uikit 2.0.0-beta.4 → 2.0.0-beta.5
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 +33 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/module.d.mts +30 -1
- package/dist/module.d.ts +28 -0
- package/dist/module.d.ts.map +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +51 -2
- package/dist/runtime/adapters/defaultMediaAdapter.d.ts +14 -0
- package/dist/runtime/adapters/defaultMediaAdapter.d.ts.map +1 -0
- package/dist/runtime/adapters/defaultMediaAdapter.js +30 -0
- package/dist/runtime/components/MapoDropArea.vue +95 -0
- package/dist/runtime/components/MapoDropArea.vue.d.ts +33 -0
- package/dist/runtime/components/MapoDropArea.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaBreadcrumbs.vue +45 -0
- package/dist/runtime/components/MapoMediaBreadcrumbs.vue.d.ts +4 -0
- package/dist/runtime/components/MapoMediaBreadcrumbs.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaEditor.vue +310 -0
- package/dist/runtime/components/MapoMediaEditor.vue.d.ts +8 -0
- package/dist/runtime/components/MapoMediaEditor.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaFileChanger.vue +108 -0
- package/dist/runtime/components/MapoMediaFileChanger.vue.d.ts +15 -0
- package/dist/runtime/components/MapoMediaFileChanger.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaFolders.vue +198 -0
- package/dist/runtime/components/MapoMediaFolders.vue.d.ts +4 -0
- package/dist/runtime/components/MapoMediaFolders.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaGallery.vue +209 -0
- package/dist/runtime/components/MapoMediaGallery.vue.d.ts +4 -0
- package/dist/runtime/components/MapoMediaGallery.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaManager.vue +130 -0
- package/dist/runtime/components/MapoMediaManager.vue.d.ts +35 -0
- package/dist/runtime/components/MapoMediaManager.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaManagerDialog.vue +112 -0
- package/dist/runtime/components/MapoMediaManagerDialog.vue.d.ts +41 -0
- package/dist/runtime/components/MapoMediaManagerDialog.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaPreview.vue +92 -0
- package/dist/runtime/components/MapoMediaPreview.vue.d.ts +19 -0
- package/dist/runtime/components/MapoMediaPreview.vue.d.ts.map +1 -0
- package/dist/runtime/components/MapoMediaUploader.vue +266 -0
- package/dist/runtime/components/MapoMediaUploader.vue.d.ts +8 -0
- package/dist/runtime/components/MapoMediaUploader.vue.d.ts.map +1 -0
- package/dist/runtime/plugins/media-adapter.d.ts +18 -0
- package/dist/runtime/plugins/media-adapter.d.ts.map +1 -0
- package/dist/runtime/plugins/media-adapter.js +7 -0
- package/dist/runtime/stores/media.d.ts +462 -0
- package/dist/runtime/stores/media.d.ts.map +1 -0
- package/dist/runtime/stores/media.js +323 -0
- package/dist/runtime/types/media.d.ts +116 -0
- package/dist/runtime/types/media.d.ts.map +1 -0
- package/dist/runtime/types/media.js +0 -0
- package/dist/types.d.mts +1 -1
- package/package.json +7 -5
- package/src/index.ts +8 -0
- package/src/module.ts +103 -0
- package/src/runtime/adapters/defaultMediaAdapter.ts +57 -0
- package/src/runtime/components/MapoDropArea.vue +122 -0
- package/src/runtime/components/MapoMediaBreadcrumbs.vue +51 -0
- package/src/runtime/components/MapoMediaEditor.vue +340 -0
- package/src/runtime/components/MapoMediaFileChanger.vue +131 -0
- package/src/runtime/components/MapoMediaFolders.vue +217 -0
- package/src/runtime/components/MapoMediaGallery.vue +227 -0
- package/src/runtime/components/MapoMediaManager.vue +170 -0
- package/src/runtime/components/MapoMediaManagerDialog.vue +142 -0
- package/src/runtime/components/MapoMediaPreview.vue +111 -0
- package/src/runtime/components/MapoMediaUploader.vue +324 -0
- package/src/runtime/plugins/media-adapter.ts +29 -0
- package/src/runtime/stores/media.ts +435 -0
- package/src/runtime/types/media.ts +126 -0
package/README.md
CHANGED
|
@@ -69,6 +69,38 @@ When installed via `mapomodule`, configure under `mapo.uikit` instead.
|
|
|
69
69
|
| `MapoListTable` | Data table with server-side pagination, sort, selection, and whole-row drag reorder (drop-line feedback; auto-disabled while a search/sort is active). Pass `permissionModel` to gate edit/delete row actions. |
|
|
70
70
|
| `MapoListQuickEdit` | Quick-edit modal driven by the same `FieldDescriptor[]` as the detail form |
|
|
71
71
|
|
|
72
|
+
#### Media Manager
|
|
73
|
+
|
|
74
|
+
| Component | Description |
|
|
75
|
+
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
76
|
+
| `MapoDropArea` | Standalone drag-and-drop area (reusable outside media manager) |
|
|
77
|
+
| `MapoMediaPreview` | MIME-aware preview: `image` → `<img>`, `video` → `<video>`, other → file icon |
|
|
78
|
+
| `MapoMediaBreadcrumbs` | Folder navigation breadcrumb |
|
|
79
|
+
| `MapoMediaFolders` | Folder sidebar with MIME filters (image/video/audio/document) |
|
|
80
|
+
| `MapoMediaGallery` | Responsive CSS Grid gallery with bulk selection and pagination |
|
|
81
|
+
| `MapoMediaEditor` | Right-side drawer for editing media metadata (title, alt text, translations); shows linked models, open-in-new-tab, and gates Edit/Delete on the media model permissions |
|
|
82
|
+
| `MapoMediaFileChanger` | Replace an existing file while optionally preserving its URL |
|
|
83
|
+
| `MapoMediaUploader` | Upload queue with per-file progress, inline metadata (title/alt/description), and destination-folder selection |
|
|
84
|
+
| `MapoMediaManager` | Main orchestrator shell (sidebar + gallery + uploader + editor drawer) |
|
|
85
|
+
| `MapoMediaManagerDialog` | `UModal` wrapper for picker mode — single or multi selection with confirm |
|
|
86
|
+
|
|
87
|
+
**Form fields** — the `media`, `media-m2m`, and `enhanced-media` field types ship with [`@mapomodule/form`](../form/README.md) in its default registry; they drive the picker above and need this package installed to work.
|
|
88
|
+
|
|
89
|
+
Media config (endpoints + upload limits) goes under `mapo.uikit.media`; backend-specific request/response transforms are handled by a pluggable `$mapoMediaAdapter` (Camomilla ships its own). See [docs/uikit/media.md](../../../docs/uikit/media.md).
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
mapo: {
|
|
93
|
+
uikit: {
|
|
94
|
+
media: {
|
|
95
|
+
endpoints: { media: "/api/media", folders: "/api/media-folders" },
|
|
96
|
+
maxImageSize: 10, // MB
|
|
97
|
+
maxVideoSize: 100, // MB
|
|
98
|
+
permissionsModel: "media", // Django model for editor change/delete checks
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
```
|
|
103
|
+
|
|
72
104
|
#### Detail shell
|
|
73
105
|
|
|
74
106
|
| Component | Description |
|
|
@@ -140,7 +172,7 @@ app/
|
|
|
140
172
|
|
|
141
173
|
The `@mapomodule/uikit` module hooks into Nuxt's `components:extend` and swaps the `filePath` — no imports, no registration needed. Keep props and slots compatible with the original.
|
|
142
174
|
|
|
143
|
-
Overridable components: `MapoTopbar`, `MapoSidebar`, `MapoSidebarList`, `MapoSidebarListItem`, `MapoSidebarProfile`, `MapoLogin`, `MapoLogoutButton`, `MapoThemeToggle`, `MapoSnackBar`, `MapoConfirmDialog`, `MapoRootComponents`, `MapoDetail`, `MapoDetailLangSwitch`, `MapoList`, `MapoListTable`, `MapoListFilters`, `MapoListActions`, `MapoListHead`, `MapoListQuickEdit`.
|
|
175
|
+
Overridable components: `MapoTopbar`, `MapoSidebar`, `MapoSidebarList`, `MapoSidebarListItem`, `MapoSidebarProfile`, `MapoLogin`, `MapoLogoutButton`, `MapoThemeToggle`, `MapoSnackBar`, `MapoConfirmDialog`, `MapoRootComponents`, `MapoDetail`, `MapoDetailLangSwitch`, `MapoList`, `MapoListTable`, `MapoListFilters`, `MapoListActions`, `MapoListHead`, `MapoListQuickEdit`, `MapoMediaManager`, `MapoMediaManagerDialog`, `MapoMediaGallery`, `MapoMediaEditor`, `MapoMediaUploader`, `MapoMediaFolders`.
|
|
144
176
|
|
|
145
177
|
## Dev workflow
|
|
146
178
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { MapoUikitOptions } from './module.mjs';
|
|
2
2
|
export { ActionContext, ActionDescriptor, ActiveFilter, FilterChoice, FilterDescriptor, ListColumn, ListTabItem } from '../dist/runtime/types/list.js';
|
|
3
|
+
export { MediaApiResponse, MediaFolder, MediaGetRootParams, MediaItem, MediaUploadPayload, SelectMode } from '../dist/runtime/types/media.js';
|
|
3
4
|
import '@nuxt/schema';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export type { MapoUikitOptions } from "./module";
|
|
2
2
|
export type { ListColumn, FilterChoice, FilterDescriptor, ActiveFilter, ActionContext, ActionDescriptor, ListTabItem, } from "./runtime/types/list.js";
|
|
3
|
+
export type { MediaItem, MediaFolder, MediaApiResponse, MediaGetRootParams, MediaUploadPayload, SelectMode, } from "./runtime/types/media.js";
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,YAAY,EACV,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,WAAW,GACZ,MAAM,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,YAAY,EACV,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,WAAW,GACZ,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,GACX,MAAM,0BAA0B,CAAC"}
|
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NuxtModule } from '@nuxt/schema';
|
|
2
2
|
import '../dist/runtime/types/list.js';
|
|
3
|
+
import '../dist/runtime/types/media.js';
|
|
3
4
|
|
|
4
5
|
interface MapoUikitOptions {
|
|
5
6
|
/**
|
|
@@ -23,8 +24,36 @@ interface MapoUikitOptions {
|
|
|
23
24
|
* @see https://ui.nuxt.com/getting-started/theme
|
|
24
25
|
*/
|
|
25
26
|
ui?: Record<string, unknown>;
|
|
27
|
+
/**
|
|
28
|
+
* Media Manager configuration. Endpoints and upload limits are
|
|
29
|
+
* forwarded to `runtimeConfig.public.mapoMedia` and read by `useMediaStore`.
|
|
30
|
+
*/
|
|
31
|
+
media?: MapoMediaOptions;
|
|
32
|
+
}
|
|
33
|
+
interface MapoMediaOptions {
|
|
34
|
+
/**
|
|
35
|
+
* REST endpoints used by the media store.
|
|
36
|
+
* Defaults align with the Camomilla integration path-rewrites.
|
|
37
|
+
*/
|
|
38
|
+
endpoints?: {
|
|
39
|
+
/** Single-media CRUD (detail, update, delete, upload). Default `/api/media`. */
|
|
40
|
+
media?: string;
|
|
41
|
+
/** Folder navigation + CRUD. Default `/api/media-folders`. */
|
|
42
|
+
folders?: string;
|
|
43
|
+
};
|
|
44
|
+
/** Max image upload size in MB. Default 10. */
|
|
45
|
+
maxImageSize?: number;
|
|
46
|
+
/** Max video upload size in MB. Default 100. */
|
|
47
|
+
maxVideoSize?: number;
|
|
48
|
+
/** Max size for any other file type in MB. Default 10. */
|
|
49
|
+
maxDefaultSize?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Django model used for media permission checks (`change_<model>`,
|
|
52
|
+
* `delete_<model>`) in the editor. Default `"media"`.
|
|
53
|
+
*/
|
|
54
|
+
permissionsModel?: string;
|
|
26
55
|
}
|
|
27
56
|
declare const _default: NuxtModule<MapoUikitOptions, MapoUikitOptions, false>;
|
|
28
57
|
|
|
29
58
|
export { _default as default };
|
|
30
|
-
export type { MapoUikitOptions };
|
|
59
|
+
export type { MapoMediaOptions, MapoUikitOptions };
|
package/dist/module.d.ts
CHANGED
|
@@ -21,6 +21,34 @@ export interface MapoUikitOptions {
|
|
|
21
21
|
* @see https://ui.nuxt.com/getting-started/theme
|
|
22
22
|
*/
|
|
23
23
|
ui?: Record<string, unknown>;
|
|
24
|
+
/**
|
|
25
|
+
* Media Manager configuration. Endpoints and upload limits are
|
|
26
|
+
* forwarded to `runtimeConfig.public.mapoMedia` and read by `useMediaStore`.
|
|
27
|
+
*/
|
|
28
|
+
media?: MapoMediaOptions;
|
|
29
|
+
}
|
|
30
|
+
export interface MapoMediaOptions {
|
|
31
|
+
/**
|
|
32
|
+
* REST endpoints used by the media store.
|
|
33
|
+
* Defaults align with the Camomilla integration path-rewrites.
|
|
34
|
+
*/
|
|
35
|
+
endpoints?: {
|
|
36
|
+
/** Single-media CRUD (detail, update, delete, upload). Default `/api/media`. */
|
|
37
|
+
media?: string;
|
|
38
|
+
/** Folder navigation + CRUD. Default `/api/media-folders`. */
|
|
39
|
+
folders?: string;
|
|
40
|
+
};
|
|
41
|
+
/** Max image upload size in MB. Default 10. */
|
|
42
|
+
maxImageSize?: number;
|
|
43
|
+
/** Max video upload size in MB. Default 100. */
|
|
44
|
+
maxVideoSize?: number;
|
|
45
|
+
/** Max size for any other file type in MB. Default 10. */
|
|
46
|
+
maxDefaultSize?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Django model used for media permission checks (`change_<model>`,
|
|
49
|
+
* `delete_<model>`) in the editor. Default `"media"`.
|
|
50
|
+
*/
|
|
51
|
+
permissionsModel?: string;
|
|
24
52
|
}
|
|
25
53
|
declare const _default: NuxtModule<MapoUikitOptions, MapoUikitOptions, false>;
|
|
26
54
|
export default _default;
|
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE7B;;;OAGG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,SAAS,CAAC,EAAE;QACV,gFAAgF;QAChF,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,8DAA8D;QAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;;AAaD,wBAqN0C"}
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { readFileSync, existsSync } from 'node:fs';
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
|
-
import { defineNuxtModule, createResolver, addTypeTemplate, addComponent, addLayout, extendPages } from '@nuxt/kit';
|
|
3
|
+
import { defineNuxtModule, createResolver, addTypeTemplate, addComponent, addLayout, addPlugin, addImports, extendPages } from '@nuxt/kit';
|
|
4
4
|
|
|
5
|
+
const MAPO_MEDIA_DEFAULTS = {
|
|
6
|
+
endpoints: {
|
|
7
|
+
media: "/api/media",
|
|
8
|
+
folders: "/api/media-folders"
|
|
9
|
+
},
|
|
10
|
+
maxImageSize: 10,
|
|
11
|
+
maxVideoSize: 100,
|
|
12
|
+
maxDefaultSize: 10,
|
|
13
|
+
permissionsModel: "media"
|
|
14
|
+
};
|
|
5
15
|
const module$1 = defineNuxtModule({
|
|
6
16
|
meta: {
|
|
7
17
|
name: "@mapomodule/uikit",
|
|
@@ -41,7 +51,19 @@ const module$1 = defineNuxtModule({
|
|
|
41
51
|
if (options.ui && Object.keys(options.ui).length) {
|
|
42
52
|
nuxt.options.ui = { ...options.ui, ...nuxt.options.ui ?? {} };
|
|
43
53
|
}
|
|
54
|
+
const media = options.media ?? {};
|
|
55
|
+
nuxt.options.runtimeConfig.public.mapoMedia = {
|
|
56
|
+
endpoints: {
|
|
57
|
+
media: media.endpoints?.media ?? MAPO_MEDIA_DEFAULTS.endpoints.media,
|
|
58
|
+
folders: media.endpoints?.folders ?? MAPO_MEDIA_DEFAULTS.endpoints.folders
|
|
59
|
+
},
|
|
60
|
+
maxImageSize: media.maxImageSize ?? MAPO_MEDIA_DEFAULTS.maxImageSize,
|
|
61
|
+
maxVideoSize: media.maxVideoSize ?? MAPO_MEDIA_DEFAULTS.maxVideoSize,
|
|
62
|
+
maxDefaultSize: media.maxDefaultSize ?? MAPO_MEDIA_DEFAULTS.maxDefaultSize,
|
|
63
|
+
permissionsModel: media.permissionsModel ?? MAPO_MEDIA_DEFAULTS.permissionsModel
|
|
64
|
+
};
|
|
44
65
|
const components = [
|
|
66
|
+
// ─── Shell / Layout ───────────────────────────────────────────────────
|
|
45
67
|
"MapoSnackBar",
|
|
46
68
|
"MapoConfirmDialog",
|
|
47
69
|
"MapoLogin",
|
|
@@ -52,6 +74,7 @@ const module$1 = defineNuxtModule({
|
|
|
52
74
|
"MapoLogoutButton",
|
|
53
75
|
"MapoSidebarProfile",
|
|
54
76
|
"MapoTopbar",
|
|
77
|
+
// ─── CRUD / Detail / List ─────────────────────────────────────────────
|
|
55
78
|
"MapoDetail",
|
|
56
79
|
"MapoDetailLangSwitch",
|
|
57
80
|
"MapoList",
|
|
@@ -60,7 +83,16 @@ const module$1 = defineNuxtModule({
|
|
|
60
83
|
"MapoListFilters",
|
|
61
84
|
"MapoListActions",
|
|
62
85
|
"MapoListQuickEdit",
|
|
63
|
-
"MapoListTable"
|
|
86
|
+
"MapoListTable",
|
|
87
|
+
// ─── Media ───────────────────────────────────────────────────────────
|
|
88
|
+
"MapoDropArea",
|
|
89
|
+
"MapoMediaBreadcrumbs",
|
|
90
|
+
"MapoMediaFolders",
|
|
91
|
+
"MapoMediaGallery",
|
|
92
|
+
"MapoMediaFileChanger",
|
|
93
|
+
"MapoMediaEditor",
|
|
94
|
+
"MapoMediaUploader",
|
|
95
|
+
"MapoMediaManager"
|
|
64
96
|
];
|
|
65
97
|
for (const name of components) {
|
|
66
98
|
addComponent({
|
|
@@ -68,6 +100,13 @@ const module$1 = defineNuxtModule({
|
|
|
68
100
|
filePath: resolver.resolve(`./runtime/components/${name}.vue`)
|
|
69
101
|
});
|
|
70
102
|
}
|
|
103
|
+
for (const name of ["MapoMediaManagerDialog", "MapoMediaPreview"]) {
|
|
104
|
+
addComponent({
|
|
105
|
+
name,
|
|
106
|
+
global: true,
|
|
107
|
+
filePath: resolver.resolve(`./runtime/components/${name}.vue`)
|
|
108
|
+
});
|
|
109
|
+
}
|
|
71
110
|
addLayout(
|
|
72
111
|
{ src: resolver.resolve("./runtime/layouts/default.vue") },
|
|
73
112
|
"mapo-default"
|
|
@@ -85,6 +124,16 @@ const module$1 = defineNuxtModule({
|
|
|
85
124
|
/* @__PURE__ */ new Set([...existing, "lucide"])
|
|
86
125
|
);
|
|
87
126
|
});
|
|
127
|
+
addPlugin({
|
|
128
|
+
src: resolver.resolve("./runtime/plugins/media-adapter"),
|
|
129
|
+
order: 5
|
|
130
|
+
});
|
|
131
|
+
addImports([
|
|
132
|
+
{
|
|
133
|
+
name: "useMediaStore",
|
|
134
|
+
from: resolver.resolve("./runtime/stores/media")
|
|
135
|
+
}
|
|
136
|
+
]);
|
|
88
137
|
nuxt.hook("components:extend", (components2) => {
|
|
89
138
|
const overrideDir = resolve(nuxt.options.srcDir, "mapooverride");
|
|
90
139
|
if (!existsSync(overrideDir)) return;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MediaAdapter } from "../types/media.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default media adapter — plain REST semantics.
|
|
4
|
+
*
|
|
5
|
+
* - List/detail params: passes `page`, `search`, `all`, and `mime` as-is.
|
|
6
|
+
* - Response: assumes the backend already returns the canonical
|
|
7
|
+
* `{ media: { items, paginator }, folders, parent_folder }` shape.
|
|
8
|
+
* - Detail params: passes `language_code` when a language is active.
|
|
9
|
+
*
|
|
10
|
+
* Integrations override any subset of these via their own `$mapoMediaAdapter`
|
|
11
|
+
* plugin (see `@mapomodule/mapo-integrations-camomilla`).
|
|
12
|
+
*/
|
|
13
|
+
export declare const defaultMediaAdapter: Required<MediaAdapter>;
|
|
14
|
+
//# sourceMappingURL=defaultMediaAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultMediaAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtime/adapters/defaultMediaAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAKb,MAAM,mBAAmB,CAAC;AAE3B;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,YAAY,CAqCtD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const defaultMediaAdapter = {
|
|
2
|
+
buildListParams(ctx) {
|
|
3
|
+
const params = {};
|
|
4
|
+
if (ctx.page != null) params.page = ctx.page;
|
|
5
|
+
if (ctx.search) params.search = ctx.search;
|
|
6
|
+
if (ctx.all) params.all = true;
|
|
7
|
+
if (ctx.mime) params.mime = ctx.mime;
|
|
8
|
+
return params;
|
|
9
|
+
},
|
|
10
|
+
parseRootResponse(raw) {
|
|
11
|
+
return raw;
|
|
12
|
+
},
|
|
13
|
+
buildDetailParams(ctx) {
|
|
14
|
+
return ctx.lang ? { language_code: ctx.lang } : {};
|
|
15
|
+
},
|
|
16
|
+
buildFolderPayload(folder) {
|
|
17
|
+
return { ...folder };
|
|
18
|
+
},
|
|
19
|
+
buildMediaPatchPayload(media) {
|
|
20
|
+
return {
|
|
21
|
+
title: media.title,
|
|
22
|
+
alt_text: media.alt_text,
|
|
23
|
+
description: media.description,
|
|
24
|
+
translations: media.translations
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
buildReplaceFilePayload(file, maintainUrl) {
|
|
28
|
+
return { file, maintain_url: maintainUrl };
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref } from "vue";
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
accept: { type: String, required: false, default: "*/*" },
|
|
5
|
+
multiple: { type: Boolean, required: false, default: true },
|
|
6
|
+
disabled: { type: Boolean, required: false, default: false }
|
|
7
|
+
});
|
|
8
|
+
const emit = defineEmits(["files"]);
|
|
9
|
+
const isDragging = ref(false);
|
|
10
|
+
const fileInput = ref(null);
|
|
11
|
+
let dragCounter = 0;
|
|
12
|
+
function onDragEnter(e) {
|
|
13
|
+
if (props.disabled) return;
|
|
14
|
+
e.preventDefault();
|
|
15
|
+
dragCounter++;
|
|
16
|
+
isDragging.value = true;
|
|
17
|
+
}
|
|
18
|
+
function onDragLeave() {
|
|
19
|
+
dragCounter--;
|
|
20
|
+
if (dragCounter <= 0) {
|
|
21
|
+
dragCounter = 0;
|
|
22
|
+
isDragging.value = false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function onDrop(e) {
|
|
26
|
+
if (props.disabled) return;
|
|
27
|
+
isDragging.value = false;
|
|
28
|
+
dragCounter = 0;
|
|
29
|
+
const files = filterFiles(Array.from(e.dataTransfer?.files ?? []));
|
|
30
|
+
if (files.length) emit("files", files);
|
|
31
|
+
}
|
|
32
|
+
function onFileInput(e) {
|
|
33
|
+
const input = e.target;
|
|
34
|
+
const files = filterFiles(Array.from(input.files ?? []));
|
|
35
|
+
if (files.length) emit("files", files);
|
|
36
|
+
input.value = "";
|
|
37
|
+
}
|
|
38
|
+
function triggerPick() {
|
|
39
|
+
if (!props.disabled) fileInput.value?.click();
|
|
40
|
+
}
|
|
41
|
+
function filterFiles(files) {
|
|
42
|
+
if (!props.accept || props.accept === "*/*") return files;
|
|
43
|
+
return files.filter((f) => matchesMime(f.type, props.accept));
|
|
44
|
+
}
|
|
45
|
+
function matchesMime(mime, accept) {
|
|
46
|
+
return accept.split(",").some((pattern) => {
|
|
47
|
+
const p = pattern.trim();
|
|
48
|
+
if (p === "*/*") return true;
|
|
49
|
+
if (p.endsWith("/*")) return mime.startsWith(p.replace("/*", "/"));
|
|
50
|
+
return mime === p;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
defineExpose({ triggerPick });
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<template>
|
|
57
|
+
<div
|
|
58
|
+
class="mapo-drop-area relative"
|
|
59
|
+
:class="{
|
|
60
|
+
'mapo-drop-area--dragging': isDragging,
|
|
61
|
+
'opacity-50 pointer-events-none': disabled
|
|
62
|
+
}"
|
|
63
|
+
@dragenter.prevent="onDragEnter"
|
|
64
|
+
@dragover.prevent
|
|
65
|
+
@dragleave="onDragLeave"
|
|
66
|
+
@drop.prevent="onDrop"
|
|
67
|
+
>
|
|
68
|
+
<input
|
|
69
|
+
ref="fileInput"
|
|
70
|
+
type="file"
|
|
71
|
+
class="sr-only"
|
|
72
|
+
:accept="accept"
|
|
73
|
+
:multiple="multiple"
|
|
74
|
+
@change="onFileInput"
|
|
75
|
+
/>
|
|
76
|
+
|
|
77
|
+
<slot :trigger-pick="triggerPick" :is-dragging="isDragging" />
|
|
78
|
+
|
|
79
|
+
<Transition name="drop-overlay">
|
|
80
|
+
<div
|
|
81
|
+
v-if="isDragging"
|
|
82
|
+
class="pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-lg border-2 border-dashed border-primary bg-default/80"
|
|
83
|
+
>
|
|
84
|
+
<div class="flex flex-col items-center gap-2 text-primary">
|
|
85
|
+
<UIcon name="i-lucide-upload-cloud" class="size-10" />
|
|
86
|
+
<span class="text-sm font-medium">Drop here</span>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</Transition>
|
|
90
|
+
</div>
|
|
91
|
+
</template>
|
|
92
|
+
|
|
93
|
+
<style scoped>
|
|
94
|
+
.drop-overlay-enter-active,.drop-overlay-leave-active{transition:opacity .15s ease}.drop-overlay-enter-from,.drop-overlay-leave-to{opacity:0}
|
|
95
|
+
</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
accept?: string;
|
|
3
|
+
multiple?: boolean;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare function triggerPick(): void;
|
|
7
|
+
declare var __VLS_1: {
|
|
8
|
+
triggerPick: typeof triggerPick;
|
|
9
|
+
isDragging: boolean;
|
|
10
|
+
};
|
|
11
|
+
type __VLS_Slots = {} & {
|
|
12
|
+
default?: (props: typeof __VLS_1) => any;
|
|
13
|
+
};
|
|
14
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
15
|
+
triggerPick: typeof triggerPick;
|
|
16
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
17
|
+
files: (files: File[]) => any;
|
|
18
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
19
|
+
onFiles?: ((files: File[]) => any) | undefined;
|
|
20
|
+
}>, {
|
|
21
|
+
accept: string;
|
|
22
|
+
multiple: boolean;
|
|
23
|
+
disabled: boolean;
|
|
24
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
25
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
26
|
+
declare const _default: typeof __VLS_export;
|
|
27
|
+
export default _default;
|
|
28
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
29
|
+
new (): {
|
|
30
|
+
$slots: S;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=MapoDropArea.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapoDropArea.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoDropArea.vue"],"names":[],"mappings":"AA+HA,KAAK,WAAW,GAAG;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAiDJ,iBAAS,WAAW,SAEnB;AA4ID,QAAA,IAAI,OAAO;;;CAAW,CAAE;AACxB,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,CAAC;AAO/C,QAAA,MAAM,UAAU;;;;;;;YA3MH,MAAM;cACJ,OAAO;cACP,OAAO;6EA8MpB,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AAWzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { useMediaStore } from "../stores/media.js";
|
|
4
|
+
const store = useMediaStore();
|
|
5
|
+
const items = computed(() => [
|
|
6
|
+
{
|
|
7
|
+
label: "Media",
|
|
8
|
+
icon: "i-lucide-folder-open",
|
|
9
|
+
folder: null
|
|
10
|
+
},
|
|
11
|
+
...store.parentFolders.map((f) => ({
|
|
12
|
+
label: f.name,
|
|
13
|
+
icon: "i-lucide-folder",
|
|
14
|
+
folder: f
|
|
15
|
+
}))
|
|
16
|
+
]);
|
|
17
|
+
function navigate(folder) {
|
|
18
|
+
store.navigateToFolder(folder);
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<nav class="flex items-center gap-1 overflow-x-auto py-1 text-sm">
|
|
24
|
+
<template v-for="(item, i) in items" :key="i">
|
|
25
|
+
<UButton
|
|
26
|
+
variant="ghost"
|
|
27
|
+
color="neutral"
|
|
28
|
+
size="xs"
|
|
29
|
+
:icon="item.icon"
|
|
30
|
+
:disabled="i === items.length - 1"
|
|
31
|
+
:class="
|
|
32
|
+
i === items.length - 1 ? 'font-semibold text-highlighted' : 'text-muted hover:text-highlighted'
|
|
33
|
+
"
|
|
34
|
+
@click="navigate(item.folder)"
|
|
35
|
+
>
|
|
36
|
+
{{ item.label }}
|
|
37
|
+
</UButton>
|
|
38
|
+
<UIcon
|
|
39
|
+
v-if="i < items.length - 1"
|
|
40
|
+
name="i-lucide-chevron-right"
|
|
41
|
+
class="size-3 shrink-0 text-dimmed"
|
|
42
|
+
/>
|
|
43
|
+
</template>
|
|
44
|
+
</nav>
|
|
45
|
+
</template>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
4
|
+
//# sourceMappingURL=MapoMediaBreadcrumbs.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapoMediaBreadcrumbs.vue.d.ts","sourceRoot":"","sources":["../../../src/runtime/components/MapoMediaBreadcrumbs.vue"],"names":[],"mappings":"AA8KA,QAAA,MAAM,YAAY,+QAChB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|