@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,171 @@
1
+ import { addMonths, compare, createControllable, defaultMessages, endOfMonth, getTextDirection, getWeekInfo, isSameDay, isSameMonth, mergeMessages, plainDate, resolveLocale, startOfMonth, toPlainDate, today as readToday, } from "../../foundation/index.js";
2
+ import { deepEqual } from "../internal/equal.js";
3
+ import { getCalendarTitle } from "../navigation/title.js";
4
+ import { isOutside } from "../views/day.js";
5
+ import { getMiniCalendarLayout } from "../views/mini-calendar.js";
6
+ import { cellAttributes, columnHeaderAttributes, isNavKey, moveInMonthGrid, nextId, navAttributes, toHighlighter, weekNumberAttributes, } from "./shared.js";
7
+ import { withOptional } from "../../foundation/store/with-optional.js";
8
+ const MONTH_VIEW = {
9
+ id: "month",
10
+ layout: "month",
11
+ length: { months: 1 },
12
+ align: "month",
13
+ };
14
+ const sameMonth = (a, b) => a.year === b.year && a.month === b.month;
15
+ const monthOf = (date) => ({
16
+ year: date.year,
17
+ month: date.month,
18
+ });
19
+ export function createMiniCalendarController(initial = {}) {
20
+ let options = initial;
21
+ const id = initial.id ?? nextId("chrono-mini-calendar");
22
+ const titleId = `${id}-title`;
23
+ const todayNow = () => readToday(options.timeZone, options.now);
24
+ const bound = (value) => value === undefined ? undefined : toPlainDate(value, options.timeZone);
25
+ const monthControl = createControllable({
26
+ value: options.month,
27
+ defaultValue: options.defaultMonth ??
28
+ (options.syncWith ? monthOf(options.syncWith.date) : monthOf(todayNow())),
29
+ onChange: (month) => options.onMonthChange?.(month),
30
+ equals: sameMonth,
31
+ });
32
+ let lastSyncDate = options.syncWith?.date;
33
+ let focusedDate = plainDate(monthControl.get().year, monthControl.get().month, 1);
34
+ let state;
35
+ const listeners = new Set();
36
+ const compute = () => {
37
+ const locale = options.locale === undefined ? undefined : resolveLocale(options.locale);
38
+ const weekInfo = getWeekInfo(locale);
39
+ const month = monthControl.get();
40
+ const today = todayNow();
41
+ const min = bound(options.min);
42
+ const max = bound(options.max);
43
+ const first = plainDate(month.year, month.month, 1);
44
+ if (!isSameMonth(focusedDate, first)) {
45
+ // Keep the day of month where possible, otherwise the first day.
46
+ focusedDate = plainDate(month.year, month.month, Math.min(focusedDate.day, endOfMonth(first).day));
47
+ }
48
+ return withOptional({
49
+ id,
50
+ month,
51
+ title: getCalendarTitle({ start: first, end: endOfMonth(first) }, MONTH_VIEW, locale),
52
+ today,
53
+ focusedDate,
54
+ layout: getMiniCalendarLayout({
55
+ month,
56
+ weekStartsOn: options.weekStartsOn ?? weekInfo.firstDay,
57
+ weekInfo,
58
+ locale,
59
+ today,
60
+ focusedDate,
61
+ highlight: options.syncWith?.visibleRange,
62
+ isMarked: options.isMarked,
63
+ selectedDate: bound(options.selectedDate),
64
+ isHighlighted: toHighlighter(options.highlightedDates, options.timeZone),
65
+ min,
66
+ max,
67
+ weekNumbers: options.weekNumbers,
68
+ }),
69
+ canGoPrev: min === undefined || compare(first, min) > 0,
70
+ canGoNext: max === undefined || compare(endOfMonth(first), max) < 0,
71
+ direction: getTextDirection(locale),
72
+ locale,
73
+ messages: mergeMessages(defaultMessages, options.messages),
74
+ });
75
+ };
76
+ const refresh = () => {
77
+ const next = compute();
78
+ if (state && deepEqual(state, next))
79
+ return;
80
+ state = next;
81
+ for (const listener of [...listeners])
82
+ listener(state);
83
+ };
84
+ state = compute();
85
+ const showMonth = (month) => {
86
+ monthControl.set(month);
87
+ refresh();
88
+ };
89
+ const page = (step) => {
90
+ if (step === -1 ? !state.canGoPrev : !state.canGoNext)
91
+ return;
92
+ focusedDate = addMonths(focusedDate, step);
93
+ showMonth(monthOf(addMonths(startOfMonth(focusedDate), 0)));
94
+ };
95
+ const controller = {
96
+ getState: () => state,
97
+ subscribe(listener) {
98
+ listeners.add(listener);
99
+ return () => {
100
+ listeners.delete(listener);
101
+ };
102
+ },
103
+ setOptions(next) {
104
+ options = { ...options, ...next };
105
+ monthControl.sync({ value: options.month });
106
+ const sync = options.syncWith;
107
+ if (sync && (!lastSyncDate || !isSameDay(lastSyncDate, sync.date))) {
108
+ lastSyncDate = sync.date;
109
+ if (!sameMonth(monthControl.get(), monthOf(sync.date))) {
110
+ focusedDate = sync.date;
111
+ monthControl.set(monthOf(sync.date));
112
+ }
113
+ }
114
+ refresh();
115
+ },
116
+ prev: () => page(-1),
117
+ next: () => page(1),
118
+ focusDate(date) {
119
+ focusedDate = date;
120
+ if (!sameMonth(monthControl.get(), monthOf(date)))
121
+ monthControl.set(monthOf(date));
122
+ refresh();
123
+ },
124
+ activateDate(date, _source) {
125
+ controller.focusDate(date);
126
+ if (!isOutside(date, bound(options.min), bound(options.max)))
127
+ options.onNavigate?.(date);
128
+ },
129
+ handleKeyDown(key, modifiers) {
130
+ if (modifiers.ctrl || modifiers.meta)
131
+ return false;
132
+ if (key === "Enter") {
133
+ controller.activateDate(state.focusedDate, "keyboard");
134
+ return true;
135
+ }
136
+ if (!isNavKey(key))
137
+ return false;
138
+ const weekInfo = getWeekInfo(state.locale);
139
+ controller.focusDate(moveInMonthGrid(state.focusedDate, key, modifiers.shift, {
140
+ weekStartsOn: options.weekStartsOn ?? weekInfo.firstDay,
141
+ direction: state.direction,
142
+ min: bound(options.min),
143
+ max: bound(options.max),
144
+ level: "day",
145
+ }, []));
146
+ return true;
147
+ },
148
+ getRootAttributes: () => ({
149
+ "data-chrono-mini-calendar": true,
150
+ dir: state.direction,
151
+ }),
152
+ getTitleAttributes: () => ({ id: titleId, "aria-live": "polite" }),
153
+ getNavAttributes: (kind) => navAttributes(kind === "prev" ? state.messages.previous : state.messages.next, kind === "prev" ? !state.canGoPrev : !state.canGoNext),
154
+ getGridAttributes: () => ({ role: "grid", "aria-labelledby": titleId }),
155
+ getColumnHeaderAttributes: columnHeaderAttributes,
156
+ getCellAttributes: (day) => ({
157
+ ...cellAttributes(day, {
158
+ locale: state.locale,
159
+ messages: state.messages,
160
+ extraLabel: day.marked ? state.messages.hasEvents : undefined,
161
+ }),
162
+ "data-in-range": day.inRange,
163
+ "data-marked": day.marked,
164
+ }),
165
+ getWeekNumberAttributes: (weekNumber) => weekNumberAttributes(weekNumber, state.messages),
166
+ destroy() {
167
+ listeners.clear();
168
+ },
169
+ };
170
+ return controller;
171
+ }
@@ -0,0 +1,33 @@
1
+ import { type Attributes, type DateInput, type DayOfWeek, type GridNavContext, type GridNavKey, type Messages, type PlainDate, type WeekdayHeader } from "../../foundation/index.js";
2
+ import type { CalendarDay } from "../views/day.js";
3
+ /**
4
+ * Ids for calendar and mini-calendar roots without an app id (08-1 Step 2, X11).
5
+ * The engine owns the page-wide counter so two calendars or two Core copies never
6
+ * collide; adapters pass framework ids for SSR.
7
+ */
8
+ export declare function nextId(prefix: string): string;
9
+ export type Modifiers = {
10
+ shift: boolean;
11
+ ctrl: boolean;
12
+ meta: boolean;
13
+ };
14
+ export declare const isNavKey: (key: string) => key is GridNavKey;
15
+ /** Next focus in a month grid, skipping hidden weekdays. */
16
+ export declare function moveInMonthGrid(current: PlainDate, key: GridNavKey, shift: boolean, ctx: GridNavContext, hidden: readonly DayOfWeek[]): PlainDate;
17
+ /** Attributes every day element shares (cells, time-grid headers, agenda days). */
18
+ export declare function dayAttributes(day: CalendarDay, role: string, options: {
19
+ locale?: string | undefined;
20
+ messages: Messages;
21
+ extraLabel?: string | undefined;
22
+ }): Attributes;
23
+ export declare function cellAttributes(day: CalendarDay, options: {
24
+ locale?: string | undefined;
25
+ messages: Messages;
26
+ extraLabel?: string | undefined;
27
+ }): Attributes;
28
+ export declare function columnHeaderAttributes(header: WeekdayHeader): Attributes;
29
+ export declare function weekNumberAttributes(weekNumber: number, messages: Messages): Attributes;
30
+ /** `highlightedDates` as a predicate: an array of dates, or the app's own function. */
31
+ export declare function toHighlighter(highlighted: readonly DateInput[] | ((date: PlainDate) => boolean) | undefined, timeZone: string | undefined): ((date: PlainDate) => boolean) | undefined;
32
+ export declare function navAttributes(label: string, disabled: boolean): Attributes;
33
+ export declare const keyOf: (date: PlainDate) => string;
@@ -0,0 +1,82 @@
1
+ import { dayOfWeek, formatMessage, getDateLabel, createId, nextFocusedDate, toIsoString, toPlainDate, } from "../../foundation/index.js";
2
+ /**
3
+ * Ids for calendar and mini-calendar roots without an app id (08-1 Step 2, X11).
4
+ * The engine owns the page-wide counter so two calendars or two Core copies never
5
+ * collide; adapters pass framework ids for SSR.
6
+ */
7
+ export function nextId(prefix) {
8
+ return createId(prefix);
9
+ }
10
+ const NAV_KEYS = new Set([
11
+ "ArrowLeft",
12
+ "ArrowRight",
13
+ "ArrowUp",
14
+ "ArrowDown",
15
+ "Home",
16
+ "End",
17
+ "PageUp",
18
+ "PageDown",
19
+ ]);
20
+ export const isNavKey = (key) => NAV_KEYS.has(key);
21
+ /** Next focus in a month grid, skipping hidden weekdays. */
22
+ export function moveInMonthGrid(current, key, shift, ctx, hidden) {
23
+ let candidate = nextFocusedDate(current, key, { shift }, ctx);
24
+ for (let guard = 0; guard < 14 && hidden.includes(dayOfWeek(candidate)); guard += 1) {
25
+ candidate = nextFocusedDate(candidate, key, { shift }, ctx);
26
+ }
27
+ return candidate;
28
+ }
29
+ /** Attributes every day element shares (cells, time-grid headers, agenda days). */
30
+ export function dayAttributes(day, role, options) {
31
+ const label = getDateLabel(day.date, options.locale, { today: day.today, selected: day.selected, disabled: day.disabled }, options.messages);
32
+ return {
33
+ role,
34
+ "aria-label": options.extraLabel ? `${label}, ${options.extraLabel}` : label,
35
+ "aria-current": day.today ? "date" : undefined,
36
+ "aria-disabled": day.disabled ? "true" : undefined,
37
+ tabindex: day.focused ? 0 : -1,
38
+ "data-chrono-key": day.key,
39
+ "data-today": day.today,
40
+ "data-weekend": day.weekend,
41
+ "data-disabled": day.disabled,
42
+ "data-focused": day.focused,
43
+ "data-selected": day.selected,
44
+ "data-highlighted": day.highlighted,
45
+ };
46
+ }
47
+ export function cellAttributes(day, options) {
48
+ return {
49
+ ...dayAttributes(day, "gridcell", options),
50
+ "data-outside-month": day.outsideMonth,
51
+ "data-hidden": day.hidden,
52
+ };
53
+ }
54
+ export function columnHeaderAttributes(header) {
55
+ return {
56
+ role: "columnheader",
57
+ abbr: header.long,
58
+ "data-weekend": header.weekend,
59
+ };
60
+ }
61
+ export function weekNumberAttributes(weekNumber, messages) {
62
+ return {
63
+ role: "rowheader",
64
+ "aria-label": formatMessage(messages.weekNumber, { number: weekNumber }),
65
+ };
66
+ }
67
+ /** `highlightedDates` as a predicate: an array of dates, or the app's own function. */
68
+ export function toHighlighter(highlighted, timeZone) {
69
+ if (typeof highlighted === "function" || highlighted === undefined)
70
+ return highlighted;
71
+ const keys = new Set(highlighted.map((value) => toIsoString(toPlainDate(value, timeZone))));
72
+ return (date) => keys.has(toIsoString(date));
73
+ }
74
+ export function navAttributes(label, disabled) {
75
+ return {
76
+ type: "button",
77
+ "aria-label": label,
78
+ "aria-disabled": disabled ? "true" : undefined,
79
+ "data-disabled": disabled,
80
+ };
81
+ }
82
+ export const keyOf = (date) => toIsoString(date);
@@ -0,0 +1,21 @@
1
+ import { type PlainDate, type PlainDateTime } from "../../foundation/index.js";
2
+ import type { AgendaItem, CalendarEventInput, NormalizedEvent } from "./types.js";
3
+ export type AgendaOptions = {
4
+ /** Include days with no events (plan 05 §2.5), default `false`. */
5
+ showEmptyDays?: boolean;
6
+ now?: PlainDateTime;
7
+ };
8
+ /** One agenda day and its events (plan 05 §2.5). */
9
+ export type AgendaDay<TEvent extends CalendarEventInput = CalendarEventInput> = {
10
+ dayKey: string;
11
+ items: AgendaItem<TEvent>[];
12
+ };
13
+ /**
14
+ * The agenda / list view (plan 05 §2.5): one group per day, multi-day events
15
+ * repeated in every day they cover with continuation flags, sorted within a
16
+ * day by all-day first, start time, then duration.
17
+ */
18
+ export declare function layoutAgenda<T extends CalendarEventInput>(events: readonly NormalizedEvent<T>[], days: readonly {
19
+ date: PlainDate;
20
+ key: string;
21
+ }[], options?: AgendaOptions): AgendaDay<T>[];
@@ -0,0 +1,72 @@
1
+ import { compare, toEpochDay } from "../../foundation/index.js";
2
+ import { coveredDays, wallSecondsOf } from "./normalize.js";
3
+ import { compareEventIds } from "./sort.js";
4
+ import { withOptional } from "../../foundation/store/with-optional.js";
5
+ function compareAgenda(a, b) {
6
+ if (a.allDay !== b.allDay) {
7
+ return a.allDay ? -1 : 1;
8
+ }
9
+ const time = compare(a.start, b.start);
10
+ if (time !== 0) {
11
+ return time;
12
+ }
13
+ const da = wallSecondsOf(a.end) - wallSecondsOf(a.start);
14
+ const db = wallSecondsOf(b.end) - wallSecondsOf(b.start);
15
+ if (da !== db) {
16
+ return db - da;
17
+ }
18
+ return compareEventIds(a.event.id, b.event.id);
19
+ }
20
+ /**
21
+ * The agenda / list view (plan 05 §2.5): one group per day, multi-day events
22
+ * repeated in every day they cover with continuation flags, sorted within a
23
+ * day by all-day first, start time, then duration.
24
+ */
25
+ export function layoutAgenda(events, days, options = {}) {
26
+ const showEmptyDays = options.showEmptyDays ?? false;
27
+ const now = options.now;
28
+ const columnByDay = new Map();
29
+ for (let index = 0; index < days.length; index += 1) {
30
+ columnByDay.set(toEpochDay(days[index].date), index);
31
+ }
32
+ const byDay = new Map();
33
+ for (const event of events) {
34
+ const { firstDay, lastDay } = coveredDays(event.start, event.end, event.allDay);
35
+ for (let day = firstDay; day <= lastDay; day += 1) {
36
+ const index = columnByDay.get(day);
37
+ if (index === undefined) {
38
+ continue;
39
+ }
40
+ const dayKey = days[index].key;
41
+ const item = withOptional({
42
+ key: `${event.key}:${dayKey}`,
43
+ event: event.event,
44
+ start: event.start,
45
+ end: event.end,
46
+ allDay: event.allDay,
47
+ continuesBefore: day > firstDay,
48
+ continuesAfter: day < lastDay,
49
+ past: now !== undefined && compare(event.end, now) <= 0,
50
+ recurrence: event.recurrence,
51
+ dayKey,
52
+ });
53
+ const list = byDay.get(index);
54
+ if (list) {
55
+ list.push(item);
56
+ }
57
+ else {
58
+ byDay.set(index, [item]);
59
+ }
60
+ }
61
+ }
62
+ const result = [];
63
+ for (let index = 0; index < days.length; index += 1) {
64
+ const items = byDay.get(index) ?? [];
65
+ if (items.length === 0 && !showEmptyDays) {
66
+ continue;
67
+ }
68
+ items.sort(compareAgenda);
69
+ result.push({ dayKey: days[index].key, items });
70
+ }
71
+ return result;
72
+ }
@@ -0,0 +1,22 @@
1
+ import { type PlainDate, type PlainDateTime } from "../../foundation/index.js";
2
+ import { type DayOverflow } from "./overflow.js";
3
+ import type { AllDayRowSegment, CalendarEventInput, NormalizedEvent } from "./types.js";
4
+ export type AllDayRowOptions = {
5
+ /** `allDayEventLimit`, default 3 (plan 05 §2.6). */
6
+ eventLimit?: number;
7
+ /** Timed events of 24h or more move here (plan 05 E5), default `true`. */
8
+ longEventsInAllDayRow?: boolean | undefined;
9
+ now?: PlainDateTime;
10
+ };
11
+ /**
12
+ * The time-grid all-day row (plan 05 §2.4 step 1): all-day events plus long
13
+ * timed events (E5), packed into lanes across the visible days with a
14
+ * first-fit pass and an `eventLimit` (default 3).
15
+ */
16
+ export declare function layoutAllDayRow<T extends CalendarEventInput>(events: readonly NormalizedEvent<T>[], days: readonly {
17
+ date: PlainDate;
18
+ key: string;
19
+ }[], options?: AllDayRowOptions): {
20
+ segments: AllDayRowSegment<T>[];
21
+ more: DayOverflow<T>[];
22
+ };
@@ -0,0 +1,93 @@
1
+ import { compare, toEpochDay } from "../../foundation/index.js";
2
+ import { coveredDays, wallSecondsOf } from "./normalize.js";
3
+ import { applyPieceLimit } from "./overflow.js";
4
+ import { compareMonthSegments } from "./sort.js";
5
+ import { withOptional } from "../../foundation/store/with-optional.js";
6
+ const SECONDS_PER_DAY = 86400;
7
+ function laneOverlaps(occupied, start, days) {
8
+ if (!occupied) {
9
+ return false;
10
+ }
11
+ for (let c = start; c < start + days; c += 1) {
12
+ if (occupied.has(c)) {
13
+ return true;
14
+ }
15
+ }
16
+ return false;
17
+ }
18
+ /**
19
+ * The time-grid all-day row (plan 05 §2.4 step 1): all-day events plus long
20
+ * timed events (E5), packed into lanes across the visible days with a
21
+ * first-fit pass and an `eventLimit` (default 3).
22
+ */
23
+ export function layoutAllDayRow(events, days, options = {}) {
24
+ const longEvents = options.longEventsInAllDayRow ?? true;
25
+ const columnByDay = new Map();
26
+ for (let index = 0; index < days.length; index += 1) {
27
+ columnByDay.set(toEpochDay(days[index].date), index);
28
+ }
29
+ const pieces = [];
30
+ for (const event of events) {
31
+ const isLong = longEvents && wallSecondsOf(event.end) - wallSecondsOf(event.start) >= SECONDS_PER_DAY;
32
+ if (!event.allDay && !isLong) {
33
+ continue;
34
+ }
35
+ const { firstDay, lastDay } = coveredDays(event.start, event.end, event.allDay);
36
+ let startColumn = -1;
37
+ let endColumn = -1;
38
+ let firstVisibleDay = Number.POSITIVE_INFINITY;
39
+ let lastVisibleDay = Number.NEGATIVE_INFINITY;
40
+ for (let day = firstDay; day <= lastDay; day += 1) {
41
+ const column = columnByDay.get(day);
42
+ if (column === undefined) {
43
+ continue;
44
+ }
45
+ if (startColumn === -1) {
46
+ startColumn = column;
47
+ }
48
+ endColumn = column;
49
+ if (day < firstVisibleDay)
50
+ firstVisibleDay = day;
51
+ if (day > lastVisibleDay)
52
+ lastVisibleDay = day;
53
+ }
54
+ if (startColumn === -1) {
55
+ continue; // no visible day
56
+ }
57
+ const firstKey = days[startColumn]?.key;
58
+ pieces.push(withOptional({
59
+ key: `${event.key}:${firstKey}`,
60
+ event: event.event,
61
+ start: event.start,
62
+ end: event.end,
63
+ allDay: event.allDay,
64
+ continuesBefore: firstVisibleDay > firstDay,
65
+ continuesAfter: lastVisibleDay < lastDay,
66
+ past: options.now !== undefined && compare(event.end, options.now) <= 0,
67
+ recurrence: event.recurrence,
68
+ dayKey: firstKey,
69
+ startColumn,
70
+ days: endColumn - startColumn + 1,
71
+ lane: 0,
72
+ hidden: false,
73
+ }));
74
+ }
75
+ pieces.sort(compareMonthSegments);
76
+ const lanes = [];
77
+ for (const piece of pieces) {
78
+ let lane = 0;
79
+ while (laneOverlaps(lanes[lane], piece.startColumn, piece.days)) {
80
+ lane += 1;
81
+ }
82
+ if (!lanes[lane]) {
83
+ lanes[lane] = new Set();
84
+ }
85
+ for (let c = piece.startColumn; c < piece.startColumn + piece.days; c += 1) {
86
+ lanes[lane]?.add(c);
87
+ }
88
+ piece.lane = lane;
89
+ }
90
+ const limit = options.eventLimit ?? 3;
91
+ const { pieces: limited, more } = applyPieceLimit(pieces, limit, () => "row", (_piece, column) => days[column]?.key);
92
+ return { segments: limited, more };
93
+ }
@@ -0,0 +1,66 @@
1
+ import { type Availability, type AvailabilityRule, type PlainDate, type PlainDateTime, type PlainTime } from "../../foundation/index.js";
2
+ /** Which pieces a layout emits (plan 11 V9). */
3
+ export type BackgroundMode = "unavailable" | "available" | "both" | false;
4
+ export type BackgroundStatus = "available" | "unavailable";
5
+ /** A shaded piece in a time-grid day column or a resource column (plan 11 V9). */
6
+ export type BackgroundPiece = {
7
+ /** `${resourceKey}:${dayKey}:${startMs}`. */
8
+ key: string;
9
+ dayKey: string;
10
+ resourceKey?: string;
11
+ /** Fractions 0–1 of the visible axis (same convention as events, 05 E10). */
12
+ top: number;
13
+ height: number;
14
+ status: BackgroundStatus;
15
+ rules: readonly AvailabilityRule[];
16
+ };
17
+ /** A shaded piece in one timeline row. */
18
+ export type TimelineBackgroundPiece = {
19
+ key: string;
20
+ rowKey: string;
21
+ resourceKey?: string;
22
+ /** Fractions 0–1 of the timeline axis. */
23
+ left: number;
24
+ width: number;
25
+ status: BackgroundStatus;
26
+ rules: readonly AvailabilityRule[];
27
+ };
28
+ export type BackgroundDay = {
29
+ date: PlainDate;
30
+ /** The cell's `data-chrono-key`. */
31
+ key: string;
32
+ resourceId?: string;
33
+ resourceKey?: string;
34
+ };
35
+ export type BackgroundLayoutOptions = {
36
+ availability: Availability;
37
+ /** The display zone (wall times are read here). */
38
+ timeZone: string;
39
+ days: readonly BackgroundDay[];
40
+ dayStart?: PlainTime;
41
+ /** Exclusive. */
42
+ dayEnd?: PlainTime | undefined;
43
+ /** Default `"unavailable"`. */
44
+ mode?: BackgroundMode;
45
+ };
46
+ export type TimelineBackgroundOptions = {
47
+ availability: Availability;
48
+ timeZone: string;
49
+ rows: readonly {
50
+ key: string;
51
+ resourceId?: string;
52
+ resourceKey?: string;
53
+ }[];
54
+ start: PlainDateTime;
55
+ end: PlainDateTime;
56
+ mode?: BackgroundMode;
57
+ };
58
+ /**
59
+ * Pieces for time-grid and resource time-grid day columns (plan 11 V9 / R5:
60
+ * month cells get attributes only). Coordinates match event pieces.
61
+ */
62
+ export declare function layoutBackgrounds(options: BackgroundLayoutOptions): BackgroundPiece[];
63
+ /** Pieces for one timeline axis, per row (plan 11 V9). */
64
+ export declare function layoutTimelineBackgrounds(options: TimelineBackgroundOptions): TimelineBackgroundPiece[];
65
+ /** The `data-chrono-background` attribute record for a piece (plan 11 V9, V12). */
66
+ export declare function backgroundAttributes(piece: BackgroundPiece | TimelineBackgroundPiece): Record<string, string | number | boolean>;
@@ -0,0 +1,106 @@
1
+ import { addDays, fromInstant, fromSecondOfDay, plainDateTime, toSecondOfDay, } from "../../foundation/index.js";
2
+ import { wallSecondsOf } from "./normalize.js";
3
+ import { withOptional } from "../../foundation/store/with-optional.js";
4
+ const SECONDS_PER_DAY = 86400;
5
+ const wants = (mode, status) => mode === "both" || mode === status;
6
+ /**
7
+ * Pieces for time-grid and resource time-grid day columns (plan 11 V9 / R5:
8
+ * month cells get attributes only). Coordinates match event pieces.
9
+ */
10
+ export function layoutBackgrounds(options) {
11
+ const mode = options.mode ?? "unavailable";
12
+ if (mode === false) {
13
+ return [];
14
+ }
15
+ const axisStart = options.dayStart ? toSecondOfDay(options.dayStart) : 0;
16
+ const rawEnd = options.dayEnd ? toSecondOfDay(options.dayEnd) : SECONDS_PER_DAY;
17
+ const axisEnd = rawEnd <= axisStart ? SECONDS_PER_DAY : rawEnd;
18
+ const axisLength = axisEnd - axisStart;
19
+ const pieces = [];
20
+ for (const day of options.days) {
21
+ const start = plainDateTime(day.date, fromSecondOfDay(axisStart));
22
+ const end = plainDateTime(axisEnd >= SECONDS_PER_DAY ? addDays(day.date, 1) : day.date, fromSecondOfDay(axisEnd % SECONDS_PER_DAY));
23
+ for (const interval of options.availability.getIntervals(start, end, day.resourceId)) {
24
+ if (!wants(mode, interval.status)) {
25
+ continue;
26
+ }
27
+ // Wall time on both edges, like event pieces (05 E9): a DST day keeps its axis.
28
+ const wallStart = fromInstant(interval.start, options.timeZone);
29
+ const wallEnd = fromInstant(interval.end, options.timeZone);
30
+ const top = (toSecondOfDay(wallStart) - axisStart) / axisLength;
31
+ const height = (wallSecondsOf(wallEnd) - wallSecondsOf(wallStart)) / axisLength;
32
+ const clampedTop = Math.max(0, Math.min(1, top));
33
+ pieces.push(withOptional({
34
+ key: `${day.resourceKey ?? ""}:${day.key}:${interval.start}`,
35
+ dayKey: day.key,
36
+ resourceKey: day.resourceKey,
37
+ top: clampedTop,
38
+ height: Math.max(0, Math.min(1 - clampedTop, height)),
39
+ status: interval.status,
40
+ rules: interval.rules,
41
+ }));
42
+ }
43
+ }
44
+ return pieces;
45
+ }
46
+ /** Pieces for one timeline axis, per row (plan 11 V9). */
47
+ export function layoutTimelineBackgrounds(options) {
48
+ const mode = options.mode ?? "unavailable";
49
+ if (mode === false) {
50
+ return [];
51
+ }
52
+ const startSeconds = wallSecondsOf(options.start);
53
+ const endSeconds = wallSecondsOf(options.end);
54
+ const length = endSeconds - startSeconds;
55
+ if (length <= 0) {
56
+ return [];
57
+ }
58
+ const pieces = [];
59
+ for (const row of options.rows) {
60
+ for (const interval of options.availability.getIntervals(options.start, options.end, row.resourceId)) {
61
+ if (!wants(mode, interval.status)) {
62
+ continue;
63
+ }
64
+ const wallStart = fromInstant(interval.start, options.timeZone);
65
+ const wallEnd = fromInstant(interval.end, options.timeZone);
66
+ const left = (wallSecondsOf(wallStart) - startSeconds) / length;
67
+ const width = (wallSecondsOf(wallEnd) - wallSecondsOf(wallStart)) / length;
68
+ const clampedLeft = Math.max(0, Math.min(1, left));
69
+ pieces.push(withOptional({
70
+ key: `${row.resourceKey ?? row.key}:${interval.start}`,
71
+ rowKey: row.key,
72
+ resourceKey: row.resourceKey,
73
+ left: clampedLeft,
74
+ width: Math.max(0, Math.min(1 - clampedLeft, width)),
75
+ status: interval.status,
76
+ rules: interval.rules,
77
+ }));
78
+ }
79
+ }
80
+ return pieces;
81
+ }
82
+ /** The `data-chrono-background` attribute record for a piece (plan 11 V9, V12). */
83
+ export function backgroundAttributes(piece) {
84
+ const attributes = {
85
+ "aria-hidden": "true",
86
+ "data-chrono-background": true,
87
+ "data-status": piece.status,
88
+ "data-chrono-key": "dayKey" in piece ? piece.dayKey : piece.rowKey,
89
+ };
90
+ if (piece.resourceKey !== undefined) {
91
+ attributes["data-resource-id"] = piece.resourceKey;
92
+ }
93
+ if ("dayKey" in piece) {
94
+ attributes["--chrono-background-top"] = piece.top;
95
+ attributes["--chrono-background-height"] = piece.height;
96
+ }
97
+ else {
98
+ attributes["--chrono-background-left"] = piece.left;
99
+ attributes["--chrono-background-width"] = piece.width;
100
+ }
101
+ const ruleId = piece.rules[0]?.id;
102
+ if (ruleId !== undefined) {
103
+ attributes["data-rule-id"] = ruleId;
104
+ }
105
+ return attributes;
106
+ }