exact-scheduler 0.0.1 → 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/CHANGELOG.md ADDED
@@ -0,0 +1,65 @@
1
+ # Changelog
2
+
3
+ All notable changes to this package are recorded here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the package uses
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [0.1.0] - 2026-12-06
8
+
9
+ The first npm release.
10
+
11
+ ### Verified
12
+
13
+ On Exact `f7788c9e6` (2026-12-04), with no change to the package:
14
+
15
+ - iOS: run on an iPhone 12 (iOS 27.2.1), a development build made on Linux: a picked day and its rows, a
16
+ swipe that turned the month, the week timeline and the agenda.
17
+ - Android: run on an API 35 emulator (x86_64) by hand: a picked day, the week, the agenda in dark, a swipe.
18
+ - Web: `bun exact.mjs verify`, 13 of 13 tests, `contract verify` 0 findings. The compiler now warns
19
+ `lower-list-beside-fixed` for the title bar over the timeline and month schedule (advice; see the README).
20
+ - Linux: 13 of 13 tests headless.
21
+ - macOS and Windows: not built, not run.
22
+ - The example's app.json accepts the edge-cut row findings of the web check, with the reason.
23
+ - README: screenshots from iPhone, Android, the web and Linux, and `bun add exact-scheduler`.
24
+
25
+ ### Fixed
26
+
27
+ - In a week or any timeline of two days or more, an event that shares its time with another kept breaking its title
28
+ between letters, so a narrow one stood one letter a line ("D", "e", "s", …). It now keeps its title to one line,
29
+ cut short. Its button's label still says the whole title, time and place.
30
+ - A title that reads the other way from the page (an English title in an Arabic week, or the reverse) lost its start
31
+ when cut short: "Standup" showed as "…tand". Chips and timeline events now draw a title in its own direction, at
32
+ the view's start side, so the start shows.
33
+
34
+ ### Added
35
+
36
+ - `SchedulerSegment.dir`: the title's own direction, `"ltr"`, `"rtl"`, or `""` for the view's, from its first strong
37
+ letter. `toSegments` fills it in. A segment an app writes by hand needs the field too (`""` keeps the view's).
38
+
39
+ ### Changed
40
+
41
+ - The example is built and tested against Exact `main` at `e2a98fb3`, and builds for iOS too (app.json now names the
42
+ iOS host). Its day rows show an event's title and time as two lines, so neither runs into the other right to left.
43
+ - With Exact `e2a98fb3`, all 13 example tests pass on the Linux host (the picker test whose last day is past ran on
44
+ the web only before) and all 13 on the Android emulator's headless host (the wide-window one included).
45
+
46
+ ## Before the first npm release (2026-11-24)
47
+
48
+ ### Added
49
+
50
+ - `MonthCalendar`: a month grid with marked dates (up to three dots), chosen days, a range band, today, week
51
+ numbers, neighbouring months' days, and a year of months behind its title.
52
+ - `DatePicker` and `DateRangePicker`, which turn their own pages. A range can be limited in length and never spans a
53
+ day the rules refuse.
54
+ - `MonthSchedule`: a month with events written in its days, for wide windows.
55
+ - `DayTimeline`, `WeekTimeline` and `Timeline` (any number of days from 1 to 7): hours, an all-day row, overlapping
56
+ events side by side, a line at the time now, and pressable free hours.
57
+ - `Agenda`: a virtualized list of days and their events that opens at a day you give.
58
+ - `SchedulerRules`: first and last day, disabled days and disabled weekdays, obeyed by every view.
59
+ - Arrows, swipes and the keyboard turn pages, mirrored right to left. Page motion stops under reduced motion.
60
+ - Date functions in Contract (`addDays`, `addMonths`, `startOfWeek`, `weekNumberOf`, `monthDays` and others) and
61
+ title functions (`monthTitle`, `dayTitle`, `dayShort`, `weekTitle`).
62
+ - `exact-scheduler/data` for `app.ts`: `schedulerNames` (month and weekday names, patterns, digits, hours and the
63
+ week's first day, from Intl), `toSegments` (events per day, with lanes), `toMarks`, `fromCalendarEvents` (for
64
+ `@exact/calendar`) and zone helpers, with types and unit tests.
65
+ - An example app (`example/`) with Contract tests.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 softwhere.uz
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 softwhere.uz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,288 @@
1
- # exact-scheduler
2
-
3
- Calendar and scheduler views (month, week, day, agenda) for [Expo Exact](https://github.com/expo/exact), on every platform Exact supports.
4
-
5
- This version is a placeholder. The first release is coming soon from softwhere.uz.
1
+ # exact-scheduler
2
+
3
+ Calendar and scheduler views for [Expo Exact](https://github.com/expo/exact), written in Contract alone, with no native code. Every Exact host draws them: Android, iOS, macOS, the web, Windows and Linux.
4
+
5
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
6
+
7
+ The package has:
8
+
9
+ - **Views:** `MonthCalendar`, `MonthSchedule`, `DayTimeline`, `WeekTimeline`, `Timeline`, `Agenda`.
10
+ - **Pickers:** `DatePicker`, `DateRangePicker`.
11
+ - **`exact-scheduler/data`**, for `app.ts`: locale names from Intl, and your events turned into what the views draw.
12
+
13
+ ## Features
14
+
15
+ - **Locale.** Month and weekday names, title patterns, the week's first day, the weekend, digits and hour labels are one `SchedulerNames` record. `schedulerNames(locale)` makes it with Intl, or you supply your own.
16
+ - **No words of its own.** Every label comes from your `SchedulerStrings`.
17
+ - **Rules.** First and last day, disabled days and disabled weekdays. The first and last day also stop the arrows, swipes and keys.
18
+ - **Navigation.** Arrows, a sideways swipe (from an event or a day too) and the keyboard. Your app holds the date shown and gets asked to change it.
19
+ - **Events.** Overlapping events share a column's width. Events over midnight are split by day. All-day events have their own row.
20
+ - **Accessibility.** The month is a `grid` with one Tab stop; every day is labelled with its full date, today, range ends, unavailability and your mark's words. Events are buttons labelled with title, time and place. Titles are headings or labelled buttons. Day and week hours move with the arrows. Text in fixed cells is capped so that it stays in its cell at the largest text sizes.
21
+ - **Motion.** A page slides in from the side it was asked from, and the year of months fades in. Both stop under reduced motion.
22
+ - **Light and dark** through platform colour roles; the accent is the platform's or your `app.forma`'s.
23
+ - **Right to left.** The layout, arrows, swipes and keys mirror (pass `rtl`). An event's title keeps its own direction, so an English title in an Arabic week still shows its start.
24
+
25
+ It is not a calendar store: it keeps no events. It pairs with `@exact/calendar` through `fromCalendarEvents`, and does not depend on it. Recurring events are yours to expand, one record each. Dragging an event to move or resize it is not in 0.1.0.
26
+
27
+ ## Platform support
28
+
29
+ What was run for 0.1.0, with the example on Exact `f7788c9e6` (`expo/exact` main, 2026-12-04):
30
+
31
+ | Platform | Status |
32
+ | --- | --- |
33
+ | iOS | **Run on an iPhone 12 (iOS 27.2.1)**, a development build made on Linux, driven through XCUITest: a day with events picked in the month (its rows listed under it), a swipe turned the month, the week timeline (with the phone's Monday week start) and the agenda. |
34
+ | Android | **Run on an API 35 emulator (x86_64)**, driven by hand through adb: a day picked, the week timeline with overlapping events side by side, the agenda in dark, and a real swipe that turned the month. Exact's own `test android` was not run: from WSL it could not drive this emulator, which runs on the Windows side. |
35
+ | Web | `bun exact.mjs verify`: the 13 Contract tests pass; light and dark at two widths, the accessibility tree, reload, the largest text size and `contract verify` (0 findings) are clean apart from the compiler warning below. Rows a scroller cuts at its edge are accepted in the example's app.json (`verify.accept`), with the reason. |
36
+ | Linux | The host builds and the 13 tests pass headless; the week was looked at in a screenshot. |
37
+ | macOS, Windows | Not built, not run. Nothing is specific to them. |
38
+
39
+ The package has no native code, so hosts that were not run draw the same Contract as those that were. That is an expectation, not a test.
40
+
41
+ **A compiler warning.** On `f7788c9e6`, `contract build` warns `lower-list-beside-fixed` for the title bar over the timeline and month schedule: on iOS a list stops at a bar holding text in a hard line, where a hand-built list scrolls under its bar. The bar (arrows and a title) stays put on purpose, as Calendar's does; the warning is advice and nothing fails.
42
+
43
+ | iPhone: a picked day | iPhone: the week | Android: the week | Android: the agenda, dark |
44
+ | --- | --- | --- | --- |
45
+ | <img src=\"docs/screenshots/ios-month.png\" width=\"200\"> | <img src=\"docs/screenshots/ios-week.png\" width=\"200\"> | <img src=\"docs/screenshots/android-week.png\" width=\"200\"> | <img src=\"docs/screenshots/android-agenda-dark.png\" width=\"200\"> |
46
+
47
+ | Web | Linux (headless) |
48
+ | --- | --- |
49
+ | <img src=\"docs/screenshots/web.png\" width=\"200\"> | <img src=\"docs/screenshots/linux-week.png\" width=\"200\"> |
50
+
51
+ **Locales without Intl data.** Exact's Android engine and its Linux development host still carried English data only at `e2a98fb3`: an Arabic example shows English month names there. `schedulerNames('ru').locale` then says `en`, which tells you to pass your own names: `schedulerNames('ru', { months: […], … })`.
52
+
53
+ ## Compatibility
54
+
55
+ | exact-scheduler | Exact |
56
+ | --- | --- |
57
+ | 0.1.x | `expo/exact` main at `f7788c9e6` (December 2026). Written on `82be4bdc`; the moves to `e2a98fb3` and `f7788c9e6` needed no change to the package. |
58
+
59
+ Exact has no releases yet, so the package names the commit it was tested on. A later `main` will probably work, but only `f7788c9e6` was tested for this release.
60
+
61
+ ## Installation
62
+
63
+ ```sh
64
+ bun add exact-scheduler
65
+ ```
66
+
67
+ ## Quick start
68
+
69
+ `app.ts`:
70
+
71
+ ```ts
72
+ import type { Answer, Result, Sources } from './app.contract.d.ts';
73
+ import { schedulerNames, toMarks, toSegments } from 'exact-scheduler/data';
74
+
75
+ export const grants = '';
76
+
77
+ const EVENTS = [
78
+ { id: '1', title: 'Standup', detail: 'Room 2', start: '2026-11-24T09:30', end: '2026-11-24T10:00' },
79
+ { id: '2', title: 'Trip', start: '2026-11-26', end: '2026-11-29', tint: '-exact-system-teal' },
80
+ ];
81
+
82
+ const sources: Sources = {
83
+ names: ([locale]): Result<'names'> => schedulerNames(locale),
84
+ events: ([locale, timeZone, allDay]): Result<'events'> => {
85
+ const segments = toSegments(EVENTS, { locale, timeZone, allDay });
86
+ return { segments, marks: toMarks(segments) };
87
+ },
88
+ };
89
+ export const answer: Answer = (source, args, store, storage, native) => sources[source](args, store, storage, native);
90
+ ```
91
+
92
+ `app.contract`:
93
+
94
+ ```contract
95
+ use MonthCalendar, SchedulerSegment, SchedulerMark, SchedulerNames, SchedulerStrings, SchedulerRange, anyDay from "exact-scheduler"
96
+
97
+ shape Time
98
+ epochAtZero: number
99
+ utcOffset: number
100
+ formatLocale: string
101
+ timeZone: string
102
+ shape Events
103
+ segments: SchedulerSegment[]
104
+ marks: SchedulerMark[]
105
+
106
+ component App
107
+ resource time = exactTime() as shape Time
108
+ resource names = names(time.formatLocale) as shape SchedulerNames
109
+ resource events = events(time.formatLocale, time.timeZone, t("allDay")) as shape Events
110
+ state day = ""
111
+ state month = ""
112
+ derive today = formatDate(time.epochAtZero, time.utcOffset, "iso")
113
+ derive strings = SchedulerStrings(previousMonth=t("previousMonth"), nextMonth=t("nextMonth"), previousYear=t("previousYear"), nextYear=t("nextYear"), previousWeek=t("previousWeek"), nextWeek=t("nextWeek"), previousDay=t("previousDay"), nextDay=t("nextDay"), chooseMonth=t("chooseMonth"), today=t("today"), allDay=t("allDay"), week=t("week"), more="+{count}", noEvents=t("noEvents"), now=t("now"), rangeStart=t("rangeStart"), rangeEnd=t("rangeEnd"), unavailable=t("unavailable"), loading=t("loading"))
114
+ action pick(d: string)
115
+ day = d
116
+ action show(d: string)
117
+ month = d
118
+ view
119
+ main padding=16
120
+ if current(names)
121
+ MonthCalendar(id="cal", month=(month == "" ? today : month), today=today, selected=[day], range=SchedulerRange(start="", end=""), marks=events.marks, rules=anyDay(), names=names, strings=strings, label=t("calendar"), weekNumbers=false, outsideDays=true, rtl=false, pick=pick, turnTo=show)
122
+ ```
123
+
124
+ Show the views once the names have arrived (`current(names)`). `example/strings/en.json` holds every word, and `example/strings/ar.json` an Arabic table.
125
+
126
+ ## Days and times
127
+
128
+ A day is a text key, `"2026-11-24"`, in your app's own zone; keys compare in date order. A time of day is minutes since that day's midnight on the wall clock.
129
+
130
+ ## Views
131
+
132
+ Every prop is required (Contract has no default props). These are shared:
133
+
134
+ | Prop | Type | What it is |
135
+ | --- | --- | --- |
136
+ | `id` | `string` | The prefix of every `testId` and element id inside. Unique on the screen. |
137
+ | `today` | `string` | Today's key. |
138
+ | `names` | `SchedulerNames` | The locale's names. |
139
+ | `strings` | `SchedulerStrings` | Your words. |
140
+ | `rules` | `SchedulerRules` | Which days may be chosen; `anyDay()` for all. |
141
+ | `label` | `string` | What a screen reader calls the calendar. |
142
+ | `rtl` | `bool` | Your app lays out right to left: swaps Left and Right, swipes and lanes. |
143
+ | `turnTo` | `action` | Hears the day (a key) of the page the person asked for. Store it and pass it back. |
144
+
145
+ ### `MonthCalendar`
146
+
147
+ ```contract
148
+ MonthCalendar(id, month, today, selected, range, marks, rules, names, strings, label, weekNumbers, outsideDays, rtl, pick, turnTo)
149
+ ```
150
+
151
+ | Prop | Type | What it is |
152
+ | --- | --- | --- |
153
+ | `month` | `string` | Any day of the month shown. |
154
+ | `selected` | `string[]` | Chosen days; several for a multiple choice. |
155
+ | `range` | `SchedulerRange` | A band from `start` to `end`; both `""` for none. |
156
+ | `marks` | `SchedulerMark[]` | Dots under days. |
157
+ | `weekNumbers` | `bool` | ISO week numbers at the start of each row. |
158
+ | `outsideDays` | `bool` | Shows the neighbouring months' days. Pressing one turns the page as well. |
159
+ | `pick` | `action` | Hears the day pressed. Never a day the rules refuse. |
160
+ | `turnTo` | `action` | Hears the first day of the month asked for. |
161
+
162
+ Pressing the title opens a year of months. Keyboard: arrows by day and week, Home and End to the week's ends, Page Up and Page Down by month, Enter or Space presses.
163
+
164
+ ### `DatePicker`, `DateRangePicker`
165
+
166
+ ```contract
167
+ DatePicker(id, value, today, marks, rules, names, strings, label, rtl, change)
168
+ DateRangePicker(id, value, today, marks, rules, maxDays, names, strings, label, rtl, change)
169
+ ```
170
+
171
+ | Prop | Type | What it is |
172
+ | --- | --- | --- |
173
+ | `value` | `string`, or `SchedulerRange` | The chosen day (`""` for none), or the range. They open on its month, else on today's (or the limit nearest to it). |
174
+ | `marks` | `SchedulerMark[]` | Dots under days. |
175
+ | `maxDays` | `number` | The longest range in days, both ends counted; 0 for no limit. |
176
+ | `change` | `action` | `DatePicker`: hears the day. `DateRangePicker`: hears a `SchedulerRange` at each press, first with `end` `""`, then with both. |
177
+
178
+ They remember the page they show. A press before the start, on the far side of a day the rules refuse, or past `maxDays` starts the range again. To put one in a sheet, place it in your route or `dialog`.
179
+
180
+ ### `MonthSchedule`
181
+
182
+ ```contract
183
+ MonthSchedule(id, month, today, segments, rules, names, strings, label, maxEvents, rtl, pick, pressEvent, turnTo)
184
+ ```
185
+
186
+ | Prop | Type | What it is |
187
+ | --- | --- | --- |
188
+ | `segments` | `SchedulerSegment[]` | From `toSegments`. |
189
+ | `maxEvents` | `number` | Events shown per day before "+n". |
190
+ | `pick` | `action` | Hears the day whose number or "+n" was pressed. Rules limit its arrows, not this press. |
191
+ | `pressEvent` | `action` | Hears the event's `id`. |
192
+
193
+ For windows about 800 points and wider. On a phone use a `MonthCalendar` with dots.
194
+
195
+ ### `DayTimeline`, `WeekTimeline`, `Timeline`
196
+
197
+ ```contract
198
+ DayTimeline(id, day, today, nowMinute, segments, rules, names, strings, label, hourHeight, openHour, slots, rtl, pressEvent, pressSlot, pickDay, turnTo)
199
+ WeekTimeline(… the same …)
200
+ Timeline(id, from, days, today, nowMinute, … the rest as above …)
201
+ ```
202
+
203
+ | Prop | Type | What it is |
204
+ | --- | --- | --- |
205
+ | `day` | `string` | The day, or any day of the week (shown from `names.firstDay`). |
206
+ | `from`, `days` | `string`, `number` | `Timeline`: the first day and how many, 1 to 7 (3 suits a phone). |
207
+ | `nowMinute` | `number` | Minutes since midnight of the line across today; -1 for none. Tick it from your app. |
208
+ | `segments` | `SchedulerSegment[]` | From `toSegments`. |
209
+ | `hourHeight` | `number` | Points an hour takes; 48 or more. |
210
+ | `openHour` | `number` | The hour at the top when it opens. |
211
+ | `slots` | `bool` | Makes each hour no event touches a button. |
212
+ | `pressEvent` | `action` | Hears the event's `id`. |
213
+ | `pressSlot` | `action` | Hears the day and the minute (`hour * 60`). Not for a day the rules refuse. |
214
+ | `pickDay` | `action` | Hears the day whose heading was pressed (two days or more). |
215
+ | `turnTo` | `action` | Hears the new first day. |
216
+
217
+ They fill the height they are given (`flex=1`), and scroll inside it. An event shorter than 24 points is drawn 24 points tall. With two days or more, an event that shares its time with another shows its title on one line, cut short; its button's label still says the whole title, time and place. With `days` between 2 and 6, the arrows are labelled `previousWeek` and `nextWeek`: give them words that fit.
218
+
219
+ ### `Agenda`
220
+
221
+ ```contract
222
+ Agenda(id, segments, from, today, names, strings, label, loading, pressEvent)
223
+ ```
224
+
225
+ | Prop | Type | What it is |
226
+ | --- | --- | --- |
227
+ | `from` | `string` | The day it opens at, or the first after it with events. Changing it scrolls there. |
228
+ | `loading` | `bool` | Shows `strings.loading` and a spinner. |
229
+ | `pressEvent` | `action` | Hears the event's `id`. |
230
+
231
+ It is a virtualized list that fills the height it is given. Its list's id is always `scheduler-agenda`, because a virtualized scroll target must be a literal id: one agenda on a screen.
232
+
233
+ ## Records
234
+
235
+ | Shape | Fields |
236
+ | --- | --- |
237
+ | `SchedulerSegment` | One event on one day: `key` (`id@day`), `id`, `day`, `title`, `dir` (the title's own direction, `"ltr"`, `"rtl"`, or `""` for the view's: a title cut short keeps its start in a page written the other way), `detail`, `tint` (a colour, `""` the accent), `allDay`, `startMinute`, `endMinute`, `lane`, `lanes`, `order` (its place in the day, from 0), `before` and `after` (it goes on from or into another day), `time` |
238
+ | `SchedulerMark` | `day`, `tints` (a dot each), `label` (heard after the date) |
239
+ | `SchedulerRules` | `minDay`, `maxDay` (`""` for none), `disabledDays`, `disabledWeekdays` (0 Sunday) |
240
+ | `SchedulerRange` | `start`, `end` (both in it; `""` not chosen) |
241
+ | `SchedulerNames` | `locale`, `months`, `monthsShort`, `monthsInDate` (as written beside a day: "24 ноября"), `weekdays`, `weekdaysShort`, `weekdaysNarrow` (from Sunday), `firstDay`, `weekend` (0 Sunday), `digits` (ten characters), `hours` (24 labels), `monthTitle`, `dayTitle`, `dayShort` (patterns of `{month}`, `{year}`, `{weekday}`, `{day}`, `{monthInDate}`, `{monthShort}`, `{monthNumber}`) |
242
+ | `SchedulerStrings` | `previousMonth`, `nextMonth`, `previousYear`, `nextYear`, `previousWeek`, `nextWeek`, `previousDay`, `nextDay`, `chooseMonth`, `today`, `allDay`, `week`, `more` (holds `{count}`), `noEvents`, `now`, `rangeStart`, `rangeEnd`, `unavailable`, `loading` |
243
+
244
+ ## Contract functions
245
+
246
+ | Function | Returns |
247
+ | --- | --- |
248
+ | `addDays(day, n)`, `addMonths(day, n)` | a day; `addMonths` keeps the date or takes the month's last day |
249
+ | `dayNumber(day)`, `dayKeyOf(n)` | days since 1970-01-01, and back |
250
+ | `monthOf(day)`, `yearOf(day)`, `monthIndexOf(day)`, `dateOf(day)` | `"2026-11"`, the year, the month from 0, the date |
251
+ | `weekdayOf(day)`, `startOfWeek(day, firstDay)`, `weekNumberOf(day)` | 0 Sunday; the week's first day; the ISO week |
252
+ | `daysInMonth(day)`, `monthDays(month, firstDay)` | a count; the grid's days in whole weeks |
253
+ | `anyDay()`, `dayAllowed(rules, day)`, `monthAllowed(rules, month)` | rules, and what they say |
254
+ | `nextRange(range, day, rules, maxDays)`, `inRange(range, day)` | the range after a press; whether a day is in it |
255
+ | `monthTitle`, `dayTitle`, `dayShort` `(names, day)`, `weekTitle(names, from, days)` | titles |
256
+ | `dayWords(names, day, extras)`, `localDigits(digits, n)` | a spoken day; a number in the locale's digits |
257
+
258
+ ## `exact-scheduler/data`
259
+
260
+ Pure functions with no clock, network or storage. Types are in `data/index.d.ts`.
261
+
262
+ | Export | What it is |
263
+ | --- | --- |
264
+ | `schedulerNames(locale, overrides?)` | `SchedulerNames` from the engine's Intl. `overrides` replaces any field, and takes `hour12`. Pass Exact's `exactTime().formatLocale` to follow the device's hour cycle. |
265
+ | `toSegments(records, options?)` | Your events as segments, sorted, with lanes. A record is `{ id, title, start, end?, allDay?, detail?, tint? }`; `start` and `end` are milliseconds, `"YYYY-MM-DD"` or `"YYYY-MM-DDTHH:MM"` (local). `end` is exclusive, as in iCalendar; left out, it is a whole day or 30 minutes. Options: `timeZone` or `utcOffset` (for milliseconds), `from` and `to` (days kept), `locale`, `hour12`, `allDay` (the words), `minMinutes` (30). A wrong record throws, naming it. |
266
+ | `toMarks(segments, { max?, label? })` | Marks: one dot per tint, up to `max` (3), and `label(count, day)`. |
267
+ | `fromCalendarEvents(events, { tint? })` | `@exact/calendar` events as records; cancelled ones left out. |
268
+ | `weekInfo(locale)` | `{ firstDay, weekend }`, from Intl or CLDR's table. |
269
+ | `localDay(ms, zone?)`, `localMinute(ms, zone?)`, `addDays(day, n)` | day and minute in a zone; a day moved |
270
+
271
+ ## Test ids
272
+
273
+ With `id="cal"`: `cal`, `cal-bar`, `cal-previous`, `cal-title`, `cal-next`; months `cal-grid`, `cal-day-<day>`, `cal-months`, `cal-month-<1…12>`; schedules `cal-cell-<day>`, `cal-event-<key>`, `cal-more-<day>`; timelines `cal-head-<day>`, `cal-all-day`, `cal-scroll`, `cal-hours`, `cal-column-<day>`, `cal-event-<key>`, `cal-slot-<day>-<hour>`, `cal-now`; agendas `cal-list`, `cal-title-<day>`, `cal-event-<key>`, `cal-empty`, `cal-loading`.
274
+
275
+ ## Example
276
+
277
+ ```sh
278
+ cd example
279
+ bun tools/pack-package.mjs # after every edit to the package
280
+ bun exact.mjs verify # tests, light and dark, two widths, accessibility, reload, large text
281
+ bun exact.mjs web # a live URL
282
+ ```
283
+
284
+ `bun test test/` in the package's root runs the data helpers' tests.
285
+
286
+ ## License
287
+
288
+ MIT, © softwhere.uz. See [LICENSE](./LICENSE).
@@ -0,0 +1,70 @@
1
+ // Types for exact-scheduler/data. See index.js for each function's contract.
2
+
3
+ /** Milliseconds since the epoch, a local "YYYY-MM-DD", or a local "YYYY-MM-DDTHH:MM[:SS]". */
4
+ export type SchedulerInstant = number | string;
5
+
6
+ export interface SchedulerRecord {
7
+ id: string;
8
+ title: string;
9
+ start: SchedulerInstant;
10
+ /** Exclusive. Left out: a whole day when all-day, else 30 minutes. */
11
+ end?: SchedulerInstant;
12
+ allDay?: boolean;
13
+ detail?: string;
14
+ /** A Contract colour; "" is the accent. */
15
+ tint?: string;
16
+ }
17
+
18
+ export interface SchedulerSegment {
19
+ key: string; id: string; day: string; title: string;
20
+ /** The title's own direction, from its first strong letter: "ltr", "rtl", or "" when it has no letter. */
21
+ dir: '' | 'ltr' | 'rtl';
22
+ detail: string; tint: string;
23
+ allDay: boolean; startMinute: number; endMinute: number; lane: number; lanes: number;
24
+ order: number; before: boolean; after: boolean; time: string;
25
+ }
26
+
27
+ export interface SchedulerMark { day: string; tints: string[]; label: string }
28
+
29
+ export interface SchedulerNames {
30
+ locale: string;
31
+ months: string[]; monthsShort: string[]; monthsInDate: string[];
32
+ weekdays: string[]; weekdaysShort: string[]; weekdaysNarrow: string[];
33
+ firstDay: number; weekend: number[]; digits: string; hours: string[];
34
+ monthTitle: string; dayTitle: string; dayShort: string;
35
+ }
36
+
37
+ export interface ZoneOptions {
38
+ /** IANA zone; wins over utcOffset. */
39
+ timeZone?: string;
40
+ /** Minutes east of UTC. */
41
+ utcOffset?: number;
42
+ }
43
+
44
+ export interface SegmentOptions extends ZoneOptions {
45
+ /** First and last day kept, inclusive. */
46
+ from?: string;
47
+ to?: string;
48
+ locale?: string;
49
+ hour12?: boolean;
50
+ /** The words for an all-day event's time. */
51
+ allDay?: string;
52
+ /** The least minutes an event takes when lanes are laid out (default 30). */
53
+ minMinutes?: number;
54
+ }
55
+
56
+ /** The fields of @exact/calendar's CalendarEvent that are read. */
57
+ export interface CalendarEventLike {
58
+ id?: string | null; uid?: string | null; title: string; start: string; duration: string;
59
+ showWithoutTime: boolean; location?: string | null; status?: string | null; recurrenceId?: string | null;
60
+ utcStart?: number | null; utcEnd?: number | null; timeZone?: string | null;
61
+ }
62
+
63
+ export declare function schedulerNames(locale: string, overrides?: Partial<SchedulerNames> & { hour12?: boolean }): SchedulerNames;
64
+ export declare function weekInfo(locale: string): { firstDay: number; weekend: number[] };
65
+ export declare function toSegments(records: SchedulerRecord[], options?: SegmentOptions): SchedulerSegment[];
66
+ export declare function toMarks(segments: SchedulerSegment[], options?: { max?: number; label?: (count: number, day: string) => string }): SchedulerMark[];
67
+ export declare function fromCalendarEvents(events: CalendarEventLike[], options?: { tint?: string }): SchedulerRecord[];
68
+ export declare function localDay(at: number, zone?: ZoneOptions): string;
69
+ export declare function localMinute(at: number, zone?: ZoneOptions): number;
70
+ export declare function addDays(day: string, n: number): string;