@brftech/filex-core 0.1.56 → 0.1.61
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/LICENSE +21 -21
- package/README.md +108 -108
- package/dist/{ArchiveViewer-CJdaw5x3.js → ArchiveViewer-CbUUEREI.js} +20 -20
- package/dist/ArchiveViewer-CbUUEREI.js.map +1 -0
- package/dist/{CsvViewer-QYx_tePQ.js → CsvViewer-72rDsQJX.js} +3 -3
- package/dist/CsvViewer-72rDsQJX.js.map +1 -0
- package/dist/{DrawioViewer-GWt0TyB7.js → DrawioViewer-DSyMwGvg.js} +7 -7
- package/dist/DrawioViewer-DSyMwGvg.js.map +1 -0
- package/dist/{EpubViewer-Je0ywklQ.js → EpubViewer-DvDa17d7.js} +3 -3
- package/dist/EpubViewer-DvDa17d7.js.map +1 -0
- package/dist/{IpynbViewer-TsB4gqP-.js → IpynbViewer-DibIkdsz.js} +3 -3
- package/dist/IpynbViewer-DibIkdsz.js.map +1 -0
- package/dist/{MermaidViewer-CXfeDS-7.js → MermaidViewer-BoFLtGvl.js} +3 -3
- package/dist/MermaidViewer-BoFLtGvl.js.map +1 -0
- package/dist/{PsdViewer-VtPpxKVe.js → PsdViewer-K2iZkwax.js} +3 -3
- package/dist/PsdViewer-K2iZkwax.js.map +1 -0
- package/dist/{TiffViewer-OINn9bbb.js → TiffViewer-JzDzbqpO.js} +3 -3
- package/dist/TiffViewer-JzDzbqpO.js.map +1 -0
- package/dist/{Viewer3D-xvvyiWHd.js → Viewer3D-WEMYCP8l.js} +7 -7
- package/dist/Viewer3D-WEMYCP8l.js.map +1 -0
- package/dist/filex-core.js +1 -1
- package/dist/filex-core.umd.cjs +4 -4
- package/dist/filex-core.umd.cjs.map +1 -1
- package/dist/{index-CmSYzt6L.js → index-B5YT-m5Q.js} +209 -209
- package/dist/index-B5YT-m5Q.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/useViewerFetch-czqbd2Lj.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Breadcrumb.vue +282 -282
- package/src/components/ContextMenu.vue +152 -152
- package/src/components/GridView.vue +166 -166
- package/src/components/ListView.vue +212 -212
- package/src/components/PendingOpsTray.vue +91 -91
- package/src/components/RecentlyOpened.vue +155 -155
- package/src/components/StarButton.vue +101 -101
- package/src/components/TagPicker.vue +184 -184
- package/src/components/Toolbar.vue +220 -220
- package/src/components/UploadProgress.vue +78 -78
- package/src/composables/useFileApi.ts +692 -692
- package/src/composables/useKeyboardShortcuts.ts +144 -144
- package/src/composables/useLocale.ts +60 -60
- package/src/composables/useMonacoLoader.ts +98 -98
- package/src/composables/usePendingOps.ts +200 -200
- package/src/composables/useSelection.ts +81 -81
- package/src/composables/useUploadChunked.ts +250 -250
- package/src/composables/useViewerFetch.ts +58 -58
- package/src/index.ts +80 -80
- package/src/locales/en.ts +122 -122
- package/src/locales/index.ts +12 -12
- package/src/locales/tr.ts +122 -122
- package/src/modals/DeleteConfirmModal.vue +32 -32
- package/src/modals/Modal.vue +104 -104
- package/src/modals/NewFolderModal.vue +64 -64
- package/src/modals/PermissionsModal.vue +815 -815
- package/src/modals/PreviewModal.vue +1070 -1070
- package/src/modals/RenameModal.vue +58 -58
- package/src/modals/ShareModal.vue +135 -135
- package/src/styles/base.css +1224 -1224
- package/src/styles/variables.css +90 -90
- package/src/types/FileNode.ts +136 -136
- package/src/types/index.ts +27 -27
- package/src/types/peers.d.ts +45 -45
- package/src/viewers/ArchiveViewer.vue +186 -186
- package/src/viewers/CsvViewer.vue +319 -319
- package/src/viewers/DrawioViewer.vue +243 -243
- package/src/viewers/EpubViewer.vue +307 -307
- package/src/viewers/IpynbViewer.vue +365 -365
- package/src/viewers/MermaidViewer.vue +259 -259
- package/src/viewers/PdfViewer.vue +562 -562
- package/src/viewers/PsdViewer.vue +264 -264
- package/src/viewers/TiffViewer.vue +273 -273
- package/src/viewers/Viewer3D.vue +120 -120
- package/dist/ArchiveViewer-CJdaw5x3.js.map +0 -1
- package/dist/CsvViewer-QYx_tePQ.js.map +0 -1
- package/dist/DrawioViewer-GWt0TyB7.js.map +0 -1
- package/dist/EpubViewer-Je0ywklQ.js.map +0 -1
- package/dist/IpynbViewer-TsB4gqP-.js.map +0 -1
- package/dist/MermaidViewer-CXfeDS-7.js.map +0 -1
- package/dist/PsdViewer-VtPpxKVe.js.map +0 -1
- package/dist/TiffViewer-OINn9bbb.js.map +0 -1
- package/dist/Viewer3D-xvvyiWHd.js.map +0 -1
- package/dist/index-CmSYzt6L.js.map +0 -1
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* RecentlyOpened — drop-down/sidebar tray of the user's recently-opened
|
|
4
|
-
* files. Backed by `GET /api/files/manager/recent?limit=20`.
|
|
5
|
-
*/
|
|
6
|
-
import { ref, onMounted, watch } from 'vue';
|
|
7
|
-
|
|
8
|
-
interface RecentNode {
|
|
9
|
-
id: number;
|
|
10
|
-
storage_id: number;
|
|
11
|
-
path: string;
|
|
12
|
-
name: string;
|
|
13
|
-
mime?: string;
|
|
14
|
-
last_opened?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const props = defineProps<{
|
|
18
|
-
apiBase?: string;
|
|
19
|
-
authHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
|
|
20
|
-
limit?: number;
|
|
21
|
-
/** Optional refresh trigger — incrementing this re-fetches. */
|
|
22
|
-
refreshKey?: number | string;
|
|
23
|
-
}>();
|
|
24
|
-
|
|
25
|
-
const emit = defineEmits<{
|
|
26
|
-
(e: 'open', node: RecentNode): void;
|
|
27
|
-
(e: 'error', message: string): void;
|
|
28
|
-
}>();
|
|
29
|
-
|
|
30
|
-
const items = ref<RecentNode[]>([]);
|
|
31
|
-
const loading = ref(false);
|
|
32
|
-
|
|
33
|
-
async function load() {
|
|
34
|
-
loading.value = true;
|
|
35
|
-
try {
|
|
36
|
-
const headers = await (props.authHeaders ?? (() => ({})))();
|
|
37
|
-
const base = props.apiBase ?? '';
|
|
38
|
-
const limit = props.limit ?? 20;
|
|
39
|
-
const res = await fetch(`${base}/api/files/manager/recent?limit=${limit}`, {
|
|
40
|
-
headers,
|
|
41
|
-
credentials: 'include',
|
|
42
|
-
});
|
|
43
|
-
if (res.ok) {
|
|
44
|
-
const body = await res.json();
|
|
45
|
-
items.value = Array.isArray(body.entries) ? body.entries : (Array.isArray(body) ? body : []);
|
|
46
|
-
}
|
|
47
|
-
} catch (err) {
|
|
48
|
-
emit('error', err instanceof Error ? err.message : String(err));
|
|
49
|
-
} finally {
|
|
50
|
-
loading.value = false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function fmtTime(s?: string): string {
|
|
55
|
-
if (!s) return '';
|
|
56
|
-
const t = new Date(s).getTime();
|
|
57
|
-
if (Number.isNaN(t)) return '';
|
|
58
|
-
const diff = Date.now() - t;
|
|
59
|
-
if (diff < 60_000) return 'just now';
|
|
60
|
-
if (diff < 3_600_000) return `${Math.floor(diff / 60_000)}m ago`;
|
|
61
|
-
if (diff < 86_400_000) return `${Math.floor(diff / 3_600_000)}h ago`;
|
|
62
|
-
return `${Math.floor(diff / 86_400_000)}d ago`;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
onMounted(load);
|
|
66
|
-
watch(() => props.refreshKey, load);
|
|
67
|
-
</script>
|
|
68
|
-
|
|
69
|
-
<template>
|
|
70
|
-
<div class="filex-recent">
|
|
71
|
-
<header>
|
|
72
|
-
<h3>Recently opened</h3>
|
|
73
|
-
<button class="filex-recent-refresh" type="button" @click="load" :disabled="loading">
|
|
74
|
-
↻
|
|
75
|
-
</button>
|
|
76
|
-
</header>
|
|
77
|
-
|
|
78
|
-
<ul v-if="items.length">
|
|
79
|
-
<li v-for="n in items" :key="n.id">
|
|
80
|
-
<button type="button" @click="emit('open', n)" class="filex-recent-item">
|
|
81
|
-
<span class="filex-recent-name">{{ n.name }}</span>
|
|
82
|
-
<span class="filex-recent-meta">{{ fmtTime(n.last_opened) }}</span>
|
|
83
|
-
</button>
|
|
84
|
-
</li>
|
|
85
|
-
</ul>
|
|
86
|
-
<p v-else-if="!loading" class="filex-recent-empty">Nothing here yet.</p>
|
|
87
|
-
<p v-else class="filex-recent-empty">Loading…</p>
|
|
88
|
-
</div>
|
|
89
|
-
</template>
|
|
90
|
-
|
|
91
|
-
<style scoped>
|
|
92
|
-
.filex-recent {
|
|
93
|
-
background: var(--fe-bg-elev, var(--filex-bg-card, #ffffff));
|
|
94
|
-
border: 1px solid var(--fe-border, var(--filex-border, #e5e7eb));
|
|
95
|
-
border-radius: 8px;
|
|
96
|
-
padding: 12px;
|
|
97
|
-
font-size: 13px;
|
|
98
|
-
}
|
|
99
|
-
.filex-recent header {
|
|
100
|
-
display: flex;
|
|
101
|
-
justify-content: space-between;
|
|
102
|
-
align-items: center;
|
|
103
|
-
margin-bottom: 8px;
|
|
104
|
-
}
|
|
105
|
-
.filex-recent h3 {
|
|
106
|
-
margin: 0;
|
|
107
|
-
font-size: 13px;
|
|
108
|
-
font-weight: 600;
|
|
109
|
-
color: var(--fe-text, var(--filex-text, #111827));
|
|
110
|
-
}
|
|
111
|
-
.filex-recent-refresh {
|
|
112
|
-
background: transparent;
|
|
113
|
-
border: none;
|
|
114
|
-
color: var(--fe-text-muted, var(--filex-text-muted, #9ca3af));
|
|
115
|
-
cursor: pointer;
|
|
116
|
-
font-size: 14px;
|
|
117
|
-
padding: 2px 6px;
|
|
118
|
-
}
|
|
119
|
-
.filex-recent ul {
|
|
120
|
-
list-style: none;
|
|
121
|
-
margin: 0;
|
|
122
|
-
padding: 0;
|
|
123
|
-
}
|
|
124
|
-
.filex-recent-item {
|
|
125
|
-
display: flex;
|
|
126
|
-
justify-content: space-between;
|
|
127
|
-
align-items: center;
|
|
128
|
-
width: 100%;
|
|
129
|
-
background: transparent;
|
|
130
|
-
border: none;
|
|
131
|
-
padding: 6px 8px;
|
|
132
|
-
cursor: pointer;
|
|
133
|
-
border-radius: 4px;
|
|
134
|
-
text-align: left;
|
|
135
|
-
}
|
|
136
|
-
.filex-recent-item:hover {
|
|
137
|
-
background: var(--fe-bg-hover, var(--filex-bg-soft, #f3f4f6));
|
|
138
|
-
}
|
|
139
|
-
.filex-recent-name {
|
|
140
|
-
color: var(--fe-text, var(--filex-text, #111827));
|
|
141
|
-
overflow: hidden;
|
|
142
|
-
text-overflow: ellipsis;
|
|
143
|
-
white-space: nowrap;
|
|
144
|
-
}
|
|
145
|
-
.filex-recent-meta {
|
|
146
|
-
color: var(--fe-text-muted, var(--filex-text-muted, #9ca3af));
|
|
147
|
-
font-size: 11px;
|
|
148
|
-
margin-left: 8px;
|
|
149
|
-
flex-shrink: 0;
|
|
150
|
-
}
|
|
151
|
-
.filex-recent-empty {
|
|
152
|
-
color: var(--fe-text-muted, var(--filex-text-muted, #9ca3af));
|
|
153
|
-
margin: 4px 0 0;
|
|
154
|
-
}
|
|
155
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* RecentlyOpened — drop-down/sidebar tray of the user's recently-opened
|
|
4
|
+
* files. Backed by `GET /api/files/manager/recent?limit=20`.
|
|
5
|
+
*/
|
|
6
|
+
import { ref, onMounted, watch } from 'vue';
|
|
7
|
+
|
|
8
|
+
interface RecentNode {
|
|
9
|
+
id: number;
|
|
10
|
+
storage_id: number;
|
|
11
|
+
path: string;
|
|
12
|
+
name: string;
|
|
13
|
+
mime?: string;
|
|
14
|
+
last_opened?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const props = defineProps<{
|
|
18
|
+
apiBase?: string;
|
|
19
|
+
authHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
|
|
20
|
+
limit?: number;
|
|
21
|
+
/** Optional refresh trigger — incrementing this re-fetches. */
|
|
22
|
+
refreshKey?: number | string;
|
|
23
|
+
}>();
|
|
24
|
+
|
|
25
|
+
const emit = defineEmits<{
|
|
26
|
+
(e: 'open', node: RecentNode): void;
|
|
27
|
+
(e: 'error', message: string): void;
|
|
28
|
+
}>();
|
|
29
|
+
|
|
30
|
+
const items = ref<RecentNode[]>([]);
|
|
31
|
+
const loading = ref(false);
|
|
32
|
+
|
|
33
|
+
async function load() {
|
|
34
|
+
loading.value = true;
|
|
35
|
+
try {
|
|
36
|
+
const headers = await (props.authHeaders ?? (() => ({})))();
|
|
37
|
+
const base = props.apiBase ?? '';
|
|
38
|
+
const limit = props.limit ?? 20;
|
|
39
|
+
const res = await fetch(`${base}/api/files/manager/recent?limit=${limit}`, {
|
|
40
|
+
headers,
|
|
41
|
+
credentials: 'include',
|
|
42
|
+
});
|
|
43
|
+
if (res.ok) {
|
|
44
|
+
const body = await res.json();
|
|
45
|
+
items.value = Array.isArray(body.entries) ? body.entries : (Array.isArray(body) ? body : []);
|
|
46
|
+
}
|
|
47
|
+
} catch (err) {
|
|
48
|
+
emit('error', err instanceof Error ? err.message : String(err));
|
|
49
|
+
} finally {
|
|
50
|
+
loading.value = false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function fmtTime(s?: string): string {
|
|
55
|
+
if (!s) return '';
|
|
56
|
+
const t = new Date(s).getTime();
|
|
57
|
+
if (Number.isNaN(t)) return '';
|
|
58
|
+
const diff = Date.now() - t;
|
|
59
|
+
if (diff < 60_000) return 'just now';
|
|
60
|
+
if (diff < 3_600_000) return `${Math.floor(diff / 60_000)}m ago`;
|
|
61
|
+
if (diff < 86_400_000) return `${Math.floor(diff / 3_600_000)}h ago`;
|
|
62
|
+
return `${Math.floor(diff / 86_400_000)}d ago`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
onMounted(load);
|
|
66
|
+
watch(() => props.refreshKey, load);
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<template>
|
|
70
|
+
<div class="filex-recent">
|
|
71
|
+
<header>
|
|
72
|
+
<h3>Recently opened</h3>
|
|
73
|
+
<button class="filex-recent-refresh" type="button" @click="load" :disabled="loading">
|
|
74
|
+
↻
|
|
75
|
+
</button>
|
|
76
|
+
</header>
|
|
77
|
+
|
|
78
|
+
<ul v-if="items.length">
|
|
79
|
+
<li v-for="n in items" :key="n.id">
|
|
80
|
+
<button type="button" @click="emit('open', n)" class="filex-recent-item">
|
|
81
|
+
<span class="filex-recent-name">{{ n.name }}</span>
|
|
82
|
+
<span class="filex-recent-meta">{{ fmtTime(n.last_opened) }}</span>
|
|
83
|
+
</button>
|
|
84
|
+
</li>
|
|
85
|
+
</ul>
|
|
86
|
+
<p v-else-if="!loading" class="filex-recent-empty">Nothing here yet.</p>
|
|
87
|
+
<p v-else class="filex-recent-empty">Loading…</p>
|
|
88
|
+
</div>
|
|
89
|
+
</template>
|
|
90
|
+
|
|
91
|
+
<style scoped>
|
|
92
|
+
.filex-recent {
|
|
93
|
+
background: var(--fe-bg-elev, var(--filex-bg-card, #ffffff));
|
|
94
|
+
border: 1px solid var(--fe-border, var(--filex-border, #e5e7eb));
|
|
95
|
+
border-radius: 8px;
|
|
96
|
+
padding: 12px;
|
|
97
|
+
font-size: 13px;
|
|
98
|
+
}
|
|
99
|
+
.filex-recent header {
|
|
100
|
+
display: flex;
|
|
101
|
+
justify-content: space-between;
|
|
102
|
+
align-items: center;
|
|
103
|
+
margin-bottom: 8px;
|
|
104
|
+
}
|
|
105
|
+
.filex-recent h3 {
|
|
106
|
+
margin: 0;
|
|
107
|
+
font-size: 13px;
|
|
108
|
+
font-weight: 600;
|
|
109
|
+
color: var(--fe-text, var(--filex-text, #111827));
|
|
110
|
+
}
|
|
111
|
+
.filex-recent-refresh {
|
|
112
|
+
background: transparent;
|
|
113
|
+
border: none;
|
|
114
|
+
color: var(--fe-text-muted, var(--filex-text-muted, #9ca3af));
|
|
115
|
+
cursor: pointer;
|
|
116
|
+
font-size: 14px;
|
|
117
|
+
padding: 2px 6px;
|
|
118
|
+
}
|
|
119
|
+
.filex-recent ul {
|
|
120
|
+
list-style: none;
|
|
121
|
+
margin: 0;
|
|
122
|
+
padding: 0;
|
|
123
|
+
}
|
|
124
|
+
.filex-recent-item {
|
|
125
|
+
display: flex;
|
|
126
|
+
justify-content: space-between;
|
|
127
|
+
align-items: center;
|
|
128
|
+
width: 100%;
|
|
129
|
+
background: transparent;
|
|
130
|
+
border: none;
|
|
131
|
+
padding: 6px 8px;
|
|
132
|
+
cursor: pointer;
|
|
133
|
+
border-radius: 4px;
|
|
134
|
+
text-align: left;
|
|
135
|
+
}
|
|
136
|
+
.filex-recent-item:hover {
|
|
137
|
+
background: var(--fe-bg-hover, var(--filex-bg-soft, #f3f4f6));
|
|
138
|
+
}
|
|
139
|
+
.filex-recent-name {
|
|
140
|
+
color: var(--fe-text, var(--filex-text, #111827));
|
|
141
|
+
overflow: hidden;
|
|
142
|
+
text-overflow: ellipsis;
|
|
143
|
+
white-space: nowrap;
|
|
144
|
+
}
|
|
145
|
+
.filex-recent-meta {
|
|
146
|
+
color: var(--fe-text-muted, var(--filex-text-muted, #9ca3af));
|
|
147
|
+
font-size: 11px;
|
|
148
|
+
margin-left: 8px;
|
|
149
|
+
flex-shrink: 0;
|
|
150
|
+
}
|
|
151
|
+
.filex-recent-empty {
|
|
152
|
+
color: var(--fe-text-muted, var(--filex-text-muted, #9ca3af));
|
|
153
|
+
margin: 4px 0 0;
|
|
154
|
+
}
|
|
155
|
+
</style>
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* StarButton — toggleable star indicator for a node.
|
|
4
|
-
*
|
|
5
|
-
* Backed by the `node_meta key="starred"` server-side row (see
|
|
6
|
-
* `POST /api/files/manager/star`). Optimistic update — flips the local
|
|
7
|
-
* state immediately and rolls back on API error.
|
|
8
|
-
*/
|
|
9
|
-
import { ref, watch } from 'vue';
|
|
10
|
-
|
|
11
|
-
const props = defineProps<{
|
|
12
|
-
starred: boolean;
|
|
13
|
-
nodeId: number;
|
|
14
|
-
apiBase?: string;
|
|
15
|
-
/** Auth header builder injected by the parent file explorer. */
|
|
16
|
-
authHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
|
|
17
|
-
/** Compact mode for grid view (no label, just the icon). */
|
|
18
|
-
compact?: boolean;
|
|
19
|
-
}>();
|
|
20
|
-
|
|
21
|
-
const emit = defineEmits<{
|
|
22
|
-
(e: 'change', value: boolean): void;
|
|
23
|
-
(e: 'error', message: string): void;
|
|
24
|
-
}>();
|
|
25
|
-
|
|
26
|
-
const local = ref(props.starred);
|
|
27
|
-
watch(() => props.starred, (v) => { local.value = v; });
|
|
28
|
-
|
|
29
|
-
async function toggle() {
|
|
30
|
-
const next = !local.value;
|
|
31
|
-
local.value = next; // optimistic
|
|
32
|
-
try {
|
|
33
|
-
const headers = {
|
|
34
|
-
'Content-Type': 'application/json',
|
|
35
|
-
...(await (props.authHeaders ?? (() => ({})))()),
|
|
36
|
-
};
|
|
37
|
-
const base = props.apiBase ?? '';
|
|
38
|
-
const res = await fetch(`${base}/api/files/manager/star`, {
|
|
39
|
-
method: 'POST',
|
|
40
|
-
headers,
|
|
41
|
-
credentials: 'include',
|
|
42
|
-
body: JSON.stringify({ node_id: props.nodeId, starred: next }),
|
|
43
|
-
});
|
|
44
|
-
if (!res.ok) throw new Error(`star toggle failed: ${res.status}`);
|
|
45
|
-
emit('change', next);
|
|
46
|
-
} catch (err) {
|
|
47
|
-
local.value = !next; // rollback
|
|
48
|
-
emit('error', err instanceof Error ? err.message : String(err));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
</script>
|
|
52
|
-
|
|
53
|
-
<template>
|
|
54
|
-
<button
|
|
55
|
-
type="button"
|
|
56
|
-
class="filex-star-btn"
|
|
57
|
-
:class="{ 'is-starred': local, 'is-compact': compact }"
|
|
58
|
-
:aria-pressed="local"
|
|
59
|
-
:title="local ? 'Unstar' : 'Star'"
|
|
60
|
-
@click.stop="toggle"
|
|
61
|
-
>
|
|
62
|
-
<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true">
|
|
63
|
-
<path
|
|
64
|
-
:fill="local ? 'currentColor' : 'none'"
|
|
65
|
-
stroke="currentColor"
|
|
66
|
-
stroke-width="2"
|
|
67
|
-
stroke-linejoin="round"
|
|
68
|
-
d="M12 2.5l3.09 6.26 6.91 1-5 4.87 1.18 6.87L12 18.27l-6.18 3.23L7 14.63 2 9.76l6.91-1z"
|
|
69
|
-
/>
|
|
70
|
-
</svg>
|
|
71
|
-
<span v-if="!compact" class="filex-star-label">{{ local ? 'Starred' : 'Star' }}</span>
|
|
72
|
-
</button>
|
|
73
|
-
</template>
|
|
74
|
-
|
|
75
|
-
<style scoped>
|
|
76
|
-
.filex-star-btn {
|
|
77
|
-
display: inline-flex;
|
|
78
|
-
align-items: center;
|
|
79
|
-
gap: 6px;
|
|
80
|
-
background: transparent;
|
|
81
|
-
border: 1px solid transparent;
|
|
82
|
-
border-radius: 6px;
|
|
83
|
-
padding: 4px 8px;
|
|
84
|
-
color: var(--filex-text-muted, #9ca3af);
|
|
85
|
-
cursor: pointer;
|
|
86
|
-
transition: color 120ms, background 120ms;
|
|
87
|
-
}
|
|
88
|
-
.filex-star-btn:hover {
|
|
89
|
-
color: var(--filex-accent-amber, #f59e0b);
|
|
90
|
-
background: var(--filex-bg-soft, rgba(0, 0, 0, 0.04));
|
|
91
|
-
}
|
|
92
|
-
.filex-star-btn.is-starred {
|
|
93
|
-
color: var(--filex-accent-amber, #f59e0b);
|
|
94
|
-
}
|
|
95
|
-
.filex-star-btn.is-compact {
|
|
96
|
-
padding: 4px;
|
|
97
|
-
}
|
|
98
|
-
.filex-star-label {
|
|
99
|
-
font-size: 13px;
|
|
100
|
-
}
|
|
101
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* StarButton — toggleable star indicator for a node.
|
|
4
|
+
*
|
|
5
|
+
* Backed by the `node_meta key="starred"` server-side row (see
|
|
6
|
+
* `POST /api/files/manager/star`). Optimistic update — flips the local
|
|
7
|
+
* state immediately and rolls back on API error.
|
|
8
|
+
*/
|
|
9
|
+
import { ref, watch } from 'vue';
|
|
10
|
+
|
|
11
|
+
const props = defineProps<{
|
|
12
|
+
starred: boolean;
|
|
13
|
+
nodeId: number;
|
|
14
|
+
apiBase?: string;
|
|
15
|
+
/** Auth header builder injected by the parent file explorer. */
|
|
16
|
+
authHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
|
|
17
|
+
/** Compact mode for grid view (no label, just the icon). */
|
|
18
|
+
compact?: boolean;
|
|
19
|
+
}>();
|
|
20
|
+
|
|
21
|
+
const emit = defineEmits<{
|
|
22
|
+
(e: 'change', value: boolean): void;
|
|
23
|
+
(e: 'error', message: string): void;
|
|
24
|
+
}>();
|
|
25
|
+
|
|
26
|
+
const local = ref(props.starred);
|
|
27
|
+
watch(() => props.starred, (v) => { local.value = v; });
|
|
28
|
+
|
|
29
|
+
async function toggle() {
|
|
30
|
+
const next = !local.value;
|
|
31
|
+
local.value = next; // optimistic
|
|
32
|
+
try {
|
|
33
|
+
const headers = {
|
|
34
|
+
'Content-Type': 'application/json',
|
|
35
|
+
...(await (props.authHeaders ?? (() => ({})))()),
|
|
36
|
+
};
|
|
37
|
+
const base = props.apiBase ?? '';
|
|
38
|
+
const res = await fetch(`${base}/api/files/manager/star`, {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
headers,
|
|
41
|
+
credentials: 'include',
|
|
42
|
+
body: JSON.stringify({ node_id: props.nodeId, starred: next }),
|
|
43
|
+
});
|
|
44
|
+
if (!res.ok) throw new Error(`star toggle failed: ${res.status}`);
|
|
45
|
+
emit('change', next);
|
|
46
|
+
} catch (err) {
|
|
47
|
+
local.value = !next; // rollback
|
|
48
|
+
emit('error', err instanceof Error ? err.message : String(err));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<button
|
|
55
|
+
type="button"
|
|
56
|
+
class="filex-star-btn"
|
|
57
|
+
:class="{ 'is-starred': local, 'is-compact': compact }"
|
|
58
|
+
:aria-pressed="local"
|
|
59
|
+
:title="local ? 'Unstar' : 'Star'"
|
|
60
|
+
@click.stop="toggle"
|
|
61
|
+
>
|
|
62
|
+
<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true">
|
|
63
|
+
<path
|
|
64
|
+
:fill="local ? 'currentColor' : 'none'"
|
|
65
|
+
stroke="currentColor"
|
|
66
|
+
stroke-width="2"
|
|
67
|
+
stroke-linejoin="round"
|
|
68
|
+
d="M12 2.5l3.09 6.26 6.91 1-5 4.87 1.18 6.87L12 18.27l-6.18 3.23L7 14.63 2 9.76l6.91-1z"
|
|
69
|
+
/>
|
|
70
|
+
</svg>
|
|
71
|
+
<span v-if="!compact" class="filex-star-label">{{ local ? 'Starred' : 'Star' }}</span>
|
|
72
|
+
</button>
|
|
73
|
+
</template>
|
|
74
|
+
|
|
75
|
+
<style scoped>
|
|
76
|
+
.filex-star-btn {
|
|
77
|
+
display: inline-flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
gap: 6px;
|
|
80
|
+
background: transparent;
|
|
81
|
+
border: 1px solid transparent;
|
|
82
|
+
border-radius: 6px;
|
|
83
|
+
padding: 4px 8px;
|
|
84
|
+
color: var(--filex-text-muted, #9ca3af);
|
|
85
|
+
cursor: pointer;
|
|
86
|
+
transition: color 120ms, background 120ms;
|
|
87
|
+
}
|
|
88
|
+
.filex-star-btn:hover {
|
|
89
|
+
color: var(--filex-accent-amber, #f59e0b);
|
|
90
|
+
background: var(--filex-bg-soft, rgba(0, 0, 0, 0.04));
|
|
91
|
+
}
|
|
92
|
+
.filex-star-btn.is-starred {
|
|
93
|
+
color: var(--filex-accent-amber, #f59e0b);
|
|
94
|
+
}
|
|
95
|
+
.filex-star-btn.is-compact {
|
|
96
|
+
padding: 4px;
|
|
97
|
+
}
|
|
98
|
+
.filex-star-label {
|
|
99
|
+
font-size: 13px;
|
|
100
|
+
}
|
|
101
|
+
</style>
|