@graview/primitives 0.1.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.
- package/LICENSE +96 -0
- package/README.md +25 -0
- package/dist/arrange-bar.d.ts +49 -0
- package/dist/arrange-bar.d.ts.map +1 -0
- package/dist/arrange-bar.js +264 -0
- package/dist/arrange-bar.js.map +1 -0
- package/dist/chat.d.ts +46 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +343 -0
- package/dist/chat.js.map +1 -0
- package/dist/companion.d.ts +58 -0
- package/dist/companion.d.ts.map +1 -0
- package/dist/companion.js +433 -0
- package/dist/companion.js.map +1 -0
- package/dist/connections.d.ts +23 -0
- package/dist/connections.d.ts.map +1 -0
- package/dist/connections.js +100 -0
- package/dist/connections.js.map +1 -0
- package/dist/default-views.d.ts +35 -0
- package/dist/default-views.d.ts.map +1 -0
- package/dist/default-views.js +605 -0
- package/dist/default-views.js.map +1 -0
- package/dist/editable.d.ts +71 -0
- package/dist/editable.d.ts.map +1 -0
- package/dist/editable.js +225 -0
- package/dist/editable.js.map +1 -0
- package/dist/figure.d.ts +30 -0
- package/dist/figure.d.ts.map +1 -0
- package/dist/figure.js +66 -0
- package/dist/figure.js.map +1 -0
- package/dist/find.d.ts +5 -0
- package/dist/find.d.ts.map +1 -0
- package/dist/find.js +252 -0
- package/dist/find.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/installation.d.ts +17 -0
- package/dist/installation.d.ts.map +1 -0
- package/dist/installation.js +37 -0
- package/dist/installation.js.map +1 -0
- package/dist/ladder.d.ts +2 -0
- package/dist/ladder.d.ts.map +1 -0
- package/dist/ladder.js +53 -0
- package/dist/ladder.js.map +1 -0
- package/dist/lens/arranging.d.ts +41 -0
- package/dist/lens/arranging.d.ts.map +1 -0
- package/dist/lens/arranging.js +38 -0
- package/dist/lens/arranging.js.map +1 -0
- package/dist/lens/board.d.ts +146 -0
- package/dist/lens/board.d.ts.map +1 -0
- package/dist/lens/board.js +658 -0
- package/dist/lens/board.js.map +1 -0
- package/dist/lens/calendar-dates.d.ts +19 -0
- package/dist/lens/calendar-dates.d.ts.map +1 -0
- package/dist/lens/calendar-dates.js +55 -0
- package/dist/lens/calendar-dates.js.map +1 -0
- package/dist/lens/calendar-drawing.d.ts +59 -0
- package/dist/lens/calendar-drawing.d.ts.map +1 -0
- package/dist/lens/calendar-drawing.js +229 -0
- package/dist/lens/calendar-drawing.js.map +1 -0
- package/dist/lens/calendar-options.d.ts +107 -0
- package/dist/lens/calendar-options.d.ts.map +1 -0
- package/dist/lens/calendar-options.js +19 -0
- package/dist/lens/calendar-options.js.map +1 -0
- package/dist/lens/calendar-placing.d.ts +35 -0
- package/dist/lens/calendar-placing.d.ts.map +1 -0
- package/dist/lens/calendar-placing.js +113 -0
- package/dist/lens/calendar-placing.js.map +1 -0
- package/dist/lens/calendar-spans.d.ts +48 -0
- package/dist/lens/calendar-spans.d.ts.map +1 -0
- package/dist/lens/calendar-spans.js +146 -0
- package/dist/lens/calendar-spans.js.map +1 -0
- package/dist/lens/calendar-view.d.ts +34 -0
- package/dist/lens/calendar-view.d.ts.map +1 -0
- package/dist/lens/calendar-view.js +228 -0
- package/dist/lens/calendar-view.js.map +1 -0
- package/dist/lens/calendar.d.ts +43 -0
- package/dist/lens/calendar.d.ts.map +1 -0
- package/dist/lens/calendar.js +43 -0
- package/dist/lens/calendar.js.map +1 -0
- package/dist/lens/coverage.d.ts +183 -0
- package/dist/lens/coverage.d.ts.map +1 -0
- package/dist/lens/coverage.js +732 -0
- package/dist/lens/coverage.js.map +1 -0
- package/dist/lens/horizon.d.ts +14 -0
- package/dist/lens/horizon.d.ts.map +1 -0
- package/dist/lens/horizon.js +20 -0
- package/dist/lens/horizon.js.map +1 -0
- package/dist/lens/more.d.ts +16 -0
- package/dist/lens/more.d.ts.map +1 -0
- package/dist/lens/more.js +17 -0
- package/dist/lens/more.js.map +1 -0
- package/dist/lens/plan-lens.d.ts +17 -0
- package/dist/lens/plan-lens.d.ts.map +1 -0
- package/dist/lens/plan-lens.js +24 -0
- package/dist/lens/plan-lens.js.map +1 -0
- package/dist/lens/plan-state.d.ts +122 -0
- package/dist/lens/plan-state.d.ts.map +1 -0
- package/dist/lens/plan-state.js +152 -0
- package/dist/lens/plan-state.js.map +1 -0
- package/dist/lens/plan-view.d.ts +10 -0
- package/dist/lens/plan-view.d.ts.map +1 -0
- package/dist/lens/plan-view.js +576 -0
- package/dist/lens/plan-view.js.map +1 -0
- package/dist/lens/plan.d.ts +25 -0
- package/dist/lens/plan.d.ts.map +1 -0
- package/dist/lens/plan.js +25 -0
- package/dist/lens/plan.js.map +1 -0
- package/dist/lens/reach.d.ts +47 -0
- package/dist/lens/reach.d.ts.map +1 -0
- package/dist/lens/reach.js +67 -0
- package/dist/lens/reach.js.map +1 -0
- package/dist/lens/timeline.d.ts +137 -0
- package/dist/lens/timeline.d.ts.map +1 -0
- package/dist/lens/timeline.js +426 -0
- package/dist/lens/timeline.js.map +1 -0
- package/dist/markup.d.ts +23 -0
- package/dist/markup.d.ts.map +1 -0
- package/dist/markup.js +24 -0
- package/dist/markup.js.map +1 -0
- package/dist/places.d.ts +24 -0
- package/dist/places.d.ts.map +1 -0
- package/dist/places.js +227 -0
- package/dist/places.js.map +1 -0
- package/dist/popover.d.ts +28 -0
- package/dist/popover.d.ts.map +1 -0
- package/dist/popover.js +59 -0
- package/dist/popover.js.map +1 -0
- package/dist/primitives/index.d.ts +214 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +381 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/profile.d.ts +65 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +233 -0
- package/dist/profile.js.map +1 -0
- package/dist/quick-relations.d.ts +16 -0
- package/dist/quick-relations.d.ts.map +1 -0
- package/dist/quick-relations.js +183 -0
- package/dist/quick-relations.js.map +1 -0
- package/dist/relation-key.d.ts +44 -0
- package/dist/relation-key.d.ts.map +1 -0
- package/dist/relation-key.js +196 -0
- package/dist/relation-key.js.map +1 -0
- package/dist/seat.d.ts +137 -0
- package/dist/seat.d.ts.map +1 -0
- package/dist/seat.js +162 -0
- package/dist/seat.js.map +1 -0
- package/dist/seats.d.ts +21 -0
- package/dist/seats.d.ts.map +1 -0
- package/dist/seats.js +62 -0
- package/dist/seats.js.map +1 -0
- package/dist/seeding.d.ts +150 -0
- package/dist/seeding.d.ts.map +1 -0
- package/dist/seeding.js +538 -0
- package/dist/seeding.js.map +1 -0
- package/dist/shell.d.ts +74 -0
- package/dist/shell.d.ts.map +1 -0
- package/dist/shell.js +86 -0
- package/dist/shell.js.map +1 -0
- package/dist/theme.d.ts +50 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +1692 -0
- package/dist/theme.js.map +1 -0
- package/dist/wordmark.d.ts +15 -0
- package/dist/wordmark.d.ts.map +1 -0
- package/dist/wordmark.js +55 -0
- package/dist/wordmark.js.map +1 -0
- package/dist/workbench/activity.d.ts +75 -0
- package/dist/workbench/activity.d.ts.map +1 -0
- package/dist/workbench/activity.js +259 -0
- package/dist/workbench/activity.js.map +1 -0
- package/dist/workbench/agent-seat.d.ts +51 -0
- package/dist/workbench/agent-seat.d.ts.map +1 -0
- package/dist/workbench/agent-seat.js +112 -0
- package/dist/workbench/agent-seat.js.map +1 -0
- package/dist/workbench/answer-args.d.ts +31 -0
- package/dist/workbench/answer-args.d.ts.map +1 -0
- package/dist/workbench/answer-args.js +257 -0
- package/dist/workbench/answer-args.js.map +1 -0
- package/dist/workbench/back-out.d.ts +71 -0
- package/dist/workbench/back-out.d.ts.map +1 -0
- package/dist/workbench/back-out.js +238 -0
- package/dist/workbench/back-out.js.map +1 -0
- package/dist/workbench/following.d.ts +7 -0
- package/dist/workbench/following.d.ts.map +1 -0
- package/dist/workbench/following.js +26 -0
- package/dist/workbench/following.js.map +1 -0
- package/dist/workbench/index.d.ts +23 -0
- package/dist/workbench/index.d.ts.map +1 -0
- package/dist/workbench/index.js +23 -0
- package/dist/workbench/index.js.map +1 -0
- package/dist/workbench/inspector.d.ts +27 -0
- package/dist/workbench/inspector.d.ts.map +1 -0
- package/dist/workbench/inspector.js +745 -0
- package/dist/workbench/inspector.js.map +1 -0
- package/dist/workbench/standing.d.ts +16 -0
- package/dist/workbench/standing.d.ts.map +1 -0
- package/dist/workbench/standing.js +102 -0
- package/dist/workbench/standing.js.map +1 -0
- package/dist/workbench/trail.d.ts +35 -0
- package/dist/workbench/trail.d.ts.map +1 -0
- package/dist/workbench/trail.js +150 -0
- package/dist/workbench/trail.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type AnySchema, type NodeOfSchema, type Store } from "@graview/core";
|
|
2
|
+
import { type CalendarBindings, type PlacedEntry } from "./calendar-options.js";
|
|
3
|
+
export declare class CalendarBindingError extends Error {
|
|
4
|
+
readonly kind: string;
|
|
5
|
+
readonly missing: readonly string[];
|
|
6
|
+
constructor(kind: string, missing: readonly string[]);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* One node as an entry, or null when it simply has no date.
|
|
10
|
+
*
|
|
11
|
+
* A binding error and a missing value are different things, the same way
|
|
12
|
+
* they are in the timeline: an app that never bound `start` has made a
|
|
13
|
+
* mistake, and a task with no due date is ordinary data. Only the first
|
|
14
|
+
* throws.
|
|
15
|
+
*/
|
|
16
|
+
export declare function placeOnCalendar<S extends AnySchema>(node: NodeOfSchema<S>, bindings: CalendarBindings, schema?: S): PlacedEntry | null;
|
|
17
|
+
/** The entries touching a day, in the order a person reads them. */
|
|
18
|
+
export declare function entriesOn(entries: readonly PlacedEntry[], day: string): PlacedEntry[];
|
|
19
|
+
/**
|
|
20
|
+
* THE ACT THAT WRITES THE DATE, found in the declaration rather than named
|
|
21
|
+
* in the lens.
|
|
22
|
+
*
|
|
23
|
+
* A calendar you cannot drag in is a picture of a schedule rather than a
|
|
24
|
+
* schedule. But the lens must not invent an edit: it looks for a declared
|
|
25
|
+
* act whose subject accepts this kind and that SAYS it writes the field the
|
|
26
|
+
* start role is bound to, and falls back to the derived edit of the kind,
|
|
27
|
+
* which every kind has. Either way the store judges it, the log records it
|
|
28
|
+
* with an author, and undo takes it back — exactly as if the same act had
|
|
29
|
+
* been pressed in the strip.
|
|
30
|
+
*/
|
|
31
|
+
export declare function actThatMoves<S extends AnySchema>(store: Store<S>, kind: string, field: string): {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly arg: string;
|
|
34
|
+
} | null;
|
|
35
|
+
//# sourceMappingURL=calendar-placing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-placing.d.ts","sourceRoot":"","sources":["../../src/lens/calendar-placing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAErG,OAAO,EAA2B,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAS,MAAM,uBAAuB,CAAC;AAGhH,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE;gBAD1B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,MAAM,EAAE;CAQtC;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,EACjD,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EACrB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,CAAC,EAAE,CAAC,GACT,WAAW,GAAG,IAAI,CAgCpB;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,EAAE,CAUrF;AAKD;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,SAAS,EAC9C,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EACf,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAyBxD"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { fieldWriters, labelOf } from "@graview/core";
|
|
2
|
+
import { dayOf, daysBetween, minutesOf } from "./calendar-dates.js";
|
|
3
|
+
import { CALENDAR_REQUIRED_ROLES, holds } from "./calendar-options.js";
|
|
4
|
+
export class CalendarBindingError extends Error {
|
|
5
|
+
kind;
|
|
6
|
+
missing;
|
|
7
|
+
constructor(kind, missing) {
|
|
8
|
+
super(`The calendar lens has no binding for ${missing.map((role) => `"${role}"`).join(", ")} on "${kind}". ` +
|
|
9
|
+
`Bind them in the lens declaration: bindings: { ${kind}: { start: "<field>" } }.`);
|
|
10
|
+
this.kind = kind;
|
|
11
|
+
this.missing = missing;
|
|
12
|
+
this.name = "CalendarBindingError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* One node as an entry, or null when it simply has no date.
|
|
17
|
+
*
|
|
18
|
+
* A binding error and a missing value are different things, the same way
|
|
19
|
+
* they are in the timeline: an app that never bound `start` has made a
|
|
20
|
+
* mistake, and a task with no due date is ordinary data. Only the first
|
|
21
|
+
* throws.
|
|
22
|
+
*/
|
|
23
|
+
export function placeOnCalendar(node, bindings, schema) {
|
|
24
|
+
const roles = bindings[node.kind];
|
|
25
|
+
if (!roles)
|
|
26
|
+
return null;
|
|
27
|
+
const record = node;
|
|
28
|
+
const declared = schema?.tryDefinition(node.kind)?.fields.shape;
|
|
29
|
+
const missing = CALENDAR_REQUIRED_ROLES.filter((role) => {
|
|
30
|
+
const field = roles[role];
|
|
31
|
+
if (!field)
|
|
32
|
+
return true;
|
|
33
|
+
return declared ? !(field in declared) : !(field in record);
|
|
34
|
+
});
|
|
35
|
+
if (missing.length > 0)
|
|
36
|
+
throw new CalendarBindingError(node.kind, missing);
|
|
37
|
+
const from = dayOf(record[roles.start]);
|
|
38
|
+
if (from === null)
|
|
39
|
+
return null;
|
|
40
|
+
const to = (roles.end ? dayOf(record[roles.end]) : null) ?? from;
|
|
41
|
+
const at = minutesOf(record[roles.start]);
|
|
42
|
+
const named = roles.label ? record[roles.label] : undefined;
|
|
43
|
+
return {
|
|
44
|
+
id: node.id,
|
|
45
|
+
kind: node.kind,
|
|
46
|
+
label: typeof named === "string" && named.length > 0
|
|
47
|
+
? named
|
|
48
|
+
: labelOf(schema?.tryDefinition(node.kind), node),
|
|
49
|
+
from,
|
|
50
|
+
// An end before its start is a typo in the data, not a span that runs
|
|
51
|
+
// backwards: the entry occupies the day it starts and says no more.
|
|
52
|
+
to: daysBetween(from, to) < 0 ? from : to,
|
|
53
|
+
at: roles.allDay && record[roles.allDay] === true ? null : at,
|
|
54
|
+
allDay: roles.allDay ? record[roles.allDay] === true || at === null : at === null,
|
|
55
|
+
done: holds(record, roles.done),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** The entries touching a day, in the order a person reads them. */
|
|
59
|
+
export function entriesOn(entries, day) {
|
|
60
|
+
return entries
|
|
61
|
+
.filter((entry) => daysBetween(entry.from, day) >= 0 && daysBetween(day, entry.to) >= 0)
|
|
62
|
+
.sort((a, b) => {
|
|
63
|
+
// All-day first — they are the frame the timed ones sit inside — then
|
|
64
|
+
// by time, then by name so the order never wobbles between renders.
|
|
65
|
+
if (a.allDay !== b.allDay)
|
|
66
|
+
return a.allDay ? -1 : 1;
|
|
67
|
+
if (a.at !== b.at)
|
|
68
|
+
return (a.at ?? 0) - (b.at ?? 0);
|
|
69
|
+
return a.label.localeCompare(b.label);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/* ------------------------------------------------------- moving a date */
|
|
73
|
+
/**
|
|
74
|
+
* THE ACT THAT WRITES THE DATE, found in the declaration rather than named
|
|
75
|
+
* in the lens.
|
|
76
|
+
*
|
|
77
|
+
* A calendar you cannot drag in is a picture of a schedule rather than a
|
|
78
|
+
* schedule. But the lens must not invent an edit: it looks for a declared
|
|
79
|
+
* act whose subject accepts this kind and that SAYS it writes the field the
|
|
80
|
+
* start role is bound to, and falls back to the derived edit of the kind,
|
|
81
|
+
* which every kind has. Either way the store judges it, the log records it
|
|
82
|
+
* with an author, and undo takes it back — exactly as if the same act had
|
|
83
|
+
* been pressed in the strip.
|
|
84
|
+
*/
|
|
85
|
+
export function actThatMoves(store, kind, field) {
|
|
86
|
+
/*
|
|
87
|
+
* Which acts write this field, asked of the framework's own answer
|
|
88
|
+
* (`fieldWriters`) rather than of `mutation.writes` alone. That is the
|
|
89
|
+
* function the checker uses for `field-without-writer`, and it also reads
|
|
90
|
+
* an act that patches a field it happens to be named for — so a
|
|
91
|
+
* `reschedule` whose declaration forgot `writes: ["due"]` is still found,
|
|
92
|
+
* and the lens does not disagree with the checker about who writes what.
|
|
93
|
+
*/
|
|
94
|
+
const writers = fieldWriters(store.schema, store.allMutations()).get(kind)?.get(field) ?? [];
|
|
95
|
+
const declared = new Map(store.allMutations().map((mutation) => [mutation.name, mutation]));
|
|
96
|
+
for (const name of writers) {
|
|
97
|
+
const mutation = declared.get(name);
|
|
98
|
+
const subject = mutation?.subject;
|
|
99
|
+
if (!mutation || !subject)
|
|
100
|
+
continue;
|
|
101
|
+
// It must also be able to be TOLD the new date, or it writes its own —
|
|
102
|
+
// "finish it" writes `done` and has no opinion you can hand it.
|
|
103
|
+
const shape = mutation.input?.shape ?? {};
|
|
104
|
+
if (!(field in shape))
|
|
105
|
+
continue;
|
|
106
|
+
return { name: mutation.name, arg: subject.arg };
|
|
107
|
+
}
|
|
108
|
+
// Every kind has a derived edit; it is the honest fallback, and the policy
|
|
109
|
+
// reads it through whatever declared acts it rides.
|
|
110
|
+
const edit = store.allMutations().find((mutation) => mutation.derived?.act === "edit" && mutation.derived.kind === kind);
|
|
111
|
+
return edit?.subject ? { name: edit.name, arg: edit.subject.arg } : null;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=calendar-placing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-placing.js","sourceRoot":"","sources":["../../src/lens/calendar-placing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,OAAO,EAAiD,MAAM,eAAe,CAAC;AACrG,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAA2C,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGhH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAElC;IACA;IAFX,YACW,IAAY,EACZ,OAA0B;QAEnC,KAAK,CACH,wCAAwC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,KAAK;YACpG,kDAAkD,IAAI,2BAA2B,CACpF,CAAC;QANO,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAmB;QAMnC,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAqB,EACrB,QAA0B,EAC1B,MAAU;IAEV,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,MAAM,GAAG,IAA+B,CAAC;IAC/C,MAAM,QAAQ,GAAG,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,KAA4C,CAAC;IACvG,MAAM,OAAO,GAAG,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AO,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACzH,OAAO,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CalendarGrain, CalendarHorizon, CalendarRange, PlacedEntry } from "./calendar-options.js";
|
|
2
|
+
/**
|
|
3
|
+
* ONE CELL OF THE GRID — a day, a week or a month, whichever the range's
|
|
4
|
+
* grain is, with what to write in its corner.
|
|
5
|
+
*/
|
|
6
|
+
export interface CalendarCell {
|
|
7
|
+
readonly from: string;
|
|
8
|
+
/** The last day the cell covers. Equal to `from` for a day cell. */
|
|
9
|
+
readonly to: string;
|
|
10
|
+
/** What the cell says in its corner: "14", "6 Apr", "Jan", "Jan 27". */
|
|
11
|
+
readonly label: string;
|
|
12
|
+
/** Outside the stretch the range is about — a day of the next month in a month grid. */
|
|
13
|
+
readonly outside?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface CalendarSpan {
|
|
16
|
+
readonly title: string;
|
|
17
|
+
readonly grain: CalendarGrain;
|
|
18
|
+
readonly cells: readonly CalendarCell[];
|
|
19
|
+
readonly columns: number;
|
|
20
|
+
/**
|
|
21
|
+
* The years a multi-year horizon covers, each somewhere to go. A grid of
|
|
22
|
+
* thirty-six month cells is a picture; the way DOWN from it to one year
|
|
23
|
+
* is a button, not a guess about which cell you meant.
|
|
24
|
+
*/
|
|
25
|
+
readonly years?: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
/** The last day of the month a day falls in. */
|
|
28
|
+
export declare function endOfMonth(day: string): string;
|
|
29
|
+
/** The first day of the quarter a day falls in. */
|
|
30
|
+
export declare function startOfQuarter(day: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* The cells a range covers, how coarse they are, and what to call the whole.
|
|
33
|
+
*
|
|
34
|
+
* One function for every range, because the grid draws whatever it is given:
|
|
35
|
+
* a day cell and a month cell differ in how much ground they cover and in
|
|
36
|
+
* nothing else, which is why a span can be drawn across either.
|
|
37
|
+
*/
|
|
38
|
+
export declare function spanOf(range: CalendarRange, at: string, options?: {
|
|
39
|
+
readonly weekStartsOn?: number;
|
|
40
|
+
readonly horizon?: CalendarHorizon;
|
|
41
|
+
}): CalendarSpan;
|
|
42
|
+
/** The entries touching a stretch of days, in the order a person reads them. */
|
|
43
|
+
export declare function entriesIn(entries: readonly PlacedEntry[], from: string, to: string): PlacedEntry[];
|
|
44
|
+
/** The longest horizon still drawn a month to a cell. */
|
|
45
|
+
export declare const YEARS_BY_THE_MONTH = 10;
|
|
46
|
+
/** The range one level finer than a cell of this grain, and what a press on it opens. */
|
|
47
|
+
export declare function finerThan(grain: CalendarGrain): CalendarRange;
|
|
48
|
+
//# sourceMappingURL=calendar-spans.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-spans.d.ts","sourceRoot":"","sources":["../../src/lens/calendar-spans.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAExG;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,wFAAwF;IACxF,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAQD,gDAAgD;AAChD,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,mDAAmD;AACnD,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGlD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,aAAa,EACpB,EAAE,EAAE,MAAM,EACV,OAAO,GAAE;IAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,CAAA;CAAO,GACnF,YAAY,CA6Gd;AAED,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,EAAE,CASlG;AAED,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC,yFAAyF;AACzF,wBAAgB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAE7D"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { MONTHS, addDays, addMonths, daysBetween, daysFrom, iso, startOfMonth, startOfWeek } from "./calendar-dates.js";
|
|
2
|
+
import { longDay } from "./calendar-drawing.js";
|
|
3
|
+
const monthCell = (day, withYear) => ({
|
|
4
|
+
from: startOfMonth(day),
|
|
5
|
+
to: endOfMonth(day),
|
|
6
|
+
label: `${MONTHS[Number(day.slice(5, 7)) - 1].slice(0, 3)}${withYear ? ` ${day.slice(2, 4)}` : ""}`,
|
|
7
|
+
});
|
|
8
|
+
/** The last day of the month a day falls in. */
|
|
9
|
+
export function endOfMonth(day) {
|
|
10
|
+
return iso(Date.UTC(Number(day.slice(0, 4)), Number(day.slice(5, 7)), 0));
|
|
11
|
+
}
|
|
12
|
+
/** The first day of the quarter a day falls in. */
|
|
13
|
+
export function startOfQuarter(day) {
|
|
14
|
+
const quarter = Math.floor((Number(day.slice(5, 7)) - 1) / 3);
|
|
15
|
+
return `${day.slice(0, 4)}-${String(quarter * 3 + 1).padStart(2, "0")}-01`;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The cells a range covers, how coarse they are, and what to call the whole.
|
|
19
|
+
*
|
|
20
|
+
* One function for every range, because the grid draws whatever it is given:
|
|
21
|
+
* a day cell and a month cell differ in how much ground they cover and in
|
|
22
|
+
* nothing else, which is why a span can be drawn across either.
|
|
23
|
+
*/
|
|
24
|
+
export function spanOf(range, at, options = {}) {
|
|
25
|
+
const weekStartsOn = options.weekStartsOn ?? 1;
|
|
26
|
+
const day = (one, outside) => ({
|
|
27
|
+
from: one,
|
|
28
|
+
to: one,
|
|
29
|
+
label: String(Number(one.slice(8, 10))),
|
|
30
|
+
...(outside ? { outside: true } : {}),
|
|
31
|
+
});
|
|
32
|
+
if (range === "day")
|
|
33
|
+
return { title: longDay(at), grain: "day", columns: 1, cells: [day(at)] };
|
|
34
|
+
if (range === "week") {
|
|
35
|
+
const from = startOfWeek(at, weekStartsOn);
|
|
36
|
+
return {
|
|
37
|
+
title: `${longDay(from)} – ${longDay(addDays(from, 6))}`,
|
|
38
|
+
grain: "day",
|
|
39
|
+
columns: 7,
|
|
40
|
+
cells: daysFrom(from, 7).map((one) => day(one)),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (range === "agenda") {
|
|
44
|
+
// Six weeks forward, which is the horizon a person means by "what is
|
|
45
|
+
// coming up" — and the same number of days a month grid draws, so the
|
|
46
|
+
// two ranges cover comparable ground.
|
|
47
|
+
return { title: `From ${longDay(at)}`, grain: "day", columns: 1, cells: daysFrom(at, 42).map((one) => day(one)) };
|
|
48
|
+
}
|
|
49
|
+
if (range === "quarter") {
|
|
50
|
+
/*
|
|
51
|
+
* A WEEK PER CELL. Thirteen of them, four to a row: a quarter drawn a
|
|
52
|
+
* day at a time is ninety cells nobody can read, and drawn a month at a
|
|
53
|
+
* time is three, which says less than the month grid it replaced.
|
|
54
|
+
*/
|
|
55
|
+
const first = startOfQuarter(at);
|
|
56
|
+
const last = endOfMonth(addMonths(first, 2));
|
|
57
|
+
const cells = [];
|
|
58
|
+
for (let from = startOfWeek(first, weekStartsOn); daysBetween(from, last) >= 0; from = addDays(from, 7)) {
|
|
59
|
+
cells.push({
|
|
60
|
+
from,
|
|
61
|
+
to: addDays(from, 6),
|
|
62
|
+
label: `${Number(from.slice(8, 10))} ${MONTHS[Number(from.slice(5, 7)) - 1].slice(0, 3)}`,
|
|
63
|
+
...(daysBetween(from, first) > 0 && daysBetween(addDays(from, 6), first) > 0 ? { outside: true } : {}),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
title: `Q${Math.floor((Number(at.slice(5, 7)) - 1) / 3) + 1} ${at.slice(0, 4)}`,
|
|
68
|
+
grain: "week",
|
|
69
|
+
columns: 4,
|
|
70
|
+
cells,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (range === "year") {
|
|
74
|
+
const year = at.slice(0, 4);
|
|
75
|
+
return {
|
|
76
|
+
title: year,
|
|
77
|
+
grain: "month",
|
|
78
|
+
columns: 4,
|
|
79
|
+
cells: Array.from({ length: 12 }, (_, month) => monthCell(`${year}-${String(month + 1).padStart(2, "0")}-01`, false)),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (range === "years") {
|
|
83
|
+
/*
|
|
84
|
+
* A MONTH PER CELL, for as many years as the app says it looks out —
|
|
85
|
+
* and the years themselves listed as stops, because the way down from
|
|
86
|
+
* thirty-six cells to one year must not be a guess about which cell was
|
|
87
|
+
* meant.
|
|
88
|
+
*/
|
|
89
|
+
const span = Math.max(1, options.horizon?.years ?? 1);
|
|
90
|
+
const first = Number(at.slice(0, 4));
|
|
91
|
+
const years = Array.from({ length: span }, (_, step) => String(first + step));
|
|
92
|
+
/*
|
|
93
|
+
* PAST A DECADE, A YEAR PER CELL. Thirty years of months is 360 cells,
|
|
94
|
+
* most of them empty, scrolled through to find the busy ones — a career
|
|
95
|
+
* read as a column of blanks. A year per cell is the whole horizon on
|
|
96
|
+
* one screen, each saying how many and the first of them; pressing one
|
|
97
|
+
* opens its months.
|
|
98
|
+
*/
|
|
99
|
+
if (span > YEARS_BY_THE_MONTH) {
|
|
100
|
+
return {
|
|
101
|
+
title: `${options.horizon?.title ?? "Years"} · ${years[0]}–${years[years.length - 1]}`,
|
|
102
|
+
grain: "year",
|
|
103
|
+
columns: 5,
|
|
104
|
+
years,
|
|
105
|
+
cells: years.map((year) => ({ from: `${year}-01-01`, to: `${year}-12-31`, label: year })),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
title: `${options.horizon?.title ?? "Years"} · ${years[0]}–${years[years.length - 1]}`,
|
|
110
|
+
grain: "month",
|
|
111
|
+
columns: 4,
|
|
112
|
+
years,
|
|
113
|
+
cells: years.flatMap((year) => Array.from({ length: 12 }, (_, month) => monthCell(`${year}-${String(month + 1).padStart(2, "0")}-01`, true))),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const first = startOfMonth(at);
|
|
117
|
+
const from = startOfWeek(first, weekStartsOn);
|
|
118
|
+
const month = at.slice(0, 7);
|
|
119
|
+
return {
|
|
120
|
+
title: `${MONTHS[Number(at.slice(5, 7)) - 1]} ${at.slice(0, 4)}`,
|
|
121
|
+
grain: "day",
|
|
122
|
+
columns: 7,
|
|
123
|
+
cells: daysFrom(from, 42).map((one) => day(one, one.slice(0, 7) !== month)),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/** The entries touching a stretch of days, in the order a person reads them. */
|
|
127
|
+
export function entriesIn(entries, from, to) {
|
|
128
|
+
return entries
|
|
129
|
+
.filter((entry) => daysBetween(entry.from, to) >= 0 && daysBetween(from, entry.to) >= 0)
|
|
130
|
+
.sort((a, b) => {
|
|
131
|
+
if (a.allDay !== b.allDay)
|
|
132
|
+
return a.allDay ? -1 : 1;
|
|
133
|
+
if (a.from !== b.from)
|
|
134
|
+
return a.from.localeCompare(b.from);
|
|
135
|
+
if (a.at !== b.at)
|
|
136
|
+
return (a.at ?? 0) - (b.at ?? 0);
|
|
137
|
+
return a.label.localeCompare(b.label);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/** The longest horizon still drawn a month to a cell. */
|
|
141
|
+
export const YEARS_BY_THE_MONTH = 10;
|
|
142
|
+
/** The range one level finer than a cell of this grain, and what a press on it opens. */
|
|
143
|
+
export function finerThan(grain) {
|
|
144
|
+
return grain === "year" ? "year" : grain === "month" ? "month" : grain === "week" ? "week" : "day";
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=calendar-spans.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-spans.js","sourceRoot":"","sources":["../../src/lens/calendar-spans.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACxH,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AA8BhD,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,QAAiB,EAAgB,EAAE,CAAC,CAAC;IACnE,IAAI,EAAE,YAAY,CAAC,GAAG,CAAC;IACvB,EAAE,EAAE,UAAU,CAAC,GAAG,CAAC;IACnB,KAAK,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,EAA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CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;AACrG,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type AnySchema, type NodeOfSchema } from "@graview/core";
|
|
2
|
+
import { type ViewProps } from "@graview/react";
|
|
3
|
+
import { type ReactElement } from "react";
|
|
4
|
+
import { type CalendarBindings, type CalendarOptions, type CalendarRange, type PlacedEntry } from "./calendar-options.js";
|
|
5
|
+
export type Emphasis = "plain" | "lit" | "dimmed";
|
|
6
|
+
export interface CalendarLens<S extends AnySchema> {
|
|
7
|
+
readonly name: "calendar";
|
|
8
|
+
readonly requiredRoles: readonly string[];
|
|
9
|
+
readonly bindings: CalendarBindings;
|
|
10
|
+
readonly options: CalendarOptions;
|
|
11
|
+
View(props: ViewProps<S>): ReactElement | null;
|
|
12
|
+
/** Which of these nodes the lens can place. */
|
|
13
|
+
place(nodes: readonly NodeOfSchema<S>[], schema?: S): PlacedEntry[];
|
|
14
|
+
/**
|
|
15
|
+
* THE SAME LENS, OPENING AT ONE RANGE — a titled place of its own.
|
|
16
|
+
*
|
|
17
|
+
* One binding and one declaration still: the horizons are not separate
|
|
18
|
+
* lenses, they are the same picture at a different grain. Registering
|
|
19
|
+
* them gives each its own `as` slug, so `places()` lists them, the URL
|
|
20
|
+
* names which one you are in, and Back returns to the year you left.
|
|
21
|
+
*
|
|
22
|
+
* The range is the DEFAULT rather than a pin: drilling from a year into
|
|
23
|
+
* a month is an ordinary stop that the address carries, and a place that
|
|
24
|
+
* refused to be navigated within would be a dead end with a name.
|
|
25
|
+
*/
|
|
26
|
+
at(range: CalendarRange): (props: ViewProps<S>) => ReactElement | null;
|
|
27
|
+
/** The ranges it offers, each with the title its place takes. */
|
|
28
|
+
ranges(): readonly {
|
|
29
|
+
readonly range: CalendarRange;
|
|
30
|
+
readonly title: string;
|
|
31
|
+
}[];
|
|
32
|
+
}
|
|
33
|
+
export declare function createCalendarLens<S extends AnySchema>(options: CalendarOptions): Calendar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