@fragiola/primitives 0.0.0-stage → 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.
Files changed (192) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/LICENSE +21 -0
  3. package/README.md +50 -2
  4. package/dist/async-list-Bv6ff5Oj.js +81 -0
  5. package/dist/async-list-Bv6ff5Oj.js.map +1 -0
  6. package/dist/async-list.d.ts +2 -0
  7. package/dist/async-list.js +1 -0
  8. package/dist/calendar-keys-DGYpjLwv.d.ts +12 -0
  9. package/dist/calendar-system-B5U5HcPQ.d.ts +415 -0
  10. package/dist/calendar-systems-Daa6Q_ca.js +659 -0
  11. package/dist/calendar-systems-Daa6Q_ca.js.map +1 -0
  12. package/dist/calendar-systems.d.ts +3 -0
  13. package/dist/calendar-systems.js +1 -0
  14. package/dist/carousel-LRbWqbAx.js +375 -0
  15. package/dist/carousel-LRbWqbAx.js.map +1 -0
  16. package/dist/carousel.d.ts +2 -0
  17. package/dist/carousel.js +1 -0
  18. package/dist/cascade-B155Xvvv.js +64 -0
  19. package/dist/cascade-B155Xvvv.js.map +1 -0
  20. package/dist/cascade.d.ts +2 -0
  21. package/dist/cascade.js +1 -0
  22. package/dist/clipboard-Cy2cbGEW.js +33 -0
  23. package/dist/clipboard-Cy2cbGEW.js.map +1 -0
  24. package/dist/clipboard.d.ts +2 -0
  25. package/dist/clipboard.js +1 -0
  26. package/dist/collection-Dbk-PB5S.js +609 -0
  27. package/dist/collection-Dbk-PB5S.js.map +1 -0
  28. package/dist/collection.d.ts +2 -0
  29. package/dist/collection.js +3 -0
  30. package/dist/color-sURV5Irg.js +699 -0
  31. package/dist/color-sURV5Irg.js.map +1 -0
  32. package/dist/color.d.ts +2 -0
  33. package/dist/color.js +1 -0
  34. package/dist/command-DueCXi65.js +104 -0
  35. package/dist/command-DueCXi65.js.map +1 -0
  36. package/dist/command.d.ts +2 -0
  37. package/dist/command.js +1 -0
  38. package/dist/date-CrbFSJKQ.js +215 -0
  39. package/dist/date-CrbFSJKQ.js.map +1 -0
  40. package/dist/date.d.ts +4 -0
  41. package/dist/date.js +1 -0
  42. package/dist/direction-CTnVLpmd.d.ts +8 -0
  43. package/dist/direction-DJDPvnxJ.js +13 -0
  44. package/dist/direction-DJDPvnxJ.js.map +1 -0
  45. package/dist/direction.d.ts +2 -0
  46. package/dist/direction.js +1 -0
  47. package/dist/drag-session-CSr06B5v.js +41 -0
  48. package/dist/drag-session-CSr06B5v.js.map +1 -0
  49. package/dist/file-DSLtfzbi.js +263 -0
  50. package/dist/file-DSLtfzbi.js.map +1 -0
  51. package/dist/file.d.ts +2 -0
  52. package/dist/file.js +1 -0
  53. package/dist/focus-BI-VvM0f.js +75 -0
  54. package/dist/focus-BI-VvM0f.js.map +1 -0
  55. package/dist/focus.d.ts +2 -0
  56. package/dist/focus.js +3 -0
  57. package/dist/form-DovwKtqz.js +501 -0
  58. package/dist/form-DovwKtqz.js.map +1 -0
  59. package/dist/form.d.ts +2 -0
  60. package/dist/form.js +1 -0
  61. package/dist/hover-BakyPYnC.js +62 -0
  62. package/dist/hover-BakyPYnC.js.map +1 -0
  63. package/dist/hover.d.ts +2 -0
  64. package/dist/hover.js +1 -0
  65. package/dist/id-B0Y8iZrc.js +13 -0
  66. package/dist/id-B0Y8iZrc.js.map +1 -0
  67. package/dist/id.d.ts +2 -0
  68. package/dist/id.js +1 -0
  69. package/dist/image-D4X_yRYw.js +44 -0
  70. package/dist/image-D4X_yRYw.js.map +1 -0
  71. package/dist/image.d.ts +2 -0
  72. package/dist/image.js +1 -0
  73. package/dist/index-B0rwIZw9.d.ts +51 -0
  74. package/dist/index-B4wF1isn.d.ts +128 -0
  75. package/dist/index-BHiBRE01.d.ts +20 -0
  76. package/dist/index-BNlMm-0u.d.ts +17 -0
  77. package/dist/index-BapNrjY9.d.ts +48 -0
  78. package/dist/index-Bd-tVb7C.d.ts +6 -0
  79. package/dist/index-BjE8nDiX.d.ts +125 -0
  80. package/dist/index-BpbT-FsX.d.ts +117 -0
  81. package/dist/index-CBgGcTeX.d.ts +37 -0
  82. package/dist/index-CGThV_Md.d.ts +100 -0
  83. package/dist/index-CMig3TXL.d.ts +28 -0
  84. package/dist/index-CWFRduRd.d.ts +212 -0
  85. package/dist/index-CkrHWyU_.d.ts +33 -0
  86. package/dist/index-Cwu6f7y1.d.ts +18 -0
  87. package/dist/index-D10LDdR6.d.ts +139 -0
  88. package/dist/index-D146vm21.d.ts +104 -0
  89. package/dist/index-DGKhEvNr.d.ts +107 -0
  90. package/dist/index-DbAu4s16.d.ts +48 -0
  91. package/dist/index-DdaCj6IO.d.ts +54 -0
  92. package/dist/index-DeHcNdjC.d.ts +68 -0
  93. package/dist/index-DeR4ncrW.d.ts +93 -0
  94. package/dist/index-HIksgK0e.d.ts +70 -0
  95. package/dist/index-IZB0mlZl.d.ts +71 -0
  96. package/dist/index-IfDZj87U.d.ts +28 -0
  97. package/dist/index-SrTuVBms.d.ts +75 -0
  98. package/dist/index-T9UcYvkf.d.ts +339 -0
  99. package/dist/index-fRTojAoR.d.ts +31 -0
  100. package/dist/index-fuLUke9n.d.ts +6 -0
  101. package/dist/index-l63esAck.d.ts +104 -0
  102. package/dist/index-raSUg9U7.d.ts +38 -0
  103. package/dist/index-twgzPKvZ.d.ts +278 -0
  104. package/dist/index-wBpjRykh.d.ts +125 -0
  105. package/dist/index.d.ts +39 -0
  106. package/dist/index.js +42 -0
  107. package/dist/inert-DlGToy3q.js +80 -0
  108. package/dist/inert-DlGToy3q.js.map +1 -0
  109. package/dist/inert.d.ts +2 -0
  110. package/dist/inert.js +1 -0
  111. package/dist/layer-stack-BEtzaFC1.js +118 -0
  112. package/dist/layer-stack-BEtzaFC1.js.map +1 -0
  113. package/dist/layers-C-N4rrZX.js +24 -0
  114. package/dist/layers-C-N4rrZX.js.map +1 -0
  115. package/dist/layers.d.ts +2 -0
  116. package/dist/layers.js +3 -0
  117. package/dist/list-navigation-CbWv4DK5.js +40 -0
  118. package/dist/list-navigation-CbWv4DK5.js.map +1 -0
  119. package/dist/month-year-BG5imFUq.js +108 -0
  120. package/dist/month-year-BG5imFUq.js.map +1 -0
  121. package/dist/month-year.d.ts +3 -0
  122. package/dist/month-year.js +1 -0
  123. package/dist/number-BFUio97d.js +316 -0
  124. package/dist/number-BFUio97d.js.map +1 -0
  125. package/dist/number.d.ts +2 -0
  126. package/dist/number.js +1 -0
  127. package/dist/overlay-BwPyiM3T.js +78 -0
  128. package/dist/overlay-BwPyiM3T.js.map +1 -0
  129. package/dist/overlay.d.ts +2 -0
  130. package/dist/overlay.js +1 -0
  131. package/dist/pagination-BkVzaIGP.js +51 -0
  132. package/dist/pagination-BkVzaIGP.js.map +1 -0
  133. package/dist/pagination.d.ts +2 -0
  134. package/dist/pagination.js +1 -0
  135. package/dist/plain-date-idQH1P6X.d.ts +29 -0
  136. package/dist/plain-date-time-B8PGahhe.d.ts +99 -0
  137. package/dist/pointer-CuDtD9XA.js +189 -0
  138. package/dist/pointer-CuDtD9XA.js.map +1 -0
  139. package/dist/pointer.d.ts +2 -0
  140. package/dist/pointer.js +3 -0
  141. package/dist/positioning-DDUQ75mB.js +148 -0
  142. package/dist/positioning-DDUQ75mB.js.map +1 -0
  143. package/dist/positioning.d.ts +2 -0
  144. package/dist/positioning.js +1 -0
  145. package/dist/presence-BhKDOmII.js +86 -0
  146. package/dist/presence-BhKDOmII.js.map +1 -0
  147. package/dist/presence.d.ts +2 -0
  148. package/dist/presence.js +1 -0
  149. package/dist/range-o0_GBhyY.js +158 -0
  150. package/dist/range-o0_GBhyY.js.map +1 -0
  151. package/dist/range.d.ts +2 -0
  152. package/dist/range.js +1 -0
  153. package/dist/scroll-area-BYNhv36t.js +447 -0
  154. package/dist/scroll-area-BYNhv36t.js.map +1 -0
  155. package/dist/scroll-area.d.ts +2 -0
  156. package/dist/scroll-area.js +1 -0
  157. package/dist/scroll-lock-JzRNOA1O.js +42 -0
  158. package/dist/scroll-lock-JzRNOA1O.js.map +1 -0
  159. package/dist/scroll-lock.d.ts +2 -0
  160. package/dist/scroll-lock.js +1 -0
  161. package/dist/segments-eRu5G_Bd.js +587 -0
  162. package/dist/segments-eRu5G_Bd.js.map +1 -0
  163. package/dist/segments.d.ts +3 -0
  164. package/dist/segments.js +1 -0
  165. package/dist/selection-Cor67w_V.js +287 -0
  166. package/dist/selection-Cor67w_V.js.map +1 -0
  167. package/dist/selection.d.ts +2 -0
  168. package/dist/selection.js +1 -0
  169. package/dist/swipe.d.ts +2 -0
  170. package/dist/swipe.js +1 -0
  171. package/dist/tabbable-BPiLssIv.js +35 -0
  172. package/dist/tabbable-BPiLssIv.js.map +1 -0
  173. package/dist/time-Ct6oq9kt.js +208 -0
  174. package/dist/time-Ct6oq9kt.js.map +1 -0
  175. package/dist/time-zone-DegkzwST.js +305 -0
  176. package/dist/time-zone-DegkzwST.js.map +1 -0
  177. package/dist/time-zone.d.ts +2 -0
  178. package/dist/time-zone.js +1 -0
  179. package/dist/time.d.ts +2 -0
  180. package/dist/time.js +1 -0
  181. package/dist/toast-BjRpJalM.js +400 -0
  182. package/dist/toast-BjRpJalM.js.map +1 -0
  183. package/dist/toast.d.ts +2 -0
  184. package/dist/toast.js +1 -0
  185. package/dist/unit-grid-DJy8lb5D.d.ts +21 -0
  186. package/dist/virtual-BlX1RuHD.js +306 -0
  187. package/dist/virtual-BlX1RuHD.js.map +1 -0
  188. package/dist/virtual.d.ts +2 -0
  189. package/dist/virtual.js +1 -0
  190. package/dist/watch-swipe-BIucfr9O.js +301 -0
  191. package/dist/watch-swipe-BIucfr9O.js.map +1 -0
  192. package/package.json +234 -3
@@ -0,0 +1,415 @@
1
+ import { t as CalendarKeyOptions } from "./calendar-keys-DGYpjLwv.js";
2
+ import { n as PlainDate } from "./plain-date-idQH1P6X.js";
3
+ import { n as UnitKeyOptions } from "./unit-grid-DJy8lb5D.js";
4
+ import { f as IsoTimePrecision, h as TimeField, n as PlainDateTime, p as PlainTime, t as DateTimeDuration } from "./plain-date-time-B8PGahhe.js";
5
+ /** A month or a year of a calendar system: `{ year, month }`, or `{ year }`. */
6
+ interface CalendarUnit {
7
+ readonly year: number;
8
+ readonly month?: number;
9
+ }
10
+ /**
11
+ * The items of a month or year calendar in a calendar system (spec/calendar-systems.md, "Month and
12
+ * year calendars"), as numbers: a month's `monthIndex` (a page is its year: 12 or 13 months), or
13
+ * the year (a page of 12 from a multiple of 12, as the ISO calendar's).
14
+ */
15
+ interface CalendarUnits {
16
+ /** The number of a month or year. */
17
+ index(item: CalendarUnit): number;
18
+ /** The month or year of a number. */
19
+ item(index: number): CalendarUnit;
20
+ /** The first item of the page holding `index`. */
21
+ pageStart(index: number): number;
22
+ /** How many items the page starting at `start` holds. */
23
+ pageSize(start: number): number;
24
+ /** The first item of the next (`1`) or previous (`-1`) page (a year can have 13 months). */
25
+ page(start: number, delta: 1 | -1): number;
26
+ /** Today's month or year (the page's local date). */
27
+ today(): number;
28
+ /** The page starting at `start`, in rows of `columns`. */
29
+ rows(start: number, columns: number): number[][];
30
+ /** The item a key moves to (the ISO calendar's `unitKeyTarget`, a page being a year). */
31
+ keyTarget(key: string, focused: number, options: UnitKeyOptions): number | null;
32
+ /** The month or year of an ISO date. */
33
+ fromDate(date: PlainDate): number;
34
+ /** The ISO dates of a month or year. */
35
+ days(index: number): PlainDate[];
36
+ /**
37
+ * A CalendarView's choice of a month or year: its enabled day nearest to the focused date's
38
+ * place in it (the same day of the month, the same month and day of the year); `undefined`
39
+ * when every day is disabled.
40
+ */
41
+ nearest(index: number, focused: PlainDate, enabled: (date: PlainDate) => boolean): PlainDate | undefined;
42
+ /** A month's cell content ("Azar"), a year's ("1405"). */
43
+ text(locale: string, index: number): string;
44
+ /** A cell's name ("Azar 1405", "1405"). */
45
+ name(locale: string, index: number): string;
46
+ /** The page's heading: the year of a month page, the span of a year page ("1395 – 1406"). */
47
+ heading(locale: string, start: number): string;
48
+ /**
49
+ * The form's text: the ISO date of the first day with the system (RFC 9557, Temporal's
50
+ * `toString` of a non-ISO month): `2026-10-23[u-ca=persian]`.
51
+ */
52
+ iso(index: number): string;
53
+ }
54
+ /**
55
+ * A date and wall-clock time in a time zone (spec/time-zones.md, "Values"): a `PlainDateTime`
56
+ * with its IANA `timeZone` and the `offset` from UTC it has there, in milliseconds (positive east:
57
+ * `+05:30` is 19 800 000). The offset tells the two times of a DST overlap apart. A plain,
58
+ * immutable object: every function returns a new one.
59
+ */
60
+ interface ZonedDateTime extends PlainDateTime {
61
+ readonly timeZone: string;
62
+ readonly offset: number;
63
+ }
64
+ /**
65
+ * Which time a wall-clock time names when its zone skips it (a DST gap) or repeats it (an
66
+ * overlap), as Temporal's `disambiguation`: `compatible` (the default) takes the later one in a
67
+ * gap and the earlier in an overlap, `earlier` and `later` always that one, `reject` throws a
68
+ * `RangeError`.
69
+ */
70
+ type Disambiguation = "compatible" | "earlier" | "later" | "reject";
71
+ /**
72
+ * The zone's offset from UTC at an instant, in milliseconds, read from `Intl` (the wall-clock
73
+ * fields it writes there, less the instant).
74
+ */
75
+ declare function offsetAt(timeZone: string, epochMs: number): number;
76
+ /** The zone the page runs in (`Intl`'s default). */
77
+ declare function localTimeZone(): string;
78
+ /** The instant (epoch milliseconds) of a zoned date and time. */
79
+ declare function toInstant(value: ZonedDateTime): number;
80
+ /** The date and time an instant (epoch milliseconds or a `Date`) has in a zone. */
81
+ declare function fromInstant(instant: number | Date, timeZone: string): ZonedDateTime;
82
+ /**
83
+ * A wall-clock date and time in a zone (spec/time-zones.md, "DST gaps and overlaps"), resolved
84
+ * with `disambiguation` when the zone skips or repeats it. In a gap, `compatible` and `later` move
85
+ * it forward by the gap (02:30 becomes 03:30), `earlier` back (01:30); `reject` throws.
86
+ */
87
+ declare function toZoned(value: PlainDateTime, timeZone: string, disambiguation?: Disambiguation): ZonedDateTime;
88
+ /** The same instant in another zone. */
89
+ declare function toTimeZone(value: ZonedDateTime, timeZone: string): ZonedDateTime;
90
+ /** Negative when `a` is the earlier instant, positive when later, 0 when the same. */
91
+ declare function compareZoned(a: ZonedDateTime, b: ZonedDateTime): number;
92
+ /**
93
+ * Adds a duration as Temporal's `ZonedDateTime#add`: the years, months and days to the wall-clock
94
+ * date (resolved `compatible`, so a day added across a DST change keeps its wall time), then the
95
+ * time in exact time (an hour added across a gap is one real hour).
96
+ */
97
+ declare function addZoned(value: ZonedDateTime, duration: DateTimeDuration): ZonedDateTime;
98
+ /**
99
+ * Steps one time field and wraps within its range, carrying nothing (the date segments' and
100
+ * React Aria's `cycle`): the hour walks the day's real hours (23 on a spring-forward day, 25 on a
101
+ * fall-back one, the repeated hour twice); a minute or second keeps the offset it had when the
102
+ * wall time still exists there, else resolves with `disambiguation`.
103
+ */
104
+ declare function cycleZoned(value: ZonedDateTime, field: Exclude<TimeField, "millisecond">, amount: number, disambiguation?: Disambiguation): ZonedDateTime;
105
+ /** `+05:30`, `-04:00` (`+00:00` for UTC); seconds only when the offset has them. */
106
+ declare function toIsoOffset(offset: number): string;
107
+ /**
108
+ * `2026-03-08T03:30-04:00[America/New_York]` (RFC 9557, Temporal's `ZonedDateTime#toString`): the
109
+ * wall time (see `toIsoDateTime` for `precision`), the offset and the zone.
110
+ */
111
+ declare function toIsoZoned(value: ZonedDateTime, precision?: IsoTimePrecision): string;
112
+ /**
113
+ * Parses `YYYY-MM-DDTHH:MM[:SS[.sss]][±HH:MM][<zone>]`; the offset, when it is one the zone has
114
+ * at that wall time, picks it (one of an overlap's two), else the wall time is resolved with
115
+ * `disambiguation`. `null` when the text is not one, or its zone is unknown.
116
+ */
117
+ declare function fromIsoZoned(text: string, disambiguation?: Disambiguation): ZonedDateTime | null;
118
+ /** The zone's name at the value's instant, from `Intl` (`timeZoneName`, default `short`: "EST"). */
119
+ declare function formatTimeZoneName(locale: string, value: ZonedDateTime, style?: Intl.DateTimeFormatOptions["timeZoneName"]): string;
120
+ /**
121
+ * A time zone as a date field or picker takes it (spec/time-zones.md, "In the fields"): its id and
122
+ * the zoned math the field calls. A field given one holds `ZonedDateTime` values in that zone;
123
+ * no component imports `/time-zone`, so a field given none bundles none of it.
124
+ */
125
+ interface TimeZone {
126
+ /** The IANA id (`America/New_York`). */
127
+ readonly id: string;
128
+ /** A wall-clock date and time in this zone, resolved with `disambiguation`. */
129
+ resolve(value: PlainDateTime, disambiguation?: Disambiguation): ZonedDateTime;
130
+ /** The same instant in this zone. */
131
+ convert(value: ZonedDateTime): ZonedDateTime;
132
+ /** The date and time of an instant (epoch milliseconds or a `Date`) in this zone. */
133
+ at(instant: number | Date): ZonedDateTime;
134
+ /** The zone's short name at the value's instant ("EST", "GMT+5:30"), from `Intl`. */
135
+ name(locale: string, value: ZonedDateTime): string;
136
+ /** The value's ISO text with its offset and zone (what a form submits). */
137
+ toIso(value: ZonedDateTime, precision?: IsoTimePrecision): string;
138
+ /**
139
+ * A wall time chosen (a picker's date, a segment's sample): resolved with `disambiguation`,
140
+ * `reject` read as `compatible`, so a choice always has a value.
141
+ */
142
+ choose(value: PlainDateTime, disambiguation?: Disambiguation): ZonedDateTime;
143
+ /** A value as this zone's wall time: a zoned one from another zone at its instant here. */
144
+ wallTime<Value extends Partial<PlainDateTime>>(value: Value): Value;
145
+ /**
146
+ * The text of a part the zone writes: its name segment's (`timeZoneName`) at a sample's wall
147
+ * time (its UTC fields); `undefined` for any other part.
148
+ */
149
+ segmentText(format: SegmentFormat, type: SegmentType, sample: Date): string | undefined;
150
+ /** The zoned value of a typed wall time, with the format's `disambiguation` (`null`: rejected). */
151
+ segmentsToDateTime(format: SegmentFormat, date: PlainDate, time: PlainTime): ZonedDateTime | null;
152
+ /** The Intl options of a field's format, with the zone's name where a date and time shows it. */
153
+ segmentOptions(options: SegmentFormatOptions, intl: Intl.DateTimeFormatOptions): Intl.DateTimeFormatOptions;
154
+ }
155
+ /** The time zone `id` (default: the page's own) for a date field or picker's `timeZone`. */
156
+ declare function timeZone(id?: string): TimeZone;
157
+ /** What a segment of a date or time field shows (spec/date-field.md, "Segments"). */
158
+ type SegmentType = "era" | "year" | "month" | "day" | "hour" | "minute" | "second" | "dayPeriod" | "timeZoneName" | "literal";
159
+ /**
160
+ * The segments the user edits; the others (`literal`, `timeZoneName`) are only shown, and an
161
+ * `era` only in a calendar system of several eras (spec/calendar-systems.md, "In the fields").
162
+ */
163
+ type EditableSegmentType = "era" | "year" | "month" | "day" | "hour" | "minute" | "second" | "dayPeriod";
164
+ /** The smallest unit a field edits: `day` for a date alone, else the time down to it. */
165
+ type SegmentGranularity = "day" | "hour" | "minute" | "second";
166
+ /** What a field holds: a date (and, finer than `day`, its time) or a time alone. */
167
+ type SegmentKind = "date" | "time";
168
+ /** `Intl`'s hour cycles: 0–11, 1–12, 0–23, 1–24. */
169
+ type HourCycle = "h11" | "h12" | "h23" | "h24";
170
+ interface SegmentFormatOptions {
171
+ /** BCP 47. */
172
+ readonly locale: string;
173
+ readonly kind: SegmentKind;
174
+ /** Default: `day` for a date, `minute` for a time (a time's `day` reads as `minute`). */
175
+ readonly granularity?: SegmentGranularity | undefined;
176
+ /** `12` or `24` (the locale picks `h11` or `h12` for 12), or an exact cycle; default: the locale's. */
177
+ readonly hourCycle?: 12 | 24 | HourCycle | undefined;
178
+ /**
179
+ * A calendar system (spec/calendar-systems.md): the segments show and edit its fields; values
180
+ * stay ISO. Default: none (the ISO calendar, as the locale writes it).
181
+ */
182
+ readonly calendar?: CalendarSystem | undefined;
183
+ /**
184
+ * A time zone (spec/time-zones.md): the values are `ZonedDateTime`s in it, and a date and
185
+ * time shows a `timeZoneName` segment unless `hideTimeZone`.
186
+ */
187
+ readonly timeZone?: TimeZone | undefined;
188
+ readonly hideTimeZone?: boolean | undefined;
189
+ /** How a wall time the zone skips or repeats resolves (default `compatible`). */
190
+ readonly disambiguation?: Disambiguation | undefined;
191
+ }
192
+ /** One piece of the format, in the locale's order: a segment, or the literal text between. */
193
+ interface SegmentPart {
194
+ readonly type: SegmentType;
195
+ /** The text of a `literal` (or `era`) part, as `Intl` writes it; `""` for the others. */
196
+ readonly literal: string;
197
+ }
198
+ /**
199
+ * A field's format for a locale (from `Intl.DateTimeFormat#formatToParts`): the order of its
200
+ * segments and the literals between them, its hour cycle, its digits and the texts `Intl` gives
201
+ * for the day periods and the segments' names. Built once per locale and options.
202
+ */
203
+ interface SegmentFormat {
204
+ readonly locale: string;
205
+ readonly kind: SegmentKind;
206
+ readonly granularity: SegmentGranularity;
207
+ readonly parts: readonly SegmentPart[];
208
+ /** The editable segments, in the locale's order. */
209
+ readonly types: readonly EditableSegmentType[];
210
+ /** `null` when the format has no hour. */
211
+ readonly hourCycle: HourCycle | null;
212
+ /** The locale's ten digits, 0 to 9 (`Intl`'s numbering system). */
213
+ readonly digits: readonly string[];
214
+ /** The day period texts, AM then PM (`["", ""]` when the format has none). */
215
+ readonly dayPeriods: readonly [string, string];
216
+ /** Each segment's name, from `Intl.DisplayNames` (`dateTimeField`), when the engine has it. */
217
+ readonly names: Readonly<Partial<Record<SegmentType, string>>>;
218
+ /** Formats a UTC date in the field's segments (`timeZone: "UTC"`). */
219
+ readonly formatter: Intl.DateTimeFormat;
220
+ /** Formats a UTC date's month name (`month: "long"`), the month's `aria-valuetext`. */
221
+ readonly monthNames: Intl.DateTimeFormat;
222
+ /** The calendar system, when the field has one. */
223
+ readonly calendar?: CalendarSystem | undefined;
224
+ /** The eras' names (`era: "short"`), oldest first, when the era is editable. */
225
+ readonly eras?: readonly string[] | undefined;
226
+ /** The time zone, when the field holds zoned values. */
227
+ readonly timeZone?: TimeZone | undefined;
228
+ readonly disambiguation?: Disambiguation | undefined;
229
+ }
230
+ /**
231
+ * The format of a date or time field in a locale (spec/date-field.md, "Segments"): the parts of
232
+ * `Intl.DateTimeFormat#formatToParts` for the field's segments, in the locale's order, with its
233
+ * literals, hour cycle and digits.
234
+ */
235
+ declare function segmentFormat(options: SegmentFormatOptions): SegmentFormat;
236
+ /**
237
+ * What the user has set of a field, segment by segment (spec/date-field.md, "Editing"): a
238
+ * segment left out is a placeholder. `hour` is 0–23 whatever the hour cycle; `dayPeriod` (0 AM,
239
+ * 1 PM) is kept only once the user set it (with an hour set, the hour's half of the day agrees
240
+ * with it). A plain, immutable object: every function returns a new one.
241
+ */
242
+ type SegmentValues = { readonly [type in EditableSegmentType]?: number; };
243
+ /** A segment's range, in the unit it shows (an hour in its cycle: 1–12 for `h12`). */
244
+ interface SegmentRange {
245
+ readonly min: number;
246
+ readonly max: number;
247
+ /** The most digits it is typed with (`0` for the day period, typed by a letter). */
248
+ readonly digits: number;
249
+ }
250
+ /** The amount Page Up and Page Down step a segment by (spec/date-field.md, "Keyboard"). */
251
+ declare const SEGMENT_PAGE_STEPS: Readonly<Record<EditableSegmentType, number>>;
252
+ /** The range of a segment, given what else is set (a day's maximum follows its month and year). */
253
+ declare function segmentRange(format: SegmentFormat, values: SegmentValues, type: EditableSegmentType): SegmentRange;
254
+ /** The hour as its cycle shows it (`h12`: 0 → 12, 13 → 1). */
255
+ declare function displayHour(hour: number, cycle: HourCycle | null): number;
256
+ /** A segment's value in the unit it shows; `undefined` while it is a placeholder. */
257
+ declare function shownValue(format: SegmentFormat, values: SegmentValues, type: EditableSegmentType): number | undefined;
258
+ /**
259
+ * Sets a segment to a value in the unit it shows (an hour in its cycle, kept in its half of the
260
+ * day; a day period moves a set hour into its half), or clears it with `undefined`. A day past
261
+ * its month's end is clamped into it.
262
+ */
263
+ declare function setSegment(format: SegmentFormat, values: SegmentValues, type: EditableSegmentType, shown: number | undefined, seed?: SegmentValues): SegmentValues;
264
+ /**
265
+ * Steps a segment by `amount`, wrapping within its range and carrying nothing into the others (an
266
+ * hour of a 12-hour cycle stays in its half of the day; the day period toggles). A placeholder
267
+ * takes the seed's value instead (the field's `placeholderValue`), with no step.
268
+ */
269
+ declare function stepSegment(format: SegmentFormat, values: SegmentValues, type: EditableSegmentType, amount: number, seed?: SegmentValues): SegmentValues;
270
+ /** Sets a segment to the edge of its range (Home: `min`, End: `max`). */
271
+ declare function segmentToEdge(format: SegmentFormat, values: SegmentValues, type: EditableSegmentType, edge: "min" | "max", seed?: SegmentValues): SegmentValues;
272
+ /** Whether every editable segment of the format is set. */
273
+ declare function isSegmentsComplete(format: SegmentFormat, values: SegmentValues): boolean;
274
+ /**
275
+ * The segment values of a date, a time or a date and time (only the format's segments; a day
276
+ * period follows the hour). `null` gives no value: every segment a placeholder.
277
+ */
278
+ declare function segmentValuesOf(format: SegmentFormat, input: Partial<PlainDateTime> | null | undefined): SegmentValues;
279
+ /**
280
+ * The date of complete values (`null` while a date segment is a placeholder); with a calendar
281
+ * system's `format`, the ISO date of its fields (its hook).
282
+ */
283
+ declare function segmentsToDate(values: SegmentValues, format?: SegmentFormat): PlainDate | null;
284
+ /** The time of values (the segments a format has not are 0); `null` with no hour. */
285
+ declare function segmentsToTime(values: SegmentValues): PlainTime | null;
286
+ /**
287
+ * The date and time of values; `null` while the date or the hour is a placeholder. With a time
288
+ * zone's `format`, a `ZonedDateTime` resolved with its `disambiguation` (`null` when `reject`
289
+ * meets a wall time the zone skips or repeats).
290
+ */
291
+ declare function segmentsToDateTime(values: SegmentValues, format?: SegmentFormat): PlainDateTime | null;
292
+ /**
293
+ * The format in the system: its era is editable where the system has several (a Japanese date's),
294
+ * with the eras' names (`era: "short"`), oldest first.
295
+ */
296
+ declare function segmentCalendarFormat(format: SegmentFormat): SegmentFormat;
297
+ /** The range of the era, the month (13 in a Hebrew leap year) and the day; none for the time. */
298
+ declare function segmentCalendarRange(format: SegmentFormat, values: SegmentValues, type: EditableSegmentType): SegmentRange | undefined;
299
+ /**
300
+ * The values, completed where they are placeholders, as the UTC date `Intl` formats: the longest
301
+ * year (a day set with no year keeps the longest month), an era set with no year its second year
302
+ * (wholly in it).
303
+ */
304
+ declare function segmentCalendarSample(format: SegmentFormat, values: SegmentValues): Date;
305
+ /** A value with its ISO date as the system's fields (the era's year where the era is edited). */
306
+ declare function segmentCalendarFields(format: SegmentFormat, value: Partial<PlainDateTime>): Partial<PlainDateTime> & {
307
+ era?: number;
308
+ };
309
+ /** The ISO date of the values' fields; `null` while a date segment is a placeholder. */
310
+ declare function segmentCalendarDate(format: SegmentFormat, values: SegmentValues): PlainDate | null;
311
+ /** The calendar systems of spec/calendar-systems.md, by their `Intl` (CLDR) identifier. */
312
+ type CalendarId = "gregory" | "buddhist" | "japanese" | "roc" | "persian" | "indian" | "islamic-civil" | "islamic-tbla" | "islamic-umalqura" | "hebrew" | "coptic" | "ethiopic" | "ethioaa";
313
+ /**
314
+ * An ISO date's fields in a calendar system (spec/calendar-systems.md, "Fields"). `year` is the
315
+ * system's arithmetic year (it keeps counting across eras: Temporal's `year`); `era` is an index
316
+ * into the system's eras (oldest first) and `eraYear` the year within it, as `Intl` writes it;
317
+ * `month` is the month's place in its year (1–13: a Hebrew leap year's Adar I is 6).
318
+ */
319
+ interface CalendarDateFields {
320
+ readonly era: number;
321
+ readonly eraYear: number;
322
+ readonly year: number;
323
+ readonly month: number;
324
+ readonly day: number;
325
+ }
326
+ /** A month of a calendar system: its arithmetic year and its place in the year. */
327
+ interface CalendarYearMonth {
328
+ readonly year: number;
329
+ readonly month: number;
330
+ }
331
+ /**
332
+ * The fields a date is built from: the arithmetic `year`, or an `era` and its `eraYear`; a month
333
+ * or day past its year's or month's end is clamped into it (Temporal's `constrain`).
334
+ */
335
+ interface CalendarFieldsInput {
336
+ readonly year?: number;
337
+ readonly era?: number;
338
+ readonly eraYear?: number;
339
+ readonly month: number;
340
+ readonly day: number;
341
+ }
342
+ /**
343
+ * A calendar system (spec/calendar-systems.md): the date math and the names of a non-Gregorian
344
+ * calendar over ISO dates. Values stay ISO `PlainDate`s; a component given one shows and moves
345
+ * through its months and years. Each system is its own export of `@fragiola/primitives/calendar-systems`,
346
+ * so an app pays only for the systems it imports, and one that passes none pays nothing.
347
+ */
348
+ interface CalendarSystem {
349
+ readonly id: CalendarId;
350
+ /** `locale` with this calendar (`-u-ca-<id>`): `Intl` writes its names. */
351
+ locale(locale: string): string;
352
+ /** The fields of an ISO date. */
353
+ fields(date: PlainDate): CalendarDateFields;
354
+ /** The ISO date of fields (clamped into the month and year). */
355
+ fromFields(fields: CalendarFieldsInput): PlainDate;
356
+ /** How many eras the system has (era segments are editable when more than one). */
357
+ eraCount(): number;
358
+ /** The arithmetic year of an era's year. */
359
+ yearOfEra(era: number, eraYear: number): number;
360
+ /** An era's name from `Intl` (`era: "short"`). */
361
+ eraName(locale: string, era: number): string;
362
+ monthsInYear(year: number): number;
363
+ daysInMonth(year: number, month: number): number;
364
+ /**
365
+ * A year whose months are the longest the system has (a leap year), for a month or day
366
+ * typed before its year.
367
+ */
368
+ referenceYear(): number;
369
+ startOfMonth(date: PlainDate): PlainDate;
370
+ endOfMonth(date: PlainDate): PlainDate;
371
+ /** The same day `months` later, clamped to the target month's last day. */
372
+ addMonths(date: PlainDate, months: number): PlainDate;
373
+ /** The same month and day `years` later (a leap month to its common year's month), clamped. */
374
+ addYears(date: PlainDate, years: number): PlainDate;
375
+ /** The difference in whole months from `a`'s month to `b`'s month. */
376
+ monthsBetween(a: PlainDate, b: PlainDate): number;
377
+ isSameMonth(a: PlainDate, b: PlainDate): boolean;
378
+ /** The 6 weeks shown for the month holding `date`, from the locale's first day. */
379
+ monthGrid(date: PlainDate, firstDayOfWeek: number): PlainDate[][];
380
+ /** `calendarKeyTarget` (`/date`) in this system: Page Up and Down move by its months and years. */
381
+ keyTarget(key: string, focused: PlainDate, options: CalendarKeyOptions): PlainDate | null;
382
+ /** A month as one number (its months counted from the system's year 0): `+ 1` is the next. */
383
+ monthIndex(month: CalendarYearMonth): number;
384
+ fromMonthIndex(index: number): CalendarYearMonth;
385
+ /** The ISO date of a month's first day. */
386
+ monthStart(month: CalendarYearMonth): PlainDate;
387
+ /** The month of an ISO date. */
388
+ yearMonthOf(date: PlainDate): CalendarYearMonth;
389
+ /**
390
+ * A day cell's name: the weekday, day, month and year in this system. Its fields are explicit
391
+ * (not `dateStyle: "full"`): Chromium's ICU has no Hebrew-calendar `he` date styles and writes
392
+ * `57870310 12:00 AM` for them (spec/calendar-systems.md, "Recorded limits").
393
+ */
394
+ fullDate(locale: string, date: PlainDate): string;
395
+ /** An ISO date written by `Intl` in this system (`timeZone: "UTC"`: no host zone moves it). */
396
+ format(locale: string, date: PlainDate, options: Intl.DateTimeFormatOptions): string;
397
+ /**
398
+ * `Intl.DateTimeFormat#formatRange` of two ISO dates in this system, every space written as
399
+ * U+0020 (engines differ on the spaces around the dash: the `/month-year` year span's rule).
400
+ */
401
+ formatRange(locale: string, start: PlainDate, end: PlainDate, options: Intl.DateTimeFormatOptions): string;
402
+ /** The items of a month or year calendar in this system (cached per kind). */
403
+ units(kind: "month" | "year"): CalendarUnits;
404
+ /** A field's format in this system: the era editable where it has several, their names. */
405
+ segmentFormat: typeof segmentCalendarFormat;
406
+ /** The range of the era, month and day segments (`undefined` for the others). */
407
+ segmentRange: typeof segmentCalendarRange;
408
+ /** Segment values as the UTC date `Intl` formats, completed where they are placeholders. */
409
+ segmentSample: typeof segmentCalendarSample;
410
+ /** A value's date as this system's fields (`segmentValuesOf`). */
411
+ segmentValuesOf: typeof segmentCalendarFields;
412
+ /** The ISO date of segment values (`segmentsToDate`); `null` while one is a placeholder. */
413
+ segmentsToDate: typeof segmentCalendarDate;
414
+ }
415
+ export { timeZone as A, offsetAt as B, SegmentFormatOptions as C, SegmentType as D, SegmentPart as E, cycleZoned as F, toZoned as G, toIsoOffset as H, formatTimeZoneName as I, CalendarUnit as K, fromInstant as L, ZonedDateTime as M, addZoned as N, segmentFormat as O, compareZoned as P, fromIsoZoned as R, SegmentFormat as S, SegmentKind as T, toIsoZoned as U, toInstant as V, toTimeZone as W, setSegment as _, CalendarYearMonth as a, EditableSegmentType as b, SegmentValues as c, segmentRange as d, segmentToEdge as f, segmentsToTime as g, segmentsToDateTime as h, CalendarSystem as i, Disambiguation as j, TimeZone as k, displayHour as l, segmentsToDate as m, CalendarFieldsInput as n, SEGMENT_PAGE_STEPS as o, segmentValuesOf as p, CalendarUnits as q, CalendarId as r, SegmentRange as s, CalendarDateFields as t, isSegmentsComplete as u, shownValue as v, SegmentGranularity as w, HourCycle as x, stepSegment as y, localTimeZone as z };