@tasknotes/calendar 0.1.3 → 0.1.4
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/CHANGELOG.md +13 -0
- package/README.md +6 -2
- package/dist/calendar.css +76 -5
- package/dist/cjs/index.cjs +362 -216
- package/dist/cjs/react.cjs +362 -216
- package/dist/esm/{chunk-XHPZ7K4W.js → chunk-26DEUGQH.js} +362 -216
- package/dist/esm/index.js +1 -1
- package/dist/esm/react.js +1 -1
- package/dist/types/dom/calendar.d.cts +14 -1
- package/dist/types/dom/calendar.d.ts +14 -1
- package/dist/types/dom/context.d.cts +4 -3
- package/dist/types/dom/context.d.ts +4 -3
- package/dist/types/dom/options.d.cts +33 -2
- package/dist/types/dom/options.d.ts +33 -2
- package/dist/types/dom/views/list.d.cts +10 -8
- package/dist/types/dom/views/list.d.ts +10 -8
- package/dist/types/dom/views/strip.d.cts +26 -6
- package/dist/types/dom/views/strip.d.ts +26 -6
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
package/dist/esm/react.js
CHANGED
|
@@ -6,6 +6,7 @@ import { type TimeZone } from "../core/zone.cjs";
|
|
|
6
6
|
import { type ElMeta, type ViewContext } from "./context.cjs";
|
|
7
7
|
import { Formatter } from "./format.cjs";
|
|
8
8
|
import { type CalendarOptions, type CalendarText, type DayArg, type ExternalDragSource, type Hit, type TimelineAnchor, type ViewInfo, type ViewType } from "./options.cjs";
|
|
9
|
+
import { DateStrip } from "./views/strip.cjs";
|
|
9
10
|
/**
|
|
10
11
|
* A calendar bound to one element. Works in any document, including Obsidian
|
|
11
12
|
* popout windows: all listeners, timers and observers use the element's window.
|
|
@@ -40,6 +41,9 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
|
|
|
40
41
|
id: string;
|
|
41
42
|
rowId: string;
|
|
42
43
|
} | null;
|
|
44
|
+
strip: DateStrip<D> | null;
|
|
45
|
+
private stripSize;
|
|
46
|
+
private rebuilding;
|
|
43
47
|
private readonly toolbarEl;
|
|
44
48
|
private readonly viewHost;
|
|
45
49
|
private current;
|
|
@@ -149,8 +153,17 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
|
|
|
149
153
|
private computeRange;
|
|
150
154
|
private computeTitle;
|
|
151
155
|
private rebuild;
|
|
152
|
-
/** Sets the visible days and view info from the anchor
|
|
156
|
+
/** Sets the visible days and view info from the anchor. */
|
|
153
157
|
private applyRange;
|
|
158
|
+
/** The range, run on to the end of the strip's days so their dots are right. */
|
|
159
|
+
private dataRangeFor;
|
|
160
|
+
/** Adds, updates or removes the date strip for the current view. */
|
|
161
|
+
private syncStrip;
|
|
162
|
+
private pickStripDay;
|
|
163
|
+
/** The strip moved to other days: load theirs too. */
|
|
164
|
+
private stripShown;
|
|
165
|
+
/** What is under a point, the date strip included. */
|
|
166
|
+
private hitAt;
|
|
154
167
|
private agendaList;
|
|
155
168
|
extendList(endDay: Day): void;
|
|
156
169
|
showListDay(day: Day): void;
|
|
@@ -6,6 +6,7 @@ import { type TimeZone } from "../core/zone.js";
|
|
|
6
6
|
import { type ElMeta, type ViewContext } from "./context.js";
|
|
7
7
|
import { Formatter } from "./format.js";
|
|
8
8
|
import { type CalendarOptions, type CalendarText, type DayArg, type ExternalDragSource, type Hit, type TimelineAnchor, type ViewInfo, type ViewType } from "./options.js";
|
|
9
|
+
import { DateStrip } from "./views/strip.js";
|
|
9
10
|
/**
|
|
10
11
|
* A calendar bound to one element. Works in any document, including Obsidian
|
|
11
12
|
* popout windows: all listeners, timers and observers use the element's window.
|
|
@@ -40,6 +41,9 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
|
|
|
40
41
|
id: string;
|
|
41
42
|
rowId: string;
|
|
42
43
|
} | null;
|
|
44
|
+
strip: DateStrip<D> | null;
|
|
45
|
+
private stripSize;
|
|
46
|
+
private rebuilding;
|
|
43
47
|
private readonly toolbarEl;
|
|
44
48
|
private readonly viewHost;
|
|
45
49
|
private current;
|
|
@@ -149,8 +153,17 @@ export declare class Calendar<D = unknown> implements ViewContext<D> {
|
|
|
149
153
|
private computeRange;
|
|
150
154
|
private computeTitle;
|
|
151
155
|
private rebuild;
|
|
152
|
-
/** Sets the visible days and view info from the anchor
|
|
156
|
+
/** Sets the visible days and view info from the anchor. */
|
|
153
157
|
private applyRange;
|
|
158
|
+
/** The range, run on to the end of the strip's days so their dots are right. */
|
|
159
|
+
private dataRangeFor;
|
|
160
|
+
/** Adds, updates or removes the date strip for the current view. */
|
|
161
|
+
private syncStrip;
|
|
162
|
+
private pickStripDay;
|
|
163
|
+
/** The strip moved to other days: load theirs too. */
|
|
164
|
+
private stripShown;
|
|
165
|
+
/** What is under a point, the date strip included. */
|
|
166
|
+
private hitAt;
|
|
154
167
|
private agendaList;
|
|
155
168
|
extendList(endDay: Day): void;
|
|
156
169
|
showListDay(day: Day): void;
|
|
@@ -5,6 +5,7 @@ import type { NormalizedItem } from "../core/types.cjs";
|
|
|
5
5
|
import type { TimeZone } from "../core/zone.cjs";
|
|
6
6
|
import type { Formatter } from "./format.cjs";
|
|
7
7
|
import type { CalendarOptions, CalendarText, DayArg, Hit, ItemVariant, ViewInfo } from "./options.cjs";
|
|
8
|
+
import type { DateStrip } from "./views/strip.cjs";
|
|
8
9
|
export type Variant = ItemVariant;
|
|
9
10
|
export interface ElMeta<D = unknown> {
|
|
10
11
|
n: NormalizedItem<D>;
|
|
@@ -70,8 +71,10 @@ export interface ViewContext<D = unknown> {
|
|
|
70
71
|
id: string;
|
|
71
72
|
rowId: string;
|
|
72
73
|
} | null;
|
|
73
|
-
/** Reports a day picked outside the grid (year days
|
|
74
|
+
/** Reports a day picked outside the grid (year days) through `onDateClick`. */
|
|
74
75
|
dateClick(day: Day, jsEvent: MouseEvent | KeyboardEvent): void;
|
|
76
|
+
/** The date strip, when the view has one. */
|
|
77
|
+
readonly strip: DateStrip<D> | null;
|
|
75
78
|
/** Agenda lists: grows the range to end at `endDay`. */
|
|
76
79
|
extendList(endDay: Day): void;
|
|
77
80
|
/** Agenda lists: brings `day` to the top, moving the range to reach it. */
|
|
@@ -97,8 +100,6 @@ export interface View {
|
|
|
97
100
|
scrollToTime?(minute: number): void;
|
|
98
101
|
/** Item elements currently shown for an id. */
|
|
99
102
|
elementsFor(id: string): HTMLElement[];
|
|
100
|
-
/** A drag ended, dropped or not. */
|
|
101
|
-
dragEnded?(): void;
|
|
102
103
|
destroy(): void;
|
|
103
104
|
}
|
|
104
105
|
export declare class ItemPool<D> {
|
|
@@ -5,6 +5,7 @@ import type { NormalizedItem } from "../core/types.js";
|
|
|
5
5
|
import type { TimeZone } from "../core/zone.js";
|
|
6
6
|
import type { Formatter } from "./format.js";
|
|
7
7
|
import type { CalendarOptions, CalendarText, DayArg, Hit, ItemVariant, ViewInfo } from "./options.js";
|
|
8
|
+
import type { DateStrip } from "./views/strip.js";
|
|
8
9
|
export type Variant = ItemVariant;
|
|
9
10
|
export interface ElMeta<D = unknown> {
|
|
10
11
|
n: NormalizedItem<D>;
|
|
@@ -70,8 +71,10 @@ export interface ViewContext<D = unknown> {
|
|
|
70
71
|
id: string;
|
|
71
72
|
rowId: string;
|
|
72
73
|
} | null;
|
|
73
|
-
/** Reports a day picked outside the grid (year days
|
|
74
|
+
/** Reports a day picked outside the grid (year days) through `onDateClick`. */
|
|
74
75
|
dateClick(day: Day, jsEvent: MouseEvent | KeyboardEvent): void;
|
|
76
|
+
/** The date strip, when the view has one. */
|
|
77
|
+
readonly strip: DateStrip<D> | null;
|
|
75
78
|
/** Agenda lists: grows the range to end at `endDay`. */
|
|
76
79
|
extendList(endDay: Day): void;
|
|
77
80
|
/** Agenda lists: brings `day` to the top, moving the range to reach it. */
|
|
@@ -97,8 +100,6 @@ export interface View {
|
|
|
97
100
|
scrollToTime?(minute: number): void;
|
|
98
101
|
/** Item elements currently shown for an id. */
|
|
99
102
|
elementsFor(id: string): HTMLElement[];
|
|
100
|
-
/** A drag ended, dropped or not. */
|
|
101
|
-
dragEnded?(): void;
|
|
102
103
|
destroy(): void;
|
|
103
104
|
}
|
|
104
105
|
export declare class ItemPool<D> {
|
|
@@ -14,6 +14,12 @@ export interface ViewInfo {
|
|
|
14
14
|
/** Anchor date the view was built around. */
|
|
15
15
|
anchor: Day;
|
|
16
16
|
title: string;
|
|
17
|
+
/**
|
|
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
|
|
20
|
+
* items for this range; `onRangeChange` fires when it changes too.
|
|
21
|
+
*/
|
|
22
|
+
dataRange: DateRange;
|
|
17
23
|
}
|
|
18
24
|
/** Where a pointer is over the calendar. */
|
|
19
25
|
export type Hit = {
|
|
@@ -291,6 +297,31 @@ export interface CalendarOptions<D = unknown> {
|
|
|
291
297
|
* dragged onto a strip day or another day's section move there.
|
|
292
298
|
*/
|
|
293
299
|
listAgenda: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Puts the agenda's date strip above the "day", "days" and "week" views
|
|
302
|
+
* too. Picking a strip day moves the grid to it, and items dragged onto a
|
|
303
|
+
* strip day move there at the same time.
|
|
304
|
+
*/
|
|
305
|
+
dateStrip: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Agenda lists: a section above the first day, titled with this text, for
|
|
308
|
+
* items `listLeadIncludes` picks out (overdue work, say). Those items show
|
|
309
|
+
* there instead of under their day. Null for none.
|
|
310
|
+
*/
|
|
311
|
+
listLeadTitle: string | null;
|
|
312
|
+
listLeadIncludes?: (item: CalendarItem<D>) => boolean;
|
|
313
|
+
/** The lead section's header has an empty slot for host controls (a "Reschedule" button, say). */
|
|
314
|
+
listLeadDidMount?: (arg: {
|
|
315
|
+
el: HTMLElement;
|
|
316
|
+
}) => void;
|
|
317
|
+
listLeadWillUnmount?: (arg: {
|
|
318
|
+
el: HTMLElement;
|
|
319
|
+
}) => void;
|
|
320
|
+
/** Agenda lists: an add row with this label under every day, reported through `onListAdd`. Null for none. */
|
|
321
|
+
listAddText: string | null;
|
|
322
|
+
onListAdd?: (arg: DayArg & {
|
|
323
|
+
jsEvent: MouseEvent | KeyboardEvent;
|
|
324
|
+
}) => void;
|
|
294
325
|
/**
|
|
295
326
|
* Month cells: "full" draws bars and titled entries; "dots" draws every
|
|
296
327
|
* item as a small dot that wraps across the cell, with a "+N" count when
|
|
@@ -402,13 +433,13 @@ export interface CalendarOptions<D = unknown> {
|
|
|
402
433
|
dayHeaderContent?: (arg: DayArg) => Node | string | null | undefined;
|
|
403
434
|
dayHeaderDidMount?: (arg: DayHeaderArg) => void;
|
|
404
435
|
/**
|
|
405
|
-
* The
|
|
436
|
+
* The date strip's header has an empty slot after its arrows. Mount host
|
|
406
437
|
* controls (a layout menu, say) into `el`; the calendar leaves it alone.
|
|
407
438
|
*/
|
|
408
439
|
stripSlotDidMount?: (arg: {
|
|
409
440
|
el: HTMLElement;
|
|
410
441
|
}) => void;
|
|
411
|
-
/** The
|
|
442
|
+
/** The date strip's slot is about to be removed. */
|
|
412
443
|
stripSlotWillUnmount?: (arg: {
|
|
413
444
|
el: HTMLElement;
|
|
414
445
|
}) => void;
|
|
@@ -14,6 +14,12 @@ export interface ViewInfo {
|
|
|
14
14
|
/** Anchor date the view was built around. */
|
|
15
15
|
anchor: Day;
|
|
16
16
|
title: string;
|
|
17
|
+
/**
|
|
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
|
|
20
|
+
* items for this range; `onRangeChange` fires when it changes too.
|
|
21
|
+
*/
|
|
22
|
+
dataRange: DateRange;
|
|
17
23
|
}
|
|
18
24
|
/** Where a pointer is over the calendar. */
|
|
19
25
|
export type Hit = {
|
|
@@ -291,6 +297,31 @@ export interface CalendarOptions<D = unknown> {
|
|
|
291
297
|
* dragged onto a strip day or another day's section move there.
|
|
292
298
|
*/
|
|
293
299
|
listAgenda: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Puts the agenda's date strip above the "day", "days" and "week" views
|
|
302
|
+
* too. Picking a strip day moves the grid to it, and items dragged onto a
|
|
303
|
+
* strip day move there at the same time.
|
|
304
|
+
*/
|
|
305
|
+
dateStrip: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* Agenda lists: a section above the first day, titled with this text, for
|
|
308
|
+
* items `listLeadIncludes` picks out (overdue work, say). Those items show
|
|
309
|
+
* there instead of under their day. Null for none.
|
|
310
|
+
*/
|
|
311
|
+
listLeadTitle: string | null;
|
|
312
|
+
listLeadIncludes?: (item: CalendarItem<D>) => boolean;
|
|
313
|
+
/** The lead section's header has an empty slot for host controls (a "Reschedule" button, say). */
|
|
314
|
+
listLeadDidMount?: (arg: {
|
|
315
|
+
el: HTMLElement;
|
|
316
|
+
}) => void;
|
|
317
|
+
listLeadWillUnmount?: (arg: {
|
|
318
|
+
el: HTMLElement;
|
|
319
|
+
}) => void;
|
|
320
|
+
/** Agenda lists: an add row with this label under every day, reported through `onListAdd`. Null for none. */
|
|
321
|
+
listAddText: string | null;
|
|
322
|
+
onListAdd?: (arg: DayArg & {
|
|
323
|
+
jsEvent: MouseEvent | KeyboardEvent;
|
|
324
|
+
}) => void;
|
|
294
325
|
/**
|
|
295
326
|
* Month cells: "full" draws bars and titled entries; "dots" draws every
|
|
296
327
|
* item as a small dot that wraps across the cell, with a "+N" count when
|
|
@@ -402,13 +433,13 @@ export interface CalendarOptions<D = unknown> {
|
|
|
402
433
|
dayHeaderContent?: (arg: DayArg) => Node | string | null | undefined;
|
|
403
434
|
dayHeaderDidMount?: (arg: DayHeaderArg) => void;
|
|
404
435
|
/**
|
|
405
|
-
* The
|
|
436
|
+
* The date strip's header has an empty slot after its arrows. Mount host
|
|
406
437
|
* controls (a layout menu, say) into `el`; the calendar leaves it alone.
|
|
407
438
|
*/
|
|
408
439
|
stripSlotDidMount?: (arg: {
|
|
409
440
|
el: HTMLElement;
|
|
410
441
|
}) => void;
|
|
411
|
-
/** The
|
|
442
|
+
/** The date strip's slot is about to be removed. */
|
|
412
443
|
stripSlotWillUnmount?: (arg: {
|
|
413
444
|
el: HTMLElement;
|
|
414
445
|
}) => void;
|
|
@@ -4,29 +4,32 @@ import { type Selection, type View, type ViewContext } from "../context.cjs";
|
|
|
4
4
|
import type { Hit } from "../options.cjs";
|
|
5
5
|
/**
|
|
6
6
|
* N-day agenda: one section per day that has items. With `listAgenda`, every
|
|
7
|
-
* day gets a section,
|
|
8
|
-
* load as the list nears its end.
|
|
7
|
+
* day gets a section, the calendar's date strip follows the day at the top,
|
|
8
|
+
* and more days load as the list nears its end. A lead section above the
|
|
9
|
+
* first day can collect items such as overdue work.
|
|
9
10
|
*/
|
|
10
11
|
export declare class ListView<D> implements View {
|
|
11
12
|
private readonly ctx;
|
|
12
13
|
readonly el: HTMLElement;
|
|
13
14
|
private readonly scroller;
|
|
14
15
|
private readonly body;
|
|
16
|
+
private readonly agenda;
|
|
15
17
|
private pools;
|
|
16
18
|
private sections;
|
|
17
|
-
private
|
|
19
|
+
private lead;
|
|
18
20
|
private readonly sentinel;
|
|
19
21
|
private readonly loader;
|
|
20
|
-
private readonly stripSize;
|
|
21
22
|
private frame;
|
|
22
23
|
/** A picked day stays marked until the list is scrolled by hand. */
|
|
23
24
|
private pinned;
|
|
24
25
|
constructor(ctx: ViewContext<D>);
|
|
25
26
|
private itemsOn;
|
|
26
27
|
render(_change: StoreChange | null): void;
|
|
27
|
-
/**
|
|
28
|
-
private
|
|
29
|
-
|
|
28
|
+
/** Places items in a pool, keeping DOM order equal to item order. */
|
|
29
|
+
private fill;
|
|
30
|
+
private renderLead;
|
|
31
|
+
private addRow;
|
|
32
|
+
/** Brings a day's section to the top, under the strip; the first day brings the lead section too. */
|
|
30
33
|
scrollToDay(day: Day): void;
|
|
31
34
|
private readonly fold;
|
|
32
35
|
private readonly onScroll;
|
|
@@ -34,7 +37,6 @@ export declare class ListView<D> implements View {
|
|
|
34
37
|
private followTop;
|
|
35
38
|
showSelection(_sel: Selection | null): void;
|
|
36
39
|
hit(x: number, y: number): Hit | null;
|
|
37
|
-
dragEnded(): void;
|
|
38
40
|
getScroll(): {
|
|
39
41
|
top: number;
|
|
40
42
|
left: number;
|
|
@@ -4,29 +4,32 @@ import { type Selection, type View, type ViewContext } from "../context.js";
|
|
|
4
4
|
import type { Hit } from "../options.js";
|
|
5
5
|
/**
|
|
6
6
|
* N-day agenda: one section per day that has items. With `listAgenda`, every
|
|
7
|
-
* day gets a section,
|
|
8
|
-
* load as the list nears its end.
|
|
7
|
+
* day gets a section, the calendar's date strip follows the day at the top,
|
|
8
|
+
* and more days load as the list nears its end. A lead section above the
|
|
9
|
+
* first day can collect items such as overdue work.
|
|
9
10
|
*/
|
|
10
11
|
export declare class ListView<D> implements View {
|
|
11
12
|
private readonly ctx;
|
|
12
13
|
readonly el: HTMLElement;
|
|
13
14
|
private readonly scroller;
|
|
14
15
|
private readonly body;
|
|
16
|
+
private readonly agenda;
|
|
15
17
|
private pools;
|
|
16
18
|
private sections;
|
|
17
|
-
private
|
|
19
|
+
private lead;
|
|
18
20
|
private readonly sentinel;
|
|
19
21
|
private readonly loader;
|
|
20
|
-
private readonly stripSize;
|
|
21
22
|
private frame;
|
|
22
23
|
/** A picked day stays marked until the list is scrolled by hand. */
|
|
23
24
|
private pinned;
|
|
24
25
|
constructor(ctx: ViewContext<D>);
|
|
25
26
|
private itemsOn;
|
|
26
27
|
render(_change: StoreChange | null): void;
|
|
27
|
-
/**
|
|
28
|
-
private
|
|
29
|
-
|
|
28
|
+
/** Places items in a pool, keeping DOM order equal to item order. */
|
|
29
|
+
private fill;
|
|
30
|
+
private renderLead;
|
|
31
|
+
private addRow;
|
|
32
|
+
/** Brings a day's section to the top, under the strip; the first day brings the lead section too. */
|
|
30
33
|
scrollToDay(day: Day): void;
|
|
31
34
|
private readonly fold;
|
|
32
35
|
private readonly onScroll;
|
|
@@ -34,7 +37,6 @@ export declare class ListView<D> implements View {
|
|
|
34
37
|
private followTop;
|
|
35
38
|
showSelection(_sel: Selection | null): void;
|
|
36
39
|
hit(x: number, y: number): Hit | null;
|
|
37
|
-
dragEnded(): void;
|
|
38
40
|
getScroll(): {
|
|
39
41
|
top: number;
|
|
40
42
|
left: number;
|
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
import { type Day } from "../../core/date.cjs";
|
|
2
2
|
import type { ViewContext } from "../context.cjs";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* with items carry a dot; the day
|
|
6
|
-
*
|
|
4
|
+
* A date strip above the agenda or a time grid: one week, or the whole month
|
|
5
|
+
* when expanded. Days with items carry a dot; the focus day (the top of the
|
|
6
|
+
* list, or the grid's first day) is marked, and the rest of a grid's range is
|
|
7
|
+
* tinted. Picking a day hands it to the calendar, and swipes step a week (or
|
|
8
|
+
* a month).
|
|
7
9
|
*/
|
|
8
10
|
export declare class DateStrip<D> {
|
|
9
11
|
private readonly ctx;
|
|
10
12
|
private readonly pick;
|
|
13
|
+
/** Called when the days on show change, so their items can be loaded. */
|
|
14
|
+
private readonly onShown;
|
|
11
15
|
readonly el: HTMLElement;
|
|
12
16
|
private readonly title;
|
|
13
17
|
private readonly dows;
|
|
14
18
|
private readonly grid;
|
|
15
19
|
private readonly slot;
|
|
20
|
+
private readonly todayBtn;
|
|
16
21
|
/** Day at the top of the list. */
|
|
17
22
|
private focus;
|
|
18
23
|
/** First day of the week shown, or the month shown when expanded. */
|
|
19
24
|
private shown;
|
|
20
25
|
private target;
|
|
26
|
+
/** Days tinted as on screen besides the focus (a time grid's range). */
|
|
27
|
+
private range;
|
|
28
|
+
private shownKey;
|
|
21
29
|
private swipe;
|
|
22
30
|
private swallowClick;
|
|
23
31
|
expanded: boolean;
|
|
24
|
-
constructor(ctx: ViewContext<D>, pick: (day: Day, ev: MouseEvent | KeyboardEvent) => void, focus: Day
|
|
25
|
-
/**
|
|
26
|
-
|
|
32
|
+
constructor(ctx: ViewContext<D>, pick: (day: Day, ev: MouseEvent | KeyboardEvent) => void, focus: Day,
|
|
33
|
+
/** Called when the days on show change, so their items can be loaded. */
|
|
34
|
+
onShown: () => void);
|
|
35
|
+
/** The list scrolled or the grid moved: mark the day and keep it in view. */
|
|
36
|
+
setFocus(day: Day, range?: {
|
|
37
|
+
start: Day;
|
|
38
|
+
end: Day;
|
|
39
|
+
} | null): void;
|
|
40
|
+
/** Publishes the strip's height as `--tnc-strip-h`, for what sticks below it. */
|
|
41
|
+
measure(): void;
|
|
42
|
+
/** First day and end (exclusive) of the days on show. */
|
|
43
|
+
window(): {
|
|
44
|
+
start: Day;
|
|
45
|
+
end: Day;
|
|
46
|
+
};
|
|
27
47
|
setExpanded(on: boolean): void;
|
|
28
48
|
/** Highlights the day a dragged item would land on. */
|
|
29
49
|
markTarget(day: Day | null): void;
|
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
import { type Day } from "../../core/date.js";
|
|
2
2
|
import type { ViewContext } from "../context.js";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* with items carry a dot; the day
|
|
6
|
-
*
|
|
4
|
+
* A date strip above the agenda or a time grid: one week, or the whole month
|
|
5
|
+
* when expanded. Days with items carry a dot; the focus day (the top of the
|
|
6
|
+
* list, or the grid's first day) is marked, and the rest of a grid's range is
|
|
7
|
+
* tinted. Picking a day hands it to the calendar, and swipes step a week (or
|
|
8
|
+
* a month).
|
|
7
9
|
*/
|
|
8
10
|
export declare class DateStrip<D> {
|
|
9
11
|
private readonly ctx;
|
|
10
12
|
private readonly pick;
|
|
13
|
+
/** Called when the days on show change, so their items can be loaded. */
|
|
14
|
+
private readonly onShown;
|
|
11
15
|
readonly el: HTMLElement;
|
|
12
16
|
private readonly title;
|
|
13
17
|
private readonly dows;
|
|
14
18
|
private readonly grid;
|
|
15
19
|
private readonly slot;
|
|
20
|
+
private readonly todayBtn;
|
|
16
21
|
/** Day at the top of the list. */
|
|
17
22
|
private focus;
|
|
18
23
|
/** First day of the week shown, or the month shown when expanded. */
|
|
19
24
|
private shown;
|
|
20
25
|
private target;
|
|
26
|
+
/** Days tinted as on screen besides the focus (a time grid's range). */
|
|
27
|
+
private range;
|
|
28
|
+
private shownKey;
|
|
21
29
|
private swipe;
|
|
22
30
|
private swallowClick;
|
|
23
31
|
expanded: boolean;
|
|
24
|
-
constructor(ctx: ViewContext<D>, pick: (day: Day, ev: MouseEvent | KeyboardEvent) => void, focus: Day
|
|
25
|
-
/**
|
|
26
|
-
|
|
32
|
+
constructor(ctx: ViewContext<D>, pick: (day: Day, ev: MouseEvent | KeyboardEvent) => void, focus: Day,
|
|
33
|
+
/** Called when the days on show change, so their items can be loaded. */
|
|
34
|
+
onShown: () => void);
|
|
35
|
+
/** The list scrolled or the grid moved: mark the day and keep it in view. */
|
|
36
|
+
setFocus(day: Day, range?: {
|
|
37
|
+
start: Day;
|
|
38
|
+
end: Day;
|
|
39
|
+
} | null): void;
|
|
40
|
+
/** Publishes the strip's height as `--tnc-strip-h`, for what sticks below it. */
|
|
41
|
+
measure(): void;
|
|
42
|
+
/** First day and end (exclusive) of the days on show. */
|
|
43
|
+
window(): {
|
|
44
|
+
start: Day;
|
|
45
|
+
end: Day;
|
|
46
|
+
};
|
|
27
47
|
setExpanded(on: boolean): void;
|
|
28
48
|
/** Highlights the day a dragged item would land on. */
|
|
29
49
|
markTarget(day: Day | null): void;
|
package/package.json
CHANGED