@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,480 @@
1
+ import { addDays, addMonths, fromEpochDay, plainDate, toEpochDay } from "../values/plain-date.js";
2
+ import { plainDateTime } from "../values/plain-date-time.js";
3
+ import { plainTime } from "../values/plain-time.js";
4
+ import { parseIsoDate, parseIsoDateTime } from "../values/iso.js";
5
+ import { fromInstant, toInstant, toZoned } from "../values/zoned.js";
6
+ import { expandRuleDay, normalizeRule, ruleMatchesResource, timeTokenToSeconds, } from "./availability-rules.js";
7
+ const MIN_DAY = -719162; // 0001-01-01
8
+ const MAX_DAY = 2932896; // 9999-12-31
9
+ const SEARCH_LIMIT = 4000;
10
+ const CACHE_DAYS = 400;
11
+ const LEAD_TIME_RULE = {
12
+ type: "range",
13
+ start: "0001-01-01",
14
+ end: "0001-01-01",
15
+ id: "lead-time",
16
+ reason: "lead time",
17
+ };
18
+ const BOOKING_WINDOW_RULE = {
19
+ type: "range",
20
+ start: "0001-01-01",
21
+ end: "0001-01-01",
22
+ id: "booking-window",
23
+ reason: "booking window",
24
+ };
25
+ let warnedLegacy = false;
26
+ /** `true` for the pre-plan-11 shape (plan 11 R1). */
27
+ export function isLegacyAvailabilitySpec(input) {
28
+ return "mode" in input;
29
+ }
30
+ /** Convert the old shape into open/blocked rules (plan 11 R1). */
31
+ export function legacyToAvailabilitySpec(input) {
32
+ const rules = [];
33
+ if (input.dates?.length) {
34
+ rules.push({ type: "dates", dates: input.dates });
35
+ }
36
+ for (const range of input.ranges ?? []) {
37
+ rules.push({
38
+ type: "range",
39
+ start: range.start,
40
+ // Legacy ranges are inclusive; the new engine is half-open (plan 11 R8).
41
+ end: toEpochDay(range.end) >= MAX_DAY ? range.end : addDays(range.end, 1),
42
+ });
43
+ }
44
+ if (input.weekdays?.length) {
45
+ rules.push({ type: "weekly", days: input.weekdays });
46
+ }
47
+ return input.mode === "available" ? { open: rules } : { blocked: rules };
48
+ }
49
+ function instantOf(value, zone) {
50
+ if (typeof value === "string") {
51
+ if (value.includes("T")) {
52
+ const dateTime = parseIsoDateTime(value);
53
+ return toInstant(toZoned(dateTime, zone, "compatible"));
54
+ }
55
+ return instantOf(parseIsoDate(value), zone);
56
+ }
57
+ if ("timeZone" in value) {
58
+ return toInstant(value);
59
+ }
60
+ if ("hour" in value) {
61
+ return toInstant(toZoned(value, zone, "compatible"));
62
+ }
63
+ return toInstant(toZoned(plainDateTime(value, plainTime(0, 0)), zone, "compatible"));
64
+ }
65
+ function startOfDayInstant(date, zone) {
66
+ return toInstant(toZoned(plainDateTime(date, plainTime(0, 0)), zone, "compatible"));
67
+ }
68
+ function parseRangeBound(value) {
69
+ if (typeof value !== "string") {
70
+ return { date: value };
71
+ }
72
+ if (value.includes("T")) {
73
+ const dateTime = parseIsoDateTime(value);
74
+ return {
75
+ date: dateTime,
76
+ time: plainTime(dateTime.hour, dateTime.minute, dateTime.second),
77
+ };
78
+ }
79
+ return { date: parseIsoDate(value) };
80
+ }
81
+ function rangeSpan(rule, zone) {
82
+ const start = parseRangeBound(rule.start);
83
+ const end = parseRangeBound(rule.end);
84
+ const startAt = start.time
85
+ ? toInstant(toZoned(plainDateTime(start.date, start.time), zone, "compatible"))
86
+ : startOfDayInstant(start.date, zone);
87
+ const endAt = end.time
88
+ ? toInstant(toZoned(plainDateTime(end.date, end.time), zone, "compatible"))
89
+ : startOfDayInstant(end.date, zone);
90
+ return { start: startAt, end: endAt, rule };
91
+ }
92
+ function mergeSpans(spans) {
93
+ const sorted = [...spans].sort((a, b) => a.start - b.start || a.end - b.end);
94
+ const merged = [];
95
+ for (const span of sorted) {
96
+ if (span.end <= span.start) {
97
+ continue;
98
+ }
99
+ const last = merged[merged.length - 1];
100
+ if (last && span.start <= last.end) {
101
+ last.end = Math.max(last.end, span.end);
102
+ if (!last.rule && span.rule) {
103
+ last.rule = span.rule;
104
+ }
105
+ }
106
+ else {
107
+ merged.push({ ...span });
108
+ }
109
+ }
110
+ return merged;
111
+ }
112
+ /** Contiguous pieces of `[start, end)` from open minus blocked (plan 11 §12.2 step 4). */
113
+ function sweep(open, blocked, start, end) {
114
+ const points = new Set([start, end]);
115
+ for (const span of open) {
116
+ if (span.start > start && span.start < end)
117
+ points.add(span.start);
118
+ if (span.end > start && span.end < end)
119
+ points.add(span.end);
120
+ }
121
+ for (const span of blocked) {
122
+ if (span.start > start && span.start < end)
123
+ points.add(span.start);
124
+ if (span.end > start && span.end < end)
125
+ points.add(span.end);
126
+ }
127
+ const sorted = [...points].sort((a, b) => a - b);
128
+ const pieces = [];
129
+ for (let index = 0; index < sorted.length - 1; index += 1) {
130
+ const from = sorted[index];
131
+ const to = sorted[index + 1];
132
+ if (to <= from) {
133
+ continue;
134
+ }
135
+ const mid = (from + to) / 2;
136
+ const isOpen = open.some((span) => span.start <= mid && mid < span.end);
137
+ const blocking = blocked.filter((span) => span.start <= mid && mid < span.end);
138
+ const status = isOpen && blocking.length === 0 ? "available" : "unavailable";
139
+ const previous = pieces[pieces.length - 1];
140
+ const rules = blocking
141
+ .map((span) => span.rule)
142
+ .filter((rule) => rule !== undefined);
143
+ if (previous &&
144
+ previous.status === status &&
145
+ previous.rules.length === rules.length &&
146
+ previous.rules.every((rule, position) => rule === rules[position])) {
147
+ previous.end = to;
148
+ }
149
+ else {
150
+ pieces.push({ start: from, end: to, status, rules });
151
+ }
152
+ }
153
+ return pieces;
154
+ }
155
+ function sumMs(pieces, status) {
156
+ return pieces
157
+ .filter((piece) => piece.status === status)
158
+ .reduce((total, piece) => total + (piece.end - piece.start), 0);
159
+ }
160
+ /**
161
+ * Compile an availability model (plan 11 V4). Pass `now` for lead time and
162
+ * booking windows; without it those fields are skipped (no implicit clock read).
163
+ */
164
+ export function createAvailability(input, options = {}) {
165
+ let spec;
166
+ if (isLegacyAvailabilitySpec(input)) {
167
+ if (!warnedLegacy) {
168
+ warnedLegacy = true;
169
+ console.warn("[chrono] The date-only AvailabilitySpec shape is deprecated; use { open, blocked }.");
170
+ }
171
+ spec = legacyToAvailabilitySpec(input);
172
+ }
173
+ else {
174
+ spec = input;
175
+ }
176
+ const ruleZone = spec.timeZone ?? options.timeZone ?? "UTC";
177
+ const displayZone = options.timeZone ?? ruleZone;
178
+ const now = options.now;
179
+ const openRules = (spec.open ?? []).map(normalizeRule);
180
+ const blockedRules = (spec.blocked ?? []).map(normalizeRule);
181
+ const hasOpen = spec.open !== undefined;
182
+ const dayCache = new Map();
183
+ const statusCache = new Map();
184
+ const cacheKey = (dayEpoch, resourceId) => `${dayEpoch}|${resourceId ?? ""}`;
185
+ const daySpans = (dayEpoch, resourceId) => {
186
+ const key = cacheKey(dayEpoch, resourceId);
187
+ const cached = dayCache.get(key);
188
+ if (cached) {
189
+ return cached;
190
+ }
191
+ const day = fromEpochDay(dayEpoch);
192
+ const spans = [];
193
+ for (const rule of [...openRules, ...blockedRules]) {
194
+ if (rule.type === "range" || !ruleMatchesResource(rule, resourceId)) {
195
+ continue;
196
+ }
197
+ const span = expandRuleDay(rule, day, ruleZone);
198
+ if (span.end > span.start) {
199
+ spans.push({ ...span, rule });
200
+ }
201
+ }
202
+ if (dayCache.size >= CACHE_DAYS) {
203
+ const oldest = dayCache.keys().next().value;
204
+ if (oldest !== undefined)
205
+ dayCache.delete(oldest);
206
+ }
207
+ dayCache.set(key, spans);
208
+ return spans;
209
+ };
210
+ const spansBetween = (rules, start, end, resourceId) => {
211
+ const spans = [];
212
+ // One-day margin on both sides so rules that cross midnight are included (V2 / §12.2).
213
+ const first = Math.max(MIN_DAY, toEpochDay(fromInstant(start, ruleZone)) - 1);
214
+ const last = Math.min(MAX_DAY, toEpochDay(fromInstant(end, ruleZone)) + 1);
215
+ for (let dayEpoch = first; dayEpoch <= last; dayEpoch += 1) {
216
+ for (const span of daySpans(dayEpoch, resourceId)) {
217
+ if (rules.includes(span.rule)) {
218
+ spans.push(span);
219
+ }
220
+ }
221
+ }
222
+ for (const rule of rules) {
223
+ if (rule.type !== "range") {
224
+ continue;
225
+ }
226
+ if (!ruleMatchesResource(rule, resourceId)) {
227
+ continue;
228
+ }
229
+ const span = rangeSpan(rule, ruleZone);
230
+ if (span.end > start && span.start < end) {
231
+ spans.push(span);
232
+ }
233
+ }
234
+ return spans;
235
+ };
236
+ // The lead-time-free base, so business days never depend on lead time (plan 11 §12.2).
237
+ const baseBusiness = spec.leadTime?.businessDays !== undefined || spec.bookingWindow !== undefined
238
+ ? createAvailability({ ...spec, leadTime: undefined, bookingWindow: undefined }, options)
239
+ : undefined;
240
+ const businessDay = (date) => (baseBusiness ?? self).getDayStatus(date) !== "unavailable";
241
+ const shiftBusinessDay = (date, direction) => {
242
+ let day = addDays(date, direction);
243
+ for (let step = 0; step < SEARCH_LIMIT; step += 1) {
244
+ if (businessDay(day))
245
+ return day;
246
+ day = addDays(day, direction);
247
+ }
248
+ throw new RangeError("No business day found within the search limit.");
249
+ };
250
+ const walkBusinessDays = (date, count) => {
251
+ if (count === 0) {
252
+ return businessDay(date) ? date : shiftBusinessDay(date, 1);
253
+ }
254
+ const direction = count > 0 ? 1 : -1;
255
+ let day = date;
256
+ let remaining = Math.abs(count);
257
+ for (let step = 0; step < SEARCH_LIMIT && remaining > 0; step += 1) {
258
+ day = addDays(day, direction);
259
+ if (businessDay(day))
260
+ remaining -= 1;
261
+ }
262
+ if (remaining > 0) {
263
+ throw new RangeError("No business day found within the search limit.");
264
+ }
265
+ return day;
266
+ };
267
+ let notBefore = -Infinity;
268
+ let notAfter = Infinity;
269
+ const lead = spec.leadTime;
270
+ if (now !== undefined) {
271
+ const nowZoned = fromInstant(now, ruleZone);
272
+ const today = plainDate(nowZoned.year, nowZoned.month, nowZoned.day);
273
+ if (lead) {
274
+ if (lead.minutes !== undefined || lead.hours !== undefined) {
275
+ const ms = ((lead.minutes ?? 0) + (lead.hours ?? 0) * 60) * 60_000;
276
+ notBefore = Math.max(notBefore, now + ms);
277
+ }
278
+ if (lead.days !== undefined) {
279
+ notBefore = Math.max(notBefore, startOfDayInstant(addDays(today, lead.days), ruleZone));
280
+ }
281
+ if (lead.businessDays !== undefined) {
282
+ const cutoff = spec.cutoffTime === undefined ? Infinity : timeTokenToSeconds(spec.cutoffTime);
283
+ const nowSeconds = nowZoned.hour * 3600 + nowZoned.minute * 60 + nowZoned.second;
284
+ let orderDay = today;
285
+ if (!businessDay(today) || nowSeconds >= cutoff) {
286
+ orderDay = shiftBusinessDay(today, 1);
287
+ }
288
+ const target = walkBusinessDays(orderDay, lead.businessDays);
289
+ notBefore = Math.max(notBefore, startOfDayInstant(target, ruleZone));
290
+ }
291
+ }
292
+ const window = spec.bookingWindow;
293
+ if (window) {
294
+ let lastDay = today;
295
+ if (window.days !== undefined)
296
+ lastDay = addDays(today, window.days);
297
+ if (window.months !== undefined) {
298
+ lastDay = addMonths(today, window.months);
299
+ }
300
+ notAfter = startOfDayInstant(addDays(lastDay, 1), ruleZone);
301
+ }
302
+ }
303
+ const blockedSpansFor = (start, end, resourceId) => {
304
+ const spans = spansBetween(blockedRules, start, end, resourceId);
305
+ if (notBefore > -Infinity) {
306
+ spans.push({ start: -Infinity, end: notBefore, rule: LEAD_TIME_RULE });
307
+ }
308
+ if (notAfter < Infinity) {
309
+ spans.push({ start: notAfter, end: Infinity, rule: BOOKING_WINDOW_RULE });
310
+ }
311
+ return spans;
312
+ };
313
+ const openSpansFor = (start, end, resourceId) => hasOpen ? mergeSpans(spansBetween(openRules, start, end, resourceId)) : [{ start, end }];
314
+ const piecesBetween = (start, end, resourceId) => {
315
+ if (end <= start) {
316
+ return [];
317
+ }
318
+ const open = openSpansFor(start, end, resourceId);
319
+ const blocked = blockedSpansFor(start, end, resourceId);
320
+ return sweep(open, blocked, start, end);
321
+ };
322
+ const instantAvailable = (at, resourceId) => {
323
+ const pieces = piecesBetween(at - 0.5, at + 0.5, resourceId);
324
+ const piece = pieces.find((value) => value.start <= at && at < value.end);
325
+ return piece?.status === "available";
326
+ };
327
+ const dayWindow = (date) => [
328
+ startOfDayInstant(date, displayZone),
329
+ startOfDayInstant(addDays(date, 1), displayZone),
330
+ ];
331
+ const self = {
332
+ timeZone: ruleZone,
333
+ spec,
334
+ getDayStatus(date, resourceId) {
335
+ const statusKey = cacheKey(toEpochDay(date), resourceId);
336
+ const cachedStatus = statusCache.get(statusKey);
337
+ if (cachedStatus) {
338
+ return cachedStatus;
339
+ }
340
+ const [start, end] = dayWindow(date);
341
+ if (end <= start) {
342
+ return "unavailable";
343
+ }
344
+ const open = openSpansFor(start, end, resourceId);
345
+ const blocked = blockedSpansFor(start, end, resourceId);
346
+ const potential = open.reduce((total, span) => total + Math.max(0, Math.min(span.end, end) - Math.max(span.start, start)), 0);
347
+ if (potential <= 0) {
348
+ return "unavailable";
349
+ }
350
+ const available = sweep(open, blocked, start, end);
351
+ const availableMs = sumMs(available, "available");
352
+ const status = availableMs <= 0 ? "unavailable" : availableMs < potential ? "partial" : "available";
353
+ if (statusCache.size >= CACHE_DAYS) {
354
+ const oldest = statusCache.keys().next().value;
355
+ if (oldest !== undefined)
356
+ statusCache.delete(oldest);
357
+ }
358
+ statusCache.set(statusKey, status);
359
+ return status;
360
+ },
361
+ getIntervals(start, end, resourceId) {
362
+ const from = instantOf(start, displayZone);
363
+ const to = instantOf(end, displayZone);
364
+ return piecesBetween(from, to, resourceId);
365
+ },
366
+ isTimeAvailable(date, time, resourceId) {
367
+ return instantAvailable(instantOf(plainDateTime(date, time), displayZone), resourceId);
368
+ },
369
+ isRangeAvailable(start, end, resourceId) {
370
+ const from = instantOf(start, displayZone);
371
+ const to = instantOf(end, displayZone);
372
+ if (to <= from) {
373
+ return instantAvailable(from, resourceId);
374
+ }
375
+ return piecesBetween(from, to, resourceId).every((piece) => piece.status === "available");
376
+ },
377
+ nextAvailable(date, direction, resourceId) {
378
+ let epochDay = toEpochDay(date) + direction;
379
+ for (let step = 0; step < SEARCH_LIMIT; step += 1) {
380
+ if (epochDay < MIN_DAY || epochDay > MAX_DAY) {
381
+ return null;
382
+ }
383
+ const day = fromEpochDay(epochDay);
384
+ if (self.getDayStatus(day, resourceId) !== "unavailable") {
385
+ return day;
386
+ }
387
+ epochDay += direction;
388
+ }
389
+ return null;
390
+ },
391
+ isAvailable(date) {
392
+ return self.getDayStatus(date) !== "unavailable";
393
+ },
394
+ };
395
+ return self;
396
+ }
397
+ /** A day with some available time (plan 11 V14). */
398
+ export function isBusinessDay(date, availability) {
399
+ return availability.getDayStatus(date) !== "unavailable";
400
+ }
401
+ /** Move `count` business days (0 = `date` or the next business day). */
402
+ export function addBusinessDays(date, count, availability) {
403
+ if (count === 0) {
404
+ let day = date;
405
+ for (let step = 0; step < SEARCH_LIMIT; step += 1) {
406
+ if (isBusinessDay(day, availability))
407
+ return day;
408
+ day = addDays(day, 1);
409
+ }
410
+ throw new RangeError("No business day found within the search limit.");
411
+ }
412
+ const direction = count > 0 ? 1 : -1;
413
+ let remaining = Math.abs(count);
414
+ let day = date;
415
+ for (let step = 0; step < SEARCH_LIMIT && remaining > 0; step += 1) {
416
+ day = addDays(day, direction);
417
+ if (isBusinessDay(day, availability))
418
+ remaining -= 1;
419
+ }
420
+ if (remaining > 0) {
421
+ throw new RangeError("No business day found within the search limit.");
422
+ }
423
+ return day;
424
+ }
425
+ /** Business days in an inclusive date range (plan 11 V14). */
426
+ export function countBusinessDays(range, availability) {
427
+ let count = 0;
428
+ for (let epochDay = toEpochDay(range.start); epochDay <= toEpochDay(range.end); epochDay += 1) {
429
+ if (isBusinessDay(fromEpochDay(epochDay), availability))
430
+ count += 1;
431
+ }
432
+ return count;
433
+ }
434
+ /** The first rule's `reason`, if any (plan 11 V12). */
435
+ export function getAvailabilityLabel(rules) {
436
+ return rules[0]?.reason ?? "";
437
+ }
438
+ const compileCache = new WeakMap();
439
+ /**
440
+ * Compile once per spec identity **and** options (plan 11 R7): the same spec in
441
+ * another zone, or with another `now`, is a different model.
442
+ */
443
+ export function compileAvailability(input, options = {}) {
444
+ if (typeof input.getDayStatus === "function") {
445
+ return input;
446
+ }
447
+ const key = `${options.timeZone ?? ""}|${options.now ?? ""}`;
448
+ let byOptions = compileCache.get(input);
449
+ if (!byOptions) {
450
+ byOptions = new Map();
451
+ compileCache.set(input, byOptions);
452
+ }
453
+ const cached = byOptions.get(key);
454
+ if (cached) {
455
+ return cached;
456
+ }
457
+ if (byOptions.size >= 8) {
458
+ // A moving `now` would otherwise grow the map without bound.
459
+ byOptions.clear();
460
+ }
461
+ const value = createAvailability(input, options);
462
+ byOptions.set(key, value);
463
+ return value;
464
+ }
465
+ let warnedDailyOnly = false;
466
+ /** Time-only components use `daily` rules only (plan 11 V6). */
467
+ export function filterDailyRules(spec) {
468
+ const keep = (rules) => rules?.filter((rule) => rule.type === "daily");
469
+ const open = keep(spec.open);
470
+ const blocked = keep(spec.blocked);
471
+ const dropped = (spec.open?.length ?? 0) -
472
+ (open?.length ?? 0) +
473
+ (spec.blocked?.length ?? 0) -
474
+ (blocked?.length ?? 0);
475
+ if (dropped > 0 && !warnedDailyOnly) {
476
+ warnedDailyOnly = true;
477
+ console.warn("[chrono] Time-only components only use `daily` availability rules; other rule types are ignored.");
478
+ }
479
+ return { ...spec, open, blocked };
480
+ }
@@ -0,0 +1,21 @@
1
+ import type { PlainDate } from "../values/types.js";
2
+ export type DateConstraints = {
3
+ min?: PlainDate | undefined;
4
+ max?: PlainDate | undefined;
5
+ isDateDisabled?: ((date: PlainDate) => boolean) | undefined;
6
+ isDateUnavailable?: (date: PlainDate) => boolean;
7
+ };
8
+ export type DateStatusReason = "before-min" | "after-max" | "disabled" | "unavailable";
9
+ /**
10
+ * `disabled` and `unavailable` are separate statuses with the same
11
+ * selectability (D14). Both stay focusable.
12
+ */
13
+ export type DateStatus = {
14
+ selectable: boolean;
15
+ disabled: boolean;
16
+ unavailable: boolean;
17
+ reason?: DateStatusReason;
18
+ };
19
+ /** Order: min, max, `isDateDisabled`, `isDateUnavailable`. The first hit wins. */
20
+ export declare function getDateStatus(date: PlainDate, constraints?: DateConstraints): DateStatus;
21
+ export declare function isDateSelectable(date: PlainDate, constraints?: DateConstraints): boolean;
@@ -0,0 +1,41 @@
1
+ import { compare } from "../values/compare.js";
2
+ /** Order: min, max, `isDateDisabled`, `isDateUnavailable`. The first hit wins. */
3
+ export function getDateStatus(date, constraints = {}) {
4
+ const { min, max, isDateDisabled, isDateUnavailable } = constraints;
5
+ if (min && compare(date, min) < 0) {
6
+ return {
7
+ selectable: false,
8
+ disabled: true,
9
+ unavailable: false,
10
+ reason: "before-min",
11
+ };
12
+ }
13
+ if (max && compare(date, max) > 0) {
14
+ return {
15
+ selectable: false,
16
+ disabled: true,
17
+ unavailable: false,
18
+ reason: "after-max",
19
+ };
20
+ }
21
+ if (isDateDisabled?.(date)) {
22
+ return {
23
+ selectable: false,
24
+ disabled: true,
25
+ unavailable: false,
26
+ reason: "disabled",
27
+ };
28
+ }
29
+ if (isDateUnavailable?.(date)) {
30
+ return {
31
+ selectable: false,
32
+ disabled: false,
33
+ unavailable: true,
34
+ reason: "unavailable",
35
+ };
36
+ }
37
+ return { selectable: true, disabled: false, unavailable: false };
38
+ }
39
+ export function isDateSelectable(date, constraints = {}) {
40
+ return getDateStatus(date, constraints).selectable;
41
+ }
@@ -0,0 +1,9 @@
1
+ export { getDateStatus, isDateSelectable } from "./date.js";
2
+ export type { DateConstraints, DateStatus, DateStatusReason } from "./date.js";
3
+ export { getTimeStatus, snapTime } from "./time.js";
4
+ export type { TimeConstraints, TimeStatus, TimeStatusReason, TimeStep } from "./time.js";
5
+ export { checkDateRange, checkTimeRange } from "./range.js";
6
+ export type { DateRangeCheck, DateRangeConstraints, DateRangeReason, TimeRangeCheck, TimeRangeConstraints, TimeRangeReason, } from "./range.js";
7
+ export { addBusinessDays, countBusinessDays, compileAvailability, createAvailability, filterDailyRules, getAvailabilityLabel, isBusinessDay, isLegacyAvailabilitySpec, legacyToAvailabilitySpec, } from "./availability.js";
8
+ export type { Availability, AvailabilityBookingWindow, AvailabilityInput, AvailabilityInterval, AvailabilityLeadTime, AvailabilityOptions, AvailabilitySpec, AvailabilityStatus, LegacyAvailabilitySpec, } from "./availability.js";
9
+ export type { AvailabilityRule, AvailabilityRuleMeta, DailyAvailabilityRule, DatesAvailabilityRule, RangeAvailabilityRule, WeeklyAvailabilityRule, } from "./availability-rules.js";
@@ -0,0 +1,4 @@
1
+ export { getDateStatus, isDateSelectable } from "./date.js";
2
+ export { getTimeStatus, snapTime } from "./time.js";
3
+ export { checkDateRange, checkTimeRange } from "./range.js";
4
+ export { addBusinessDays, countBusinessDays, compileAvailability, createAvailability, filterDailyRules, getAvailabilityLabel, isBusinessDay, isLegacyAvailabilitySpec, legacyToAvailabilitySpec, } from "./availability.js";
@@ -0,0 +1,44 @@
1
+ import type { PlainTime } from "../values/types.js";
2
+ import type { DateRange } from "../ranges/date-range.js";
3
+ import type { Availability } from "./availability.js";
4
+ import { type DateConstraints } from "./date.js";
5
+ import { type TimeConstraints } from "./time.js";
6
+ export type DateRangeConstraints = DateConstraints & {
7
+ minDays?: number | undefined;
8
+ maxDays?: number | undefined;
9
+ allowUnavailableInside?: boolean | undefined;
10
+ allowDisabledInside?: boolean | undefined;
11
+ /** Extra unavailable days from {@link createAvailability}. */
12
+ availability?: Availability;
13
+ };
14
+ export type DateRangeReason = "start-invalid" | "end-invalid" | "too-short" | "too-long" | "contains-unavailable" | "contains-disabled";
15
+ export type DateRangeCheck = {
16
+ valid: true;
17
+ } | {
18
+ valid: false;
19
+ reason: DateRangeReason;
20
+ };
21
+ /**
22
+ * Validate an inclusive date range. Endpoints must be selectable; days
23
+ * between them may be unavailable or disabled only when the matching
24
+ * `allow*Inside` option is set. Only days between the endpoints are scanned.
25
+ */
26
+ export declare function checkDateRange(range: DateRange, constraints?: DateRangeConstraints): DateRangeCheck;
27
+ export type TimeRangeConstraints = TimeConstraints & {
28
+ /** Seconds. */
29
+ minDuration?: number;
30
+ maxDuration?: number;
31
+ /** An end before the start means the next day. */
32
+ allowOvernight?: boolean;
33
+ };
34
+ export type TimeRangeReason = "start-invalid" | "end-invalid" | "too-short" | "too-long" | "overnight";
35
+ export type TimeRangeCheck = {
36
+ valid: true;
37
+ } | {
38
+ valid: false;
39
+ reason: TimeRangeReason;
40
+ };
41
+ export declare function checkTimeRange(range: {
42
+ start: PlainTime;
43
+ end: PlainTime;
44
+ }, constraints?: TimeRangeConstraints): TimeRangeCheck;
@@ -0,0 +1,70 @@
1
+ import { compare } from "../values/compare.js";
2
+ import { fromEpochDay, toEpochDay } from "../values/plain-date.js";
3
+ import { SECONDS_PER_DAY, toSecondOfDay } from "../values/plain-time.js";
4
+ import { dateRangeLength } from "../ranges/date-range.js";
5
+ import { getDateStatus } from "./date.js";
6
+ import { getTimeStatus } from "./time.js";
7
+ /**
8
+ * Validate an inclusive date range. Endpoints must be selectable; days
9
+ * between them may be unavailable or disabled only when the matching
10
+ * `allow*Inside` option is set. Only days between the endpoints are scanned.
11
+ */
12
+ export function checkDateRange(range, constraints = {}) {
13
+ const { minDays, maxDays, allowUnavailableInside, allowDisabledInside, availability } = constraints;
14
+ const isUnavailable = (date) => (constraints.isDateUnavailable?.(date) ?? false) ||
15
+ (availability ? !availability.isAvailable(date) : false);
16
+ const withAvailability = {
17
+ ...constraints,
18
+ isDateUnavailable: isUnavailable,
19
+ };
20
+ if (!getDateStatus(range.start, withAvailability).selectable) {
21
+ return { valid: false, reason: "start-invalid" };
22
+ }
23
+ if (!getDateStatus(range.end, withAvailability).selectable) {
24
+ return { valid: false, reason: "end-invalid" };
25
+ }
26
+ const length = dateRangeLength(range);
27
+ if (minDays !== undefined && length < minDays) {
28
+ return { valid: false, reason: "too-short" };
29
+ }
30
+ if (maxDays !== undefined && length > maxDays) {
31
+ return { valid: false, reason: "too-long" };
32
+ }
33
+ if (!allowUnavailableInside || !allowDisabledInside) {
34
+ const first = toEpochDay(range.start) + 1;
35
+ const last = toEpochDay(range.end) - 1;
36
+ for (let day = first; day <= last; day += 1) {
37
+ const status = getDateStatus(fromEpochDay(day), withAvailability);
38
+ if (status.unavailable && !allowUnavailableInside) {
39
+ return { valid: false, reason: "contains-unavailable" };
40
+ }
41
+ if (status.disabled && !allowDisabledInside) {
42
+ return { valid: false, reason: "contains-disabled" };
43
+ }
44
+ }
45
+ }
46
+ return { valid: true };
47
+ }
48
+ export function checkTimeRange(range, constraints = {}) {
49
+ const { minDuration, maxDuration, allowOvernight } = constraints;
50
+ if (!getTimeStatus(range.start, constraints).selectable) {
51
+ return { valid: false, reason: "start-invalid" };
52
+ }
53
+ if (!getTimeStatus(range.end, constraints).selectable) {
54
+ return { valid: false, reason: "end-invalid" };
55
+ }
56
+ let duration = toSecondOfDay(range.end) - toSecondOfDay(range.start);
57
+ if (compare(range.end, range.start) < 0) {
58
+ if (!allowOvernight) {
59
+ return { valid: false, reason: "overnight" };
60
+ }
61
+ duration += SECONDS_PER_DAY;
62
+ }
63
+ if (minDuration !== undefined && duration < minDuration) {
64
+ return { valid: false, reason: "too-short" };
65
+ }
66
+ if (maxDuration !== undefined && duration > maxDuration) {
67
+ return { valid: false, reason: "too-long" };
68
+ }
69
+ return { valid: true };
70
+ }