ocean-brain 0.12.2 → 0.13.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 (71) hide show
  1. package/package.json +1 -1
  2. package/server/client/dist/assets/{ArrowRight.es-CD1IMhU2.js → ArrowRight.es-BlNsZQFs.js} +1 -1
  3. package/server/client/dist/assets/AuxiliaryPanelHeader-HAttwVby.js +1 -0
  4. package/server/client/dist/assets/Calendar-CaeK7gTz.js +25 -0
  5. package/server/client/dist/assets/Callout-CcYyvHQP.js +1 -0
  6. package/server/client/dist/assets/CaretUp.es-C8iY5OlB.js +1 -0
  7. package/server/client/dist/assets/{CheckCircle.es-C7fkzE3t.js → CheckCircle.es-Dqr3WImn.js} +1 -1
  8. package/server/client/dist/assets/{Copy.es-D6rl6b78.js → Copy.es-fMv0ETir.js} +1 -1
  9. package/server/client/dist/assets/{File.es-CcjtzE38.js → File.es-CHtXXafR.js} +1 -1
  10. package/server/client/dist/assets/FileText.es-DPIwDCEe.js +1 -0
  11. package/server/client/dist/assets/{FlowArrow.es-CAIThqWk.js → FlowArrow.es-Dxee98ir.js} +1 -1
  12. package/server/client/dist/assets/Graph-CdEu8eAn.js +46 -0
  13. package/server/client/dist/assets/Graph-hVj6vAYJ.js +1 -0
  14. package/server/client/dist/assets/{Image.es-BDpo5R66.js → Image.es-CjXY1JVf.js} +1 -1
  15. package/server/client/dist/assets/Info.es-CYxg-Vku.js +1 -0
  16. package/server/client/dist/assets/LinkSimple.es-B-P-7Iem.js +1 -0
  17. package/server/client/dist/assets/{Note-Dq2Szaxd.js → Note-CGI-Y1__.js} +4 -4
  18. package/server/client/dist/assets/{NotePropertiesPanel-Cu3RgDic.js → NotePropertiesPanel-6P7UfRBR.js} +2 -2
  19. package/server/client/dist/assets/{Plus.es-P9Fjwtud.js → Plus.es-Dy6onD-Z.js} +1 -1
  20. package/server/client/dist/assets/Reminders-DnuALBL6.js +1 -0
  21. package/server/client/dist/assets/{Search-DVROxY_B.js → Search-DAYHxAml.js} +2 -2
  22. package/server/client/dist/assets/{SurfaceCard-D_OU_Oy6.js → SurfaceCard-D5QxOte_.js} +1 -1
  23. package/server/client/dist/assets/Tag-CG8b0l1j.js +1 -0
  24. package/server/client/dist/assets/TagNotes-COyaVsdn.js +1 -0
  25. package/server/client/dist/assets/{Trash.es-BeR1sZMe.js → Trash.es-XEcWG_aq.js} +1 -1
  26. package/server/client/dist/assets/{ViewChip-D-Ax5PdL.js → ViewChip-BVkZAXyx.js} +1 -1
  27. package/server/client/dist/assets/Views-BPxlw3vk.js +1 -0
  28. package/server/client/dist/assets/app-BezcjTfd.js +151 -0
  29. package/server/client/dist/assets/app-DjDwGe0t.css +1 -0
  30. package/server/client/dist/assets/calendar-data-wB0ifXdo.js +1 -0
  31. package/server/client/dist/assets/{image.api-CtfyPwkV.js → image.api-ChvlfuZg.js} +1 -1
  32. package/server/client/dist/assets/index-CzZFedXj.js +1 -0
  33. package/server/client/dist/assets/{manage-image-m-7v_Z1W.js → manage-image-CSJ3Flgc.js} +1 -1
  34. package/server/client/dist/assets/manage-image-detail-9hRTiAsR.js +1 -0
  35. package/server/client/dist/assets/{mcp-admin-adapter-Cw6w5mfg.js → mcp-admin-adapter-D0R8p9az.js} +1 -1
  36. package/server/client/dist/assets/{mcp-B-aGeAQD.js → mcp-ugdCKa6H.js} +1 -1
  37. package/server/client/dist/assets/{note-ui-CYsZc3DI.js → note-ui-BaqzP-YU.js} +1 -1
  38. package/server/client/dist/assets/placeholder-CZoqs4S3.js +34 -0
  39. package/server/client/dist/assets/{properties-B93_V2uD.js → properties-B7Fv95qY.js} +1 -1
  40. package/server/client/dist/assets/route-preload.js +2 -2
  41. package/server/client/dist/assets/{search-admin-adapter-Dj0KKKrJ.js → search-admin-adapter-Daf7e2YQ.js} +1 -1
  42. package/server/client/dist/assets/search-ddYl3qH-.js +1 -0
  43. package/server/client/dist/assets/{tag.api-BJ6eaHui.js → tag.api-DEUROVKQ.js} +1 -1
  44. package/server/client/dist/assets/time-PxWila4-.js +361 -0
  45. package/server/client/dist/assets/trash-BHida7BG.js +1 -0
  46. package/server/client/dist/assets/{url-BvjSC8PU.js → url-DKUMNVCI.js} +1 -1
  47. package/server/client/dist/assets/useNoteMutate-BjvZUmtX.js +9 -0
  48. package/server/client/dist/assets/{useReminderMutate-kTBRSjYc.js → useReminderMutate-C5n-5LM-.js} +2 -2
  49. package/server/client/dist/index.html +6 -6
  50. package/server/dist/features/note/services/properties.js +32 -8
  51. package/server/dist/features/view/graphql/view.query.resolver.js +20 -0
  52. package/server/dist/features/view/graphql/view.type-defs.js +17 -0
  53. package/server/dist/features/view/services/workspace.js +116 -1
  54. package/server/client/dist/assets/AuxiliaryPanelHeader-zoJGsYWR.js +0 -1
  55. package/server/client/dist/assets/Calendar-6otw_EJn.js +0 -25
  56. package/server/client/dist/assets/Callout-C1QiCWCa.js +0 -1
  57. package/server/client/dist/assets/Graph-BHsmPDPh.js +0 -46
  58. package/server/client/dist/assets/Reminders-DKm0GFI2.js +0 -1
  59. package/server/client/dist/assets/Tag-wMHTRwlF.js +0 -1
  60. package/server/client/dist/assets/TagNotes-BRza6i14.js +0 -1
  61. package/server/client/dist/assets/Views-CL7rC05G.js +0 -1
  62. package/server/client/dist/assets/app-CyQtGTtn.js +0 -139
  63. package/server/client/dist/assets/app-DGFNtdpS.css +0 -1
  64. package/server/client/dist/assets/index-BEfKfbvr.js +0 -1
  65. package/server/client/dist/assets/manage-image-detail-BNYOCSmu.js +0 -1
  66. package/server/client/dist/assets/placeholder-C5fNzKrL.js +0 -34
  67. package/server/client/dist/assets/search-BmXuuK26.js +0 -1
  68. package/server/client/dist/assets/sortable.esm-DgSW3bAA.js +0 -5
  69. package/server/client/dist/assets/time-DI902Sxa.js +0 -361
  70. package/server/client/dist/assets/trash-GulvRh9f.js +0 -1
  71. package/server/client/dist/assets/useNoteMutate-xEIypxi5.js +0 -9
@@ -1,4 +1,4 @@
1
- import{r as u,j as r}from"./floating-ui.react-dom-BWTnA00G.js";import{g as p,M as f,L as h,I as C,m as F,d as w,a as N,b as v,T as $,B as R,u as S,q as b,e as q}from"./time-DI902Sxa.js";import{M as A}from"./useNoteMutate-xEIypxi5.js";const I=(e={})=>({limit:e.limit??10,offset:e.offset??0}),y=`
1
+ import{r as u,j as r}from"./floating-ui.react-dom-BWTnA00G.js";import{d as C,M as F}from"./useNoteMutate-BjvZUmtX.js";import{g as p,M as f,L as h,I as w,d as N,a as S,b as v,T as $,B as R,u as q,q as b,e as A}from"./time-PxWila4-.js";const I=(e={})=>({limit:e.limit??10,offset:e.offset??0}),y=`
2
2
  totalCount
3
3
  reminders {
4
4
  id
@@ -118,4 +118,4 @@ import{r as u,j as r}from"./floating-ui.react-dom-BWTnA00G.js";import{g as p,M a
118
118
  mutation DeleteReminder($id: ID!) {
119
119
  deleteReminder(id: $id)
120
120
  }
121
- `,{id:e}),D={low:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},medium:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},high:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"}};function K({isOpen:e,onClose:t,onSave:o,reminder:a,mode:n}){const[i,l]=u.useState(new Date),[d,s]=u.useState("medium"),[m,g]=u.useState("");u.useEffect(()=>{e&&n==="edit"&&a?(l(new Date(Number(a.reminderDate))),s(a.priority||"medium"),g(a.content||"")):e&&n==="create"&&(l(new Date),s("medium"),g(""))},[e,n,a]);const j=()=>{o(i,d,m||void 0),t()},x=c=>d===c?D[c].active:D[c].inactive;return r.jsxs(f,{isOpen:e,onClose:t,variant:"form",children:[r.jsx(f.Header,{title:n==="create"?"Create Reminder":"Edit Reminder",onClose:t}),r.jsx(f.Body,{children:r.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(h,{children:"Date & Time"}),r.jsx(C,{type:"datetime-local",size:"sm",value:F(i).format("YYYY-MM-DDTHH:mm"),onChange:c=>l(new Date(c.target.value))})]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(h,{children:"Content"}),r.jsx(w,{size:"sm",placeholder:"Enter reminder content (optional)",value:m,onChange:c=>g(c.target.value)})]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(h,{children:"Priority"}),r.jsxs(N,{type:"single",variant:"quiet",value:d,onValueChange:c=>c&&s(c),className:"gap-1.5 border-none rounded-[14px] bg-muted/70 p-1 sm:gap-2",children:[r.jsx(v,{value:"low",className:`flex-1 rounded-[10px] border ${x("low")}`,children:r.jsx($,{as:"span",weight:"medium",className:"text-current",children:"Low"})}),r.jsx(v,{value:"medium",className:`flex-1 rounded-[10px] border ${x("medium")}`,children:r.jsx($,{as:"span",weight:"medium",className:"text-current",children:"Medium"})}),r.jsx(v,{value:"high",className:`flex-1 rounded-[10px] border ${x("high")}`,children:r.jsx($,{as:"span",weight:"medium",className:"text-current",children:"High"})})]})]})]})}),r.jsx(f.Footer,{children:r.jsxs(A,{children:[r.jsx(R,{variant:"ghost",size:"sm",onClick:t,children:"Cancel"}),r.jsx(R,{variant:"primary",size:"sm",onClick:j,children:n==="create"?"Create":"Save"})]})})]})}function U(){const e=q(),t=S(),o=u.useCallback(async(i,l,d="medium",s,m)=>{const g=await P({noteId:i,reminderDate:l,priority:d,content:m});if(g.type==="error"){e(g.errors[0].message);return}await t.invalidateQueries({queryKey:b.reminders.all(),exact:!1}),s&&s()},[t,e]),a=u.useCallback(async(i,l,d,s)=>{const m=await M({id:i,...d});if(m.type==="error"){e(m.errors[0].message);return}await t.invalidateQueries({queryKey:b.reminders.all(),exact:!1}),s&&s()},[t,e]),n=u.useCallback(async(i,l,d)=>{const s=await T(i);if(s.type==="error"){e(s.errors[0].message);return}await t.invalidateQueries({queryKey:b.reminders.all(),exact:!1}),d&&d()},[t,e]);return{onCreate:o,onUpdate:a,onDelete:n}}export{K as R,z as a,E as b,Q as c,H as f,U as u};
121
+ `,{id:e}),D={low:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},medium:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},high:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"}};function K({isOpen:e,onClose:t,onSave:o,reminder:a,mode:n}){const[i,l]=u.useState(new Date),[d,s]=u.useState("medium"),[m,g]=u.useState("");u.useEffect(()=>{e&&n==="edit"&&a?(l(new Date(Number(a.reminderDate))),s(a.priority||"medium"),g(a.content||"")):e&&n==="create"&&(l(new Date),s("medium"),g(""))},[e,n,a]);const j=()=>{o(i,d,m||void 0),t()},x=c=>d===c?D[c].active:D[c].inactive;return r.jsxs(f,{isOpen:e,onClose:t,variant:"form",children:[r.jsx(f.Header,{title:n==="create"?"Create Reminder":"Edit Reminder",onClose:t}),r.jsx(f.Body,{children:r.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(h,{children:"Date & Time"}),r.jsx(w,{type:"datetime-local",size:"sm",value:C(i).format("YYYY-MM-DDTHH:mm"),onChange:c=>l(new Date(c.target.value))})]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(h,{children:"Content"}),r.jsx(N,{size:"sm",placeholder:"Enter reminder content (optional)",value:m,onChange:c=>g(c.target.value)})]}),r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(h,{children:"Priority"}),r.jsxs(S,{type:"single",variant:"quiet",value:d,onValueChange:c=>c&&s(c),className:"gap-1.5 border-none rounded-[14px] bg-muted/70 p-1 sm:gap-2",children:[r.jsx(v,{value:"low",className:`flex-1 rounded-[10px] border ${x("low")}`,children:r.jsx($,{as:"span",weight:"medium",className:"text-current",children:"Low"})}),r.jsx(v,{value:"medium",className:`flex-1 rounded-[10px] border ${x("medium")}`,children:r.jsx($,{as:"span",weight:"medium",className:"text-current",children:"Medium"})}),r.jsx(v,{value:"high",className:`flex-1 rounded-[10px] border ${x("high")}`,children:r.jsx($,{as:"span",weight:"medium",className:"text-current",children:"High"})})]})]})]})}),r.jsx(f.Footer,{children:r.jsxs(F,{children:[r.jsx(R,{variant:"ghost",size:"sm",onClick:t,children:"Cancel"}),r.jsx(R,{variant:"primary",size:"sm",onClick:j,children:n==="create"?"Create":"Save"})]})})]})}function U(){const e=A(),t=q(),o=u.useCallback(async(i,l,d="medium",s,m)=>{const g=await P({noteId:i,reminderDate:l,priority:d,content:m});if(g.type==="error"){e(g.errors[0].message);return}await t.invalidateQueries({queryKey:b.reminders.all(),exact:!1}),s&&s()},[t,e]),a=u.useCallback(async(i,l,d,s)=>{const m=await M({id:i,...d});if(m.type==="error"){e(m.errors[0].message);return}await t.invalidateQueries({queryKey:b.reminders.all(),exact:!1}),s&&s()},[t,e]),n=u.useCallback(async(i,l,d)=>{const s=await T(i);if(s.type==="error"){e(s.errors[0].message);return}await t.invalidateQueries({queryKey:b.reminders.all(),exact:!1}),d&&d()},[t,e]);return{onCreate:o,onUpdate:a,onDelete:n}}export{K as R,z as a,E as b,Q as c,H as f,U as u};
@@ -8,14 +8,14 @@
8
8
  <link rel="icon" type="image/png" href="/icon.png" />
9
9
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10
10
  <title>Ocean Brain</title>
11
- <script type="module" crossorigin src="/assets/app-CyQtGTtn.js"></script>
11
+ <script type="module" crossorigin src="/assets/app-BezcjTfd.js"></script>
12
12
  <link rel="modulepreload" crossorigin href="/assets/floating-ui.react-dom-BWTnA00G.js">
13
- <link rel="modulepreload" crossorigin href="/assets/url-BvjSC8PU.js">
14
- <link rel="modulepreload" crossorigin href="/assets/time-DI902Sxa.js">
15
- <link rel="modulepreload" crossorigin href="/assets/useNoteMutate-xEIypxi5.js">
13
+ <link rel="modulepreload" crossorigin href="/assets/url-DKUMNVCI.js">
14
+ <link rel="modulepreload" crossorigin href="/assets/time-PxWila4-.js">
15
+ <link rel="modulepreload" crossorigin href="/assets/useNoteMutate-BjvZUmtX.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-BXl3LOEh.js">
17
- <link rel="modulepreload" crossorigin href="/assets/sortable.esm-DgSW3bAA.js">
18
- <link rel="stylesheet" crossorigin href="/assets/app-DGFNtdpS.css">
17
+ <link rel="modulepreload" crossorigin href="/assets/Graph-hVj6vAYJ.js">
18
+ <link rel="stylesheet" crossorigin href="/assets/app-DjDwGe0t.css">
19
19
  </head>
20
20
 
21
21
  <body>
@@ -260,16 +260,17 @@ const parseViewQueryRecord = (value) => {
260
260
  return null;
261
261
  }
262
262
  };
263
- const getNormalizedViewFilterKey = (filter) => {
264
- if (typeof filter.key !== "string") {
263
+ const getNormalizedViewPropertyKey = (value) => {
264
+ if (typeof value !== "string") {
265
265
  return null;
266
266
  }
267
267
  try {
268
- return normalizePropertyKey(filter.key);
268
+ return normalizePropertyKey(value);
269
269
  } catch {
270
270
  return null;
271
271
  }
272
272
  };
273
+ const getNormalizedViewFilterKey = (filter) => getNormalizedViewPropertyKey(filter.key);
273
274
  const renamePropertyFiltersInViewQuery = ({
274
275
  query,
275
276
  key,
@@ -329,12 +330,31 @@ const findReferencedRemovedPropertyOptionValue = ({
329
330
  }
330
331
  return null;
331
332
  };
332
- const viewQueryReferencesProperty = ({ query, key }) => {
333
+ const viewQueryReferencesProperty = ({
334
+ query,
335
+ key,
336
+ displayType
337
+ }) => {
333
338
  const parsed = parseViewQueryRecord(query);
334
- if (!parsed || !Array.isArray(parsed.propertyFilters)) {
339
+ if (!parsed) {
335
340
  return false;
336
341
  }
337
- return parsed.propertyFilters.some((filter) => isRecord(filter) && getNormalizedViewFilterKey(filter) === key);
342
+ const isReferencedKey = (value) => getNormalizedViewPropertyKey(value) === key;
343
+ const referencedByFilter = Array.isArray(parsed.propertyFilters) && parsed.propertyFilters.some((filter) => isRecord(filter) && getNormalizedViewFilterKey(filter) === key);
344
+ const displayOptions = isRecord(parsed.displayOptions) ? parsed.displayOptions : null;
345
+ if (!displayOptions) {
346
+ return referencedByFilter;
347
+ }
348
+ if (referencedByFilter) {
349
+ return true;
350
+ }
351
+ if (displayType === "board") {
352
+ return isReferencedKey(displayOptions.boardGroupByPropertyKey);
353
+ }
354
+ if (displayType === "calendar") {
355
+ return isReferencedKey(displayOptions.calendarDatePropertyKey);
356
+ }
357
+ return displayType === "table" && Array.isArray(displayOptions.tablePropertyKeys) && displayOptions.tablePropertyKeys.some(isReferencedKey);
338
358
  };
339
359
  const buildTypedValueData = async (input, definitionId, tx = models) => {
340
360
  const resetValues = {
@@ -704,10 +724,14 @@ const deleteNotePropertyDefinition = async ({
704
724
  }
705
725
  const referencingViewSections = await tx.viewSection.findMany({
706
726
  where: { query: { contains: definition.key } },
707
- select: { title: true, query: true }
727
+ select: { title: true, displayType: true, query: true }
708
728
  });
709
729
  const referencingView = referencingViewSections.find(
710
- (section) => viewQueryReferencesProperty({ query: section.query, key: definition.key })
730
+ (section) => viewQueryReferencesProperty({
731
+ query: section.query,
732
+ key: definition.key,
733
+ displayType: section.displayType
734
+ })
711
735
  );
712
736
  if (referencingView) {
713
737
  throw new InvalidNotePropertyInputError(
@@ -4,6 +4,7 @@ import {
4
4
  getNotesByProperties,
5
5
  getViewSectionBoardColumn,
6
6
  getViewSectionById,
7
+ getViewSectionCalendarNotes,
7
8
  getViewSectionNotes,
8
9
  getViewWorkspace
9
10
  } from "../../../features/view/services/workspace.js";
@@ -11,6 +12,7 @@ const createViewQueryResolvers = (deps = {
11
12
  getNotesByProperties,
12
13
  getViewSectionBoardColumn,
13
14
  getViewSectionById,
15
+ getViewSectionCalendarNotes,
14
16
  getViewSectionNotes,
15
17
  getViewWorkspace
16
18
  }) => ({
@@ -42,6 +44,24 @@ const createViewQueryResolvers = (deps = {
42
44
  }
43
45
  return sectionNotes;
44
46
  },
47
+ viewSectionCalendarNotes: async (_, { id, dateRange }) => {
48
+ try {
49
+ const notes = await deps.getViewSectionCalendarNotes(id, dateRange);
50
+ if (!notes) {
51
+ throw "NOT FOUND";
52
+ }
53
+ return notes;
54
+ } catch (error) {
55
+ if (error instanceof InvalidNotePropertyInputError) {
56
+ throw new GraphQLError(error.message, {
57
+ extensions: {
58
+ code: "INVALID_NOTE_PROPERTY_INPUT"
59
+ }
60
+ });
61
+ }
62
+ throw error;
63
+ }
64
+ },
45
65
  viewSectionBoardColumn: async (_, {
46
66
  id,
47
67
  optionValue = null,
@@ -39,6 +39,8 @@ const viewType = gql`
39
39
  tableColumns: [ViewTableColumn!]!
40
40
  tablePropertyKeys: [String!]!
41
41
  boardGroupByPropertyKey: String
42
+ calendarDateField: ViewCalendarDateField!
43
+ calendarDatePropertyKey: String
42
44
  }
43
45
 
44
46
  type ViewBoardNote {
@@ -52,6 +54,12 @@ const viewType = gql`
52
54
  notes: [ViewBoardNote!]!
53
55
  }
54
56
 
57
+ type ViewCalendarNote {
58
+ id: ID!
59
+ title: String!
60
+ calendarDate: String!
61
+ }
62
+
55
63
  enum ViewDisplayType {
56
64
  list
57
65
  table
@@ -67,6 +75,12 @@ const viewType = gql`
67
75
  updatedAt
68
76
  }
69
77
 
78
+ enum ViewCalendarDateField {
79
+ createdAt
80
+ updatedAt
81
+ property
82
+ }
83
+
70
84
  enum ViewPropertyFilterOperator {
71
85
  equals
72
86
  notEquals
@@ -100,6 +114,8 @@ const viewType = gql`
100
114
  tableColumns: [ViewTableColumn!]
101
115
  tablePropertyKeys: [String!]
102
116
  boardGroupByPropertyKey: String
117
+ calendarDateField: ViewCalendarDateField
118
+ calendarDatePropertyKey: String
103
119
  }
104
120
 
105
121
  input ViewSectionInput {
@@ -132,6 +148,7 @@ const viewQuery = gql`
132
148
  sortBy: ViewSortBy
133
149
  sortOrder: ViewSortOrder
134
150
  ): Notes!
151
+ viewSectionCalendarNotes(id: ID!, dateRange: DateRangeInput!): [ViewCalendarNote!]!
135
152
  viewSectionBoardColumn(id: ID!, optionValue: String, pagination: PaginationInput): ViewBoardColumnNotes!
136
153
  notesByProperties(input: NotesByPropertiesInput!, pagination: PaginationInput): Notes!
137
154
  }
@@ -13,10 +13,12 @@ const DEFAULT_VIEW_NOTES_QUERY_LIMIT = 20;
13
13
  const MAX_VIEW_NOTES_QUERY_LIMIT = 50;
14
14
  const MAX_VIEW_PROPERTY_FILTERS = 10;
15
15
  const MAX_VIEW_TABLE_PROPERTY_COLUMNS = 6;
16
+ const MAX_VIEW_CALENDAR_RANGE_MS = 32 * 24 * 60 * 60 * 1e3;
16
17
  const DEFAULT_VIEW_DISPLAY_TYPE = "list";
17
18
  const DEFAULT_VIEW_SORT_BY = "updatedAt";
18
19
  const DEFAULT_VIEW_SORT_ORDER = "desc";
19
20
  const DEFAULT_VIEW_TABLE_COLUMNS = ["title", "tags", "properties", "createdAt", "updatedAt"];
21
+ const DEFAULT_VIEW_CALENDAR_DATE_FIELD = "createdAt";
20
22
  const orderedViewSectionTagsInclude = {
21
23
  tags: {
22
24
  orderBy: [{ order: "asc" }, { createdAt: "asc" }]
@@ -75,11 +77,15 @@ const normalizeViewTableColumns = (columns) => {
75
77
  return uniqueColumns.includes("title") ? uniqueColumns : ["title", ...uniqueColumns];
76
78
  };
77
79
  const normalizeViewTablePropertyKeys = (keys) => Array.from(new Set((keys ?? []).map(normalizePropertyKey))).slice(0, MAX_VIEW_TABLE_PROPERTY_COLUMNS);
80
+ const normalizeViewCalendarDateField = (value) => value === "updatedAt" || value === "property" ? value : DEFAULT_VIEW_CALENDAR_DATE_FIELD;
78
81
  const normalizeViewDisplayOptions = (options) => {
82
+ const calendarDateField = normalizeViewCalendarDateField(options?.calendarDateField);
79
83
  return {
80
84
  tableColumns: normalizeViewTableColumns(options?.tableColumns),
81
85
  tablePropertyKeys: normalizeViewTablePropertyKeys(options?.tablePropertyKeys),
82
- boardGroupByPropertyKey: options?.boardGroupByPropertyKey ? normalizePropertyKey(options.boardGroupByPropertyKey) : null
86
+ boardGroupByPropertyKey: options?.boardGroupByPropertyKey ? normalizePropertyKey(options.boardGroupByPropertyKey) : null,
87
+ calendarDateField,
88
+ calendarDatePropertyKey: calendarDateField === "property" && options?.calendarDatePropertyKey ? normalizePropertyKey(options.calendarDatePropertyKey) : null
83
89
  };
84
90
  };
85
91
  const normalizeFilterValue = ({
@@ -218,6 +224,9 @@ const normalizeViewSectionInput = (input) => {
218
224
  if (displayType === "board" && propertyFilters.some((filter) => filter.key === displayOptions.boardGroupByPropertyKey)) {
219
225
  throw new InvalidNotePropertyInputError("A board grouping property cannot also be used as a section filter.");
220
226
  }
227
+ if (displayType === "calendar" && displayOptions.calendarDateField === "property" && !displayOptions.calendarDatePropertyKey) {
228
+ throw new InvalidNotePropertyInputError("Calendar sections require a date property.");
229
+ }
221
230
  return {
222
231
  title: trimmedTitle || buildDefaultSectionTitle(tagNames, propertyFilters),
223
232
  displayType,
@@ -386,6 +395,19 @@ const buildStoredViewQuery = async (db, section) => {
386
395
  throw new InvalidNotePropertyInputError("Board grouping properties require at least one option.");
387
396
  }
388
397
  }
398
+ if (section.displayType === "calendar" && section.displayOptions.calendarDateField === "property") {
399
+ const calendarDatePropertyKey = section.displayOptions.calendarDatePropertyKey ?? "";
400
+ const calendarDateProperty = await db.propertyDefinition.findUnique({
401
+ where: { key: calendarDatePropertyKey },
402
+ select: { valueType: true }
403
+ });
404
+ if (!calendarDateProperty) {
405
+ throw new InvalidNotePropertyInputError(`Property ${calendarDatePropertyKey} is not defined.`);
406
+ }
407
+ if (calendarDateProperty.valueType !== "date") {
408
+ throw new InvalidNotePropertyInputError("Calendar sections can only use a date property.");
409
+ }
410
+ }
389
411
  return serializeStoredViewQuery({
390
412
  propertyFilters,
391
413
  sortBy: section.sortBy,
@@ -549,6 +571,38 @@ const buildViewNotesWhere = (query) => {
549
571
  const buildViewSectionWhere = (section) => {
550
572
  return buildViewNotesWhere(section);
551
573
  };
574
+ const normalizeViewCalendarDateRange = (dateRange) => {
575
+ const start = new Date(dateRange.start);
576
+ const end = new Date(dateRange.end);
577
+ const duration = end.getTime() - start.getTime();
578
+ if (Number.isNaN(start.getTime()) || Number.isNaN(end.getTime()) || duration <= 0 || duration > MAX_VIEW_CALENDAR_RANGE_MS) {
579
+ throw new InvalidNotePropertyInputError("Calendar date range must be valid and cover no more than 32 days.");
580
+ }
581
+ return { start, end };
582
+ };
583
+ const buildViewSectionCalendarWhere = (section, dateRange, propertyDefinitionId) => {
584
+ const sectionWhere = buildViewSectionWhere(section);
585
+ if (section.displayOptions.calendarDateField === "property" && propertyDefinitionId === void 0) {
586
+ throw new InvalidNotePropertyInputError("Calendar date property definition is required.");
587
+ }
588
+ const dateWhere = section.displayOptions.calendarDateField === "property" ? {
589
+ properties: {
590
+ some: {
591
+ propertyDefinitionId,
592
+ dateValue: {
593
+ gte: dateRange.start,
594
+ lt: dateRange.end
595
+ }
596
+ }
597
+ }
598
+ } : {
599
+ [section.displayOptions.calendarDateField]: {
600
+ gte: dateRange.start,
601
+ lt: dateRange.end
602
+ }
603
+ };
604
+ return Object.keys(sectionWhere).length === 0 ? dateWhere : { AND: [sectionWhere, dateWhere] };
605
+ };
552
606
  const buildViewBoardColumnWhere = (section, propertyDefinitionId, optionId) => {
553
607
  const sectionWhere = buildViewSectionWhere(section);
554
608
  const columnWhere = optionId === null ? {
@@ -596,6 +650,63 @@ const getViewSectionNotes = async (id, pagination, sort = {}) => {
596
650
  notes
597
651
  };
598
652
  };
653
+ const getViewSectionCalendarNotes = async (id, dateRangeInput) => {
654
+ const section = await models.viewSection.findUnique({
655
+ where: { id: parseViewId(id) },
656
+ include: orderedViewSectionTagsInclude
657
+ });
658
+ if (!section) {
659
+ return null;
660
+ }
661
+ const serializedSection = serializeViewSection(section);
662
+ if (serializedSection.displayType !== "calendar") {
663
+ throw new InvalidNotePropertyInputError("This section is not configured as a calendar.");
664
+ }
665
+ const dateRange = normalizeViewCalendarDateRange(dateRangeInput);
666
+ const dateField = serializedSection.displayOptions.calendarDateField;
667
+ if (dateField === "property") {
668
+ const propertyKey = serializedSection.displayOptions.calendarDatePropertyKey;
669
+ const propertyDefinition = propertyKey ? await models.propertyDefinition.findUnique({
670
+ where: { key: propertyKey },
671
+ select: { id: true, valueType: true }
672
+ }) : null;
673
+ if (!propertyDefinition || propertyDefinition.valueType !== "date") {
674
+ throw new InvalidNotePropertyInputError("The calendar date property is unavailable.");
675
+ }
676
+ const notes2 = await models.note.findMany({
677
+ orderBy: [{ id: "asc" }],
678
+ where: buildViewSectionCalendarWhere(serializedSection, dateRange, propertyDefinition.id),
679
+ select: {
680
+ id: true,
681
+ title: true,
682
+ properties: {
683
+ where: { propertyDefinitionId: propertyDefinition.id },
684
+ select: { dateValue: true },
685
+ take: 1
686
+ }
687
+ }
688
+ });
689
+ return notes2.flatMap((note) => {
690
+ const dateValue = note.properties[0]?.dateValue;
691
+ return dateValue ? [{ id: note.id, title: note.title, calendarDate: dateValue.toISOString().slice(0, 10) }] : [];
692
+ }).sort((left, right) => left.calendarDate.localeCompare(right.calendarDate) || left.id - right.id);
693
+ }
694
+ const notes = await models.note.findMany({
695
+ orderBy: [{ [dateField]: "asc" }, { id: "asc" }],
696
+ where: buildViewSectionCalendarWhere(serializedSection, dateRange),
697
+ select: {
698
+ id: true,
699
+ title: true,
700
+ createdAt: true,
701
+ updatedAt: true
702
+ }
703
+ });
704
+ return notes.map((note) => ({
705
+ id: note.id,
706
+ title: note.title,
707
+ calendarDate: note[dateField].toISOString()
708
+ }));
709
+ };
599
710
  const getViewSectionBoardColumn = async (id, optionValue, pagination) => {
600
711
  const section = await models.viewSection.findUnique({
601
712
  where: { id: parseViewId(id) },
@@ -888,6 +999,7 @@ export {
888
999
  buildPropertyFilterWhere,
889
1000
  buildViewBoardColumnWhere,
890
1001
  buildViewNotesWhere,
1002
+ buildViewSectionCalendarWhere,
891
1003
  buildViewSectionWhere,
892
1004
  clampViewSectionLimit,
893
1005
  createViewSection,
@@ -898,9 +1010,12 @@ export {
898
1010
  getNotesByPropertiesWithDb,
899
1011
  getViewSectionBoardColumn,
900
1012
  getViewSectionById,
1013
+ getViewSectionCalendarNotes,
901
1014
  getViewSectionNotes,
902
1015
  getViewWorkspace,
903
1016
  hydratePropertyFilters,
1017
+ normalizeViewCalendarDateField,
1018
+ normalizeViewCalendarDateRange,
904
1019
  normalizeViewDisplayOptions,
905
1020
  normalizeViewNotesPagination,
906
1021
  normalizeViewNotesQueryInput,
@@ -1 +0,0 @@
1
- import{r as a,j as t}from"./floating-ui.react-dom-BWTnA00G.js";import{C as m,T as c,c as s}from"./time-DI902Sxa.js";const i=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M87.5,151.52l64-64a12,12,0,0,1,17,17l-64,64a12,12,0,0,1-17-17Zm131-114a60.08,60.08,0,0,0-84.87,0L103.51,67.61a12,12,0,0,0,17,17l30.07-30.06a36,36,0,0,1,50.93,50.92L171.4,135.52a12,12,0,1,0,17,17l30.08-30.06A60.09,60.09,0,0,0,218.45,37.55ZM135.52,171.4l-30.07,30.08a36,36,0,0,1-50.92-50.93l30.06-30.07a12,12,0,0,0-17-17L37.55,133.58a60,60,0,0,0,84.88,84.87l30.06-30.07a12,12,0,0,0-17-17Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M209.94,113.94l-96,96a48,48,0,0,1-67.88-67.88l96-96a48,48,0,0,1,67.88,67.88Z",opacity:"0.2"}),a.createElement("path",{d:"M165.66,90.34a8,8,0,0,1,0,11.32l-64,64a8,8,0,0,1-11.32-11.32l64-64A8,8,0,0,1,165.66,90.34ZM215.6,40.4a56,56,0,0,0-79.2,0L106.34,70.45a8,8,0,0,0,11.32,11.32l30.06-30a40,40,0,0,1,56.57,56.56l-30.07,30.06a8,8,0,0,0,11.31,11.32L215.6,119.6a56,56,0,0,0,0-79.2ZM138.34,174.22l-30.06,30.06a40,40,0,1,1-56.56-56.57l30.05-30.05a8,8,0,0,0-11.32-11.32L40.4,136.4a56,56,0,0,0,79.2,79.2l30.06-30.07a8,8,0,0,0-11.32-11.31Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM144.56,173.66l-21.45,21.45a44,44,0,0,1-62.22-62.22l21.45-21.46a8,8,0,0,1,11.32,11.31L72.2,144.2a28,28,0,0,0,39.6,39.6l21.45-21.46a8,8,0,0,1,11.31,11.32Zm-34.9-16a8,8,0,0,1-11.32-11.32l48-48a8,8,0,0,1,11.32,11.32Zm85.45-34.55-21.45,21.45a8,8,0,0,1-11.32-11.31L183.8,111.8a28,28,0,0,0-39.6-39.6L122.74,93.66a8,8,0,0,1-11.31-11.32l21.46-21.45a44,44,0,0,1,62.22,62.22Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M164.25,91.75a6,6,0,0,1,0,8.49l-64,64a6,6,0,0,1-8.49-8.48l64-64A6,6,0,0,1,164.25,91.75ZM214.2,41.8a54.07,54.07,0,0,0-76.38,0L107.75,71.85a6,6,0,0,0,8.49,8.49l30.07-30.06a42,42,0,0,1,59.41,59.41l-30.08,30.07a6,6,0,1,0,8.49,8.49l30.07-30.07A54,54,0,0,0,214.2,41.8ZM139.76,175.64l-30.07,30.08a42,42,0,0,1-59.41-59.41l30.06-30.07a6,6,0,0,0-8.49-8.49l-30,30.07a54,54,0,0,0,76.38,76.39l30.07-30.08a6,6,0,0,0-8.49-8.49Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M165.66,90.34a8,8,0,0,1,0,11.32l-64,64a8,8,0,0,1-11.32-11.32l64-64A8,8,0,0,1,165.66,90.34ZM215.6,40.4a56,56,0,0,0-79.2,0L106.34,70.45a8,8,0,0,0,11.32,11.32l30.06-30a40,40,0,0,1,56.57,56.56l-30.07,30.06a8,8,0,0,0,11.31,11.32L215.6,119.6a56,56,0,0,0,0-79.2ZM138.34,174.22l-30.06,30.06a40,40,0,1,1-56.56-56.57l30.05-30.05a8,8,0,0,0-11.32-11.32L40.4,136.4a56,56,0,0,0,79.2,79.2l30.06-30.07a8,8,0,0,0-11.32-11.31Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M162.84,93.16a4,4,0,0,1,0,5.66l-64,64a4,4,0,0,1-5.66-5.66l64-64A4,4,0,0,1,162.84,93.16Zm49.95-49.95a52.07,52.07,0,0,0-73.56,0L109.17,73.27a4,4,0,0,0,5.65,5.66l30.07-30.06a44,44,0,0,1,62.24,62.24l-30.07,30.06a4,4,0,0,0,5.66,5.66l30.07-30.06A52.07,52.07,0,0,0,212.79,43.21ZM141.17,177.06l-30.06,30.07a44,44,0,0,1-62.24-62.24l30.06-30.06a4,4,0,0,0-5.66-5.66L43.21,139.23a52,52,0,0,0,73.56,73.56l30.06-30.07a4,4,0,1,0-5.66-5.66Z"}))]]),n=a.forwardRef((e,l)=>a.createElement(m,{ref:l,...e,weights:i}));n.displayName="LinkSimpleIcon";const o=n;function d({icon:e,title:l,className:r}){return t.jsxs("div",{className:s("flex items-center gap-2",r),children:[t.jsx("div",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center text-current",children:e}),t.jsx(c,{as:"span",variant:"label",weight:"semibold",className:"text-current",children:l})]})}export{d as A,o as p};
@@ -1,25 +0,0 @@
1
- import{r as l,j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{C as me,T as h,c as D,m as j,F as he,y as xe,z as P,B as S,R as pe,a2 as ue,M as $,q as Y,g as X,P as ge,h as ye}from"./time-DI902Sxa.js";import{N as fe,C as be}from"./url-BvjSC8PU.js";import{e as G}from"./app-CyQtGTtn.js";import{s as V,a as L}from"./useNoteMutate-xEIypxi5.js";import{C as Ne}from"./Callout-C1QiCWCa.js";import"./preload-helper-BXl3LOEh.js";import"./sortable.esm-DgSW3bAA.js";const je=new Map([["bold",l.createElement(l.Fragment,null,l.createElement("path",{d:"M216.49,79.52l-56-56A12,12,0,0,0,152,20H56A20,20,0,0,0,36,40V216a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V88A12,12,0,0,0,216.49,79.52ZM160,57l23,23H160ZM60,212V44h76V92a12,12,0,0,0,12,12h48V212Zm112-80a12,12,0,0,1-12,12H96a12,12,0,0,1,0-24h64A12,12,0,0,1,172,132Zm0,40a12,12,0,0,1-12,12H96a12,12,0,0,1,0-24h64A12,12,0,0,1,172,172Z"}))],["duotone",l.createElement(l.Fragment,null,l.createElement("path",{d:"M208,88H152V32Z",opacity:"0.2"}),l.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Zm-32-80a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,136Zm0,32a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,168Z"}))],["fill",l.createElement(l.Fragment,null,l.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,176H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm0-32H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm-8-56V44l44,44Z"}))],["light",l.createElement(l.Fragment,null,l.createElement("path",{d:"M212.24,83.76l-56-56A6,6,0,0,0,152,26H56A14,14,0,0,0,42,40V216a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V88A6,6,0,0,0,212.24,83.76ZM158,46.48,193.52,82H158ZM200,218H56a2,2,0,0,1-2-2V40a2,2,0,0,1,2-2h90V88a6,6,0,0,0,6,6h50V216A2,2,0,0,1,200,218Zm-34-82a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,136Zm0,32a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,168Z"}))],["regular",l.createElement(l.Fragment,null,l.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Zm-32-80a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,136Zm0,32a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,168Z"}))],["thin",l.createElement(l.Fragment,null,l.createElement("path",{d:"M210.83,85.17l-56-56A4,4,0,0,0,152,28H56A12,12,0,0,0,44,40V216a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V88A4,4,0,0,0,210.83,85.17ZM156,41.65,198.34,84H156ZM200,220H56a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h92V88a4,4,0,0,0,4,4h52V216A4,4,0,0,1,200,220Zm-36-84a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,136Zm0,32a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,168Z"}))]]),ee=l.forwardRef((t,a)=>l.createElement(me,{ref:a,...t,weights:je}));ee.displayName="FileTextIcon";const T=ee,z="bg-surface shadow-[inset_0_0_0_1px_var(--border-subtle)]",K="bg-emphasis",U=(t,a)=>`${t} ${t===1?a:`${a}s`}`,we=({day:t,dateLabel:a,cellClassName:s,dayNumberClassName:i,isCurrentMonth:o,isToday:x,isSelected:p,noteCount:c,reminderCount:d,previewItems:u,overflowCount:n,onSelect:y})=>{const w=c+d,A=`${a}, ${U(c,"note")}, ${U(d,"reminder")}`;return e.jsxs("button",{type:"button",disabled:!o,"aria-label":A,"aria-pressed":o?p:void 0,"aria-current":o&&x?"date":void 0,onClick:y,className:D("focus-ring-soft relative flex min-h-16 min-w-0 flex-col p-1.5 text-left outline-none transition-colors focus-visible:z-10 sm:min-h-24 sm:p-2 lg:min-h-36 lg:p-2.5",s),children:[e.jsx(h,{as:"span",variant:"label",className:D("flex h-6 min-w-6 items-center justify-center self-end whitespace-nowrap rounded-[9px] px-1.5 sm:h-7 sm:min-w-7 lg:!text-sm",i),children:t}),o&&w>0?e.jsxs("div",{"aria-hidden":"true",className:"mt-1.5 w-full sm:mt-2",children:[e.jsxs("div",{className:"flex flex-col gap-0.5 text-fg-tertiary sm:hidden",children:[c>0?e.jsxs("span",{className:"flex items-center justify-between leading-none",children:[e.jsx(T,{className:"shrink-0",size:10}),e.jsx("span",{className:"whitespace-nowrap text-[10px] font-semibold text-fg-secondary tabular-nums",children:c})]}):null,d>0?e.jsxs("span",{className:"flex items-center justify-between leading-none",children:[e.jsx(V,{className:"shrink-0",size:10}),e.jsx("span",{className:"whitespace-nowrap text-[10px] font-semibold text-fg-secondary tabular-nums",children:d})]}):null]}),e.jsxs("div",{className:"hidden flex-col gap-1 sm:flex 2xl:hidden",children:[c>0?e.jsxs("span",{className:D("flex min-h-7 min-w-0 items-center justify-between gap-1 rounded-[8px] px-2 py-1.5 text-fg-tertiary",z),children:[e.jsx(h,{as:"span",variant:"micro",weight:"medium",tone:"secondary",className:"truncate !text-[11px] !leading-4",children:"Notes"}),e.jsx(h,{as:"span",variant:"micro",weight:"semibold",tone:"secondary",className:"!text-[11px] !leading-4 tabular-nums",children:c})]}):null,d>0?e.jsxs("span",{className:D("flex min-h-7 min-w-0 items-center justify-between gap-1 rounded-[8px] px-2 py-1.5 text-fg-tertiary",K),children:[e.jsx(h,{as:"span",variant:"micro",weight:"medium",tone:"secondary",className:"truncate !text-[11px] !leading-4",children:"Reminders"}),e.jsx(h,{as:"span",variant:"micro",weight:"semibold",tone:"secondary",className:"!text-[11px] !leading-4 tabular-nums",children:d})]}):null]}),e.jsxs("div",{className:"hidden flex-col gap-1 2xl:flex",children:[u.map(v=>e.jsxs("span",{className:D("flex min-h-8 min-w-0 items-center gap-1.5 rounded-[8px] px-2 py-1.5",v.type==="reminder"?K:z),children:[v.type==="reminder"?e.jsx(V,{className:"shrink-0 text-fg-tertiary",size:12}):e.jsx(T,{className:"shrink-0 text-fg-tertiary",size:12}),e.jsx(h,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:D("truncate",v.isCompleted&&"line-through"),children:v.title})]},v.key)),n>0?e.jsxs(h,{as:"span",variant:"micro",weight:"medium",tone:"secondary",className:"flex min-h-4 items-center px-2 !text-[11px] !leading-4",children:["+",n," more"]}):null]})]}):null]})},H=2,ve=({year:t,month:a,day:s,isCurrentMonth:i,isSunday:o,isToday:x,isSelected:p,isPast:c,notes:d,reminders:u,onSelect:n})=>{const y=d.slice(0,H).map(M=>({key:`note-${M.id}`,type:"note",title:M.title})),w=u.slice(0,H).map(M=>({key:`reminder-${M.id}`,type:"reminder",title:M.content||M.note?.title||"No title",isCompleted:M.completed})),A=(c?[...y,...w]:[...w,...y]).slice(0,H),v=()=>i?p?"bg-elevated shadow-[inset_0_0_0_1px_var(--border-secondary)] hover:bg-surface":"bg-surface hover:bg-muted":"cursor-default bg-[var(--page-bg)] text-fg-disabled",C=()=>x?"bg-cta font-semibold text-fg-on-filled":i?o?"font-semibold text-fg-weekend":"font-semibold text-fg-secondary":"font-medium text-fg-tertiary";return e.jsx(we,{day:s,dateLabel:j(new Date(t,a-1,s)).format("dddd, MMMM D, YYYY"),cellClassName:v(),dayNumberClassName:C(),isCurrentMonth:i,isToday:x,isSelected:p,noteCount:d.length,reminderCount:u.length,previewItems:A,overflowCount:Math.max(0,d.length+u.length-H),onSelect:n})},Me=ve,te=({params:t,toneClassName:a="",header:s,title:i,meta:o,titleClassName:x=""})=>e.jsx(he,{to:fe,params:t,className:"focus-ring-soft group block rounded-[8px] outline-none",children:e.jsxs("div",{className:D("flex items-start gap-1.5 rounded-[8px] px-1.5 py-1 transition-colors group-hover:bg-muted",a),children:[s?e.jsx("span",{className:"mt-[2px] flex h-4 w-4 shrink-0 items-center justify-center text-fg-tertiary",children:s}):e.jsx("span",{"aria-hidden":"true",className:"mt-[6px] h-1.5 w-1.5 shrink-0 rounded-full bg-fg-placeholder"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(h,{as:"div",variant:"label",weight:"medium",tone:"secondary",className:D("line-clamp-1",x),children:i}),o?e.jsx(h,{as:"div",variant:"micro",weight:"medium",tone:"secondary",className:"mt-0.5 !text-[11px] !leading-4",children:o}):null]})]})}),De=({note:t,type:a})=>e.jsx(te,{params:{id:t.id},header:e.jsx(T,{size:12}),title:t.title,meta:j(Number(a==="create"?t.createdAt:t.updatedAt)).format("HH:mm")}),Ee=({reminder:t})=>e.jsx(te,{params:{id:String(t.note?.id??t.noteId)},header:e.jsx(V,{size:12}),title:t.content||t.note?.title||"No title",titleClassName:t.completed?"line-through":"",meta:j(Number(t.reminderDate)).format("HH:mm")}),Ae=(t,a)=>t.map(s=>s.type==="note"?e.jsx(De,{note:s.item,type:a},`note-${s.item.id}`):e.jsx(Ee,{reminder:s.item},`reminder-${s.item.id}`)),q=(t,a)=>`${t} ${t===1?a:`${a}s`}`,Re="mt-3 flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto overscroll-y-contain pr-2 [scrollbar-color:var(--border-secondary)_transparent] [scrollbar-width:thin] [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-border-secondary [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar]:w-1.5",ae=t=>j(new Date(t.year,t.month-1,t.day)).format("dddd, MMMM D"),Q=({day:t,type:a,isLoading:s,presentation:i="rail"})=>{const o=l.useMemo(()=>{if(!t)return[];const d=t.notes.map(n=>({type:"note",item:n})),u=t.reminders.map(n=>({type:"reminder",item:n}));return t.isPast?[...d,...u]:[...u,...d]},[t]);if(!t)return e.jsx("section",{"aria-label":"Day details",className:"flex h-full min-h-40 items-center justify-center text-center",children:e.jsx(h,{as:"p",variant:"meta",weight:"medium",tone:"secondary",children:"Select a day to see its activity."})});const x=ae(t),p=s?"Loading activity...":[q(t.notes.length,"note"),q(t.reminders.length,"reminder")].join(" · "),c=s?null:e.jsx("div",{className:i==="rail"?Re:"flex flex-col gap-1",children:o.length>0?Ae(o,a):e.jsx(h,{as:"p",variant:"meta",weight:"medium",tone:"secondary",className:"py-8 text-center",children:"No activity on this day."})});return i==="modal"?e.jsxs("div",{"aria-label":`${x} activity`,children:[e.jsx(h,{as:"p",variant:"label",weight:"medium",tone:"secondary",className:"mb-3",children:p}),c]}):e.jsxs("section",{"aria-label":`${x} details`,className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"flex shrink-0 items-start gap-2 border-b border-border-subtle/80 pb-3",children:[e.jsx(G,{"aria-hidden":"true",className:"mt-0.5 shrink-0 text-fg-tertiary",size:15}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(h,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",children:x}),e.jsx(h,{as:"p",variant:"label",weight:"medium",tone:"secondary",className:"mt-0.5",children:p})]})]}),c]})},ke=["January","February","March","April","May","June","July","August","September","October","November","December"],$e=({month:t,year:a,type:s,onPrevMonth:i,onNextMonth:o,onToday:x,onTypeChange:p})=>e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-x-2.5 gap-y-1",children:[e.jsx(h,{as:"h1",variant:"display",weight:"bold",tracking:"tighter",className:"text-2xl leading-none sm:text-[2.15rem]",children:ke[t-1]}),e.jsx(h,{as:"span",variant:"subheading",weight:"medium",tone:"secondary",tracking:"tight",className:"pb-0.5",children:a})]}),e.jsx(h,{as:"p",variant:"meta",weight:"medium",tone:"secondary",className:"hidden sm:block",children:"Track note activity and reminders across the month"})]}),e.jsx("div",{className:"flex lg:justify-end",children:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:inline-flex sm:w-auto sm:flex-row sm:items-center sm:gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(h,{id:"calendar-note-date-label",as:"span",variant:"label",weight:"medium",tone:"secondary",children:"Note date"}),e.jsxs(xe,{value:s,"aria-labelledby":"calendar-note-date-label",onValueChange:d=>p(d),variant:"ghost",size:"sm",children:[e.jsx(P,{value:"create",children:"Created"}),e.jsx(P,{value:"update",children:"Updated"})]})]}),e.jsx("div",{className:"hidden h-5 w-px bg-divider sm:block"}),e.jsxs("div",{className:"flex items-center justify-between sm:justify-start sm:gap-1.5",children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:x,children:"Today"}),e.jsxs("div",{className:"flex items-center gap-1",role:"group","aria-label":"Month navigation",children:[e.jsx(S,{variant:"ghost",size:"icon-sm","aria-label":"Previous month",onClick:i,children:e.jsx(pe,{width:18,height:18})}),e.jsx(S,{variant:"ghost",size:"icon-sm","aria-label":"Next month",onClick:o,children:e.jsx(ue,{width:18,height:18})})]})]})]})})]}),He=["SUN","MON","TUE","WED","THU","FRI","SAT"],W="(min-width: 1280px)",Ce=({days:t,type:a,isLoading:s,selectedDayKey:i,onSelectedDayChange:o})=>{const[x,p]=l.useState(!1),c=l.useMemo(()=>t.find(n=>n.key===i),[t,i]);l.useEffect(()=>{const n=window.matchMedia(W),y=w=>{w.matches&&p(!1)};return n.addEventListener("change",y),()=>n.removeEventListener("change",y)},[]);const d=n=>{o(n),window.matchMedia(W).matches||p(!0)},u=c?ae(c):"Day details";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-w-0 xl:grid xl:grid-cols-[minmax(0,1fr)_20rem] 2xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsx("section",{"aria-label":"Month overview","aria-busy":s,className:"min-w-0 xl:pr-5",children:e.jsx("div",{className:"overflow-x-auto overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:e.jsxs("div",{className:"min-w-[19rem]",children:[e.jsx("div",{className:"mb-2 grid grid-cols-7 gap-px",children:He.map((n,y)=>e.jsxs(h,{as:"div",variant:"label",weight:"semibold",tracking:"wider",transform:"uppercase",className:`py-1.5 text-center ${y===0?"text-fg-weekend":"text-fg-secondary"}`,children:[e.jsx("span",{"aria-hidden":"true",className:"sm:hidden",children:n.slice(0,1)}),e.jsx("span",{className:"hidden sm:inline",children:n})]},n))}),e.jsx("div",{className:"grid grid-cols-7 gap-px overflow-hidden rounded-[12px] border border-border-subtle/80 bg-border-subtle/70",children:t.map(n=>e.jsx(Me,{year:n.year,month:n.month,day:n.day,isCurrentMonth:n.isCurrentMonth,isSunday:n.isSunday,isToday:n.isToday,isSelected:n.key===i,isPast:n.isPast,notes:n.notes,reminders:n.reminders,onSelect:()=>d(n.key)},n.key))})]})})}),e.jsx("aside",{className:"relative hidden min-h-0 border-l border-border-subtle xl:block","aria-label":"Selected day",children:e.jsx("div",{className:"absolute inset-y-0 right-0 left-5",children:e.jsx(Q,{day:c,type:a,isLoading:s})})})]}),e.jsxs($,{isOpen:x&&!!c,onClose:()=>p(!1),variant:"inspect",className:"xl:hidden",children:[e.jsx($.Header,{title:u,onClose:()=>p(!1)}),e.jsxs($.Body,{children:[e.jsxs($.Description,{className:"sr-only",children:["View notes and reminders for ",u,"."]}),e.jsx(Q,{day:c,type:a,isLoading:s,presentation:"modal"})]})]})]})},Se=(t,a)=>({start:new Date(t,a-1,1).toISOString(),end:new Date(t,a,1).toISOString()}),B=t=>{const a=Number(t);return Number.isFinite(a)?a:Date.parse(t)},Ve=(t,a)=>{const s=a==="create"?"createdAt":"updatedAt";return[...t].sort((i,o)=>B(i[s])-B(o[s]))},Te=`
2
- query NotesInDateRange($dateRange: DateRangeInput) {
3
- notesInDateRange(dateRange: $dateRange) {
4
- id
5
- title
6
- createdAt
7
- updatedAt
8
- }
9
- }
10
- `,Ie=`
11
- query RemindersInDateRange($dateRange: DateRangeInput) {
12
- remindersInDateRange(dateRange: $dateRange) {
13
- id
14
- noteId
15
- reminderDate
16
- completed
17
- priority
18
- content
19
- note {
20
- id
21
- title
22
- }
23
- }
24
- }
25
- `,_e=async t=>{const a=await X(Te,{dateRange:t});if(a.type==="error")throw a;return a.notesInDateRange},Ze=async t=>{const a=await X(Ie,{dateRange:t});if(a.type==="error")throw a;return a.remindersInDateRange},Oe=({year:t,month:a})=>{const s=Se(t,a),i=L({queryKey:Y.calendar.notesInDateRange(t,a),queryFn:()=>_e(s)}),o=L({queryKey:Y.reminders.inDateRange(t,a),queryFn:()=>Ze(s)});return{notes:i.data??[],reminders:o.data??[],isLoading:i.isLoading||o.isLoading,isError:i.isError||o.isError}},Fe=[],Pe=[],J=ye(be);function Be(){const t=J.useNavigate(),{year:a,month:s,type:i}=J.useSearch(),o=`${a}-${s}`,[x,p]=l.useState(()=>({monthKey:o})),{notes:c,reminders:d,isLoading:u,isError:n}=Oe({year:a,month:s}),y=l.useMemo(()=>{const m=j(),f=`${m.year()}-${m.month()+1}-${m.date()}`,g=new Map;for(const r of c){const b=i==="create"?j(Number(r.createdAt)):j(Number(r.updatedAt)),N=`${b.year()}-${b.month()+1}-${b.date()}`,E=g.get(N)||[];E.push(r),g.set(N,E)}for(const[r,b]of g)g.set(r,Ve(b,i));const R=new Map;for(const r of d){const b=j(Number(r.reminderDate)),N=`${b.year()}-${b.month()+1}-${b.date()}`,E=R.get(N)||[];E.push(r),R.set(N,E)}const re=new Date(a,s-1,1),ie=new Date(a,s,0),I=re.getDay(),_=ie.getDate(),k=[],Z=s===1?12:s-1,O=s===1?a-1:a,le=new Date(O,Z,0).getDate();for(let r=I-1;r>=0;r--)k.push({day:le-r,isCurrentMonth:!1,year:O,month:Z});for(let r=1;r<=_;r++)k.push({day:r,isCurrentMonth:!0,year:a,month:s});const F=(I+_)%7,oe=F===0?0:7-F,ce=s===12?1:s+1,de=s===12?a+1:a;for(let r=1;r<=oe;r++)k.push({day:r,isCurrentMonth:!1,year:de,month:ce});return k.map((r,b)=>{const N=`${r.year}-${r.month}-${r.day}`,E=j(`${r.year}-${String(r.month).padStart(2,"0")}-${String(r.day).padStart(2,"0")}`);return{key:N,year:r.year,month:r.month,day:r.day,isCurrentMonth:r.isCurrentMonth,isSunday:b%7===0,isToday:N===f,isPast:E.isBefore(m,"day"),notes:g.get(N)||Fe,reminders:R.get(N)||Pe}})},[a,s,c,d,i]),w=y.find(m=>m.isCurrentMonth&&m.isToday)?.key,A=x.monthKey===o?x.dayKey??w:w,v=()=>{const m=s===1?12:s-1,f=s===1?a-1:a;t({search:g=>({...g,month:m,year:f})})},C=()=>{const m=s===12?1:s+1,f=s===12?a+1:a;t({search:g=>({...g,month:m,year:f})})},M=()=>{const m=j(),f=m.month()+1,g=m.year();p({monthKey:`${g}-${f}`,dayKey:`${g}-${f}-${m.date()}`}),t({search:R=>({...R,month:f,year:g})})},se=m=>{m&&t({search:f=>({...f,type:m})})},ne=m=>{p({monthKey:o,dayKey:m})};return e.jsx(ge,{title:"Calendar",variant:"none",children:n?e.jsx(Ne,{children:"Failed to load calendar data. Please try again later."}):e.jsxs("div",{className:"-mr-4",children:[e.jsx("div",{className:"border-b border-border-subtle/80 pb-4",children:e.jsx($e,{month:s,year:a,type:i,onPrevMonth:v,onNextMonth:C,onToday:M,onTypeChange:se})}),e.jsx("div",{className:"pt-4",children:e.jsx(Ce,{days:y,type:i,isLoading:u,selectedDayKey:A,onSelectedDayChange:ne})})]})})}export{Be as default};
@@ -1 +0,0 @@
1
- import{r as e,j as n}from"./floating-ui.react-dom-BWTnA00G.js";import{C as m,T as d}from"./time-DI902Sxa.js";const p=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M108,84a16,16,0,1,1,16,16A16,16,0,0,1,108,84Zm128,44A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Zm-72,36.68V132a20,20,0,0,0-20-20,12,12,0,0,0-4,23.32V168a20,20,0,0,0,20,20,12,12,0,0,0,4-23.32Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),e.createElement("path",{d:"M144,176a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176Zm88-48A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128ZM124,96a12,12,0,1,0-12-12A12,12,0,0,0,124,96Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-4,48a12,12,0,1,1-12,12A12,12,0,0,1,124,72Zm12,112a16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40a8,8,0,0,1,0,16Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M142,176a6,6,0,0,1-6,6,14,14,0,0,1-14-14V128a2,2,0,0,0-2-2,6,6,0,0,1,0-12,14,14,0,0,1,14,14v40a2,2,0,0,0,2,2A6,6,0,0,1,142,176ZM124,94a10,10,0,1,0-10-10A10,10,0,0,0,124,94Zm106,34A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M140,176a4,4,0,0,1-4,4,12,12,0,0,1-12-12V128a4,4,0,0,0-4-4,4,4,0,0,1,0-8,12,12,0,0,1,12,12v40a4,4,0,0,0,4,4A4,4,0,0,1,140,176ZM124,92a8,8,0,1,0-8-8A8,8,0,0,0,124,92Zm104,36A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z"}))]]),g=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Zm-12-80V80a12,12,0,0,1,24,0v52a12,12,0,0,1-24,0Zm28,40a16,16,0,1,1-16-16A16,16,0,0,1,144,172Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-8,56a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm8,104a12,12,0,1,1,12-12A12,12,0,0,1,128,184Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Zm-6-82V80a6,6,0,0,1,12,0v56a6,6,0,0,1-12,0Zm16,36a10,10,0,1,1-10-10A10,10,0,0,1,138,172Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm-8-80V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,172Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Zm-4-84V80a4,4,0,0,1,8,0v56a4,4,0,0,1-8,0Zm12,36a8,8,0,1,1-8-8A8,8,0,0,1,136,172Z"}))]]),l=e.forwardRef((a,t)=>e.createElement(m,{ref:t,...a,weights:p}));l.displayName="InfoIcon";const E=l,c=e.forwardRef((a,t)=>e.createElement(m,{ref:t,...a,weights:g}));c.displayName="WarningCircleIcon";const i=c,M=({children:a,className:t="",tone:r="info"})=>{const o=r==="danger"?i:E,Z=r==="danger"?"border-border-error/70 bg-accent-soft-danger/60":"border-border-subtle bg-hover-subtle/50",s=r==="danger"?"text-fg-error":"text-fg-tertiary",A=r==="danger"?"error":"secondary";return n.jsxs("div",{className:`flex items-center gap-2.5 rounded-[12px] border px-4 py-3 ${Z} ${t}`,children:[n.jsx(o,{className:`h-4 w-4 shrink-0 ${s}`}),n.jsx(d,{as:"div",variant:"meta",weight:"medium",tone:A,children:a})]})};export{M as C,E as c,i as m};