@knotpad/app 0.1.0 → 0.1.1

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 (341) hide show
  1. package/bin/brief.js +165 -78
  2. package/package.json +3 -17
  3. package/app/(app)/calendar/page.tsx +0 -57
  4. package/app/(app)/error.tsx +0 -35
  5. package/app/(app)/graph/page.tsx +0 -32
  6. package/app/(app)/guide/page.tsx +0 -21
  7. package/app/(app)/kanban/loading.tsx +0 -24
  8. package/app/(app)/kanban/page.tsx +0 -59
  9. package/app/(app)/layout.tsx +0 -122
  10. package/app/(app)/list/loading.tsx +0 -21
  11. package/app/(app)/list/page.tsx +0 -137
  12. package/app/(app)/loading.tsx +0 -18
  13. package/app/(app)/notes/[noteId]/page.tsx +0 -84
  14. package/app/(app)/notes/layout.tsx +0 -30
  15. package/app/(app)/notes/page.tsx +0 -39
  16. package/app/(app)/page.tsx +0 -5
  17. package/app/(app)/settings/agent-token/page.tsx +0 -59
  18. package/app/(app)/settings/backup/page.tsx +0 -49
  19. package/app/(app)/settings/billing/page.tsx +0 -53
  20. package/app/(app)/settings/calendar/page.tsx +0 -41
  21. package/app/(app)/settings/layout.test.tsx +0 -39
  22. package/app/(app)/settings/layout.tsx +0 -71
  23. package/app/(app)/settings/page.tsx +0 -4
  24. package/app/(app)/settings/security/page.tsx +0 -43
  25. package/app/(app)/settings/team/page.tsx +0 -74
  26. package/app/(app)/settings/workspace/page.tsx +0 -27
  27. package/app/(app)/tasks/[taskId]/page.tsx +0 -79
  28. package/app/(auth)/forgot-password/page.tsx +0 -106
  29. package/app/(auth)/guest/page.tsx +0 -56
  30. package/app/(auth)/layout.tsx +0 -13
  31. package/app/(auth)/login/page.tsx +0 -14
  32. package/app/(auth)/register/page.tsx +0 -193
  33. package/app/(auth)/reset-password/page.tsx +0 -138
  34. package/app/api/account/claim/route.tsx +0 -135
  35. package/app/api/admin/backfill-encryption/route.tsx +0 -43
  36. package/app/api/admin/license/route.tsx +0 -42
  37. package/app/api/auth/2fa/route.tsx +0 -148
  38. package/app/api/auth/[...nextauth]/route.tsx +0 -3
  39. package/app/api/auth/change-password/route.tsx +0 -61
  40. package/app/api/auth/check-2fa/route.tsx +0 -19
  41. package/app/api/auth/forgot-password/route.tsx +0 -65
  42. package/app/api/auth/reset-password/route.tsx +0 -52
  43. package/app/api/auth/verify-2fa/route.tsx +0 -88
  44. package/app/api/backup/download/db/route.ts +0 -29
  45. package/app/api/backup/download/notes/route.ts +0 -25
  46. package/app/api/backup/settings/route.ts +0 -92
  47. package/app/api/billing/checkout/route.tsx +0 -81
  48. package/app/api/billing/migrate/route.tsx +0 -163
  49. package/app/api/billing/portal/route.tsx +0 -24
  50. package/app/api/billing/setup-intent/route.tsx +0 -55
  51. package/app/api/billing/status/route.tsx +0 -36
  52. package/app/api/billing/subscribe/route.tsx +0 -85
  53. package/app/api/billing/webhook/route.tsx +0 -199
  54. package/app/api/calendar-feeds/[feedId]/route.tsx +0 -67
  55. package/app/api/calendar-feeds/[feedId]/sync/route.tsx +0 -37
  56. package/app/api/calendar-feeds/events/route.tsx +0 -82
  57. package/app/api/calendar-feeds/route.tsx +0 -52
  58. package/app/api/calendar-feeds/sync-all/route.tsx +0 -34
  59. package/app/api/cron/calendar-feeds/route.tsx +0 -31
  60. package/app/api/cron/stale-tasks/route.tsx +0 -51
  61. package/app/api/cron/sync/route.tsx +0 -34
  62. package/app/api/devices/[deviceId]/route.tsx +0 -25
  63. package/app/api/devices/route.tsx +0 -41
  64. package/app/api/export/route.tsx +0 -40
  65. package/app/api/feedback/route.tsx +0 -54
  66. package/app/api/folders/[folderId]/route.tsx +0 -51
  67. package/app/api/folders/route.tsx +0 -37
  68. package/app/api/graph/route.tsx +0 -242
  69. package/app/api/guest/route.tsx +0 -58
  70. package/app/api/health/route.tsx +0 -10
  71. package/app/api/holidays/countries/route.tsx +0 -14
  72. package/app/api/holidays/route.tsx +0 -49
  73. package/app/api/holidays/states/route.tsx +0 -21
  74. package/app/api/invites/[token]/route.tsx +0 -131
  75. package/app/api/invites/route.tsx +0 -74
  76. package/app/api/mcp/generate-token/route.tsx +0 -55
  77. package/app/api/mcp/revoke-token/[tokenId]/route.tsx +0 -30
  78. package/app/api/mcp/update-alias/[tokenId]/route.tsx +0 -22
  79. package/app/api/notes/[noteId]/export/route.tsx +0 -45
  80. package/app/api/notes/[noteId]/route.tsx +0 -360
  81. package/app/api/notes/route.tsx +0 -112
  82. package/app/api/notifications/route.tsx +0 -44
  83. package/app/api/register/route.tsx +0 -67
  84. package/app/api/restore/route.tsx +0 -148
  85. package/app/api/sync/conflicts/[conflictId]/route.tsx +0 -134
  86. package/app/api/sync/conflicts/route.tsx +0 -48
  87. package/app/api/sync/status/route.tsx +0 -49
  88. package/app/api/sync/trigger/route.tsx +0 -15
  89. package/app/api/tasks/[taskId]/detail/route.tsx +0 -68
  90. package/app/api/tasks/[taskId]/route.tsx +0 -259
  91. package/app/api/tasks/bulk/route.tsx +0 -133
  92. package/app/api/tasks/route.tsx +0 -36
  93. package/app/api/workspace/active/route.tsx +0 -39
  94. package/app/api/workspace/create-team/route.tsx +0 -42
  95. package/app/api/workspace/kanban-statuses/route.tsx +0 -71
  96. package/app/api/workspace/members/[memberId]/route.tsx +0 -69
  97. package/app/api/workspace/route.tsx +0 -24
  98. package/app/download/page.tsx +0 -170
  99. package/app/favicon.ico +0 -0
  100. package/app/generated/prisma/client.d.ts +0 -1
  101. package/app/generated/prisma/client.js +0 -5
  102. package/app/generated/prisma/default.d.ts +0 -1
  103. package/app/generated/prisma/default.js +0 -5
  104. package/app/generated/prisma/edge.d.ts +0 -1
  105. package/app/generated/prisma/edge.js +0 -497
  106. package/app/generated/prisma/index-browser.js +0 -523
  107. package/app/generated/prisma/index.d.ts +0 -46376
  108. package/app/generated/prisma/index.js +0 -497
  109. package/app/generated/prisma/package.json +0 -144
  110. package/app/generated/prisma/query_compiler_fast_bg.js +0 -2
  111. package/app/generated/prisma/query_compiler_fast_bg.wasm +0 -0
  112. package/app/generated/prisma/query_compiler_fast_bg.wasm-base64.js +0 -2
  113. package/app/generated/prisma/runtime/client.d.ts +0 -3386
  114. package/app/generated/prisma/runtime/client.js +0 -86
  115. package/app/generated/prisma/runtime/index-browser.d.ts +0 -90
  116. package/app/generated/prisma/runtime/index-browser.js +0 -6
  117. package/app/generated/prisma/runtime/wasm-compiler-edge.js +0 -76
  118. package/app/generated/prisma/schema.prisma +0 -456
  119. package/app/generated/prisma/wasm-edge-light-loader.mjs +0 -5
  120. package/app/generated/prisma/wasm-worker-loader.mjs +0 -5
  121. package/app/globals.css +0 -54
  122. package/app/invite/[token]/page.tsx +0 -52
  123. package/app/layout.tsx +0 -90
  124. package/app/mcp/route.tsx +0 -430
  125. package/app/opengraph-image.tsx +0 -120
  126. package/app/page.tsx +0 -398
  127. package/app/privacy/page.tsx +0 -69
  128. package/app/robots.tsx +0 -25
  129. package/app/sitemap.tsx +0 -36
  130. package/app/terms/page.tsx +0 -69
  131. package/app/upgrade/page.tsx +0 -75
  132. package/auth.config.ts +0 -33
  133. package/auth.ts +0 -79
  134. package/components/auth/login-form.tsx +0 -302
  135. package/components/auth/password-checklist.tsx +0 -31
  136. package/components/auth/password-input.tsx +0 -36
  137. package/components/auth/switch-account-button.test.tsx +0 -22
  138. package/components/auth/switch-account-button.tsx +0 -19
  139. package/components/auth/two-factor-input.tsx +0 -116
  140. package/components/billing/billing-dashboard.tsx +0 -265
  141. package/components/billing/card-form.tsx +0 -210
  142. package/components/billing/claim-account-form.tsx +0 -99
  143. package/components/branding/app-logo.test.tsx +0 -20
  144. package/components/branding/app-logo.tsx +0 -25
  145. package/components/calendar/calendar-agenda.tsx +0 -150
  146. package/components/calendar/calendar-drag.test.tsx +0 -177
  147. package/components/calendar/calendar-grid.tsx +0 -357
  148. package/components/calendar/calendar-hooks.test.tsx +0 -27
  149. package/components/calendar/calendar-hooks.ts +0 -351
  150. package/components/calendar/calendar-toolbar.test.tsx +0 -68
  151. package/components/calendar/calendar-toolbar.tsx +0 -291
  152. package/components/calendar/calendar-types.ts +0 -148
  153. package/components/calendar/calendar-view.test.tsx +0 -295
  154. package/components/calendar/calendar-view.tsx +0 -307
  155. package/components/calendar/day-detail-popover.tsx +0 -174
  156. package/components/calendar/task-chip.tsx +0 -86
  157. package/components/command/command-palette.test.tsx +0 -33
  158. package/components/command/command-palette.tsx +0 -310
  159. package/components/download-cta.tsx +0 -87
  160. package/components/feedback/feedback-popup.tsx +0 -207
  161. package/components/graph/graph-draw.ts +0 -337
  162. package/components/graph/graph-overlays.tsx +0 -160
  163. package/components/graph/graph-page.test.tsx +0 -131
  164. package/components/graph/graph-page.tsx +0 -263
  165. package/components/graph/graph-types.ts +0 -47
  166. package/components/graph/graph-view.tsx +0 -322
  167. package/components/guide/guide-view.tsx +0 -522
  168. package/components/kanban/kanban-board.test.tsx +0 -128
  169. package/components/kanban/kanban-board.tsx +0 -361
  170. package/components/kanban/kanban-card-menu.tsx +0 -102
  171. package/components/kanban/kanban-card.tsx +0 -227
  172. package/components/kanban/kanban-column.tsx +0 -49
  173. package/components/kanban/kanban-status-context.tsx +0 -28
  174. package/components/landing/calendar-sandbox.test.tsx +0 -15
  175. package/components/landing/calendar-sandbox.tsx +0 -107
  176. package/components/landing/graph-sandbox.test.tsx +0 -27
  177. package/components/landing/graph-sandbox.tsx +0 -80
  178. package/components/landing/kanban-sandbox.test.tsx +0 -24
  179. package/components/landing/kanban-sandbox.tsx +0 -101
  180. package/components/landing/landing-showcase.test.tsx +0 -21
  181. package/components/landing/landing-showcase.tsx +0 -54
  182. package/components/landing/list-sandbox.tsx +0 -86
  183. package/components/landing/mock-workspace.ts +0 -168
  184. package/components/landing/notes-sandbox.test.tsx +0 -14
  185. package/components/landing/notes-sandbox.tsx +0 -88
  186. package/components/layout/app-shell.tsx +0 -83
  187. package/components/layout/backup-scheduler.tsx +0 -122
  188. package/components/layout/bottom-nav.tsx +0 -43
  189. package/components/layout/icon-bar.test.tsx +0 -29
  190. package/components/layout/icon-bar.tsx +0 -118
  191. package/components/layout/mobile-top-bar.tsx +0 -68
  192. package/components/layout/notes-panel-folder.tsx +0 -127
  193. package/components/layout/notes-panel-note-item.tsx +0 -140
  194. package/components/layout/notes-panel-task-tab.tsx +0 -63
  195. package/components/layout/notes-panel-types.ts +0 -44
  196. package/components/layout/notes-panel.tsx +0 -476
  197. package/components/layout/notification-bell.tsx +0 -251
  198. package/components/layout/paywall-screen.tsx +0 -41
  199. package/components/layout/pro-banner.tsx +0 -76
  200. package/components/layout/sw-register.tsx +0 -27
  201. package/components/layout/workspace-switcher.tsx +0 -90
  202. package/components/notes/mobile-bottom-sheet.tsx +0 -99
  203. package/components/notes/note-editor-context-menu.tsx +0 -47
  204. package/components/notes/note-editor-dom.ts +0 -33
  205. package/components/notes/note-editor-dropdowns.tsx +0 -484
  206. package/components/notes/note-editor-hooks.ts +0 -692
  207. package/components/notes/note-editor-keyboard.ts +0 -305
  208. package/components/notes/note-editor-overlay.tsx +0 -90
  209. package/components/notes/note-editor.test.tsx +0 -372
  210. package/components/notes/note-editor.tsx +0 -662
  211. package/components/notes/note-preview-pane.tsx +0 -156
  212. package/components/notes/note-tabs.tsx +0 -120
  213. package/components/notes/note-types.tsx +0 -157
  214. package/components/settings/accept-invite.tsx +0 -108
  215. package/components/settings/agent-token-settings.tsx +0 -369
  216. package/components/settings/backup-restore-settings.test.tsx +0 -25
  217. package/components/settings/backup-restore-settings.tsx +0 -327
  218. package/components/settings/calendar-feeds-settings.tsx +0 -489
  219. package/components/settings/calendar-general-settings.tsx +0 -174
  220. package/components/settings/confirm-danger-action.test.tsx +0 -215
  221. package/components/settings/confirm-danger-action.tsx +0 -65
  222. package/components/settings/security-settings.tsx +0 -252
  223. package/components/settings/settings-guidance.test.tsx +0 -98
  224. package/components/settings/team-settings.tsx +0 -319
  225. package/components/settings/two-factor-auth.tsx +0 -296
  226. package/components/settings/workspace-settings-client.tsx +0 -363
  227. package/components/settings/workspace-settings-form.tsx +0 -73
  228. package/components/sync/conflict-viewer.tsx +0 -247
  229. package/components/sync/sync-indicator.tsx +0 -171
  230. package/components/tasks/snippet-thread.tsx +0 -119
  231. package/components/tasks/status-dot.tsx +0 -47
  232. package/components/tasks/task-badge.tsx +0 -43
  233. package/components/tasks/task-detail.test.tsx +0 -187
  234. package/components/tasks/task-detail.tsx +0 -458
  235. package/components/tasks/task-list-filters.test.tsx +0 -75
  236. package/components/tasks/task-list-filters.tsx +0 -163
  237. package/components/tasks/task-list-types.ts +0 -20
  238. package/components/tasks/task-list.test.tsx +0 -175
  239. package/components/tasks/task-list.tsx +0 -481
  240. package/components/tasks/task-row.tsx +0 -85
  241. package/components/tasks/task-table-row.tsx +0 -259
  242. package/components/ui/skeleton.tsx +0 -3
  243. package/components/ui/toast.test.tsx +0 -42
  244. package/components/ui/toast.tsx +0 -70
  245. package/electron/main.ts +0 -251
  246. package/electron/preload.ts +0 -56
  247. package/instrumentation.tsx +0 -23
  248. package/lib/api-error.ts +0 -50
  249. package/lib/backup/backup-runner.test.ts +0 -32
  250. package/lib/backup/backup-runner.ts +0 -19
  251. package/lib/backup/backup-schedule.test.ts +0 -23
  252. package/lib/backup/backup-schedule.ts +0 -55
  253. package/lib/backup/backup-settings.test.ts +0 -30
  254. package/lib/backup/backup-settings.ts +0 -27
  255. package/lib/backup/export-notes-zip.test.ts +0 -26
  256. package/lib/backup/export-notes-zip.ts +0 -82
  257. package/lib/backup/export-workspace-backup.test.ts +0 -17
  258. package/lib/backup/export-workspace-backup.ts +0 -77
  259. package/lib/backup/restore-workspace-from-export.test.ts +0 -18
  260. package/lib/backup/restore-workspace-from-export.ts +0 -183
  261. package/lib/backup/types.ts +0 -14
  262. package/lib/brand-icons.ts +0 -1
  263. package/lib/calendar-feed-crypto.ts +0 -38
  264. package/lib/calendar-feed.ts +0 -239
  265. package/lib/client/online-status.ts +0 -47
  266. package/lib/conflict-resolver.test.ts +0 -57
  267. package/lib/conflict-resolver.ts +0 -240
  268. package/lib/db-init.ts +0 -79
  269. package/lib/email.ts +0 -159
  270. package/lib/encryption.test.ts +0 -41
  271. package/lib/encryption.ts +0 -98
  272. package/lib/extract-snippet.test.ts +0 -123
  273. package/lib/extract-snippet.ts +0 -69
  274. package/lib/kanban-status.ts +0 -55
  275. package/lib/license.ts +0 -21
  276. package/lib/limits.ts +0 -31
  277. package/lib/mcp-auth.test.ts +0 -58
  278. package/lib/mcp-auth.ts +0 -65
  279. package/lib/mcp-contract.test.ts +0 -25
  280. package/lib/mcp-contract.ts +0 -210
  281. package/lib/mcp-handler.ts +0 -31
  282. package/lib/mcp-url.test.ts +0 -12
  283. package/lib/mcp-url.ts +0 -7
  284. package/lib/mentions.test.ts +0 -45
  285. package/lib/mentions.ts +0 -73
  286. package/lib/note-crypto.ts +0 -108
  287. package/lib/note-sync.ts +0 -201
  288. package/lib/note-title.ts +0 -93
  289. package/lib/prisma.ts +0 -193
  290. package/lib/pro-flush.ts +0 -292
  291. package/lib/rate-limit.ts +0 -57
  292. package/lib/stripe.ts +0 -38
  293. package/lib/sync-worker.ts +0 -388
  294. package/lib/task-parser.test.ts +0 -91
  295. package/lib/task-parser.ts +0 -81
  296. package/lib/task-utils.ts +0 -52
  297. package/lib/use-is-electron.ts +0 -19
  298. package/lib/use-is-mobile.ts +0 -22
  299. package/lib/validation/calendar-feed.ts +0 -31
  300. package/lib/validation/note.ts +0 -27
  301. package/lib/validation/task.ts +0 -26
  302. package/lib/view-preferences.test.ts +0 -54
  303. package/lib/view-preferences.ts +0 -28
  304. package/lib/workspace.ts +0 -66
  305. package/next.config.ts +0 -21
  306. package/postcss.config.mjs +0 -7
  307. package/prisma/migrations/20260519021916_init/migration.sql +0 -388
  308. package/prisma/migrations/20260519061113_drop_sync_password/migration.sql +0 -8
  309. package/prisma/migrations/20260520065016_add_task_start_date/migration.sql +0 -2
  310. package/prisma/migrations/20260529010600_remove_encryption_fields/migration.sql +0 -12
  311. package/prisma/migrations/20260529020000_restore_encryption_salt/migration.sql +0 -3
  312. package/prisma/migrations/20260529030000_add_folders/migration.sql +0 -17
  313. package/prisma/migrations/20260605000000_deferred_fixes/migration.sql +0 -31
  314. package/prisma/migrations/20260605020806_add_pending_sync_to_note_and_task/migration.sql +0 -5
  315. package/prisma/migrations/20260605063634_add_stripe_webhook_event_sync_lock/migration.sql +0 -14
  316. package/prisma/migrations/20260605100000_add_prod_indexes/migration.sql +0 -26
  317. package/prisma/migrations/20260608081404_add_kanban_statuses/migration.sql +0 -23
  318. package/prisma/migrations/20260611032723_add_calendar_feeds/migration.sql +0 -43
  319. package/prisma/migrations/20260611040000_add_calendar_feed_color/migration.sql +0 -2
  320. package/prisma/migrations/20260611050000_add_task_priority/migration.sql +0 -14
  321. package/prisma/migrations/20260612060000_add_critical_priority/migration.sql +0 -2
  322. package/prisma/migrations/20260613090000_add_backup_settings/migration.sql +0 -25
  323. package/prisma/migrations/20260614160000_add_feedback/migration.sql +0 -20
  324. package/prisma/migrations/20260614210000_add_2fa/migration.sql +0 -4
  325. package/prisma/migrations/migration_lock.toml +0 -3
  326. package/prisma/schema.prisma +0 -457
  327. package/public/Logo_icon.svg +0 -1
  328. package/public/file.svg +0 -1
  329. package/public/globe.svg +0 -1
  330. package/public/icon-192.png +0 -0
  331. package/public/icon-512.png +0 -0
  332. package/public/icon.svg +0 -4
  333. package/public/icon_dark.svg +0 -1
  334. package/public/knotpad_icon.svg +0 -1
  335. package/public/knotpad_logo_full.svg +0 -1
  336. package/public/manifest.json +0 -14
  337. package/public/next.svg +0 -1
  338. package/public/sw.js +0 -137
  339. package/public/vercel.svg +0 -1
  340. package/public/window.svg +0 -1
  341. package/tsconfig.json +0 -35
@@ -1,174 +0,0 @@
1
- "use client";
2
-
3
- import { useState, useEffect, useLayoutEffect, useRef } from "react";
4
- import { createPortal } from "react-dom";
5
- import Link from "next/link";
6
- import { useKanbanStatuses } from "@/components/kanban/kanban-status-context";
7
- import type { CalTask, BusyBlockEntry, HolidayEntry } from "./calendar-types";
8
- import { getStatusDot, feedBg, feedText, countryFlag } from "./calendar-types";
9
- import { MobileBottomSheet } from "@/components/notes/mobile-bottom-sheet";
10
-
11
- const POPOVER_WIDTH = 256;
12
-
13
- function formatDate(dateKey: string): string {
14
- const d = new Date(dateKey + "T00:00:00");
15
- return d.toLocaleDateString(undefined, { weekday: "short", month: "short", day: "numeric" });
16
- }
17
-
18
- function formatTime(iso: string): string {
19
- return new Date(iso).toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" });
20
- }
21
-
22
- type Props = {
23
- open: boolean;
24
- onClose: () => void;
25
- dateKey: string | null;
26
- kind: "busy" | "tasks" | "holidays";
27
- busyBlocks: BusyBlockEntry[];
28
- tasks: CalTask[];
29
- holidays?: HolidayEntry[];
30
- holidayCountry?: string;
31
- taskHref: (taskId: string) => string;
32
- isOverdue: (task: CalTask) => boolean;
33
- anchorRect: DOMRect | null;
34
- };
35
-
36
- export function DayDetailPopover({
37
- open,
38
- onClose,
39
- dateKey,
40
- kind,
41
- busyBlocks,
42
- tasks,
43
- holidays = [],
44
- holidayCountry = "MY",
45
- taskHref,
46
- isOverdue,
47
- anchorRect,
48
- }: Props) {
49
- const kanbanStatuses = useKanbanStatuses();
50
- const popoverRef = useRef<HTMLDivElement>(null);
51
- const [pos, setPos] = useState<{ top: number; left: number }>({ top: 0, left: 0 });
52
-
53
- useLayoutEffect(() => {
54
- if (!open || !anchorRect) return;
55
- const popoverHeight = popoverRef.current?.offsetHeight ?? 320;
56
- let top = anchorRect.bottom + 4;
57
- let left = anchorRect.left;
58
- if (top + popoverHeight > window.innerHeight) {
59
- top = Math.max(4, anchorRect.top - popoverHeight - 4);
60
- }
61
- if (left + POPOVER_WIDTH > window.innerWidth) {
62
- left = Math.max(8, window.innerWidth - POPOVER_WIDTH - 8);
63
- }
64
- if (left < 0) left = 8;
65
- setPos({ top, left });
66
- }, [open, anchorRect]);
67
-
68
- // Escape key dismissal
69
- useEffect(() => {
70
- if (!open) return;
71
- function onKey(e: KeyboardEvent) {
72
- if (e.key === "Escape") onClose();
73
- }
74
- document.addEventListener("keydown", onKey);
75
- return () => document.removeEventListener("keydown", onKey);
76
- }, [open, onClose]);
77
-
78
- // Close on scroll/resize (desktop popover only)
79
- useEffect(() => {
80
- if (!open || !anchorRect) return;
81
- function handle() {
82
- onClose();
83
- }
84
- window.addEventListener("scroll", handle, true);
85
- window.addEventListener("resize", handle);
86
- return () => {
87
- window.removeEventListener("scroll", handle, true);
88
- window.removeEventListener("resize", handle);
89
- };
90
- }, [open, anchorRect, onClose]);
91
-
92
- if (!open || !dateKey) return null;
93
-
94
- const count = kind === "busy" ? busyBlocks.length : kind === "holidays" ? holidays.length : tasks.length;
95
-
96
- const content = (
97
- <>
98
- <div className="flex items-center justify-between border-b border-zinc-800 px-3 py-2">
99
- <span className="text-sm font-medium text-zinc-200">{formatDate(dateKey)}</span>
100
- <span className="rounded-full bg-zinc-800 px-2 py-0.5 text-[10px] text-zinc-400">
101
- {count} {kind === "busy" ? "busy" : kind === "holidays" ? "holiday" + (count === 1 ? "" : "s") : "task" + (count === 1 ? "" : "s")}
102
- </span>
103
- </div>
104
- <div className="max-h-[50vh] overflow-y-auto p-2">
105
- {kind === "busy"
106
- ? busyBlocks.map((b, i) => (
107
- <div
108
- key={`${b.title}-${i}`}
109
- className={`mb-1 rounded border px-2 py-1.5 text-xs ${feedBg(b.feedColor)} ${feedText(b.feedColor)}`}
110
- >
111
- <div className="truncate">
112
- {b.allDay ? b.title : `${formatTime(b.start)} ${b.title}`}
113
- </div>
114
- <div className="truncate text-[10px] opacity-60">{b.feedLabel}</div>
115
- </div>
116
- ))
117
- : kind === "holidays"
118
- ? holidays.map((h) => (
119
- <div
120
- key={h.name}
121
- className="mb-1 rounded border border-amber-800/40 bg-amber-950/50 px-2 py-1.5 text-xs text-amber-300"
122
- >
123
- <div className="flex items-center gap-1.5 truncate">
124
- <span className="shrink-0 text-[10px]">{countryFlag(holidayCountry)}</span>
125
- <span className="truncate">{h.name}{h.is_subject_to_change ? " *" : ""}</span>
126
- </div>
127
- </div>
128
- ))
129
- : tasks.map((task) => {
130
- const overdue = isOverdue(task);
131
- return (
132
- <Link
133
- key={task.id}
134
- href={taskHref(task.id)}
135
- onClick={onClose}
136
- className="flex items-center gap-2 rounded px-2 py-1.5 text-sm transition-colors hover:bg-zinc-800"
137
- >
138
- <span
139
- className={`h-2 w-2 shrink-0 rounded-full ${overdue ? "bg-red-400" : getStatusDot(kanbanStatuses, task.status)}`}
140
- />
141
- <span className={`flex-1 truncate ${overdue ? "text-red-300" : "text-zinc-200"}`}>
142
- {task.title}
143
- </span>
144
- <span className="shrink-0 truncate text-xs text-zinc-600 max-w-[80px]">{task.noteTitle}</span>
145
- </Link>
146
- );
147
- })}
148
- </div>
149
- </>
150
- );
151
-
152
- return (
153
- <>
154
- {anchorRect &&
155
- createPortal(
156
- <>
157
- <div className="fixed inset-0 z-40 hidden md:block" onClick={onClose} aria-hidden />
158
- <div
159
- ref={popoverRef}
160
- className="fixed z-50 hidden w-64 rounded-lg border border-zinc-700 bg-zinc-900 shadow-xl shadow-black/40 md:block"
161
- style={{ top: pos.top, left: pos.left }}
162
- >
163
- {content}
164
- </div>
165
- </>,
166
- document.body,
167
- )}
168
-
169
- <MobileBottomSheet open={open} onClose={onClose}>
170
- <div className="px-1">{content}</div>
171
- </MobileBottomSheet>
172
- </>
173
- );
174
- }
@@ -1,86 +0,0 @@
1
- "use client";
2
-
3
- import Link from "next/link";
4
- import { useKanbanStatuses } from "@/components/kanban/kanban-status-context";
5
- import type { CalTask } from "./calendar-types";
6
- import { getStatusDot } from "./calendar-types";
7
-
8
- export function TaskChip({
9
- task,
10
- href,
11
- isSaving,
12
- isOverdue,
13
- onDragStart,
14
- onDragEnd,
15
- onEdgeDragStart,
16
- resizable = false,
17
- compact = false,
18
- }: {
19
- task: CalTask;
20
- href: string;
21
- isSaving: boolean;
22
- isOverdue: boolean;
23
- onDragStart: (e: React.DragEvent) => void;
24
- onDragEnd: () => void;
25
- onEdgeDragStart?: (e: React.DragEvent, edge: "start" | "end") => void;
26
- resizable?: boolean;
27
- compact?: boolean;
28
- }) {
29
- const kanbanStatuses = useKanbanStatuses();
30
- const showHandles = resizable && !!onEdgeDragStart;
31
- return (
32
- <div
33
- className={`flex items-center overflow-hidden rounded border text-[11px] leading-tight transition ${
34
- isSaving ? "opacity-50" : ""
35
- } ${
36
- isOverdue
37
- ? "border-red-800/50 bg-red-900/60"
38
- : compact
39
- ? "border-zinc-800 bg-zinc-900"
40
- : "border-zinc-700/50 bg-zinc-800/70"
41
- }`}
42
- title={`${task.title} · ${task.noteTitle}${isOverdue ? " · Overdue" : ""}`}
43
- >
44
- {showHandles && (
45
- <span
46
- draggable
47
- onDragStart={(e) => { e.stopPropagation(); onEdgeDragStart!(e, "start"); }}
48
- onDragEnd={(e) => { e.stopPropagation(); onDragEnd(); }}
49
- aria-label={`Resize start for ${task.title}`}
50
- title="Drag to set start date"
51
- className="flex w-3.5 shrink-0 cursor-ew-resize items-center justify-center self-stretch border-r border-white/10 bg-black/25 text-[9px] leading-none text-white/60 hover:bg-black/45 hover:text-white/90"
52
- >
53
- &lt;
54
- </span>
55
- )}
56
- <div
57
- draggable
58
- onDragStart={(e) => { e.stopPropagation(); onDragStart(e); }}
59
- onDragEnd={(e) => { e.stopPropagation(); onDragEnd(); }}
60
- className="flex min-w-0 flex-1 cursor-grab items-center gap-1 px-1 py-0.5 transition hover:opacity-90 active:cursor-grabbing"
61
- >
62
- <Link
63
- href={href}
64
- draggable={false}
65
- onClick={(e) => e.stopPropagation()}
66
- className="flex min-w-0 flex-1 items-center gap-1 overflow-hidden"
67
- >
68
- <span className={`shrink-0 h-1.5 w-1.5 rounded-full ${isOverdue ? "bg-red-400" : getStatusDot(kanbanStatuses, task.status)}`} />
69
- <span className={`truncate max-w-[100px] ${isOverdue ? "text-red-300" : "text-zinc-300"}`}>{task.title}</span>
70
- </Link>
71
- </div>
72
- {showHandles && (
73
- <span
74
- draggable
75
- onDragStart={(e) => { e.stopPropagation(); onEdgeDragStart!(e, "end"); }}
76
- onDragEnd={(e) => { e.stopPropagation(); onDragEnd(); }}
77
- aria-label={`Resize end for ${task.title}`}
78
- title="Drag to set end date"
79
- className="flex w-3.5 shrink-0 cursor-ew-resize items-center justify-center self-stretch border-l border-white/10 bg-black/25 text-[9px] leading-none text-white/60 hover:bg-black/45 hover:text-white/90"
80
- >
81
- &gt;
82
- </span>
83
- )}
84
- </div>
85
- );
86
- }
@@ -1,33 +0,0 @@
1
- // @vitest-environment jsdom
2
- import { render, screen } from "@testing-library/react";
3
- import userEvent from "@testing-library/user-event";
4
- import { beforeAll, describe, expect, it, vi } from "vitest";
5
- import { CommandPaletteProvider } from "@/components/command/command-palette";
6
-
7
- vi.mock("next/navigation", () => ({
8
- useRouter: () => ({ push: vi.fn() }),
9
- }));
10
-
11
- beforeAll(() => {
12
- window.HTMLElement.prototype.scrollIntoView = vi.fn();
13
- });
14
-
15
- describe("CommandPalette", () => {
16
- it("shows an empty state with recovery hints when no results match", async () => {
17
- const user = userEvent.setup();
18
-
19
- render(
20
- <CommandPaletteProvider data={{ notes: [], tasks: [], folders: [], notesHref: "/notes" }}>
21
- <button>Child</button>
22
- </CommandPaletteProvider>
23
- );
24
-
25
- await user.keyboard("{Meta>}k{/Meta}");
26
- await user.type(screen.getByRole("textbox"), "zzzz");
27
-
28
- expect(screen.getByText('No results for "zzzz"')).toBeInTheDocument();
29
- expect(
30
- screen.getByText(/try a note title, a task name, or a command like "calendar" or "settings"\./i)
31
- ).toBeInTheDocument();
32
- });
33
- });
@@ -1,310 +0,0 @@
1
- "use client";
2
-
3
- import {
4
- createContext,
5
- useContext,
6
- useEffect,
7
- useMemo,
8
- useRef,
9
- useState,
10
- } from "react";
11
- import { useRouter } from "next/navigation";
12
- import {
13
- Search,
14
- FileText,
15
- Folder,
16
- Plus,
17
- Kanban,
18
- List as ListIcon,
19
- Calendar,
20
- Share2,
21
- Settings,
22
- CheckSquare,
23
- CornerDownLeft,
24
- } from "lucide-react";
25
-
26
- export type CommandData = {
27
- notes: { id: string; title: string }[];
28
- tasks: { id: string; title: string; note: { id: string; title: string } | null }[];
29
- folders: { id: string; name: string }[];
30
- notesHref: string;
31
- };
32
-
33
- type Item = {
34
- key: string;
35
- section: string;
36
- icon: React.ComponentType<{ size?: number; className?: string }>;
37
- label: string;
38
- sublabel?: string;
39
- run: () => void;
40
- };
41
-
42
- /**
43
- * Lightweight relevance score. Returns -1 for no match; higher is better.
44
- * exact > prefix > substring > subsequence. No external dependency.
45
- */
46
- function score(textRaw: string, qRaw: string): number {
47
- const text = textRaw.toLowerCase();
48
- const q = qRaw.toLowerCase();
49
- if (!q) return 0;
50
- if (text === q) return 1000;
51
- if (text.startsWith(q)) return 600 - text.length;
52
- const idx = text.indexOf(q);
53
- if (idx >= 0) return 300 - idx;
54
- // subsequence fallback (fuzzy)
55
- let ti = 0;
56
- for (const ch of q) {
57
- ti = text.indexOf(ch, ti);
58
- if (ti === -1) return -1;
59
- ti++;
60
- }
61
- return 50;
62
- }
63
-
64
- const Ctx = createContext<{ open: () => void }>({ open: () => {} });
65
- export function useCommandPalette() {
66
- return useContext(Ctx);
67
- }
68
-
69
- export function CommandPaletteProvider({
70
- data,
71
- children,
72
- }: {
73
- data: CommandData;
74
- children: React.ReactNode;
75
- }) {
76
- const [open, setOpen] = useState(false);
77
-
78
- useEffect(() => {
79
- function onKey(e: KeyboardEvent) {
80
- if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") {
81
- e.preventDefault();
82
- setOpen((o) => !o);
83
- }
84
- }
85
- document.addEventListener("keydown", onKey);
86
- return () => document.removeEventListener("keydown", onKey);
87
- }, []);
88
-
89
- return (
90
- <Ctx.Provider value={{ open: () => setOpen(true) }}>
91
- {children}
92
- {open && <CommandPalette data={data} onClose={() => setOpen(false)} />}
93
- </Ctx.Provider>
94
- );
95
- }
96
-
97
- function CommandPalette({ data, onClose }: { data: CommandData; onClose: () => void }) {
98
- const router = useRouter();
99
- const [query, setQuery] = useState("");
100
- const [active, setActive] = useState(0);
101
- const inputRef = useRef<HTMLInputElement>(null);
102
- const listRef = useRef<HTMLDivElement>(null);
103
-
104
- useEffect(() => {
105
- inputRef.current?.focus();
106
- }, []);
107
-
108
- const go = (href: string) => {
109
- onClose();
110
- router.push(href);
111
- };
112
-
113
- async function createNote() {
114
- onClose();
115
- try {
116
- const res = await fetch("/api/notes", {
117
- method: "POST",
118
- headers: { "Content-Type": "application/json" },
119
- body: JSON.stringify({ title: "Untitled", content: "" }),
120
- });
121
- if (res.ok) {
122
- const note = await res.json();
123
- router.push(`/notes/${note.id}`);
124
- }
125
- } catch {
126
- /* ignore */
127
- }
128
- }
129
-
130
- const items = useMemo<Item[]>(() => {
131
- const q = query.trim();
132
- const out: Item[] = [];
133
-
134
- const navCmds: Omit<Item, "section" | "key">[] = [
135
- { label: "Go to Notes", icon: FileText, run: () => go(data.notesHref) },
136
- { label: "Go to List", icon: ListIcon, run: () => go("/list") },
137
- { label: "Go to Kanban", icon: Kanban, run: () => go("/kanban") },
138
- { label: "Go to Calendar", icon: Calendar, run: () => go("/calendar") },
139
- { label: "Go to Graph", icon: Share2, run: () => go("/graph") },
140
- { label: "Go to Settings", icon: Settings, run: () => go("/settings") },
141
- { label: "Create new note", icon: Plus, run: createNote },
142
- ];
143
-
144
- if (!q) {
145
- navCmds.forEach((c, i) => out.push({ key: `cmd-${i}`, section: "Jump to", ...c }));
146
- data.notes.slice(0, 5).forEach((n) =>
147
- out.push({
148
- key: `recent-${n.id}`,
149
- section: "Recent notes",
150
- icon: FileText,
151
- label: n.title || "Untitled",
152
- run: () => go(`/notes/${n.id}`),
153
- })
154
- );
155
- return out;
156
- }
157
-
158
- const ranked = <T,>(arr: T[], text: (t: T) => string, limit: number) =>
159
- arr
160
- .map((t) => ({ t, s: score(text(t), q) }))
161
- .filter((x) => x.s >= 0)
162
- .sort((a, b) => b.s - a.s)
163
- .slice(0, limit)
164
- .map((x) => x.t);
165
-
166
- ranked(data.notes, (n) => n.title || "Untitled", 6).forEach((n) =>
167
- out.push({
168
- key: `note-${n.id}`,
169
- section: "Notes",
170
- icon: FileText,
171
- label: n.title || "Untitled",
172
- run: () => go(`/notes/${n.id}`),
173
- })
174
- );
175
-
176
- ranked(data.tasks, (t) => t.title, 6).forEach((t) =>
177
- out.push({
178
- key: `task-${t.id}`,
179
- section: "Tasks",
180
- icon: CheckSquare,
181
- label: t.title,
182
- sublabel: t.note?.title,
183
- run: () => go(`/tasks/${t.id}`),
184
- })
185
- );
186
-
187
- ranked(data.folders, (f) => f.name, 4).forEach((f) =>
188
- out.push({
189
- key: `folder-${f.id}`,
190
- section: "Folders",
191
- icon: Folder,
192
- label: f.name,
193
- run: () => go(`/list?folder=${f.id}`),
194
- })
195
- );
196
-
197
- navCmds
198
- .filter((c) => score(c.label, q) >= 0)
199
- .forEach((c, i) => out.push({ key: `cmd-${i}`, section: "Commands", ...c }));
200
-
201
- return out;
202
- // eslint-disable-next-line react-hooks/exhaustive-deps
203
- }, [query, data]);
204
-
205
- // Clamp during render (no effect) so the active row is always in range even
206
- // as results shrink/grow.
207
- const activeIdx = items.length === 0 ? -1 : Math.min(active, items.length - 1);
208
-
209
- function onKeyDown(e: React.KeyboardEvent) {
210
- if (e.key === "ArrowDown") {
211
- e.preventDefault();
212
- setActive(Math.min(activeIdx + 1, items.length - 1));
213
- } else if (e.key === "ArrowUp") {
214
- e.preventDefault();
215
- setActive(Math.max(activeIdx - 1, 0));
216
- } else if (e.key === "Enter") {
217
- e.preventDefault();
218
- items[activeIdx]?.run();
219
- } else if (e.key === "Escape") {
220
- e.preventDefault();
221
- onClose();
222
- }
223
- }
224
-
225
- // Scroll the active row into view.
226
- useEffect(() => {
227
- const el = listRef.current?.querySelector<HTMLElement>(`[data-idx="${activeIdx}"]`);
228
- el?.scrollIntoView({ block: "nearest" });
229
- }, [activeIdx]);
230
-
231
- let lastSection = "";
232
-
233
- return (
234
- <div
235
- className="fixed inset-0 z-[100] flex items-start justify-center bg-black/60 px-4 pt-[12vh]"
236
- onMouseDown={onClose}
237
- >
238
- <div
239
- className="w-full max-w-lg overflow-hidden rounded-xl border border-zinc-700 bg-zinc-900 shadow-2xl"
240
- onMouseDown={(e) => e.stopPropagation()}
241
- role="dialog"
242
- aria-label="Command palette"
243
- >
244
- <div className="flex items-center gap-2 border-b border-zinc-800 px-3">
245
- <Search size={16} className="shrink-0 text-zinc-500" />
246
- <input
247
- ref={inputRef}
248
- value={query}
249
- onChange={(e) => {
250
- setQuery(e.target.value);
251
- setActive(0);
252
- }}
253
- onKeyDown={onKeyDown}
254
- placeholder="Search notes, tasks, or jump to…"
255
- aria-label="Search notes, tasks, or jump to a view"
256
- className="w-full bg-transparent py-3 text-sm text-zinc-100 placeholder:text-zinc-600 outline-none"
257
- />
258
- <kbd className="hidden shrink-0 rounded border border-zinc-700 px-1.5 py-0.5 text-[10px] text-zinc-500 sm:block">
259
- Esc
260
- </kbd>
261
- </div>
262
-
263
- <div ref={listRef} className="max-h-[55vh] overflow-y-auto py-1">
264
- {items.length === 0 && (
265
- <div className="border-t border-zinc-800 px-4 py-6 text-sm text-zinc-500">
266
- <p className="font-medium text-zinc-300">No results for "{query.trim()}"</p>
267
- <p className="mt-1">
268
- Try a note title, a task name, or a command like "calendar" or
269
- "settings".
270
- </p>
271
- </div>
272
- )}
273
- {items.map((item, i) => {
274
- const header = item.section !== lastSection ? item.section : null;
275
- lastSection = item.section;
276
- const Icon = item.icon;
277
- return (
278
- <div key={item.key}>
279
- {header && (
280
- <p className="px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-zinc-600">
281
- {header}
282
- </p>
283
- )}
284
- <button
285
- data-idx={i}
286
- onMouseMove={() => setActive(i)}
287
- onClick={() => item.run()}
288
- className={`flex w-full items-center gap-2.5 px-3 py-2 text-left text-sm transition-colors ${
289
- activeIdx === i ? "bg-zinc-800 text-zinc-100" : "text-zinc-300"
290
- }`}
291
- >
292
- <Icon size={15} className="shrink-0 text-zinc-500" />
293
- <span className="flex-1 truncate">{item.label}</span>
294
- {item.sublabel && (
295
- <span className="shrink-0 max-w-[40%] truncate text-xs text-zinc-600">
296
- {item.sublabel}
297
- </span>
298
- )}
299
- {activeIdx === i && (
300
- <CornerDownLeft size={13} className="shrink-0 text-zinc-600" />
301
- )}
302
- </button>
303
- </div>
304
- );
305
- })}
306
- </div>
307
- </div>
308
- </div>
309
- );
310
- }
@@ -1,87 +0,0 @@
1
- "use client";
2
-
3
- import { useEffect, useState } from "react";
4
- import Link from "next/link";
5
-
6
- type Platform = "windows" | "macos" | "linux" | "unknown";
7
-
8
- function detectPlatform(): Platform {
9
- if (typeof navigator === "undefined") return "unknown";
10
- const ua = navigator.userAgent.toLowerCase();
11
- if (ua.includes("win")) return "windows";
12
- if (ua.includes("mac") || ua.includes("darwin")) return "macos";
13
- if (ua.includes("linux")) return "linux";
14
- return "unknown";
15
- }
16
-
17
-
18
- export default function DownloadCTA() {
19
- const [platform, setPlatform] = useState<Platform>("unknown");
20
- const [isMounted, setIsMounted] = useState(false);
21
-
22
- useEffect(() => {
23
- setPlatform(detectPlatform());
24
- setIsMounted(true);
25
- }, []);
26
-
27
- // Don't flash wrong content during SSR — render minimal state
28
- if (!isMounted) {
29
- return (
30
- <div className="flex flex-col gap-4 sm:flex-row sm:items-center">
31
- <div className="inline-flex items-center justify-center rounded-lg bg-zinc-100 px-6 py-3 text-sm font-semibold text-zinc-900 animate-pulse">
32
- Loading…
33
- </div>
34
- <div className="flex flex-col gap-0.5 rounded-lg border border-zinc-800 bg-zinc-900 px-4 py-3">
35
- <code className="text-sm font-mono text-zinc-300">npx @knotpad/app</code>
36
- </div>
37
- </div>
38
- );
39
- }
40
-
41
- const isMac = platform === "macos";
42
-
43
- return (
44
- <div className="flex flex-col gap-4">
45
- {/* Primary CTA */}
46
- <div className="flex flex-col gap-4 sm:flex-row sm:items-center">
47
- {isMac ? (
48
- <div className="flex flex-col gap-2">
49
- <div className="inline-flex items-center gap-2 rounded-full border border-amber-800/40 bg-amber-950/30 px-3 py-1 w-fit">
50
- <span className="h-1.5 w-1.5 rounded-full bg-amber-400 animate-pulse" />
51
- <span className="text-xs text-amber-300">macOS coming soon</span>
52
- </div>
53
- <Link
54
- href="/register"
55
- className="inline-flex items-center justify-center rounded-lg bg-zinc-100 px-6 py-3 text-sm font-semibold text-zinc-900 hover:bg-white transition-colors"
56
- >
57
- Get started free →
58
- </Link>
59
- </div>
60
- ) : (
61
- <Link
62
- href="/download"
63
- className="inline-flex items-center justify-center rounded-lg bg-zinc-100 px-6 py-3 text-sm font-semibold text-zinc-900 hover:bg-white transition-colors"
64
- >
65
- Download ↓
66
- </Link>
67
- )}
68
-
69
- <div className="flex flex-col gap-0.5 rounded-lg border border-zinc-800 bg-zinc-900 px-4 py-3">
70
- <code className="text-sm font-mono text-zinc-300">npx @knotpad/app</code>
71
- </div>
72
- </div>
73
-
74
- {/* All platforms fallback (for unknown / mobile) */}
75
- {platform === "unknown" && (
76
- <div className="flex flex-wrap gap-3 pt-1">
77
- <Link
78
- href="/download"
79
- className="inline-flex items-center gap-2 rounded-md border border-zinc-800 bg-zinc-900 px-3 py-1.5 text-xs text-zinc-400 hover:text-zinc-200 hover:border-zinc-700 transition-colors"
80
- >
81
- View all downloads
82
- </Link>
83
- </div>
84
- )}
85
- </div>
86
- );
87
- }