@tano.page/workbench 0.15.0 → 0.16.0
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/package.json +35 -14
- package/src/App.vue +68 -797
- package/src/assistant/agent-identities.ts +1 -97
- package/src/assistant/agent-task-context.ts +1 -54
- package/src/assistant/attachments.ts +1 -1
- package/src/assistant/completion.ts +1 -61
- package/src/assistant/components/AssistantPanel.vue +1 -1
- package/src/assistant/connection-actions.ts +237 -0
- package/src/assistant/document-mentions.ts +1 -33
- package/src/assistant/engine.ts +1 -585
- package/src/assistant/execution.ts +6 -33
- package/src/assistant/hash.ts +1 -4
- package/src/assistant/language.ts +10 -37
- package/src/assistant/plugin-bridge-builder.ts +146 -0
- package/src/assistant/prompts.ts +1 -65
- package/src/assistant/proposal-actions.ts +336 -0
- package/src/assistant/store.ts +87 -554
- package/src/assistant/structures.ts +1 -157
- package/src/assistant/tasks.ts +8 -94
- package/src/assistant/tool-rules.ts +1 -7
- package/src/composables/use-workbench-help.ts +177 -0
- package/src/composables/use-workbench-lifecycle.ts +249 -0
- package/src/composables/use-workbench-settings.ts +185 -0
- package/src/composables/use-workbench-shortcuts.ts +37 -1022
- package/src/composables/use-workbench-views.ts +325 -0
- package/src/documents/components/DocumentActionMenu.vue +279 -0
- package/src/documents/components/DocumentInspector.vue +168 -0
- package/src/documents/components/DocumentPane.vue +482 -0
- package/src/documents/description-merge.ts +1 -9
- package/src/files/components/FileMetadataPanel.vue +49 -15
- package/src/i18n/locale-catalogs.ts +7 -6
- package/src/i18n/locale-registry.ts +8 -6
- package/src/i18n/locales/de-DE.json +23 -1
- package/src/i18n/locales/en-US.json +23 -1
- package/src/i18n/locales/es-ES.json +23 -1
- package/src/i18n/locales/ja-JP.json +23 -1
- package/src/i18n/locales/zh-TW.json +23 -1
- package/src/mail/components/MailAccountDialog.vue +1 -0
- package/src/mail/components/MailComposerDialog.vue +1 -0
- package/src/mail/components/MailWorkspaceView.vue +1 -0
- package/src/mail/components/SidebarMail.vue +1 -0
- package/src/objects/content-references.ts +6 -56
- package/src/objects/wiki-links.ts +1 -48
- package/src/objects/workspace-objects.ts +2 -3
- package/src/plans/calendar.ts +2 -2
- package/src/plans/components/CalendarAgendaView.vue +165 -0
- package/src/plans/components/CalendarFilterBar.vue +128 -0
- package/src/plans/components/CalendarMonthView.vue +224 -0
- package/src/plans/components/CalendarQuickCreateDialog.vue +269 -0
- package/src/plans/components/CalendarTimelineView.vue +517 -0
- package/src/plans/components/CalendarTopbarControls.vue +101 -0
- package/src/plans/components/CalendarView.vue +162 -2106
- package/src/plans/components/CalendarYearView.vue +138 -0
- package/src/plans/components/PlanConnectionsDialog.vue +1 -1
- package/src/plans/components/calendar-shared.css +192 -0
- package/src/plans/composables/use-calendar-interactions.ts +396 -0
- package/src/plans/composables/use-calendar-scroll.ts +420 -0
- package/src/plugins/components/PluginDetailPage.vue +10 -6
- package/src/plugins/components/PluginDeveloperArea.vue +192 -0
- package/src/plugins/components/PluginExplorer.vue +6 -4
- package/src/plugins/components/PluginImportDialog.vue +1 -1
- package/src/plugins/components/PluginInstaller.vue +269 -178
- package/src/plugins/components/PluginMaintenance.vue +37 -49
- package/src/plugins/components/PluginRepositoryStorage.vue +4 -2
- package/src/plugins/components/PluginSettingsForm.vue +2 -1
- package/src/plugins/components/PluginsTabPage.vue +61 -0
- package/src/plugins/components/plugin-center.css +5 -0
- package/src/plugins/data.ts +9 -86
- package/src/plugins/editor-plugin-adapters.ts +169 -0
- package/src/plugins/plugin-data.ts +2 -3
- package/src/plugins/plugin-rpc-router.ts +558 -0
- package/src/plugins/plugin-sdk.ts +1 -260
- package/src/plugins/plugin-ui-dialogs.ts +167 -0
- package/src/plugins/queries.ts +1 -75
- package/src/plugins/view-header.ts +2 -7
- package/src/runtime.ts +3 -2
- package/src/settings/components/SettingsPanel.vue +8 -3
- package/src/settings/components/WorkbenchSettings.vue +20 -7
- package/src/settings/components/settings-context.ts +1 -1
- package/src/settings/settings-tab.ts +1 -0
- package/src/shell/command-palette.ts +3 -3
- package/src/shell/components/EditorToolbar.vue +8 -9
- package/src/shell/components/EditorTools.vue +1 -5
- package/src/shell/components/PaneTopbar.vue +393 -0
- package/src/shell/components/SelectionToolbar.vue +0 -2
- package/src/shell/components/WorkbenchContextMenus.vue +37 -26
- package/src/shell/components/WorkbenchModals.vue +22 -18
- package/src/shell/components/WorkbenchPanes.vue +358 -1512
- package/src/shell/components/WorkbenchSidebar.vue +486 -0
- package/src/shell/pane-registry.ts +69 -0
- package/src/shell/use-surface-dismissal.ts +219 -0
- package/src/shell/use-workbench-commands.ts +599 -0
- package/src/shell/use-workbench-keybindings.ts +337 -0
- package/src/shell/use-workbench.ts +488 -1081
- package/src/shell/workbench-context.ts +30 -3
- package/src/stores/workspace-document-io.ts +807 -0
- package/src/stores/workspace-file-ops.ts +1 -1
- package/src/stores/workspace-knowledge.ts +1 -1
- package/src/stores/workspace-lifecycle.ts +459 -0
- package/src/stores/workspace-plugins-state.ts +71 -599
- package/src/stores/workspace-session.ts +287 -0
- package/src/stores/workspace-tabs-layout.ts +1 -1
- package/src/stores/workspace-types.ts +50 -0
- package/src/stores/workspace.ts +163 -1345
- package/src/styles.css +0 -1
- package/src/tabs/components/DesktopTabs.vue +19 -11
- package/src/windows/AuxiliaryWindows.vue +2 -2
- package/src/windows/use-window-event-bridge.ts +152 -0
- package/src/workspace/components/TemplateLibrary.vue +1 -1
- package/src/workspace/components/WorkspaceIconPicker.vue +5 -4
- package/src/workspace/components/WorkspacePickerMenu.vue +317 -0
- package/src/assistant/locales/de-DE.json +0 -129
- package/src/assistant/locales/en-US.json +0 -129
- package/src/assistant/locales/es-ES.json +0 -129
- package/src/assistant/locales/ja-JP.json +0 -129
- package/src/assistant/locales/zh-CN.json +0 -129
- package/src/assistant/locales/zh-TW.json +0 -129
- package/src/assistant/task-prompts.json +0 -39
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import { computed, onUnmounted, ref, type ComputedRef, type Ref } from 'vue';
|
|
2
|
+
import { isPlanCompletionLocked, withPlanCompleted, type WorkspaceObject } from '@tano/protocol';
|
|
3
|
+
import { t, uiLocale } from '../../i18n/i18n';
|
|
4
|
+
import type { ObjectRecord } from '../../objects/workspace-objects';
|
|
5
|
+
import type { usePlanStore } from '../../stores/plans';
|
|
6
|
+
import {
|
|
7
|
+
hasEventTime,
|
|
8
|
+
isCheckableEvent,
|
|
9
|
+
isEventCompleted,
|
|
10
|
+
isEventOverdue,
|
|
11
|
+
localDayKey,
|
|
12
|
+
type CalendarDayEntry,
|
|
13
|
+
} from '../calendar';
|
|
14
|
+
import {
|
|
15
|
+
formatMinutesLabel,
|
|
16
|
+
MIN_DURATION_MINUTES,
|
|
17
|
+
minutesFromOffsetY,
|
|
18
|
+
moveRecordToDay,
|
|
19
|
+
moveRecordToSlot,
|
|
20
|
+
PLAN_DRAG_MIME,
|
|
21
|
+
planDateFromSlot,
|
|
22
|
+
resizeRecordEnd,
|
|
23
|
+
selectionRangeFromOffsets,
|
|
24
|
+
snapMinutes,
|
|
25
|
+
} from '../calendar-interaction';
|
|
26
|
+
import type { TimedEventBlock } from '../timeline-layout';
|
|
27
|
+
import { planKey, planSourceLabel } from '../personal-plans';
|
|
28
|
+
import type { PlanDateValue } from '../plan-date';
|
|
29
|
+
import { isVirtualOccurrence } from '../recurrence';
|
|
30
|
+
import { CALENDAR_HOUR_HEIGHT } from './use-calendar-scroll';
|
|
31
|
+
|
|
32
|
+
export interface SlotPreview {
|
|
33
|
+
dayKey: string;
|
|
34
|
+
top: number;
|
|
35
|
+
height: number;
|
|
36
|
+
label: string;
|
|
37
|
+
startMinutes: number;
|
|
38
|
+
endMinutes: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ResizeState {
|
|
42
|
+
record: ObjectRecord;
|
|
43
|
+
key: string;
|
|
44
|
+
day: Date;
|
|
45
|
+
dayKey: string;
|
|
46
|
+
startY: number;
|
|
47
|
+
startMinutes: number;
|
|
48
|
+
initialEndMinutes: number;
|
|
49
|
+
previewEndMinutes: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface DropTarget {
|
|
53
|
+
zone: 'timeline' | 'day';
|
|
54
|
+
dayKey: string;
|
|
55
|
+
minutes?: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface CalendarInteractionOptions {
|
|
59
|
+
plans: ReturnType<typeof usePlanStore>;
|
|
60
|
+
records: () => ObjectRecord[] | undefined;
|
|
61
|
+
today: ComputedRef<string>;
|
|
62
|
+
canCreate: ComputedRef<boolean>;
|
|
63
|
+
window: Window;
|
|
64
|
+
openQuickCreate: (planDate: PlanDateValue, checkable?: boolean) => void | Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function useCalendarInteractions(options: CalendarInteractionOptions) {
|
|
68
|
+
const { plans, today, canCreate, window } = options;
|
|
69
|
+
const hourHeight = CALENDAR_HOUR_HEIGHT;
|
|
70
|
+
|
|
71
|
+
const pending = ref<string[]>([]);
|
|
72
|
+
const interactionError = ref('');
|
|
73
|
+
|
|
74
|
+
function canEditRecord(record: ObjectRecord) {
|
|
75
|
+
if (isVirtualOccurrence(record)) return false;
|
|
76
|
+
return typeof plans.canEdit === 'function' ? plans.canEdit(record) : false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function canDragRecord(record: ObjectRecord) {
|
|
80
|
+
return (
|
|
81
|
+
canEditRecord(record) &&
|
|
82
|
+
typeof plans.update === 'function' &&
|
|
83
|
+
!pending.value.includes(planKey(record))
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function canToggleComplete(record: ObjectRecord) {
|
|
88
|
+
return (
|
|
89
|
+
isCheckableEvent(record) &&
|
|
90
|
+
!isPlanCompletionLocked(record.object) &&
|
|
91
|
+
canEditRecord(record) &&
|
|
92
|
+
typeof plans.update === 'function' &&
|
|
93
|
+
!pending.value.includes(planKey(record))
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function updateRecordObject(record: ObjectRecord, next: WorkspaceObject) {
|
|
98
|
+
const key = planKey(record);
|
|
99
|
+
if (!canEditRecord(record) || typeof plans.update !== 'function' || pending.value.includes(key)) return;
|
|
100
|
+
pending.value.push(key);
|
|
101
|
+
interactionError.value = '';
|
|
102
|
+
try {
|
|
103
|
+
await plans.update(record, next);
|
|
104
|
+
} catch (reason) {
|
|
105
|
+
interactionError.value = String(reason);
|
|
106
|
+
} finally {
|
|
107
|
+
pending.value = pending.value.filter((id) => id !== key);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function toggleComplete(record: ObjectRecord) {
|
|
112
|
+
if (!canToggleComplete(record)) return;
|
|
113
|
+
return updateRecordObject(record, withPlanCompleted(record.object, !isEventCompleted(record)));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// --- Timeline Slot Selection (Click / Drag-to-Create) ---
|
|
117
|
+
interface SlotSelection {
|
|
118
|
+
day: Date;
|
|
119
|
+
dayKey: string;
|
|
120
|
+
anchorY: number;
|
|
121
|
+
currentY: number;
|
|
122
|
+
column: HTMLElement;
|
|
123
|
+
}
|
|
124
|
+
const slotSelect = ref<SlotSelection>();
|
|
125
|
+
const slotPreview: ComputedRef<SlotPreview | undefined> = computed(() => {
|
|
126
|
+
if (!slotSelect.value) return undefined;
|
|
127
|
+
const range = selectionRangeFromOffsets(slotSelect.value.anchorY, slotSelect.value.currentY, hourHeight);
|
|
128
|
+
return {
|
|
129
|
+
dayKey: slotSelect.value.dayKey,
|
|
130
|
+
top: (range.startMinutes / 60) * hourHeight,
|
|
131
|
+
height: Math.max(22, ((range.endMinutes - range.startMinutes) / 60) * hourHeight),
|
|
132
|
+
label: `${formatMinutesLabel(range.startMinutes)} – ${formatMinutesLabel(range.endMinutes)}`,
|
|
133
|
+
...range,
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
function startSlotSelection(day: Date, event: PointerEvent) {
|
|
138
|
+
if (event.button !== 0 || !canCreate.value || event.target !== event.currentTarget || resizing.value) return;
|
|
139
|
+
const column = event.currentTarget as HTMLElement;
|
|
140
|
+
const rect = column.getBoundingClientRect();
|
|
141
|
+
const y = Math.max(0, Math.min(rect.height || 24 * hourHeight, event.clientY - rect.top));
|
|
142
|
+
slotSelect.value = { day, dayKey: localDayKey(day), anchorY: y, currentY: y, column };
|
|
143
|
+
window.addEventListener('pointermove', moveSlotSelection);
|
|
144
|
+
window.addEventListener('pointerup', endSlotSelection);
|
|
145
|
+
window.addEventListener('pointercancel', cancelSlotSelection);
|
|
146
|
+
}
|
|
147
|
+
function moveSlotSelection(event: PointerEvent) {
|
|
148
|
+
if (!slotSelect.value) return;
|
|
149
|
+
const rect = slotSelect.value.column.getBoundingClientRect();
|
|
150
|
+
slotSelect.value.currentY = Math.max(0, Math.min(rect.height || 24 * hourHeight, event.clientY - rect.top));
|
|
151
|
+
}
|
|
152
|
+
function cleanupSlotListeners() {
|
|
153
|
+
window.removeEventListener('pointermove', moveSlotSelection);
|
|
154
|
+
window.removeEventListener('pointerup', endSlotSelection);
|
|
155
|
+
window.removeEventListener('pointercancel', cancelSlotSelection);
|
|
156
|
+
}
|
|
157
|
+
function cancelSlotSelection() {
|
|
158
|
+
cleanupSlotListeners();
|
|
159
|
+
slotSelect.value = undefined;
|
|
160
|
+
}
|
|
161
|
+
function endSlotSelection() {
|
|
162
|
+
const current = slotSelect.value;
|
|
163
|
+
const preview = slotPreview.value;
|
|
164
|
+
cleanupSlotListeners();
|
|
165
|
+
slotSelect.value = undefined;
|
|
166
|
+
if (!current || !preview) return;
|
|
167
|
+
void options.openQuickCreate(planDateFromSlot(current.day, preview.startMinutes, preview.endMinutes), false);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// --- Bottom-Edge Resize ---
|
|
171
|
+
const resizing = ref<ResizeState>();
|
|
172
|
+
|
|
173
|
+
function startResize(item: TimedEventBlock, day: Date, event: PointerEvent) {
|
|
174
|
+
if (event.button !== 0 || !canDragRecord(item.record) || item.point) return;
|
|
175
|
+
const dayStart = new Date(day.getFullYear(), day.getMonth(), day.getDate()).getTime();
|
|
176
|
+
const startMinutes = Math.max(0, Math.round((item.visibleStart - dayStart) / 60_000));
|
|
177
|
+
const initialEndMinutes = Math.max(
|
|
178
|
+
startMinutes + MIN_DURATION_MINUTES,
|
|
179
|
+
Math.round((item.visibleEnd - dayStart) / 60_000),
|
|
180
|
+
);
|
|
181
|
+
resizing.value = {
|
|
182
|
+
record: item.record,
|
|
183
|
+
key: planKey(item.record),
|
|
184
|
+
day,
|
|
185
|
+
dayKey: localDayKey(day),
|
|
186
|
+
startY: event.clientY,
|
|
187
|
+
startMinutes,
|
|
188
|
+
initialEndMinutes,
|
|
189
|
+
previewEndMinutes: initialEndMinutes,
|
|
190
|
+
};
|
|
191
|
+
window.addEventListener('pointermove', moveResize);
|
|
192
|
+
window.addEventListener('pointerup', endResize);
|
|
193
|
+
window.addEventListener('pointercancel', cancelResize);
|
|
194
|
+
}
|
|
195
|
+
function moveResize(event: PointerEvent) {
|
|
196
|
+
if (!resizing.value) return;
|
|
197
|
+
const deltaMinutes = ((event.clientY - resizing.value.startY) / hourHeight) * 60;
|
|
198
|
+
resizing.value.previewEndMinutes = Math.max(
|
|
199
|
+
resizing.value.startMinutes + MIN_DURATION_MINUTES,
|
|
200
|
+
Math.min(24 * 60, snapMinutes(resizing.value.initialEndMinutes + deltaMinutes)),
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
function cleanupResizeListeners() {
|
|
204
|
+
window.removeEventListener('pointermove', moveResize);
|
|
205
|
+
window.removeEventListener('pointerup', endResize);
|
|
206
|
+
window.removeEventListener('pointercancel', cancelResize);
|
|
207
|
+
}
|
|
208
|
+
function cancelResize() {
|
|
209
|
+
cleanupResizeListeners();
|
|
210
|
+
resizing.value = undefined;
|
|
211
|
+
}
|
|
212
|
+
function endResize() {
|
|
213
|
+
const state = resizing.value;
|
|
214
|
+
cleanupResizeListeners();
|
|
215
|
+
resizing.value = undefined;
|
|
216
|
+
if (!state || state.previewEndMinutes === state.initialEndMinutes) return;
|
|
217
|
+
const next = resizeRecordEnd(state.record.object, state.day, state.previewEndMinutes);
|
|
218
|
+
void updateRecordObject(state.record, next);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// --- Drag Move & Sidebar Drop Timeblocking ---
|
|
222
|
+
const draggingKey = ref<string>();
|
|
223
|
+
const dropTarget = ref<DropTarget>();
|
|
224
|
+
|
|
225
|
+
function allEditablePool(): readonly ObjectRecord[] {
|
|
226
|
+
const fromStore = typeof plans.recordsFor === 'function' ? plans.recordsFor('all') : [];
|
|
227
|
+
if (fromStore.length) return fromStore;
|
|
228
|
+
return options.records() ?? plans.records;
|
|
229
|
+
}
|
|
230
|
+
function resolveDraggedRecord(event: DragEvent): ObjectRecord | undefined {
|
|
231
|
+
const key = event.dataTransfer?.getData(PLAN_DRAG_MIME) || draggingKey.value;
|
|
232
|
+
if (!key) return undefined;
|
|
233
|
+
return allEditablePool().find((record) => planKey(record) === key);
|
|
234
|
+
}
|
|
235
|
+
function hasPlanDrag(event: DragEvent) {
|
|
236
|
+
const types = event.dataTransfer?.types;
|
|
237
|
+
return Boolean(draggingKey.value || (types && [...types].includes(PLAN_DRAG_MIME)));
|
|
238
|
+
}
|
|
239
|
+
function onEventDragStart(record: ObjectRecord, event: DragEvent) {
|
|
240
|
+
if (!canDragRecord(record) || !event.dataTransfer) {
|
|
241
|
+
event.preventDefault();
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const key = planKey(record);
|
|
245
|
+
draggingKey.value = key;
|
|
246
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
247
|
+
event.dataTransfer.setData(PLAN_DRAG_MIME, key);
|
|
248
|
+
event.dataTransfer.setData('text/plain', record.object.name);
|
|
249
|
+
}
|
|
250
|
+
function onEventDragEnd() {
|
|
251
|
+
draggingKey.value = undefined;
|
|
252
|
+
dropTarget.value = undefined;
|
|
253
|
+
}
|
|
254
|
+
function onTimelineDragOver(day: Date, event: DragEvent) {
|
|
255
|
+
if (!hasPlanDrag(event)) return;
|
|
256
|
+
event.preventDefault();
|
|
257
|
+
if (event.dataTransfer) event.dataTransfer.dropEffect = 'move';
|
|
258
|
+
const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
|
|
259
|
+
const minutes = minutesFromOffsetY(event.clientY - rect.top, hourHeight);
|
|
260
|
+
dropTarget.value = { zone: 'timeline', dayKey: localDayKey(day), minutes };
|
|
261
|
+
}
|
|
262
|
+
function onTimelineDrop(day: Date, event: DragEvent) {
|
|
263
|
+
const record = resolveDraggedRecord(event);
|
|
264
|
+
const rect = (event.currentTarget as HTMLElement).getBoundingClientRect();
|
|
265
|
+
const minutes = minutesFromOffsetY(event.clientY - rect.top, hourHeight);
|
|
266
|
+
draggingKey.value = undefined;
|
|
267
|
+
dropTarget.value = undefined;
|
|
268
|
+
if (!record || !canDragRecord(record)) return;
|
|
269
|
+
const next = moveRecordToSlot(record.object, day, minutes);
|
|
270
|
+
void updateRecordObject(record, next);
|
|
271
|
+
}
|
|
272
|
+
function onDayDragOver(day: Date, event: DragEvent) {
|
|
273
|
+
if (!hasPlanDrag(event)) return;
|
|
274
|
+
event.preventDefault();
|
|
275
|
+
if (event.dataTransfer) event.dataTransfer.dropEffect = 'move';
|
|
276
|
+
dropTarget.value = { zone: 'day', dayKey: localDayKey(day) };
|
|
277
|
+
}
|
|
278
|
+
function onDayDrop(day: Date, event: DragEvent) {
|
|
279
|
+
const record = resolveDraggedRecord(event);
|
|
280
|
+
draggingKey.value = undefined;
|
|
281
|
+
dropTarget.value = undefined;
|
|
282
|
+
if (!record || !canDragRecord(record)) return;
|
|
283
|
+
const next = moveRecordToDay(record.object, day);
|
|
284
|
+
void updateRecordObject(record, next);
|
|
285
|
+
}
|
|
286
|
+
function onDragLeave(event: DragEvent) {
|
|
287
|
+
const related = event.relatedTarget as Node | null;
|
|
288
|
+
if (!related || !(event.currentTarget as HTMLElement).contains(related)) {
|
|
289
|
+
dropTarget.value = undefined;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// --- Shared Presentation Helpers ---
|
|
294
|
+
function itemClasses(record: ObjectRecord, kind?: CalendarDayEntry['kind']) {
|
|
295
|
+
const checkable = isCheckableEvent(record);
|
|
296
|
+
const completed = isEventCompleted(record);
|
|
297
|
+
const overdue = isEventOverdue(record, today.value);
|
|
298
|
+
return {
|
|
299
|
+
'is-task': checkable,
|
|
300
|
+
'is-schedule': !checkable,
|
|
301
|
+
'is-completed': completed,
|
|
302
|
+
'is-overdue': overdue,
|
|
303
|
+
'is-due': kind === 'due',
|
|
304
|
+
'is-timed': kind === 'timed',
|
|
305
|
+
'is-personal': record.source?.scope === 'personal',
|
|
306
|
+
'is-synced': !!record.object.properties.syncConnection,
|
|
307
|
+
'is-draggable': kind !== 'due' && canDragRecord(record),
|
|
308
|
+
'is-dragging': draggingKey.value === planKey(record),
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function clockLabel(value: unknown) {
|
|
313
|
+
return new Date(String(value)).toLocaleTimeString(uiLocale.value, {
|
|
314
|
+
hour: '2-digit',
|
|
315
|
+
minute: '2-digit',
|
|
316
|
+
hour12: false,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function entryTime(entry: CalendarDayEntry) {
|
|
321
|
+
if (entry.kind === 'due') return t('截止');
|
|
322
|
+
const { record } = entry;
|
|
323
|
+
if (record.object.properties.allDay === true) return t('全天');
|
|
324
|
+
if (!hasEventTime(record)) return t('仅日期');
|
|
325
|
+
return new Date(String(record.object.properties.start)).toLocaleTimeString(uiLocale.value, {
|
|
326
|
+
hour: '2-digit',
|
|
327
|
+
minute: '2-digit',
|
|
328
|
+
hour12: false,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function entryTooltip(entry: CalendarDayEntry, time = entryTime(entry)) {
|
|
333
|
+
const suffix = isEventOverdue(entry.record, today.value)
|
|
334
|
+
? ` · ${t('逾期')}`
|
|
335
|
+
: isEventCompleted(entry.record)
|
|
336
|
+
? t(' · 已完成')
|
|
337
|
+
: '';
|
|
338
|
+
return `${entry.record.object.name} · ${time} · ${planSourceLabel(entry.record)}${suffix}`;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function timedEventStyle(item: TimedEventBlock, day: Date) {
|
|
342
|
+
const widthPct = 100 / item.columnCount;
|
|
343
|
+
const leftPct = item.column * widthPct;
|
|
344
|
+
let height = item.height;
|
|
345
|
+
if (
|
|
346
|
+
resizing.value &&
|
|
347
|
+
resizing.value.key === planKey(item.record) &&
|
|
348
|
+
resizing.value.dayKey === localDayKey(day)
|
|
349
|
+
) {
|
|
350
|
+
height = Math.max(
|
|
351
|
+
22,
|
|
352
|
+
((resizing.value.previewEndMinutes - resizing.value.startMinutes) / 60) * hourHeight,
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
return {
|
|
356
|
+
top: `${item.top}px`,
|
|
357
|
+
height: `${height}px`,
|
|
358
|
+
left: `calc(${leftPct}% + 2px)`,
|
|
359
|
+
width: `calc(${widthPct}% - 4px)`,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
onUnmounted(() => {
|
|
364
|
+
cleanupSlotListeners();
|
|
365
|
+
cleanupResizeListeners();
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
return {
|
|
369
|
+
pending,
|
|
370
|
+
interactionError,
|
|
371
|
+
canEditRecord,
|
|
372
|
+
canDragRecord,
|
|
373
|
+
canToggleComplete,
|
|
374
|
+
toggleComplete,
|
|
375
|
+
slotPreview,
|
|
376
|
+
startSlotSelection,
|
|
377
|
+
resizing: resizing as Ref<ResizeState | undefined>,
|
|
378
|
+
startResize,
|
|
379
|
+
draggingKey,
|
|
380
|
+
dropTarget,
|
|
381
|
+
onEventDragStart,
|
|
382
|
+
onEventDragEnd,
|
|
383
|
+
onTimelineDragOver,
|
|
384
|
+
onTimelineDrop,
|
|
385
|
+
onDayDragOver,
|
|
386
|
+
onDayDrop,
|
|
387
|
+
onDragLeave,
|
|
388
|
+
itemClasses,
|
|
389
|
+
clockLabel,
|
|
390
|
+
entryTime,
|
|
391
|
+
entryTooltip,
|
|
392
|
+
timedEventStyle,
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export type CalendarInteractions = ReturnType<typeof useCalendarInteractions>;
|