@ahrowe/ui 0.39.0 → 0.40.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/README.md +2 -1
- package/dist/cjs-types/common/calendar/calendar.d.ts +4 -0
- package/dist/cjs-types/common/calendar/calendar.types.d.ts +141 -0
- package/dist/cjs-types/common/calendar/components/agendaList/agendaList.d.ts +5 -0
- package/dist/cjs-types/common/calendar/components/agendaList/agendaList.types.d.ts +23 -0
- package/dist/cjs-types/common/calendar/components/agendaList/index.d.ts +1 -0
- package/dist/cjs-types/common/calendar/components/calendarHeader/calendarHeader.d.ts +4 -0
- package/dist/cjs-types/common/calendar/components/calendarHeader/calendarHeader.types.d.ts +17 -0
- package/dist/cjs-types/common/calendar/components/calendarHeader/index.d.ts +1 -0
- package/dist/cjs-types/common/calendar/components/compactMonth/compactMonth.d.ts +9 -0
- package/dist/cjs-types/common/calendar/components/compactMonth/compactMonth.types.d.ts +1 -0
- package/dist/cjs-types/common/calendar/components/compactMonth/index.d.ts +1 -0
- package/dist/cjs-types/common/calendar/components/monthView/index.d.ts +1 -0
- package/dist/cjs-types/common/calendar/components/monthView/monthView.d.ts +5 -0
- package/dist/cjs-types/common/calendar/components/monthView/monthView.types.d.ts +10 -0
- package/dist/cjs-types/common/calendar/components/timeGrid/index.d.ts +1 -0
- package/dist/cjs-types/common/calendar/components/timeGrid/timeGrid.d.ts +5 -0
- package/dist/cjs-types/common/calendar/components/timeGrid/timeGrid.types.d.ts +40 -0
- package/dist/cjs-types/common/calendar/dates.d.ts +50 -0
- package/dist/cjs-types/common/calendar/format.d.ts +32 -0
- package/dist/cjs-types/common/calendar/gesture.d.ts +32 -0
- package/dist/cjs-types/common/calendar/index.d.ts +2 -0
- package/dist/cjs-types/common/calendar/layout.d.ts +74 -0
- package/dist/cjs-types/common/calendar/useGestures.d.ts +37 -0
- package/dist/cjs-types/common/calendar/usePager.d.ts +20 -0
- package/dist/cjs-types/common/calendar/view.types.d.ts +26 -0
- package/dist/cjs-types/common/configProvider/configProvider.types.d.ts +3 -0
- package/dist/cjs-types/common/confirmModal/confirmModal.types.d.ts +1 -1
- package/dist/cjs-types/common/datePicker/index.d.ts +1 -1
- package/dist/cjs-types/common/modal/modal.types.d.ts +4 -3
- package/dist/cjs-types/common/themeProvider/theme.types.d.ts +8 -0
- package/dist/cjs-types/common/utils/day.d.ts +8 -0
- package/dist/cjs-types/common/virtualList/useColumns.d.ts +3 -1
- package/dist/cjs-types/index.d.ts +2 -0
- package/dist/esm/common/calendar/calendar.mjs +2 -0
- package/dist/esm/common/calendar/calendar.mjs.map +1 -0
- package/dist/esm/common/calendar/calendar.module.mjs +2 -0
- package/dist/esm/common/calendar/calendar.module.mjs.map +1 -0
- package/dist/esm/common/calendar/calendar.types.mjs +2 -0
- package/dist/esm/common/calendar/calendar.types.mjs.map +1 -0
- package/dist/esm/common/calendar/components/agendaList/agendaList.mjs +2 -0
- package/dist/esm/common/calendar/components/agendaList/agendaList.mjs.map +1 -0
- package/dist/esm/common/calendar/components/agendaList/agendaList.module.mjs +2 -0
- package/dist/esm/common/calendar/components/agendaList/agendaList.module.mjs.map +1 -0
- package/dist/esm/common/calendar/components/calendarHeader/calendarHeader.mjs +2 -0
- package/dist/esm/common/calendar/components/calendarHeader/calendarHeader.mjs.map +1 -0
- package/dist/esm/common/calendar/components/calendarHeader/calendarHeader.module.mjs +2 -0
- package/dist/esm/common/calendar/components/calendarHeader/calendarHeader.module.mjs.map +1 -0
- package/dist/esm/common/calendar/components/compactMonth/compactMonth.mjs +2 -0
- package/dist/esm/common/calendar/components/compactMonth/compactMonth.mjs.map +1 -0
- package/dist/esm/common/calendar/components/compactMonth/compactMonth.module.mjs +2 -0
- package/dist/esm/common/calendar/components/compactMonth/compactMonth.module.mjs.map +1 -0
- package/dist/esm/common/calendar/components/monthView/monthView.mjs +2 -0
- package/dist/esm/common/calendar/components/monthView/monthView.mjs.map +1 -0
- package/dist/esm/common/calendar/components/monthView/monthView.module.mjs +2 -0
- package/dist/esm/common/calendar/components/monthView/monthView.module.mjs.map +1 -0
- package/dist/esm/common/calendar/components/timeGrid/timeGrid.mjs +2 -0
- package/dist/esm/common/calendar/components/timeGrid/timeGrid.mjs.map +1 -0
- package/dist/esm/common/calendar/components/timeGrid/timeGrid.module.mjs +2 -0
- package/dist/esm/common/calendar/components/timeGrid/timeGrid.module.mjs.map +1 -0
- package/dist/esm/common/calendar/dates.mjs +2 -0
- package/dist/esm/common/calendar/dates.mjs.map +1 -0
- package/dist/esm/common/calendar/format.mjs +2 -0
- package/dist/esm/common/calendar/format.mjs.map +1 -0
- package/dist/esm/common/calendar/gesture.mjs +2 -0
- package/dist/esm/common/calendar/gesture.mjs.map +1 -0
- package/dist/esm/common/calendar/layout.mjs +2 -0
- package/dist/esm/common/calendar/layout.mjs.map +1 -0
- package/dist/esm/common/calendar/pager.module.mjs +2 -0
- package/dist/esm/common/calendar/pager.module.mjs.map +1 -0
- package/dist/esm/common/calendar/useGestures.mjs +2 -0
- package/dist/esm/common/calendar/useGestures.mjs.map +1 -0
- package/dist/esm/common/calendar/usePager.mjs +2 -0
- package/dist/esm/common/calendar/usePager.mjs.map +1 -0
- package/dist/esm/common/confirmModal/confirmModal.mjs +1 -1
- package/dist/esm/common/confirmModal/confirmModal.mjs.map +1 -1
- package/dist/esm/common/datePicker/components/datePickerMonth/datePickerMonth.mjs +1 -1
- package/dist/esm/common/datePicker/dateFunctions.mjs +1 -1
- package/dist/esm/common/datePicker/datePicker.mjs +1 -1
- package/dist/esm/common/input/input.mjs +1 -1
- package/dist/esm/common/input/input.mjs.map +1 -1
- package/dist/esm/common/modal/modal.mjs +1 -1
- package/dist/esm/common/modal/modal.mjs.map +1 -1
- package/dist/esm/common/popover/popover.mjs +1 -1
- package/dist/esm/common/popover/popover.mjs.map +1 -1
- package/dist/esm/common/scrollFade/scrollFade.mjs +1 -1
- package/dist/esm/common/tabHeader/tabHeader.module.mjs.map +1 -1
- package/dist/esm/common/utils/day.mjs +1 -1
- package/dist/esm/common/utils/day.mjs.map +1 -1
- package/dist/esm/common/virtualList/useColumns.mjs +1 -1
- package/dist/esm/common/virtualList/useColumns.mjs.map +1 -1
- package/dist/esm/common/virtualList/virtualList.mjs +1 -1
- package/dist/esm/common/virtualList/virtualList.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/common/calendar/calendar.d.ts +4 -0
- package/dist/types/common/calendar/calendar.types.d.ts +141 -0
- package/dist/types/common/calendar/components/agendaList/agendaList.d.ts +5 -0
- package/dist/types/common/calendar/components/agendaList/agendaList.types.d.ts +23 -0
- package/dist/types/common/calendar/components/agendaList/index.d.ts +1 -0
- package/dist/types/common/calendar/components/calendarHeader/calendarHeader.d.ts +4 -0
- package/dist/types/common/calendar/components/calendarHeader/calendarHeader.types.d.ts +17 -0
- package/dist/types/common/calendar/components/calendarHeader/index.d.ts +1 -0
- package/dist/types/common/calendar/components/compactMonth/compactMonth.d.ts +9 -0
- package/dist/types/common/calendar/components/compactMonth/compactMonth.types.d.ts +1 -0
- package/dist/types/common/calendar/components/compactMonth/index.d.ts +1 -0
- package/dist/types/common/calendar/components/monthView/index.d.ts +1 -0
- package/dist/types/common/calendar/components/monthView/monthView.d.ts +5 -0
- package/dist/types/common/calendar/components/monthView/monthView.types.d.ts +10 -0
- package/dist/types/common/calendar/components/timeGrid/index.d.ts +1 -0
- package/dist/types/common/calendar/components/timeGrid/timeGrid.d.ts +5 -0
- package/dist/types/common/calendar/components/timeGrid/timeGrid.types.d.ts +40 -0
- package/dist/types/common/calendar/dates.d.ts +50 -0
- package/dist/types/common/calendar/format.d.ts +32 -0
- package/dist/types/common/calendar/gesture.d.ts +32 -0
- package/dist/types/common/calendar/index.d.ts +2 -0
- package/dist/types/common/calendar/layout.d.ts +74 -0
- package/dist/types/common/calendar/useGestures.d.ts +37 -0
- package/dist/types/common/calendar/usePager.d.ts +20 -0
- package/dist/types/common/calendar/view.types.d.ts +26 -0
- package/dist/types/common/configProvider/configProvider.types.d.ts +3 -0
- package/dist/types/common/confirmModal/confirmModal.types.d.ts +1 -1
- package/dist/types/common/datePicker/index.d.ts +1 -1
- package/dist/types/common/modal/modal.types.d.ts +4 -3
- package/dist/types/common/themeProvider/theme.types.d.ts +8 -0
- package/dist/types/common/utils/day.d.ts +8 -0
- package/dist/types/common/virtualList/useColumns.d.ts +3 -1
- package/dist/types/index.d.ts +2 -0
- package/docs/CLAUDE.md +7 -5
- package/docs/Calendar.md +184 -0
- package/docs/ConfigProvider.md +2 -1
- package/docs/ConfirmModal.md +1 -1
- package/docs/DatePicker.md +9 -2
- package/docs/Modal.md +2 -2
- package/docs/TimeInput.md +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -127,6 +127,7 @@ runs where `@ahrowe/ui` is installed.
|
|
|
127
127
|
| `Breadcrumb` | A trail showing the current page's position within a hierarchy, with links back to each ancestor, such as a file browser path, a category/subcategory drill-down, or a multi-level settings page |
|
|
128
128
|
| `Button`, `ButtonStyleType`, `ButtonSize`, `ButtonType` | Primary interactive action trigger |
|
|
129
129
|
| `ButtonGroup`, `ButtonGroupOrientation` | Joins a row (or column) of buttons into a single seamless control, merging their borders and rounding only the outer corners |
|
|
130
|
+
| `Calendar`, `CalendarView` | Showing and editing your own events over time, in month, week, day and agenda views: bookings, shifts, appointments, a team schedule |
|
|
130
131
|
| `Card`, `CardStyleType`, `CardHeader`, `CardMedia`, `CardContent`, `CardActions` | Surface container for grouping related content — list items, profile cards, dashboard tiles, product listings |
|
|
131
132
|
| `Carousel` | A slide track for stepping through a set of items one at a time, with arrows, dots, and drag/swipe support, plus optional autoplay |
|
|
132
133
|
| `Checkbox` | Boolean toggle input — settings, multi-select lists, accept terms, feature flags |
|
|
@@ -136,7 +137,7 @@ runs where `@ahrowe/ui` is installed.
|
|
|
136
137
|
| `ConfigProvider` | Set global **default props** for library components once, near the root of your app, instead of repeating the same prop on every instance |
|
|
137
138
|
| `ConfirmModal` | Confirmation dialog before destructive or irreversible actions — delete, archive, send, overwrite |
|
|
138
139
|
| `CopyButton` | Icon-only button that copies a value to the clipboard: an invoice number, an ID in a table row, an API key or share link inside an `Input` |
|
|
139
|
-
| `DatePicker`, `dateToDay`, `dayToDate` | Date selection input — booking forms, birth date fields, date range pickers, deadline selectors |
|
|
140
|
+
| `DatePicker`, `dateToDay`, `dayToDate`, `dateToTime`, `dayTimeToDate` | Date selection input — booking forms, birth date fields, date range pickers, deadline selectors |
|
|
140
141
|
| `Divider`, `DividerTextPosition`, `DividerOrientation` | A rule that separates sections of content — horizontal by default, filling the width of its parent |
|
|
141
142
|
| `Drawer` | Inline horizontal panel that collapses and expands by animating its width — side panels, navigation rails, detail/filter panes that slide open beside the main content |
|
|
142
143
|
| `DropZone`, `DropZoneReturnType`, `DropZoneStatus` | Drag-and-drop file upload area, optionally click-to-open the native picker |
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode, Ref } from 'react';
|
|
2
|
+
import { SlotClassNames, SlotStyles, HtmlProps } from '../types/slots.types.js';
|
|
3
|
+
export declare enum CalendarView {
|
|
4
|
+
Month = "month",
|
|
5
|
+
Week = "week",
|
|
6
|
+
Day = "day",
|
|
7
|
+
Agenda = "agenda"
|
|
8
|
+
}
|
|
9
|
+
/** A day of the week, as `Date#getDay()` counts: 0 is Sunday, 1 is Monday. */
|
|
10
|
+
export type CalendarWeekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
11
|
+
/** First day of the week, as `Date#getDay()` counts: 0 is Sunday, 1 is Monday. */
|
|
12
|
+
export type CalendarWeekStart = CalendarWeekday;
|
|
13
|
+
export interface CalendarEvent {
|
|
14
|
+
id: string | number;
|
|
15
|
+
title: string;
|
|
16
|
+
/** Local time. */
|
|
17
|
+
start: Date;
|
|
18
|
+
/** Local time, exclusive. An all-day event on the 26th ends at midnight on the 27th. */
|
|
19
|
+
end: Date;
|
|
20
|
+
/** Shown in the all-day row instead of the time grid. Timed events of 24 hours or more are too. */
|
|
21
|
+
allDay?: boolean;
|
|
22
|
+
/** Any CSS colour. Falls back to `--primary-color`. */
|
|
23
|
+
color?: string;
|
|
24
|
+
/** Can be clicked but not moved or resized. */
|
|
25
|
+
readOnly?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** A span of local time. `end` is exclusive. */
|
|
28
|
+
export interface CalendarRange {
|
|
29
|
+
start: Date;
|
|
30
|
+
end: Date;
|
|
31
|
+
}
|
|
32
|
+
export interface CalendarEventChange<E extends CalendarEvent = CalendarEvent> {
|
|
33
|
+
event: E;
|
|
34
|
+
start: Date;
|
|
35
|
+
end: Date;
|
|
36
|
+
}
|
|
37
|
+
export interface CalendarSlot {
|
|
38
|
+
start: Date;
|
|
39
|
+
end: Date;
|
|
40
|
+
allDay: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** Where `renderEvent` draws an event. */
|
|
43
|
+
export interface CalendarEventContext {
|
|
44
|
+
/**
|
|
45
|
+
* The event has one line: an event under 45 minutes in the week and day views, an all-day bar,
|
|
46
|
+
* or a row of the month view. The day and agenda lists have room for more.
|
|
47
|
+
*/
|
|
48
|
+
singleLine: boolean;
|
|
49
|
+
}
|
|
50
|
+
export type CalendarSlots = 'root' | 'header' | 'dayHeader' | 'cell' | 'event';
|
|
51
|
+
/** Text Calendar renders of its own, for translating it. Dates and times come from `locale`. */
|
|
52
|
+
export interface CalendarLabels {
|
|
53
|
+
/** Previous period button (default `Previous`). */
|
|
54
|
+
previous?: string;
|
|
55
|
+
/** Next period button (default `Next`). */
|
|
56
|
+
next?: string;
|
|
57
|
+
/** Jump to today (default `Today`). */
|
|
58
|
+
today?: string;
|
|
59
|
+
/** Name of the view switcher, read out by screen readers (default `Calendar view`). */
|
|
60
|
+
viewSwitcher?: string;
|
|
61
|
+
month?: string;
|
|
62
|
+
week?: string;
|
|
63
|
+
day?: string;
|
|
64
|
+
agenda?: string;
|
|
65
|
+
/** All-day row and all-day events (default `All day`). */
|
|
66
|
+
allDay?: string;
|
|
67
|
+
/** Overflow button in a month cell (default `+3 more`). */
|
|
68
|
+
more?: (count: number) => string;
|
|
69
|
+
/** Appended to a day's name for screen readers (default `3 events`). */
|
|
70
|
+
eventCount?: (count: number) => string;
|
|
71
|
+
/** A day or period without events (default `No events`). */
|
|
72
|
+
noEvents?: string;
|
|
73
|
+
/** Create button in a day's event list, shown when `onSlotCreate` is set (default `New event`). */
|
|
74
|
+
newEvent?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface CalendarProps<E extends CalendarEvent = CalendarEvent> extends HtmlProps<HTMLDivElement> {
|
|
77
|
+
/** The events to show. Only the ones inside the range `onRangeChange` reports are needed. */
|
|
78
|
+
events: E[];
|
|
79
|
+
/** Controlled: the selected day, `'YYYY-MM-DD'`, whose period is shown. Omit for uncontrolled. */
|
|
80
|
+
date?: string;
|
|
81
|
+
/** Day shown initially when uncontrolled, `'YYYY-MM-DD'` (default today). */
|
|
82
|
+
defaultDate?: string;
|
|
83
|
+
/** Called with the new day, `'YYYY-MM-DD'`: the value a DatePicker holds. */
|
|
84
|
+
onDateChange?: (day: string) => void;
|
|
85
|
+
/** Controlled view. Omit for uncontrolled. */
|
|
86
|
+
view?: CalendarView;
|
|
87
|
+
/** View shown initially when uncontrolled (default `CalendarView.Month`). */
|
|
88
|
+
defaultView?: CalendarView;
|
|
89
|
+
onViewChange?: (view: CalendarView) => void;
|
|
90
|
+
/** Views offered in the switcher, in order. The switcher is hidden when there is only one (default all four). */
|
|
91
|
+
views?: CalendarView[];
|
|
92
|
+
/** BCP 47 tag for dates, times and the week start (default the browser's locale). */
|
|
93
|
+
locale?: string;
|
|
94
|
+
/** Overrides the locale's first day of the week. */
|
|
95
|
+
weekStartsOn?: CalendarWeekStart;
|
|
96
|
+
/** Minutes that creating, moving and resizing snap to (default `15`). */
|
|
97
|
+
slotMinutes?: number;
|
|
98
|
+
/** Days of the week left out of every view: `[0, 6]` hides the weekend. */
|
|
99
|
+
hiddenDays?: CalendarWeekday[];
|
|
100
|
+
/**
|
|
101
|
+
* Hour the week and day views open at, such as `6` for 06:00 (default an hour before now while
|
|
102
|
+
* today is shown, otherwise 07:00).
|
|
103
|
+
*/
|
|
104
|
+
scrollToHour?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Called on mount and whenever the shown period changes, with the period and one either side of
|
|
107
|
+
* it, so the neighbours are already filled while swiping. Fetch events and expand recurring
|
|
108
|
+
* series for this range.
|
|
109
|
+
*/
|
|
110
|
+
onRangeChange?: (range: CalendarRange) => void;
|
|
111
|
+
/** An event was clicked or tapped. `anchor` is its element, for positioning a popover. */
|
|
112
|
+
onEventClick?: (event: E, anchor: HTMLElement) => void;
|
|
113
|
+
/**
|
|
114
|
+
* An event was moved or resized. Setting it is what makes events draggable. Update `events`
|
|
115
|
+
* in the same render, or return a promise: the event then stays where it was dropped until the
|
|
116
|
+
* promise settles, and is drawn from `events` again after that, back in place if it rejected.
|
|
117
|
+
*/
|
|
118
|
+
onEventChange?: (change: CalendarEventChange<E>) => void | Promise<unknown>;
|
|
119
|
+
/**
|
|
120
|
+
* Empty time was clicked or dragged over. Setting it is what enables creating: a click creates
|
|
121
|
+
* an hour, or an all-day slot in the month view. `anchor` marks the slot on screen, for a
|
|
122
|
+
* popover's `anchor`: the day's cell in the month view, an invisible box over the slot in the
|
|
123
|
+
* week and day views.
|
|
124
|
+
*/
|
|
125
|
+
onSlotCreate?: (slot: CalendarSlot, anchor: HTMLElement) => void;
|
|
126
|
+
/**
|
|
127
|
+
* Content of an event, in place of its title. Must not contain interactive elements. Keep to the
|
|
128
|
+
* title where `context.singleLine` is set: further lines have no room there.
|
|
129
|
+
*/
|
|
130
|
+
renderEvent?: (event: E, context: CalendarEventContext) => ReactNode;
|
|
131
|
+
/** The root element. */
|
|
132
|
+
ref?: Ref<HTMLDivElement>;
|
|
133
|
+
className?: string;
|
|
134
|
+
style?: CSSProperties;
|
|
135
|
+
classNames?: SlotClassNames<CalendarSlots>;
|
|
136
|
+
styles?: SlotStyles<CalendarSlots>;
|
|
137
|
+
/** Overrides the text Calendar renders of its own. Merged per key. */
|
|
138
|
+
labels?: CalendarLabels;
|
|
139
|
+
}
|
|
140
|
+
/** The props `ConfigProvider` can set for every Calendar. The rest depend on the event type. */
|
|
141
|
+
export type CalendarDefaults = Pick<CalendarProps, 'labels' | 'locale' | 'weekStartsOn' | 'slotMinutes' | 'views' | 'hiddenDays' | 'scrollToHour'>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { CalendarEvent } from '../../calendar.types.js';
|
|
3
|
+
import { AgendaListProps } from './agendaList.types.js';
|
|
4
|
+
declare function AgendaList<E extends CalendarEvent>({ events, start, days, hidden, scrollTo, showDayHeaders, locale, text, onEventClick, renderEvent, className, classNames, slotStyles, }: AgendaListProps<E>): ReactElement;
|
|
5
|
+
export default AgendaList;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SlotClassNames, SlotStyles } from '../../../types/slots.types.js';
|
|
3
|
+
import { CalendarEvent, CalendarEventContext, CalendarLabels, CalendarSlots } from '../../calendar.types.js';
|
|
4
|
+
export interface AgendaListProps<E extends CalendarEvent = CalendarEvent> {
|
|
5
|
+
events: readonly E[];
|
|
6
|
+
/** First day listed. */
|
|
7
|
+
start: Date;
|
|
8
|
+
/** Days listed from `start`. */
|
|
9
|
+
days: number;
|
|
10
|
+
/** Weekdays left out of the list, as `Date#getDay()` counts. */
|
|
11
|
+
hidden?: ReadonlySet<number>;
|
|
12
|
+
/** Scrolled to on mount and whenever it changes: the first listed day on or after it. */
|
|
13
|
+
scrollTo?: Date;
|
|
14
|
+
/** A dated heading over each day. The list of a single, already named day leaves them out. */
|
|
15
|
+
showDayHeaders: boolean;
|
|
16
|
+
locale: string | undefined;
|
|
17
|
+
text: Required<CalendarLabels>;
|
|
18
|
+
onEventClick: ((event: E, anchor: HTMLElement) => void) | undefined;
|
|
19
|
+
renderEvent: ((event: E, context: CalendarEventContext) => ReactNode) | undefined;
|
|
20
|
+
className?: string;
|
|
21
|
+
classNames: SlotClassNames<CalendarSlots> | undefined;
|
|
22
|
+
slotStyles: SlotStyles<CalendarSlots> | undefined;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './agendaList.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { CalendarHeaderProps } from './calendarHeader.types.js';
|
|
3
|
+
declare function CalendarHeader({ title, compact, direction, view, views, text, onStep, onToday, onViewChange, className, style, }: CalendarHeaderProps): ReactElement;
|
|
4
|
+
export default CalendarHeader;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { CalendarLabels, CalendarView } from '../../calendar.types.js';
|
|
3
|
+
export interface CalendarHeaderProps {
|
|
4
|
+
title: string;
|
|
5
|
+
/** Narrow: the view switcher takes a row of its own. */
|
|
6
|
+
compact: boolean;
|
|
7
|
+
/** `1` after paging forwards, `-1` back: the direction the title slides in from. */
|
|
8
|
+
direction: 1 | -1;
|
|
9
|
+
view: CalendarView;
|
|
10
|
+
views: CalendarView[];
|
|
11
|
+
text: Required<CalendarLabels>;
|
|
12
|
+
onStep: (step: 1 | -1) => void;
|
|
13
|
+
onToday: () => void;
|
|
14
|
+
onViewChange: (view: CalendarView) => void;
|
|
15
|
+
className?: string;
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './calendarHeader.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { CalendarEvent } from '../../calendar.types.js';
|
|
3
|
+
import { CompactMonthProps } from './compactMonth.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The month view of a narrow calendar: a grid of days with event dots over the selected day's
|
|
6
|
+
* events. Scrolling that list folds the month up into the selected week, iOS-style.
|
|
7
|
+
*/
|
|
8
|
+
declare function CompactMonth<E extends CalendarEvent>({ events, date, locale, weekStartsOn, hidden, text, onDateChange, onEventClick, onSlotCreate, renderEvent, classNames, slotStyles, }: CompactMonthProps<E>): ReactElement;
|
|
9
|
+
export default CompactMonth;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { CalendarViewProps as CompactMonthProps } from '../../view.types.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './compactMonth.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './monthView.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { CalendarEvent } from '../../calendar.types.js';
|
|
3
|
+
import { MonthViewProps } from './monthView.types.js';
|
|
4
|
+
declare function MonthView<E extends CalendarEvent>({ events, date, locale, weekStartsOn, hidden, text, onDateChange, onOpenDay, onEventClick, onEventChange, onSlotCreate, renderEvent, classNames, slotStyles, }: MonthViewProps<E>): ReactElement;
|
|
5
|
+
export default MonthView;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CalendarEvent } from '../../calendar.types.js';
|
|
2
|
+
/** An event picked up in the month view, and how many days it has been dragged. */
|
|
3
|
+
export interface MonthDrag<E extends CalendarEvent = CalendarEvent> {
|
|
4
|
+
event: E;
|
|
5
|
+
/** The day under the pointer when it was picked up. */
|
|
6
|
+
grabbed: Date;
|
|
7
|
+
/** Days it has been dragged by. */
|
|
8
|
+
offset: number;
|
|
9
|
+
}
|
|
10
|
+
export type { CalendarViewProps as MonthViewProps } from '../../view.types.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './timeGrid.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { CalendarEvent } from '../../calendar.types.js';
|
|
3
|
+
import { TimeGridProps } from './timeGrid.types.js';
|
|
4
|
+
declare function TimeGrid<E extends CalendarEvent>({ events, date, view, locale, weekStartsOn, slotMinutes, hidden, scrollToHour, text, onDateChange, onOpenDay, onEventClick, onEventChange, onSlotCreate, renderEvent, classNames, slotStyles, zoomRef, }: TimeGridProps<E>): ReactElement;
|
|
5
|
+
export default TimeGrid;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { CalendarEvent } from '../../calendar.types.js';
|
|
3
|
+
import { CalendarViewProps } from '../../view.types.js';
|
|
4
|
+
export interface TimeGridZoom {
|
|
5
|
+
/** Hour height in px. */
|
|
6
|
+
hour: number;
|
|
7
|
+
/** The theme's hour height in px, measured before the first zoom: the scale the limits are set in. */
|
|
8
|
+
base: number;
|
|
9
|
+
}
|
|
10
|
+
export interface TimeGridProps<E extends CalendarEvent = CalendarEvent> extends CalendarViewProps<E> {
|
|
11
|
+
/**
|
|
12
|
+
* The zoom set by pinching, or `null` for the theme's hour height. Owned by Calendar so the
|
|
13
|
+
* zoom survives switching between Week and Day, or out to Month and back.
|
|
14
|
+
*/
|
|
15
|
+
zoomRef: RefObject<TimeGridZoom | null>;
|
|
16
|
+
}
|
|
17
|
+
interface DragBase {
|
|
18
|
+
/** The time the preview shows, recomputed on every move. */
|
|
19
|
+
start: Date;
|
|
20
|
+
end: Date;
|
|
21
|
+
}
|
|
22
|
+
export interface CreateDrag extends DragBase {
|
|
23
|
+
kind: 'create';
|
|
24
|
+
/** Days from the period's first day to the one the drag started on. Creating stays on it. */
|
|
25
|
+
day: number;
|
|
26
|
+
/** Wall-clock minutes of the press. */
|
|
27
|
+
anchor: number;
|
|
28
|
+
}
|
|
29
|
+
export interface MoveDrag<E extends CalendarEvent = CalendarEvent> extends DragBase {
|
|
30
|
+
kind: 'move';
|
|
31
|
+
event: E;
|
|
32
|
+
/** Minutes from the event's start to the press, so the event does not jump under the finger. */
|
|
33
|
+
grab: number;
|
|
34
|
+
}
|
|
35
|
+
export interface ResizeDrag<E extends CalendarEvent = CalendarEvent> extends DragBase {
|
|
36
|
+
kind: 'resize';
|
|
37
|
+
event: E;
|
|
38
|
+
}
|
|
39
|
+
export type TimeDrag<E extends CalendarEvent = CalendarEvent> = CreateDrag | MoveDrag<E> | ResizeDrag<E>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { CalendarView, CalendarRange, CalendarWeekStart } from './calendar.types.js';
|
|
2
|
+
export declare const MINUTES_PER_DAY = 1440;
|
|
3
|
+
export declare function startOfDay(date: Date): Date;
|
|
4
|
+
/** Midnight, `days` calendar days away. */
|
|
5
|
+
export declare function addDays(date: Date, days: number): Date;
|
|
6
|
+
/** The same wall-clock time, `days` calendar days away. */
|
|
7
|
+
export declare function shiftDays(date: Date, days: number): Date;
|
|
8
|
+
export declare function daysInMonth(year: number, month: number): number;
|
|
9
|
+
/** Midnight, `months` months away. The day is clamped, so 31 January plus one month is the end of February. */
|
|
10
|
+
export declare function addMonths(date: Date, months: number): Date;
|
|
11
|
+
export declare function startOfMonth(date: Date): Date;
|
|
12
|
+
export declare function startOfWeek(date: Date, weekStartsOn: CalendarWeekStart): Date;
|
|
13
|
+
/** Calendar days from `a` to `b`, whatever their times of day. */
|
|
14
|
+
export declare function dayDiff(a: Date, b: Date): number;
|
|
15
|
+
export declare function isSameDay(a: Date, b: Date): boolean;
|
|
16
|
+
export { dateToDay } from '../utils/day.js';
|
|
17
|
+
/** Wall-clock minutes since midnight. On a 25-hour day the repeated hour maps onto itself. */
|
|
18
|
+
export declare function minutesOfDay(date: Date): number;
|
|
19
|
+
/**
|
|
20
|
+
* The wall-clock time `minutes` after the start of `day`; 1440 is the next midnight. A time the
|
|
21
|
+
* clock skips resolves forwards (02:30 becomes 03:30) and a repeated one to its first occurrence.
|
|
22
|
+
*/
|
|
23
|
+
export declare function atMinutes(day: Date, minutes: number): Date;
|
|
24
|
+
/**
|
|
25
|
+
* `end`, unless a clock change turned the range around: where one end lands in the hour the
|
|
26
|
+
* clocks skip, a wall-clock end can fall on or before its start. Then `minutes` of real time
|
|
27
|
+
* after the start instead.
|
|
28
|
+
*/
|
|
29
|
+
export declare function endAfter(start: Date, end: Date, minutes: number): Date;
|
|
30
|
+
/** Midnight of the first day of the period `date` is in. */
|
|
31
|
+
export declare function periodStart(view: CalendarView, date: Date, weekStartsOn: CalendarWeekStart): Date;
|
|
32
|
+
/** The days a view shows for `date`. The month view is always six full weeks. */
|
|
33
|
+
export declare function periodRange(view: CalendarView, date: Date, weekStartsOn: CalendarWeekStart): CalendarRange;
|
|
34
|
+
/** `hiddenDays` as a lookup. A list that leaves no day of the week hides nothing. */
|
|
35
|
+
export declare function hiddenDaySet(hiddenDays: readonly number[] | undefined): ReadonlySet<number>;
|
|
36
|
+
/** `date`, or the first shown day from it on in `direction`. */
|
|
37
|
+
export declare function shownDay(date: Date, hidden: ReadonlySet<number>, direction?: 1 | -1): Date;
|
|
38
|
+
/** `date` moved by `steps` periods, keeping its place in the period where it can. */
|
|
39
|
+
export declare function stepDate(view: CalendarView, date: Date, steps: number, hidden?: ReadonlySet<number>): Date;
|
|
40
|
+
/** The shown period plus one on either side: what the swipe pager can reveal. */
|
|
41
|
+
export declare function rangeWithNeighbours(view: CalendarView, date: Date, weekStartsOn: CalendarWeekStart, hidden?: ReadonlySet<number>): CalendarRange;
|
|
42
|
+
/** Midnight of each of `count` days from `start`. */
|
|
43
|
+
export declare function daysFrom(start: Date, count: number): Date[];
|
|
44
|
+
/** The days of `count` from `start` that are not hidden: the columns a row of them draws. */
|
|
45
|
+
export declare function shownDays(start: Date, count: number, hidden?: ReadonlySet<number>): Date[];
|
|
46
|
+
/**
|
|
47
|
+
* The day a month grid moves to for `key`, or `null` for a key it does not handle. A hidden day
|
|
48
|
+
* gives way to the next shown one in the direction the key points, so the focus stays on a cell.
|
|
49
|
+
*/
|
|
50
|
+
export declare function gridKeyTarget(key: string, day: Date, weekStartsOn: CalendarWeekStart, hidden?: ReadonlySet<number>): Date | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CalendarView, CalendarRange, CalendarWeekStart } from './calendar.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Cached, since building one costs about fifty times more than using it. A formatter keeps the
|
|
4
|
+
* time zone it was built in while `Date` follows the current one, so the key carries the zone: a
|
|
5
|
+
* zone change (the device's, or `process.env.TZ` between tests) then builds a new formatter
|
|
6
|
+
* instead of labelling days in the old zone.
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatter(locale: string | undefined, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
|
|
9
|
+
/**
|
|
10
|
+
* The locale's first day of the week, falling back to Monday where `getWeekInfo` is missing:
|
|
11
|
+
* it is Baseline only since July 2026 (Chrome 130, Firefox 153, Safari 17).
|
|
12
|
+
*/
|
|
13
|
+
export declare function localeWeekStart(locale: string | undefined): CalendarWeekStart;
|
|
14
|
+
export declare function formatTime(date: Date, locale: string | undefined): string;
|
|
15
|
+
/** A time span, with the dates added by Intl where the two ends fall on different days. */
|
|
16
|
+
export declare function formatTimeRange(start: Date, end: Date, locale: string | undefined): string;
|
|
17
|
+
/**
|
|
18
|
+
* The clock times alone, `10:00 PM to 2:00 AM` as the locale writes it, where `formatTimeRange` would add both dates for
|
|
19
|
+
* an event that crosses midnight. Both ends are moved onto one day for it. The first spec of
|
|
20
|
+
* `formatRange` threw a RangeError for an end earlier than the start; an engine still doing that
|
|
21
|
+
* gets the start time alone.
|
|
22
|
+
*/
|
|
23
|
+
export declare function formatClockRange(start: Date, end: Date, locale: string | undefined): string;
|
|
24
|
+
/** `9 AM` where the locale counts to twelve, `09:00` where it counts to 24. */
|
|
25
|
+
export declare function formatHour(hour: number, locale: string | undefined): string;
|
|
26
|
+
export declare function formatWeekday(date: Date, locale: string | undefined, width: 'long' | 'short' | 'narrow'): string;
|
|
27
|
+
/** The day of the month in the locale's own digits. */
|
|
28
|
+
export declare function formatDayNumber(date: Date, locale: string | undefined): string;
|
|
29
|
+
export declare function formatLongDate(date: Date, locale: string | undefined): string;
|
|
30
|
+
export declare function formatShortDate(date: Date, locale: string | undefined): string;
|
|
31
|
+
export declare function formatMonthTitle(date: Date, locale: string | undefined): string;
|
|
32
|
+
export declare function formatPeriodTitle(view: CalendarView, date: Date, range: CalendarRange, locale: string | undefined): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Touch movement before a press is read as a swipe or a scroll (carousel.tsx, useSwipeDismiss.ts). */
|
|
2
|
+
export declare const LOCK_DISTANCE = 10;
|
|
3
|
+
/** Mouse movement before a press becomes a drag. */
|
|
4
|
+
export declare const MOUSE_DRAG_DISTANCE = 4;
|
|
5
|
+
/** Hold before a touch picks something up (VirtualList's `longPressDelay`). */
|
|
6
|
+
export declare const LONG_PRESS_MS = 400;
|
|
7
|
+
/** A touch this soon after a scroll is stopping momentum, not picking something up. */
|
|
8
|
+
export declare const RECENT_SCROLL_MS = 150;
|
|
9
|
+
/** Share of the width a swipe must travel to page (carousel.tsx). */
|
|
10
|
+
export declare const COMMIT_RATIO = 0.2;
|
|
11
|
+
/** px/ms a shorter flick must reach to page anyway (useSwipeDismiss.ts). */
|
|
12
|
+
export declare const COMMIT_VELOCITY = 0.5;
|
|
13
|
+
/** How far back the flick velocity is measured. */
|
|
14
|
+
export declare const VELOCITY_WINDOW_MS = 100;
|
|
15
|
+
/** Distance from a scroller's edge where a drag starts scrolling it (useRowDrag.ts). */
|
|
16
|
+
export declare const EDGE_ZONE = 48;
|
|
17
|
+
/** px per frame at the very edge. */
|
|
18
|
+
export declare const EDGE_SPEED = 18;
|
|
19
|
+
/** How long after a gesture the click it ends in is swallowed (useRowDrag.ts). */
|
|
20
|
+
export declare const CLICK_SUPPRESS_MS = 350;
|
|
21
|
+
/** `1` to page forwards, `-1` back, `0` to return. A swipe to the left reveals the next period. */
|
|
22
|
+
export declare function pageStep(dx: number, width: number, velocity: number): -1 | 0 | 1;
|
|
23
|
+
/** Scroll speed for a pointer at `y` in a scroller spanning `top` to `bottom`: negative scrolls up. */
|
|
24
|
+
export declare function edgeSpeed(y: number, top: number, bottom: number): number;
|
|
25
|
+
export declare function snap(minutes: number, step: number): number;
|
|
26
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
27
|
+
export interface VelocitySample {
|
|
28
|
+
time: number;
|
|
29
|
+
x: number;
|
|
30
|
+
}
|
|
31
|
+
/** px/ms over the samples of the last `VELOCITY_WINDOW_MS`. */
|
|
32
|
+
export declare function velocityOf(samples: readonly VelocitySample[], now: number): number;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { CalendarEvent } from './calendar.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Below this an event has no room for a line of text at the default hour height. It is drawn as a
|
|
4
|
+
* bar of its real length with its label beneath, and packed with room for that label.
|
|
5
|
+
*/
|
|
6
|
+
export declare const BRIEF_EVENT_MINUTES = 15;
|
|
7
|
+
/** `end`, clamped so an event that ends before it starts is treated as having no length. */
|
|
8
|
+
export declare function eventEnd(event: CalendarEvent): Date;
|
|
9
|
+
/** Drawn in the all-day row rather than the time grid. */
|
|
10
|
+
export declare function isAllDayLike(event: CalendarEvent): boolean;
|
|
11
|
+
/** First and last day (both midnight, both inclusive) the event appears on. */
|
|
12
|
+
export declare function eventDays(event: CalendarEvent): {
|
|
13
|
+
first: Date;
|
|
14
|
+
last: Date;
|
|
15
|
+
};
|
|
16
|
+
/** All-day events first, then by start, then the longer first, so a day reads the same everywhere. */
|
|
17
|
+
export declare function compareEvents(a: CalendarEvent, b: CalendarEvent): number;
|
|
18
|
+
/** The events on each of `dates`, sorted with `compareEvents`. */
|
|
19
|
+
export declare function eventsByDay<E extends CalendarEvent>(events: readonly E[], dates: readonly Date[]): E[][];
|
|
20
|
+
export interface TimedBox<E extends CalendarEvent = CalendarEvent> {
|
|
21
|
+
event: E;
|
|
22
|
+
/** Wall-clock minutes from the column's midnight. */
|
|
23
|
+
top: number;
|
|
24
|
+
bottom: number;
|
|
25
|
+
/** Where the next event in its column may start: below the label of a brief event. */
|
|
26
|
+
reach: number;
|
|
27
|
+
/** Left edge, as a column of `columns`. */
|
|
28
|
+
column: number;
|
|
29
|
+
columns: number;
|
|
30
|
+
/** Columns it can widen into to its right without covering another event. */
|
|
31
|
+
span: number;
|
|
32
|
+
continuesBefore: boolean;
|
|
33
|
+
continuesAfter: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Lays out one day column of the time grid: events that overlap share the width in columns, and
|
|
37
|
+
* each one widens right into columns that are free for its whole height.
|
|
38
|
+
*
|
|
39
|
+
* Positions are wall-clock minutes, never milliseconds from midnight. Drawing and packing have
|
|
40
|
+
* to agree on that: on a 25-hour day two events in the repeated hour occupy the same rows, and
|
|
41
|
+
* packing them by real time would put them in one column, drawn over each other.
|
|
42
|
+
*/
|
|
43
|
+
export declare function packDay<E extends CalendarEvent>(events: readonly E[], day: Date): TimedBox<E>[];
|
|
44
|
+
export interface LaneBar<E extends CalendarEvent = CalendarEvent> {
|
|
45
|
+
event: E;
|
|
46
|
+
/** First column of the row it covers, 0-based. */
|
|
47
|
+
start: number;
|
|
48
|
+
/** Columns it covers within the row. */
|
|
49
|
+
span: number;
|
|
50
|
+
lane: number;
|
|
51
|
+
/** It starts before its first column: in an earlier row, or on a hidden day. */
|
|
52
|
+
continuesBefore: boolean;
|
|
53
|
+
continuesAfter: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Stacks the events of one row of days into lanes, as the month view and the all-day row draw
|
|
57
|
+
* them: longer bars first, so a multi-day event keeps one lane across the week. `dates` are the
|
|
58
|
+
* row's columns, so a hidden day between two of them is simply not drawn.
|
|
59
|
+
*/
|
|
60
|
+
export declare function packLanes<E extends CalendarEvent>(events: readonly E[], dates: readonly Date[], include?: (event: E) => boolean): LaneBar<E>[];
|
|
61
|
+
export interface LimitedLanes<E extends CalendarEvent = CalendarEvent> {
|
|
62
|
+
visible: LaneBar<E>[];
|
|
63
|
+
/** Lane the `+N` buttons go in, on the days that have one. */
|
|
64
|
+
moreLane: number;
|
|
65
|
+
/** Events hidden on each day of the row. */
|
|
66
|
+
hidden: number[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Fits the bars into `capacity` lanes. A day that needs more gives its last lane to a `+N`
|
|
70
|
+
* button; a day that does not keeps every bar. Decided per day, so one crowded day does not
|
|
71
|
+
* hide events on the quiet days next to it. A bar crossing into a crowded day's `+N` lane is
|
|
72
|
+
* hidden along its whole length and counted on each day it covers.
|
|
73
|
+
*/
|
|
74
|
+
export declare function limitLanes<E extends CalendarEvent>(bars: LaneBar<E>[], days: number, capacity: number): LimitedLanes<E>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
export interface GesturePoint {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
export interface GestureHandlers<D> {
|
|
7
|
+
/** Every press that starts a gesture, before anything else: where a running settle is finished. */
|
|
8
|
+
onPress?: () => void;
|
|
9
|
+
/** Whether a horizontal swipe may page right now. */
|
|
10
|
+
canSwipe?: () => boolean;
|
|
11
|
+
onSwipeMove?: (dx: number) => void;
|
|
12
|
+
/** Also called with `(0, 0)` when the browser takes the gesture over. */
|
|
13
|
+
onSwipeEnd?: (dx: number, velocity: number) => void;
|
|
14
|
+
/** What a press on `target` would pick up, or `null` where nothing can be dragged. */
|
|
15
|
+
dragFrom?: (target: Element, point: GesturePoint) => D | null;
|
|
16
|
+
onDragStart?: (drag: D, point: GesturePoint) => void;
|
|
17
|
+
onDragMove?: (point: GesturePoint) => void;
|
|
18
|
+
onDragEnd?: (point: GesturePoint) => void;
|
|
19
|
+
onDragCancel?: () => void;
|
|
20
|
+
onPinchStart?: (center: GesturePoint, distance: number) => void;
|
|
21
|
+
onPinchMove?: (center: GesturePoint, distance: number) => void;
|
|
22
|
+
onPinchEnd?: () => void;
|
|
23
|
+
/** The element a drag scrolls near its edges, and the band of the viewport that counts as its inside. */
|
|
24
|
+
autoScroll?: () => {
|
|
25
|
+
element: HTMLElement;
|
|
26
|
+
top: number;
|
|
27
|
+
bottom: number;
|
|
28
|
+
} | null;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* One owner for every pointer gesture inside `ref`, so a swipe, a long-press drag, a pinch and
|
|
32
|
+
* the browser's own scrolling can never both act on the same touch.
|
|
33
|
+
*
|
|
34
|
+
* Mouse or touch rules are chosen per event from `pointerType`, not once from a media query,
|
|
35
|
+
* which answers wrongly on a laptop with a touch screen.
|
|
36
|
+
*/
|
|
37
|
+
export declare function useGestures<D>(ref: RefObject<HTMLElement | null>, handlers: GestureHandlers<D>): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface Pager {
|
|
2
|
+
/** Ref for each element that slides. The time grid has two, its head and its body. */
|
|
3
|
+
trackRef: (element: HTMLElement | null) => void;
|
|
4
|
+
/** Width of one pane. */
|
|
5
|
+
width: () => number;
|
|
6
|
+
/** Offset every track by `dx` px, following the finger. */
|
|
7
|
+
move: (dx: number) => void;
|
|
8
|
+
/** Animate to the next (`1`) or previous (`-1`) pane and page, or back (`0`). */
|
|
9
|
+
settle: (step: -1 | 0 | 1) => void;
|
|
10
|
+
/** Jump to the end of a running settle: a new press arrived before it finished. */
|
|
11
|
+
finish: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Drives the three panes a pageable view renders: previous, current and next, keyed by period, so
|
|
15
|
+
* after paging the pane that slid in is the same DOM node as the one now current. The track is
|
|
16
|
+
* reset in the same commit that swaps them, which is why nothing flashes.
|
|
17
|
+
*
|
|
18
|
+
* `focusFallback` receives focus when it would otherwise be left inside a pane that just went inert.
|
|
19
|
+
*/
|
|
20
|
+
export declare function usePager(periodKey: string, onPage: (step: 1 | -1) => void, focusFallback: () => HTMLElement | null): Pager;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { SlotClassNames, SlotStyles } from '../types/slots.types.js';
|
|
3
|
+
import { CalendarEvent, CalendarEventChange, CalendarEventContext, CalendarLabels, CalendarSlot, CalendarSlots, CalendarView, CalendarWeekStart } from './calendar.types.js';
|
|
4
|
+
/** What Calendar hands each of its views. Internal, so it stays out of the published types. */
|
|
5
|
+
export interface CalendarViewProps<E extends CalendarEvent = CalendarEvent> {
|
|
6
|
+
events: readonly E[];
|
|
7
|
+
/** Local midnight of the selected day. */
|
|
8
|
+
date: Date;
|
|
9
|
+
view: CalendarView;
|
|
10
|
+
locale: string | undefined;
|
|
11
|
+
weekStartsOn: CalendarWeekStart;
|
|
12
|
+
slotMinutes: number;
|
|
13
|
+
/** Weekdays left out, as `Date#getDay()` counts. `date` is never one of them. */
|
|
14
|
+
hidden: ReadonlySet<number>;
|
|
15
|
+
scrollToHour: number | undefined;
|
|
16
|
+
text: Required<CalendarLabels>;
|
|
17
|
+
onDateChange: (date: Date) => void;
|
|
18
|
+
/** Opens a day in the Day view, or `undefined` where the Day view is not offered. */
|
|
19
|
+
onOpenDay: ((date: Date) => void) | undefined;
|
|
20
|
+
onEventClick: ((event: E, anchor: HTMLElement) => void) | undefined;
|
|
21
|
+
onEventChange: ((change: CalendarEventChange<E>) => void) | undefined;
|
|
22
|
+
onSlotCreate: ((slot: CalendarSlot, anchor: HTMLElement) => void) | undefined;
|
|
23
|
+
renderEvent: ((event: E, context: CalendarEventContext) => ReactNode) | undefined;
|
|
24
|
+
classNames: SlotClassNames<CalendarSlots> | undefined;
|
|
25
|
+
slotStyles: SlotStyles<CalendarSlots> | undefined;
|
|
26
|
+
}
|
|
@@ -15,6 +15,7 @@ import { SearchInputLabels } from '../searchInput/searchInput.types.js';
|
|
|
15
15
|
import { TooltipLabels } from '../tooltip/tooltip.types.js';
|
|
16
16
|
import { VirtualListLabels } from '../virtualList/virtualList.types.js';
|
|
17
17
|
import { ButtonProps } from '../button/button.types.js';
|
|
18
|
+
import { CalendarDefaults } from '../calendar/calendar.types.js';
|
|
18
19
|
import { CopyButtonProps } from '../copyButton/copyButton.types.js';
|
|
19
20
|
import { CommandPaletteProps } from '../commandPalette/commandPalette.types.js';
|
|
20
21
|
import { WeatherIconProps } from '../weatherIcon/weatherIcon.types.js';
|
|
@@ -84,6 +85,8 @@ export interface ComponentDefaults {
|
|
|
84
85
|
VirtualList?: {
|
|
85
86
|
labels?: VirtualListLabels;
|
|
86
87
|
};
|
|
88
|
+
/** Not `Partial<CalendarProps>`: the rest of its props depend on the event type. */
|
|
89
|
+
Calendar?: CalendarDefaults;
|
|
87
90
|
Input?: Partial<InputProps>;
|
|
88
91
|
Textarea?: Partial<TextareaProps>;
|
|
89
92
|
NumberInput?: Partial<NumberInputProps>;
|
|
@@ -14,7 +14,7 @@ export interface ConfirmModalProps extends Omit<HtmlProps<HTMLDivElement>, 'onCl
|
|
|
14
14
|
style?: CSSProperties;
|
|
15
15
|
onClose?: (didSubmit: boolean) => void;
|
|
16
16
|
onConfirm?: () => void | Promise<void>;
|
|
17
|
-
title?:
|
|
17
|
+
title?: ReactNode;
|
|
18
18
|
content?: ReactNode;
|
|
19
19
|
isOpen?: boolean;
|
|
20
20
|
isDelete?: boolean;
|