@zealakit/chrono-react 0.0.0-stage → 1.0.0-beta.2

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 (363) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +625 -2
  3. package/dist/calendar/components.d.ts +346 -0
  4. package/dist/calendar/components.js +243 -0
  5. package/dist/calendar/context.d.ts +636 -0
  6. package/dist/calendar/context.js +21 -0
  7. package/dist/calendar/index.d.ts +6 -0
  8. package/dist/calendar/index.js +6 -0
  9. package/dist/calendar/mini-calendar.d.ts +60 -0
  10. package/dist/calendar/mini-calendar.js +51 -0
  11. package/dist/calendar/options.d.ts +4 -0
  12. package/dist/calendar/options.js +98 -0
  13. package/dist/calendar/use-calendar.d.ts +340 -0
  14. package/dist/calendar/use-calendar.js +154 -0
  15. package/dist/calendar/use-mini-calendar.d.ts +302 -0
  16. package/dist/calendar/use-mini-calendar.js +56 -0
  17. package/dist/calendar/utilities.d.ts +9 -0
  18. package/dist/calendar/utilities.js +8 -0
  19. package/dist/date/bind-panel.d.ts +30 -0
  20. package/dist/date/bind-panel.js +125 -0
  21. package/dist/date/components.d.ts +197 -0
  22. package/dist/date/components.js +193 -0
  23. package/dist/date/context.d.ts +34 -0
  24. package/dist/date/context.js +19 -0
  25. package/dist/date/index.d.ts +4 -0
  26. package/dist/date/index.js +4 -0
  27. package/dist/date/options.d.ts +7 -0
  28. package/dist/date/options.js +91 -0
  29. package/dist/date/use-date-input.d.ts +43 -0
  30. package/dist/date/use-date-input.js +138 -0
  31. package/dist/date/use-date-panel.d.ts +81 -0
  32. package/dist/date/use-date-panel.js +21 -0
  33. package/dist/date/utilities.d.ts +4 -0
  34. package/dist/date/utilities.js +4 -0
  35. package/dist/datetime/components.d.ts +121 -0
  36. package/dist/datetime/components.js +164 -0
  37. package/dist/datetime/context.d.ts +8 -0
  38. package/dist/datetime/context.js +18 -0
  39. package/dist/datetime/index.d.ts +4 -0
  40. package/dist/datetime/index.js +4 -0
  41. package/dist/datetime/options.d.ts +5 -0
  42. package/dist/datetime/options.js +99 -0
  43. package/dist/datetime/use-datetime-input.d.ts +44 -0
  44. package/dist/datetime/use-datetime-input.js +145 -0
  45. package/dist/datetime/use-datetime-panel.d.ts +128 -0
  46. package/dist/datetime/use-datetime-panel.js +60 -0
  47. package/dist/datetime/utilities.d.ts +4 -0
  48. package/dist/datetime/utilities.js +4 -0
  49. package/dist/index.d.ts +4 -0
  50. package/dist/index.js +4 -0
  51. package/dist/shared/defined-options.d.ts +18 -0
  52. package/dist/shared/defined-options.js +9 -0
  53. package/dist/shared/merge-props.d.ts +9 -0
  54. package/dist/shared/merge-props.js +31 -0
  55. package/dist/shared/modifiers.d.ts +7 -0
  56. package/dist/shared/modifiers.js +6 -0
  57. package/dist/shared/part.d.ts +10 -0
  58. package/dist/shared/part.js +9 -0
  59. package/dist/shared/slot.d.ts +12 -0
  60. package/dist/shared/slot.js +57 -0
  61. package/dist/shared/style-properties.d.ts +8 -0
  62. package/dist/shared/style-properties.js +13 -0
  63. package/dist/shared/to-react-props.d.ts +11 -0
  64. package/dist/shared/to-react-props.js +27 -0
  65. package/dist/time/bind-panel.d.ts +19 -0
  66. package/dist/time/bind-panel.js +97 -0
  67. package/dist/time/components.d.ts +183 -0
  68. package/dist/time/components.js +169 -0
  69. package/dist/time/context.d.ts +24 -0
  70. package/dist/time/context.js +19 -0
  71. package/dist/time/index.d.ts +4 -0
  72. package/dist/time/index.js +4 -0
  73. package/dist/time/options.d.ts +5 -0
  74. package/dist/time/options.js +85 -0
  75. package/dist/time/use-time-input.d.ts +43 -0
  76. package/dist/time/use-time-input.js +138 -0
  77. package/dist/time/use-time-panel.d.ts +37 -0
  78. package/dist/time/use-time-panel.js +18 -0
  79. package/dist/time/utilities.d.ts +4 -0
  80. package/dist/time/utilities.js +4 -0
  81. package/dist/vendor/core/calendar/availability.d.ts +39 -0
  82. package/dist/vendor/core/calendar/availability.js +73 -0
  83. package/dist/vendor/core/calendar/controllers/calendar-controller.d.ts +251 -0
  84. package/dist/vendor/core/calendar/controllers/calendar-controller.js +1396 -0
  85. package/dist/vendor/core/calendar/controllers/drag-engine.d.ts +99 -0
  86. package/dist/vendor/core/calendar/controllers/drag-engine.js +363 -0
  87. package/dist/vendor/core/calendar/controllers/mini-calendar-controller.d.ts +66 -0
  88. package/dist/vendor/core/calendar/controllers/mini-calendar-controller.js +171 -0
  89. package/dist/vendor/core/calendar/controllers/shared.d.ts +33 -0
  90. package/dist/vendor/core/calendar/controllers/shared.js +82 -0
  91. package/dist/vendor/core/calendar/events/agenda-layout.d.ts +21 -0
  92. package/dist/vendor/core/calendar/events/agenda-layout.js +72 -0
  93. package/dist/vendor/core/calendar/events/all-day-row.d.ts +22 -0
  94. package/dist/vendor/core/calendar/events/all-day-row.js +93 -0
  95. package/dist/vendor/core/calendar/events/background-layout.d.ts +66 -0
  96. package/dist/vendor/core/calendar/events/background-layout.js +106 -0
  97. package/dist/vendor/core/calendar/events/index.d.ts +17 -0
  98. package/dist/vendor/core/calendar/events/index.js +8 -0
  99. package/dist/vendor/core/calendar/events/month-layout.d.ts +13 -0
  100. package/dist/vendor/core/calendar/events/month-layout.js +157 -0
  101. package/dist/vendor/core/calendar/events/normalize.d.ts +33 -0
  102. package/dist/vendor/core/calendar/events/normalize.js +156 -0
  103. package/dist/vendor/core/calendar/events/now-indicator.d.ts +18 -0
  104. package/dist/vendor/core/calendar/events/now-indicator.js +19 -0
  105. package/dist/vendor/core/calendar/events/overflow.d.ts +36 -0
  106. package/dist/vendor/core/calendar/events/overflow.js +112 -0
  107. package/dist/vendor/core/calendar/events/sort.d.ts +21 -0
  108. package/dist/vendor/core/calendar/events/sort.js +35 -0
  109. package/dist/vendor/core/calendar/events/time-grid-layout.d.ts +22 -0
  110. package/dist/vendor/core/calendar/events/time-grid-layout.js +177 -0
  111. package/dist/vendor/core/calendar/events/types.d.ts +141 -0
  112. package/dist/vendor/core/calendar/events/types.js +1 -0
  113. package/dist/vendor/core/calendar/index.d.ts +70 -0
  114. package/dist/vendor/core/calendar/index.js +37 -0
  115. package/dist/vendor/core/calendar/interaction/auto-scroll.d.ts +11 -0
  116. package/dist/vendor/core/calendar/interaction/auto-scroll.js +37 -0
  117. package/dist/vendor/core/calendar/interaction/drag-geometry.d.ts +52 -0
  118. package/dist/vendor/core/calendar/interaction/drag-geometry.js +122 -0
  119. package/dist/vendor/core/calendar/interaction/drag-keyboard.d.ts +38 -0
  120. package/dist/vendor/core/calendar/interaction/drag-keyboard.js +53 -0
  121. package/dist/vendor/core/calendar/interaction/drag-pointer.d.ts +24 -0
  122. package/dist/vendor/core/calendar/interaction/drag-pointer.js +43 -0
  123. package/dist/vendor/core/calendar/interaction/event-focus.d.ts +28 -0
  124. package/dist/vendor/core/calendar/interaction/event-focus.js +44 -0
  125. package/dist/vendor/core/calendar/interaction/gesture-handle.d.ts +17 -0
  126. package/dist/vendor/core/calendar/interaction/gesture-handle.js +26 -0
  127. package/dist/vendor/core/calendar/interaction/hit-test.d.ts +17 -0
  128. package/dist/vendor/core/calendar/interaction/hit-test.js +26 -0
  129. package/dist/vendor/core/calendar/interaction/pending.d.ts +17 -0
  130. package/dist/vendor/core/calendar/interaction/pending.js +17 -0
  131. package/dist/vendor/core/calendar/interaction/pointer.d.ts +21 -0
  132. package/dist/vendor/core/calendar/interaction/pointer.js +169 -0
  133. package/dist/vendor/core/calendar/interaction/selection.d.ts +29 -0
  134. package/dist/vendor/core/calendar/interaction/selection.js +47 -0
  135. package/dist/vendor/core/calendar/internal/equal.d.ts +3 -0
  136. package/dist/vendor/core/calendar/internal/equal.js +43 -0
  137. package/dist/vendor/core/calendar/navigation/navigate.d.ts +33 -0
  138. package/dist/vendor/core/calendar/navigation/navigate.js +81 -0
  139. package/dist/vendor/core/calendar/navigation/range.d.ts +15 -0
  140. package/dist/vendor/core/calendar/navigation/range.js +52 -0
  141. package/dist/vendor/core/calendar/navigation/title.d.ts +12 -0
  142. package/dist/vendor/core/calendar/navigation/title.js +39 -0
  143. package/dist/vendor/core/calendar/navigation/view-definition.d.ts +39 -0
  144. package/dist/vendor/core/calendar/navigation/view-definition.js +62 -0
  145. package/dist/vendor/core/calendar/navigation/zoom.d.ts +5 -0
  146. package/dist/vendor/core/calendar/navigation/zoom.js +11 -0
  147. package/dist/vendor/core/calendar/recurrence/apply.d.ts +50 -0
  148. package/dist/vendor/core/calendar/recurrence/apply.js +206 -0
  149. package/dist/vendor/core/calendar/recurrence/expand.d.ts +27 -0
  150. package/dist/vendor/core/calendar/recurrence/expand.js +298 -0
  151. package/dist/vendor/core/calendar/recurrence/pack.d.ts +3 -0
  152. package/dist/vendor/core/calendar/recurrence/pack.js +248 -0
  153. package/dist/vendor/core/calendar/recurrence/rrule-types.d.ts +30 -0
  154. package/dist/vendor/core/calendar/recurrence/rrule-types.js +8 -0
  155. package/dist/vendor/core/calendar/recurrence/rrule.d.ts +12 -0
  156. package/dist/vendor/core/calendar/recurrence/rrule.js +278 -0
  157. package/dist/vendor/core/calendar/recurrence/series.d.ts +25 -0
  158. package/dist/vendor/core/calendar/recurrence/series.js +163 -0
  159. package/dist/vendor/core/calendar/recurrence/types.d.ts +30 -0
  160. package/dist/vendor/core/calendar/recurrence/types.js +1 -0
  161. package/dist/vendor/core/calendar/resources/keys.d.ts +2 -0
  162. package/dist/vendor/core/calendar/resources/keys.js +2 -0
  163. package/dist/vendor/core/calendar/resources/resource-time-grid.d.ts +7 -0
  164. package/dist/vendor/core/calendar/resources/resource-time-grid.js +129 -0
  165. package/dist/vendor/core/calendar/resources/timeline-axis.d.ts +10 -0
  166. package/dist/vendor/core/calendar/resources/timeline-axis.js +98 -0
  167. package/dist/vendor/core/calendar/resources/timeline-layout.d.ts +7 -0
  168. package/dist/vendor/core/calendar/resources/timeline-layout.js +109 -0
  169. package/dist/vendor/core/calendar/resources/tree.d.ts +10 -0
  170. package/dist/vendor/core/calendar/resources/tree.js +86 -0
  171. package/dist/vendor/core/calendar/resources/types.d.ts +177 -0
  172. package/dist/vendor/core/calendar/resources/types.js +1 -0
  173. package/dist/vendor/core/calendar/resources/views.d.ts +7 -0
  174. package/dist/vendor/core/calendar/resources/views.js +45 -0
  175. package/dist/vendor/core/calendar/resources/windowing.d.ts +11 -0
  176. package/dist/vendor/core/calendar/resources/windowing.js +17 -0
  177. package/dist/vendor/core/calendar/views/day.d.ts +37 -0
  178. package/dist/vendor/core/calendar/views/day.js +36 -0
  179. package/dist/vendor/core/calendar/views/list-layout.d.ts +8 -0
  180. package/dist/vendor/core/calendar/views/list-layout.js +5 -0
  181. package/dist/vendor/core/calendar/views/mini-calendar.d.ts +23 -0
  182. package/dist/vendor/core/calendar/views/mini-calendar.js +31 -0
  183. package/dist/vendor/core/calendar/views/month-layout.d.ts +30 -0
  184. package/dist/vendor/core/calendar/views/month-layout.js +63 -0
  185. package/dist/vendor/core/calendar/views/time-grid-layout.d.ts +26 -0
  186. package/dist/vendor/core/calendar/views/time-grid-layout.js +27 -0
  187. package/dist/vendor/core/date/index.d.ts +9 -0
  188. package/dist/vendor/core/date/index.js +9 -0
  189. package/dist/vendor/core/date/input/date-input-controller.d.ts +97 -0
  190. package/dist/vendor/core/date/input/date-input-controller.js +466 -0
  191. package/dist/vendor/core/date/input/date-range-input-controller.d.ts +43 -0
  192. package/dist/vendor/core/date/input/date-range-input-controller.js +186 -0
  193. package/dist/vendor/core/date/input/parse.d.ts +22 -0
  194. package/dist/vendor/core/date/input/parse.js +78 -0
  195. package/dist/vendor/core/date/input/validity.d.ts +6 -0
  196. package/dist/vendor/core/date/input/validity.js +13 -0
  197. package/dist/vendor/core/date/panel/panel-controller.d.ts +176 -0
  198. package/dist/vendor/core/date/panel/panel-controller.js +704 -0
  199. package/dist/vendor/core/date/presets.d.ts +22 -0
  200. package/dist/vendor/core/date/presets.js +103 -0
  201. package/dist/vendor/core/date/selection/multiple.d.ts +7 -0
  202. package/dist/vendor/core/date/selection/multiple.js +29 -0
  203. package/dist/vendor/core/date/selection/range.d.ts +29 -0
  204. package/dist/vendor/core/date/selection/range.js +35 -0
  205. package/dist/vendor/core/date/types.d.ts +12 -0
  206. package/dist/vendor/core/date/types.js +1 -0
  207. package/dist/vendor/core/datetime/compose.d.ts +24 -0
  208. package/dist/vendor/core/datetime/compose.js +49 -0
  209. package/dist/vendor/core/datetime/constraints.d.ts +42 -0
  210. package/dist/vendor/core/datetime/constraints.js +56 -0
  211. package/dist/vendor/core/datetime/index.d.ts +9 -0
  212. package/dist/vendor/core/datetime/index.js +9 -0
  213. package/dist/vendor/core/datetime/input/datetime-input-controller.d.ts +96 -0
  214. package/dist/vendor/core/datetime/input/datetime-input-controller.js +380 -0
  215. package/dist/vendor/core/datetime/input/datetime-range-input-controller.d.ts +46 -0
  216. package/dist/vendor/core/datetime/input/datetime-range-input-controller.js +171 -0
  217. package/dist/vendor/core/datetime/input/parse.d.ts +20 -0
  218. package/dist/vendor/core/datetime/input/parse.js +56 -0
  219. package/dist/vendor/core/datetime/panel/controller.d.ts +64 -0
  220. package/dist/vendor/core/datetime/panel/controller.js +191 -0
  221. package/dist/vendor/core/datetime/panel/range-controller.d.ts +71 -0
  222. package/dist/vendor/core/datetime/panel/range-controller.js +205 -0
  223. package/dist/vendor/core/datetime/types.d.ts +12 -0
  224. package/dist/vendor/core/datetime/types.js +1 -0
  225. package/dist/vendor/core/datetime/zone/day-instants.d.ts +19 -0
  226. package/dist/vendor/core/datetime/zone/day-instants.js +52 -0
  227. package/dist/vendor/core/datetime/zone/resolve.d.ts +16 -0
  228. package/dist/vendor/core/datetime/zone/resolve.js +24 -0
  229. package/dist/vendor/core/dom/auto-scroll.d.ts +37 -0
  230. package/dist/vendor/core/dom/auto-scroll.js +57 -0
  231. package/dist/vendor/core/dom/drag-session.d.ts +25 -0
  232. package/dist/vendor/core/dom/drag-session.js +257 -0
  233. package/dist/vendor/core/foundation/a11y/announcer.d.ts +12 -0
  234. package/dist/vendor/core/foundation/a11y/announcer.js +24 -0
  235. package/dist/vendor/core/foundation/a11y/grid-navigation.d.ts +19 -0
  236. package/dist/vendor/core/foundation/a11y/grid-navigation.js +76 -0
  237. package/dist/vendor/core/foundation/a11y/index.d.ts +8 -0
  238. package/dist/vendor/core/foundation/a11y/index.js +5 -0
  239. package/dist/vendor/core/foundation/a11y/labels.d.ts +21 -0
  240. package/dist/vendor/core/foundation/a11y/labels.js +43 -0
  241. package/dist/vendor/core/foundation/a11y/messages.d.ts +80 -0
  242. package/dist/vendor/core/foundation/a11y/messages.js +74 -0
  243. package/dist/vendor/core/foundation/a11y/roving-focus.d.ts +18 -0
  244. package/dist/vendor/core/foundation/a11y/roving-focus.js +73 -0
  245. package/dist/vendor/core/foundation/constraints/availability-rules.d.ts +52 -0
  246. package/dist/vendor/core/foundation/constraints/availability-rules.js +64 -0
  247. package/dist/vendor/core/foundation/constraints/availability.d.ts +93 -0
  248. package/dist/vendor/core/foundation/constraints/availability.js +480 -0
  249. package/dist/vendor/core/foundation/constraints/date.d.ts +21 -0
  250. package/dist/vendor/core/foundation/constraints/date.js +41 -0
  251. package/dist/vendor/core/foundation/constraints/index.d.ts +9 -0
  252. package/dist/vendor/core/foundation/constraints/index.js +4 -0
  253. package/dist/vendor/core/foundation/constraints/range.d.ts +44 -0
  254. package/dist/vendor/core/foundation/constraints/range.js +70 -0
  255. package/dist/vendor/core/foundation/constraints/time.d.ts +30 -0
  256. package/dist/vendor/core/foundation/constraints/time.js +56 -0
  257. package/dist/vendor/core/foundation/grid/index.d.ts +8 -0
  258. package/dist/vendor/core/foundation/grid/index.js +4 -0
  259. package/dist/vendor/core/foundation/grid/month-grid.d.ts +33 -0
  260. package/dist/vendor/core/foundation/grid/month-grid.js +52 -0
  261. package/dist/vendor/core/foundation/grid/time-axis.d.ts +25 -0
  262. package/dist/vendor/core/foundation/grid/time-axis.js +32 -0
  263. package/dist/vendor/core/foundation/grid/weekday-headers.d.ts +17 -0
  264. package/dist/vendor/core/foundation/grid/weekday-headers.js +26 -0
  265. package/dist/vendor/core/foundation/grid/year-grid.d.ts +29 -0
  266. package/dist/vendor/core/foundation/grid/year-grid.js +40 -0
  267. package/dist/vendor/core/foundation/index.d.ts +8 -0
  268. package/dist/vendor/core/foundation/index.js +8 -0
  269. package/dist/vendor/core/foundation/input/form.d.ts +7 -0
  270. package/dist/vendor/core/foundation/input/form.js +10 -0
  271. package/dist/vendor/core/foundation/input/index.d.ts +6 -0
  272. package/dist/vendor/core/foundation/input/index.js +3 -0
  273. package/dist/vendor/core/foundation/input/segment-engine.d.ts +33 -0
  274. package/dist/vendor/core/foundation/input/segment-engine.js +45 -0
  275. package/dist/vendor/core/foundation/input/tokenize.d.ts +19 -0
  276. package/dist/vendor/core/foundation/input/tokenize.js +24 -0
  277. package/dist/vendor/core/foundation/locale/digits.d.ts +6 -0
  278. package/dist/vendor/core/foundation/locale/digits.js +35 -0
  279. package/dist/vendor/core/foundation/locale/direction.d.ts +1 -0
  280. package/dist/vendor/core/foundation/locale/direction.js +25 -0
  281. package/dist/vendor/core/foundation/locale/format.d.ts +31 -0
  282. package/dist/vendor/core/foundation/locale/format.js +77 -0
  283. package/dist/vendor/core/foundation/locale/hour-cycle.d.ts +12 -0
  284. package/dist/vendor/core/foundation/locale/hour-cycle.js +41 -0
  285. package/dist/vendor/core/foundation/locale/index.d.ts +10 -0
  286. package/dist/vendor/core/foundation/locale/index.js +8 -0
  287. package/dist/vendor/core/foundation/locale/names.d.ts +6 -0
  288. package/dist/vendor/core/foundation/locale/names.js +30 -0
  289. package/dist/vendor/core/foundation/locale/resolve.d.ts +7 -0
  290. package/dist/vendor/core/foundation/locale/resolve.js +39 -0
  291. package/dist/vendor/core/foundation/locale/week-info.d.ts +5 -0
  292. package/dist/vendor/core/foundation/locale/week-info.js +60 -0
  293. package/dist/vendor/core/foundation/locale/zone-label.d.ts +6 -0
  294. package/dist/vendor/core/foundation/locale/zone-label.js +24 -0
  295. package/dist/vendor/core/foundation/ranges/date-range.d.ts +18 -0
  296. package/dist/vendor/core/foundation/ranges/date-range.js +40 -0
  297. package/dist/vendor/core/foundation/ranges/index.d.ts +4 -0
  298. package/dist/vendor/core/foundation/ranges/index.js +2 -0
  299. package/dist/vendor/core/foundation/ranges/interval.d.ts +24 -0
  300. package/dist/vendor/core/foundation/ranges/interval.js +54 -0
  301. package/dist/vendor/core/foundation/store/attributes.d.ts +19 -0
  302. package/dist/vendor/core/foundation/store/attributes.js +43 -0
  303. package/dist/vendor/core/foundation/store/controllable.d.ts +19 -0
  304. package/dist/vendor/core/foundation/store/controllable.js +50 -0
  305. package/dist/vendor/core/foundation/store/env.d.ts +1 -0
  306. package/dist/vendor/core/foundation/store/env.js +3 -0
  307. package/dist/vendor/core/foundation/store/ids.d.ts +9 -0
  308. package/dist/vendor/core/foundation/store/ids.js +12 -0
  309. package/dist/vendor/core/foundation/store/index.d.ts +11 -0
  310. package/dist/vendor/core/foundation/store/index.js +7 -0
  311. package/dist/vendor/core/foundation/store/store.d.ts +7 -0
  312. package/dist/vendor/core/foundation/store/store.js +25 -0
  313. package/dist/vendor/core/foundation/store/ticker.d.ts +11 -0
  314. package/dist/vendor/core/foundation/store/ticker.js +27 -0
  315. package/dist/vendor/core/foundation/store/with-optional.d.ts +15 -0
  316. package/dist/vendor/core/foundation/store/with-optional.js +3 -0
  317. package/dist/vendor/core/foundation/values/clock.d.ts +4 -0
  318. package/dist/vendor/core/foundation/values/clock.js +21 -0
  319. package/dist/vendor/core/foundation/values/compare.d.ts +16 -0
  320. package/dist/vendor/core/foundation/values/compare.js +70 -0
  321. package/dist/vendor/core/foundation/values/convert.d.ts +31 -0
  322. package/dist/vendor/core/foundation/values/convert.js +108 -0
  323. package/dist/vendor/core/foundation/values/epoch-day.d.ts +15 -0
  324. package/dist/vendor/core/foundation/values/epoch-day.js +43 -0
  325. package/dist/vendor/core/foundation/values/index.d.ts +14 -0
  326. package/dist/vendor/core/foundation/values/index.js +10 -0
  327. package/dist/vendor/core/foundation/values/iso.d.ts +24 -0
  328. package/dist/vendor/core/foundation/values/iso.js +111 -0
  329. package/dist/vendor/core/foundation/values/plain-date-time.d.ts +8 -0
  330. package/dist/vendor/core/foundation/values/plain-date-time.js +25 -0
  331. package/dist/vendor/core/foundation/values/plain-date.d.ts +33 -0
  332. package/dist/vendor/core/foundation/values/plain-date.js +105 -0
  333. package/dist/vendor/core/foundation/values/plain-time.d.ts +15 -0
  334. package/dist/vendor/core/foundation/values/plain-time.js +43 -0
  335. package/dist/vendor/core/foundation/values/types.d.ts +37 -0
  336. package/dist/vendor/core/foundation/values/types.js +1 -0
  337. package/dist/vendor/core/foundation/values/week.d.ts +9 -0
  338. package/dist/vendor/core/foundation/values/week.js +31 -0
  339. package/dist/vendor/core/foundation/values/year-month.d.ts +10 -0
  340. package/dist/vendor/core/foundation/values/year-month.js +19 -0
  341. package/dist/vendor/core/foundation/values/zoned.d.ts +16 -0
  342. package/dist/vendor/core/foundation/values/zoned.js +152 -0
  343. package/dist/vendor/core/index.d.ts +5 -0
  344. package/dist/vendor/core/index.js +5 -0
  345. package/dist/vendor/core/time/index.d.ts +8 -0
  346. package/dist/vendor/core/time/index.js +8 -0
  347. package/dist/vendor/core/time/input/parse.d.ts +19 -0
  348. package/dist/vendor/core/time/input/parse.js +82 -0
  349. package/dist/vendor/core/time/input/time-input-controller.d.ts +102 -0
  350. package/dist/vendor/core/time/input/time-input-controller.js +547 -0
  351. package/dist/vendor/core/time/input/time-range-input-controller.d.ts +49 -0
  352. package/dist/vendor/core/time/input/time-range-input-controller.js +178 -0
  353. package/dist/vendor/core/time/input/validity.d.ts +7 -0
  354. package/dist/vendor/core/time/input/validity.js +16 -0
  355. package/dist/vendor/core/time/panel/time-panel-controller.d.ts +163 -0
  356. package/dist/vendor/core/time/panel/time-panel-controller.js +809 -0
  357. package/dist/vendor/core/time/selection/range.d.ts +25 -0
  358. package/dist/vendor/core/time/selection/range.js +35 -0
  359. package/dist/vendor/core/time/selection/slots.d.ts +46 -0
  360. package/dist/vendor/core/time/selection/slots.js +76 -0
  361. package/dist/vendor/core/time/types.d.ts +11 -0
  362. package/dist/vendor/core/time/types.js +1 -0
  363. package/package.json +83 -4
@@ -0,0 +1,33 @@
1
+ import { daysInMonth, daysInYear, isLeapYear } from "./epoch-day.js";
2
+ import type { DayOfWeek, Overflow, PlainDate } from "./types.js";
3
+ export { daysInMonth, daysInYear, isLeapYear };
4
+ export declare function isValidDate(year: number, month: number, day: number): boolean;
5
+ /**
6
+ * Create a frozen {@link PlainDate}. Invalid input throws a `RangeError`, or
7
+ * is clamped into the month with `overflow: "constrain"`.
8
+ */
9
+ export declare function plainDate(year: number, month: number, day: number, options?: {
10
+ overflow?: Overflow;
11
+ }): PlainDate;
12
+ export declare function toEpochDay(date: Pick<PlainDate, "year" | "month" | "day">): number;
13
+ export declare function fromEpochDay(epochDay: number): PlainDate;
14
+ /** 1 = Monday ... 7 = Sunday. */
15
+ export declare function dayOfWeek(date: Pick<PlainDate, "year" | "month" | "day">): DayOfWeek;
16
+ export declare function dayOfWeekFromEpochDay(epochDay: number): DayOfWeek;
17
+ export declare function dayOfYear(date: PlainDate): number;
18
+ export declare function addDays(date: PlainDate, days: number): PlainDate;
19
+ export declare function addWeeks(date: PlainDate, weeks: number): PlainDate;
20
+ export declare function addMonths(date: PlainDate, months: number, options?: {
21
+ overflow?: Overflow;
22
+ }): PlainDate;
23
+ export declare function addYears(date: PlainDate, years: number, options?: {
24
+ overflow?: Overflow;
25
+ }): PlainDate;
26
+ /** `a - b` in whole days. */
27
+ export declare function diffDays(a: PlainDate, b: PlainDate): number;
28
+ export declare function startOfWeek(date: PlainDate, weekStartsOn: DayOfWeek): PlainDate;
29
+ export declare function endOfWeek(date: PlainDate, weekStartsOn: DayOfWeek): PlainDate;
30
+ export declare function startOfMonth(date: PlainDate): PlainDate;
31
+ export declare function endOfMonth(date: PlainDate): PlainDate;
32
+ export declare function startOfYear(date: PlainDate): PlainDate;
33
+ export declare function endOfYear(date: PlainDate): PlainDate;
@@ -0,0 +1,105 @@
1
+ import { civilFromDays, daysFromCivil, daysInMonth, daysInYear, isLeapYear, MAX_YEAR, MIN_YEAR, } from "./epoch-day.js";
2
+ export { daysInMonth, daysInYear, isLeapYear };
3
+ export function isValidDate(year, month, day) {
4
+ return (Number.isInteger(year) &&
5
+ Number.isInteger(month) &&
6
+ Number.isInteger(day) &&
7
+ year >= MIN_YEAR &&
8
+ year <= MAX_YEAR &&
9
+ month >= 1 &&
10
+ month <= 12 &&
11
+ day >= 1 &&
12
+ day <= daysInMonth(year, month));
13
+ }
14
+ /**
15
+ * Create a frozen {@link PlainDate}. Invalid input throws a `RangeError`, or
16
+ * is clamped into the month with `overflow: "constrain"`.
17
+ */
18
+ export function plainDate(year, month, day, options = {}) {
19
+ if (options.overflow === "constrain") {
20
+ if (Number.isInteger(year) &&
21
+ Number.isInteger(month) &&
22
+ Number.isInteger(day) &&
23
+ year >= MIN_YEAR &&
24
+ year <= MAX_YEAR &&
25
+ month >= 1 &&
26
+ month <= 12) {
27
+ return Object.freeze({
28
+ calendar: "gregory",
29
+ year,
30
+ month,
31
+ day: Math.min(Math.max(day, 1), daysInMonth(year, month)),
32
+ });
33
+ }
34
+ }
35
+ if (!isValidDate(year, month, day)) {
36
+ throw new RangeError(`Invalid date ${year}-${month}-${day}: year must be ${MIN_YEAR}-${MAX_YEAR}, month 1-12 and day within the month.`);
37
+ }
38
+ return Object.freeze({ calendar: "gregory", year, month, day });
39
+ }
40
+ export function toEpochDay(date) {
41
+ return daysFromCivil(date.year, date.month, date.day);
42
+ }
43
+ export function fromEpochDay(epochDay) {
44
+ const [year, month, day] = civilFromDays(epochDay);
45
+ if (year < MIN_YEAR || year > MAX_YEAR) {
46
+ throw new RangeError(`Date out of range: year ${year} is outside ${MIN_YEAR}-${MAX_YEAR}.`);
47
+ }
48
+ return Object.freeze({ calendar: "gregory", year, month, day });
49
+ }
50
+ /** 1 = Monday ... 7 = Sunday. */
51
+ export function dayOfWeek(date) {
52
+ return dayOfWeekFromEpochDay(toEpochDay(date));
53
+ }
54
+ export function dayOfWeekFromEpochDay(epochDay) {
55
+ // 1970-01-01 was a Thursday (4).
56
+ return (((((epochDay + 3) % 7) + 7) % 7) + 1);
57
+ }
58
+ export function dayOfYear(date) {
59
+ return toEpochDay(date) - daysFromCivil(date.year, 1, 1) + 1;
60
+ }
61
+ export function addDays(date, days) {
62
+ return fromEpochDay(toEpochDay(date) + days);
63
+ }
64
+ export function addWeeks(date, weeks) {
65
+ return addDays(date, weeks * 7);
66
+ }
67
+ export function addMonths(date, months, options = {}) {
68
+ const index = date.year * 12 + (date.month - 1) + months;
69
+ const year = Math.floor(index / 12);
70
+ const month = index - year * 12 + 1;
71
+ if (year < MIN_YEAR || year > MAX_YEAR) {
72
+ throw new RangeError(`Date out of range: year ${year}.`);
73
+ }
74
+ const limit = daysInMonth(year, month);
75
+ if (date.day > limit && options.overflow === "reject") {
76
+ throw new RangeError(`${year}-${month}-${date.day} does not exist (overflow: "reject").`);
77
+ }
78
+ return plainDate(year, month, Math.min(date.day, limit));
79
+ }
80
+ export function addYears(date, years, options = {}) {
81
+ return addMonths(date, years * 12, options);
82
+ }
83
+ /** `a - b` in whole days. */
84
+ export function diffDays(a, b) {
85
+ return toEpochDay(a) - toEpochDay(b);
86
+ }
87
+ export function startOfWeek(date, weekStartsOn) {
88
+ const offset = (dayOfWeek(date) - weekStartsOn + 7) % 7;
89
+ return addDays(date, -offset);
90
+ }
91
+ export function endOfWeek(date, weekStartsOn) {
92
+ return addDays(startOfWeek(date, weekStartsOn), 6);
93
+ }
94
+ export function startOfMonth(date) {
95
+ return plainDate(date.year, date.month, 1);
96
+ }
97
+ export function endOfMonth(date) {
98
+ return plainDate(date.year, date.month, daysInMonth(date.year, date.month));
99
+ }
100
+ export function startOfYear(date) {
101
+ return plainDate(date.year, 1, 1);
102
+ }
103
+ export function endOfYear(date) {
104
+ return plainDate(date.year, 12, 31);
105
+ }
@@ -0,0 +1,15 @@
1
+ import type { PlainTime } from "./types.js";
2
+ export declare const SECONDS_PER_DAY = 86400;
3
+ export declare function isValidTime(hour: number, minute: number, second: number): boolean;
4
+ export declare function plainTime(hour: number, minute: number, second?: number): PlainTime;
5
+ export declare function toSecondOfDay(time: PlainTime): number;
6
+ export declare function fromSecondOfDay(secondOfDay: number): PlainTime;
7
+ /** Add seconds, wrapping at midnight. `dayDelta` is the number of days carried. */
8
+ export declare function addSeconds(time: PlainTime, seconds: number): {
9
+ time: PlainTime;
10
+ dayDelta: number;
11
+ };
12
+ export declare function addMinutes(time: PlainTime, minutes: number): {
13
+ time: PlainTime;
14
+ dayDelta: number;
15
+ };
@@ -0,0 +1,43 @@
1
+ export const SECONDS_PER_DAY = 86400;
2
+ export function isValidTime(hour, minute, second) {
3
+ return (Number.isInteger(hour) &&
4
+ Number.isInteger(minute) &&
5
+ Number.isInteger(second) &&
6
+ hour >= 0 &&
7
+ hour <= 23 &&
8
+ minute >= 0 &&
9
+ minute <= 59 &&
10
+ second >= 0 &&
11
+ second <= 59);
12
+ }
13
+ export function plainTime(hour, minute, second = 0) {
14
+ if (!isValidTime(hour, minute, second)) {
15
+ throw new RangeError(`Invalid time ${hour}:${minute}:${second}: expected hour 0-23, minute 0-59, second 0-59.`);
16
+ }
17
+ return Object.freeze({ hour, minute, second });
18
+ }
19
+ export function toSecondOfDay(time) {
20
+ return time.hour * 3600 + time.minute * 60 + time.second;
21
+ }
22
+ export function fromSecondOfDay(secondOfDay) {
23
+ if (!Number.isInteger(secondOfDay) || secondOfDay < 0 || secondOfDay >= SECONDS_PER_DAY) {
24
+ throw new RangeError(`Second of day out of range: ${secondOfDay}.`);
25
+ }
26
+ return Object.freeze({
27
+ hour: Math.floor(secondOfDay / 3600),
28
+ minute: Math.floor((secondOfDay % 3600) / 60),
29
+ second: secondOfDay % 60,
30
+ });
31
+ }
32
+ /** Add seconds, wrapping at midnight. `dayDelta` is the number of days carried. */
33
+ export function addSeconds(time, seconds) {
34
+ const total = toSecondOfDay(time) + seconds;
35
+ const dayDelta = Math.floor(total / SECONDS_PER_DAY);
36
+ return {
37
+ time: fromSecondOfDay(total - dayDelta * SECONDS_PER_DAY),
38
+ dayDelta,
39
+ };
40
+ }
41
+ export function addMinutes(time, minutes) {
42
+ return addSeconds(time, minutes * 60);
43
+ }
@@ -0,0 +1,37 @@
1
+ /** ISO weekday number: 1 = Monday ... 7 = Sunday (plan 03 D2). */
2
+ export type DayOfWeek = 1 | 2 | 3 | 4 | 5 | 6 | 7;
3
+ /** A calendar date with no time and no time zone. Months are 1-based (D2). */
4
+ export type PlainDate = Readonly<{
5
+ calendar: "gregory";
6
+ year: number;
7
+ month: number;
8
+ day: number;
9
+ }>;
10
+ /** A wall-clock time with no date and no time zone. Second precision (D6). */
11
+ export type PlainTime = Readonly<{
12
+ hour: number;
13
+ minute: number;
14
+ second: number;
15
+ }>;
16
+ export type PlainDateTime = Readonly<PlainDate & PlainTime>;
17
+ /** A wall-clock date-time pinned to a time zone. `offset` is minutes east of UTC (D7). */
18
+ export type ZonedDateTime = Readonly<PlainDateTime & {
19
+ timeZone: string;
20
+ offset: number;
21
+ }>;
22
+ /** How a wall time that is skipped or repeated by a DST change is resolved (D8). */
23
+ export type Disambiguation = "compatible" | "earlier" | "later" | "reject";
24
+ /** What public props accept for a date. */
25
+ export type DateInput = PlainDate | string | Date;
26
+ /** What public props accept for a time. */
27
+ export type TimeInput = PlainTime | string;
28
+ /** What public props accept for a date-time (plan 05 R4). */
29
+ export type DateTimeInput = PlainDateTime | ZonedDateTime | string;
30
+ /** `constrain` clamps an overflowing day; `reject` throws (D5). */
31
+ export type Overflow = "constrain" | "reject";
32
+ /** Locale week rules (D12). */
33
+ export type WeekInfo = Readonly<{
34
+ firstDay: DayOfWeek;
35
+ weekend: readonly DayOfWeek[];
36
+ minimalDays: 1 | 2 | 3 | 4 | 5 | 6 | 7;
37
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { PlainDate, WeekInfo } from "./types.js";
2
+ export type WeekNumber = {
3
+ year: number;
4
+ week: number;
5
+ };
6
+ /** ISO 8601 week: weeks start on Monday, week 1 contains January 4th. */
7
+ export declare function getIsoWeek(date: PlainDate): WeekNumber;
8
+ /** Week number under a locale's first day and minimal days. */
9
+ export declare function getLocaleWeek(date: PlainDate, weekInfo: Pick<WeekInfo, "firstDay" | "minimalDays">): WeekNumber;
@@ -0,0 +1,31 @@
1
+ import { daysFromCivil } from "./epoch-day.js";
2
+ import { dayOfWeekFromEpochDay, toEpochDay } from "./plain-date.js";
3
+ const ISO_WEEK_INFO = { firstDay: 1, minimalDays: 4 };
4
+ /** Epoch day on which week 1 of `year` starts under the given rules. */
5
+ function firstWeekStart(year, firstDay, minimalDays) {
6
+ const jan1 = daysFromCivil(year, 1, 1);
7
+ const offset = (dayOfWeekFromEpochDay(jan1) - firstDay + 7) % 7;
8
+ const weekStart = jan1 - offset;
9
+ const daysInYearPart = 7 - offset;
10
+ return daysInYearPart >= minimalDays ? weekStart : weekStart + 7;
11
+ }
12
+ function weekNumber(date, firstDay, minimalDays) {
13
+ const day = toEpochDay(date);
14
+ let year = date.year;
15
+ if (day >= firstWeekStart(year + 1, firstDay, minimalDays)) {
16
+ year += 1;
17
+ }
18
+ else if (day < firstWeekStart(year, firstDay, minimalDays)) {
19
+ year -= 1;
20
+ }
21
+ const week = Math.floor((day - firstWeekStart(year, firstDay, minimalDays)) / 7) + 1;
22
+ return { year, week };
23
+ }
24
+ /** ISO 8601 week: weeks start on Monday, week 1 contains January 4th. */
25
+ export function getIsoWeek(date) {
26
+ return weekNumber(date, ISO_WEEK_INFO.firstDay, ISO_WEEK_INFO.minimalDays);
27
+ }
28
+ /** Week number under a locale's first day and minimal days. */
29
+ export function getLocaleWeek(date, weekInfo) {
30
+ return weekNumber(date, weekInfo.firstDay, weekInfo.minimalDays);
31
+ }
@@ -0,0 +1,10 @@
1
+ import type { PlainDate } from "./types.js";
2
+ /** A calendar month without a day (plan 06 A25). Months are 1-based. */
3
+ export type PlainYearMonth = Readonly<{
4
+ year: number;
5
+ month: number;
6
+ }>;
7
+ export declare function plainYearMonth(year: number, month: number): PlainYearMonth;
8
+ export declare const toPlainYearMonth: (date: PlainDate) => PlainYearMonth;
9
+ export declare const compareYearMonth: (a: PlainYearMonth, b: PlainYearMonth) => number;
10
+ export declare function addMonthsToYearMonth(value: PlainYearMonth, months: number): PlainYearMonth;
@@ -0,0 +1,19 @@
1
+ import { MAX_YEAR, MIN_YEAR } from "./epoch-day.js";
2
+ export function plainYearMonth(year, month) {
3
+ if (!Number.isInteger(year) ||
4
+ !Number.isInteger(month) ||
5
+ year < MIN_YEAR ||
6
+ year > MAX_YEAR ||
7
+ month < 1 ||
8
+ month > 12) {
9
+ throw new RangeError(`${year}-${month} is not a valid year and month.`);
10
+ }
11
+ return Object.freeze({ year, month });
12
+ }
13
+ export const toPlainYearMonth = (date) => plainYearMonth(date.year, date.month);
14
+ export const compareYearMonth = (a, b) => a.year * 12 + a.month - (b.year * 12 + b.month);
15
+ export function addMonthsToYearMonth(value, months) {
16
+ const total = value.year * 12 + (value.month - 1) + months;
17
+ const year = Math.floor(total / 12);
18
+ return plainYearMonth(year, total - year * 12 + 1);
19
+ }
@@ -0,0 +1,16 @@
1
+ import type { Disambiguation, PlainDateTime, ZonedDateTime } from "./types.js";
2
+ /** Minutes east of UTC for a fixed-offset id such as `+05:30`, else `null`. */
3
+ export declare function parseOffsetId(id: string): number | null;
4
+ /** `true` for an IANA zone id the runtime knows, or a fixed offset such as `+05:30`. */
5
+ export declare function isValidTimeZone(timeZone: string): boolean;
6
+ /**
7
+ * Offset of `timeZone` at an instant, in minutes east of UTC. Historical
8
+ * offsets with seconds (pre-1900 local mean time) are rounded to the minute.
9
+ */
10
+ export declare function getOffset(epochMs: number, timeZone: string): number;
11
+ /** The instant (epoch milliseconds) a zoned value points at. */
12
+ export declare function toInstant(zoned: ZonedDateTime): number;
13
+ export declare function fromInstant(epochMs: number, timeZone: string): ZonedDateTime;
14
+ /** Pin a wall time to a zone. DST gaps and overlaps follow `disambiguation` (D8). */
15
+ export declare function toZoned(dateTime: PlainDateTime, timeZone: string, disambiguation?: Disambiguation): ZonedDateTime;
16
+ export declare function withTimeZone(zoned: ZonedDateTime, timeZone: string): ZonedDateTime;
@@ -0,0 +1,152 @@
1
+ import { civilFromDays, daysFromCivil, floorDiv, MAX_YEAR, MIN_YEAR } from "./epoch-day.js";
2
+ import { plainDateTime, wallSeconds } from "./plain-date-time.js";
3
+ import { fromSecondOfDay } from "./plain-time.js";
4
+ import { fromEpochDay, plainDate } from "./plain-date.js";
5
+ const DAY_SECONDS = 86400;
6
+ const OFFSET_ID = /^([+-])(\d{2}):?(\d{2})$/;
7
+ const formatters = new Map();
8
+ /** Minutes east of UTC for a fixed-offset id such as `+05:30`, else `null`. */
9
+ export function parseOffsetId(id) {
10
+ const match = OFFSET_ID.exec(id);
11
+ if (!match) {
12
+ return null;
13
+ }
14
+ const hours = Number(match[2]);
15
+ const minutes = Number(match[3]);
16
+ if (hours > 23 || minutes > 59) {
17
+ return null;
18
+ }
19
+ return (match[1] === "-" ? -1 : 1) * (hours * 60 + minutes);
20
+ }
21
+ function getFormatter(timeZone) {
22
+ let formatter = formatters.get(timeZone);
23
+ if (!formatter) {
24
+ formatter = new Intl.DateTimeFormat("en-US", {
25
+ timeZone,
26
+ calendar: "gregory",
27
+ hourCycle: "h23",
28
+ year: "numeric",
29
+ month: "numeric",
30
+ day: "numeric",
31
+ hour: "numeric",
32
+ minute: "numeric",
33
+ second: "numeric",
34
+ });
35
+ formatters.set(timeZone, formatter);
36
+ }
37
+ return formatter;
38
+ }
39
+ /** `true` for an IANA zone id the runtime knows, or a fixed offset such as `+05:30`. */
40
+ export function isValidTimeZone(timeZone) {
41
+ if (typeof timeZone !== "string" || timeZone === "") {
42
+ return false;
43
+ }
44
+ if (parseOffsetId(timeZone) !== null) {
45
+ return true;
46
+ }
47
+ try {
48
+ getFormatter(timeZone);
49
+ return true;
50
+ }
51
+ catch {
52
+ return false;
53
+ }
54
+ }
55
+ function assertTimeZone(timeZone) {
56
+ if (!isValidTimeZone(timeZone)) {
57
+ throw new RangeError(`Unknown time zone "${timeZone}".`);
58
+ }
59
+ }
60
+ /**
61
+ * Offset of `timeZone` at an instant, in minutes east of UTC. Historical
62
+ * offsets with seconds (pre-1900 local mean time) are rounded to the minute.
63
+ */
64
+ export function getOffset(epochMs, timeZone) {
65
+ const fixed = parseOffsetId(timeZone);
66
+ if (fixed !== null) {
67
+ return fixed;
68
+ }
69
+ // UTC never shifts; skip the Intl round-trip on the common fixed-zone path.
70
+ if (timeZone === "UTC" || timeZone === "Etc/UTC") {
71
+ return 0;
72
+ }
73
+ assertTimeZone(timeZone);
74
+ const values = {};
75
+ for (const part of getFormatter(timeZone).formatToParts(epochMs)) {
76
+ if (part.type !== "literal") {
77
+ values[part.type] = Number(part.value);
78
+ }
79
+ }
80
+ const days = daysFromCivil(values.year ?? 1970, values.month ?? 1, values.day ?? 1);
81
+ const wall = days * DAY_SECONDS +
82
+ ((values.hour ?? 0) % 24) * 3600 +
83
+ (values.minute ?? 0) * 60 +
84
+ (values.second ?? 0);
85
+ return Math.round((wall - Math.floor(epochMs / 1000)) / 60);
86
+ }
87
+ function build(dateTime, timeZone, offset) {
88
+ return Object.freeze({
89
+ calendar: "gregory",
90
+ year: dateTime.year,
91
+ month: dateTime.month,
92
+ day: dateTime.day,
93
+ hour: dateTime.hour,
94
+ minute: dateTime.minute,
95
+ second: dateTime.second,
96
+ timeZone,
97
+ offset,
98
+ });
99
+ }
100
+ /** The instant (epoch milliseconds) a zoned value points at. */
101
+ export function toInstant(zoned) {
102
+ return (wallSeconds(zoned) - zoned.offset * 60) * 1000;
103
+ }
104
+ export function fromInstant(epochMs, timeZone) {
105
+ const offset = getOffset(epochMs, timeZone);
106
+ const wall = Math.floor(epochMs / 1000) + offset * 60;
107
+ const days = floorDiv(wall, DAY_SECONDS);
108
+ const [year] = civilFromDays(days);
109
+ if (year < MIN_YEAR || year > MAX_YEAR) {
110
+ throw new RangeError(`Date out of range: year ${year}.`);
111
+ }
112
+ const date = fromEpochDay(days);
113
+ const time = fromSecondOfDay(wall - days * DAY_SECONDS);
114
+ return build(plainDateTime(date, time), timeZone, offset);
115
+ }
116
+ /** Pin a wall time to a zone. DST gaps and overlaps follow `disambiguation` (D8). */
117
+ export function toZoned(dateTime, timeZone, disambiguation = "compatible") {
118
+ assertTimeZone(timeZone);
119
+ // Validates the fields as a side effect.
120
+ plainDate(dateTime.year, dateTime.month, dateTime.day);
121
+ const fixed = parseOffsetId(timeZone);
122
+ if (fixed !== null) {
123
+ return build(dateTime, timeZone, fixed);
124
+ }
125
+ const wall = wallSeconds(dateTime);
126
+ const before = getOffset((wall - DAY_SECONDS) * 1000, timeZone);
127
+ const after = getOffset((wall + DAY_SECONDS) * 1000, timeZone);
128
+ const candidates = before === after ? [before] : [before, after];
129
+ const valid = candidates.filter((offset) => getOffset((wall - offset * 60) * 1000, timeZone) === offset);
130
+ let offset;
131
+ if (valid.length === 1) {
132
+ offset = valid[0];
133
+ }
134
+ else if (valid.length === 2) {
135
+ if (disambiguation === "reject") {
136
+ throw new RangeError(`${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute} is ambiguous in ${timeZone}.`);
137
+ }
138
+ // Larger offset = earlier instant.
139
+ offset = disambiguation === "later" ? Math.min(before, after) : Math.max(before, after);
140
+ }
141
+ else {
142
+ if (disambiguation === "reject") {
143
+ throw new RangeError(`${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute} does not exist in ${timeZone} (DST gap).`);
144
+ }
145
+ // In a gap the offset grows. Using the old offset moves forward, the new one backward.
146
+ offset = disambiguation === "earlier" ? after : before;
147
+ }
148
+ return fromInstant((wall - offset * 60) * 1000, timeZone);
149
+ }
150
+ export function withTimeZone(zoned, timeZone) {
151
+ return fromInstant(toInstant(zoned), timeZone);
152
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./foundation/index.js";
2
+ export * from "./date/index.js";
3
+ export * from "./time/index.js";
4
+ export * from "./datetime/index.js";
5
+ export * from "./calendar/index.js";
@@ -0,0 +1,5 @@
1
+ export * from "./foundation/index.js";
2
+ export * from "./date/index.js";
3
+ export * from "./time/index.js";
4
+ export * from "./datetime/index.js";
5
+ export * from "./calendar/index.js";
@@ -0,0 +1,8 @@
1
+ export * from "./types.js";
2
+ export * from "./selection/slots.js";
3
+ export * from "./selection/range.js";
4
+ export * from "./input/parse.js";
5
+ export * from "./input/validity.js";
6
+ export * from "./input/time-input-controller.js";
7
+ export * from "./input/time-range-input-controller.js";
8
+ export * from "./panel/time-panel-controller.js";
@@ -0,0 +1,8 @@
1
+ export * from "./types.js";
2
+ export * from "./selection/slots.js";
3
+ export * from "./selection/range.js";
4
+ export * from "./input/parse.js";
5
+ export * from "./input/validity.js";
6
+ export * from "./input/time-input-controller.js";
7
+ export * from "./input/time-range-input-controller.js";
8
+ export * from "./panel/time-panel-controller.js";
@@ -0,0 +1,19 @@
1
+ import { type PlainTime } from "../../foundation/index.js";
2
+ import type { HourCycle, TimeGranularity } from "../types.js";
3
+ export type TimeParseContext = {
4
+ locale?: string | undefined;
5
+ hourCycle?: HourCycle;
6
+ granularity?: TimeGranularity;
7
+ };
8
+ export type TimeParseResult = {
9
+ time: PlainTime;
10
+ } | {
11
+ error: "empty" | "unparseable" | "invalid";
12
+ };
13
+ /** `am` / `pm` for a word: the locale's labels, `am`, `pm`, and the first letters `a`, `p`. */
14
+ export declare function dayPeriodOf(word: string, locale?: string): "am" | "pm" | null;
15
+ /**
16
+ * Parse typed text into a time (plan 07 T17): `9`, `930`, `0930`, `9:30`, `9.30`,
17
+ * `9h30`, `21:30`, `9:30 pm`, `9 PM`, the locale's day-period words and `09:30:15`.
18
+ */
19
+ export declare function parseTime(text: string, context?: TimeParseContext): TimeParseResult;
@@ -0,0 +1,82 @@
1
+ import { fold, getDayPeriodNames, plainTime, tokenize, toLatinDigits, } from "../../foundation/index.js";
2
+ const isValidTime = (h, m, s) => h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59;
3
+ const clean = (text) => fold(text).replace(/[.\s]/g, "");
4
+ /** `am` / `pm` for a word: the locale's labels, `am`, `pm`, and the first letters `a`, `p`. */
5
+ export function dayPeriodOf(word, locale) {
6
+ const needle = clean(word);
7
+ if (!needle)
8
+ return null;
9
+ const names = getDayPeriodNames(locale);
10
+ if (needle === clean(names.am) || needle === "am" || needle === "a")
11
+ return "am";
12
+ if (needle === clean(names.pm) || needle === "pm" || needle === "p")
13
+ return "pm";
14
+ return null;
15
+ }
16
+ /**
17
+ * Parse typed text into a time (plan 07 T17): `9`, `930`, `0930`, `9:30`, `9.30`,
18
+ * `9h30`, `21:30`, `9:30 pm`, `9 PM`, the locale's day-period words and `09:30:15`.
19
+ */
20
+ export function parseTime(text, context = {}) {
21
+ const latin = toLatinDigits(text.trim(), context.locale);
22
+ if (latin === "")
23
+ return { error: "empty" };
24
+ const tokens = tokenize(latin, context.locale);
25
+ let period = null;
26
+ const numbers = [];
27
+ let separators = 0;
28
+ for (const token of tokens) {
29
+ if (token.type === "number") {
30
+ numbers.push(token);
31
+ }
32
+ else if (token.type === "word") {
33
+ if (/^h$/i.test(token.text)) {
34
+ separators += 1;
35
+ continue;
36
+ }
37
+ const found = dayPeriodOf(token.text, context.locale);
38
+ if (!found || period)
39
+ return { error: "unparseable" };
40
+ period = found;
41
+ }
42
+ else if (/[:.]/.test(token.text)) {
43
+ separators += 1;
44
+ }
45
+ }
46
+ // A glued day period such as `9pm` is one word token after the number.
47
+ let hour;
48
+ let minute = 0;
49
+ let second = 0;
50
+ if (numbers.length === 1 && separators === 0) {
51
+ const digits = numbers[0].text;
52
+ if (digits.length <= 2)
53
+ hour = Number(digits);
54
+ else if (digits.length <= 4) {
55
+ hour = Number(digits.slice(0, -2));
56
+ minute = Number(digits.slice(-2));
57
+ }
58
+ else if (digits.length <= 6) {
59
+ hour = Number(digits.slice(0, -4));
60
+ minute = Number(digits.slice(-4, -2));
61
+ second = Number(digits.slice(-2));
62
+ }
63
+ else
64
+ return { error: "unparseable" };
65
+ }
66
+ else if (numbers.length >= 1 && numbers.length <= 3 && separators >= numbers.length - 1) {
67
+ hour = numbers[0].value;
68
+ minute = numbers[1]?.value ?? 0;
69
+ second = numbers[2]?.value ?? 0;
70
+ }
71
+ else {
72
+ return { error: "unparseable" };
73
+ }
74
+ if (period) {
75
+ if (hour < 1 || hour > 12)
76
+ return { error: "invalid" };
77
+ hour = (hour % 12) + (period === "pm" ? 12 : 0);
78
+ }
79
+ return isValidTime(hour, minute, second)
80
+ ? { time: plainTime(hour, minute, second) }
81
+ : { error: "invalid" };
82
+ }