@tasknotes/calendar 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  TIMELINE_UNIT_DAYS,
8
8
  defaultOptions,
9
9
  localeFirstDay
10
- } from "./chunk-URE7QLU3.js";
10
+ } from "./chunk-EXKFHPW2.js";
11
11
  import {
12
12
  DAY_MS,
13
13
  ItemStore,
package/dist/esm/react.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Calendar
3
- } from "./chunk-URE7QLU3.js";
3
+ } from "./chunk-EXKFHPW2.js";
4
4
  import "./chunk-66A6EMCU.js";
5
5
 
6
6
  // src/react/index.tsx
@@ -25,6 +25,7 @@ export interface CalendarItem<D = unknown> {
25
25
  backgroundColor?: string;
26
26
  borderColor?: string;
27
27
  textColor?: string;
28
+ timeDisplay?: "start" | "range";
28
29
  className?: string | string[];
29
30
  /** Host-managed temporary placement: inert, mirror-styled and never hidden by event limits. */
30
31
  preview?: boolean;
@@ -25,6 +25,7 @@ export interface CalendarItem<D = unknown> {
25
25
  backgroundColor?: string;
26
26
  borderColor?: string;
27
27
  textColor?: string;
28
+ timeDisplay?: "start" | "range";
28
29
  className?: string | string[];
29
30
  /** Host-managed temporary placement: inert, mirror-styled and never hidden by event limits. */
30
31
  preview?: boolean;
@@ -37,6 +37,11 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
37
37
  scroll: number;
38
38
  };
39
39
  draggingId: string | null;
40
+ private listDragPreview;
41
+ private dragSources;
42
+ private dragScrollFrame;
43
+ private readonly dragScrollOrigins;
44
+ private readonly itemWriteStates;
40
45
  dragRow: {
41
46
  id: string;
42
47
  rowId: string;
@@ -53,6 +58,7 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
53
58
  private session;
54
59
  private selection;
55
60
  private suppressClick;
61
+ private cancelledPointerId;
56
62
  private selectedIds;
57
63
  private popover;
58
64
  private timer;
@@ -136,7 +142,7 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
136
142
  suppressNextClick(): void;
137
143
  dayArg(day: Day): DayArg;
138
144
  dayClasses(day: Day): string[];
139
- isEditable(n: NormalizedItem<D>, what: "start" | "duration"): boolean;
145
+ isEditable(n: NormalizedItem<D>, what: "start" | "duration", presentation?: boolean): boolean;
140
146
  navLink(day: Day, label: Node | string, cls: string): HTMLElement;
141
147
  navigate(day: Day, jsEvent: MouseEvent | KeyboardEvent, view?: "day" | "month"): void;
142
148
  createItemEl(meta: ElMeta<D>): HTMLElement;
@@ -144,7 +150,7 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
144
150
  private selectedSet;
145
151
  private applySelected;
146
152
  destroyItemEl(el: HTMLElement): void;
147
- openMore(day: Day, anchor: HTMLElement, jsEvent: MouseEvent | KeyboardEvent): void;
153
+ openMore(day: Day, anchor: HTMLElement, jsEvent: MouseEvent | KeyboardEvent, itemIds?: readonly string[]): void;
148
154
  private resolveText;
149
155
  private todayDay;
150
156
  private toDay;
@@ -170,6 +176,7 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
170
176
  dateClick(day: Day, jsEvent: MouseEvent | KeyboardEvent): void;
171
177
  private createView;
172
178
  private renderToolbar;
179
+ private syncToolbarViewDisplay;
173
180
  private applyChange;
174
181
  /** Renders pending changes now. Called automatically on the next frame. */
175
182
  flush(): void;
@@ -184,6 +191,9 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
184
191
  private addHandles;
185
192
  /** Start and finish link handles (a milestone has one). */
186
193
  private addPorts;
194
+ private readonly onMoreGeometryChange;
195
+ private listenMoreGeometry;
196
+ private positionMore;
187
197
  private refreshMore;
188
198
  private closeMore;
189
199
  private bindEvents;
@@ -193,6 +203,7 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
193
203
  private readonly onDocPointerDown;
194
204
  private readonly onPointerDown;
195
205
  private activate;
206
+ private startDragScroll;
196
207
  private readonly onTouchMove;
197
208
  private readonly onPointerMove;
198
209
  private readonly onPointerUp;
@@ -200,6 +211,7 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
200
211
  private readonly onDocKeyDown;
201
212
  /** Proposal for the current pointer position. */
202
213
  private track;
214
+ private invalidateProposal;
203
215
  private trackExternal;
204
216
  private externalItem;
205
217
  private timelineSnap;
@@ -218,6 +230,7 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
218
230
  /** Ends the current pointer session, committing unless `cancel`. */
219
231
  private endSession;
220
232
  private commit;
233
+ private applyItemWriteState;
221
234
  /** Runs in the capture phase so the click ending a drag never reaches content inside the calendar, React portals included. */
222
235
  private readonly onClickCapture;
223
236
  private readonly onClick;
@@ -37,6 +37,11 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
37
37
  scroll: number;
38
38
  };
39
39
  draggingId: string | null;
40
+ private listDragPreview;
41
+ private dragSources;
42
+ private dragScrollFrame;
43
+ private readonly dragScrollOrigins;
44
+ private readonly itemWriteStates;
40
45
  dragRow: {
41
46
  id: string;
42
47
  rowId: string;
@@ -53,6 +58,7 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
53
58
  private session;
54
59
  private selection;
55
60
  private suppressClick;
61
+ private cancelledPointerId;
56
62
  private selectedIds;
57
63
  private popover;
58
64
  private timer;
@@ -136,7 +142,7 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
136
142
  suppressNextClick(): void;
137
143
  dayArg(day: Day): DayArg;
138
144
  dayClasses(day: Day): string[];
139
- isEditable(n: NormalizedItem<D>, what: "start" | "duration"): boolean;
145
+ isEditable(n: NormalizedItem<D>, what: "start" | "duration", presentation?: boolean): boolean;
140
146
  navLink(day: Day, label: Node | string, cls: string): HTMLElement;
141
147
  navigate(day: Day, jsEvent: MouseEvent | KeyboardEvent, view?: "day" | "month"): void;
142
148
  createItemEl(meta: ElMeta<D>): HTMLElement;
@@ -144,7 +150,7 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
144
150
  private selectedSet;
145
151
  private applySelected;
146
152
  destroyItemEl(el: HTMLElement): void;
147
- openMore(day: Day, anchor: HTMLElement, jsEvent: MouseEvent | KeyboardEvent): void;
153
+ openMore(day: Day, anchor: HTMLElement, jsEvent: MouseEvent | KeyboardEvent, itemIds?: readonly string[]): void;
148
154
  private resolveText;
149
155
  private todayDay;
150
156
  private toDay;
@@ -170,6 +176,7 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
170
176
  dateClick(day: Day, jsEvent: MouseEvent | KeyboardEvent): void;
171
177
  private createView;
172
178
  private renderToolbar;
179
+ private syncToolbarViewDisplay;
173
180
  private applyChange;
174
181
  /** Renders pending changes now. Called automatically on the next frame. */
175
182
  flush(): void;
@@ -184,6 +191,9 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
184
191
  private addHandles;
185
192
  /** Start and finish link handles (a milestone has one). */
186
193
  private addPorts;
194
+ private readonly onMoreGeometryChange;
195
+ private listenMoreGeometry;
196
+ private positionMore;
187
197
  private refreshMore;
188
198
  private closeMore;
189
199
  private bindEvents;
@@ -193,6 +203,7 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
193
203
  private readonly onDocPointerDown;
194
204
  private readonly onPointerDown;
195
205
  private activate;
206
+ private startDragScroll;
196
207
  private readonly onTouchMove;
197
208
  private readonly onPointerMove;
198
209
  private readonly onPointerUp;
@@ -200,6 +211,7 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
200
211
  private readonly onDocKeyDown;
201
212
  /** Proposal for the current pointer position. */
202
213
  private track;
214
+ private invalidateProposal;
203
215
  private trackExternal;
204
216
  private externalItem;
205
217
  private timelineSnap;
@@ -218,6 +230,7 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
218
230
  /** Ends the current pointer session, committing unless `cancel`. */
219
231
  private endSession;
220
232
  private commit;
233
+ private applyItemWriteState;
221
234
  /** Runs in the capture phase so the click ending a drag never reaches content inside the calendar, React portals included. */
222
235
  private readonly onClickCapture;
223
236
  private readonly onClick;
@@ -61,7 +61,7 @@ export interface ViewContext<D = unknown> {
61
61
  destroyItemEl(el: HTMLElement): void;
62
62
  /** Builds a nav link (day number / header) for a day. */
63
63
  navLink(day: Day, label: Node | string, cls: string): HTMLElement;
64
- openMore(day: Day, anchor: HTMLElement, jsEvent: MouseEvent | KeyboardEvent): void;
64
+ openMore(day: Day, anchor: HTMLElement, jsEvent: MouseEvent | KeyboardEvent, itemIds?: readonly string[]): void;
65
65
  /** Follows a date link: `onNavLink`, or switches to `view` at `day`. */
66
66
  navigate(day: Day, jsEvent: MouseEvent | KeyboardEvent, view?: "day" | "month"): void;
67
67
  /** Swallows the click that follows a drag the view handled itself. */
@@ -61,7 +61,7 @@ export interface ViewContext<D = unknown> {
61
61
  destroyItemEl(el: HTMLElement): void;
62
62
  /** Builds a nav link (day number / header) for a day. */
63
63
  navLink(day: Day, label: Node | string, cls: string): HTMLElement;
64
- openMore(day: Day, anchor: HTMLElement, jsEvent: MouseEvent | KeyboardEvent): void;
64
+ openMore(day: Day, anchor: HTMLElement, jsEvent: MouseEvent | KeyboardEvent, itemIds?: readonly string[]): void;
65
65
  /** Follows a date link: `onNavLink`, or switches to `view` at `day`. */
66
66
  navigate(day: Day, jsEvent: MouseEvent | KeyboardEvent, view?: "day" | "month"): void;
67
67
  /** Swallows the click that follows a drag the view handled itself. */
@@ -16,7 +16,7 @@ export interface ViewInfo {
16
16
  title: string;
17
17
  /**
18
18
  * The days whose items the calendar can show: `range`, extended to the
19
- * end of the days a date strip is showing so their dots are right. Load
19
+ * full window of days a date strip is showing so their dots are right. Load
20
20
  * items for this range; `onRangeChange` fires when it changes too.
21
21
  */
22
22
  dataRange: DateRange;
@@ -258,6 +258,7 @@ export interface ToolbarButton {
258
258
  export interface ToolbarOptions {
259
259
  /** View buttons, in order. */
260
260
  views?: ViewType[];
261
+ viewDisplay?: "auto" | "buttons" | "select";
261
262
  extraButtons?: ToolbarButton[];
262
263
  /** Extra buttons go before prev/next ("start") or after the view buttons ("end"). */
263
264
  extraPlacement?: "start" | "end";
@@ -269,6 +270,7 @@ export interface CalendarText {
269
270
  allDay: string;
270
271
  noItems: string;
271
272
  more: (n: number) => string;
273
+ appointments: (n: number) => string;
272
274
  /** Day-cell label suffix in `monthDisplay: "dots"`. */
273
275
  itemCount: (n: number) => string;
274
276
  weekNumber: (n: number) => string;
@@ -319,6 +321,7 @@ export interface CalendarOptions<D = unknown> {
319
321
  }) => void;
320
322
  /** Agenda lists: an add row with this label under every day, reported through `onListAdd`. Null for none. */
321
323
  listAddText: string | null;
324
+ listEmptyContent?: () => Node;
322
325
  onListAdd?: (arg: DayArg & {
323
326
  jsEvent: MouseEvent | KeyboardEvent;
324
327
  }) => void;
@@ -329,7 +332,7 @@ export interface CalendarOptions<D = unknown> {
329
332
  * the tap target: dots ignore the pointer and are hidden from assistive
330
333
  * technology, and the cell is labelled with its item count.
331
334
  */
332
- monthDisplay: "full" | "dots";
335
+ monthDisplay: "full" | "dots" | "chips";
333
336
  /** "local" or an IANA name. */
334
337
  timeZone: string;
335
338
  locale: string | undefined;
@@ -16,7 +16,7 @@ export interface ViewInfo {
16
16
  title: string;
17
17
  /**
18
18
  * The days whose items the calendar can show: `range`, extended to the
19
- * end of the days a date strip is showing so their dots are right. Load
19
+ * full window of days a date strip is showing so their dots are right. Load
20
20
  * items for this range; `onRangeChange` fires when it changes too.
21
21
  */
22
22
  dataRange: DateRange;
@@ -258,6 +258,7 @@ export interface ToolbarButton {
258
258
  export interface ToolbarOptions {
259
259
  /** View buttons, in order. */
260
260
  views?: ViewType[];
261
+ viewDisplay?: "auto" | "buttons" | "select";
261
262
  extraButtons?: ToolbarButton[];
262
263
  /** Extra buttons go before prev/next ("start") or after the view buttons ("end"). */
263
264
  extraPlacement?: "start" | "end";
@@ -269,6 +270,7 @@ export interface CalendarText {
269
270
  allDay: string;
270
271
  noItems: string;
271
272
  more: (n: number) => string;
273
+ appointments: (n: number) => string;
272
274
  /** Day-cell label suffix in `monthDisplay: "dots"`. */
273
275
  itemCount: (n: number) => string;
274
276
  weekNumber: (n: number) => string;
@@ -319,6 +321,7 @@ export interface CalendarOptions<D = unknown> {
319
321
  }) => void;
320
322
  /** Agenda lists: an add row with this label under every day, reported through `onListAdd`. Null for none. */
321
323
  listAddText: string | null;
324
+ listEmptyContent?: () => Node;
322
325
  onListAdd?: (arg: DayArg & {
323
326
  jsEvent: MouseEvent | KeyboardEvent;
324
327
  }) => void;
@@ -329,7 +332,7 @@ export interface CalendarOptions<D = unknown> {
329
332
  * the tap target: dots ignore the pointer and are hidden from assistive
330
333
  * technology, and the cell is labelled with its item count.
331
334
  */
332
- monthDisplay: "full" | "dots";
335
+ monthDisplay: "full" | "dots" | "chips";
333
336
  /** "local" or an IANA name. */
334
337
  timeZone: string;
335
338
  locale: string | undefined;
@@ -13,7 +13,7 @@ export declare class DayGridView<D> implements View {
13
13
  private morePx;
14
14
  private topPx;
15
15
  private lastHeights;
16
- private readonly dotsMode;
16
+ private dotsMode;
17
17
  constructor(ctx: ViewContext<D>);
18
18
  private daysPerWeek;
19
19
  private sizeKey;
@@ -13,7 +13,7 @@ export declare class DayGridView<D> implements View {
13
13
  private morePx;
14
14
  private topPx;
15
15
  private lastHeights;
16
- private readonly dotsMode;
16
+ private dotsMode;
17
17
  constructor(ctx: ViewContext<D>);
18
18
  private daysPerWeek;
19
19
  private sizeKey;
@@ -1,3 +1,4 @@
1
+ import { type Day } from "../../core/date.cjs";
1
2
  import type { StoreChange } from "../../core/store.cjs";
2
3
  import { type Selection, type View, type ViewContext } from "../context.cjs";
3
4
  import type { Hit } from "../options.cjs";
@@ -6,6 +7,7 @@ export declare class TimeGridView<D> implements View {
6
7
  private readonly ctx;
7
8
  readonly el: HTMLElement;
8
9
  private readonly scroller;
10
+ private readonly dayNavigation;
9
11
  private readonly top;
10
12
  private readonly headRow;
11
13
  private readonly allDayRow;
@@ -40,6 +42,8 @@ export declare class TimeGridView<D> implements View {
40
42
  hit(x: number, y: number): Hit | null;
41
43
  tick(): void;
42
44
  resize(): void;
45
+ revealDay(day: Day): void;
46
+ private updateDayNavigation;
43
47
  scrollToTime(minute: number): void;
44
48
  getScroll(): {
45
49
  top: number;
@@ -1,3 +1,4 @@
1
+ import { type Day } from "../../core/date.js";
1
2
  import type { StoreChange } from "../../core/store.js";
2
3
  import { type Selection, type View, type ViewContext } from "../context.js";
3
4
  import type { Hit } from "../options.js";
@@ -6,6 +7,7 @@ export declare class TimeGridView<D> implements View {
6
7
  private readonly ctx;
7
8
  readonly el: HTMLElement;
8
9
  private readonly scroller;
10
+ private readonly dayNavigation;
9
11
  private readonly top;
10
12
  private readonly headRow;
11
13
  private readonly allDayRow;
@@ -40,6 +42,8 @@ export declare class TimeGridView<D> implements View {
40
42
  hit(x: number, y: number): Hit | null;
41
43
  tick(): void;
42
44
  resize(): void;
45
+ revealDay(day: Day): void;
46
+ private updateDayNavigation;
43
47
  scrollToTime(minute: number): void;
44
48
  getScroll(): {
45
49
  top: number;
@@ -21,6 +21,7 @@ export declare class YearView<D> implements View {
21
21
  top: number;
22
22
  left: number;
23
23
  }): void;
24
+ revealDay(day: Day): void;
24
25
  elementsFor(_id: string): HTMLElement[];
25
26
  destroy(): void;
26
27
  }
@@ -21,6 +21,7 @@ export declare class YearView<D> implements View {
21
21
  top: number;
22
22
  left: number;
23
23
  }): void;
24
+ revealDay(day: Day): void;
24
25
  elementsFor(_id: string): HTMLElement[];
25
26
  destroy(): void;
26
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tasknotes/calendar",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Task-native calendar engine for TaskNotes: incremental layout, time grid, month, list, year and timeline views.",
5
5
  "license": "MIT",
6
6
  "type": "module",