foldkit 0.60.0 → 0.61.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.
Files changed (38) hide show
  1. package/dist/calendar/arithmetic.d.ts +140 -0
  2. package/dist/calendar/arithmetic.d.ts.map +1 -0
  3. package/dist/calendar/arithmetic.js +169 -0
  4. package/dist/calendar/calendarDate.d.ts +162 -0
  5. package/dist/calendar/calendarDate.d.ts.map +1 -0
  6. package/dist/calendar/calendarDate.js +196 -0
  7. package/dist/calendar/comparison.d.ts +163 -0
  8. package/dist/calendar/comparison.d.ts.map +1 -0
  9. package/dist/calendar/comparison.js +134 -0
  10. package/dist/calendar/index.d.ts +7 -0
  11. package/dist/calendar/index.d.ts.map +1 -0
  12. package/dist/calendar/index.js +6 -0
  13. package/dist/calendar/info.d.ts +76 -0
  14. package/dist/calendar/info.d.ts.map +1 -0
  15. package/dist/calendar/info.js +125 -0
  16. package/dist/calendar/locale.d.ts +71 -0
  17. package/dist/calendar/locale.d.ts.map +1 -0
  18. package/dist/calendar/locale.js +171 -0
  19. package/dist/calendar/public.d.ts +2 -0
  20. package/dist/calendar/public.d.ts.map +1 -0
  21. package/dist/calendar/public.js +1 -0
  22. package/dist/calendar/today.d.ts +41 -0
  23. package/dist/calendar/today.d.ts.map +1 -0
  24. package/dist/calendar/today.js +33 -0
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +1 -0
  28. package/dist/ui/calendar/index.d.ts +242 -0
  29. package/dist/ui/calendar/index.d.ts.map +1 -0
  30. package/dist/ui/calendar/index.js +515 -0
  31. package/dist/ui/calendar/public.d.ts +3 -0
  32. package/dist/ui/calendar/public.d.ts.map +1 -0
  33. package/dist/ui/calendar/public.js +1 -0
  34. package/dist/ui/dragAndDrop/index.d.ts +1 -1
  35. package/dist/ui/index.d.ts +1 -0
  36. package/dist/ui/index.d.ts.map +1 -1
  37. package/dist/ui/index.js +1 -0
  38. package/package.json +9 -1
@@ -0,0 +1,171 @@
1
+ import { Function, Schema as S } from 'effect';
2
+ import { DayOfWeek, dayOfWeek } from './info';
3
+ const twelveStrings = S.Tuple(S.String, S.String, S.String, S.String, S.String, S.String, S.String, S.String, S.String, S.String, S.String, S.String);
4
+ const sevenStrings = S.Tuple(S.String, S.String, S.String, S.String, S.String, S.String, S.String);
5
+ /**
6
+ * Locale configuration for rendering calendar dates. Contains only data —
7
+ * month/day names and the first day of the week. Formatting functions
8
+ * (`formatLong`, `formatShort`, `formatAriaLabel`) are separate exports that
9
+ * take a `LocaleConfig` as input.
10
+ *
11
+ * Day names are always stored Sunday-first in the config; `firstDayOfWeek`
12
+ * controls how the view rotates them at render time.
13
+ */
14
+ export const LocaleConfig = S.Struct({
15
+ firstDayOfWeek: DayOfWeek,
16
+ monthNames: twelveStrings,
17
+ shortMonthNames: twelveStrings,
18
+ dayNames: sevenStrings,
19
+ shortDayNames: sevenStrings,
20
+ });
21
+ /**
22
+ * Default English (United States) locale. Picker components default to this
23
+ * when no locale is passed via ViewConfig. Consumers who want a different
24
+ * locale pass their own `LocaleConfig`.
25
+ */
26
+ export const defaultEnglishLocale = {
27
+ firstDayOfWeek: 'Sunday',
28
+ monthNames: [
29
+ 'January',
30
+ 'February',
31
+ 'March',
32
+ 'April',
33
+ 'May',
34
+ 'June',
35
+ 'July',
36
+ 'August',
37
+ 'September',
38
+ 'October',
39
+ 'November',
40
+ 'December',
41
+ ],
42
+ shortMonthNames: [
43
+ 'Jan',
44
+ 'Feb',
45
+ 'Mar',
46
+ 'Apr',
47
+ 'May',
48
+ 'Jun',
49
+ 'Jul',
50
+ 'Aug',
51
+ 'Sep',
52
+ 'Oct',
53
+ 'Nov',
54
+ 'Dec',
55
+ ],
56
+ dayNames: [
57
+ 'Sunday',
58
+ 'Monday',
59
+ 'Tuesday',
60
+ 'Wednesday',
61
+ 'Thursday',
62
+ 'Friday',
63
+ 'Saturday',
64
+ ],
65
+ shortDayNames: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
66
+ };
67
+ const pickMonthName = (locale, month) => {
68
+ if (month === 1)
69
+ return locale.monthNames[0];
70
+ if (month === 2)
71
+ return locale.monthNames[1];
72
+ if (month === 3)
73
+ return locale.monthNames[2];
74
+ if (month === 4)
75
+ return locale.monthNames[3];
76
+ if (month === 5)
77
+ return locale.monthNames[4];
78
+ if (month === 6)
79
+ return locale.monthNames[5];
80
+ if (month === 7)
81
+ return locale.monthNames[6];
82
+ if (month === 8)
83
+ return locale.monthNames[7];
84
+ if (month === 9)
85
+ return locale.monthNames[8];
86
+ if (month === 10)
87
+ return locale.monthNames[9];
88
+ if (month === 11)
89
+ return locale.monthNames[10];
90
+ return locale.monthNames[11];
91
+ };
92
+ const pickShortMonthName = (locale, month) => {
93
+ if (month === 1)
94
+ return locale.shortMonthNames[0];
95
+ if (month === 2)
96
+ return locale.shortMonthNames[1];
97
+ if (month === 3)
98
+ return locale.shortMonthNames[2];
99
+ if (month === 4)
100
+ return locale.shortMonthNames[3];
101
+ if (month === 5)
102
+ return locale.shortMonthNames[4];
103
+ if (month === 6)
104
+ return locale.shortMonthNames[5];
105
+ if (month === 7)
106
+ return locale.shortMonthNames[6];
107
+ if (month === 8)
108
+ return locale.shortMonthNames[7];
109
+ if (month === 9)
110
+ return locale.shortMonthNames[8];
111
+ if (month === 10)
112
+ return locale.shortMonthNames[9];
113
+ if (month === 11)
114
+ return locale.shortMonthNames[10];
115
+ return locale.shortMonthNames[11];
116
+ };
117
+ const pickDayName = (locale, day) => {
118
+ if (day === 'Sunday')
119
+ return locale.dayNames[0];
120
+ if (day === 'Monday')
121
+ return locale.dayNames[1];
122
+ if (day === 'Tuesday')
123
+ return locale.dayNames[2];
124
+ if (day === 'Wednesday')
125
+ return locale.dayNames[3];
126
+ if (day === 'Thursday')
127
+ return locale.dayNames[4];
128
+ if (day === 'Friday')
129
+ return locale.dayNames[5];
130
+ return locale.dayNames[6];
131
+ };
132
+ /**
133
+ * Renders a calendar date in long form. Example: `"January 15, 2026"`.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * import { Calendar } from 'foldkit'
138
+ * import { pipe } from 'effect'
139
+ *
140
+ * Calendar.formatLong(Calendar.make(2026, 1, 15), Calendar.defaultEnglishLocale)
141
+ * // "January 15, 2026"
142
+ *
143
+ * pipe(
144
+ * Calendar.make(2026, 1, 15),
145
+ * Calendar.formatLong(Calendar.defaultEnglishLocale),
146
+ * )
147
+ * // "January 15, 2026"
148
+ * ```
149
+ */
150
+ export const formatLong = Function.dual(2, (self, locale) => `${pickMonthName(locale, self.month)} ${self.day}, ${self.year}`);
151
+ /**
152
+ * Renders a calendar date in short form. Example: `"Jan 15, 2026"`.
153
+ */
154
+ export const formatShort = Function.dual(2, (self, locale) => `${pickShortMonthName(locale, self.month)} ${self.day}, ${self.year}`);
155
+ /**
156
+ * Renders an accessibility label for a calendar date, suitable for
157
+ * `aria-label` on a grid cell. Example: `"Monday, January 15, 2026"`.
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * import { Calendar } from 'foldkit'
162
+ *
163
+ * Calendar.formatAriaLabel(Calendar.make(2026, 1, 15), Calendar.defaultEnglishLocale)
164
+ * // "Thursday, January 15, 2026"
165
+ * ```
166
+ */
167
+ export const formatAriaLabel = Function.dual(2, (self, locale) => {
168
+ const dayName = pickDayName(locale, dayOfWeek(self));
169
+ const monthName = pickMonthName(locale, self.month);
170
+ return `${dayName}, ${monthName} ${self.day}, ${self.year}`;
171
+ });
@@ -0,0 +1,2 @@
1
+ export { addDays, addMonths, addYears, between, CalendarDate, CalendarDateFromIsoString, clamp, DayOfWeek, dayOfWeek, daysInMonth, daysSince, daysUntil, defaultEnglishLocale, endOfWeek, Equivalence, firstOfMonth, formatAriaLabel, formatLong, formatShort, fromDateInZone, fromDateLocal, isAfter, isAfterOrEqual, isBefore, isBeforeOrEqual, isCalendarDate, isEqual, isLeapYear, lastOfMonth, LocaleConfig, make, max, min, Order, startOfWeek, subtractDays, subtractMonths, subtractYears, toDateLocal, today, } from './index';
2
+ //# sourceMappingURL=public.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/calendar/public.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,SAAS,EACT,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,yBAAyB,EACzB,KAAK,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,oBAAoB,EACpB,SAAS,EACT,WAAW,EACX,YAAY,EACZ,eAAe,EACf,UAAU,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,OAAO,EACP,cAAc,EACd,QAAQ,EACR,eAAe,EACf,cAAc,EACd,OAAO,EACP,UAAU,EACV,WAAW,EACX,YAAY,EACZ,IAAI,EACJ,GAAG,EACH,GAAG,EACH,KAAK,EACL,WAAW,EACX,YAAY,EACZ,cAAc,EACd,aAAa,EACb,WAAW,EACX,KAAK,GACN,MAAM,SAAS,CAAA"}
@@ -0,0 +1 @@
1
+ export { addDays, addMonths, addYears, between, CalendarDate, CalendarDateFromIsoString, clamp, DayOfWeek, dayOfWeek, daysInMonth, daysSince, daysUntil, defaultEnglishLocale, endOfWeek, Equivalence, firstOfMonth, formatAriaLabel, formatLong, formatShort, fromDateInZone, fromDateLocal, isAfter, isAfterOrEqual, isBefore, isBeforeOrEqual, isCalendarDate, isEqual, isLeapYear, lastOfMonth, LocaleConfig, make, max, min, Order, startOfWeek, subtractDays, subtractMonths, subtractYears, toDateLocal, today, } from './index';
@@ -0,0 +1,41 @@
1
+ import { Effect } from 'effect';
2
+ /**
3
+ * Effect-based accessors for the current calendar date. Uses Effect's `Clock`
4
+ * service under the hood, so tests can freeze time with `TestClock` and
5
+ * production uses the real system clock.
6
+ *
7
+ * This is the **only** impurity boundary in the calendar module — every
8
+ * other function in this module is referentially transparent.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { Calendar } from 'foldkit'
13
+ * import { Effect } from 'effect'
14
+ *
15
+ * const program = Effect.gen(function* () {
16
+ * const today = yield* Calendar.today.local
17
+ * const nycToday = yield* Calendar.today.inZone('America/New_York')
18
+ * return { today, nycToday }
19
+ * })
20
+ * ```
21
+ */
22
+ export declare const today: {
23
+ /**
24
+ * The current calendar date in the browser's local timezone.
25
+ */
26
+ local: Effect.Effect<{
27
+ readonly year: number;
28
+ readonly month: number;
29
+ readonly day: number;
30
+ }, never, never>;
31
+ /**
32
+ * The current calendar date in a specific IANA timezone
33
+ * (e.g. `"America/New_York"`, `"Europe/London"`, `"Asia/Tokyo"`).
34
+ */
35
+ inZone: (timeZone: string) => Effect.Effect<{
36
+ readonly year: number;
37
+ readonly month: number;
38
+ readonly day: number;
39
+ }, never, never>;
40
+ };
41
+ //# sourceMappingURL=today.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"today.d.ts","sourceRoot":"","sources":["../../src/calendar/today.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAA;AAQtC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,KAAK;IAChB;;OAEG;;;;;;IAMH;;;OAGG;uBACgB,MAAM;;;;;CAK1B,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { Clock, Effect } from 'effect';
2
+ import { fromDateInZone, fromDateLocal, } from './calendarDate';
3
+ /**
4
+ * Effect-based accessors for the current calendar date. Uses Effect's `Clock`
5
+ * service under the hood, so tests can freeze time with `TestClock` and
6
+ * production uses the real system clock.
7
+ *
8
+ * This is the **only** impurity boundary in the calendar module — every
9
+ * other function in this module is referentially transparent.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { Calendar } from 'foldkit'
14
+ * import { Effect } from 'effect'
15
+ *
16
+ * const program = Effect.gen(function* () {
17
+ * const today = yield* Calendar.today.local
18
+ * const nycToday = yield* Calendar.today.inZone('America/New_York')
19
+ * return { today, nycToday }
20
+ * })
21
+ * ```
22
+ */
23
+ export const today = {
24
+ /**
25
+ * The current calendar date in the browser's local timezone.
26
+ */
27
+ local: Effect.map(Clock.currentTimeMillis, (millis) => fromDateLocal(new Date(millis))),
28
+ /**
29
+ * The current calendar date in a specific IANA timezone
30
+ * (e.g. `"America/New_York"`, `"Europe/London"`, `"Asia/Tokyo"`).
31
+ */
32
+ inZone: (timeZone) => Effect.map(Clock.currentTimeMillis, (millis) => fromDateInZone(new Date(millis), timeZone)),
33
+ };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * as Calendar from './calendar/public';
1
2
  export * as Command from './command/public';
2
3
  export * as ManagedResource from './managedResource/public';
3
4
  export * as FieldValidation from './fieldValidation/public';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,eAAe,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,eAAe,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,EAAE,MAAM,MAAM,CAAA;AAC1B,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,eAAe,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,eAAe,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,IAAI,MAAM,eAAe,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,EAAE,MAAM,MAAM,CAAA;AAC1B,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * as Calendar from './calendar/public';
1
2
  export * as Command from './command/public';
2
3
  export * as ManagedResource from './managedResource/public';
3
4
  export * as FieldValidation from './fieldValidation/public';
@@ -0,0 +1,242 @@
1
+ import { Option, Schema as S } from 'effect';
2
+ import * as Calendar from '../../calendar';
3
+ import type { CalendarDate } from '../../calendar';
4
+ import * as Command from '../../command';
5
+ import { type Attribute, type Html } from '../../html';
6
+ /** Schema for the calendar component's state. Tracks the visible month/year,
7
+ * the keyboard-focused and user-selected dates, and the configuration that
8
+ * governs navigation (locale, min/max, disabled days). */
9
+ export declare const Model: S.Struct<{
10
+ id: typeof S.String;
11
+ today: S.filter<S.Struct<{
12
+ year: typeof S.Int;
13
+ month: S.filter<typeof S.Int>;
14
+ day: S.filter<typeof S.Int>;
15
+ }>>;
16
+ viewYear: typeof S.Int;
17
+ viewMonth: S.filter<typeof S.Int>;
18
+ maybeFocusedDate: S.OptionFromSelf<S.filter<S.Struct<{
19
+ year: typeof S.Int;
20
+ month: S.filter<typeof S.Int>;
21
+ day: S.filter<typeof S.Int>;
22
+ }>>>;
23
+ maybeSelectedDate: S.OptionFromSelf<S.filter<S.Struct<{
24
+ year: typeof S.Int;
25
+ month: S.filter<typeof S.Int>;
26
+ day: S.filter<typeof S.Int>;
27
+ }>>>;
28
+ isGridFocused: typeof S.Boolean;
29
+ locale: S.Struct<{
30
+ firstDayOfWeek: S.Literal<["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]>;
31
+ monthNames: S.Tuple<[typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String]>;
32
+ shortMonthNames: S.Tuple<[typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String]>;
33
+ dayNames: S.Tuple<[typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String]>;
34
+ shortDayNames: S.Tuple<[typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String]>;
35
+ }>;
36
+ maybeMinDate: S.OptionFromSelf<S.filter<S.Struct<{
37
+ year: typeof S.Int;
38
+ month: S.filter<typeof S.Int>;
39
+ day: S.filter<typeof S.Int>;
40
+ }>>>;
41
+ maybeMaxDate: S.OptionFromSelf<S.filter<S.Struct<{
42
+ year: typeof S.Int;
43
+ month: S.filter<typeof S.Int>;
44
+ day: S.filter<typeof S.Int>;
45
+ }>>>;
46
+ disabledDaysOfWeek: S.Array$<S.Literal<["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]>>;
47
+ disabledDates: S.Array$<S.filter<S.Struct<{
48
+ year: typeof S.Int;
49
+ month: S.filter<typeof S.Int>;
50
+ day: S.filter<typeof S.Int>;
51
+ }>>>;
52
+ }>;
53
+ export type Model = typeof Model.Type;
54
+ /** Sent when the user clicks a day cell in the grid. */
55
+ export declare const ClickedDay: import("../../schema").CallableTaggedStruct<"ClickedDay", {
56
+ date: S.filter<S.Struct<{
57
+ year: typeof S.Int;
58
+ month: S.filter<typeof S.Int>;
59
+ day: S.filter<typeof S.Int>;
60
+ }>>;
61
+ }>;
62
+ /** Sent when the user presses a key on the grid container. The update maps
63
+ * the key to a navigation or selection action. */
64
+ export declare const PressedKeyOnGrid: import("../../schema").CallableTaggedStruct<"PressedKeyOnGrid", {
65
+ key: typeof S.String;
66
+ isShift: typeof S.Boolean;
67
+ }>;
68
+ /** Sent when the user clicks the previous-month navigation button. */
69
+ export declare const ClickedPreviousMonthButton: import("../../schema").CallableTaggedStruct<"ClickedPreviousMonthButton", {}>;
70
+ /** Sent when the user clicks the next-month navigation button. */
71
+ export declare const ClickedNextMonthButton: import("../../schema").CallableTaggedStruct<"ClickedNextMonthButton", {}>;
72
+ /** Sent when the user picks a month from the month dropdown. */
73
+ export declare const SelectedMonthFromDropdown: import("../../schema").CallableTaggedStruct<"SelectedMonthFromDropdown", {
74
+ month: typeof S.Int;
75
+ }>;
76
+ /** Sent when the user picks a year from the year dropdown. */
77
+ export declare const SelectedYearFromDropdown: import("../../schema").CallableTaggedStruct<"SelectedYearFromDropdown", {
78
+ year: typeof S.Int;
79
+ }>;
80
+ /** Sent when the grid container receives DOM focus. */
81
+ export declare const FocusedGrid: import("../../schema").CallableTaggedStruct<"FocusedGrid", {}>;
82
+ /** Sent when the grid container loses DOM focus. */
83
+ export declare const BlurredGrid: import("../../schema").CallableTaggedStruct<"BlurredGrid", {}>;
84
+ /** Sent when a long-lived session's "today" reference should be refreshed. */
85
+ export declare const RefreshedToday: import("../../schema").CallableTaggedStruct<"RefreshedToday", {
86
+ today: S.filter<S.Struct<{
87
+ year: typeof S.Int;
88
+ month: S.filter<typeof S.Int>;
89
+ day: S.filter<typeof S.Int>;
90
+ }>>;
91
+ }>;
92
+ /** Sent when a FocusGrid command completes. */
93
+ export declare const CompletedFocusGrid: import("../../schema").CallableTaggedStruct<"CompletedFocusGrid", {}>;
94
+ /** Union of all messages the calendar component can produce. */
95
+ export declare const Message: S.Union<[import("../../schema").CallableTaggedStruct<"ClickedDay", {
96
+ date: S.filter<S.Struct<{
97
+ year: typeof S.Int;
98
+ month: S.filter<typeof S.Int>;
99
+ day: S.filter<typeof S.Int>;
100
+ }>>;
101
+ }>, import("../../schema").CallableTaggedStruct<"PressedKeyOnGrid", {
102
+ key: typeof S.String;
103
+ isShift: typeof S.Boolean;
104
+ }>, import("../../schema").CallableTaggedStruct<"ClickedPreviousMonthButton", {}>, import("../../schema").CallableTaggedStruct<"ClickedNextMonthButton", {}>, import("../../schema").CallableTaggedStruct<"SelectedMonthFromDropdown", {
105
+ month: typeof S.Int;
106
+ }>, import("../../schema").CallableTaggedStruct<"SelectedYearFromDropdown", {
107
+ year: typeof S.Int;
108
+ }>, import("../../schema").CallableTaggedStruct<"FocusedGrid", {}>, import("../../schema").CallableTaggedStruct<"BlurredGrid", {}>, import("../../schema").CallableTaggedStruct<"RefreshedToday", {
109
+ today: S.filter<S.Struct<{
110
+ year: typeof S.Int;
111
+ month: S.filter<typeof S.Int>;
112
+ day: S.filter<typeof S.Int>;
113
+ }>>;
114
+ }>, import("../../schema").CallableTaggedStruct<"CompletedFocusGrid", {}>]>;
115
+ export type Message = typeof Message.Type;
116
+ /** Emitted when the visible month changes due to navigation. Consumers of an
117
+ * inline calendar may use this to load month-scoped data (holidays, events).
118
+ *
119
+ * Date selection does NOT use OutMessage — consumers subscribe via the
120
+ * `onSelectedDate` callback in `ViewConfig`, matching the Listbox/Popover
121
+ * controlled-component pattern. Use `Calendar.selectDate(model, date)` to
122
+ * write back when handling the callback. */
123
+ export declare const ChangedViewMonth: import("../../schema").CallableTaggedStruct<"ChangedViewMonth", {
124
+ year: typeof S.Int;
125
+ month: typeof S.Int;
126
+ }>;
127
+ /** The calendar's OutMessage. Only one variant — `ChangedViewMonth` — which
128
+ * fires when navigation shifts the visible month. Date selection goes through
129
+ * the `onSelectedDate` ViewConfig callback, not OutMessage. */
130
+ export declare const OutMessage: import("../../schema").CallableTaggedStruct<"ChangedViewMonth", {
131
+ year: typeof S.Int;
132
+ month: typeof S.Int;
133
+ }>;
134
+ export type OutMessage = typeof OutMessage.Type;
135
+ /** Configuration for creating a calendar model with `init`. */
136
+ export type InitConfig = Readonly<{
137
+ id: string;
138
+ today: CalendarDate;
139
+ maybeInitialSelectedDate?: Option.Option<CalendarDate>;
140
+ locale?: Calendar.LocaleConfig;
141
+ maybeMinDate?: Option.Option<CalendarDate>;
142
+ maybeMaxDate?: Option.Option<CalendarDate>;
143
+ disabledDaysOfWeek?: ReadonlyArray<Calendar.DayOfWeek>;
144
+ disabledDates?: ReadonlyArray<CalendarDate>;
145
+ }>;
146
+ /** Creates an initial calendar model. The view month defaults to the month
147
+ * of the initial selected date, or today if no date is pre-selected. */
148
+ export declare const init: (config: InitConfig) => Model;
149
+ type UpdateReturn = readonly [
150
+ Model,
151
+ ReadonlyArray<Command.Command<Message>>,
152
+ Option.Option<OutMessage>
153
+ ];
154
+ /** Focuses the calendar grid container. */
155
+ export declare const FocusGrid: Command.CommandDefinition<"FocusGrid", {
156
+ readonly _tag: "CompletedFocusGrid";
157
+ }>;
158
+ /** Builds a command that focuses the calendar grid container. Parent
159
+ * components like DatePicker dispatch this after opening to hand focus to
160
+ * the grid's keyboard layer. */
161
+ export declare const focusGrid: (modelId: string) => Command.Command<Message>;
162
+ /** Programmatically selects a date on the calendar, committing it as the
163
+ * chosen value and moving the cursor onto it. Use this in controlled-mode
164
+ * handlers (when the view's `onSelectedDate` callback is provided) to write
165
+ * the selection back to the calendar's internal state.
166
+ *
167
+ * Equivalent to dispatching `ClickedDay({ date })` through `update`. */
168
+ export declare const selectDate: (model: Model, date: CalendarDate) => UpdateReturn;
169
+ /** Processes a calendar message and returns the next model, commands, and
170
+ * optional OutMessage. */
171
+ export declare const update: (model: Model, message: Message) => UpdateReturn;
172
+ /** Information about a single day cell in the rendered calendar grid. */
173
+ export type DayCell<ParentMessage> = Readonly<{
174
+ date: CalendarDate;
175
+ label: string;
176
+ cellAttributes: ReadonlyArray<Attribute<ParentMessage>>;
177
+ buttonAttributes: ReadonlyArray<Attribute<ParentMessage>>;
178
+ isSelected: boolean;
179
+ isFocused: boolean;
180
+ isToday: boolean;
181
+ isInViewMonth: boolean;
182
+ isDisabled: boolean;
183
+ }>;
184
+ /** A column header for the grid's first row (day-of-week labels). */
185
+ export type ColumnHeader<ParentMessage> = Readonly<{
186
+ name: string;
187
+ attributes: ReadonlyArray<Attribute<ParentMessage>>;
188
+ }>;
189
+ /** A single week row in the calendar grid, carrying its own row attributes
190
+ * (role, aria-rowindex) alongside its 7 day cells. */
191
+ export type Week<ParentMessage> = Readonly<{
192
+ attributes: ReadonlyArray<Attribute<ParentMessage>>;
193
+ cells: ReadonlyArray<DayCell<ParentMessage>>;
194
+ }>;
195
+ /** Attribute groups and derived data the calendar component provides to the
196
+ * consumer's `toView` callback. */
197
+ export type CalendarAttributes<ParentMessage> = Readonly<{
198
+ root: ReadonlyArray<Attribute<ParentMessage>>;
199
+ previousMonthButton: ReadonlyArray<Attribute<ParentMessage>>;
200
+ nextMonthButton: ReadonlyArray<Attribute<ParentMessage>>;
201
+ heading: Readonly<{
202
+ id: string;
203
+ text: string;
204
+ }>;
205
+ monthSelect: ReadonlyArray<Attribute<ParentMessage>>;
206
+ monthOptions: ReadonlyArray<Readonly<{
207
+ value: number;
208
+ label: string;
209
+ }>>;
210
+ yearSelect: ReadonlyArray<Attribute<ParentMessage>>;
211
+ yearOptions: ReadonlyArray<number>;
212
+ grid: ReadonlyArray<Attribute<ParentMessage>>;
213
+ headerRow: ReadonlyArray<Attribute<ParentMessage>>;
214
+ columnHeaders: ReadonlyArray<ColumnHeader<ParentMessage>>;
215
+ weeks: ReadonlyArray<Week<ParentMessage>>;
216
+ }>;
217
+ /** Configuration for rendering a calendar with `view`. */
218
+ export type ViewConfig<ParentMessage> = Readonly<{
219
+ model: Model;
220
+ toParentMessage: (message: Message) => ParentMessage;
221
+ toView: (attributes: CalendarAttributes<ParentMessage>) => Html;
222
+ /** Optional callback invoked when the user commits a date via click, Enter,
223
+ * or Space. When provided, the view dispatches the callback directly (the
224
+ * controlled pattern — parent owns the event). When omitted, the calendar
225
+ * manages its own `maybeSelectedDate` state automatically (uncontrolled).
226
+ * In controlled mode, use `Calendar.selectDate(model, date)` to write the
227
+ * selection back to the calendar's internal state. */
228
+ onSelectedDate?: (date: CalendarDate) => ParentMessage;
229
+ previousMonthLabel?: string;
230
+ nextMonthLabel?: string;
231
+ monthSelectLabel?: string;
232
+ yearSelectLabel?: string;
233
+ }>;
234
+ /** Renders an accessible calendar grid. Builds ARIA attribute groups (grid,
235
+ * row, gridcell, column header) plus the derived month grid, then delegates
236
+ * layout to the consumer's `toView` callback. */
237
+ export declare const view: <ParentMessage>(config: ViewConfig<ParentMessage>) => Html;
238
+ /** Creates a memoized calendar view. Static config is captured in a closure;
239
+ * only `model` and `toParentMessage` are compared per render via `createLazy`. */
240
+ export declare const lazy: <ParentMessage>(staticConfig: Omit<ViewConfig<ParentMessage>, "model" | "toParentMessage">) => ((model: Model, toParentMessage: ViewConfig<ParentMessage>["toParentMessage"]) => Html);
241
+ export {};
242
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/calendar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,MAAM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