@olares/lares-mobile 0.15.5 → 0.15.7
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 +6 -2
- package/package.json +2 -2
- package/src/App.vue +918 -178
- package/src/chat/ChatBar.vue +2 -2
- package/src/chat/Composer.vue +467 -16
- package/src/chat/Deliverables.vue +22 -10
- package/src/chat/HistoryPanel.vue +747 -55
- package/src/chat/MessageActions.vue +88 -34
- package/src/chat/QuestionCard.vue +5 -5
- package/src/chat/StageRow.vue +8 -5
- package/src/chat/Transcript.vue +20 -6
- package/src/chat/composer-tokens.js +32 -0
- package/src/chat/format.js +37 -0
- package/src/desktop/DesktopComposer.vue +942 -0
- package/src/desktop/DesktopContextMeter.vue +81 -0
- package/src/desktop/DesktopGoal.vue +88 -0
- package/src/desktop/DesktopPreview.vue +58 -0
- package/src/desktop/DesktopPreviewTabs.vue +82 -0
- package/src/desktop/DesktopQuestions.vue +118 -0
- package/src/desktop/DesktopQueue.vue +203 -0
- package/src/desktop/DesktopShell.vue +229 -0
- package/src/desktop/DesktopSidebar.vue +645 -0
- package/src/desktop/DesktopTodos.vue +52 -0
- package/src/desktop/DirectoryBrowser.vue +231 -0
- package/src/desktop/DirectoryNewFolder.vue +124 -0
- package/src/desktop/ui/PcDialog.vue +100 -0
- package/src/desktop/ui/PcPopover.vue +110 -0
- package/src/desktop/ui/PcTooltip.vue +95 -0
- package/src/desktop/ui/place.js +24 -0
- package/src/desktop/workspace-view.js +121 -0
- package/src/host.js +20 -2
- package/src/index.d.ts +2 -0
- package/src/mobile/MobileDirectoryNewFolder.vue +121 -0
- package/src/mobile/MobileDirectorySheet.vue +162 -0
- package/src/mobile/MobileNewSession.vue +217 -0
- package/src/mobile/MobileShell.vue +367 -0
- package/src/motion.css +166 -0
- package/src/preview/Preview.vue +91 -150
- package/src/preview/PreviewBody.vue +185 -0
- package/src/settings/AgentSettings.vue +126 -36
- package/src/settings/Select.vue +183 -0
- package/src/settings/SettingRow.vue +5 -4
- package/src/settings/Sheet.vue +4 -4
- package/src/styles.css +9 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span
|
|
3
|
+
ref="anchor"
|
|
4
|
+
class="lares-pc-tooltip"
|
|
5
|
+
@mouseenter="schedule"
|
|
6
|
+
@mouseleave="hide"
|
|
7
|
+
@focusin="schedule"
|
|
8
|
+
@focusout="hide"
|
|
9
|
+
@click="hide"
|
|
10
|
+
>
|
|
11
|
+
<slot />
|
|
12
|
+
<Teleport to="body">
|
|
13
|
+
<div v-if="shown" class="lares-pc-tooltip__chip" role="tooltip" :style="chip">{{ label }}</div>
|
|
14
|
+
</Teleport>
|
|
15
|
+
</span>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
export default {
|
|
20
|
+
name: "LaresPcTooltip",
|
|
21
|
+
props: {
|
|
22
|
+
label: { type: String, default: "" },
|
|
23
|
+
placement: { type: String, default: "bottom" },
|
|
24
|
+
delay: { type: Number, default: 120 },
|
|
25
|
+
},
|
|
26
|
+
data() {
|
|
27
|
+
return {
|
|
28
|
+
open: false,
|
|
29
|
+
timer: 0,
|
|
30
|
+
chip: { top: "0px", left: "0px" },
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
computed: {
|
|
34
|
+
shown() {
|
|
35
|
+
return this.open && Boolean(this.label);
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
watch: {
|
|
39
|
+
label(value) {
|
|
40
|
+
if (this.open && value) this.$nextTick(this.place);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
beforeUnmount() {
|
|
44
|
+
this.hide();
|
|
45
|
+
},
|
|
46
|
+
methods: {
|
|
47
|
+
schedule() {
|
|
48
|
+
if (!this.label) return;
|
|
49
|
+
window.clearTimeout(this.timer);
|
|
50
|
+
this.timer = window.setTimeout(() => {
|
|
51
|
+
this.open = true;
|
|
52
|
+
window.addEventListener("scroll", this.hide, true);
|
|
53
|
+
this.$nextTick(this.place);
|
|
54
|
+
}, this.delay);
|
|
55
|
+
},
|
|
56
|
+
hide() {
|
|
57
|
+
window.clearTimeout(this.timer);
|
|
58
|
+
this.timer = 0;
|
|
59
|
+
if (!this.open) return;
|
|
60
|
+
this.open = false;
|
|
61
|
+
window.removeEventListener("scroll", this.hide, true);
|
|
62
|
+
},
|
|
63
|
+
place() {
|
|
64
|
+
const anchor = this.$refs.anchor;
|
|
65
|
+
if (!anchor) return;
|
|
66
|
+
const box = anchor.getBoundingClientRect();
|
|
67
|
+
const gap = 4;
|
|
68
|
+
const above = this.placement === "top";
|
|
69
|
+
this.chip = {
|
|
70
|
+
top: above ? `${Math.max(6, box.top - gap)}px` : `${box.bottom + gap}px`,
|
|
71
|
+
left: `${Math.max(6, box.left)}px`,
|
|
72
|
+
transform: above ? "translateY(-100%)" : "none",
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<style scoped>
|
|
80
|
+
.lares-pc-tooltip { display:inline-flex; min-width:0; }
|
|
81
|
+
.lares-pc-tooltip__chip {
|
|
82
|
+
position:fixed;
|
|
83
|
+
z-index:9500;
|
|
84
|
+
max-width:260px;
|
|
85
|
+
border-radius:6px;
|
|
86
|
+
padding:4px 8px;
|
|
87
|
+
background:var(--q-background-3);
|
|
88
|
+
color:var(--q-ink-1);
|
|
89
|
+
font-size:14px;
|
|
90
|
+
line-height:18px;
|
|
91
|
+
white-space:nowrap;
|
|
92
|
+
pointer-events:none;
|
|
93
|
+
box-shadow:0 4px 14px rgb(0 0 0 / 24%);
|
|
94
|
+
}
|
|
95
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const GAP = 5;
|
|
2
|
+
const EDGE = 8;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Fixed-position style for a panel hanging off `box`. Composer menus sit at the
|
|
6
|
+
* bottom of the window and open upward; the side only flips when the requested
|
|
7
|
+
* one is too cramped to read.
|
|
8
|
+
*/
|
|
9
|
+
export function placePanel({ box, viewport, width, placement = "bottom-end", minHeight = 120 }) {
|
|
10
|
+
const below = viewport.height - box.bottom - GAP;
|
|
11
|
+
const above = box.top - GAP;
|
|
12
|
+
const preferTop = placement.startsWith("top");
|
|
13
|
+
const wanted = preferTop ? above : below;
|
|
14
|
+
const other = preferTop ? below : above;
|
|
15
|
+
const useTop = preferTop !== (wanted < minHeight && other > wanted);
|
|
16
|
+
const rawLeft = placement.endsWith("start") ? box.left : box.right - width;
|
|
17
|
+
return {
|
|
18
|
+
top: useTop ? "" : `${box.bottom + GAP}px`,
|
|
19
|
+
bottom: useTop ? `${viewport.height - box.top + GAP}px` : "",
|
|
20
|
+
left: `${Math.max(EDGE, Math.min(rawLeft, viewport.width - width - EDGE))}px`,
|
|
21
|
+
width: `${width}px`,
|
|
22
|
+
maxHeight: `${Math.max(minHeight, useTop ? above : below)}px`,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FLAT_SESSION_ORDER_KEY,
|
|
3
|
+
nextSessionOrderAccount,
|
|
4
|
+
} from "@olares/lares-core/larepass/workspace";
|
|
5
|
+
|
|
6
|
+
const STORAGE_KEY = "lares.larepass.workspace.view.v1";
|
|
7
|
+
|
|
8
|
+
const initialView = () => ({
|
|
9
|
+
groupBy: "workspace",
|
|
10
|
+
orderBy: "updated",
|
|
11
|
+
groupExpansion: {},
|
|
12
|
+
sessionOrderByAccount: {},
|
|
13
|
+
sessionUpdatedAtByAccount: {},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export function loadWorkspaceView(storage = globalThis.localStorage) {
|
|
17
|
+
if (!storage) return initialView();
|
|
18
|
+
try {
|
|
19
|
+
const saved = JSON.parse(storage.getItem(STORAGE_KEY) || "{}");
|
|
20
|
+
return {
|
|
21
|
+
groupBy: saved.groupBy === "flat" ? "flat" : "workspace",
|
|
22
|
+
orderBy: saved.orderBy === "manual" ? "manual" : "updated",
|
|
23
|
+
groupExpansion: saved.groupExpansion && typeof saved.groupExpansion === "object"
|
|
24
|
+
? saved.groupExpansion
|
|
25
|
+
: {},
|
|
26
|
+
sessionOrderByAccount: saved.sessionOrderByAccount && typeof saved.sessionOrderByAccount === "object"
|
|
27
|
+
? saved.sessionOrderByAccount
|
|
28
|
+
: {},
|
|
29
|
+
sessionUpdatedAtByAccount: saved.sessionUpdatedAtByAccount && typeof saved.sessionUpdatedAtByAccount === "object"
|
|
30
|
+
? saved.sessionUpdatedAtByAccount
|
|
31
|
+
: {},
|
|
32
|
+
};
|
|
33
|
+
} catch {
|
|
34
|
+
return initialView();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function saveWorkspaceView(view, storage = globalThis.localStorage) {
|
|
39
|
+
if (!storage) return;
|
|
40
|
+
try {
|
|
41
|
+
storage.setItem(STORAGE_KEY, JSON.stringify(view));
|
|
42
|
+
} catch {
|
|
43
|
+
// Browser storage can be unavailable in private or embedded contexts.
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function accountSessionIds(sessions, workspaces) {
|
|
48
|
+
const known = new Set(sessions.map((row) => row.sessionId));
|
|
49
|
+
const accounted = new Set();
|
|
50
|
+
const accounts = workspaces.map((workspace) => {
|
|
51
|
+
const ids = (workspace.sessionIds ?? []).filter((id) => known.has(id));
|
|
52
|
+
ids.forEach((id) => accounted.add(id));
|
|
53
|
+
return [workspace.workspaceId, ids];
|
|
54
|
+
});
|
|
55
|
+
accounts.push(["", sessions.map((row) => row.sessionId).filter((id) => !accounted.has(id))]);
|
|
56
|
+
accounts.push([FLAT_SESSION_ORDER_KEY, sessions.map((row) => row.sessionId)]);
|
|
57
|
+
return accounts;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function promote(order, sessionId) {
|
|
61
|
+
return [sessionId, ...order.filter((id) => id !== sessionId)];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function syncWorkspaceViewOrders(view, {
|
|
65
|
+
sessions = [],
|
|
66
|
+
workspaces = [],
|
|
67
|
+
currentSessionId = "",
|
|
68
|
+
sortByRecency = false,
|
|
69
|
+
} = {}) {
|
|
70
|
+
const nextOrder = {};
|
|
71
|
+
const nextUpdatedAt = {};
|
|
72
|
+
for (const [key, sessionIds] of accountSessionIds(sessions, workspaces)) {
|
|
73
|
+
const next = nextSessionOrderAccount({
|
|
74
|
+
sessionIds,
|
|
75
|
+
previousOrder: view.sessionOrderByAccount[key],
|
|
76
|
+
previousUpdatedAt: view.sessionUpdatedAtByAccount[key],
|
|
77
|
+
sessions,
|
|
78
|
+
orderBy: view.orderBy,
|
|
79
|
+
sortByRecency: view.orderBy === "updated"
|
|
80
|
+
&& (sortByRecency || view.sessionOrderByAccount[key] === undefined),
|
|
81
|
+
});
|
|
82
|
+
nextOrder[key] = next.order;
|
|
83
|
+
nextUpdatedAt[key] = next.updatedAt;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const current = sessions.find((row) => row.sessionId === currentSessionId);
|
|
87
|
+
if (current?.blank) {
|
|
88
|
+
const account = workspaces.find((workspace) => (
|
|
89
|
+
workspace.sessionIds?.includes(currentSessionId)
|
|
90
|
+
))?.workspaceId ?? "";
|
|
91
|
+
nextOrder[account] = promote(nextOrder[account] ?? [], currentSessionId);
|
|
92
|
+
nextOrder[FLAT_SESSION_ORDER_KEY] = promote(
|
|
93
|
+
nextOrder[FLAT_SESSION_ORDER_KEY] ?? [],
|
|
94
|
+
currentSessionId,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
...view,
|
|
100
|
+
sessionOrderByAccount: nextOrder,
|
|
101
|
+
sessionUpdatedAtByAccount: nextUpdatedAt,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Reordering is expressed as "insert before X", while a pointer lands on an edge
|
|
107
|
+
* of a row. Translate the hovered row plus edge into that anchor; "" is the end
|
|
108
|
+
* of the list, which every insert-before call reads as an append.
|
|
109
|
+
*/
|
|
110
|
+
export function dropAnchor(ids, hint) {
|
|
111
|
+
const at = ids.indexOf(hint?.key);
|
|
112
|
+
if (at === -1) return "";
|
|
113
|
+
return hint.edge === "after" ? ids[at + 1] ?? "" : hint.key;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function insertSessionBefore(order, sessionId, beforeSessionId) {
|
|
117
|
+
const next = order.filter((id) => id !== sessionId);
|
|
118
|
+
const index = beforeSessionId ? next.indexOf(beforeSessionId) : -1;
|
|
119
|
+
next.splice(index === -1 ? next.length : index, 0, sessionId);
|
|
120
|
+
return next;
|
|
121
|
+
}
|
package/src/host.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { hostTarget, hostUrl, MODELS_PATH, probeHost } from "@olares/lares-core/larepass/host";
|
|
2
2
|
import { callRpc, consumeMux, ensureSession, loadTranscript, MUX_PATH, sendPrompt } from "@olares/lares-core/larepass/chat";
|
|
3
|
+
import { commandsUrl, normalizeCommands } from "@olares/lares-core/larepass/commands";
|
|
4
|
+
import { normalizeReferenceCandidates, referencesUrl } from "@olares/lares-core/larepass/references";
|
|
3
5
|
import { muxWsUrl } from "@olares/lares-core/larepass/mux";
|
|
4
6
|
import { RESPOND_PATH } from "@olares/lares-core/larepass/rpc";
|
|
5
7
|
import { createHostSettings } from "@olares/lares-core/larepass/settings";
|
|
@@ -133,8 +135,8 @@ export function createHostClient(ports = {}) {
|
|
|
133
135
|
history(sessionId) {
|
|
134
136
|
return loadTranscript(rpc, sessionId);
|
|
135
137
|
},
|
|
136
|
-
prompt(sessionId,
|
|
137
|
-
return sendPrompt(rpc, sessionId,
|
|
138
|
+
prompt(sessionId, content, mode) {
|
|
139
|
+
return sendPrompt(rpc, sessionId, content, mode);
|
|
138
140
|
},
|
|
139
141
|
async respond(message) {
|
|
140
142
|
const res = await request(RESPOND_PATH, { method: "POST", body: message });
|
|
@@ -142,6 +144,22 @@ export function createHostClient(ports = {}) {
|
|
|
142
144
|
if (body && typeof body === "object" && typeof body.accepted === "boolean") return body;
|
|
143
145
|
return { accepted: Boolean(res?.ok), reason: res?.ok ? undefined : "bad-response" };
|
|
144
146
|
},
|
|
147
|
+
async commands(sessionId) {
|
|
148
|
+
const res = await request(commandsUrl(sessionId));
|
|
149
|
+
const http = Number(res?.status) || 0;
|
|
150
|
+
if (http < 200 || http >= 300) {
|
|
151
|
+
throw new Error(res?.body?.error?.code || `commands ${http || "failed"}`);
|
|
152
|
+
}
|
|
153
|
+
return normalizeCommands(res?.body);
|
|
154
|
+
},
|
|
155
|
+
async references(sessionId, query, quoted = false) {
|
|
156
|
+
const res = await request(referencesUrl(sessionId, query));
|
|
157
|
+
const http = Number(res?.status) || 0;
|
|
158
|
+
if (http < 200 || http >= 300) {
|
|
159
|
+
throw new Error(res?.body?.error?.code || `references ${http || "failed"}`);
|
|
160
|
+
}
|
|
161
|
+
return normalizeReferenceCandidates(res?.body, quoted);
|
|
162
|
+
},
|
|
145
163
|
async preview(sessionId, path) {
|
|
146
164
|
const res = await request(previewMetaUrl(sessionId, path));
|
|
147
165
|
const http = Number(res?.status) || 0;
|
package/src/index.d.ts
CHANGED
|
@@ -71,10 +71,12 @@ export const LaresApp: DefineComponent<{
|
|
|
71
71
|
proxyPrefix?: string;
|
|
72
72
|
env?: HostEnv;
|
|
73
73
|
request?: (url: string, init?: HostRequestInit) => Promise<HostResponse>;
|
|
74
|
+
socketProtocol?: HostPorts["socketProtocol"];
|
|
74
75
|
}>;
|
|
75
76
|
|
|
76
77
|
export const LaresAgentSettings: DefineComponent<{
|
|
77
78
|
locale?: string;
|
|
79
|
+
device?: ChatDevice;
|
|
78
80
|
baseUrl?: string;
|
|
79
81
|
proxyPrefix?: string;
|
|
80
82
|
env?: HostEnv;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<LaresSheet :open="open" :title="t('desktop.newFolder')" @close="$emit('close')">
|
|
3
|
+
<div class="mobile-directory-new">
|
|
4
|
+
<input
|
|
5
|
+
ref="input"
|
|
6
|
+
v-model="value"
|
|
7
|
+
class="mobile-directory-new__input"
|
|
8
|
+
:placeholder="t('desktop.untitledFolder')"
|
|
9
|
+
:disabled="busy"
|
|
10
|
+
@keydown.enter.prevent="submit"
|
|
11
|
+
/>
|
|
12
|
+
<div class="mobile-directory-new__actions">
|
|
13
|
+
<button type="button" class="mobile-directory-new__cancel" :disabled="busy" @click="$emit('close')">
|
|
14
|
+
{{ t("desktop.cancel") }}
|
|
15
|
+
</button>
|
|
16
|
+
<button
|
|
17
|
+
type="button"
|
|
18
|
+
class="mobile-directory-new__create"
|
|
19
|
+
:disabled="busy || !value.trim()"
|
|
20
|
+
@click="submit"
|
|
21
|
+
>
|
|
22
|
+
{{ t("desktop.createFolder") }}
|
|
23
|
+
</button>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</LaresSheet>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script>
|
|
30
|
+
import LaresSheet from "../settings/Sheet.vue";
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
name: "LaresMobileDirectoryNewFolder",
|
|
34
|
+
components: { LaresSheet },
|
|
35
|
+
props: {
|
|
36
|
+
open: { type: Boolean, default: false },
|
|
37
|
+
busy: { type: Boolean, default: false },
|
|
38
|
+
t: { type: Function, required: true },
|
|
39
|
+
},
|
|
40
|
+
emits: ["close", "create"],
|
|
41
|
+
data() {
|
|
42
|
+
return { value: "" };
|
|
43
|
+
},
|
|
44
|
+
watch: {
|
|
45
|
+
open(value) {
|
|
46
|
+
if (!value) {
|
|
47
|
+
this.value = "";
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
this.value = this.t("desktop.untitledFolder");
|
|
51
|
+
this.$nextTick(() => {
|
|
52
|
+
this.$refs.input?.focus();
|
|
53
|
+
this.$refs.input?.select();
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
methods: {
|
|
58
|
+
submit() {
|
|
59
|
+
const name = this.value.trim();
|
|
60
|
+
if (!name || this.busy) return;
|
|
61
|
+
this.$emit("create", name);
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<style scoped>
|
|
68
|
+
.mobile-directory-new {
|
|
69
|
+
padding: 0 20px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.mobile-directory-new__input {
|
|
73
|
+
box-sizing: border-box;
|
|
74
|
+
width: 100%;
|
|
75
|
+
height: 44px;
|
|
76
|
+
border: 1px solid var(--q-input-stroke, var(--q-separator));
|
|
77
|
+
border-radius: 999px;
|
|
78
|
+
padding: 0 16px;
|
|
79
|
+
background: transparent;
|
|
80
|
+
color: var(--q-ink-1);
|
|
81
|
+
font: inherit;
|
|
82
|
+
font-size: 16px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.mobile-directory-new__input:focus {
|
|
86
|
+
outline: none;
|
|
87
|
+
border-color: var(--q-blue-default);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.mobile-directory-new__actions {
|
|
91
|
+
display: flex;
|
|
92
|
+
justify-content: flex-end;
|
|
93
|
+
gap: 8px;
|
|
94
|
+
margin-top: 16px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.mobile-directory-new__cancel,
|
|
98
|
+
.mobile-directory-new__create {
|
|
99
|
+
min-height: 40px;
|
|
100
|
+
border-radius: 10px;
|
|
101
|
+
padding: 0 16px;
|
|
102
|
+
font: inherit;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.mobile-directory-new__cancel {
|
|
106
|
+
border: 1px solid var(--q-separator);
|
|
107
|
+
background: transparent;
|
|
108
|
+
color: var(--q-ink-2);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.mobile-directory-new__create {
|
|
112
|
+
border: 0;
|
|
113
|
+
background: var(--q-blue-default);
|
|
114
|
+
color: var(--q-ink-on-brand);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.mobile-directory-new__cancel:disabled,
|
|
118
|
+
.mobile-directory-new__create:disabled {
|
|
119
|
+
opacity: 0.5;
|
|
120
|
+
}
|
|
121
|
+
</style>
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<LaresSheet :open="open" :title="t('desktop.chooseFolder')" @close="$emit('close')">
|
|
3
|
+
<div class="mobile-directory">
|
|
4
|
+
<nav v-if="state.listing" class="mobile-directory__crumbs" :aria-label="t('desktop.folderPath')">
|
|
5
|
+
<button
|
|
6
|
+
v-for="crumb in state.listing.crumbs"
|
|
7
|
+
:key="crumb.path"
|
|
8
|
+
type="button"
|
|
9
|
+
@click="$emit('browse', crumb.path)"
|
|
10
|
+
>
|
|
11
|
+
{{ crumb.path === state.listing.home ? t("desktop.home") : crumb.name }}
|
|
12
|
+
</button>
|
|
13
|
+
</nav>
|
|
14
|
+
<div class="mobile-directory__body">
|
|
15
|
+
<p v-if="state.loading" class="mobile-directory__status">{{ t("desktop.loadingFolders") }}</p>
|
|
16
|
+
<p v-else-if="state.error" class="mobile-directory__error">{{ state.error }}</p>
|
|
17
|
+
<template v-else-if="state.listing">
|
|
18
|
+
<button
|
|
19
|
+
v-for="entry in visibleEntries"
|
|
20
|
+
:key="entry.path"
|
|
21
|
+
type="button"
|
|
22
|
+
class="mobile-directory__row"
|
|
23
|
+
:data-selected="selected === entry.path"
|
|
24
|
+
@click="selected = entry.path"
|
|
25
|
+
>
|
|
26
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3.5 7.5h6l1.6 2H20.5v9H3.5z" /></svg>
|
|
27
|
+
<span>{{ entry.name }}</span>
|
|
28
|
+
<span
|
|
29
|
+
class="mobile-directory__open"
|
|
30
|
+
role="button"
|
|
31
|
+
tabindex="0"
|
|
32
|
+
:aria-label="entry.name"
|
|
33
|
+
@click.stop="$emit('browse', entry.path)"
|
|
34
|
+
@keydown.enter.stop="$emit('browse', entry.path)"
|
|
35
|
+
>
|
|
36
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m9 6 6 6-6 6" /></svg>
|
|
37
|
+
</span>
|
|
38
|
+
</button>
|
|
39
|
+
<p v-if="visibleEntries.length === 0" class="mobile-directory__status">{{ t("desktop.noFolders") }}</p>
|
|
40
|
+
</template>
|
|
41
|
+
</div>
|
|
42
|
+
<footer class="mobile-directory__footer">
|
|
43
|
+
<p class="mobile-directory__path">{{ selected || state.listing?.path || "" }}</p>
|
|
44
|
+
<div class="mobile-directory__tools">
|
|
45
|
+
<button
|
|
46
|
+
type="button"
|
|
47
|
+
class="mobile-directory__new-folder"
|
|
48
|
+
:disabled="!state.listing?.path || state.loading || state.creatingFolder"
|
|
49
|
+
@click="newFolderOpen = true"
|
|
50
|
+
>
|
|
51
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14" /></svg>
|
|
52
|
+
<span>{{ t("desktop.newFolder") }}</span>
|
|
53
|
+
</button>
|
|
54
|
+
<label class="mobile-directory__hidden">
|
|
55
|
+
<input
|
|
56
|
+
type="checkbox"
|
|
57
|
+
:checked="state.showHidden"
|
|
58
|
+
@change="$emit('toggle-hidden', $event.target.checked)"
|
|
59
|
+
/>
|
|
60
|
+
<span>{{ t("desktop.showHiddenFiles") }}</span>
|
|
61
|
+
</label>
|
|
62
|
+
</div>
|
|
63
|
+
<div class="mobile-directory__actions">
|
|
64
|
+
<button type="button" class="mobile-directory__cancel" :disabled="state.creating" @click="$emit('close')">
|
|
65
|
+
{{ t("desktop.cancel") }}
|
|
66
|
+
</button>
|
|
67
|
+
<button
|
|
68
|
+
type="button"
|
|
69
|
+
class="mobile-directory__choose"
|
|
70
|
+
:disabled="state.loading || state.creating || !(selected || state.listing?.path)"
|
|
71
|
+
@click="$emit('choose', selected || state.listing.path)"
|
|
72
|
+
>
|
|
73
|
+
{{ state.creating ? t("desktop.addingWorkspace") : t("desktop.addWorkspace") }}
|
|
74
|
+
</button>
|
|
75
|
+
</div>
|
|
76
|
+
</footer>
|
|
77
|
+
</div>
|
|
78
|
+
<LaresMobileDirectoryNewFolder
|
|
79
|
+
:open="newFolderOpen"
|
|
80
|
+
:busy="state.creatingFolder"
|
|
81
|
+
:t="t"
|
|
82
|
+
@close="newFolderOpen = false"
|
|
83
|
+
@create="onCreateFolder"
|
|
84
|
+
/>
|
|
85
|
+
</LaresSheet>
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
<script>
|
|
89
|
+
import LaresSheet from "../settings/Sheet.vue";
|
|
90
|
+
import LaresMobileDirectoryNewFolder from "./MobileDirectoryNewFolder.vue";
|
|
91
|
+
|
|
92
|
+
export default {
|
|
93
|
+
name: "LaresMobileDirectorySheet",
|
|
94
|
+
components: { LaresSheet, LaresMobileDirectoryNewFolder },
|
|
95
|
+
props: {
|
|
96
|
+
open: { type: Boolean, default: false },
|
|
97
|
+
state: { type: Object, required: true },
|
|
98
|
+
t: { type: Function, required: true },
|
|
99
|
+
},
|
|
100
|
+
emits: ["close", "browse", "choose", "create-folder", "toggle-hidden"],
|
|
101
|
+
data() {
|
|
102
|
+
return { selected: "", newFolderOpen: false };
|
|
103
|
+
},
|
|
104
|
+
computed: {
|
|
105
|
+
visibleEntries() {
|
|
106
|
+
const entries = this.state.listing?.entries ?? [];
|
|
107
|
+
return this.state.showHidden ? entries : entries.filter((entry) => !entry.hidden);
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
watch: {
|
|
111
|
+
"state.listing.path"() {
|
|
112
|
+
this.selected = this.state.selectPath || "";
|
|
113
|
+
},
|
|
114
|
+
"state.selectPath"(path) {
|
|
115
|
+
if (path) this.selected = path;
|
|
116
|
+
},
|
|
117
|
+
"state.creatingFolder"(busy, was) {
|
|
118
|
+
if (was && !busy && !this.state.error) this.newFolderOpen = false;
|
|
119
|
+
},
|
|
120
|
+
open(value) {
|
|
121
|
+
if (!value) {
|
|
122
|
+
this.newFolderOpen = false;
|
|
123
|
+
this.selected = "";
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
methods: {
|
|
128
|
+
onCreateFolder(name) {
|
|
129
|
+
this.$emit("create-folder", name);
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<style scoped>
|
|
136
|
+
.mobile-directory { display:flex; min-height:min(420px, 55vh); flex-direction:column; margin:-4px 0 0; }
|
|
137
|
+
.mobile-directory svg { width:20px; height:20px; flex-shrink:0; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
|
|
138
|
+
.mobile-directory__crumbs { display:flex; gap:4px; overflow:auto; padding:0 20px 8px; }
|
|
139
|
+
.mobile-directory__crumbs button { flex-shrink:0; border:0; border-radius:8px; padding:6px 8px; background:transparent; color:var(--q-ink-3); font-size:14px; }
|
|
140
|
+
.mobile-directory__body { flex:1; min-height:0; overflow:auto; padding:0 12px; }
|
|
141
|
+
.mobile-directory__row { display:flex; width:100%; align-items:center; gap:10px; border:0; border-radius:12px; padding:12px 10px; background:transparent; color:var(--q-ink-1); text-align:left; }
|
|
142
|
+
.mobile-directory__row[data-selected="true"],
|
|
143
|
+
.mobile-directory__row:active { background:var(--q-background-hover); }
|
|
144
|
+
.mobile-directory__row > span:first-of-type { min-width:0; flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
|
|
145
|
+
.mobile-directory__open { display:grid; width:32px; height:32px; place-items:center; color:var(--q-ink-3); }
|
|
146
|
+
.mobile-directory__status,
|
|
147
|
+
.mobile-directory__error { margin:16px 8px; color:var(--q-ink-3); font-size:15px; text-align:center; }
|
|
148
|
+
.mobile-directory__error { color:var(--q-orange-default); }
|
|
149
|
+
.mobile-directory__footer { display:flex; flex-direction:column; gap:10px; padding:12px 20px calc(12px + env(safe-area-inset-bottom, 0px)); border-top:1px solid var(--q-separator); }
|
|
150
|
+
.mobile-directory__path { width:100%; margin:0; overflow:hidden; color:var(--q-ink-3); font-size:13px; text-overflow:ellipsis; white-space:nowrap; }
|
|
151
|
+
.mobile-directory__tools { display:flex; flex-wrap:wrap; align-items:center; gap:10px 14px; }
|
|
152
|
+
.mobile-directory__new-folder { display:inline-flex; align-items:center; gap:6px; border:1px solid var(--q-separator); border-radius:999px; padding:0 12px; min-height:36px; background:transparent; color:var(--q-ink-2); font:inherit; font-size:14px; }
|
|
153
|
+
.mobile-directory__new-folder svg { width:16px; height:16px; }
|
|
154
|
+
.mobile-directory__hidden { display:inline-flex; align-items:center; gap:8px; color:var(--q-ink-3); font-size:14px; }
|
|
155
|
+
.mobile-directory__hidden input { width:16px; height:16px; margin:0; }
|
|
156
|
+
.mobile-directory__actions { display:flex; justify-content:flex-end; gap:8px; }
|
|
157
|
+
.mobile-directory__cancel,
|
|
158
|
+
.mobile-directory__choose { min-height:40px; border-radius:10px; padding:0 14px; font:inherit; }
|
|
159
|
+
.mobile-directory__cancel { border:1px solid var(--q-separator); background:transparent; color:var(--q-ink-2); }
|
|
160
|
+
.mobile-directory__choose { border:0; background:var(--q-blue-default); color:var(--q-ink-on-brand); }
|
|
161
|
+
.mobile-directory button:disabled { opacity:.5; }
|
|
162
|
+
</style>
|