@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,1396 @@
1
+ import { compileAvailability, addDays, announce, createControllable, createTicker, dayOfWeek, defaultMessages, formatMessage, fromEpochDay, fromSecondOfDay, getTextDirection, getWeekInfo, isDateInRange, isSameDay, mergeMessages, nowZoned, parseCellKey, plainDateTime, plainDate, resolveLocale, toIsoString, toPlainDate, toPlainDateTime, toPlainTime, toSecondOfDay, today as readToday, } from "../../foundation/index.js";
2
+ import { resolveCalendarAvailability } from "../availability.js";
3
+ import { backgroundAttributes, layoutBackgrounds, layoutTimelineBackgrounds, } from "../events/background-layout.js";
4
+ import { statesEqual } from "../internal/equal.js";
5
+ import { canNavigate, firstVisibleDay, getDefinition, getHiddenDays, navigate, } from "../navigation/navigate.js";
6
+ import { getRange, getVisibleRange } from "../navigation/range.js";
7
+ import { getCalendarTitle } from "../navigation/title.js";
8
+ import { resolveViews, } from "../navigation/view-definition.js";
9
+ import { isOutside } from "../views/day.js";
10
+ import { getListLayout } from "../views/list-layout.js";
11
+ import { getMonthLayout } from "../views/month-layout.js";
12
+ import { getTimeGridLayout, } from "../views/time-grid-layout.js";
13
+ import { applyEventLimit, layoutAgenda, layoutAllDayRow, layoutMonthEvents, layoutTimeGridEvents, normalizeEvents, wallSecondsOf, } from "../events/index.js";
14
+ import { getNowIndicator } from "../events/now-indicator.js";
15
+ import { computeSelection, selectionPieces, } from "../interaction/selection.js";
16
+ import { enterCell as enterInteractionCell, stepFocus, } from "../interaction/event-focus.js";
17
+ import { createSelectionPointer } from "../interaction/pointer.js";
18
+ import { createDragPointer } from "../interaction/drag-pointer.js";
19
+ import { warnOnce } from "../events/normalize.js";
20
+ import { zoomTarget } from "../navigation/zoom.js";
21
+ import { resourceCellKey } from "../resources/keys.js";
22
+ import { createDragEngine } from "./drag-engine.js";
23
+ import { cellAttributes, columnHeaderAttributes, dayAttributes, isNavKey, keyOf, moveInMonthGrid, navAttributes, nextId, toHighlighter, weekNumberAttributes, } from "./shared.js";
24
+ import { withOptional } from "../../foundation/store/with-optional.js";
25
+ const day1 = (month) => ({
26
+ calendar: "gregory",
27
+ year: month.year,
28
+ month: month.month,
29
+ day: 1,
30
+ });
31
+ const isCalendarDay = (value) => "date" in value;
32
+ export function createCalendarController(initial = {}) {
33
+ const { lazyStart, ...rest } = initial;
34
+ let options = rest;
35
+ const id = initial.id ?? nextId("chrono-calendar");
36
+ const titleId = `${id}-title`;
37
+ const readConfig = () => {
38
+ const locale = options.locale === undefined ? undefined : resolveLocale(options.locale);
39
+ const weekInfo = getWeekInfo(locale);
40
+ const weekStartsOn = options.weekStartsOn ?? weekInfo.firstDay;
41
+ const timeZone = options.timeZone ?? new Intl.DateTimeFormat().resolvedOptions().timeZone;
42
+ const today = readToday(timeZone, options.now);
43
+ return {
44
+ locale,
45
+ weekInfo,
46
+ weekStartsOn,
47
+ today,
48
+ timeZone,
49
+ messages: mergeMessages(defaultMessages, options.messages),
50
+ nav: {
51
+ views: resolveViews(options.views, weekInfo.weekend),
52
+ weekStartsOn,
53
+ hiddenDays: options.hiddenDays ?? [],
54
+ min: options.min === undefined ? undefined : toPlainDate(options.min, timeZone),
55
+ max: options.max === undefined ? undefined : toPlainDate(options.max, timeZone),
56
+ today,
57
+ },
58
+ };
59
+ };
60
+ let config = readConfig();
61
+ const viewControl = createControllable({
62
+ value: options.view,
63
+ defaultValue: options.defaultView ?? "month",
64
+ onChange: (view) => options.onViewChange?.(view),
65
+ });
66
+ const dateControl = createControllable({
67
+ value: options.date === undefined ? undefined : toPlainDate(options.date, config.timeZone),
68
+ defaultValue: options.defaultDate === undefined
69
+ ? config.today
70
+ : toPlainDate(options.defaultDate, config.timeZone),
71
+ onChange: (date) => options.onDateChange?.(date),
72
+ equals: isSameDay,
73
+ });
74
+ const selectedEventControl = createControllable({
75
+ value: options.selectedEventId === undefined ? undefined : options.selectedEventId,
76
+ defaultValue: options.defaultSelectedEventId ?? null,
77
+ onChange: (selected) => options.onSelectedEventChange?.(selected, eventById(selected)),
78
+ });
79
+ const collapsedControl = createControllable({
80
+ value: options.collapsedResourceIds,
81
+ defaultValue: options.defaultCollapsedResourceIds ?? [],
82
+ onChange: (ids) => options.onCollapsedResourceIdsChange?.(ids),
83
+ equals: (a, b) => a.length === b.length && a.every((id, i) => id === b[i]),
84
+ });
85
+ let custom;
86
+ let focusedDate = dateControl.get();
87
+ let started = false;
88
+ let lastRange;
89
+ let state;
90
+ let nowMs = options.now ?? Date.now();
91
+ let ticker;
92
+ let pointer;
93
+ let dragPointer;
94
+ let eventLimitOverride;
95
+ let focus;
96
+ const listeners = new Set();
97
+ // Memoization of the events pipeline (plan 05 R1): unchanged inputs reuse
98
+ // the same arrays, so the state comparer sees equal references.
99
+ let eventsCache;
100
+ const navState = () => ({
101
+ view: custom ? "custom" : viewControl.get(),
102
+ anchor: dateControl.get(),
103
+ focusedDate,
104
+ custom,
105
+ });
106
+ const normalizeFor = (source, visibleRange) => {
107
+ if (!source) {
108
+ return [];
109
+ }
110
+ return normalizeEvents(source, {
111
+ visibleRange,
112
+ timeZone: config.timeZone,
113
+ recurrence: options.recurrence,
114
+ onRecurrenceError: options.onRecurrenceError,
115
+ });
116
+ };
117
+ const eventsFor = (layout, visibleRange, now) => {
118
+ const source = options.events;
119
+ const timeGrid = options.timeGrid;
120
+ const key = [
121
+ toIsoString(visibleRange.start),
122
+ toIsoString(visibleRange.end),
123
+ config.timeZone,
124
+ layout.kind,
125
+ options.eventLimit ?? eventLimitOverride ?? "auto",
126
+ options.allDayEventLimit ?? 3,
127
+ options.minEventDuration ?? 15,
128
+ options.longEventsInAllDayRow ?? true,
129
+ timeGrid?.start ? toIsoString(toPlainTime(timeGrid.start)) : "",
130
+ timeGrid?.end ? toIsoString(toPlainTime(timeGrid.end)) : "",
131
+ config.nav.hiddenDays.join(","),
132
+ Math.floor(nowMs / 60_000),
133
+ engine.pendingSignature(),
134
+ options.recurrence === undefined ? "" : "recurrence",
135
+ ].join("|");
136
+ if (eventsCache && eventsCache.source === source && eventsCache.key === key) {
137
+ return eventsCache.result;
138
+ }
139
+ const normalized = normalizeFor(source, visibleRange).map((event) => engine.override(event));
140
+ const result = buildEvents(layout, normalized, now);
141
+ eventsCache = { source, key, result };
142
+ return result;
143
+ };
144
+ const buildEvents = (layout, normalized, now) => {
145
+ if (layout.kind === "month") {
146
+ const segments = layoutMonthEvents(normalized, layout, { now });
147
+ const limit = effectiveLimit();
148
+ const { segments: limited, more } = applyEventLimit(segments, limit, layout);
149
+ return { events: limited, more, allDayRow: [], nowIndicator: null };
150
+ }
151
+ if (layout.kind === "time-grid") {
152
+ const timeGrid = options.timeGrid;
153
+ const dayStart = timeGrid?.start === undefined ? undefined : toPlainTime(timeGrid.start);
154
+ const dayEnd = timeGrid?.end === undefined ? undefined : toPlainTime(timeGrid.end);
155
+ const { segments } = layoutAllDayRow(normalized, layout.days, {
156
+ eventLimit: options.allDayEventLimit ?? 3,
157
+ longEventsInAllDayRow: options.longEventsInAllDayRow,
158
+ now,
159
+ });
160
+ const events = layoutTimeGridEvents(normalized, layout.days, {
161
+ dayStart,
162
+ dayEnd,
163
+ minEventDuration: options.minEventDuration,
164
+ longEventsInAllDayRow: options.longEventsInAllDayRow,
165
+ now,
166
+ });
167
+ const nowIndicator = getNowIndicator(now, layout.days, {
168
+ dayStart,
169
+ dayEnd,
170
+ });
171
+ return { events, more: [], allDayRow: segments, nowIndicator };
172
+ }
173
+ const days = layoutAgenda(normalized, layout.days, { now });
174
+ return {
175
+ events: days.flatMap((day) => day.items),
176
+ more: [],
177
+ allDayRow: [],
178
+ nowIndicator: null,
179
+ };
180
+ };
181
+ /** `eventLimit: "auto"` measures after mount; before that it falls back to 3 (plan 05 §3.1). */
182
+ const effectiveLimit = () => {
183
+ if (eventLimitOverride !== undefined) {
184
+ return eventLimitOverride;
185
+ }
186
+ const limit = options.eventLimit;
187
+ if (typeof limit === "number") {
188
+ return limit;
189
+ }
190
+ return limit === "auto" ? 3 : undefined;
191
+ };
192
+ const eventById = (eventId) => {
193
+ if (eventId == null) {
194
+ return null;
195
+ }
196
+ return options.events?.find((event) => event.id === eventId) ?? null;
197
+ };
198
+ const nowDateTime = () => toPlainDateTime(nowZoned(config.timeZone, nowMs), config.timeZone);
199
+ /** The focus cell key: a day key, or a slot key in a time grid (plan 05 R3). */
200
+ const focusCellKey = (layout, date) => {
201
+ const dayKey = keyOf(date);
202
+ if (layout.kind === "time-grid" && layout.slots[0]) {
203
+ return `${dayKey}T${toIsoString(layout.slots[0].start)}`;
204
+ }
205
+ return dayKey;
206
+ };
207
+ let resourcesCache;
208
+ const resourcesFor = (definition, range, visibleRange, layout, now) => {
209
+ const collapsed = collapsedControl.get();
210
+ const timeGrid = options.timeGrid;
211
+ const key = [
212
+ definition.id,
213
+ toIsoString(range.start),
214
+ toIsoString(range.end),
215
+ config.timeZone,
216
+ config.locale ?? "",
217
+ options.resourceGrouping ?? "resource-first",
218
+ collapsed.map(String).join(","),
219
+ JSON.stringify(options.resourceWindow ?? null),
220
+ JSON.stringify(options.slotWindow ?? null),
221
+ timeGrid?.start ? toIsoString(toPlainTime(timeGrid.start)) : "",
222
+ timeGrid?.end ? toIsoString(toPlainTime(timeGrid.end)) : "",
223
+ options.minEventDuration ?? 15,
224
+ options.longEventsInAllDayRow ?? true,
225
+ config.nav.hiddenDays.join(","),
226
+ Math.floor(nowMs / 60_000),
227
+ engine.pendingSignature(),
228
+ options.recurrence === undefined ? "" : "recurrence",
229
+ ].join("|");
230
+ if (resourcesCache &&
231
+ resourcesCache.events === options.events &&
232
+ resourcesCache.resources === options.resources &&
233
+ resourcesCache.label === options.getResourceLabel &&
234
+ resourcesCache.key === key) {
235
+ return resourcesCache.result;
236
+ }
237
+ const normalized = normalizeFor(options.events, visibleRange).map((event) => engine.override(event));
238
+ if (normalized.some((event) => !event.resourceIds?.length)) {
239
+ warnOnce("[chrono] Events without a resourceId are not shown in resource views.");
240
+ }
241
+ const builder = definition.layoutBuilder;
242
+ const result = builder({
243
+ definition,
244
+ range,
245
+ days: layout.days,
246
+ locale: config.locale,
247
+ now,
248
+ events: normalized,
249
+ resources: options.resources ?? [],
250
+ collapsed,
251
+ grouping: options.resourceGrouping ?? "resource-first",
252
+ getLabel: options.getResourceLabel,
253
+ resourceWindow: options.resourceWindow,
254
+ slotWindow: options.slotWindow,
255
+ dayStart: timeGrid?.start === undefined ? undefined : toPlainTime(timeGrid.start),
256
+ dayEnd: timeGrid?.end === undefined ? undefined : toPlainTime(timeGrid.end),
257
+ minEventDuration: options.minEventDuration,
258
+ longEventsInAllDayRow: options.longEventsInAllDayRow,
259
+ });
260
+ resourcesCache = {
261
+ events: options.events,
262
+ resources: options.resources,
263
+ label: options.getResourceLabel,
264
+ key,
265
+ result,
266
+ };
267
+ return result;
268
+ };
269
+ /** Everything a view shows apart from events, selection and the drag preview. */
270
+ const buildView = (nav, definition, range) => {
271
+ const visibleRange = getVisibleRange(definition, range, config.nav);
272
+ const hidden = getHiddenDays(definition, config.nav);
273
+ const selectedDate = options.selectedDate === undefined
274
+ ? undefined
275
+ : toPlainDate(options.selectedDate, config.timeZone);
276
+ const ctx = {
277
+ definition,
278
+ range,
279
+ visibleRange,
280
+ focusedDate,
281
+ hiddenDays: hidden,
282
+ min: config.nav.min,
283
+ max: config.nav.max,
284
+ selectedDate,
285
+ isHighlighted: toHighlighter(options.highlightedDates, config.timeZone),
286
+ weekStartsOn: config.weekStartsOn,
287
+ weekInfo: config.weekInfo,
288
+ locale: config.locale,
289
+ today: config.today,
290
+ weekNumbers: options.weekNumbers ?? false,
291
+ };
292
+ // Resource layouts sit on the time-grid layout for days, slots and focus (plan 10 IG1).
293
+ const layout = definition.layout === "month"
294
+ ? getMonthLayout(ctx)
295
+ : definition.layout === "list"
296
+ ? getListLayout(ctx)
297
+ : getTimeGridLayout(ctx, options.timeGrid);
298
+ return {
299
+ nav,
300
+ definition,
301
+ range,
302
+ visibleRange,
303
+ hidden,
304
+ layout,
305
+ title: getCalendarTitle(range, definition, config.locale),
306
+ direction: getTextDirection(config.locale),
307
+ cellKey: focusCellKey(layout, focusedDate),
308
+ };
309
+ };
310
+ // A drag rebuilds the state on every frame, but the view only changes with these inputs, so it
311
+ // is built once and keeps its identity. Outside a drag it is always rebuilt, so app functions
312
+ // such as `highlightedDates` are read again.
313
+ let dragInputs = [];
314
+ let dragView;
315
+ const compute = (fix = false) => {
316
+ const nav = navState();
317
+ const inputs = [options, config, nav.view, custom, nav.anchor, focusedDate];
318
+ const reused = engine.drag && inputs.every((input, index) => input === dragInputs[index])
319
+ ? dragView
320
+ : undefined;
321
+ const definition = reused?.definition ?? getDefinition(nav, config.nav);
322
+ const range = reused?.range ?? getRange(definition, nav.anchor, config.nav);
323
+ const visibleRange = reused?.visibleRange ?? getVisibleRange(definition, range, config.nav);
324
+ const hidden = reused?.hidden ?? getHiddenDays(definition, config.nav);
325
+ const scope = definition.layout === "month" ? visibleRange : range;
326
+ if (fix && (!isDateInRange(focusedDate, scope) || hidden.includes(dayOfWeek(focusedDate)))) {
327
+ focusedDate =
328
+ isDateInRange(nav.anchor, range) && !hidden.includes(dayOfWeek(nav.anchor))
329
+ ? nav.anchor
330
+ : firstVisibleDay(range, hidden);
331
+ }
332
+ const view = reused ?? buildView(nav, definition, range);
333
+ dragInputs = inputs;
334
+ dragView = engine.drag ? view : undefined;
335
+ const { layout } = view;
336
+ const now = nowDateTime();
337
+ const events = eventsFor(layout, visibleRange, now);
338
+ const resources = definition.layoutBuilder && layout.kind === "time-grid"
339
+ ? resourcesFor(definition, range, visibleRange, layout, now)
340
+ : null;
341
+ const currentFocus = focus ?? { mode: "navigation", cellKey: view.cellKey };
342
+ return withOptional({
343
+ id,
344
+ view: nav.view,
345
+ definition,
346
+ date: nav.anchor,
347
+ focusedDate,
348
+ today: config.today,
349
+ range: view.range,
350
+ visibleRange: view.visibleRange,
351
+ title: view.title,
352
+ layout,
353
+ canGoPrev: canNavigate(nav, -1, config.nav),
354
+ canGoNext: canNavigate(nav, 1, config.nav),
355
+ direction: view.direction,
356
+ locale: config.locale,
357
+ hiddenDays: view.hidden,
358
+ messages: config.messages,
359
+ events: events.events,
360
+ more: events.more,
361
+ allDayRow: events.allDayRow,
362
+ nowIndicator: events.nowIndicator,
363
+ selection: selection ?? null,
364
+ selectedEventId: selectedEventControl.get(),
365
+ focus: currentFocus,
366
+ drag: engine.drag,
367
+ pending: engine.pending,
368
+ resources,
369
+ backgrounds: backgroundsFor(layout, resources, visibleRange),
370
+ });
371
+ };
372
+ const emitRange = () => {
373
+ if (!started) {
374
+ return;
375
+ }
376
+ const visible = state.visibleRange;
377
+ if (!lastRange ||
378
+ !isSameDay(lastRange.start, visible.start) ||
379
+ !isSameDay(lastRange.end, visible.end)) {
380
+ lastRange = visible;
381
+ options.onVisibleRangeChange?.(visible, { view: state.view });
382
+ }
383
+ };
384
+ const refresh = (fix = false) => {
385
+ const next = compute(fix);
386
+ if (state && statesEqual(state, next)) {
387
+ return;
388
+ }
389
+ state = next;
390
+ emitRange();
391
+ for (const listener of [...listeners]) {
392
+ listener(state);
393
+ }
394
+ };
395
+ // Selection state (E14/E15). `selection` is the active range (preview or confirmed).
396
+ let selection = null;
397
+ let selectionAnchor = null;
398
+ let selectionSource = "pointer";
399
+ // Availability (plan 11 V4, R6, R7): compile once per identity, cache the
400
+ // function form for the duration of one drag (its exclude id is constant).
401
+ let dragAvailability;
402
+ const resolveAvailability = (excludeEventId) => {
403
+ const input = options.availability;
404
+ if (input === undefined) {
405
+ return undefined;
406
+ }
407
+ const compileOptions = {
408
+ timeZone: config.timeZone,
409
+ now: options.now,
410
+ };
411
+ if (typeof input !== "function") {
412
+ return resolveCalendarAvailability(input, {}, compileOptions);
413
+ }
414
+ const key = String(excludeEventId ?? "");
415
+ if (dragAvailability?.key === key) {
416
+ return dragAvailability.value;
417
+ }
418
+ const value = resolveCalendarAvailability(input, { excludeEventId }, compileOptions);
419
+ dragAvailability = { key, value };
420
+ return value;
421
+ };
422
+ const selectionCovered = (proposal) => {
423
+ if (options.availabilityBlocksInteraction === false) {
424
+ return false;
425
+ }
426
+ const availability = resolveAvailability();
427
+ return availability ? !availability.isRangeAvailable(proposal.start, proposal.end) : false;
428
+ };
429
+ // Moving and resizing events (plan 09). The engine owns the drag and pending changes.
430
+ let normalizedCache;
431
+ const normalizedNow = () => {
432
+ if (!state)
433
+ return [];
434
+ const visible = state.visibleRange;
435
+ const key = `${toIsoString(visible.start)}|${toIsoString(visible.end)}|${config.timeZone}`;
436
+ if (normalizedCache &&
437
+ normalizedCache.source === options.events &&
438
+ normalizedCache.key === key) {
439
+ return normalizedCache.value;
440
+ }
441
+ const value = normalizeFor(options.events, visible);
442
+ normalizedCache = { source: options.events, key, value };
443
+ return value;
444
+ };
445
+ const dragOptions = () => {
446
+ const base = options;
447
+ if (base.availabilityBlocksInteraction === false || base.availability === undefined) {
448
+ return base;
449
+ }
450
+ return {
451
+ ...base,
452
+ validateEventChange: (proposal) => {
453
+ const availability = resolveAvailability(proposal.event.id);
454
+ if (availability && !availability.isRangeAvailable(proposal.to.start, proposal.to.end)) {
455
+ return false;
456
+ }
457
+ return base.validateEventChange?.(proposal) ?? true;
458
+ },
459
+ };
460
+ };
461
+ const engine = createDragEngine({
462
+ options: dragOptions,
463
+ layoutKind: () => (state ? state.layout.kind : "month"),
464
+ timeZone: () => config.timeZone,
465
+ locale: () => config.locale,
466
+ messages: () => config.messages,
467
+ rtl: () => getTextDirection(config.locale) === "rtl",
468
+ normalized: normalizedNow,
469
+ segmentEvent: (segmentKey) => [...state.events, ...state.allDayRow].find((segment) => segment.key === segmentKey)?.event,
470
+ segmentNormalized: (segmentKey) => {
471
+ let best;
472
+ for (const item of normalizedNow()) {
473
+ if ((segmentKey === item.key || segmentKey.startsWith(`${item.key}:`)) &&
474
+ (best === undefined || item.key.length > best.key.length)) {
475
+ best = item;
476
+ }
477
+ }
478
+ return best;
479
+ },
480
+ buildPreview: (event) => {
481
+ const built = buildEvents(state.layout, [event], nowDateTime());
482
+ return { events: built.events, allDayRow: built.allDayRow };
483
+ },
484
+ refresh: () => refresh(),
485
+ });
486
+ const SECONDS_PER_DAY = 86400;
487
+ // Availability on cells and slots (plan 11 V7, V12): attributes plus a label suffix.
488
+ const reasonOf = (rules) => options.getAvailabilityLabel ? options.getAvailabilityLabel(rules) : (rules[0]?.reason ?? "");
489
+ const dayAvailability = (date) => {
490
+ const availability = resolveAvailability();
491
+ if (!availability) {
492
+ return { status: "available", label: "" };
493
+ }
494
+ const status = availability.getDayStatus(date);
495
+ if (status !== "unavailable") {
496
+ return { status, label: "" };
497
+ }
498
+ const piece = availability
499
+ .getIntervals(date, addDays(date, 1))
500
+ .find((interval) => interval.status === "unavailable");
501
+ const reason = piece ? reasonOf(piece.rules) : "";
502
+ return {
503
+ status,
504
+ label: reason ? `${state.messages.unavailable}: ${reason}` : state.messages.unavailable,
505
+ };
506
+ };
507
+ const slotUnavailable = (slot, day) => {
508
+ const availability = resolveAvailability();
509
+ if (!availability) {
510
+ return false;
511
+ }
512
+ const end = slot.endSecond >= SECONDS_PER_DAY
513
+ ? plainDateTime(addDays(day.date, 1), fromSecondOfDay(0))
514
+ : plainDateTime(day.date, fromSecondOfDay(slot.endSecond));
515
+ return !availability.isRangeAvailable(plainDateTime(day.date, slot.start), end);
516
+ };
517
+ // Availability backgrounds (plan 11 V9). The array is memoized so
518
+ // `statesEqual` can compare it by reference (rule `data` is app-owned).
519
+ const EMPTY_BACKGROUNDS = [];
520
+ let backgroundsCache;
521
+ const objectIds = new WeakMap();
522
+ let objectIdCounter = 0;
523
+ const objectKey = (value) => {
524
+ if (value === null || value === undefined) {
525
+ return "";
526
+ }
527
+ if (typeof value === "object" || typeof value === "function") {
528
+ let id = objectIds.get(value);
529
+ if (id === undefined) {
530
+ id = ++objectIdCounter;
531
+ objectIds.set(value, id);
532
+ }
533
+ return String(id);
534
+ }
535
+ return String(value);
536
+ };
537
+ const wallFromSeconds = (seconds) => {
538
+ const day = Math.floor(seconds / SECONDS_PER_DAY);
539
+ return plainDateTime(fromEpochDay(day), fromSecondOfDay(seconds - day * SECONDS_PER_DAY));
540
+ };
541
+ const backgroundsFor = (layout, resources, visibleRange) => {
542
+ const mode = options.backgrounds ?? "unavailable";
543
+ if (mode === false || options.availability === undefined) {
544
+ return EMPTY_BACKGROUNDS;
545
+ }
546
+ const availability = resolveAvailability();
547
+ if (!availability) {
548
+ return EMPTY_BACKGROUNDS;
549
+ }
550
+ const availabilityOf = (resource) => {
551
+ const spec = options.getResourceAvailability?.(resource);
552
+ return spec
553
+ ? compileAvailability(spec, {
554
+ timeZone: config.timeZone,
555
+ now: options.now,
556
+ })
557
+ : availability;
558
+ };
559
+ const base = [
560
+ toIsoString(visibleRange.start),
561
+ toIsoString(visibleRange.end),
562
+ config.timeZone,
563
+ String(mode),
564
+ objectKey(options.availability),
565
+ objectKey(options.events),
566
+ objectKey(options.getResourceAvailability),
567
+ String(options.now ?? ""),
568
+ layout.kind === "time-grid"
569
+ ? `${layout.slots[0]?.startSecond ?? ""}-${layout.slots[layout.slots.length - 1]?.endSecond ?? ""}`
570
+ : "",
571
+ ].join("|");
572
+ const signature = resources
573
+ ? `${base}|${resources.kind}|${resources.kind === "timeline"
574
+ ? resources.rows.map((row) => row.key).join(",")
575
+ : resources.columns.map((column) => column.key).join(",")}`
576
+ : `${base}|${layout.kind}|${layout.kind === "time-grid" ? layout.days.map((day) => day.key).join(",") : ""}`;
577
+ if (backgroundsCache?.key === signature) {
578
+ return backgroundsCache.value;
579
+ }
580
+ let value = EMPTY_BACKGROUNDS;
581
+ if (resources?.kind === "timeline") {
582
+ const axis = resources.axis;
583
+ const end = wallFromSeconds(wallSecondsOf(axis.start) + axis.length);
584
+ value = resources.rows.flatMap((row) => layoutTimelineBackgrounds({
585
+ availability: availabilityOf(row.resource),
586
+ timeZone: config.timeZone,
587
+ rows: [{ key: row.key, resourceId: String(row.id), resourceKey: row.key }],
588
+ start: axis.start,
589
+ end,
590
+ mode,
591
+ }));
592
+ }
593
+ else if (resources?.kind === "resource-time-grid") {
594
+ const slots = layout.kind === "time-grid" ? layout.slots : [];
595
+ const dayEnd = slots[slots.length - 1]
596
+ ? fromSecondOfDay(slots[slots.length - 1].endSecond % SECONDS_PER_DAY)
597
+ : undefined;
598
+ value = resources.columns.flatMap((column) => layoutBackgrounds({
599
+ availability: availabilityOf(column.resource),
600
+ timeZone: config.timeZone,
601
+ days: [
602
+ {
603
+ date: column.day.date,
604
+ key: column.day.key,
605
+ resourceId: String(column.resourceId),
606
+ resourceKey: column.resourceKey,
607
+ },
608
+ ],
609
+ dayStart: slots[0]?.start,
610
+ dayEnd,
611
+ mode,
612
+ }));
613
+ }
614
+ else if (layout.kind === "time-grid") {
615
+ const slots = layout.slots;
616
+ value = layoutBackgrounds({
617
+ availability,
618
+ timeZone: config.timeZone,
619
+ days: layout.days.map((day) => ({ date: day.date, key: day.key })),
620
+ dayStart: slots[0]?.start,
621
+ dayEnd: slots[slots.length - 1]
622
+ ? fromSecondOfDay(slots[slots.length - 1].endSecond % SECONDS_PER_DAY)
623
+ : undefined,
624
+ mode,
625
+ });
626
+ }
627
+ backgroundsCache = { key: signature, value };
628
+ return value;
629
+ };
630
+ state = compute(true);
631
+ const apply = (next) => {
632
+ custom = next.custom;
633
+ focusedDate = next.focusedDate;
634
+ if (!next.custom && next.view !== viewControl.get()) {
635
+ viewControl.set(next.view);
636
+ }
637
+ if (!isSameDay(next.anchor, dateControl.get())) {
638
+ dateControl.set(next.anchor);
639
+ }
640
+ refresh();
641
+ };
642
+ const go = (action) => apply(navigate(navState(), action, config.nav));
643
+ const moveFocusTo = (target) => {
644
+ if (!isDateInRange(target, state.range)) {
645
+ go({ goTo: target });
646
+ return;
647
+ }
648
+ focusedDate = target;
649
+ refresh();
650
+ };
651
+ const visibleDays = () => (state.layout.kind === "month" ? [] : state.layout.days);
652
+ const cellItems = (cellKey) => {
653
+ const segments = segmentList();
654
+ const keys = segments
655
+ .filter((segment) => segmentCellKey(segment) === cellKey)
656
+ .map((segment) => segment.key);
657
+ const hasMore = state.more.some((m) => m.dayKey === cellKey);
658
+ return hasMore ? [...keys, `more:${cellKey}`] : keys;
659
+ };
660
+ const segmentList = () => {
661
+ const events = state.events;
662
+ if (Array.isArray(events)) {
663
+ return events;
664
+ }
665
+ return [];
666
+ };
667
+ const segmentCellKey = (segment) => {
668
+ if ("dayKey" in segment) {
669
+ return segment.dayKey;
670
+ }
671
+ if ("month" in segment) {
672
+ // Month segment: resolve via the layout.
673
+ return monthSegmentCellKey(segment);
674
+ }
675
+ return "";
676
+ };
677
+ const monthSegmentCellKey = (segment) => {
678
+ const layout = state.layout;
679
+ if (layout.kind !== "month") {
680
+ return "";
681
+ }
682
+ const month = layout.months[segment.month];
683
+ const week = month?.weeks[segment.week];
684
+ const day = week?.days.filter((d) => !d.hidden)[segment.startColumn];
685
+ return day?.key ?? "";
686
+ };
687
+ const handleKeyDown = (key, modifiers) => {
688
+ if (modifiers.ctrl || modifiers.meta) {
689
+ return false;
690
+ }
691
+ // 0. Keyboard editing of an event (plan 09 M10).
692
+ if (engine.isEditing()) {
693
+ return engine.handleKey(key, modifiers);
694
+ }
695
+ // 1. Active selection preview.
696
+ if (selection) {
697
+ if (key === "Escape") {
698
+ cancelSelection();
699
+ return true;
700
+ }
701
+ if (key === "Enter") {
702
+ confirmSelection();
703
+ return true;
704
+ }
705
+ if (isNavKey(key) && modifiers.shift) {
706
+ extendSelectionKeyboard(key);
707
+ return true;
708
+ }
709
+ return false;
710
+ }
711
+ // 2. Interaction mode (focus on events inside a cell).
712
+ if (state.focus.mode === "interaction") {
713
+ const edit = state.focus.itemKey ? engine.shortcut(key, { ...modifiers, alt: false }) : null;
714
+ if (edit && state.focus.itemKey && engine.canEditSegment(state.focus.itemKey, edit)) {
715
+ return engine.start(edit, state.focus.itemKey, "keyboard");
716
+ }
717
+ if (key === " ") {
718
+ const segment = segmentByKey(state.focus.itemKey);
719
+ if (segment) {
720
+ selectEvent(segment.event.id);
721
+ announce(formatMessage(state.messages.eventSelected, {}));
722
+ return true;
723
+ }
724
+ }
725
+ if (key === "Enter") {
726
+ const itemKey = state.focus.itemKey;
727
+ if (itemKey?.startsWith("more:")) {
728
+ activateMore(state.focus.cellKey);
729
+ return true;
730
+ }
731
+ const segment = segmentByKey(itemKey);
732
+ if (segment) {
733
+ activateEvent(segment.key, "keyboard");
734
+ return true;
735
+ }
736
+ }
737
+ const next = stepFocus(state.focus, key, modifiers, cellItems(state.focus.cellKey));
738
+ if (next) {
739
+ focus = next.mode === "navigation" ? undefined : next;
740
+ refresh();
741
+ return true;
742
+ }
743
+ return false;
744
+ }
745
+ // 3. Navigation mode.
746
+ if (key === "Enter") {
747
+ if (modifiers.shift) {
748
+ controller.activateDate(state.focusedDate, "keyboard");
749
+ return true;
750
+ }
751
+ const cellKey = keyOf(state.focusedDate);
752
+ if (cellItems(cellKey).length > 0) {
753
+ enterCellAction(cellKey);
754
+ return true;
755
+ }
756
+ controller.activateDate(state.focusedDate, "keyboard");
757
+ return true;
758
+ }
759
+ if (key === "F2") {
760
+ const cellKey = keyOf(state.focusedDate);
761
+ if (cellItems(cellKey).length > 0) {
762
+ enterCellAction(cellKey);
763
+ return true;
764
+ }
765
+ }
766
+ if (isNavKey(key) && modifiers.shift && options.selectable) {
767
+ startSelection({ date: state.focusedDate }, "keyboard");
768
+ return true;
769
+ }
770
+ if (!isNavKey(key)) {
771
+ return false;
772
+ }
773
+ const rtl = state.direction === "rtl";
774
+ if (state.definition.layout === "month") {
775
+ moveFocusTo(moveInMonthGrid(state.focusedDate, key, modifiers.shift, {
776
+ weekStartsOn: config.weekStartsOn,
777
+ direction: state.direction,
778
+ min: config.nav.min,
779
+ max: config.nav.max,
780
+ level: "day",
781
+ }, state.hiddenDays));
782
+ return true;
783
+ }
784
+ if (key === "PageUp" || key === "PageDown") {
785
+ go(key === "PageUp" ? "prev" : "next");
786
+ return true;
787
+ }
788
+ const days = visibleDays();
789
+ const keys = days.map((day) => day.key);
790
+ const index = keys.indexOf(keyOf(state.focusedDate));
791
+ if (key === "Home" || key === "End") {
792
+ const edge = key === "Home" ? days[0] : days[days.length - 1];
793
+ if (edge) {
794
+ moveFocusTo(edge.date);
795
+ }
796
+ return true;
797
+ }
798
+ const list = state.definition.layout === "list";
799
+ const forward = key === "ArrowRight" ? !rtl : key === "ArrowLeft" ? rtl : key === "ArrowDown" ? list : false;
800
+ const backward = key === "ArrowLeft" ? !rtl : key === "ArrowRight" ? rtl : key === "ArrowUp" ? list : false;
801
+ if (!forward && !backward) {
802
+ return true;
803
+ }
804
+ const step = forward ? 1 : -1;
805
+ const neighbor = days[index + step];
806
+ if (neighbor) {
807
+ moveFocusTo(neighbor.date);
808
+ }
809
+ else {
810
+ let candidate = addDays(state.focusedDate, step);
811
+ for (let guard = 0; guard < 7 && state.hiddenDays.includes(dayOfWeek(candidate)); guard += 1) {
812
+ candidate = addDays(candidate, step);
813
+ }
814
+ go({ goTo: candidate });
815
+ }
816
+ return true;
817
+ };
818
+ const segmentByKey = (itemKey) => {
819
+ if (!itemKey) {
820
+ return undefined;
821
+ }
822
+ return segmentList().find((segment) => segment.key === itemKey);
823
+ };
824
+ const extendSelectionKeyboard = (key) => {
825
+ const days = state.layout.kind === "month" ? [] : state.layout.days;
826
+ const keys = days.map((day) => day.key);
827
+ const index = keys.indexOf(keyOf(state.focusedDate));
828
+ const target = days[index + (key === "ArrowLeft" || key === "ArrowUp" ? -1 : 1)];
829
+ if (target) {
830
+ extendSelection({ date: target.date });
831
+ }
832
+ };
833
+ const activateMore = (cellKey) => {
834
+ const overflow = state.more.find((m) => m.dayKey === cellKey);
835
+ if (!overflow) {
836
+ return;
837
+ }
838
+ const date = toPlainDate(cellKey, config.timeZone);
839
+ options.onMoreActivate?.(date, [...overflow.events]);
840
+ };
841
+ const selectionToProposal = (range) => ({
842
+ kind: "create",
843
+ start: range.allDay
844
+ ? plainDate(range.start.year, range.start.month, range.start.day)
845
+ : range.start,
846
+ end: range.allDay ? plainDate(range.end.year, range.end.month, range.end.day) : range.end,
847
+ allDay: range.allDay,
848
+ source: selectionSource,
849
+ });
850
+ const selectEvent = (eventId) => {
851
+ selectedEventControl.set(eventId);
852
+ refresh();
853
+ };
854
+ const activateEvent = (segmentKey, source) => {
855
+ const segment = segmentByKey(segmentKey);
856
+ if (!segment) {
857
+ return;
858
+ }
859
+ options.onEventActivate?.(segment.event, {
860
+ source,
861
+ dayKey: segmentCellKey(segment),
862
+ });
863
+ };
864
+ const enterCellAction = (cellKey) => {
865
+ focus = enterInteractionCell(cellKey, cellItems(cellKey));
866
+ refresh();
867
+ };
868
+ const exitCellAction = () => {
869
+ focus = undefined;
870
+ refresh();
871
+ };
872
+ const startSelection = (target, source) => {
873
+ if (!options.selectable) {
874
+ return;
875
+ }
876
+ selectionSource = source;
877
+ const allDay = state.definition.layout === "month";
878
+ // The anchor is the cell the selection starts on (plan 05 E14).
879
+ selectionAnchor = withOptional(allDay ? { date: target.date } : { date: target.date, time: target.time });
880
+ selection = computeSelection(withOptional(selectionAnchor), target, {
881
+ allDay,
882
+ slotDurationMinutes: options.timeGrid?.step ?? 30,
883
+ maxDurationMinutes: options.maxSelectionDuration,
884
+ });
885
+ refresh();
886
+ };
887
+ const extendSelection = (target) => {
888
+ if (!selection || !selectionAnchor) {
889
+ return;
890
+ }
891
+ selection = computeSelection(selectionAnchor, target, {
892
+ allDay: selection.allDay,
893
+ slotDurationMinutes: options.timeGrid?.step ?? 30,
894
+ maxDurationMinutes: options.maxSelectionDuration,
895
+ });
896
+ refresh();
897
+ };
898
+ const confirmSelection = () => {
899
+ if (!selection) {
900
+ return;
901
+ }
902
+ const proposal = selectionToProposal(selection);
903
+ if (selectionCovered(proposal)) {
904
+ return;
905
+ }
906
+ if (options.validateSelection && !options.validateSelection(proposal)) {
907
+ return;
908
+ }
909
+ options.onSelectRange?.(proposal);
910
+ options.onSelectionChange?.(proposal);
911
+ announce(formatMessage(state.messages.selectionCreated, {
912
+ range: toIsoString(selection.start),
913
+ }), options.announcer);
914
+ };
915
+ const cancelSelection = () => {
916
+ if (!selection) {
917
+ return;
918
+ }
919
+ selection = null;
920
+ selectionAnchor = null;
921
+ announce(state.messages.selectionCancelled, options.announcer);
922
+ refresh();
923
+ };
924
+ const clearSelection = () => {
925
+ selection = null;
926
+ selectionAnchor = null;
927
+ refresh();
928
+ };
929
+ const setEventLimit = (limit) => {
930
+ if (eventLimitOverride === limit) {
931
+ return;
932
+ }
933
+ eventLimitOverride = limit;
934
+ refresh();
935
+ };
936
+ const controller = {
937
+ getState: () => state,
938
+ subscribe(listener) {
939
+ listeners.add(listener);
940
+ return () => {
941
+ listeners.delete(listener);
942
+ };
943
+ },
944
+ setOptions(next) {
945
+ const previousView = options.view;
946
+ options = { ...options, ...next };
947
+ if (next.view !== undefined && next.view !== previousView) {
948
+ custom = undefined;
949
+ }
950
+ if (next.now !== undefined) {
951
+ nowMs = next.now;
952
+ }
953
+ config = readConfig();
954
+ viewControl.sync({ value: options.view });
955
+ dateControl.sync({
956
+ value: options.date === undefined ? undefined : toPlainDate(options.date, config.timeZone),
957
+ });
958
+ selectedEventControl.sync({ value: options.selectedEventId });
959
+ collapsedControl.sync({ value: options.collapsedResourceIds });
960
+ if (next.events !== undefined) {
961
+ engine.onEventsChanged(normalizedNow());
962
+ }
963
+ refresh(true);
964
+ },
965
+ start() {
966
+ if (started) {
967
+ return;
968
+ }
969
+ started = true;
970
+ emitRange();
971
+ },
972
+ prev: () => go("prev"),
973
+ next: () => go("next"),
974
+ today: () => go("today"),
975
+ toggleResource(id) {
976
+ const current = collapsedControl.get();
977
+ const key = String(id);
978
+ collapsedControl.set(current.some((entry) => String(entry) === key)
979
+ ? current.filter((entry) => String(entry) !== key)
980
+ : [...current, id]);
981
+ refresh();
982
+ },
983
+ zoomIn() {
984
+ const next = zoomTarget(options.zoomLevels ?? [], state.view, -1);
985
+ if (next)
986
+ go({ view: next });
987
+ },
988
+ zoomOut() {
989
+ const next = zoomTarget(options.zoomLevels ?? [], state.view, 1);
990
+ if (next)
991
+ go({ view: next });
992
+ },
993
+ getResourceHeaderAttributes: (column) => ({
994
+ role: "columnheader",
995
+ "aria-label": column.label,
996
+ "data-resource-id": column.resourceKey,
997
+ "data-chrono-key": resourceCellKey(column.day.key, column.resourceKey),
998
+ }),
999
+ getResourceGroupHeaderAttributes: (group) => ({
1000
+ role: "columnheader",
1001
+ "aria-label": group.label,
1002
+ "aria-colspan": group.colSpan,
1003
+ "data-resource-id": group.resourceKey,
1004
+ "data-resource-group": true,
1005
+ "data-level": group.level,
1006
+ }),
1007
+ getTimelineAttributes: () => ({
1008
+ role: state.resources?.kind === "timeline" && state.resources.grouped ? "treegrid" : "grid",
1009
+ "aria-rowcount": state.resources?.kind === "timeline"
1010
+ ? state.resources.window.totalRows + state.resources.axis.headerRows.length
1011
+ : undefined,
1012
+ "aria-colcount": state.resources?.kind === "timeline" ? state.resources.window.totalColumns : undefined,
1013
+ }),
1014
+ getTimelineHeaderCellAttributes: (cell) => ({
1015
+ role: "columnheader",
1016
+ "aria-colspan": cell.span,
1017
+ "aria-label": cell.label,
1018
+ "data-header-level": cell.unit,
1019
+ }),
1020
+ getTimelineRowAttributes: (row) => {
1021
+ const headerRows = state.resources?.kind === "timeline" ? state.resources.axis.headerRows.length : 0;
1022
+ return {
1023
+ role: "row",
1024
+ "aria-level": row.level + 1,
1025
+ "aria-expanded": row.group ? String(row.expanded) : undefined,
1026
+ "aria-rowindex": row.index + 1 + headerRows,
1027
+ "data-resource-id": row.key,
1028
+ "data-collapsed": row.group && !row.expanded,
1029
+ "--chrono-row-lanes": row.lanes,
1030
+ };
1031
+ },
1032
+ getTimelineRowHeaderAttributes: (row) => ({
1033
+ role: "rowheader",
1034
+ "aria-label": row.label,
1035
+ "data-resource-id": row.key,
1036
+ "data-level": row.level,
1037
+ "data-resource-group": row.group,
1038
+ }),
1039
+ getTimelineCellAttributes: (row, slot) => ({
1040
+ role: "gridcell",
1041
+ "data-chrono-key": resourceCellKey(slot.key, row.key),
1042
+ "data-resource-id": row.key,
1043
+ }),
1044
+ getResourcePieceAttributes: (piece) => ({
1045
+ "data-chrono-event": true,
1046
+ "data-resource-id": piece.resourceKey,
1047
+ "data-past": piece.past,
1048
+ "data-continues-before": piece.continuesBefore,
1049
+ "data-continues-after": piece.continuesAfter,
1050
+ "data-all-day": piece.allDay,
1051
+ "data-recurring": piece.recurrence !== undefined || piece.event.recurringId !== undefined,
1052
+ "data-override": piece.recurrence?.isOverride === true,
1053
+ "data-selected": selectedEventControl.get() === piece.event.id,
1054
+ "--chrono-event-lane": piece.lane,
1055
+ "--chrono-event-left": piece.left,
1056
+ "--chrono-event-width": piece.width,
1057
+ "--chrono-event-top": piece.top,
1058
+ "--chrono-event-height": piece.height,
1059
+ "--chrono-event-column": piece.column,
1060
+ "--chrono-event-columns": piece.columns,
1061
+ "--chrono-event-span": piece.span,
1062
+ }),
1063
+ goTo: (date) => go({ goTo: toPlainDate(date, config.timeZone) }),
1064
+ setView: (view) => go({ view }),
1065
+ setRange: (range) => go({ range }),
1066
+ focusDate(date) {
1067
+ if (isDateInRange(date, state.visibleRange)) {
1068
+ focusedDate = date;
1069
+ focus = undefined;
1070
+ refresh();
1071
+ }
1072
+ else {
1073
+ go({ goTo: date });
1074
+ }
1075
+ },
1076
+ activateDate(date, source) {
1077
+ controller.focusDate(date);
1078
+ if (!isOutside(date, config.nav.min, config.nav.max)) {
1079
+ options.onDateActivate?.(date, { view: state.view, source });
1080
+ }
1081
+ },
1082
+ handleKeyDown,
1083
+ selectEvent,
1084
+ activateEvent,
1085
+ activateMore,
1086
+ enterCell: enterCellAction,
1087
+ exitCell: exitCellAction,
1088
+ startSelection,
1089
+ extendSelection,
1090
+ confirmSelection,
1091
+ cancelSelection,
1092
+ clearSelection,
1093
+ setEventLimit,
1094
+ getEventLimit: () => options.eventLimit,
1095
+ startMove: (segmentKey, source = "pointer") => engine.start("move", segmentKey, source),
1096
+ startResize: (segmentKey, edge, source = "pointer") => engine.start(edge === "start" ? "resize-start" : "resize-end", segmentKey, source),
1097
+ updateDrag: (target) => engine.update(target),
1098
+ dropDrag: () => engine.drop(),
1099
+ cancelDrag: () => engine.cancel(),
1100
+ getResizeHandleAttributes: (segment, edge) => engine.resizeHandle(segment.key, edge),
1101
+ getDragPreviewAttributes: (piece) => {
1102
+ const { role: _r, tabindex: _t, "aria-pressed": _p, ...rest } = eventAttributes(piece);
1103
+ return {
1104
+ ...rest,
1105
+ "data-chrono-event": undefined,
1106
+ "data-chrono-event-key": undefined,
1107
+ "data-editable": undefined,
1108
+ "data-dragging": undefined,
1109
+ "data-pending": undefined,
1110
+ "data-focused": undefined,
1111
+ "data-selected": undefined,
1112
+ "aria-keyshortcuts": undefined,
1113
+ "aria-description": undefined,
1114
+ "aria-label": undefined,
1115
+ "aria-hidden": "true",
1116
+ "data-drag-preview": true,
1117
+ "data-invalid": state.drag ? !state.drag.valid : false,
1118
+ };
1119
+ },
1120
+ mount(root) {
1121
+ if (options.now === undefined && root && !ticker) {
1122
+ ticker = createTicker((now) => {
1123
+ nowMs = now;
1124
+ refresh();
1125
+ });
1126
+ ticker.start(nowMs);
1127
+ }
1128
+ if (options.editable && root && !dragPointer) {
1129
+ dragPointer = createDragPointer(root, {
1130
+ canStart: (kind, key) => engine.canEditSegment(key, kind),
1131
+ begin: (kind, key, target) => engine.start(kind, key, "pointer", target),
1132
+ update: (target) => engine.update(target),
1133
+ drop: () => engine.drop(),
1134
+ cancel: () => engine.cancel(),
1135
+ hitTest: options.hitTest,
1136
+ scroll: () => (options.autoScroll === false ? false : (options.scrollContainer ?? null)),
1137
+ });
1138
+ }
1139
+ if (options.selectable && root && !pointer) {
1140
+ pointer = createSelectionPointer(root, {
1141
+ ignore: (event) => !!options.editable &&
1142
+ !!event.target?.closest?.("[data-chrono-event-key]"),
1143
+ start: (target) => startSelectionFromKey(target),
1144
+ extend: (target) => extendSelectionFromKey(target),
1145
+ confirm: confirmSelection,
1146
+ cancel: cancelSelection,
1147
+ hitTest: options.hitTest,
1148
+ });
1149
+ }
1150
+ },
1151
+ unmount() {
1152
+ ticker?.stop();
1153
+ ticker = undefined;
1154
+ pointer?.destroy();
1155
+ pointer = undefined;
1156
+ dragPointer?.destroy();
1157
+ dragPointer = undefined;
1158
+ },
1159
+ getRootAttributes: () => ({
1160
+ "data-chrono-calendar": true,
1161
+ "data-view": state.view,
1162
+ "data-layout": state.definition.layout,
1163
+ "data-dragging": state.drag !== null,
1164
+ dir: state.direction,
1165
+ }),
1166
+ getTitleAttributes: () => ({ id: titleId, "aria-live": "polite" }),
1167
+ getNavAttributes: (kind) => navAttributes(kind === "prev"
1168
+ ? state.messages.previous
1169
+ : kind === "next"
1170
+ ? state.messages.next
1171
+ : state.messages.goToToday, kind === "prev" ? !state.canGoPrev : kind === "next" ? !state.canGoNext : false),
1172
+ getViewButtonAttributes: (view) => ({
1173
+ type: "button",
1174
+ "aria-pressed": state.view === view ? "true" : "false",
1175
+ "data-view": view,
1176
+ }),
1177
+ getGridAttributes(monthIndex = 0) {
1178
+ const months = state.layout.kind === "month" ? state.layout.months : [];
1179
+ const month = months[monthIndex];
1180
+ if (months.length > 1 && month) {
1181
+ return {
1182
+ role: "grid",
1183
+ "aria-label": getCalendarTitle({ start: day1(month), end: day1(month) }, state.definition, config.locale).text,
1184
+ };
1185
+ }
1186
+ return { role: "grid", "aria-labelledby": titleId };
1187
+ },
1188
+ getColumnHeaderAttributes(day) {
1189
+ if (!isCalendarDay(day)) {
1190
+ return columnHeaderAttributes(day);
1191
+ }
1192
+ // E13: day headers are no longer the focusable row; drop focus + key.
1193
+ const attributes = dayAttributes(day, "columnheader", {
1194
+ locale: config.locale,
1195
+ messages: state.messages,
1196
+ });
1197
+ delete attributes.tabindex;
1198
+ delete attributes["data-chrono-key"];
1199
+ return attributes;
1200
+ },
1201
+ getCellAttributes: (day) => {
1202
+ const { status, label } = dayAvailability(day.date);
1203
+ return {
1204
+ ...cellAttributes(day, {
1205
+ locale: config.locale,
1206
+ messages: state.messages,
1207
+ extraLabel: label || undefined,
1208
+ }),
1209
+ "data-unavailable": status === "unavailable",
1210
+ "data-partially-available": status === "partial",
1211
+ };
1212
+ },
1213
+ getWeekNumberAttributes: (weekNumber) => weekNumberAttributes(weekNumber, state.messages),
1214
+ getTimeGridAttributes: () => ({
1215
+ role: "grid",
1216
+ "aria-labelledby": titleId,
1217
+ "aria-rowcount": state.layout.kind === "time-grid" ? state.layout.slots.length : undefined,
1218
+ "aria-colcount": state.layout.kind === "time-grid" ? state.layout.days.length : undefined,
1219
+ }),
1220
+ getSlotAttributes: (slot, day) => {
1221
+ const slotKey = `${day.key}T${toIsoString(slot.start)}`;
1222
+ const focused = state.focus.cellKey === slotKey;
1223
+ return {
1224
+ role: "gridcell",
1225
+ tabindex: focused ? 0 : -1,
1226
+ "data-chrono-key": slotKey,
1227
+ "data-slot-start": toIsoString(slot.start),
1228
+ "data-unavailable": slotUnavailable(slot, day),
1229
+ "data-working-hours": slot.working &&
1230
+ (state.layout.kind !== "time-grid" || state.layout.workingDays.includes(day.dayOfWeek)),
1231
+ "data-selecting": state.selection !== null && state.layout.kind === "time-grid",
1232
+ "data-has-events": slotHasEvents(slot, day),
1233
+ };
1234
+ },
1235
+ getAgendaAttributes: () => ({ role: "list", "aria-labelledby": titleId }),
1236
+ getAgendaDayAttributes: (day) => {
1237
+ const { status, label } = dayAvailability(day.date);
1238
+ return {
1239
+ ...dayAttributes(day, "listitem", {
1240
+ locale: config.locale,
1241
+ messages: state.messages,
1242
+ extraLabel: label || undefined,
1243
+ }),
1244
+ "data-unavailable": status === "unavailable",
1245
+ "data-partially-available": status === "partial",
1246
+ };
1247
+ },
1248
+ getEventAttributes: (segment) => eventAttributes(segment),
1249
+ getCellEventSegments: (day) => segmentList().filter((segment) => segmentCellKey(segment) === day.key),
1250
+ getBackgroundAttributes: (piece) => backgroundAttributes(piece),
1251
+ getCellDragPreviewSegments: (day, allDay = false) => {
1252
+ const preview = state.drag?.preview;
1253
+ if (!preview) {
1254
+ return [];
1255
+ }
1256
+ const pieces = (allDay ? preview.allDayRow : preview.events);
1257
+ return Array.isArray(pieces)
1258
+ ? pieces.filter((piece) => segmentCellKey(piece) === day.key)
1259
+ : [];
1260
+ },
1261
+ getEventSegment: (key) => segmentByKey(key),
1262
+ getMoreAttributes: (day) => {
1263
+ const overflow = state.more.find((m) => m.dayKey === day.key);
1264
+ return {
1265
+ type: "button",
1266
+ "aria-label": formatMessage(state.messages.moreEvents, {
1267
+ count: overflow?.count ?? 0,
1268
+ }),
1269
+ "data-overflow": overflow !== undefined,
1270
+ "data-chrono-key": day.key,
1271
+ };
1272
+ },
1273
+ getAllDayCellAttributes: (day) => ({
1274
+ "data-chrono-key": day.key,
1275
+ "data-all-day-cell": true,
1276
+ "data-has-events": state.allDayRow.some((s) => segmentCovers(s, day.key)),
1277
+ }),
1278
+ getNowIndicatorAttributes: () => state.nowIndicator
1279
+ ? {
1280
+ "aria-hidden": "true",
1281
+ "data-now": true,
1282
+ "--chrono-now-top": state.nowIndicator.top,
1283
+ }
1284
+ : {},
1285
+ getSelectionPreviewAttributes: (day) => {
1286
+ if (!state.selection) {
1287
+ return {};
1288
+ }
1289
+ const pieces = selectionPieces(state.selection);
1290
+ const piece = pieces.find((p) => toIsoString(p.date) === day.key);
1291
+ if (!piece) {
1292
+ return {};
1293
+ }
1294
+ return {
1295
+ "aria-hidden": "true",
1296
+ "data-selection": true,
1297
+ "data-invalid": selectionInvalid(),
1298
+ "data-continues-before": piece.continuesBefore,
1299
+ "data-continues-after": piece.continuesAfter,
1300
+ "--chrono-event-top": topOf(piece.start),
1301
+ "--chrono-event-height": heightOf(piece.start, piece.end),
1302
+ };
1303
+ },
1304
+ destroy() {
1305
+ controller.unmount();
1306
+ engine.dispose();
1307
+ listeners.clear();
1308
+ },
1309
+ };
1310
+ const slotHasEvents = (slot, day) => {
1311
+ if (state.layout.kind !== "time-grid") {
1312
+ return false;
1313
+ }
1314
+ const start = toSecondOfDay(slot.start);
1315
+ const end = slot.endSecond;
1316
+ return state.events.some((segment) => segment.dayKey === day.key &&
1317
+ toSecondOfDay(segment.start) < end &&
1318
+ start < toSecondOfDay(segment.end));
1319
+ };
1320
+ const segmentCovers = (segment, dayKey) => {
1321
+ if (state.layout.kind !== "time-grid") {
1322
+ return false;
1323
+ }
1324
+ const start = state.layout.days.findIndex((d) => d.key === segment.dayKey);
1325
+ const target = state.layout.days.findIndex((d) => d.key === dayKey);
1326
+ return start >= 0 && target >= start && target < start + segment.days;
1327
+ };
1328
+ const selectionInvalid = () => {
1329
+ if (!state.selection) {
1330
+ return false;
1331
+ }
1332
+ const proposal = selectionToProposal(state.selection);
1333
+ if (selectionCovered(proposal)) {
1334
+ return true;
1335
+ }
1336
+ return options.validateSelection ? !options.validateSelection(proposal) : false;
1337
+ };
1338
+ const axisStart = () => state.layout.kind === "time-grid" && state.layout.slots[0]
1339
+ ? toSecondOfDay(state.layout.slots[0].start)
1340
+ : 0;
1341
+ const axisEnd = () => state.layout.kind === "time-grid" && state.layout.slots[state.layout.slots.length - 1]
1342
+ ? state.layout.slots[state.layout.slots.length - 1].endSecond
1343
+ : 86400;
1344
+ const topOf = (value) => (toSecondOfDay(value) - axisStart()) / (axisEnd() - axisStart());
1345
+ const heightOf = (start, end) => (toSecondOfDay(end) - toSecondOfDay(start)) / (axisEnd() - axisStart());
1346
+ const eventAttributes = (segment) => {
1347
+ const base = {
1348
+ role: "button",
1349
+ "aria-pressed": selectedEventControl.get() === segment.event.id ? "true" : "false",
1350
+ tabindex: state.focus.mode === "interaction" && state.focus.itemKey === segment.key ? 0 : -1,
1351
+ "data-chrono-event": true,
1352
+ "data-chrono-event-key": segment.key,
1353
+ "data-calendar-id": segment.event.calendarId,
1354
+ "data-selected": selectedEventControl.get() === segment.event.id,
1355
+ "data-focused": state.focus.mode === "interaction" && state.focus.itemKey === segment.key,
1356
+ "data-all-day": segment.allDay,
1357
+ "data-continues-before": segment.continuesBefore,
1358
+ "data-continues-after": segment.continuesAfter,
1359
+ "data-past": segment.past,
1360
+ "data-recurring": segment.recurrence !== undefined || segment.event.recurringId !== undefined,
1361
+ "data-override": segment.recurrence?.isOverride === true,
1362
+ };
1363
+ Object.assign(base, engine.attributes(segment.key));
1364
+ const label = options.getEventLabel?.(segment.event);
1365
+ const recurring = segment.recurrence ? state.messages.recurring : "";
1366
+ if (label !== undefined) {
1367
+ base["aria-label"] = recurring ? `${label}, ${recurring}` : label;
1368
+ }
1369
+ else if (recurring) {
1370
+ base["aria-label"] = recurring;
1371
+ }
1372
+ if ("top" in segment) {
1373
+ base["--chrono-event-top"] = segment.top;
1374
+ base["--chrono-event-height"] = segment.height;
1375
+ base["--chrono-event-column"] = segment.column;
1376
+ base["--chrono-event-columns"] = segment.columns;
1377
+ base["--chrono-event-span"] = segment.span;
1378
+ }
1379
+ else if ("startColumn" in segment) {
1380
+ base["--chrono-event-start"] = segment.startColumn;
1381
+ base["--chrono-event-days"] = segment.days;
1382
+ base["--chrono-event-lane"] = segment.lane;
1383
+ }
1384
+ return base;
1385
+ };
1386
+ const startSelectionFromKey = (target) => {
1387
+ startSelection(parseCellKey(target.cellKey), "pointer");
1388
+ };
1389
+ const extendSelectionFromKey = (target) => {
1390
+ extendSelection(parseCellKey(target.cellKey));
1391
+ };
1392
+ if (!lazyStart) {
1393
+ controller.start();
1394
+ }
1395
+ return controller;
1396
+ }