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

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 (355) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +624 -2
  3. package/dist/calendar/components.d.ts +346 -0
  4. package/dist/calendar/components.js +245 -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 +50 -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 +156 -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 +202 -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 +169 -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/merge-props.d.ts +9 -0
  52. package/dist/shared/merge-props.js +33 -0
  53. package/dist/shared/modifiers.d.ts +7 -0
  54. package/dist/shared/modifiers.js +6 -0
  55. package/dist/shared/part.d.ts +10 -0
  56. package/dist/shared/part.js +9 -0
  57. package/dist/shared/slot.d.ts +12 -0
  58. package/dist/shared/slot.js +60 -0
  59. package/dist/shared/style-properties.d.ts +8 -0
  60. package/dist/shared/style-properties.js +13 -0
  61. package/dist/shared/to-react-props.d.ts +11 -0
  62. package/dist/shared/to-react-props.js +27 -0
  63. package/dist/time/bind-panel.d.ts +19 -0
  64. package/dist/time/bind-panel.js +97 -0
  65. package/dist/time/components.d.ts +183 -0
  66. package/dist/time/components.js +174 -0
  67. package/dist/time/context.d.ts +24 -0
  68. package/dist/time/context.js +19 -0
  69. package/dist/time/index.d.ts +4 -0
  70. package/dist/time/index.js +4 -0
  71. package/dist/time/options.d.ts +5 -0
  72. package/dist/time/options.js +85 -0
  73. package/dist/time/use-time-input.d.ts +43 -0
  74. package/dist/time/use-time-input.js +138 -0
  75. package/dist/time/use-time-panel.d.ts +37 -0
  76. package/dist/time/use-time-panel.js +18 -0
  77. package/dist/time/utilities.d.ts +4 -0
  78. package/dist/time/utilities.js +4 -0
  79. package/dist/vendor/core/calendar/availability.d.ts +39 -0
  80. package/dist/vendor/core/calendar/availability.js +74 -0
  81. package/dist/vendor/core/calendar/controllers/calendar-controller.d.ts +251 -0
  82. package/dist/vendor/core/calendar/controllers/calendar-controller.js +1448 -0
  83. package/dist/vendor/core/calendar/controllers/drag-engine.d.ts +99 -0
  84. package/dist/vendor/core/calendar/controllers/drag-engine.js +382 -0
  85. package/dist/vendor/core/calendar/controllers/mini-calendar-controller.d.ts +66 -0
  86. package/dist/vendor/core/calendar/controllers/mini-calendar-controller.js +170 -0
  87. package/dist/vendor/core/calendar/controllers/shared.d.ts +29 -0
  88. package/dist/vendor/core/calendar/controllers/shared.js +82 -0
  89. package/dist/vendor/core/calendar/events/agenda-layout.d.ts +21 -0
  90. package/dist/vendor/core/calendar/events/agenda-layout.js +71 -0
  91. package/dist/vendor/core/calendar/events/all-day-row.d.ts +22 -0
  92. package/dist/vendor/core/calendar/events/all-day-row.js +93 -0
  93. package/dist/vendor/core/calendar/events/background-layout.d.ts +66 -0
  94. package/dist/vendor/core/calendar/events/background-layout.js +107 -0
  95. package/dist/vendor/core/calendar/events/index.d.ts +17 -0
  96. package/dist/vendor/core/calendar/events/index.js +8 -0
  97. package/dist/vendor/core/calendar/events/month-layout.d.ts +13 -0
  98. package/dist/vendor/core/calendar/events/month-layout.js +156 -0
  99. package/dist/vendor/core/calendar/events/normalize.d.ts +33 -0
  100. package/dist/vendor/core/calendar/events/normalize.js +159 -0
  101. package/dist/vendor/core/calendar/events/now-indicator.d.ts +18 -0
  102. package/dist/vendor/core/calendar/events/now-indicator.js +19 -0
  103. package/dist/vendor/core/calendar/events/overflow.d.ts +36 -0
  104. package/dist/vendor/core/calendar/events/overflow.js +112 -0
  105. package/dist/vendor/core/calendar/events/sort.d.ts +21 -0
  106. package/dist/vendor/core/calendar/events/sort.js +35 -0
  107. package/dist/vendor/core/calendar/events/time-grid-layout.d.ts +22 -0
  108. package/dist/vendor/core/calendar/events/time-grid-layout.js +184 -0
  109. package/dist/vendor/core/calendar/events/types.d.ts +141 -0
  110. package/dist/vendor/core/calendar/events/types.js +1 -0
  111. package/dist/vendor/core/calendar/index.d.ts +70 -0
  112. package/dist/vendor/core/calendar/index.js +37 -0
  113. package/dist/vendor/core/calendar/interaction/auto-scroll.d.ts +19 -0
  114. package/dist/vendor/core/calendar/interaction/auto-scroll.js +64 -0
  115. package/dist/vendor/core/calendar/interaction/drag-geometry.d.ts +52 -0
  116. package/dist/vendor/core/calendar/interaction/drag-geometry.js +125 -0
  117. package/dist/vendor/core/calendar/interaction/drag-keyboard.d.ts +38 -0
  118. package/dist/vendor/core/calendar/interaction/drag-keyboard.js +56 -0
  119. package/dist/vendor/core/calendar/interaction/drag-pointer.d.ts +23 -0
  120. package/dist/vendor/core/calendar/interaction/drag-pointer.js +203 -0
  121. package/dist/vendor/core/calendar/interaction/event-focus.d.ts +28 -0
  122. package/dist/vendor/core/calendar/interaction/event-focus.js +44 -0
  123. package/dist/vendor/core/calendar/interaction/hit-test.d.ts +17 -0
  124. package/dist/vendor/core/calendar/interaction/hit-test.js +26 -0
  125. package/dist/vendor/core/calendar/interaction/pending.d.ts +17 -0
  126. package/dist/vendor/core/calendar/interaction/pending.js +17 -0
  127. package/dist/vendor/core/calendar/interaction/pointer.d.ts +21 -0
  128. package/dist/vendor/core/calendar/interaction/pointer.js +119 -0
  129. package/dist/vendor/core/calendar/interaction/selection.d.ts +29 -0
  130. package/dist/vendor/core/calendar/interaction/selection.js +47 -0
  131. package/dist/vendor/core/calendar/internal/equal.d.ts +3 -0
  132. package/dist/vendor/core/calendar/internal/equal.js +43 -0
  133. package/dist/vendor/core/calendar/navigation/navigate.d.ts +33 -0
  134. package/dist/vendor/core/calendar/navigation/navigate.js +83 -0
  135. package/dist/vendor/core/calendar/navigation/range.d.ts +15 -0
  136. package/dist/vendor/core/calendar/navigation/range.js +52 -0
  137. package/dist/vendor/core/calendar/navigation/title.d.ts +12 -0
  138. package/dist/vendor/core/calendar/navigation/title.js +39 -0
  139. package/dist/vendor/core/calendar/navigation/view-definition.d.ts +39 -0
  140. package/dist/vendor/core/calendar/navigation/view-definition.js +61 -0
  141. package/dist/vendor/core/calendar/navigation/zoom.d.ts +5 -0
  142. package/dist/vendor/core/calendar/navigation/zoom.js +11 -0
  143. package/dist/vendor/core/calendar/recurrence/apply.d.ts +50 -0
  144. package/dist/vendor/core/calendar/recurrence/apply.js +207 -0
  145. package/dist/vendor/core/calendar/recurrence/expand.d.ts +27 -0
  146. package/dist/vendor/core/calendar/recurrence/expand.js +302 -0
  147. package/dist/vendor/core/calendar/recurrence/pack.d.ts +3 -0
  148. package/dist/vendor/core/calendar/recurrence/pack.js +251 -0
  149. package/dist/vendor/core/calendar/recurrence/rrule-types.d.ts +30 -0
  150. package/dist/vendor/core/calendar/recurrence/rrule-types.js +8 -0
  151. package/dist/vendor/core/calendar/recurrence/rrule.d.ts +12 -0
  152. package/dist/vendor/core/calendar/recurrence/rrule.js +288 -0
  153. package/dist/vendor/core/calendar/recurrence/series.d.ts +25 -0
  154. package/dist/vendor/core/calendar/recurrence/series.js +165 -0
  155. package/dist/vendor/core/calendar/recurrence/types.d.ts +30 -0
  156. package/dist/vendor/core/calendar/recurrence/types.js +1 -0
  157. package/dist/vendor/core/calendar/resources/keys.d.ts +2 -0
  158. package/dist/vendor/core/calendar/resources/keys.js +2 -0
  159. package/dist/vendor/core/calendar/resources/resource-time-grid.d.ts +7 -0
  160. package/dist/vendor/core/calendar/resources/resource-time-grid.js +130 -0
  161. package/dist/vendor/core/calendar/resources/timeline-axis.d.ts +10 -0
  162. package/dist/vendor/core/calendar/resources/timeline-axis.js +98 -0
  163. package/dist/vendor/core/calendar/resources/timeline-layout.d.ts +7 -0
  164. package/dist/vendor/core/calendar/resources/timeline-layout.js +111 -0
  165. package/dist/vendor/core/calendar/resources/tree.d.ts +10 -0
  166. package/dist/vendor/core/calendar/resources/tree.js +86 -0
  167. package/dist/vendor/core/calendar/resources/types.d.ts +177 -0
  168. package/dist/vendor/core/calendar/resources/types.js +1 -0
  169. package/dist/vendor/core/calendar/resources/views.d.ts +7 -0
  170. package/dist/vendor/core/calendar/resources/views.js +45 -0
  171. package/dist/vendor/core/calendar/resources/windowing.d.ts +11 -0
  172. package/dist/vendor/core/calendar/resources/windowing.js +17 -0
  173. package/dist/vendor/core/calendar/views/day.d.ts +37 -0
  174. package/dist/vendor/core/calendar/views/day.js +39 -0
  175. package/dist/vendor/core/calendar/views/list-layout.d.ts +8 -0
  176. package/dist/vendor/core/calendar/views/list-layout.js +5 -0
  177. package/dist/vendor/core/calendar/views/mini-calendar.d.ts +23 -0
  178. package/dist/vendor/core/calendar/views/mini-calendar.js +31 -0
  179. package/dist/vendor/core/calendar/views/month-layout.d.ts +30 -0
  180. package/dist/vendor/core/calendar/views/month-layout.js +63 -0
  181. package/dist/vendor/core/calendar/views/time-grid-layout.d.ts +26 -0
  182. package/dist/vendor/core/calendar/views/time-grid-layout.js +30 -0
  183. package/dist/vendor/core/date/index.d.ts +9 -0
  184. package/dist/vendor/core/date/index.js +9 -0
  185. package/dist/vendor/core/date/input/date-input-controller.d.ts +97 -0
  186. package/dist/vendor/core/date/input/date-input-controller.js +478 -0
  187. package/dist/vendor/core/date/input/date-range-input-controller.d.ts +43 -0
  188. package/dist/vendor/core/date/input/date-range-input-controller.js +189 -0
  189. package/dist/vendor/core/date/input/parse.d.ts +22 -0
  190. package/dist/vendor/core/date/input/parse.js +84 -0
  191. package/dist/vendor/core/date/input/validity.d.ts +6 -0
  192. package/dist/vendor/core/date/input/validity.js +13 -0
  193. package/dist/vendor/core/date/panel/panel-controller.d.ts +176 -0
  194. package/dist/vendor/core/date/panel/panel-controller.js +726 -0
  195. package/dist/vendor/core/date/presets.d.ts +22 -0
  196. package/dist/vendor/core/date/presets.js +104 -0
  197. package/dist/vendor/core/date/selection/multiple.d.ts +7 -0
  198. package/dist/vendor/core/date/selection/multiple.js +32 -0
  199. package/dist/vendor/core/date/selection/range.d.ts +29 -0
  200. package/dist/vendor/core/date/selection/range.js +39 -0
  201. package/dist/vendor/core/date/types.d.ts +12 -0
  202. package/dist/vendor/core/date/types.js +1 -0
  203. package/dist/vendor/core/datetime/compose.d.ts +24 -0
  204. package/dist/vendor/core/datetime/compose.js +49 -0
  205. package/dist/vendor/core/datetime/constraints.d.ts +42 -0
  206. package/dist/vendor/core/datetime/constraints.js +56 -0
  207. package/dist/vendor/core/datetime/index.d.ts +9 -0
  208. package/dist/vendor/core/datetime/index.js +9 -0
  209. package/dist/vendor/core/datetime/input/datetime-input-controller.d.ts +96 -0
  210. package/dist/vendor/core/datetime/input/datetime-input-controller.js +395 -0
  211. package/dist/vendor/core/datetime/input/datetime-range-input-controller.d.ts +46 -0
  212. package/dist/vendor/core/datetime/input/datetime-range-input-controller.js +182 -0
  213. package/dist/vendor/core/datetime/input/parse.d.ts +20 -0
  214. package/dist/vendor/core/datetime/input/parse.js +59 -0
  215. package/dist/vendor/core/datetime/panel/controller.d.ts +64 -0
  216. package/dist/vendor/core/datetime/panel/controller.js +197 -0
  217. package/dist/vendor/core/datetime/panel/range-controller.d.ts +71 -0
  218. package/dist/vendor/core/datetime/panel/range-controller.js +217 -0
  219. package/dist/vendor/core/datetime/types.d.ts +12 -0
  220. package/dist/vendor/core/datetime/types.js +1 -0
  221. package/dist/vendor/core/datetime/zone/day-instants.d.ts +19 -0
  222. package/dist/vendor/core/datetime/zone/day-instants.js +54 -0
  223. package/dist/vendor/core/datetime/zone/resolve.d.ts +16 -0
  224. package/dist/vendor/core/datetime/zone/resolve.js +26 -0
  225. package/dist/vendor/core/foundation/a11y/announcer.d.ts +7 -0
  226. package/dist/vendor/core/foundation/a11y/announcer.js +36 -0
  227. package/dist/vendor/core/foundation/a11y/grid-navigation.d.ts +19 -0
  228. package/dist/vendor/core/foundation/a11y/grid-navigation.js +86 -0
  229. package/dist/vendor/core/foundation/a11y/index.d.ts +8 -0
  230. package/dist/vendor/core/foundation/a11y/index.js +5 -0
  231. package/dist/vendor/core/foundation/a11y/labels.d.ts +21 -0
  232. package/dist/vendor/core/foundation/a11y/labels.js +43 -0
  233. package/dist/vendor/core/foundation/a11y/messages.d.ts +80 -0
  234. package/dist/vendor/core/foundation/a11y/messages.js +74 -0
  235. package/dist/vendor/core/foundation/a11y/roving-focus.d.ts +18 -0
  236. package/dist/vendor/core/foundation/a11y/roving-focus.js +52 -0
  237. package/dist/vendor/core/foundation/constraints/availability-rules.d.ts +52 -0
  238. package/dist/vendor/core/foundation/constraints/availability-rules.js +66 -0
  239. package/dist/vendor/core/foundation/constraints/availability.d.ts +93 -0
  240. package/dist/vendor/core/foundation/constraints/availability.js +490 -0
  241. package/dist/vendor/core/foundation/constraints/date.d.ts +21 -0
  242. package/dist/vendor/core/foundation/constraints/date.js +41 -0
  243. package/dist/vendor/core/foundation/constraints/index.d.ts +9 -0
  244. package/dist/vendor/core/foundation/constraints/index.js +4 -0
  245. package/dist/vendor/core/foundation/constraints/range.d.ts +44 -0
  246. package/dist/vendor/core/foundation/constraints/range.js +70 -0
  247. package/dist/vendor/core/foundation/constraints/time.d.ts +30 -0
  248. package/dist/vendor/core/foundation/constraints/time.js +56 -0
  249. package/dist/vendor/core/foundation/grid/index.d.ts +8 -0
  250. package/dist/vendor/core/foundation/grid/index.js +4 -0
  251. package/dist/vendor/core/foundation/grid/month-grid.d.ts +33 -0
  252. package/dist/vendor/core/foundation/grid/month-grid.js +52 -0
  253. package/dist/vendor/core/foundation/grid/time-axis.d.ts +25 -0
  254. package/dist/vendor/core/foundation/grid/time-axis.js +32 -0
  255. package/dist/vendor/core/foundation/grid/weekday-headers.d.ts +17 -0
  256. package/dist/vendor/core/foundation/grid/weekday-headers.js +26 -0
  257. package/dist/vendor/core/foundation/grid/year-grid.d.ts +29 -0
  258. package/dist/vendor/core/foundation/grid/year-grid.js +40 -0
  259. package/dist/vendor/core/foundation/index.d.ts +8 -0
  260. package/dist/vendor/core/foundation/index.js +8 -0
  261. package/dist/vendor/core/foundation/input/form.d.ts +7 -0
  262. package/dist/vendor/core/foundation/input/form.js +10 -0
  263. package/dist/vendor/core/foundation/input/index.d.ts +6 -0
  264. package/dist/vendor/core/foundation/input/index.js +3 -0
  265. package/dist/vendor/core/foundation/input/segment-engine.d.ts +33 -0
  266. package/dist/vendor/core/foundation/input/segment-engine.js +49 -0
  267. package/dist/vendor/core/foundation/input/tokenize.d.ts +19 -0
  268. package/dist/vendor/core/foundation/input/tokenize.js +24 -0
  269. package/dist/vendor/core/foundation/locale/digits.d.ts +6 -0
  270. package/dist/vendor/core/foundation/locale/digits.js +35 -0
  271. package/dist/vendor/core/foundation/locale/direction.d.ts +1 -0
  272. package/dist/vendor/core/foundation/locale/direction.js +37 -0
  273. package/dist/vendor/core/foundation/locale/format.d.ts +31 -0
  274. package/dist/vendor/core/foundation/locale/format.js +79 -0
  275. package/dist/vendor/core/foundation/locale/hour-cycle.d.ts +12 -0
  276. package/dist/vendor/core/foundation/locale/hour-cycle.js +45 -0
  277. package/dist/vendor/core/foundation/locale/index.d.ts +10 -0
  278. package/dist/vendor/core/foundation/locale/index.js +8 -0
  279. package/dist/vendor/core/foundation/locale/names.d.ts +6 -0
  280. package/dist/vendor/core/foundation/locale/names.js +30 -0
  281. package/dist/vendor/core/foundation/locale/resolve.d.ts +7 -0
  282. package/dist/vendor/core/foundation/locale/resolve.js +29 -0
  283. package/dist/vendor/core/foundation/locale/week-info.d.ts +5 -0
  284. package/dist/vendor/core/foundation/locale/week-info.js +61 -0
  285. package/dist/vendor/core/foundation/locale/zone-label.d.ts +6 -0
  286. package/dist/vendor/core/foundation/locale/zone-label.js +24 -0
  287. package/dist/vendor/core/foundation/ranges/date-range.d.ts +18 -0
  288. package/dist/vendor/core/foundation/ranges/date-range.js +40 -0
  289. package/dist/vendor/core/foundation/ranges/index.d.ts +4 -0
  290. package/dist/vendor/core/foundation/ranges/index.js +2 -0
  291. package/dist/vendor/core/foundation/ranges/interval.d.ts +24 -0
  292. package/dist/vendor/core/foundation/ranges/interval.js +56 -0
  293. package/dist/vendor/core/foundation/store/attributes.d.ts +19 -0
  294. package/dist/vendor/core/foundation/store/attributes.js +43 -0
  295. package/dist/vendor/core/foundation/store/controllable.d.ts +19 -0
  296. package/dist/vendor/core/foundation/store/controllable.js +50 -0
  297. package/dist/vendor/core/foundation/store/env.d.ts +1 -0
  298. package/dist/vendor/core/foundation/store/env.js +3 -0
  299. package/dist/vendor/core/foundation/store/global-state.d.ts +1 -0
  300. package/dist/vendor/core/foundation/store/global-state.js +21 -0
  301. package/dist/vendor/core/foundation/store/ids.d.ts +2 -0
  302. package/dist/vendor/core/foundation/store/ids.js +7 -0
  303. package/dist/vendor/core/foundation/store/index.d.ts +11 -0
  304. package/dist/vendor/core/foundation/store/index.js +7 -0
  305. package/dist/vendor/core/foundation/store/store.d.ts +7 -0
  306. package/dist/vendor/core/foundation/store/store.js +25 -0
  307. package/dist/vendor/core/foundation/store/ticker.d.ts +11 -0
  308. package/dist/vendor/core/foundation/store/ticker.js +27 -0
  309. package/dist/vendor/core/foundation/values/clock.d.ts +4 -0
  310. package/dist/vendor/core/foundation/values/clock.js +21 -0
  311. package/dist/vendor/core/foundation/values/compare.d.ts +16 -0
  312. package/dist/vendor/core/foundation/values/compare.js +70 -0
  313. package/dist/vendor/core/foundation/values/convert.d.ts +31 -0
  314. package/dist/vendor/core/foundation/values/convert.js +112 -0
  315. package/dist/vendor/core/foundation/values/epoch-day.d.ts +15 -0
  316. package/dist/vendor/core/foundation/values/epoch-day.js +47 -0
  317. package/dist/vendor/core/foundation/values/index.d.ts +14 -0
  318. package/dist/vendor/core/foundation/values/index.js +10 -0
  319. package/dist/vendor/core/foundation/values/iso.d.ts +24 -0
  320. package/dist/vendor/core/foundation/values/iso.js +113 -0
  321. package/dist/vendor/core/foundation/values/plain-date-time.d.ts +8 -0
  322. package/dist/vendor/core/foundation/values/plain-date-time.js +25 -0
  323. package/dist/vendor/core/foundation/values/plain-date.d.ts +33 -0
  324. package/dist/vendor/core/foundation/values/plain-date.js +105 -0
  325. package/dist/vendor/core/foundation/values/plain-time.d.ts +15 -0
  326. package/dist/vendor/core/foundation/values/plain-time.js +45 -0
  327. package/dist/vendor/core/foundation/values/types.d.ts +37 -0
  328. package/dist/vendor/core/foundation/values/types.js +1 -0
  329. package/dist/vendor/core/foundation/values/week.d.ts +9 -0
  330. package/dist/vendor/core/foundation/values/week.js +31 -0
  331. package/dist/vendor/core/foundation/values/year-month.d.ts +10 -0
  332. package/dist/vendor/core/foundation/values/year-month.js +19 -0
  333. package/dist/vendor/core/foundation/values/zoned.d.ts +16 -0
  334. package/dist/vendor/core/foundation/values/zoned.js +155 -0
  335. package/dist/vendor/core/index.d.ts +5 -0
  336. package/dist/vendor/core/index.js +5 -0
  337. package/dist/vendor/core/time/index.d.ts +8 -0
  338. package/dist/vendor/core/time/index.js +8 -0
  339. package/dist/vendor/core/time/input/parse.d.ts +19 -0
  340. package/dist/vendor/core/time/input/parse.js +84 -0
  341. package/dist/vendor/core/time/input/time-input-controller.d.ts +102 -0
  342. package/dist/vendor/core/time/input/time-input-controller.js +562 -0
  343. package/dist/vendor/core/time/input/time-range-input-controller.d.ts +49 -0
  344. package/dist/vendor/core/time/input/time-range-input-controller.js +185 -0
  345. package/dist/vendor/core/time/input/validity.d.ts +7 -0
  346. package/dist/vendor/core/time/input/validity.js +16 -0
  347. package/dist/vendor/core/time/panel/time-panel-controller.d.ts +163 -0
  348. package/dist/vendor/core/time/panel/time-panel-controller.js +839 -0
  349. package/dist/vendor/core/time/selection/range.d.ts +25 -0
  350. package/dist/vendor/core/time/selection/range.js +35 -0
  351. package/dist/vendor/core/time/selection/slots.d.ts +46 -0
  352. package/dist/vendor/core/time/selection/slots.js +78 -0
  353. package/dist/vendor/core/time/types.d.ts +11 -0
  354. package/dist/vendor/core/time/types.js +1 -0
  355. package/package.json +90 -4
@@ -0,0 +1,839 @@
1
+ import { compileAvailability, createControllable, createId, defaultMessages, filterDailyRules, formatTime, fromSecondOfDay, getDayPeriodLabel, getDayPeriodNames, getHourCycle, getTextDirection, getTimeStatus, isSameTime, mergeMessages, nowZoned, plainTime, today as readTodayDate, resolveLocale, toLatinDigits, toPlainTime, toSecondOfDay, } from "../../foundation/index.js";
2
+ import { checkTimeRangeValue, } from "../selection/range.js";
3
+ import { getBookingSlots, timeKey, } from "../selection/slots.js";
4
+ const DAY = 86400;
5
+ const EMPTY = { hour: null, minute: null, second: null, period: null };
6
+ const sameT = (a, b) => a === b || (a !== null && b !== null && isSameTime(a, b));
7
+ const sameR = (a, b) => a === b ||
8
+ (a !== null && b !== null && sameT(a.start, b.start) && sameT(a.end, b.end));
9
+ function createPanel(kind, initial) {
10
+ let options = initial;
11
+ const id = options.id ?? createId("chrono-time-panel");
12
+ const range = kind === "range";
13
+ const layout = () => options.layout ?? (range ? "list" : "columns");
14
+ const localeOf = () => options.locale === undefined ? undefined : resolveLocale(options.locale);
15
+ const gran = () => options.granularity ?? "minute";
16
+ const cycle = () => options.hourCycle ?? getHourCycle(localeOf());
17
+ const bound = (value) => value === undefined ? undefined : toPlainTime(value);
18
+ const constraints = () => ({
19
+ min: bound(options.min),
20
+ max: bound(options.max),
21
+ disabledRanges: options.disabledRanges?.map((r) => ({
22
+ start: toPlainTime(r.start),
23
+ end: toPlainTime(r.end),
24
+ })),
25
+ isTimeDisabled: options.isTimeDisabled,
26
+ });
27
+ const availabilityOf = () => {
28
+ if (options.availability === undefined) {
29
+ return undefined;
30
+ }
31
+ const input = typeof options.availability.getDayStatus === "function"
32
+ ? options.availability
33
+ : filterDailyRules(options.availability);
34
+ return compileAvailability(input, {
35
+ timeZone: options.timeZone,
36
+ now: options.now,
37
+ });
38
+ };
39
+ const referenceDate = () => readTodayDate(options.timeZone, options.now);
40
+ const unavailableAt = (time) => {
41
+ const availability = availabilityOf();
42
+ return ((options.isTimeUnavailable?.(time) ?? false) ||
43
+ (availability
44
+ ? !availability.isTimeAvailable(referenceDate(), time)
45
+ : false));
46
+ };
47
+ const selectable = (time) => getTimeStatus(time, constraints()).selectable && !unavailableAt(time);
48
+ const limits = () => ({
49
+ ...constraints(),
50
+ isTimeUnavailable: unavailableAt,
51
+ allowOvernight: options.allowOvernight,
52
+ minDuration: options.minDuration,
53
+ maxDuration: options.maxDuration,
54
+ });
55
+ const control = createControllable({
56
+ value: options.value,
57
+ defaultValue: options.defaultValue ?? null,
58
+ onChange: (value) => {
59
+ if (range)
60
+ options.onValueChange?.(value);
61
+ else
62
+ options.onValueChange?.(value, {
63
+ slot: slotOf(value),
64
+ });
65
+ },
66
+ equals: (a, b) => range
67
+ ? sameR(a, b)
68
+ : sameT(a, b),
69
+ });
70
+ // ---- entries (list layout)
71
+ let entryCache;
72
+ const entries = () => {
73
+ const stepSeconds = (options.step?.minutes ?? 0) * 60 + (options.step?.seconds ?? 0) || 1800;
74
+ const sig = JSON.stringify([
75
+ options.start,
76
+ options.end,
77
+ options.slotDuration,
78
+ options.step,
79
+ options.slots,
80
+ options.min,
81
+ options.max,
82
+ options.disabledRanges,
83
+ ]);
84
+ // Functions cannot be part of the signature; recompute when they are present.
85
+ if (entryCache?.sig === sig &&
86
+ !options.isTimeDisabled &&
87
+ !options.isTimeUnavailable &&
88
+ options.availability === undefined) {
89
+ return entryCache.entries;
90
+ }
91
+ const slotMode = options.slots !== undefined || options.slotDuration !== undefined;
92
+ let list;
93
+ if (slotMode) {
94
+ list = getBookingSlots({
95
+ start: options.start,
96
+ end: options.end,
97
+ slotDuration: options.slotDuration,
98
+ step: options.step?.minutes,
99
+ slots: options.slots,
100
+ min: options.min,
101
+ max: options.max,
102
+ disabledRanges: options.disabledRanges,
103
+ isTimeDisabled: options.isTimeDisabled,
104
+ isTimeUnavailable: unavailableAt,
105
+ }).map((slot) => ({
106
+ key: slot.key,
107
+ time: slot.start,
108
+ startSecond: slot.startSecond,
109
+ endSecond: slot.endSecond,
110
+ available: slot.available,
111
+ slot,
112
+ }));
113
+ }
114
+ else {
115
+ const first = options.start === undefined
116
+ ? 0
117
+ : toSecondOfDay(toPlainTime(options.start));
118
+ const last = options.end === undefined
119
+ ? DAY
120
+ : toSecondOfDay(toPlainTime(options.end)) || DAY;
121
+ list = [];
122
+ for (let at = first; at < last; at += stepSeconds) {
123
+ const time = fromSecondOfDay(at);
124
+ list.push({
125
+ key: timeKey(time),
126
+ time,
127
+ startSecond: at,
128
+ endSecond: at,
129
+ available: selectable(time),
130
+ });
131
+ }
132
+ }
133
+ entryCache = { sig, entries: list };
134
+ return list;
135
+ };
136
+ const slotOf = (value) => {
137
+ if (!value || range || layout() !== "list")
138
+ return undefined;
139
+ return entries().find((e) => e.key === timeKey(value))?.slot;
140
+ };
141
+ // ---- columns state (partial parts per set)
142
+ const parts = { value: EMPTY, start: EMPTY, end: EMPTY };
143
+ const requiredParts = () => {
144
+ const list = ["hour"];
145
+ if (gran() !== "hour")
146
+ list.push("minute");
147
+ if (gran() === "second")
148
+ list.push("second");
149
+ if (cycle() === "h12")
150
+ list.push("dayPeriod");
151
+ return list;
152
+ };
153
+ const to24 = (hour, period) => cycle() === "h12" ? (hour % 12) + (period === 1 ? 12 : 0) : hour;
154
+ const fromTime = (time) => time
155
+ ? {
156
+ hour: cycle() === "h12" ? time.hour % 12 || 12 : time.hour,
157
+ minute: time.minute,
158
+ second: time.second,
159
+ period: time.hour >= 12 ? 1 : 0,
160
+ }
161
+ : EMPTY;
162
+ const toTime = (p) => {
163
+ const need = requiredParts();
164
+ const has = (part) => part === "dayPeriod"
165
+ ? p.period !== null
166
+ : p[part] !== null;
167
+ if (!need.every(has))
168
+ return null;
169
+ return plainTime(to24(p.hour, p.period), gran() === "hour" ? 0 : p.minute, gran() === "second" ? p.second : 0);
170
+ };
171
+ const syncParts = () => {
172
+ const value = control.get();
173
+ if (range) {
174
+ const r = value;
175
+ if (!sameT(toTime(parts.start), r?.start ?? null))
176
+ parts.start = fromTime(r?.start ?? null);
177
+ if (!sameT(toTime(parts.end), r?.end ?? null))
178
+ parts.end = fromTime(r?.end ?? null);
179
+ }
180
+ else if (!sameT(toTime(parts.value), value)) {
181
+ parts.value = fromTime(value);
182
+ }
183
+ };
184
+ syncParts();
185
+ let focusKey = "";
186
+ let hover = null;
187
+ let draftStart = null;
188
+ let beforeDraft = null;
189
+ let lastPreview = "";
190
+ let typeBuffer = "";
191
+ let typeAt = 0;
192
+ let state;
193
+ const listeners = new Set();
194
+ const minuteValues = () => {
195
+ const size = options.step?.minutes ?? 1;
196
+ return Array.from({ length: Math.ceil(60 / size) }, (_, i) => i * size);
197
+ };
198
+ const secondValues = () => {
199
+ const size = options.step?.seconds ?? 1;
200
+ return Array.from({ length: Math.ceil(60 / size) }, (_, i) => i * size);
201
+ };
202
+ const hourValues = () => cycle() === "h12"
203
+ ? [12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
204
+ : Array.from({ length: 24 }, (_, i) => i);
205
+ /** Does any time in the given hour/minute/second sets satisfy `ok`? Early exit. */
206
+ const anyOk = (hours, minutes, seconds, ok) => {
207
+ for (const h of hours) {
208
+ for (const m of minutes) {
209
+ for (const s of seconds)
210
+ if (ok(plainTime(h, m, s)))
211
+ return true;
212
+ }
213
+ }
214
+ return false;
215
+ };
216
+ const text = (time) => formatTime(time, localeOf(), {
217
+ hour: "numeric",
218
+ minute: gran() === "hour" ? undefined : "2-digit",
219
+ second: gran() === "second" ? "2-digit" : undefined,
220
+ hourCycle: cycle(),
221
+ });
222
+ const buildColumns = (setKey, messages) => {
223
+ const p = parts[setKey];
224
+ const names = getDayPeriodNames(localeOf());
225
+ const isEnd = range && setKey === "end";
226
+ const start = isEnd ? toTime(parts.start) : null;
227
+ const rangeOk = (end) => !start || checkTimeRangeValue(start, end, limits()).valid;
228
+ const ok = (time) => (isEnd ? true : selectable(time));
229
+ const restMinutes = gran() === "hour" ? [0] : minuteValues();
230
+ const restSeconds = gran() === "second" ? secondValues() : [0];
231
+ const hoursFor = (hour, period) => {
232
+ if (hour === null)
233
+ return Array.from({ length: 24 }, (_, i) => i).filter((h) => cycle() !== "h12" || period === null || h >= 12 === (period === 1));
234
+ return cycle() === "h12"
235
+ ? period === null
236
+ ? [to24(hour, 0), to24(hour, 1)]
237
+ : [to24(hour, period)]
238
+ : [hour];
239
+ };
240
+ const mark = (hours, minutes, seconds) => {
241
+ const free = anyOk(hours, minutes, seconds, ok);
242
+ const blocked = isEnd && start
243
+ ? !anyOk(hours, minutes, seconds, (t) => rangeOk(t))
244
+ : false;
245
+ return { disabled: !free && !isEnd, blocked };
246
+ };
247
+ const columns = [];
248
+ const prefix = setKey === "value" ? "" : `${setKey}:`;
249
+ const selectedTime = toTime(p);
250
+ const option = (part, value, label, shown, flags, selected) => ({
251
+ key: `${prefix}${part}:${value}`,
252
+ text: shown,
253
+ label: `${label}, ${shown}`,
254
+ value,
255
+ selected,
256
+ disabled: flags.disabled,
257
+ unavailable: false,
258
+ focused: false,
259
+ now: false,
260
+ rangeStart: false,
261
+ rangeEnd: false,
262
+ inRange: false,
263
+ preview: false,
264
+ blocked: flags.blocked,
265
+ });
266
+ const pad = (n) => String(n).padStart(2, "0");
267
+ columns.push({
268
+ key: `${prefix}hour`,
269
+ part: "hour",
270
+ label: messages.hour,
271
+ options: hourValues().map((h) => option("hour", h, messages.hour, cycle() === "h12" ? String(h) : pad(h), mark(hoursFor(h, p.period), restMinutes, restSeconds), p.hour === h)),
272
+ });
273
+ if (gran() !== "hour") {
274
+ columns.push({
275
+ key: `${prefix}minute`,
276
+ part: "minute",
277
+ label: messages.minute,
278
+ options: minuteValues().map((m) => option("minute", m, messages.minute, pad(m), mark(hoursFor(p.hour, p.period), [m], restSeconds), p.minute === m)),
279
+ });
280
+ }
281
+ if (gran() === "second") {
282
+ columns.push({
283
+ key: `${prefix}second`,
284
+ part: "second",
285
+ label: messages.second,
286
+ options: secondValues().map((s) => option("second", s, messages.second, pad(s), mark(hoursFor(p.hour, p.period), p.minute === null ? restMinutes : [p.minute], [s]), p.second === s)),
287
+ });
288
+ }
289
+ if (cycle() === "h12") {
290
+ columns.push({
291
+ key: `${prefix}dayPeriod`,
292
+ part: "dayPeriod",
293
+ label: messages.dayPeriod,
294
+ options: [0, 1].map((period) => option("dayPeriod", period, messages.dayPeriod, period === 1 ? names.pm : names.am, mark(p.hour === null
295
+ ? Array.from({ length: 12 }, (_, i) => i + period * 12)
296
+ : [to24(p.hour, period)], restMinutes, restSeconds), p.period === period)),
297
+ });
298
+ }
299
+ void selectedTime;
300
+ return columns;
301
+ };
302
+ const compute = () => {
303
+ syncParts();
304
+ const locale = localeOf();
305
+ const messages = mergeMessages(defaultMessages, options.messages);
306
+ const value = control.get();
307
+ const draft = range &&
308
+ value?.start != null &&
309
+ value?.end == null;
310
+ const rv = range ? value : null;
311
+ const lay = layout();
312
+ let sets = [];
313
+ const groups = [];
314
+ let preview = null;
315
+ let crossesMidnight = false;
316
+ let duration = null;
317
+ if (rv?.start && rv.end) {
318
+ const check = checkTimeRangeValue(rv.start, rv.end, limits());
319
+ if (check.valid) {
320
+ crossesMidnight = check.crossesMidnight;
321
+ duration = check.duration;
322
+ }
323
+ }
324
+ if (lay === "columns") {
325
+ sets = (range ? ["start", "end"] : ["value"]).map((key) => ({
326
+ key,
327
+ label: key === "start"
328
+ ? messages.startTime
329
+ : key === "end"
330
+ ? messages.endTime
331
+ : messages.time,
332
+ columns: buildColumns(key, messages),
333
+ }));
334
+ if (!focusKey ||
335
+ !sets.some((s) => s.columns.some((c) => c.options.some((o) => o.key === focusKey)))) {
336
+ const firstSet = sets[0];
337
+ const chosen = firstSet.columns[0]?.options.find((o) => o.selected);
338
+ focusKey =
339
+ (chosen ??
340
+ firstSet.columns[0]?.options.find((o) => !o.disabled) ??
341
+ firstSet.columns[0]?.options[0])?.key ?? "";
342
+ }
343
+ for (const set of sets)
344
+ for (const column of set.columns)
345
+ for (const o of column.options)
346
+ o.focused = o.key === focusKey;
347
+ }
348
+ else {
349
+ const list = entries();
350
+ const nowSecond = options.now === undefined
351
+ ? null
352
+ : (() => {
353
+ const z = nowZoned(options.timeZone ?? "UTC", options.now);
354
+ return z.hour * 3600 + z.minute * 60 + z.second;
355
+ })();
356
+ const target = hover ?? focusKey;
357
+ const startEntry = draft
358
+ ? (draftStart ??
359
+ list.find((e) => e.key === timeKey(rv?.start)) ??
360
+ null)
361
+ : null;
362
+ const rangeFor = (a, b) => {
363
+ let from = a;
364
+ let to = b;
365
+ if (to.startSecond < from.startSecond && !options.allowOvernight)
366
+ [from, to] = [to, from];
367
+ const endSecond = to.endSecond % DAY === 0 && to.endSecond > 0 ? DAY : to.endSecond;
368
+ const end = fromSecondOfDay(endSecond % DAY);
369
+ const check = checkTimeRangeValue(from.time, end, limits(), endSecond);
370
+ return { start: from.time, end, endSecond, valid: check.valid };
371
+ };
372
+ if (draft && startEntry) {
373
+ const targetEntry = list.find((e) => e.key === target);
374
+ if (targetEntry) {
375
+ const r = rangeFor(startEntry, targetEntry);
376
+ if (r.valid)
377
+ preview = { start: r.start, end: r.end };
378
+ }
379
+ }
380
+ const shown = rv?.start && rv.end ? { start: rv.start, end: rv.end } : preview;
381
+ const startSec = shown ? toSecondOfDay(shown.start) : null;
382
+ let endSec = shown ? toSecondOfDay(shown.end) : null;
383
+ if (startSec !== null && endSec !== null && endSec === 0 && startSec > 0)
384
+ endSec = DAY;
385
+ const flat = list.map((e) => {
386
+ const selectedSingle = !range && value !== null && timeKey(value) === e.key;
387
+ const inShown = startSec !== null &&
388
+ endSec !== null &&
389
+ (endSec > startSec
390
+ ? e.startSecond >= startSec && e.startSecond < endSec
391
+ : e.startSecond >= startSec || e.startSecond < endSec - DAY);
392
+ const complete = !!(rv?.start && rv.end);
393
+ const slotMode = e.slot !== undefined;
394
+ return {
395
+ key: e.key,
396
+ text: text(e.time),
397
+ label: [
398
+ slotMode
399
+ ? `${text(e.time)} – ${text(fromSecondOfDay(e.endSecond % DAY))}`
400
+ : text(e.time),
401
+ ...(selectedSingle ? [messages.selected] : []),
402
+ ...(!e.available ? [messages.unavailable] : []),
403
+ ].join(", "),
404
+ value: e.startSecond,
405
+ selected: selectedSingle ||
406
+ (range && !!rv?.start && sameT(rv.start, e.time)) ||
407
+ (range && complete && endMatches(e, rv?.end ?? null)),
408
+ disabled: false,
409
+ unavailable: !e.available,
410
+ focused: e.key === focusKey,
411
+ now: nowSecond !== null &&
412
+ nowSecond >= e.startSecond &&
413
+ nowSecond <
414
+ (e.endSecond > e.startSecond
415
+ ? e.endSecond
416
+ : e.startSecond + (options.step?.minutes ?? 30) * 60),
417
+ rangeStart: range && !!shown && sameT(shown.start, e.time),
418
+ rangeEnd: range && !!shown && endMatches(e, shown.end),
419
+ inRange: range && complete && inShown,
420
+ preview: range && !complete && inShown,
421
+ blocked: !!(draft && startEntry && !rangeFor(startEntry, e).valid),
422
+ };
423
+ });
424
+ const groupOf = (e) => {
425
+ const by = options.groupBy;
426
+ if (!by)
427
+ return { key: "all", label: "" };
428
+ if (typeof by === "function")
429
+ return by(e.time);
430
+ if (by === "hour")
431
+ return {
432
+ key: String(e.time.hour),
433
+ label: text(plainTime(e.time.hour, 0, 0)),
434
+ };
435
+ const label = getDayPeriodLabel(e.time.hour, locale);
436
+ return { key: label, label };
437
+ };
438
+ for (let i = 0; i < list.length; i += 1) {
439
+ const g = groupOf(list[i]);
440
+ const last = groups[groups.length - 1];
441
+ if (last && last.key === g.key)
442
+ last.options.push(flat[i]);
443
+ else
444
+ groups.push({
445
+ key: g.key,
446
+ label: g.label,
447
+ options: [flat[i]],
448
+ });
449
+ }
450
+ if (!focusKey || !flat.some((o) => o.key === focusKey)) {
451
+ focusKey =
452
+ (flat.find((o) => o.selected) ??
453
+ flat.find((o) => !o.unavailable) ??
454
+ flat[0])?.key ?? "";
455
+ for (const o of flat)
456
+ o.focused = o.key === focusKey;
457
+ }
458
+ }
459
+ function endMatches(e, end) {
460
+ if (!end)
461
+ return false;
462
+ const endSecond = toSecondOfDay(end);
463
+ return e.slot
464
+ ? e.endSecond % DAY === endSecond
465
+ : e.startSecond === endSecond;
466
+ }
467
+ return {
468
+ id,
469
+ kind,
470
+ layout: lay,
471
+ value: value,
472
+ draft,
473
+ preview,
474
+ sets,
475
+ groups,
476
+ focusKey,
477
+ crossesMidnight,
478
+ duration,
479
+ readOnly: options.readOnly ?? false,
480
+ disabled: options.disabled ?? false,
481
+ autoFocus: options.autoFocus ?? false,
482
+ scrollToSelected: options.scrollToSelected ?? true,
483
+ direction: getTextDirection(locale),
484
+ locale,
485
+ messages,
486
+ };
487
+ };
488
+ const refresh = () => {
489
+ const next = compute();
490
+ if (state && JSON.stringify(state) === JSON.stringify(next))
491
+ return;
492
+ state = next;
493
+ if (range) {
494
+ const key = next.preview
495
+ ? `${timeKey(next.preview.start)}|${timeKey(next.preview.end)}`
496
+ : "";
497
+ if (key !== lastPreview) {
498
+ lastPreview = key;
499
+ options.onRangePreviewChange?.(next.preview);
500
+ }
501
+ }
502
+ for (const listener of [...listeners])
503
+ listener(state);
504
+ };
505
+ state = compute();
506
+ const setValue = (value) => control.set(value);
507
+ const flatOptions = () => state.layout === "list"
508
+ ? state.groups.flatMap((g) => g.options)
509
+ : state.sets.flatMap((s) => s.columns.flatMap((c) => c.options));
510
+ const parseColumnKey = (key) => {
511
+ const bits = key.split(":");
512
+ const set = (bits.length === 3 ? bits[0] : "value");
513
+ return {
514
+ set,
515
+ part: bits[bits.length - 2],
516
+ value: Number(bits[bits.length - 1]),
517
+ };
518
+ };
519
+ const commitSingle = (time) => {
520
+ options.onValueCommit?.(time, { slot: slotOf(time) });
521
+ };
522
+ const pickColumn = (key) => {
523
+ const { set, part, value } = parseColumnKey(key);
524
+ const option = flatOptions().find((o) => o.key === key);
525
+ if (!option || (option.disabled && set !== "end"))
526
+ return;
527
+ const next = { ...parts[set] };
528
+ if (part === "hour")
529
+ next.hour = value;
530
+ else if (part === "minute")
531
+ next.minute = value;
532
+ else if (part === "second")
533
+ next.second = value;
534
+ else
535
+ next.period = value;
536
+ // A part that became disabled by this pick is cleared, never moved silently.
537
+ parts[set] = next;
538
+ const probe = (p) => {
539
+ const time = toTime(p);
540
+ return time ? (set === "end" ? true : selectable(time)) : true;
541
+ };
542
+ if (!probe(next)) {
543
+ const cleared = { ...next };
544
+ if (part === "hour" || part === "dayPeriod")
545
+ cleared.minute = gran() === "hour" ? cleared.minute : null;
546
+ if (cleared.minute === null && gran() === "second")
547
+ cleared.second = null;
548
+ parts[set] = cleared;
549
+ }
550
+ focusKey = key;
551
+ const last = requiredParts()[requiredParts().length - 1];
552
+ if (range) {
553
+ const start = toTime(parts.start);
554
+ const end = toTime(parts.end);
555
+ const current = control.get();
556
+ const nextValue = start === null && end === null ? null : { start, end };
557
+ if (!sameR(current, nextValue))
558
+ setValue(nextValue);
559
+ if (set === "end" && part === last && start && end) {
560
+ const check = checkTimeRangeValue(start, end, limits());
561
+ if (check.valid)
562
+ options.onValueCommit?.({
563
+ start,
564
+ end,
565
+ });
566
+ else
567
+ options.onInvalidRange?.(check.reason);
568
+ }
569
+ }
570
+ else {
571
+ const time = toTime(parts.value);
572
+ if (!sameT(control.get(), time))
573
+ setValue(time);
574
+ if (part === last && time && selectable(time))
575
+ commitSingle(time);
576
+ }
577
+ };
578
+ const pickList = (key) => {
579
+ const list = entries();
580
+ const entry = list.find((e) => e.key === key);
581
+ if (!entry)
582
+ return;
583
+ focusKey = key;
584
+ if (!entry.available) {
585
+ if (range)
586
+ options.onInvalidRange?.("start-invalid");
587
+ return;
588
+ }
589
+ if (!range) {
590
+ setValue(entry.time);
591
+ commitSingle(entry.time);
592
+ return;
593
+ }
594
+ const current = control.get();
595
+ if (!current?.start || current.end) {
596
+ beforeDraft = current?.start && current.end ? current : null;
597
+ draftStart = entry;
598
+ setValue({ start: entry.time, end: null });
599
+ return;
600
+ }
601
+ const first = draftStart ??
602
+ list.find((e) => e.key === timeKey(current.start)) ??
603
+ entry;
604
+ let from = first;
605
+ let to = entry;
606
+ if (to.startSecond < from.startSecond && !options.allowOvernight)
607
+ [from, to] = [to, from];
608
+ const endSecond = to.endSecond % DAY === 0 && to.endSecond > 0 ? DAY : to.endSecond;
609
+ const end = fromSecondOfDay(endSecond % DAY);
610
+ const check = checkTimeRangeValue(from.time, end, limits(), endSecond);
611
+ if (!check.valid) {
612
+ options.onInvalidRange?.(check.reason);
613
+ return;
614
+ }
615
+ draftStart = null;
616
+ setValue({ start: from.time, end });
617
+ options.onValueCommit?.({
618
+ start: from.time,
619
+ end,
620
+ });
621
+ };
622
+ const move = (to) => {
623
+ if (!to)
624
+ return true;
625
+ focusKey = to;
626
+ hover = null;
627
+ refresh();
628
+ return true;
629
+ };
630
+ const controller = {
631
+ getState: () => state,
632
+ getValue: () => control.get(),
633
+ getSlot: (key) => entries().find((e) => e.key === key)?.slot,
634
+ subscribe(listener) {
635
+ listeners.add(listener);
636
+ return () => {
637
+ listeners.delete(listener);
638
+ };
639
+ },
640
+ setOptions(next) {
641
+ options = { ...options, ...next };
642
+ control.sync({ value: options.value });
643
+ refresh();
644
+ },
645
+ pick(key, _source) {
646
+ if (options.disabled || options.readOnly) {
647
+ focusKey = key;
648
+ refresh();
649
+ return;
650
+ }
651
+ if (layout() === "columns")
652
+ pickColumn(key);
653
+ else
654
+ pickList(key);
655
+ hover = null;
656
+ refresh();
657
+ },
658
+ setPreview(key) {
659
+ hover = key;
660
+ refresh();
661
+ },
662
+ cancelDraft() {
663
+ if (!range || !state.draft)
664
+ return;
665
+ hover = null;
666
+ draftStart = null;
667
+ setValue(beforeDraft);
668
+ beforeDraft = null;
669
+ refresh();
670
+ },
671
+ clear() {
672
+ if (options.disabled || options.readOnly)
673
+ return;
674
+ parts.value = EMPTY;
675
+ parts.start = EMPTY;
676
+ parts.end = EMPTY;
677
+ draftStart = null;
678
+ setValue(range ? null : null);
679
+ refresh();
680
+ },
681
+ commit() {
682
+ const value = control.get();
683
+ if (range) {
684
+ const r = value;
685
+ if (r?.start && r.end)
686
+ options.onValueCommit?.({
687
+ start: r.start,
688
+ end: r.end,
689
+ });
690
+ }
691
+ else if (value)
692
+ commitSingle(value);
693
+ },
694
+ focusOption(key) {
695
+ focusKey = key;
696
+ refresh();
697
+ },
698
+ handleKeyDown(key, modifiers) {
699
+ if (options.disabled || modifiers.ctrl || modifiers.meta)
700
+ return false;
701
+ if (key === "Escape") {
702
+ if (range && state.draft) {
703
+ controller.cancelDraft();
704
+ return true;
705
+ }
706
+ return false;
707
+ }
708
+ if (key === "Enter" || key === " ") {
709
+ controller.pick(state.focusKey, "keyboard");
710
+ return true;
711
+ }
712
+ const all = flatOptions();
713
+ const index = all.findIndex((o) => o.key === focusKey);
714
+ const current = all[index];
715
+ const digit = toLatinDigits(key, localeOf());
716
+ if (/^\d$/.test(digit)) {
717
+ const now = (options.timer ?? Date.now)();
718
+ typeBuffer = now - typeAt > 700 ? digit : typeBuffer + digit;
719
+ typeAt = now;
720
+ const norm = (value) => toLatinDigits(value, localeOf()).replace(/^0+(?=\d)/, "");
721
+ const scope = state.layout === "columns"
722
+ ? (state.sets
723
+ .flatMap((s) => s.columns)
724
+ .find((c) => c.options.some((o) => o.key === focusKey))
725
+ ?.options ?? all)
726
+ : all;
727
+ const found = scope.find((o) => norm(o.text).startsWith(norm(typeBuffer)));
728
+ return move(found?.key);
729
+ }
730
+ if (state.layout === "list") {
731
+ const perHour = Math.max(1, Math.round(3600 /
732
+ ((options.step?.minutes ?? 0) * 60 +
733
+ (options.step?.seconds ?? 0) ||
734
+ (options.slotDuration
735
+ ? (options.step?.minutes ?? options.slotDuration) * 60
736
+ : 1800))));
737
+ const by = {
738
+ ArrowDown: 1,
739
+ ArrowUp: -1,
740
+ PageDown: perHour,
741
+ PageUp: -perHour,
742
+ };
743
+ if (key in by)
744
+ return move(all[Math.max(0, Math.min(all.length - 1, index + by[key]))]?.key);
745
+ if (key === "Home")
746
+ return move(all[0]?.key);
747
+ if (key === "End")
748
+ return move(all[all.length - 1]?.key);
749
+ return false;
750
+ }
751
+ // columns: flat list of columns across sets
752
+ const columns = state.sets.flatMap((s) => s.columns);
753
+ const ci = columns.findIndex((c) => c.options.some((o) => o.key === focusKey));
754
+ const column = columns[ci];
755
+ if (!column || !current)
756
+ return false;
757
+ const at = column.options.findIndex((o) => o.key === focusKey);
758
+ const rtl = state.direction === "rtl";
759
+ const clamp = (n) => Math.max(0, Math.min(column.options.length - 1, n));
760
+ if (key === "ArrowDown")
761
+ return move(column.options[clamp(at + 1)]?.key);
762
+ if (key === "ArrowUp")
763
+ return move(column.options[clamp(at - 1)]?.key);
764
+ if (key === "Home")
765
+ return move(column.options[0]?.key);
766
+ if (key === "End")
767
+ return move(column.options[column.options.length - 1]?.key);
768
+ if (key === "PageDown" || key === "PageUp") {
769
+ const size = column.part === "hour" ? 3 : column.part === "dayPeriod" ? 1 : 15;
770
+ return move(column.options[clamp(at + (key === "PageDown" ? size : -size))]?.key);
771
+ }
772
+ if (key === "ArrowLeft" || key === "ArrowRight") {
773
+ const step = (key === "ArrowRight") !== rtl ? 1 : -1;
774
+ const target = columns[ci + step];
775
+ if (!target)
776
+ return true;
777
+ return move(target.options[Math.min(at, target.options.length - 1)]?.key);
778
+ }
779
+ return false;
780
+ },
781
+ getRootAttributes: () => ({
782
+ role: "group",
783
+ "data-chrono-time-panel": range ? "range" : true,
784
+ "data-layout": state.layout,
785
+ "data-disabled": state.disabled,
786
+ "data-readonly": state.readOnly,
787
+ dir: state.direction,
788
+ }),
789
+ getSetAttributes: (set) => ({
790
+ role: "group",
791
+ "aria-label": set.label,
792
+ "data-chrono-set": set.key,
793
+ }),
794
+ getColumnAttributes: (column) => ({
795
+ role: "listbox",
796
+ "aria-label": column.label,
797
+ "data-chrono-part": column.part,
798
+ }),
799
+ getGroupAttributes: (group) => ({
800
+ role: "group",
801
+ "aria-label": group.label || undefined,
802
+ "data-chrono-group": group.key,
803
+ }),
804
+ getListAttributes: () => ({
805
+ role: "listbox",
806
+ "aria-multiselectable": range ? "true" : undefined,
807
+ }),
808
+ getOptionAttributes: (option) => ({
809
+ role: "option",
810
+ "aria-selected": option.selected
811
+ ? "true"
812
+ : option.disabled || option.unavailable
813
+ ? undefined
814
+ : "false",
815
+ "aria-disabled": option.disabled || option.unavailable || option.blocked
816
+ ? "true"
817
+ : undefined,
818
+ "aria-label": option.label,
819
+ tabindex: option.focused ? 0 : -1,
820
+ "data-chrono-key": option.key,
821
+ "data-selected": option.selected,
822
+ "data-focused": option.focused,
823
+ "data-disabled": option.disabled,
824
+ "data-unavailable": option.unavailable,
825
+ "data-now": option.now,
826
+ "data-range-start": option.rangeStart,
827
+ "data-range-end": option.rangeEnd,
828
+ "data-in-range": option.inRange,
829
+ "data-range-preview": option.preview,
830
+ "data-range-blocked": option.blocked,
831
+ }),
832
+ destroy() {
833
+ listeners.clear();
834
+ },
835
+ };
836
+ return controller;
837
+ }
838
+ export const createTimePanelController = (options = {}) => createPanel("single", options);
839
+ export const createTimeRangePanelController = (options = {}) => createPanel("range", options);