@k2b/ui 0.22.0 → 0.23.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/dist/browser/content/Calendar.js +1086 -1049
- package/dist/browser/content/Calendar.js.map +1 -1
- package/dist/browser/content/CalendarDayView.js +1187 -0
- package/dist/browser/content/CalendarDayView.js.map +1 -0
- package/dist/browser/content/CalendarWeekView.js +1571 -0
- package/dist/browser/content/CalendarWeekView.js.map +1 -0
- package/dist/browser/content/ChartExplorer.js +174 -82
- package/dist/browser/content/ChartExplorer.js.map +1 -1
- package/dist/browser/content/ChartFilterControls.js +90 -33
- package/dist/browser/content/ChartFilterControls.js.map +1 -1
- package/dist/browser/content/DataTable.js +199 -171
- package/dist/browser/content/DataTable.js.map +1 -1
- package/dist/browser/content/calendar-day-scroll.js +98 -0
- package/dist/browser/content/calendar-day-scroll.js.map +1 -0
- package/dist/browser/content/calendar-days.js +408 -0
- package/dist/browser/content/calendar-days.js.map +1 -0
- package/dist/browser/content/calendar-dialogs.js +236 -0
- package/dist/browser/content/calendar-dialogs.js.map +1 -0
- package/dist/browser/content/calendar-messages.js +210 -2
- package/dist/browser/content/calendar-messages.js.map +1 -1
- package/dist/browser/content/calendar-pointer.js +15 -3
- package/dist/browser/content/calendar-pointer.js.map +1 -1
- package/dist/browser/content/calendar-shared.js +328 -0
- package/dist/browser/content/calendar-shared.js.map +1 -0
- package/dist/browser/content/calendar-time-view.js +1649 -0
- package/dist/browser/content/calendar-time-view.js.map +1 -0
- package/dist/browser/content/chart-messages.js +10 -0
- package/dist/browser/content/chart-messages.js.map +1 -1
- package/dist/browser/content/index.js.map +1 -1
- package/dist/browser/inputs/Combobox.js +0 -1
- package/dist/browser/inputs/Combobox.js.map +1 -1
- package/dist/browser/layout/AppWorkspace.js +123 -97
- package/dist/browser/layout/AppWorkspace.js.map +1 -1
- package/dist/browser/layout/PageTitle.js +4 -1
- package/dist/browser/layout/PageTitle.js.map +1 -1
- package/dist/browser/layout/app-workspace-controller.js +164 -86
- package/dist/browser/layout/app-workspace-controller.js.map +1 -1
- package/dist/browser/surfaces/StatCell.js +18 -6
- package/dist/browser/surfaces/StatCell.js.map +1 -1
- package/dist/ssr/content/Calendar.js +524 -335
- package/dist/ssr/content/Calendar.js.map +1 -1
- package/dist/ssr/content/CalendarDayView.js +800 -0
- package/dist/ssr/content/CalendarDayView.js.map +1 -0
- package/dist/ssr/content/CalendarWeekView.js +1069 -0
- package/dist/ssr/content/CalendarWeekView.js.map +1 -0
- package/dist/ssr/content/ChartExplorer.js +93 -34
- package/dist/ssr/content/ChartExplorer.js.map +1 -1
- package/dist/ssr/content/ChartFilterControls.js +49 -7
- package/dist/ssr/content/ChartFilterControls.js.map +1 -1
- package/dist/ssr/content/DataTable.js +69 -51
- package/dist/ssr/content/DataTable.js.map +1 -1
- package/dist/ssr/content/calendar-day-scroll.js +98 -0
- package/dist/ssr/content/calendar-day-scroll.js.map +1 -0
- package/dist/ssr/content/calendar-days.js +408 -0
- package/dist/ssr/content/calendar-days.js.map +1 -0
- package/dist/ssr/content/calendar-dialogs.js +159 -0
- package/dist/ssr/content/calendar-dialogs.js.map +1 -0
- package/dist/ssr/content/calendar-messages.js +210 -2
- package/dist/ssr/content/calendar-messages.js.map +1 -1
- package/dist/ssr/content/calendar-pointer.js +15 -3
- package/dist/ssr/content/calendar-pointer.js.map +1 -1
- package/dist/ssr/content/calendar-shared.js +261 -0
- package/dist/ssr/content/calendar-shared.js.map +1 -0
- package/dist/ssr/content/calendar-time-view.js +1306 -0
- package/dist/ssr/content/calendar-time-view.js.map +1 -0
- package/dist/ssr/content/chart-messages.js +10 -0
- package/dist/ssr/content/chart-messages.js.map +1 -1
- package/dist/ssr/content/index.js.map +1 -1
- package/dist/ssr/inputs/Combobox.js.map +1 -1
- package/dist/ssr/layout/AppWorkspace.js +38 -29
- package/dist/ssr/layout/AppWorkspace.js.map +1 -1
- package/dist/ssr/layout/PageTitle.js +4 -1
- package/dist/ssr/layout/PageTitle.js.map +1 -1
- package/dist/ssr/layout/app-workspace-controller.js +164 -86
- package/dist/ssr/layout/app-workspace-controller.js.map +1 -1
- package/dist/ssr/surfaces/StatCell.js +2 -2
- package/dist/ssr/surfaces/StatCell.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/content/Calendar.d.ts +91 -0
- package/dist/types/content/CalendarDayView.d.ts +7 -0
- package/dist/types/content/CalendarWeekView.d.ts +7 -0
- package/dist/types/content/ChartExplorer.d.ts +36 -1
- package/dist/types/content/ChartFilterControls.d.ts +6 -1
- package/dist/types/content/DataTable.d.ts +5 -0
- package/dist/types/content/calendar-day-scroll.d.ts +42 -0
- package/dist/types/content/calendar-days.d.ts +192 -0
- package/dist/types/content/calendar-dialogs.d.ts +22 -0
- package/dist/types/content/calendar-messages.d.ts +99 -0
- package/dist/types/content/calendar-pointer.d.ts +9 -0
- package/dist/types/content/calendar-shared.d.ts +69 -0
- package/dist/types/content/calendar-time-view.d.ts +252 -0
- package/dist/types/content/chart-messages.d.ts +5 -0
- package/dist/types/content/index.d.ts +2 -2
- package/dist/types/layout/AppWorkspace.d.ts +25 -3
- package/dist/types/layout/PageTitle.d.ts +2 -1
- package/dist/types/layout/app-workspace-controller.d.ts +9 -1
- package/dist/types/surfaces/StatCell.d.ts +5 -0
- package/package.json +1 -1
|
@@ -26,6 +26,11 @@ export type CalendarEvent = {
|
|
|
26
26
|
* a priority flag in custom `renderEvent` content.
|
|
27
27
|
*/
|
|
28
28
|
accessibleDetail?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Day and week views with `dayHours`: the state of the entry's checkbox, such as a to-do's. Leave it out for entries
|
|
31
|
+
* without one. With `onEventCheck` the reader can change it.
|
|
32
|
+
*/
|
|
33
|
+
checked?: boolean;
|
|
29
34
|
location?: string;
|
|
30
35
|
calendarName?: string;
|
|
31
36
|
attendees?: CalendarAttendee[];
|
|
@@ -66,6 +71,59 @@ export type CalendarEventRenderContext = {
|
|
|
66
71
|
timeLabel: string;
|
|
67
72
|
/** Month view: the start time to show before the title of a one-day timed entry; absent on bars and elsewhere. */
|
|
68
73
|
leadingTime?: string;
|
|
74
|
+
/** Day and week views: what is left of the event that is running now, such as "27 min left". */
|
|
75
|
+
remaining?: string;
|
|
76
|
+
/** Day and week views: the calendar draws the event's checkbox beside this content, so leave yours out. */
|
|
77
|
+
checkbox?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Day and week views with `dayHours`: the event is a band, a deadline, or an all-day entry of a timeline. Render the
|
|
80
|
+
* title in `k2b-calendar-event__title` and the time in `k2b-calendar-event__meta` there, so the views size them.
|
|
81
|
+
*/
|
|
82
|
+
timeline?: boolean;
|
|
83
|
+
};
|
|
84
|
+
/** The days a host loaded events for, from the first day `from` up to `to`, both `YYYY-MM-DD` or dates. */
|
|
85
|
+
export type CalendarRange = {
|
|
86
|
+
from: Date | string;
|
|
87
|
+
to: Date | string;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* An action the calendar offers for keyboard shortcuts, the command palette, and its shortcuts dialog. The calendar
|
|
91
|
+
* publishes its own through `onCommandsChange`; the host registers them with its shortcut dispatcher.
|
|
92
|
+
*/
|
|
93
|
+
export type CalendarCommand = {
|
|
94
|
+
/** Unique on the page, such as `calendar.today`. */
|
|
95
|
+
id: string;
|
|
96
|
+
label: string;
|
|
97
|
+
/** One key combination: a key such as `h`, or modifiers and a key such as `shift+n`. */
|
|
98
|
+
shortcut?: string;
|
|
99
|
+
/** One sentence for the command palette and the help, such as "Show today in the calendar". */
|
|
100
|
+
description?: string;
|
|
101
|
+
icon?: string;
|
|
102
|
+
run: () => void;
|
|
103
|
+
};
|
|
104
|
+
/** An entry dragged into the day or week view from outside the calendar, such as a task from a list below it. */
|
|
105
|
+
export type CalendarExternalDrag = {
|
|
106
|
+
title: string;
|
|
107
|
+
color?: CalendarEventColor;
|
|
108
|
+
colorHex?: string;
|
|
109
|
+
/** The length it gets in the calendar. */
|
|
110
|
+
minutes: number;
|
|
111
|
+
};
|
|
112
|
+
/** Actions of the calendar that the host starts from its own controls. */
|
|
113
|
+
export type CalendarController = {
|
|
114
|
+
/**
|
|
115
|
+
* Opens the quick create at the selection, or where a new entry fits: today at the next full hour while today is
|
|
116
|
+
* shown, else at 09:00 of the first shown day. `create` reaches `renderQuickCreate` as in the month view's menu.
|
|
117
|
+
*/
|
|
118
|
+
quickCreate: (create?: string) => void;
|
|
119
|
+
/** The time a new entry takes, by the rule of `quickCreate`; all-day for days selected in the month view. */
|
|
120
|
+
createTarget: () => CalendarEventTimeChange;
|
|
121
|
+
/**
|
|
122
|
+
* Day and week views with `dayHours`: follows a pointer that pressed an entry outside the calendar, shows where it
|
|
123
|
+
* would go and whether it fits the free time there, and calls `onDrop` with the time where it is released. Escape
|
|
124
|
+
* or a release outside the days cancels.
|
|
125
|
+
*/
|
|
126
|
+
dragIn: (event: PointerEvent, item: CalendarExternalDrag, onDrop: (slot: CalendarEventTimeChange) => void) => void;
|
|
69
127
|
};
|
|
70
128
|
/** A view the application adds to the switcher; the calendar shows its header and toolbar, the application the body. */
|
|
71
129
|
export type CalendarCustomView<V extends string = string> = {
|
|
@@ -90,6 +148,24 @@ export type CalendarProps<V extends string = never> = {
|
|
|
90
148
|
withWeekNumbers?: boolean;
|
|
91
149
|
startHour?: number;
|
|
92
150
|
endHour?: number;
|
|
151
|
+
/**
|
|
152
|
+
* Waking hours `[start, end]` of the day and week views, such as `[6, 22]`. With them, a day runs from `start` to
|
|
153
|
+
* `start` of the next day, so the night after `end` belongs to the day before. The day view becomes one stream of
|
|
154
|
+
* days down the page and the week view a strip of days to scroll sideways; nights fold unless an entry lies in them.
|
|
155
|
+
* `startHour`, `endHour`, and the visible hours do not apply then.
|
|
156
|
+
*/
|
|
157
|
+
dayHours?: readonly [start: number, end: number];
|
|
158
|
+
/** Day and week views with `dayHours`: the days of `events`. Without it they cover the day or week of `date`. */
|
|
159
|
+
range?: CalendarRange;
|
|
160
|
+
/** Called once when the reader nears the first loaded day, again once `range.from` moved. */
|
|
161
|
+
onLoadEarlier?: () => unknown;
|
|
162
|
+
/** Called once when the reader nears the last loaded day, again once `range.to` moved. */
|
|
163
|
+
onLoadLater?: () => unknown;
|
|
164
|
+
/**
|
|
165
|
+
* Day and week views with `dayHours`: the first and the last day the reader sees, once the view opened and whenever
|
|
166
|
+
* scrolling changed them, such as for the URL or a count of what is in view.
|
|
167
|
+
*/
|
|
168
|
+
onVisibleDateChange?: (date: Date, last: Date) => void;
|
|
93
169
|
visibleStartHour?: number;
|
|
94
170
|
visibleEndHour?: number;
|
|
95
171
|
allDayMaxHeightRem?: number;
|
|
@@ -117,6 +193,11 @@ export type CalendarProps<V extends string = never> = {
|
|
|
117
193
|
onEventDrop?: (event: CalendarEvent, next: CalendarEventTimeChange) => void;
|
|
118
194
|
onEventResize?: (event: CalendarEvent, next: CalendarEventTimeChange) => void;
|
|
119
195
|
onSlotActivate?: (slot: CalendarEventTimeChange) => void;
|
|
196
|
+
/**
|
|
197
|
+
* Changes the checkbox of an entry with `checked`; leave it out when the reader may not change it. The box shows the
|
|
198
|
+
* change at once; a returned promise that rejects puts it back.
|
|
199
|
+
*/
|
|
200
|
+
onEventCheck?: (event: CalendarEvent, checked: boolean) => void | Promise<unknown>;
|
|
120
201
|
/** Pointer gesture used for empty slots. Keyboard activation is always immediate. */
|
|
121
202
|
slotActivation?: "single" | "double";
|
|
122
203
|
/**
|
|
@@ -140,6 +221,16 @@ export type CalendarProps<V extends string = never> = {
|
|
|
140
221
|
toolbarActions?: JSX.Element;
|
|
141
222
|
/** Application controls, such as filters, right after the period title. */
|
|
142
223
|
toolbarContent?: JSX.Element;
|
|
224
|
+
/** The application's own commands, such as New event, listed after the calendar's in its shortcuts dialog. */
|
|
225
|
+
commands?: readonly CalendarCommand[];
|
|
226
|
+
/**
|
|
227
|
+
* Receives the calendar's commands and `commands` whenever they change, to register them with the host's shortcut
|
|
228
|
+
* dispatcher: Today (H), Next (J) and Previous (K), the views (1 to 4), and Go to (G). The calendar then also offers
|
|
229
|
+
* its shortcuts dialog. Without a dispatcher the commands have no keys.
|
|
230
|
+
*/
|
|
231
|
+
onCommandsChange?: (commands: readonly CalendarCommand[]) => void;
|
|
232
|
+
/** Receives the calendar's controller once it mounts. */
|
|
233
|
+
controller?: (controller: CalendarController) => void;
|
|
143
234
|
class?: string;
|
|
144
235
|
};
|
|
145
236
|
export type CalendarSelectionControls = {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type TimeViewProps } from "./calendar-time-view";
|
|
2
|
+
/**
|
|
3
|
+
* The day view with `dayHours`: the loaded days one below the other in a single scroll, each with its heading kept on
|
|
4
|
+
* top while it is in view. Runs of empty days fold into one row. The view slows down and settles at each day start,
|
|
5
|
+
* and a line at the top of the heading fills while a day start passes.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CalendarDayView: (props: TimeViewProps) => import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type TimeViewProps } from "./calendar-time-view";
|
|
2
|
+
/**
|
|
3
|
+
* The week view with `dayHours`: the loaded days side by side in one strip, seven on a wide screen and three on a
|
|
4
|
+
* phone. A trackpad, Shift with the wheel, or a finger scroll it sideways day by day; each gesture keeps the axis it
|
|
5
|
+
* started on, and the strip settles on a day start. The arrows move by whole weeks.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CalendarWeekView: (props: TimeViewProps) => import("solid-js").JSX.Element;
|
|
@@ -8,19 +8,47 @@ export type ChartExplorerColumn<T> = {
|
|
|
8
8
|
value: (row: T) => string;
|
|
9
9
|
/** Optional table cell presentation; value remains the plain text used for copy/details. */
|
|
10
10
|
render?: (row: T) => JSX.Element;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Explicit comparable value. Omit to leave the column unsortable.
|
|
13
|
+
* Returning a number also exempts the cell from spreadsheet formula guarding on copy.
|
|
14
|
+
*/
|
|
12
15
|
sortValue?: (row: T) => string | number | null;
|
|
13
16
|
align?: "left" | "center" | "right";
|
|
14
17
|
};
|
|
18
|
+
/** One legend entry; `color` is the palette index the renderer gave the series (0 is `--stdlib-chart-c1`). */
|
|
19
|
+
export type ChartLegendEntry = {
|
|
20
|
+
label: string;
|
|
21
|
+
color: number;
|
|
22
|
+
/** Line pattern of a line series; a solid series shows a filled swatch. */
|
|
23
|
+
style?: "solid" | "dashed" | "dotted";
|
|
24
|
+
/** A comparison series, drawn hollow like its marks. */
|
|
25
|
+
reference?: boolean;
|
|
26
|
+
};
|
|
15
27
|
export type ChartExplorerProps<T extends ChartExplorerRow> = {
|
|
16
28
|
cursor?: ChartCursor;
|
|
17
29
|
title: string;
|
|
30
|
+
/** Level of the title heading. Defaults to 3; a chart inside a titled group of charts sits one level below it. */
|
|
31
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
18
32
|
description?: JSX.Element;
|
|
19
33
|
data: ChartExplorerData<T>;
|
|
20
34
|
columns: readonly ChartExplorerColumn<T>[];
|
|
21
35
|
view?: "chart" | "table";
|
|
22
36
|
defaultView?: "chart" | "table";
|
|
23
37
|
onViewChange?: (view: "chart" | "table") => void;
|
|
38
|
+
/**
|
|
39
|
+
* Several charts of the same rows. The switcher then lists each chart and the table; `chart` names the one `data`
|
|
40
|
+
* holds, and `onChartChange` reports a pick, so the owner passes the matching data.
|
|
41
|
+
*/
|
|
42
|
+
charts?: readonly {
|
|
43
|
+
id: string;
|
|
44
|
+
label: string;
|
|
45
|
+
}[];
|
|
46
|
+
chart?: string;
|
|
47
|
+
onChartChange?: (id: string) => void;
|
|
48
|
+
/** Filter controls between the header and the viewport, such as ChartFilterControls. */
|
|
49
|
+
controls?: JSX.Element;
|
|
50
|
+
/** The table renders at most this many rows of the sorted order; sorting and Copy data use every row. */
|
|
51
|
+
tableRows?: number;
|
|
24
52
|
sort?: DataTableSort | null;
|
|
25
53
|
defaultSort?: DataTableSort | null;
|
|
26
54
|
onSortChange?: (sort: DataTableSort | null) => void;
|
|
@@ -29,6 +57,13 @@ export type ChartExplorerProps<T extends ChartExplorerRow> = {
|
|
|
29
57
|
/** false hides the complete local detail area for a shared selection panel. */
|
|
30
58
|
renderDetails?: false | ((row: T) => JSX.Element);
|
|
31
59
|
height?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Series names below the chart, wrapping inside the fixed viewport height. Use it instead of the renderer's legend,
|
|
62
|
+
* which draws in one row and runs out of narrow columns.
|
|
63
|
+
*/
|
|
64
|
+
legend?: readonly ChartLegendEntry[];
|
|
65
|
+
/** What the viewport shows without rows, for example while they load; defaults to "No data". */
|
|
66
|
+
empty?: JSX.Element;
|
|
32
67
|
class?: string;
|
|
33
68
|
};
|
|
34
69
|
export declare function ChartExplorer<T extends ChartExplorerRow>(props: ChartExplorerProps<T>): JSX.Element;
|
|
@@ -6,12 +6,17 @@ export type ChartFilterControlsProps = {
|
|
|
6
6
|
key: string;
|
|
7
7
|
label: string;
|
|
8
8
|
}[];
|
|
9
|
+
/** Series to filter; `color` shows a swatch and belongs only to series the chart colors that way. */
|
|
9
10
|
series?: readonly {
|
|
10
11
|
key: string;
|
|
11
12
|
label: string;
|
|
12
|
-
color
|
|
13
|
+
color?: string;
|
|
13
14
|
}[];
|
|
14
15
|
dimensionLabel?: string;
|
|
16
|
+
/** Label of the series filter, such as the column the series come from; defaults to the inherited series label. */
|
|
17
|
+
seriesLabel?: string;
|
|
18
|
+
/** Offer pinning the current step as a reference for comparison. */
|
|
19
|
+
compare?: boolean;
|
|
15
20
|
disabled?: boolean;
|
|
16
21
|
failed?: boolean;
|
|
17
22
|
onRequest: (request: ChartExplorerRequest) => void;
|
|
@@ -58,6 +58,11 @@ export type DataTableProps<T> = {
|
|
|
58
58
|
* server-rendered: sorting is a query change, not client state.
|
|
59
59
|
*/
|
|
60
60
|
sortHref?: (next: DataTableSort) => string;
|
|
61
|
+
/**
|
|
62
|
+
* Sorts on the client instead: sortable headers become buttons that report the
|
|
63
|
+
* next order, with the same look and order of directions as `sortHref`.
|
|
64
|
+
*/
|
|
65
|
+
onSortChange?: (next: DataTableSort) => void;
|
|
61
66
|
selectedRowId?: string | null;
|
|
62
67
|
/** Optional multi-selection shared with another collection view. Requires getRowId. */
|
|
63
68
|
selection?: CollectionSelection;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scroll rules of the day and week views, free of the DOM so they can be tested.
|
|
3
|
+
*
|
|
4
|
+
* The day view runs down through the days and stops gently at each day start: within `STOP_ZONE` pixels of one the
|
|
5
|
+
* wheel slows down, and a scroll that rests close to one glides onto it. The week view scrolls sideways through the
|
|
6
|
+
* days; a wheel or trackpad gesture keeps the axis it started on, and a scroll that rests between two days glides to
|
|
7
|
+
* the nearer day.
|
|
8
|
+
*/
|
|
9
|
+
/** Pixels before and after a day start in which the wheel slows down. */
|
|
10
|
+
export declare const STOP_ZONE = 72;
|
|
11
|
+
/** How much of a wheel step remains right at a day start. */
|
|
12
|
+
export declare const STOP_MIN_FACTOR = 0.16;
|
|
13
|
+
/** A resting scroll this close to a day start glides onto it: a wheel or trackpad, and a finger that flings further. */
|
|
14
|
+
export declare const SETTLE_RADIUS: {
|
|
15
|
+
readonly wheel: 40;
|
|
16
|
+
readonly touch: 88;
|
|
17
|
+
};
|
|
18
|
+
/** A pause between wheel events that starts a new gesture. */
|
|
19
|
+
export declare const GESTURE_GAP_MS = 150;
|
|
20
|
+
/** A wheel delta in pixels, whatever unit the browser reports it in. */
|
|
21
|
+
export declare const wheelPixels: (delta: number, mode: number, page: number) => number;
|
|
22
|
+
/** The index of the last stop at or before a position; `stops` are sorted. */
|
|
23
|
+
export declare const stopIndexAt: (stops: readonly number[], position: number) => number;
|
|
24
|
+
export declare const nearestStop: (stops: readonly number[], position: number) => number | undefined;
|
|
25
|
+
/** How much of a wheel step moves the view at a position: less the closer it is to a stop, eased. */
|
|
26
|
+
export declare const stopFactor: (stops: readonly number[], position: number) => number;
|
|
27
|
+
/**
|
|
28
|
+
* Where a wheel step of `delta` pixels takes the view, braked near stops, or `undefined` when no stop lies within
|
|
29
|
+
* reach and the browser scrolls as usual. The first stop at 0 brakes nothing: there is no day before it to leave.
|
|
30
|
+
*/
|
|
31
|
+
export declare const brakedScroll: (stops: readonly number[], position: number, delta: number) => number | undefined;
|
|
32
|
+
/** The stop a resting scroll glides onto, or `undefined` when it rests on one or too far from any. */
|
|
33
|
+
export declare const settleTarget: (stops: readonly number[], position: number, radius: number) => number | undefined;
|
|
34
|
+
/** How far a header has crossed its stop, 0 to 1, for the line that fills while a day start passes. */
|
|
35
|
+
export declare const stopCrossing: (stop: number, position: number) => number;
|
|
36
|
+
export type WheelAxis = "x" | "y";
|
|
37
|
+
/** The axis a wheel gesture takes from its first event: Shift turns a vertical wheel sideways. */
|
|
38
|
+
export declare const wheelAxis: (deltaX: number, deltaY: number, shiftKey: boolean) => WheelAxis;
|
|
39
|
+
/** The sideways part of a wheel event on an axis, Shift turning the vertical delta into a sideways one. */
|
|
40
|
+
export declare const wheelDelta: (axis: WheelAxis, deltaX: number, deltaY: number, shiftKey: boolean) => number;
|
|
41
|
+
/** The scroll position of the nearest day start in a strip of equal columns. */
|
|
42
|
+
export declare const snapToColumn: (position: number, width: number) => number;
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { type DateContext } from "@k2b/stdlib";
|
|
2
|
+
/**
|
|
3
|
+
* The time model of the day and week views with `dayHours`: a day runs from its start hour to the same hour of the next
|
|
4
|
+
* day, so the night after the waking hours belongs to the day before it. Every place in a day is a count of minutes on
|
|
5
|
+
* the wall clock after that start, which keeps a day 24 hours long on the clock across a change to or from summer
|
|
6
|
+
* time. Timed events over calendar dates go to the all-day row, unless they end by the next day's start hour.
|
|
7
|
+
* An event that crosses only the day start stays bands in both days. The functions here are pure and work on
|
|
8
|
+
* `YYYY-MM-DD` day keys in the calendar's time zone.
|
|
9
|
+
*/
|
|
10
|
+
/** Waking hours: `start` begins the day, `end` begins its night, which lasts until `start` of the next day. */
|
|
11
|
+
export type CalendarDayHours = readonly [start: number, end: number];
|
|
12
|
+
export declare const DAY_MINUTES = 1440;
|
|
13
|
+
/** Free time from this length on is labelled, such as "1 hr free"; shorter gaps show only while dragging into them. */
|
|
14
|
+
export declare const GAP_LABEL_MINUTES = 60;
|
|
15
|
+
/** Free time from this length on stands out. */
|
|
16
|
+
export declare const GAP_LONG_MINUTES = 180;
|
|
17
|
+
/** Days since 1970-01-01 of a `YYYY-MM-DD` key; day keys need no time zone for this. */
|
|
18
|
+
export declare const dayKeyNumber: (key: string) => number;
|
|
19
|
+
export declare const keyOfDayNumber: (value: number) => string;
|
|
20
|
+
export declare const addDayKeys: (key: string, days: number) => string;
|
|
21
|
+
/** Every key from `first` to `last`, both included. */
|
|
22
|
+
export declare const dayKeyRange: (first: string, last: string) => string[];
|
|
23
|
+
/** The wall clock of an instant in the calendar's time zone, as `YYYY-MM-DDTHH:mm`. */
|
|
24
|
+
export declare const wallClock: (instant: Date, context?: DateContext) => string;
|
|
25
|
+
/** The instant of a wall clock in the calendar's time zone; a time a clock change skips moves forward, as clocks do. */
|
|
26
|
+
export declare const wallInstant: (wall: string, context?: DateContext) => Date;
|
|
27
|
+
/** Minutes on the wall clock from the start of the day `key` to the instant; negative before it, above 1440 after it. */
|
|
28
|
+
export declare const minuteInDay: (key: string, instant: Date, hours: CalendarDayHours, context?: DateContext) => number;
|
|
29
|
+
/** The instant at a minute of the day `key`. */
|
|
30
|
+
export declare const instantInDay: (key: string, minute: number, hours: CalendarDayHours, context?: DateContext) => Date;
|
|
31
|
+
/**
|
|
32
|
+
* The instants of a slot of the day `key`. A time the change to summer time skips moves forward, so a slot drawn there
|
|
33
|
+
* could end at or before its start; it then keeps the length it was drawn with.
|
|
34
|
+
*/
|
|
35
|
+
export declare const instantsInDay: (key: string, start: number, end: number, hours: CalendarDayHours, context?: DateContext) => {
|
|
36
|
+
start: Date;
|
|
37
|
+
end: Date;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* An entry with one edge dragged to a minute of the day `key`, given as the slot `minutes` it now spans there. The
|
|
41
|
+
* other edge keeps its instant, so an entry in the hour a change from summer time repeats keeps its real time; the
|
|
42
|
+
* entry never ends before it starts.
|
|
43
|
+
*/
|
|
44
|
+
export declare const resizedInDay: (entry: {
|
|
45
|
+
start: Date;
|
|
46
|
+
end: Date;
|
|
47
|
+
}, edge: "start" | "end", key: string, minutes: {
|
|
48
|
+
start: number;
|
|
49
|
+
end: number;
|
|
50
|
+
}, hours: CalendarDayHours, context?: DateContext) => {
|
|
51
|
+
start: Date;
|
|
52
|
+
end: Date;
|
|
53
|
+
};
|
|
54
|
+
/** The day an instant belongs to: before the start hour it is still the night of the day before. */
|
|
55
|
+
export declare const dayKeyOf: (instant: Date, hours: CalendarDayHours, context?: DateContext) => string;
|
|
56
|
+
/** The wall-clock time `HH:mm` at a minute of a day. */
|
|
57
|
+
export declare const clockAt: (minute: number, hours: CalendarDayHours) => string;
|
|
58
|
+
/** Minutes of the waking hours, from the start of the day to the start of its night. */
|
|
59
|
+
export declare const wakeMinutes: (hours: CalendarDayHours) => number;
|
|
60
|
+
/** One entry the views place: a timed event, an all-day event, or a point in time such as a deadline. */
|
|
61
|
+
export type DayEntry<T> = {
|
|
62
|
+
item: T;
|
|
63
|
+
start: Date;
|
|
64
|
+
/** For all-day entries the midnight after their last day. */
|
|
65
|
+
end: Date;
|
|
66
|
+
allDay: boolean;
|
|
67
|
+
/** A point in time at `start`; an all-day point is due on its day. */
|
|
68
|
+
marker: boolean;
|
|
69
|
+
};
|
|
70
|
+
/** A timed entry of one day, in minutes of that day. */
|
|
71
|
+
export type DayBand<T> = {
|
|
72
|
+
item: T;
|
|
73
|
+
start: number;
|
|
74
|
+
end: number;
|
|
75
|
+
};
|
|
76
|
+
export type DayMarker<T> = {
|
|
77
|
+
item: T;
|
|
78
|
+
minute: number;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* An entry of the all-day row: all-day events, points due on a day, and timed events over calendar dates, ignoring
|
|
82
|
+
* the end date when the event ends by its day start. Events crossing only the day start stay bands in both days.
|
|
83
|
+
*/
|
|
84
|
+
export type DaySpan<T> = {
|
|
85
|
+
item: T;
|
|
86
|
+
firstKey: string;
|
|
87
|
+
lastKey: string;
|
|
88
|
+
marker: boolean;
|
|
89
|
+
};
|
|
90
|
+
export type DayModel<T> = {
|
|
91
|
+
key: string;
|
|
92
|
+
bands: DayBand<T>[];
|
|
93
|
+
markers: DayMarker<T>[];
|
|
94
|
+
spans: DaySpan<T>[];
|
|
95
|
+
/** Something lies in the night, so it opens by default. */
|
|
96
|
+
night: boolean;
|
|
97
|
+
empty: boolean;
|
|
98
|
+
};
|
|
99
|
+
/** Where an entry goes: the timelines of the days it touches, or the all-day row over its calendar dates. */
|
|
100
|
+
export declare const placeEntry: <T>(entry: DayEntry<T>, hours: CalendarDayHours, context?: DateContext) => {
|
|
101
|
+
kind: "band";
|
|
102
|
+
bands: {
|
|
103
|
+
key: string;
|
|
104
|
+
band: DayBand<T>;
|
|
105
|
+
}[];
|
|
106
|
+
} | {
|
|
107
|
+
kind: "marker";
|
|
108
|
+
key: string;
|
|
109
|
+
marker: DayMarker<T>;
|
|
110
|
+
} | {
|
|
111
|
+
kind: "span";
|
|
112
|
+
span: DaySpan<T>;
|
|
113
|
+
};
|
|
114
|
+
/** The model of each day from `first` to `last`. */
|
|
115
|
+
export declare const buildDays: <T>(first: string, last: string, entries: readonly DayEntry<T>[], hours: CalendarDayHours, context?: DateContext) => Map<string, DayModel<T>>;
|
|
116
|
+
export type DayGap = {
|
|
117
|
+
start: number;
|
|
118
|
+
end: number;
|
|
119
|
+
past: boolean;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Free time of a day's waking hours between its timed entries. `now` is the current minute of this day, `Infinity`
|
|
123
|
+
* for a day that is over, and `-Infinity` for one still ahead. The gap that holds now starts at the next quarter hour.
|
|
124
|
+
*/
|
|
125
|
+
export declare const freeGaps: <T>(bands: readonly DayBand<T>[], wake: number, now: number, minimum?: number) => DayGap[];
|
|
126
|
+
/**
|
|
127
|
+
* What activating free time creates: a gap up to two hours whole, a longer one an hour from its start. A gap from the
|
|
128
|
+
* start of the day that leaves room proposes 09:00, so "16 hrs free" never becomes a 16-hour event.
|
|
129
|
+
*/
|
|
130
|
+
export declare const gapProposal: (gap: Pick<DayGap, "start" | "end">, hours: CalendarDayHours) => [start: number, end: number];
|
|
131
|
+
export type DayLane<T> = DayBand<T> & {
|
|
132
|
+
lane: number;
|
|
133
|
+
lanes: number;
|
|
134
|
+
};
|
|
135
|
+
/** Overlapping bands side by side; a band counts at least `minimum` minutes long, as its drawn height does. */
|
|
136
|
+
export declare const dayLanes: <T>(bands: readonly DayBand<T>[], minimum: number) => DayLane<T>[];
|
|
137
|
+
/** About the minutes a deadline's pill covers in the waking hours; the open night is half as tall, so twice as many. */
|
|
138
|
+
export declare const MARKER_MINUTES = 30;
|
|
139
|
+
/**
|
|
140
|
+
* Deadlines whose pills would cover each other side by side, in time order from the left; each line stays at its own
|
|
141
|
+
* minute. Two to-dos due at the same time, such as Spaces' default 17:00, so both keep their title and checkbox.
|
|
142
|
+
*/
|
|
143
|
+
export declare const markerLanes: <T>(markers: readonly DayMarker<T>[], wake: number) => import("./calendar-event-layout").CalendarIntervalLayout<DayMarker<T>>[];
|
|
144
|
+
export type DayGroup = {
|
|
145
|
+
kind: "day";
|
|
146
|
+
key: string;
|
|
147
|
+
} | {
|
|
148
|
+
kind: "empty";
|
|
149
|
+
keys: string[];
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* The days of the stream: each day with something in it alone, runs of empty days as one. The days in `keep`, such
|
|
153
|
+
* as today, the day the reader opened, and every day of a run the reader unfolded, never fold, so days that load
|
|
154
|
+
* next to an unfolded run fold on their own and leave it open.
|
|
155
|
+
*/
|
|
156
|
+
export declare const dayGroups: (keys: readonly string[], empty: (key: string) => boolean, keep: ReadonlySet<string>) => DayGroup[];
|
|
157
|
+
/** Pixel sizes of a day's timeline: waking hours at full height, the night at half, below a bar or folded into a row. */
|
|
158
|
+
export type DayGeometry = {
|
|
159
|
+
hour: number;
|
|
160
|
+
nightHour: number;
|
|
161
|
+
nightBar: number;
|
|
162
|
+
fold: number;
|
|
163
|
+
wake: number;
|
|
164
|
+
expanded: boolean;
|
|
165
|
+
};
|
|
166
|
+
/** The top of a minute. */
|
|
167
|
+
export declare const dayY: (geometry: DayGeometry, minute: number) => number;
|
|
168
|
+
/** The top of something that starts at a minute: from the start of the night on, below the night's bar. */
|
|
169
|
+
export declare const dayTopY: (geometry: DayGeometry, minute: number) => number;
|
|
170
|
+
/** The minute at a height, the inverse of `dayY`; the night's bar and a folded night map to the start of the night. */
|
|
171
|
+
export declare const dayMinuteAt: (geometry: DayGeometry, y: number) => number;
|
|
172
|
+
export declare const dayHeight: (geometry: DayGeometry) => number;
|
|
173
|
+
/** The last minute the timeline draws: the end of the night when it is open, else the start of the night. */
|
|
174
|
+
export declare const dayLimit: (geometry: DayGeometry) => number;
|
|
175
|
+
/** Rounds to the step, the 15 or 5 minutes a pointer snaps to. */
|
|
176
|
+
export declare const snapMinutes: (minute: number, step: number) => number;
|
|
177
|
+
/**
|
|
178
|
+
* A height in a day's timeline as counts of the four sizes the stylesheet sets: waking hours, night hours, the night's
|
|
179
|
+
* bar, and the folded night row. The views draw with these, so a phone's smaller hours need no script.
|
|
180
|
+
*/
|
|
181
|
+
export type DayTerms = readonly [hours: number, nightHours: number, nightBars: number, folds: number];
|
|
182
|
+
/** `dayY` as terms. */
|
|
183
|
+
export declare const dayYTerms: (wake: number, expanded: boolean, minute: number) => DayTerms;
|
|
184
|
+
/** `dayTopY` as terms. */
|
|
185
|
+
export declare const dayTopTerms: (wake: number, expanded: boolean, minute: number) => DayTerms;
|
|
186
|
+
/** `dayHeight` as terms. */
|
|
187
|
+
export declare const dayHeightTerms: (wake: number, expanded: boolean) => DayTerms;
|
|
188
|
+
export declare const subtractTerms: (left: DayTerms, right: DayTerms) => DayTerms;
|
|
189
|
+
/** Terms as a CSS length over the sizes of the stylesheet. */
|
|
190
|
+
export declare const termsCss: (terms: DayTerms) => string;
|
|
191
|
+
/** The pixel sizes of the terms where an element draws its timeline, for pointer positions. */
|
|
192
|
+
export declare const readDayGeometry: (element: Element, wake: number, expanded: boolean) => DayGeometry;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CalendarCommand } from "./Calendar";
|
|
2
|
+
import type { CalendarMessages } from "./calendar-messages";
|
|
3
|
+
/** The keys of a shortcut as the reader presses them, such as ["⇧", "N"] or ["Shift", "N"]. */
|
|
4
|
+
export declare const shortcutKeys: (shortcut: string) => string[];
|
|
5
|
+
/**
|
|
6
|
+
* The calendar's shortcuts: the same list the host registers for its dispatcher and its help. `alternatives` names
|
|
7
|
+
* other keys the calendar itself handles for a command, such as the arrow keys that page like J and K.
|
|
8
|
+
*/
|
|
9
|
+
export declare const openCalendarShortcuts: (commands: readonly CalendarCommand[], messages: CalendarMessages, alternatives?: Readonly<Record<string, string>>) => Promise<void | undefined>;
|
|
10
|
+
/**
|
|
11
|
+
* Reads German and English dates, weekdays, months, week numbers, today, and tomorrow for Go to. Weekdays include
|
|
12
|
+
* today unless preceded by next; a month alone uses the next year if it has passed. A date without a year is this
|
|
13
|
+
* year's. Names ignore case and accents and allow a trailing dot. Returns a `YYYY-MM-DD` key or `null`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const parseGoTo: (text: string, today: string) => string | null;
|
|
16
|
+
/** Go to: a field that reads a date or a week number and names the day it found before the reader goes there. */
|
|
17
|
+
export declare const openCalendarGoTo: (props: {
|
|
18
|
+
messages: CalendarMessages;
|
|
19
|
+
today: string;
|
|
20
|
+
describe: (key: string) => string;
|
|
21
|
+
onGo: (key: string) => void;
|
|
22
|
+
}) => Promise<void>;
|
|
@@ -52,6 +52,105 @@ declare const calendarMessages: import("@k2b/stdlib").Catalog<{
|
|
|
52
52
|
day: number;
|
|
53
53
|
month?: string;
|
|
54
54
|
}) => string;
|
|
55
|
+
calendarDuration: ({ minutes }: {
|
|
56
|
+
minutes: number;
|
|
57
|
+
}) => string;
|
|
58
|
+
calendarFree: ({ duration }: {
|
|
59
|
+
duration: string;
|
|
60
|
+
}) => string;
|
|
61
|
+
calendarCreateAt: ({ start, end }: {
|
|
62
|
+
start: string;
|
|
63
|
+
end: string;
|
|
64
|
+
}) => string;
|
|
65
|
+
calendarFreeAction: ({ duration, from, to, start, end, }: {
|
|
66
|
+
duration: string;
|
|
67
|
+
from: string;
|
|
68
|
+
to: string;
|
|
69
|
+
start: string;
|
|
70
|
+
end: string;
|
|
71
|
+
}) => string;
|
|
72
|
+
calendarRemaining: ({ duration }: {
|
|
73
|
+
duration: string;
|
|
74
|
+
}) => string;
|
|
75
|
+
calendarSoon: ({ title, duration }: {
|
|
76
|
+
title: string;
|
|
77
|
+
duration: string;
|
|
78
|
+
}) => string;
|
|
79
|
+
calendarNight: ({ from, to }: {
|
|
80
|
+
from: string;
|
|
81
|
+
to: string;
|
|
82
|
+
}) => string;
|
|
83
|
+
calendarNightHours: ({ from, to }: {
|
|
84
|
+
from: string;
|
|
85
|
+
to: string;
|
|
86
|
+
}) => string;
|
|
87
|
+
calendarFoldNight: string;
|
|
88
|
+
calendarOpenNight: string;
|
|
89
|
+
calendarFoldNights: string;
|
|
90
|
+
calendarOpenNights: ({ from, to }: {
|
|
91
|
+
from: string;
|
|
92
|
+
to: string;
|
|
93
|
+
}) => string;
|
|
94
|
+
calendarUntil: ({ time }: {
|
|
95
|
+
time: string;
|
|
96
|
+
}) => string;
|
|
97
|
+
calendarNothingPlannedShort: string;
|
|
98
|
+
calendarUnfoldDays: ({ count }: {
|
|
99
|
+
count: number;
|
|
100
|
+
}) => string;
|
|
101
|
+
calendarDayCount: ({ count }: {
|
|
102
|
+
count: number;
|
|
103
|
+
}) => string;
|
|
104
|
+
calendarDaySummary: ({ events, tasks }: {
|
|
105
|
+
events: number;
|
|
106
|
+
tasks: number;
|
|
107
|
+
}) => string;
|
|
108
|
+
calendarMoreDays: string;
|
|
109
|
+
calendarAllDayRow: string;
|
|
110
|
+
calendarAllDayRowShort: string;
|
|
111
|
+
calendarAllDayAndDue: string;
|
|
112
|
+
calendarDone: ({ title }: {
|
|
113
|
+
title: string;
|
|
114
|
+
}) => string;
|
|
115
|
+
calendarAllDone: string;
|
|
116
|
+
calendarAllDoneShort: string;
|
|
117
|
+
calendarDue: ({ time }: {
|
|
118
|
+
time: string;
|
|
119
|
+
}) => string;
|
|
120
|
+
calendarFits: string;
|
|
121
|
+
calendarTooShort: ({ duration }: {
|
|
122
|
+
duration: string;
|
|
123
|
+
}) => string;
|
|
124
|
+
calendarOverlaps: ({ title }: {
|
|
125
|
+
title: string;
|
|
126
|
+
}) => string;
|
|
127
|
+
calendarWeekNumber: ({ week }: {
|
|
128
|
+
week: number;
|
|
129
|
+
}) => string;
|
|
130
|
+
calendarWeek: string;
|
|
131
|
+
calendarDays: string;
|
|
132
|
+
calendarKeyboardHelp: string;
|
|
133
|
+
calendarDayKeyboardHelp: string;
|
|
134
|
+
calendarShortcuts: string;
|
|
135
|
+
calendarShortcutsNote: string;
|
|
136
|
+
calendarCommandToday: string;
|
|
137
|
+
calendarCommandTodayDescription: string;
|
|
138
|
+
calendarCommandNext: string;
|
|
139
|
+
calendarCommandNextDescription: string;
|
|
140
|
+
calendarCommandPrevious: string;
|
|
141
|
+
calendarCommandPreviousDescription: string;
|
|
142
|
+
calendarCommandView: ({ view }: {
|
|
143
|
+
view: string;
|
|
144
|
+
}) => string;
|
|
145
|
+
calendarCommandViewDescription: ({ view }: {
|
|
146
|
+
view: string;
|
|
147
|
+
}) => string;
|
|
148
|
+
calendarCommandGoTo: string;
|
|
149
|
+
calendarCommandGoToDescription: string;
|
|
150
|
+
calendarGoToPlaceholder: string;
|
|
151
|
+
calendarGoToHint: string;
|
|
152
|
+
calendarGoToUnknown: string;
|
|
153
|
+
calendarGoToGo: string;
|
|
55
154
|
}>;
|
|
56
155
|
export type CalendarMessages = ReturnType<(typeof calendarMessages)["resolve"]>["t"];
|
|
57
156
|
/** Resolved from the inherited render locale, like the rest of @k2b/ui. */
|
|
@@ -10,8 +10,17 @@ type CalendarPointerSessionOptions<T> = {
|
|
|
10
10
|
onPreview: (value: T) => void;
|
|
11
11
|
onCommit: (value: T) => void;
|
|
12
12
|
onCancel?: () => void;
|
|
13
|
+
/** Called once whenever the session ends, even before activation, after onCommit or onCancel. */
|
|
14
|
+
onEnd?: () => void;
|
|
13
15
|
scrollContainer?: HTMLElement;
|
|
14
16
|
threshold?: number;
|
|
17
|
+
/**
|
|
18
|
+
* The edges scroll only once the pointer has been well inside the container, and only while it is over it, so a drag
|
|
19
|
+
* that comes in from outside, such as from a list below, does not scroll on its way in.
|
|
20
|
+
*/
|
|
21
|
+
armAutoScroll?: boolean;
|
|
22
|
+
/** Called on every move once the gesture is active, such as to move a token with the pointer. */
|
|
23
|
+
onMove?: (clientX: number, clientY: number) => void;
|
|
15
24
|
};
|
|
16
25
|
/**
|
|
17
26
|
* Owns one pointer gesture from threshold crossing through commit or cancel.
|