@tano.page/workbench 0.14.0 → 0.15.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.
Files changed (177) hide show
  1. package/package.json +21 -8
  2. package/src/App.vue +76 -17
  3. package/src/appearance/appearance.ts +14 -4
  4. package/src/appearance/components/ThemePresetPreview.vue +52 -8
  5. package/src/appearance/interface-font.ts +99 -0
  6. package/src/appearance/theme.ts +26 -10
  7. package/src/appearance/use-interface-font.ts +30 -0
  8. package/src/assets/mail-provider-icons/NOTICE.txt +27 -0
  9. package/src/assets/mail-provider-icons/aliyun-mail.svg +3 -0
  10. package/src/assets/mail-provider-icons/gmail.svg +1 -0
  11. package/src/assets/mail-provider-icons/icloud.svg +12 -0
  12. package/src/assets/mail-provider-icons/netease-126.svg +5 -0
  13. package/src/assets/mail-provider-icons/netease-163.svg +5 -0
  14. package/src/assets/mail-provider-icons/qq.svg +9 -0
  15. package/src/assets/mail-provider-icons/tencent-exmail.svg +4 -0
  16. package/src/assistant/components/AssistantChangeList.vue +98 -21
  17. package/src/assistant/components/AssistantPanel.vue +424 -7
  18. package/src/assistant/components/PluginToolProposalCard.vue +235 -0
  19. package/src/assistant/engine.ts +56 -3
  20. package/src/assistant/files.ts +5 -13
  21. package/src/assistant/inbox.ts +1 -148
  22. package/src/assistant/locales/de-DE.json +4 -1
  23. package/src/assistant/locales/en-US.json +4 -1
  24. package/src/assistant/locales/es-ES.json +4 -1
  25. package/src/assistant/locales/ja-JP.json +4 -1
  26. package/src/assistant/locales/zh-CN.json +4 -1
  27. package/src/assistant/locales/zh-TW.json +4 -1
  28. package/src/assistant/mention-autocomplete.ts +69 -0
  29. package/src/assistant/prompts.ts +7 -0
  30. package/src/assistant/results.ts +20 -86
  31. package/src/assistant/store.ts +319 -12
  32. package/src/assistant/structures.ts +7 -5
  33. package/src/assistant/tasks.ts +3 -5
  34. package/src/assistant/workspace-bridge.ts +1 -1
  35. package/src/composables/use-document-actions.ts +38 -20
  36. package/src/composables/use-file-tree-controller.ts +7 -12
  37. package/src/composables/use-workbench-history.ts +2 -4
  38. package/src/composables/use-workbench-modals.ts +6 -1
  39. package/src/composables/use-workbench-outline.ts +0 -5
  40. package/src/composables/use-workbench-shortcuts.ts +26 -22
  41. package/src/data-tables/data-tables.ts +1 -2
  42. package/src/documents/components/DocumentHistoryPanel.vue +3 -1
  43. package/src/features.ts +1 -0
  44. package/src/fonts/Inter-Latin-Italic.woff2 +0 -0
  45. package/src/fonts/Inter-Latin.woff2 +0 -0
  46. package/src/fonts/TanoUISansSC-Bold.woff2 +0 -0
  47. package/src/fonts/TanoUISansSC-Medium.woff2 +0 -0
  48. package/src/fonts/TanoUISansSC-Regular.woff2 +0 -0
  49. package/src/help/help-milestones.ts +3 -5
  50. package/src/i18n/locales/de-DE.json +349 -3
  51. package/src/i18n/locales/en-US.json +349 -2
  52. package/src/i18n/locales/es-ES.json +349 -3
  53. package/src/i18n/locales/ja-JP.json +348 -2
  54. package/src/i18n/locales/zh-TW.json +348 -2
  55. package/src/mail/components/MailAccountDialog.vue +449 -0
  56. package/src/mail/components/MailComposerDialog.vue +325 -0
  57. package/src/mail/components/MailProviderIcon.vue +30 -0
  58. package/src/mail/components/MailWorkspaceView.vue +820 -0
  59. package/src/mail/components/SidebarMail.vue +133 -0
  60. package/src/mail/mail-avatar.ts +17 -0
  61. package/src/mail/mail-bridge.ts +68 -0
  62. package/src/mail/mail-calendar.ts +208 -0
  63. package/src/mail/mail-markdown.ts +195 -0
  64. package/src/mail/types.ts +226 -0
  65. package/src/objects/components/ObjectDetailModal.vue +1001 -0
  66. package/src/objects/workspace-objects.ts +1 -1
  67. package/src/plan-sync/types.ts +6 -3
  68. package/src/plans/calendar-interaction.ts +194 -0
  69. package/src/plans/calendar.ts +63 -7
  70. package/src/plans/components/CalendarDayPopover.vue +172 -39
  71. package/src/plans/components/CalendarView.vue +1736 -276
  72. package/src/plans/components/PlanArchiveDialog.vue +295 -0
  73. package/src/plans/components/PlanDateField.vue +6 -4
  74. package/src/plans/components/PlanDetailPanel.vue +227 -32
  75. package/src/plans/components/PlanEventList.vue +16 -4
  76. package/src/plans/components/SidebarPlan.vue +22 -15
  77. package/src/plans/components/TaskRepeatControls.vue +169 -30
  78. package/src/plans/local-reminders.ts +149 -0
  79. package/src/plans/personal-plans.ts +10 -1
  80. package/src/plans/plan-date.ts +8 -1
  81. package/src/plans/plan-migration.ts +95 -0
  82. package/src/plans/recurrence.ts +95 -0
  83. package/src/plans/task-repeat.ts +8 -8
  84. package/src/plans/timeline-layout.ts +92 -0
  85. package/src/plugins/assistant-bridge.ts +520 -0
  86. package/src/plugins/attachment-reader.ts +3 -1
  87. package/src/plugins/cache-storage.ts +42 -2
  88. package/src/plugins/components/PluginAutomations.vue +3 -3
  89. package/src/plugins/components/PluginCatalogBrowser.vue +17 -8
  90. package/src/plugins/components/PluginChangeSummary.vue +16 -3
  91. package/src/plugins/components/PluginConnections.vue +1 -1
  92. package/src/plugins/components/PluginCustomView.vue +2 -2
  93. package/src/plugins/components/PluginDetailPage.vue +129 -54
  94. package/src/plugins/components/PluginDocumentSlot.vue +63 -0
  95. package/src/plugins/components/PluginExplorer.vue +15 -21
  96. package/src/plugins/components/PluginImportDialog.vue +410 -0
  97. package/src/plugins/components/PluginInstaller.vue +39 -145
  98. package/src/plugins/components/PluginListItem.vue +3 -0
  99. package/src/plugins/components/PluginMaintenance.vue +21 -6
  100. package/src/plugins/components/PluginRuntimePanel.vue +3 -3
  101. package/src/plugins/components/PluginSettingsForm.vue +111 -0
  102. package/src/plugins/components/PluginStatusBar.vue +161 -0
  103. package/src/plugins/components/PluginSurface.vue +18 -6
  104. package/src/plugins/components/PluginUiDialog.vue +452 -0
  105. package/src/plugins/excalidraw/bundle.tano-plugin.json +1 -1
  106. package/src/plugins/excalidraw/manifest.json +12 -1
  107. package/src/plugins/host.ts +662 -43
  108. package/src/plugins/native.ts +2 -10
  109. package/src/plugins/overlay-mapping.ts +125 -0
  110. package/src/plugins/packages.ts +73 -1
  111. package/src/plugins/plugin-permissions.ts +57 -0
  112. package/src/plugins/plugin-sdk.ts +174 -8
  113. package/src/plugins/policy.ts +53 -3
  114. package/src/plugins/presentation-preview/bundle.tano-plugin.json +1 -1
  115. package/src/plugins/presentation-preview/manifest.json +2 -1
  116. package/src/plugins/queries.ts +3 -1
  117. package/src/plugins/sandbox.ts +15 -1
  118. package/src/plugins/use-plugin-actions.ts +67 -20
  119. package/src/plugins/user-plugins.ts +254 -0
  120. package/src/plugins/word-preview/bundle.tano-plugin.json +1 -1
  121. package/src/plugins/word-preview/manifest.json +13 -1
  122. package/src/plugins/workbench.ts +175 -2
  123. package/src/plugins/worker.js +105 -8
  124. package/src/plugins/workspace-plugin-runtime.ts +23 -7
  125. package/src/plugins/workspace-plugins.ts +212 -21
  126. package/src/runtime.ts +101 -3
  127. package/src/settings/components/SettingsAppearancePage.vue +46 -0
  128. package/src/settings/components/SettingsDocumentsPage.vue +0 -1
  129. package/src/settings/components/settings-search.ts +2 -3
  130. package/src/shell/components/SidebarNavigation.vue +22 -2
  131. package/src/shell/components/WorkbenchContextMenus.vue +21 -8
  132. package/src/shell/components/WorkbenchModals.vue +27 -46
  133. package/src/shell/components/WorkbenchPanes.vue +267 -84
  134. package/src/shell/components/WorkspaceBreadcrumb.vue +6 -14
  135. package/src/shell/components/WorkspaceViewSwitcher.vue +12 -7
  136. package/src/shell/use-workbench.ts +116 -145
  137. package/src/shell/workbench-async-components.ts +14 -5
  138. package/src/stores/mail.ts +414 -0
  139. package/src/stores/plan-sync.ts +2 -1
  140. package/src/stores/plans.ts +2 -9
  141. package/src/stores/workspace-knowledge.ts +1 -113
  142. package/src/stores/workspace-plugins-state.ts +537 -14
  143. package/src/stores/workspace-tabs-layout.ts +5 -43
  144. package/src/stores/workspace.ts +69 -66
  145. package/src/styles/agent-diff-modals.css +0 -7
  146. package/src/styles/dark-theme.css +3 -3
  147. package/src/styles/inspector.css +0 -59
  148. package/src/styles/layout-themes.css +346 -0
  149. package/src/styles/mail.css +1568 -0
  150. package/src/styles/mobile.css +2 -2
  151. package/src/styles/recent-and-media.css +0 -17
  152. package/src/styles/theme-contract.css +3 -3
  153. package/src/styles/workbench-shell.css +110 -17
  154. package/src/styles/workspace-states.css +9 -33
  155. package/src/styles.css +1 -1
  156. package/src/tabs/components/DesktopTabs.vue +0 -3
  157. package/src/tabs/components/NewTabPicker.vue +10 -4
  158. package/src/tabs/tab-label.ts +0 -1
  159. package/src/workspace/components/WorkspaceGeneralSettings.vue +0 -13
  160. package/src/workspace/components/WorkspaceIconPicker.vue +28 -6
  161. package/src/workspace/workspace-comments.ts +11 -151
  162. package/src/workspace/workspace-welcome.ts +1 -1
  163. package/src/documents/components/FormulaMenu.vue +0 -50
  164. package/src/files/components/FileDatabasePage.vue +0 -152
  165. package/src/files/components/FolderHomeIcon.vue +0 -12
  166. package/src/objects/components/ObjectDatabasePage.vue +0 -100
  167. package/src/objects/components/ObjectPanel.vue +0 -554
  168. package/src/plans/components/PersonalPlanDialog.vue +0 -105
  169. package/src/shell/components/WorkspaceViewPage.vue +0 -127
  170. package/src/shell/components/WorkspaceViewTab.vue +0 -24
  171. package/src/styles/object-panel.css +0 -163
  172. package/src/workspace/components/GitInspectionPanel.vue +0 -35
  173. package/src/workspace/components/WorkspaceSyncPanel.vue +0 -50
  174. package/src/workspace/welcome-slogans.ts +0 -11
  175. package/src/workspace/workspace-git.ts +0 -35
  176. package/src/workspace/workspace-sync.ts +0 -46
  177. package/src/workspace/workspace-views.ts +0 -48
@@ -26,7 +26,7 @@ export async function loadObjects(adapter: Pick<ObjectStorage, 'read'>, workspac
26
26
  const snapshot = await adapter.read(file.path);
27
27
  const object = parseObject(snapshot.content);
28
28
  const definition = objectTypeRegistry.get(object.type);
29
- if (definition && !definition.retired) {
29
+ if (definition) {
30
30
  try {
31
31
  validateObjectProperties(object.type, object.properties);
32
32
  } catch (error) {
@@ -1,3 +1,4 @@
1
+ import { isPlanCompleted } from '@tano/protocol';
1
2
  import type { ObjectRecord } from '../objects/workspace-objects';
2
3
  export type SyncKind = 'calendar' | 'todo';
3
4
  export type ProviderId = 'google' | 'icloud' | 'feishu' | 'caldav' | 'todoist' | 'microsoft';
@@ -49,10 +50,12 @@ export const sameValue = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.
49
50
  export function localValue(record: ObjectRecord, kind: SyncKind): ItemValue {
50
51
  const p = record.object.properties;
51
52
  if (kind === 'todo') return { name: record.object.name, description: record.object.description, archived: record.object.archived,
52
- completed: p.completed === true || p.status === 'done' || p.status === 'completed', ...(typeof p.due === 'string' && p.due ? { date: p.due } : {}) };
53
+ completed: isPlanCompleted(record.object), ...(typeof p.due === 'string' && p.due ? { date: p.due } : {}) };
53
54
  if (typeof p.date === 'string' && p.date && !p.start) {
54
- const start = new Date(`${p.date}T00:00:00`), end = new Date(start); end.setDate(end.getDate() + 1);
55
- return { name: record.object.name, description: record.object.description, archived: record.object.archived, start: start.toISOString(), end: end.toISOString(), allDay: true };
55
+ const start = new Date(`${p.date}T00:00:00`);
56
+ const endBase = typeof p.endDate === 'string' && p.endDate >= p.date ? new Date(`${p.endDate}T00:00:00`) : new Date(start);
57
+ endBase.setDate(endBase.getDate() + 1);
58
+ return { name: record.object.name, description: record.object.description, archived: record.object.archived, start: start.toISOString(), end: endBase.toISOString(), allDay: true };
56
59
  }
57
60
  return {
58
61
  name: record.object.name, description: record.object.description, archived: record.object.archived,
@@ -0,0 +1,194 @@
1
+ import type { WorkspaceObject } from '@tano/protocol';
2
+ import { validEventDate, validEventTime } from '@tano/protocol';
3
+ import { localDateTime, localDayKey } from './calendar';
4
+ import type { PlanDateValue } from './plan-date';
5
+
6
+ export const PLAN_DRAG_MIME = 'application/x-tano-plan-key';
7
+ export const SNAP_MINUTES = 15;
8
+ export const MIN_DURATION_MINUTES = 15;
9
+ export const DEFAULT_CLICK_DURATION_MINUTES = 60;
10
+ const DAY_MINUTES = 24 * 60;
11
+
12
+ export function snapMinutes(minutes: number, step = SNAP_MINUTES): number {
13
+ const clamped = Math.max(0, Math.min(DAY_MINUTES, minutes));
14
+ return Math.max(0, Math.min(DAY_MINUTES, Math.round(clamped / step) * step));
15
+ }
16
+
17
+ export function minutesFromOffsetY(offsetY: number, hourHeight: number, step = SNAP_MINUTES): number {
18
+ if (!Number.isFinite(offsetY) || hourHeight <= 0) return 0;
19
+ return snapMinutes((offsetY / hourHeight) * 60, step);
20
+ }
21
+
22
+ export function selectionRangeFromOffsets(
23
+ anchorY: number,
24
+ currentY: number,
25
+ hourHeight: number,
26
+ step = SNAP_MINUTES,
27
+ ): { startMinutes: number; endMinutes: number } {
28
+ if (Math.abs(currentY - anchorY) < 6) {
29
+ const raw = Math.max(0, Math.min(DAY_MINUTES - step, (anchorY / hourHeight) * 60));
30
+ const startMinutes = Math.floor(raw / step) * step;
31
+ const endMinutes = Math.min(DAY_MINUTES, startMinutes + DEFAULT_CLICK_DURATION_MINUTES);
32
+ return { startMinutes, endMinutes };
33
+ }
34
+ const a = minutesFromOffsetY(anchorY, hourHeight, step);
35
+ const b = minutesFromOffsetY(currentY, hourHeight, step);
36
+ const startMinutes = Math.min(a, b);
37
+ const endMinutes = Math.min(DAY_MINUTES, Math.max(startMinutes + 30, Math.max(a, b)));
38
+ if (startMinutes >= DAY_MINUTES) {
39
+ return { startMinutes: DAY_MINUTES - 30, endMinutes: DAY_MINUTES };
40
+ }
41
+ return { startMinutes, endMinutes };
42
+ }
43
+
44
+ export function formatMinutesLabel(minutes: number): string {
45
+ const clamped = Math.max(0, Math.min(DAY_MINUTES, Math.round(minutes)));
46
+ const h = Math.floor(clamped / 60);
47
+ const m = clamped % 60;
48
+ return `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`;
49
+ }
50
+
51
+ export function planDateFromSlot(day: Date, startMinutes: number, endMinutes: number): PlanDateValue {
52
+ const start = new Date(day.getFullYear(), day.getMonth(), day.getDate(), 0, startMinutes);
53
+ const end = new Date(day.getFullYear(), day.getMonth(), day.getDate(), 0, Math.max(startMinutes + MIN_DURATION_MINUTES, endMinutes));
54
+ const startLocal = localDateTime(start);
55
+ return {
56
+ date: startLocal.slice(0, 10),
57
+ time: startLocal.slice(11, 16),
58
+ end: localDateTime(end),
59
+ };
60
+ }
61
+
62
+ export function buildTimedProperties(
63
+ properties: Record<string, unknown>,
64
+ day: Date,
65
+ startMinutes: number,
66
+ endMinutes: number,
67
+ ): Record<string, unknown> {
68
+ const safeStart = Math.max(0, Math.min(DAY_MINUTES - MIN_DURATION_MINUTES, startMinutes));
69
+ const safeEnd = Math.max(safeStart + MIN_DURATION_MINUTES, Math.min(DAY_MINUTES, endMinutes));
70
+ const start = new Date(day.getFullYear(), day.getMonth(), day.getDate(), 0, safeStart);
71
+ const end = new Date(day.getFullYear(), day.getMonth(), day.getDate(), 0, safeEnd);
72
+ const next: Record<string, unknown> = { ...properties };
73
+ delete next.date;
74
+ delete next.endDate;
75
+ delete next.allDay;
76
+ next.start = start.toISOString();
77
+ next.end = end.toISOString();
78
+ return next;
79
+ }
80
+
81
+ function addCalendarDays(dateKey: string, deltaDays: number): string {
82
+ const date = new Date(`${dateKey}T00:00:00`);
83
+ date.setDate(date.getDate() + deltaDays);
84
+ return localDayKey(date);
85
+ }
86
+
87
+ function calendarDayDelta(fromDayKey: string, toDayKey: string): number {
88
+ return Math.round(
89
+ (Date.parse(`${toDayKey}T00:00:00Z`) - Date.parse(`${fromDayKey}T00:00:00Z`)) / 86_400_000,
90
+ );
91
+ }
92
+
93
+ /** Moves an event or task to a target calendar day, preserving its time-of-day duration or span. */
94
+ export function moveRecordToDay<T extends WorkspaceObject>(object: T, targetDay: Date): T {
95
+ const p = object.properties;
96
+ const targetKey = localDayKey(targetDay);
97
+ const next: Record<string, unknown> = { ...p };
98
+
99
+ if (validEventTime(p.start) && validEventTime(p.end)) {
100
+ const startDate = new Date(p.start);
101
+ const endDate = new Date(p.end);
102
+ const delta = calendarDayDelta(localDayKey(startDate), targetKey);
103
+ if (p.allDay === true) {
104
+ const movedStart = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate() + delta);
105
+ const movedEnd = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate() + delta);
106
+ next.start = movedStart.toISOString();
107
+ next.end = movedEnd.toISOString();
108
+ next.allDay = true;
109
+ } else {
110
+ const durationMs = Math.max(0, endDate.getTime() - startDate.getTime());
111
+ const movedStart = new Date(
112
+ targetDay.getFullYear(),
113
+ targetDay.getMonth(),
114
+ targetDay.getDate(),
115
+ startDate.getHours(),
116
+ startDate.getMinutes(),
117
+ startDate.getSeconds(),
118
+ startDate.getMilliseconds(),
119
+ );
120
+ next.start = movedStart.toISOString();
121
+ next.end = new Date(movedStart.getTime() + durationMs).toISOString();
122
+ }
123
+ return { ...object, properties: next };
124
+ }
125
+
126
+ delete next.start;
127
+ delete next.end;
128
+ delete next.allDay;
129
+ if (validEventDate(p.date) && validEventDate(p.endDate)) {
130
+ const delta = calendarDayDelta(p.date, targetKey);
131
+ next.date = targetKey;
132
+ next.endDate = addCalendarDays(p.endDate, delta);
133
+ } else {
134
+ delete next.endDate;
135
+ next.date = targetKey;
136
+ }
137
+ return { ...object, properties: next };
138
+ }
139
+
140
+ /** Moves or timeblocks a record into a specific timed slot on a target day, preserving existing duration if timed. */
141
+ export function moveRecordToSlot<T extends WorkspaceObject>(
142
+ object: T,
143
+ targetDay: Date,
144
+ startMinutes: number,
145
+ fallbackDurationMinutes = DEFAULT_CLICK_DURATION_MINUTES,
146
+ ): T {
147
+ const p = object.properties;
148
+ let durationMinutes = fallbackDurationMinutes;
149
+ if (validEventTime(p.start) && validEventTime(p.end) && p.allDay !== true) {
150
+ const existing = Math.round((Date.parse(p.end) - Date.parse(p.start)) / 60_000);
151
+ if (existing >= MIN_DURATION_MINUTES) durationMinutes = existing;
152
+ else if (existing === 0) durationMinutes = 0;
153
+ }
154
+ const safeStart = Math.max(0, Math.min(DAY_MINUTES - MIN_DURATION_MINUTES, snapMinutes(startMinutes)));
155
+ const start = new Date(targetDay.getFullYear(), targetDay.getMonth(), targetDay.getDate(), 0, safeStart);
156
+ const end = durationMinutes === 0
157
+ ? new Date(start.getTime())
158
+ : new Date(
159
+ targetDay.getFullYear(),
160
+ targetDay.getMonth(),
161
+ targetDay.getDate(),
162
+ 0,
163
+ Math.min(DAY_MINUTES, safeStart + Math.max(MIN_DURATION_MINUTES, durationMinutes)),
164
+ );
165
+ const next: Record<string, unknown> = { ...p };
166
+ delete next.date;
167
+ delete next.endDate;
168
+ delete next.allDay;
169
+ next.start = start.toISOString();
170
+ next.end = end.toISOString();
171
+ return { ...object, properties: next };
172
+ }
173
+
174
+ /** Resizes a timed event's end time on the given day while keeping start intact and >= 15 minutes duration. */
175
+ export function resizeRecordEnd<T extends WorkspaceObject>(
176
+ object: T,
177
+ day: Date,
178
+ newEndMinutes: number,
179
+ ): T {
180
+ const p = object.properties;
181
+ if (!validEventTime(p.start)) return object;
182
+ const startMs = Date.parse(p.start);
183
+ const dayStart = new Date(day.getFullYear(), day.getMonth(), day.getDate()).getTime();
184
+ const clampedMinutes = Math.max(MIN_DURATION_MINUTES, Math.min(DAY_MINUTES, snapMinutes(newEndMinutes)));
185
+ const targetEndMs = dayStart + clampedMinutes * 60_000;
186
+ const safeEndMs = Math.max(startMs + MIN_DURATION_MINUTES * 60_000, targetEndMs);
187
+ return {
188
+ ...object,
189
+ properties: {
190
+ ...p,
191
+ end: new Date(safeEndMs).toISOString(),
192
+ },
193
+ };
194
+ }
@@ -1,4 +1,11 @@
1
- import { validEventDate, validEventTime, validateObjectProperties } from '@tano/protocol';
1
+ import {
2
+ isActionableTask,
3
+ isPlanCompleted,
4
+ isPlanObject,
5
+ validEventDate,
6
+ validEventTime,
7
+ validateObjectProperties,
8
+ } from '@tano/protocol';
2
9
  import type { ObjectRecord } from '../objects/workspace-objects';
3
10
  import { uiLocale } from '../i18n/i18n';
4
11
 
@@ -58,18 +65,47 @@ export function monthDays(month: Date) {
58
65
  (_, index) => new Date(month.getFullYear(), month.getMonth(), index - offset + 1),
59
66
  );
60
67
  }
61
- export const isCheckableEvent = ({ object }: ObjectRecord) =>
62
- object.type === 'task' || (object.type === 'event' && object.properties.checkable === true);
63
- export const isEventCompleted = ({ object }: ObjectRecord) =>
64
- object.properties.completed === true || (object.type === 'task' && ['done', 'completed'].includes(String(object.properties.status)));
68
+ export const isCheckableEvent = ({ object }: ObjectRecord) => isActionableTask(object);
69
+ export const isEventCompleted = ({ object }: ObjectRecord) => isPlanCompleted(object);
65
70
  export const hasEventTime = ({ object: { properties } }: ObjectRecord) =>
66
71
  validEventTime(properties.start) && validEventTime(properties.end) && Date.parse(properties.end) >= Date.parse(properties.start);
72
+ export const eventDueDate = ({ object: { properties } }: ObjectRecord): string | null =>
73
+ validEventDate(properties.due) ? properties.due : null;
74
+ export const isEventOverdue = (record: ObjectRecord, today = localDayKey(new Date())) => {
75
+ const due = eventDueDate(record);
76
+ return isCheckableEvent(record) && !isEventCompleted(record) && due !== null && due < today;
77
+ };
78
+ export const isDateOnlyOnDay = ({ object: { properties } }: ObjectRecord, day: Date) => {
79
+ if (validEventTime(properties.start) && validEventTime(properties.end)) return false;
80
+ if (!validEventDate(properties.date)) return false;
81
+ const key = localDayKey(day);
82
+ if (validEventDate(properties.endDate)) return properties.date <= key && key <= properties.endDate;
83
+ return properties.date === key;
84
+ };
85
+
86
+ export interface CalendarFilter {
87
+ kind: 'all' | 'task' | 'event';
88
+ showCompleted: boolean;
89
+ query: string;
90
+ }
91
+
92
+ export function filterCalendarRecords(records: readonly ObjectRecord[], filter: CalendarFilter) {
93
+ const needle = filter.query.trim().toLocaleLowerCase();
94
+ return records.filter((record) => {
95
+ const checkable = isCheckableEvent(record);
96
+ if (filter.kind === 'task' && !checkable) return false;
97
+ if (filter.kind === 'event' && checkable) return false;
98
+ if (!filter.showCompleted && checkable && isEventCompleted(record)) return false;
99
+ if (needle && !`${record.object.name}\n${record.object.description}`.toLocaleLowerCase().includes(needle)) return false;
100
+ return true;
101
+ });
102
+ }
67
103
 
68
104
  /** Planning includes date-only and unscheduled tasks as well as timed events. */
69
105
  export function planningEvents(records: readonly ObjectRecord[]) {
70
106
  return records
71
107
  .filter(({ object }) => {
72
- if (!['event', 'task'].includes(object.type) || object.archived) return false;
108
+ if (!isPlanObject(object) || object.archived) return false;
73
109
  try {
74
110
  validateObjectProperties(object.type, object.properties);
75
111
  return true;
@@ -89,7 +125,27 @@ export function calendarEvents(records: readonly ObjectRecord[]) {
89
125
  }
90
126
  export function plannedEventsOnDay(records: readonly ObjectRecord[], day: Date) {
91
127
  const timed = new Set(eventsOnDay(records.filter(hasEventTime), day));
92
- return records.filter(record => timed.has(record) || (!hasEventTime(record) && record.object.properties.date === localDayKey(day)));
128
+ return records.filter(record => timed.has(record) || isDateOnlyOnDay(record, day));
129
+ }
130
+ export interface CalendarDayEntry {
131
+ record: ObjectRecord;
132
+ kind: 'timed' | 'all-day' | 'due';
133
+ }
134
+ /** Combines scheduled items on a day with tasks whose due date falls on that day. */
135
+ export function calendarDayEntries(records: readonly ObjectRecord[], day: Date): CalendarDayEntry[] {
136
+ const dayKey = localDayKey(day);
137
+ const timed = new Set(eventsOnDay(records.filter(hasEventTime), day));
138
+ const entries: CalendarDayEntry[] = [];
139
+ for (const record of records) {
140
+ if (timed.has(record)) {
141
+ entries.push({ record, kind: record.object.properties.allDay === true ? 'all-day' : 'timed' });
142
+ } else if (isDateOnlyOnDay(record, day)) {
143
+ entries.push({ record, kind: 'all-day' });
144
+ } else if (eventDueDate(record) === dayKey) {
145
+ entries.push({ record, kind: 'due' });
146
+ }
147
+ }
148
+ return entries;
93
149
  }
94
150
  export function unscheduledTasks(records: readonly ObjectRecord[]) {
95
151
  return records.filter(record => isCheckableEvent(record) && !hasEventTime(record) && !validEventDate(record.object.properties.date));
@@ -5,18 +5,39 @@ const ResizeObserver = (window as Window & typeof globalThis).ResizeObserver;
5
5
  import { isNode } from '@tano/editor/dom-realm';
6
6
  import { vSurfaceMotion } from '@tano/editor/surface-motion';
7
7
  import { t, uiLocale } from '../../i18n/i18n';
8
- import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
9
- import { X } from 'lucide-vue-next';
10
- import { hasEventTime, isEventCompleted, localDayKey } from '../calendar';
11
- import { planKey, planSourceLabel } from '../personal-plans';
8
+ import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
9
+ import { Circle, CircleCheck, Flag, X } from 'lucide-vue-next';
10
+ import { isPlanCompletionLocked } from '@tano/protocol';
11
+ import { hasEventTime, isCheckableEvent, isEventCompleted, isEventOverdue, localDayKey } from '../calendar';
12
+ import type { CalendarDayEntry } from '../calendar';
13
+ import { planKey, planSourceLabel, sourcePlanKey } from '../personal-plans';
12
14
  import type { ObjectRecord } from '../../objects/workspace-objects';
13
15
 
14
- const props = defineProps<{ id: string; date: Date; anchor: HTMLElement; records: ObjectRecord[] }>();
15
- const emit = defineEmits<{ close: []; 'select-event': [id: string] }>();
16
+ const props = defineProps<{
17
+ id: string;
18
+ date: Date;
19
+ anchor: HTMLElement;
20
+ records: ObjectRecord[];
21
+ entries?: CalendarDayEntry[];
22
+ canEdit?: (record: ObjectRecord) => boolean;
23
+ pending?: readonly string[];
24
+ }>();
25
+ const emit = defineEmits<{
26
+ close: [];
27
+ 'select-event': [id: string];
28
+ 'toggle-complete': [record: ObjectRecord];
29
+ }>();
16
30
  const panel = ref<HTMLElement>();
17
31
  const position = ref({ left: '0px', top: '0px' });
18
32
  let resizeObserver: ResizeObserver | undefined;
19
33
 
34
+ const items = computed<CalendarDayEntry[]>(() =>
35
+ props.entries ?? props.records.map((record) => ({
36
+ record,
37
+ kind: hasEventTime(record) && record.object.properties.allDay !== true ? 'timed' : 'all-day',
38
+ })),
39
+ );
40
+
20
41
  function close(restoreFocus = false) {
21
42
  if (restoreFocus) props.anchor.focus({ preventScroll: true });
22
43
  emit('close');
@@ -62,9 +83,19 @@ async function focusPanel() {
62
83
  }
63
84
  function select(record: ObjectRecord) {
64
85
  close();
65
- emit('select-event', planKey(record));
86
+ emit('select-event', sourcePlanKey(record));
87
+ }
88
+ function canToggle(record: ObjectRecord) {
89
+ return (
90
+ isCheckableEvent(record) &&
91
+ !isPlanCompletionLocked(record.object) &&
92
+ props.canEdit?.(record) === true &&
93
+ !props.pending?.includes(planKey(record))
94
+ );
66
95
  }
67
- function eventTime(record: ObjectRecord) {
96
+ function eventTime(entry: CalendarDayEntry) {
97
+ if (entry.kind === 'due') return t('截止');
98
+ const { record } = entry;
68
99
  if (record.object.properties.allDay === true) return t('全天');
69
100
  if (!hasEventTime(record)) return t('当天');
70
101
  const format = (value: unknown) => {
@@ -81,10 +112,12 @@ onMounted(() => {
81
112
  document.addEventListener('pointerdown', dismiss);
82
113
  document.addEventListener('focusin', dismiss);
83
114
  window.addEventListener('resize', place);
84
- resizeObserver = new ResizeObserver(place);
85
- if (panel.value) resizeObserver.observe(panel.value);
86
- const calendar = props.anchor.closest('.calendar-view');
87
- if (calendar) resizeObserver.observe(calendar);
115
+ if (typeof ResizeObserver !== 'undefined') {
116
+ resizeObserver = new ResizeObserver(place);
117
+ if (panel.value) resizeObserver.observe(panel.value);
118
+ const calendar = props.anchor.closest('.calendar-view');
119
+ if (calendar) resizeObserver.observe(calendar);
120
+ }
88
121
  });
89
122
  onUnmounted(() => {
90
123
  document.removeEventListener('pointerdown', dismiss);
@@ -112,17 +145,50 @@ watch(() => props.date, focusPanel);
112
145
  <strong>{{ date.getDate() }}</strong>
113
146
  <div>
114
147
  <span>{{ date.toLocaleDateString(uiLocale, { month: 'short', weekday: 'short' }) }}</span>
115
- <small>{{ records.length ? t('{0} 项活动', [records.length]) : t('当天活动') }}</small>
148
+ <small>{{ items.length ? t('{0} 项活动', [items.length]) : t('当天活动') }}</small>
116
149
  </div>
117
150
  <button type="button" class="calendar-day-popover-close" :aria-label="t('关闭当天活动')" @click="close(true)">
118
151
  <X :size="17" aria-hidden="true" />
119
152
  </button>
120
153
  </header>
121
- <ul v-if="records.length" class="calendar-day-popover-events">
122
- <li v-for="record in records" :key="planKey(record)">
123
- <button type="button" :class="{ completed: isEventCompleted(record) }" @click="select(record)">
124
- <strong>{{ record.object.name }}</strong>
125
- <small><time>{{ eventTime(record) }}</time> · {{ planSourceLabel(record) }}{{ isEventCompleted(record) ? t(' · 已完成') : '' }}</small>
154
+ <ul v-if="items.length" class="calendar-day-popover-events">
155
+ <li
156
+ v-for="entry in items"
157
+ :key="`${planKey(entry.record)}:${entry.kind}`"
158
+ class="calendar-day-popover-row"
159
+ :class="{
160
+ completed: isEventCompleted(entry.record),
161
+ overdue: isEventOverdue(entry.record),
162
+ due: entry.kind === 'due',
163
+ }"
164
+ >
165
+ <button
166
+ v-if="isCheckableEvent(entry.record)"
167
+ type="button"
168
+ class="calendar-day-popover-check"
169
+ :aria-label="`${isEventCompleted(entry.record) ? t('标记未完成') : t('完成')}:${entry.record.object.name}`"
170
+ :disabled="!canToggle(entry.record)"
171
+ @click.stop="emit('toggle-complete', entry.record)"
172
+ >
173
+ <CircleCheck v-if="isEventCompleted(entry.record)" :size="15" aria-hidden="true" />
174
+ <Circle v-else :size="15" aria-hidden="true" />
175
+ </button>
176
+ <span
177
+ v-else
178
+ class="calendar-day-popover-marker"
179
+ :class="{ personal: entry.record.source?.scope === 'personal' }"
180
+ aria-hidden="true"
181
+ />
182
+ <button type="button" class="calendar-day-popover-item" @click="select(entry.record)">
183
+ <strong>
184
+ <Flag v-if="entry.kind === 'due'" :size="12" class="calendar-day-popover-flag" aria-hidden="true" />
185
+ {{ entry.record.object.name }}
186
+ </strong>
187
+ <small>
188
+ <time>{{ eventTime(entry) }}</time> · {{ planSourceLabel(entry.record) }}
189
+ <template v-if="isEventOverdue(entry.record)"> · {{ t('逾期') }}</template>
190
+ <template v-else-if="isEventCompleted(entry.record)">{{ t(' · 已完成') }}</template>
191
+ </small>
126
192
  </button>
127
193
  </li>
128
194
  </ul>
@@ -137,39 +203,106 @@ watch(() => props.date, focusPanel);
137
203
  z-index: 40;
138
204
  display: flex;
139
205
  flex-direction: column;
140
- width: 272px;
206
+ width: 292px;
141
207
  max-width: calc(100vw - 24px);
142
- max-height: min(380px, calc(100dvh - 24px));
143
- padding: 14px 12px 12px;
208
+ max-height: min(400px, calc(100dvh - 24px));
209
+ padding: 12px 8px 8px;
144
210
  border: 1px solid var(--line);
145
211
  border-radius: 12px;
146
212
  background: var(--paper);
147
213
  color: var(--text);
148
- box-shadow: 0 8px 28px #0002, 0 2px 6px #0001;
214
+ box-shadow: var(--overlay-shadow, 0 8px 28px #0002, 0 2px 6px #0001);
149
215
  outline: none;
150
216
  }
151
- .calendar-day-popover-heading { display: flex; align-items: center; gap: 10px; flex-shrink: 0; padding: 0 2px; }
152
- .calendar-day-popover-heading > strong { display: grid; place-items: center; flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: var(--green); font-size: 23px; line-height: 1; font-weight: 500; }
153
- .calendar-day-popover-heading > div { flex: 1; }
154
- .calendar-day-popover-heading span { display: block; font-size: 13px; }
155
- .calendar-day-popover-heading small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
217
+ .calendar-day-popover-heading { display: flex; align-items: center; gap: 10px; flex-shrink: 0; padding: 0 4px 0 6px; }
218
+ .calendar-day-popover-heading > strong {
219
+ display: grid;
220
+ place-items: center;
221
+ flex-shrink: 0;
222
+ width: 38px;
223
+ height: 38px;
224
+ border-radius: 10px;
225
+ background: var(--surface);
226
+ box-shadow: inset 0 0 0 1px var(--line);
227
+ color: var(--text);
228
+ font-size: 19px;
229
+ line-height: 1;
230
+ font-weight: 600;
231
+ font-variant-numeric: tabular-nums;
232
+ }
233
+ .calendar-day-popover-heading > div { flex: 1; min-width: 0; }
234
+ .calendar-day-popover-heading span { display: block; font-size: 13px; font-weight: 500; }
235
+ .calendar-day-popover-heading small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
156
236
  .calendar-day-popover-close {
157
237
  flex-shrink: 0;
158
238
  display: grid;
159
239
  place-items: center;
160
240
  width: 28px;
161
241
  height: 28px;
162
- border-radius: 6px;
163
- color: var(--text-secondary);
242
+ border-radius: 7px;
243
+ color: var(--muted);
244
+ }
245
+ .calendar-day-popover-close:hover { background: var(--hover); color: var(--text); }
246
+ .calendar-day-popover-empty { margin: 16px 6px 6px; color: var(--muted); font-size: 12px; line-height: 1.6; }
247
+ .calendar-day-popover-events {
248
+ min-height: 0;
249
+ overflow-y: auto;
250
+ overscroll-behavior: contain;
251
+ list-style: none;
252
+ margin: 10px 0 0;
253
+ padding: 8px 0 0;
254
+ border-top: 1px solid var(--line);
255
+ }
256
+ .calendar-day-popover-row {
257
+ display: flex;
258
+ align-items: flex-start;
259
+ gap: 4px;
260
+ padding: 0 4px;
261
+ border-radius: 8px;
262
+ transition: background-color var(--motion-quick) var(--ease-standard);
263
+ animation: tano-rise-in var(--motion-spring) var(--ease-spring-smooth) both;
264
+ }
265
+ .calendar-day-popover-row:nth-child(2) { animation-delay: 20ms; }
266
+ .calendar-day-popover-row:nth-child(3) { animation-delay: 40ms; }
267
+ .calendar-day-popover-row:nth-child(4) { animation-delay: 60ms; }
268
+ .calendar-day-popover-row:nth-child(n + 5) { animation-delay: 80ms; }
269
+ .calendar-day-popover-row + .calendar-day-popover-row { margin-top: 1px; }
270
+ .calendar-day-popover-row:hover,
271
+ .calendar-day-popover-row:focus-within { background: var(--hover); }
272
+ .calendar-day-popover-check,
273
+ .calendar-day-popover-marker {
274
+ flex: none;
275
+ display: grid;
276
+ place-items: center;
277
+ width: 24px;
278
+ height: 24px;
279
+ margin-top: 6px;
280
+ border-radius: 50%;
281
+ color: var(--muted);
282
+ }
283
+ .calendar-day-popover-marker::before {
284
+ content: '';
285
+ width: 7px;
286
+ height: 7px;
287
+ border-radius: 50%;
288
+ background: color-mix(in srgb, var(--text) 55%, var(--paper));
289
+ }
290
+ .calendar-day-popover-marker.personal::before { background: #3d6cc9; }
291
+ :root[data-theme='dark'] .calendar-day-popover-marker.personal::before { background: #86a6ea; }
292
+ .calendar-day-popover-check:hover:not(:disabled) { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); }
293
+ .calendar-day-popover-check:disabled { opacity: 0.45; cursor: not-allowed; }
294
+ .calendar-day-popover-row.completed .calendar-day-popover-check { color: var(--text-secondary); }
295
+ .calendar-day-popover-item { flex: 1; min-width: 0; padding: 7px 6px 7px 2px; border-radius: 6px; text-align: left; }
296
+ .calendar-day-popover-item:hover { color: inherit; }
297
+ .calendar-day-popover-item strong { display: flex; align-items: center; gap: 5px; color: var(--text); font-size: 13px; line-height: 1.5; font-weight: 500; overflow-wrap: anywhere; }
298
+ .calendar-day-popover-flag { flex: none; color: #b7791f; }
299
+ .calendar-day-popover-item small { display: block; margin-top: 1px; color: var(--muted); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
300
+ .calendar-day-popover-item small time { font-variant-numeric: tabular-nums; }
301
+ .calendar-day-popover-row.completed .calendar-day-popover-item strong { color: var(--muted); text-decoration: line-through; }
302
+ .calendar-day-popover-row.overdue .calendar-day-popover-item small,
303
+ .calendar-day-popover-row.overdue .calendar-day-popover-flag { color: var(--danger, #c24141); }
304
+ button:focus-visible { outline: 2px solid var(--focus-ring, var(--green)); outline-offset: 1px; }
305
+ @media (prefers-reduced-motion: reduce) {
306
+ .calendar-day-popover-row { animation: none; }
164
307
  }
165
- .calendar-day-popover-close:hover { background: var(--hover); }
166
- .calendar-day-popover-empty { margin: 16px 4px 6px; color: var(--muted); font-size: 12px; line-height: 1.6; }
167
- .calendar-day-popover-events { min-height: 0; overflow-y: auto; overscroll-behavior: contain; list-style: none; margin: 10px 0 0; padding: 2px; }
168
- .calendar-day-popover-events li + li { margin-top: 3px; }
169
- .calendar-day-popover-events button { width: 100%; padding: 8px; border-radius: 6px; text-align: left; }
170
- .calendar-day-popover-events button:hover { background: var(--hover); }
171
- .calendar-day-popover-events strong { display: block; color: var(--text); font-size: 13px; line-height: 1.5; font-weight: 500; overflow-wrap: anywhere; }
172
- .calendar-day-popover-events small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
173
- .calendar-day-popover-events .completed strong { color: var(--muted); text-decoration: line-through; }
174
- button:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
175
308
  </style>