foldkit 0.60.0 → 0.62.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 (52) 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/anchor.d.ts +2 -1
  29. package/dist/ui/anchor.d.ts.map +1 -1
  30. package/dist/ui/anchor.js +24 -3
  31. package/dist/ui/calendar/index.d.ts +242 -0
  32. package/dist/ui/calendar/index.d.ts.map +1 -0
  33. package/dist/ui/calendar/index.js +516 -0
  34. package/dist/ui/calendar/public.d.ts +3 -0
  35. package/dist/ui/calendar/public.d.ts.map +1 -0
  36. package/dist/ui/calendar/public.js +1 -0
  37. package/dist/ui/datePicker/index.d.ts +226 -0
  38. package/dist/ui/datePicker/index.d.ts.map +1 -0
  39. package/dist/ui/datePicker/index.js +231 -0
  40. package/dist/ui/datePicker/public.d.ts +3 -0
  41. package/dist/ui/datePicker/public.d.ts.map +1 -0
  42. package/dist/ui/datePicker/public.js +1 -0
  43. package/dist/ui/dragAndDrop/index.d.ts +1 -1
  44. package/dist/ui/index.d.ts +2 -0
  45. package/dist/ui/index.d.ts.map +1 -1
  46. package/dist/ui/index.js +2 -0
  47. package/dist/ui/menu/index.d.ts.map +1 -1
  48. package/dist/ui/menu/index.js +1 -5
  49. package/dist/ui/popover/index.d.ts +4 -1
  50. package/dist/ui/popover/index.d.ts.map +1 -1
  51. package/dist/ui/popover/index.js +8 -9
  52. package/package.json +9 -1
@@ -0,0 +1,163 @@
1
+ import { type Equivalence as equivalence, Order as order } from 'effect';
2
+ import type { CalendarDate } from './calendarDate';
3
+ /**
4
+ * Total ordering over calendar dates. Uses lexicographic comparison on
5
+ * `year`, then `month`, then `day` — which matches calendar chronology
6
+ * because the struct fields are already in the right order.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { Calendar } from 'foldkit'
11
+ * import { Array } from 'effect'
12
+ *
13
+ * const dates = [
14
+ * Calendar.make(2026, 5, 1),
15
+ * Calendar.make(2026, 4, 30),
16
+ * Calendar.make(2026, 4, 13),
17
+ * ]
18
+ * Array.sort(dates, Calendar.Order)
19
+ * ```
20
+ */
21
+ export declare const Order: order.Order<CalendarDate>;
22
+ /**
23
+ * Value-based equivalence for calendar dates.
24
+ */
25
+ export declare const Equivalence: equivalence.Equivalence<CalendarDate>;
26
+ /**
27
+ * Returns `true` when two calendar dates represent the same day.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { Calendar } from 'foldkit'
32
+ * import { pipe } from 'effect'
33
+ *
34
+ * Calendar.isEqual(Calendar.make(2026, 4, 13), Calendar.make(2026, 4, 13)) // true
35
+ * pipe(Calendar.make(2026, 4, 13), Calendar.isEqual(Calendar.make(2026, 4, 14))) // false
36
+ * ```
37
+ */
38
+ export declare const isEqual: {
39
+ (that: CalendarDate): (self: CalendarDate) => boolean;
40
+ (self: CalendarDate, that: CalendarDate): boolean;
41
+ };
42
+ /**
43
+ * Returns `true` when `self` is strictly before `that`.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { Calendar } from 'foldkit'
48
+ * import { pipe } from 'effect'
49
+ *
50
+ * Calendar.isBefore(Calendar.make(2026, 4, 12), Calendar.make(2026, 4, 13)) // true
51
+ * pipe(Calendar.make(2026, 4, 14), Calendar.isBefore(Calendar.make(2026, 4, 13))) // false
52
+ * ```
53
+ */
54
+ export declare const isBefore: {
55
+ (that: CalendarDate): (self: CalendarDate) => boolean;
56
+ (self: CalendarDate, that: CalendarDate): boolean;
57
+ };
58
+ /**
59
+ * Returns `true` when `self` is strictly after `that`.
60
+ */
61
+ export declare const isAfter: {
62
+ (that: CalendarDate): (self: CalendarDate) => boolean;
63
+ (self: CalendarDate, that: CalendarDate): boolean;
64
+ };
65
+ /**
66
+ * Returns `true` when `self` is before or equal to `that`.
67
+ */
68
+ export declare const isBeforeOrEqual: {
69
+ (that: CalendarDate): (self: CalendarDate) => boolean;
70
+ (self: CalendarDate, that: CalendarDate): boolean;
71
+ };
72
+ /**
73
+ * Returns `true` when `self` is after or equal to `that`.
74
+ */
75
+ export declare const isAfterOrEqual: {
76
+ (that: CalendarDate): (self: CalendarDate) => boolean;
77
+ (self: CalendarDate, that: CalendarDate): boolean;
78
+ };
79
+ /**
80
+ * Returns the earlier of two calendar dates.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * import { Calendar } from 'foldkit'
85
+ * import { pipe } from 'effect'
86
+ *
87
+ * Calendar.min(Calendar.make(2026, 4, 13), Calendar.make(2026, 4, 14))
88
+ * // { year: 2026, month: 4, day: 13 }
89
+ *
90
+ * pipe(Calendar.make(2026, 4, 14), Calendar.min(Calendar.make(2026, 4, 13)))
91
+ * // { year: 2026, month: 4, day: 13 }
92
+ * ```
93
+ */
94
+ export declare const min: {
95
+ (that: CalendarDate): (self: CalendarDate) => CalendarDate;
96
+ (self: CalendarDate, that: CalendarDate): CalendarDate;
97
+ };
98
+ /**
99
+ * Returns the later of two calendar dates.
100
+ */
101
+ export declare const max: {
102
+ (that: CalendarDate): (self: CalendarDate) => CalendarDate;
103
+ (self: CalendarDate, that: CalendarDate): CalendarDate;
104
+ };
105
+ /**
106
+ * Returns `true` when `self` is within the inclusive range `[minimum, maximum]`.
107
+ *
108
+ * @example
109
+ * ```ts
110
+ * import { Calendar } from 'foldkit'
111
+ * import { pipe } from 'effect'
112
+ *
113
+ * Calendar.between(Calendar.make(2026, 4, 13), {
114
+ * minimum: Calendar.make(2026, 1, 1),
115
+ * maximum: Calendar.make(2026, 12, 31),
116
+ * }) // true
117
+ *
118
+ * pipe(
119
+ * Calendar.make(2026, 4, 13),
120
+ * Calendar.between({
121
+ * minimum: Calendar.make(2027, 1, 1),
122
+ * maximum: Calendar.make(2027, 12, 31),
123
+ * }),
124
+ * ) // false
125
+ * ```
126
+ */
127
+ export declare const between: {
128
+ (options: {
129
+ readonly minimum: CalendarDate;
130
+ readonly maximum: CalendarDate;
131
+ }): (self: CalendarDate) => boolean;
132
+ (self: CalendarDate, options: {
133
+ readonly minimum: CalendarDate;
134
+ readonly maximum: CalendarDate;
135
+ }): boolean;
136
+ };
137
+ /**
138
+ * Clamps `self` to the inclusive range `[minimum, maximum]`. Returns
139
+ * `minimum` when `self` is before it, `maximum` when `self` is after it,
140
+ * and `self` itself otherwise.
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * import { Calendar } from 'foldkit'
145
+ *
146
+ * Calendar.clamp(Calendar.make(2025, 12, 31), {
147
+ * minimum: Calendar.make(2026, 1, 1),
148
+ * maximum: Calendar.make(2026, 12, 31),
149
+ * })
150
+ * // { year: 2026, month: 1, day: 1 }
151
+ * ```
152
+ */
153
+ export declare const clamp: {
154
+ (options: {
155
+ readonly minimum: CalendarDate;
156
+ readonly maximum: CalendarDate;
157
+ }): (self: CalendarDate) => CalendarDate;
158
+ (self: CalendarDate, options: {
159
+ readonly minimum: CalendarDate;
160
+ readonly maximum: CalendarDate;
161
+ }): CalendarDate;
162
+ };
163
+ //# sourceMappingURL=comparison.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comparison.d.ts","sourceRoot":"","sources":["../../src/calendar/comparison.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,134 @@
1
+ import { Function, Order as order, } from 'effect';
2
+ /**
3
+ * Total ordering over calendar dates. Uses lexicographic comparison on
4
+ * `year`, then `month`, then `day` — which matches calendar chronology
5
+ * because the struct fields are already in the right order.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { Calendar } from 'foldkit'
10
+ * import { Array } from 'effect'
11
+ *
12
+ * const dates = [
13
+ * Calendar.make(2026, 5, 1),
14
+ * Calendar.make(2026, 4, 30),
15
+ * Calendar.make(2026, 4, 13),
16
+ * ]
17
+ * Array.sort(dates, Calendar.Order)
18
+ * ```
19
+ */
20
+ export const Order = order.struct({
21
+ year: order.number,
22
+ month: order.number,
23
+ day: order.number,
24
+ });
25
+ /**
26
+ * Value-based equivalence for calendar dates.
27
+ */
28
+ export const Equivalence = (a, b) => a.year === b.year && a.month === b.month && a.day === b.day;
29
+ /**
30
+ * Returns `true` when two calendar dates represent the same day.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * import { Calendar } from 'foldkit'
35
+ * import { pipe } from 'effect'
36
+ *
37
+ * Calendar.isEqual(Calendar.make(2026, 4, 13), Calendar.make(2026, 4, 13)) // true
38
+ * pipe(Calendar.make(2026, 4, 13), Calendar.isEqual(Calendar.make(2026, 4, 14))) // false
39
+ * ```
40
+ */
41
+ export const isEqual = Function.dual(2, (self, that) => Equivalence(self, that));
42
+ /**
43
+ * Returns `true` when `self` is strictly before `that`.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { Calendar } from 'foldkit'
48
+ * import { pipe } from 'effect'
49
+ *
50
+ * Calendar.isBefore(Calendar.make(2026, 4, 12), Calendar.make(2026, 4, 13)) // true
51
+ * pipe(Calendar.make(2026, 4, 14), Calendar.isBefore(Calendar.make(2026, 4, 13))) // false
52
+ * ```
53
+ */
54
+ export const isBefore = Function.dual(2, (self, that) => Order(self, that) < 0);
55
+ /**
56
+ * Returns `true` when `self` is strictly after `that`.
57
+ */
58
+ export const isAfter = Function.dual(2, (self, that) => Order(self, that) > 0);
59
+ /**
60
+ * Returns `true` when `self` is before or equal to `that`.
61
+ */
62
+ export const isBeforeOrEqual = Function.dual(2, (self, that) => Order(self, that) <= 0);
63
+ /**
64
+ * Returns `true` when `self` is after or equal to `that`.
65
+ */
66
+ export const isAfterOrEqual = Function.dual(2, (self, that) => Order(self, that) >= 0);
67
+ /**
68
+ * Returns the earlier of two calendar dates.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * import { Calendar } from 'foldkit'
73
+ * import { pipe } from 'effect'
74
+ *
75
+ * Calendar.min(Calendar.make(2026, 4, 13), Calendar.make(2026, 4, 14))
76
+ * // { year: 2026, month: 4, day: 13 }
77
+ *
78
+ * pipe(Calendar.make(2026, 4, 14), Calendar.min(Calendar.make(2026, 4, 13)))
79
+ * // { year: 2026, month: 4, day: 13 }
80
+ * ```
81
+ */
82
+ export const min = Function.dual(2, (self, that) => Order(self, that) <= 0 ? self : that);
83
+ /**
84
+ * Returns the later of two calendar dates.
85
+ */
86
+ export const max = Function.dual(2, (self, that) => Order(self, that) >= 0 ? self : that);
87
+ /**
88
+ * Returns `true` when `self` is within the inclusive range `[minimum, maximum]`.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * import { Calendar } from 'foldkit'
93
+ * import { pipe } from 'effect'
94
+ *
95
+ * Calendar.between(Calendar.make(2026, 4, 13), {
96
+ * minimum: Calendar.make(2026, 1, 1),
97
+ * maximum: Calendar.make(2026, 12, 31),
98
+ * }) // true
99
+ *
100
+ * pipe(
101
+ * Calendar.make(2026, 4, 13),
102
+ * Calendar.between({
103
+ * minimum: Calendar.make(2027, 1, 1),
104
+ * maximum: Calendar.make(2027, 12, 31),
105
+ * }),
106
+ * ) // false
107
+ * ```
108
+ */
109
+ export const between = Function.dual(2, (self, options) => Order(self, options.minimum) >= 0 && Order(self, options.maximum) <= 0);
110
+ /**
111
+ * Clamps `self` to the inclusive range `[minimum, maximum]`. Returns
112
+ * `minimum` when `self` is before it, `maximum` when `self` is after it,
113
+ * and `self` itself otherwise.
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * import { Calendar } from 'foldkit'
118
+ *
119
+ * Calendar.clamp(Calendar.make(2025, 12, 31), {
120
+ * minimum: Calendar.make(2026, 1, 1),
121
+ * maximum: Calendar.make(2026, 12, 31),
122
+ * })
123
+ * // { year: 2026, month: 1, day: 1 }
124
+ * ```
125
+ */
126
+ export const clamp = Function.dual(2, (self, options) => {
127
+ if (Order(self, options.minimum) < 0) {
128
+ return options.minimum;
129
+ }
130
+ if (Order(self, options.maximum) > 0) {
131
+ return options.maximum;
132
+ }
133
+ return self;
134
+ });
@@ -0,0 +1,7 @@
1
+ export { CalendarDate, CalendarDateFromIsoString, daysInMonth, fromDateInZone, fromDateLocal, isCalendarDate, isLeapYear, make, toDateLocal, unsafeMake, } from './calendarDate';
2
+ export { addDays, addMonths, addYears, daysSince, daysUntil, subtractDays, subtractMonths, subtractYears, } from './arithmetic';
3
+ export { between, clamp, Equivalence, isAfter, isAfterOrEqual, isBefore, isBeforeOrEqual, isEqual, max, min, Order, } from './comparison';
4
+ export { DayOfWeek, dayOfWeek, endOfWeek, firstOfMonth, lastOfMonth, startOfWeek, } from './info';
5
+ export { today } from './today';
6
+ export { defaultEnglishLocale, formatAriaLabel, formatLong, formatShort, LocaleConfig, } from './locale';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/calendar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,yBAAyB,EACzB,WAAW,EACX,cAAc,EACd,aAAa,EACb,cAAc,EACd,UAAU,EACV,IAAI,EACJ,WAAW,EACX,UAAU,GACX,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACL,OAAO,EACP,SAAS,EACT,QAAQ,EACR,SAAS,EACT,SAAS,EACT,YAAY,EACZ,cAAc,EACd,aAAa,GACd,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,OAAO,EACP,KAAK,EACL,WAAW,EACX,OAAO,EACP,cAAc,EACd,QAAQ,EACR,eAAe,EACf,OAAO,EACP,GAAG,EACH,GAAG,EACH,KAAK,GACN,MAAM,cAAc,CAAA;AAErB,OAAO,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,YAAY,EACZ,WAAW,EACX,WAAW,GACZ,MAAM,QAAQ,CAAA;AAEf,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,WAAW,EACX,YAAY,GACb,MAAM,UAAU,CAAA"}
@@ -0,0 +1,6 @@
1
+ export { CalendarDate, CalendarDateFromIsoString, daysInMonth, fromDateInZone, fromDateLocal, isCalendarDate, isLeapYear, make, toDateLocal, unsafeMake, } from './calendarDate';
2
+ export { addDays, addMonths, addYears, daysSince, daysUntil, subtractDays, subtractMonths, subtractYears, } from './arithmetic';
3
+ export { between, clamp, Equivalence, isAfter, isAfterOrEqual, isBefore, isBeforeOrEqual, isEqual, max, min, Order, } from './comparison';
4
+ export { DayOfWeek, dayOfWeek, endOfWeek, firstOfMonth, lastOfMonth, startOfWeek, } from './info';
5
+ export { today } from './today';
6
+ export { defaultEnglishLocale, formatAriaLabel, formatLong, formatShort, LocaleConfig, } from './locale';
@@ -0,0 +1,76 @@
1
+ import { Schema as S } from 'effect';
2
+ import { type CalendarDate } from './calendarDate';
3
+ /**
4
+ * Schema for days of the week, Sunday through Saturday. Tagged union preferred
5
+ * over 0-6 numeric indices to avoid magic numbers at call sites.
6
+ */
7
+ export declare const DayOfWeek: S.Literal<["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]>;
8
+ export type DayOfWeek = typeof DayOfWeek.Type;
9
+ /**
10
+ * Returns the day of the week for a calendar date.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { Calendar } from 'foldkit'
15
+ *
16
+ * Calendar.dayOfWeek(Calendar.make(2026, 1, 1)) // "Thursday"
17
+ * Calendar.dayOfWeek(Calendar.make(2000, 1, 1)) // "Saturday"
18
+ * ```
19
+ */
20
+ export declare const dayOfWeek: (self: CalendarDate) => DayOfWeek;
21
+ /**
22
+ * Returns the first day of the month containing `self`.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * import { Calendar } from 'foldkit'
27
+ *
28
+ * Calendar.firstOfMonth(Calendar.make(2026, 4, 13))
29
+ * // { year: 2026, month: 4, day: 1 }
30
+ * ```
31
+ */
32
+ export declare const firstOfMonth: (self: CalendarDate) => CalendarDate;
33
+ /**
34
+ * Returns the last day of the month containing `self`. Leap-year aware
35
+ * for February.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { Calendar } from 'foldkit'
40
+ *
41
+ * Calendar.lastOfMonth(Calendar.make(2024, 2, 10))
42
+ * // { year: 2024, month: 2, day: 29 } — leap year
43
+ *
44
+ * Calendar.lastOfMonth(Calendar.make(2026, 2, 10))
45
+ * // { year: 2026, month: 2, day: 28 }
46
+ * ```
47
+ */
48
+ export declare const lastOfMonth: (self: CalendarDate) => CalendarDate;
49
+ /**
50
+ * Returns the start-of-week date for the week containing `self`, where
51
+ * `firstDayOfWeek` specifies which day begins the week. Returns `self`
52
+ * itself when it already falls on `firstDayOfWeek`.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * import { Calendar } from 'foldkit'
57
+ * import { pipe } from 'effect'
58
+ *
59
+ * Calendar.startOfWeek(Calendar.make(2026, 4, 15), 'Sunday')
60
+ * // The Sunday that begins the week containing April 15, 2026
61
+ *
62
+ * pipe(Calendar.make(2026, 4, 15), Calendar.startOfWeek('Monday'))
63
+ * ```
64
+ */
65
+ export declare const startOfWeek: {
66
+ (firstDayOfWeek: DayOfWeek): (self: CalendarDate) => CalendarDate;
67
+ (self: CalendarDate, firstDayOfWeek: DayOfWeek): CalendarDate;
68
+ };
69
+ /**
70
+ * Returns the end-of-week date — six days after the start of the week.
71
+ */
72
+ export declare const endOfWeek: {
73
+ (firstDayOfWeek: DayOfWeek): (self: CalendarDate) => CalendarDate;
74
+ (self: CalendarDate, firstDayOfWeek: DayOfWeek): CalendarDate;
75
+ };
76
+ //# sourceMappingURL=info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../src/calendar/info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAG9C,OAAO,EAAE,KAAK,YAAY,EAA2B,MAAM,gBAAgB,CAAA;AAE3E;;;GAGG;AACH,eAAO,MAAM,SAAS,2FAQrB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAA;AA6B7C;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,YAAY,KAAG,SAgB9C,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,YAAY,KAAG,YACZ,CAAA;AAEtC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,YAAY,KAAG,YACsB,CAAA;AAEvE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,EAAE;IACxB,CAAC,cAAc,EAAE,SAAS,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,YAAY,CAAA;IACjE,CAAC,IAAI,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,GAAG,YAAY,CAAA;CAS9D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE;IACtB,CAAC,cAAc,EAAE,SAAS,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,YAAY,CAAA;IACjE,CAAC,IAAI,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,GAAG,YAAY,CAAA;CAK9D,CAAA"}
@@ -0,0 +1,125 @@
1
+ import { Function, Schema as S } from 'effect';
2
+ import { addDays, subtractDays } from './arithmetic';
3
+ import { daysInMonth, unsafeMake } from './calendarDate';
4
+ /**
5
+ * Schema for days of the week, Sunday through Saturday. Tagged union preferred
6
+ * over 0-6 numeric indices to avoid magic numbers at call sites.
7
+ */
8
+ export const DayOfWeek = S.Literal('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
9
+ const dayOfWeekFromIndex = (index) => {
10
+ if (index === 0)
11
+ return 'Sunday';
12
+ if (index === 1)
13
+ return 'Monday';
14
+ if (index === 2)
15
+ return 'Tuesday';
16
+ if (index === 3)
17
+ return 'Wednesday';
18
+ if (index === 4)
19
+ return 'Thursday';
20
+ if (index === 5)
21
+ return 'Friday';
22
+ return 'Saturday';
23
+ };
24
+ const dayOfWeekToIndex = (day) => {
25
+ if (day === 'Sunday')
26
+ return 0;
27
+ if (day === 'Monday')
28
+ return 1;
29
+ if (day === 'Tuesday')
30
+ return 2;
31
+ if (day === 'Wednesday')
32
+ return 3;
33
+ if (day === 'Thursday')
34
+ return 4;
35
+ if (day === 'Friday')
36
+ return 5;
37
+ return 6;
38
+ };
39
+ // NOTE: Sakamoto's algorithm for day-of-week. The offsets array is a
40
+ // precomputed lookup table that makes the formula branch-free.
41
+ // See https://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week#Sakamoto's_methods
42
+ const sakamotoOffsets = [
43
+ 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4,
44
+ ];
45
+ /**
46
+ * Returns the day of the week for a calendar date.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * import { Calendar } from 'foldkit'
51
+ *
52
+ * Calendar.dayOfWeek(Calendar.make(2026, 1, 1)) // "Thursday"
53
+ * Calendar.dayOfWeek(Calendar.make(2000, 1, 1)) // "Saturday"
54
+ * ```
55
+ */
56
+ export const dayOfWeek = (self) => {
57
+ const adjustedYear = self.month < 3 ? self.year - 1 : self.year;
58
+ const offset = sakamotoOffsets[self.month - 1] ?? 0;
59
+ // The `+ 7) % 7` trick handles negative results from the modulo operation
60
+ // on negative years — JS `%` preserves sign, so we wrap back into [0, 6].
61
+ const index = (((adjustedYear +
62
+ Math.floor(adjustedYear / 4) -
63
+ Math.floor(adjustedYear / 100) +
64
+ Math.floor(adjustedYear / 400) +
65
+ offset +
66
+ self.day) %
67
+ 7) +
68
+ 7) %
69
+ 7;
70
+ return dayOfWeekFromIndex(index);
71
+ };
72
+ /**
73
+ * Returns the first day of the month containing `self`.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * import { Calendar } from 'foldkit'
78
+ *
79
+ * Calendar.firstOfMonth(Calendar.make(2026, 4, 13))
80
+ * // { year: 2026, month: 4, day: 1 }
81
+ * ```
82
+ */
83
+ export const firstOfMonth = (self) => unsafeMake(self.year, self.month, 1);
84
+ /**
85
+ * Returns the last day of the month containing `self`. Leap-year aware
86
+ * for February.
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * import { Calendar } from 'foldkit'
91
+ *
92
+ * Calendar.lastOfMonth(Calendar.make(2024, 2, 10))
93
+ * // { year: 2024, month: 2, day: 29 } — leap year
94
+ *
95
+ * Calendar.lastOfMonth(Calendar.make(2026, 2, 10))
96
+ * // { year: 2026, month: 2, day: 28 }
97
+ * ```
98
+ */
99
+ export const lastOfMonth = (self) => unsafeMake(self.year, self.month, daysInMonth(self.year, self.month));
100
+ /**
101
+ * Returns the start-of-week date for the week containing `self`, where
102
+ * `firstDayOfWeek` specifies which day begins the week. Returns `self`
103
+ * itself when it already falls on `firstDayOfWeek`.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * import { Calendar } from 'foldkit'
108
+ * import { pipe } from 'effect'
109
+ *
110
+ * Calendar.startOfWeek(Calendar.make(2026, 4, 15), 'Sunday')
111
+ * // The Sunday that begins the week containing April 15, 2026
112
+ *
113
+ * pipe(Calendar.make(2026, 4, 15), Calendar.startOfWeek('Monday'))
114
+ * ```
115
+ */
116
+ export const startOfWeek = Function.dual(2, (self, firstDayOfWeek) => {
117
+ const startIndex = dayOfWeekToIndex(firstDayOfWeek);
118
+ const dateIndex = dayOfWeekToIndex(dayOfWeek(self));
119
+ const offset = (dateIndex - startIndex + 7) % 7;
120
+ return subtractDays(self, offset);
121
+ });
122
+ /**
123
+ * Returns the end-of-week date — six days after the start of the week.
124
+ */
125
+ export const endOfWeek = Function.dual(2, (self, firstDayOfWeek) => addDays(startOfWeek(self, firstDayOfWeek), 6));
@@ -0,0 +1,71 @@
1
+ import { Schema as S } from 'effect';
2
+ import type { CalendarDate } from './calendarDate';
3
+ /**
4
+ * Locale configuration for rendering calendar dates. Contains only data —
5
+ * month/day names and the first day of the week. Formatting functions
6
+ * (`formatLong`, `formatShort`, `formatAriaLabel`) are separate exports that
7
+ * take a `LocaleConfig` as input.
8
+ *
9
+ * Day names are always stored Sunday-first in the config; `firstDayOfWeek`
10
+ * controls how the view rotates them at render time.
11
+ */
12
+ export declare const LocaleConfig: S.Struct<{
13
+ firstDayOfWeek: S.Literal<["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]>;
14
+ 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]>;
15
+ 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]>;
16
+ dayNames: S.Tuple<[typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String]>;
17
+ shortDayNames: S.Tuple<[typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String, typeof S.String]>;
18
+ }>;
19
+ export type LocaleConfig = typeof LocaleConfig.Type;
20
+ /**
21
+ * Default English (United States) locale. Picker components default to this
22
+ * when no locale is passed via ViewConfig. Consumers who want a different
23
+ * locale pass their own `LocaleConfig`.
24
+ */
25
+ export declare const defaultEnglishLocale: LocaleConfig;
26
+ /**
27
+ * Renders a calendar date in long form. Example: `"January 15, 2026"`.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { Calendar } from 'foldkit'
32
+ * import { pipe } from 'effect'
33
+ *
34
+ * Calendar.formatLong(Calendar.make(2026, 1, 15), Calendar.defaultEnglishLocale)
35
+ * // "January 15, 2026"
36
+ *
37
+ * pipe(
38
+ * Calendar.make(2026, 1, 15),
39
+ * Calendar.formatLong(Calendar.defaultEnglishLocale),
40
+ * )
41
+ * // "January 15, 2026"
42
+ * ```
43
+ */
44
+ export declare const formatLong: {
45
+ (locale: LocaleConfig): (self: CalendarDate) => string;
46
+ (self: CalendarDate, locale: LocaleConfig): string;
47
+ };
48
+ /**
49
+ * Renders a calendar date in short form. Example: `"Jan 15, 2026"`.
50
+ */
51
+ export declare const formatShort: {
52
+ (locale: LocaleConfig): (self: CalendarDate) => string;
53
+ (self: CalendarDate, locale: LocaleConfig): string;
54
+ };
55
+ /**
56
+ * Renders an accessibility label for a calendar date, suitable for
57
+ * `aria-label` on a grid cell. Example: `"Monday, January 15, 2026"`.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import { Calendar } from 'foldkit'
62
+ *
63
+ * Calendar.formatAriaLabel(Calendar.make(2026, 1, 15), Calendar.defaultEnglishLocale)
64
+ * // "Thursday, January 15, 2026"
65
+ * ```
66
+ */
67
+ export declare const formatAriaLabel: {
68
+ (locale: LocaleConfig): (self: CalendarDate) => string;
69
+ (self: CalendarDate, locale: LocaleConfig): string;
70
+ };
71
+ //# sourceMappingURL=locale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../src/calendar/locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AA4BlD;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY;;;;;;EAMvB,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAA;AAEnD;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,YAwClC,CAAA;AA0CD;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,UAAU,EAAE;IACvB,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,MAAM,CAAA;IACtD,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAAA;CAKnD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE;IACxB,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,MAAM,CAAA;IACtD,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAAA;CAKnD,CAAA;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,EAAE;IAC5B,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,MAAM,CAAA;IACtD,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAAA;CAKlD,CAAA"}