@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,466 @@
1
+ import { backspace, compileAvailability, createControllable, createId, daysInMonth, defaultMessages, emptySegment, formatDate, getDateFormatPattern, getDatePartOrder, getHiddenInputs, getMonthNames, getTextDirection, isSameDay, isValidDate, mergeMessages, plainDate, resolveLocale, segmentOf, stepSegment, toIsoString, toLatinDigits, toLocaleDigits, toPlainDate, today as readToday, typeDigit, } from "../../foundation/index.js";
2
+ import { parseDate, resolveTwoDigitYear } from "./parse.js";
3
+ import { getValidity, isInvalid } from "./validity.js";
4
+ import { withOptional } from "../../foundation/store/with-optional.js";
5
+ const PARTS = ["day", "month", "year"];
6
+ const sameNullable = (a, b) => a === b || (a !== null && b !== null && isSameDay(a, b));
7
+ export function createDateInputController(initial = {}) {
8
+ let options = initial;
9
+ const id = options.id ?? createId("chrono-date-input");
10
+ const todayNow = () => readToday(options.timeZone, options.now);
11
+ const bound = (value) => value === undefined ? undefined : toPlainDate(value, options.timeZone);
12
+ const availabilityOf = () => options.availability === undefined
13
+ ? undefined
14
+ : compileAvailability(options.availability, {
15
+ timeZone: options.timeZone,
16
+ now: options.now,
17
+ });
18
+ const constraints = () => ({
19
+ min: bound(options.min),
20
+ max: bound(options.max),
21
+ isDateDisabled: options.isDateDisabled,
22
+ isDateUnavailable: (date) => (options.isDateUnavailable?.(date) ?? false) ||
23
+ availabilityOf()?.getDayStatus(date) === "unavailable",
24
+ });
25
+ const localeOf = () => options.locale === undefined ? undefined : resolveLocale(options.locale);
26
+ const control = createControllable({
27
+ value: options.value,
28
+ defaultValue: options.defaultValue ?? null,
29
+ onChange: (value) => options.onValueChange?.(value),
30
+ equals: sameNullable,
31
+ });
32
+ let parts = {
33
+ day: emptySegment,
34
+ month: emptySegment,
35
+ year: emptySegment,
36
+ };
37
+ let text = "";
38
+ /** The value `text` currently stands for; a different value from outside re-formats it. */
39
+ let textValue = null;
40
+ let invalidText = false;
41
+ let focusedPart = getDatePartOrder(localeOf()).order[0];
42
+ let lastCommitted = control.get();
43
+ let state;
44
+ const listeners = new Set();
45
+ const formatValue = (date) => options.format
46
+ ? options.format(date, { locale: localeOf() })
47
+ : formatDate(date, localeOf(), {
48
+ year: "numeric",
49
+ month: "2-digit",
50
+ day: "2-digit",
51
+ });
52
+ const parseContext = () => ({
53
+ locale: localeOf(),
54
+ today: todayNow(),
55
+ });
56
+ const parseText = (value) => {
57
+ if (options.parse) {
58
+ if (value.trim() === "")
59
+ return { error: "empty" };
60
+ const date = options.parse(value, parseContext());
61
+ return date ? { date } : { error: "unparseable" };
62
+ }
63
+ return parseDate(value, parseContext());
64
+ };
65
+ const syncParts = (value) => {
66
+ parts = value
67
+ ? {
68
+ day: segmentOf(value.day),
69
+ month: segmentOf(value.month),
70
+ year: segmentOf(value.year),
71
+ }
72
+ : { day: emptySegment, month: emptySegment, year: emptySegment };
73
+ text = value ? formatValue(value) : "";
74
+ textValue = value;
75
+ invalidText = false;
76
+ };
77
+ syncParts(control.get());
78
+ const derive = () => {
79
+ const { day, month, year } = parts;
80
+ if (day.value === null || month.value === null || year.value === null) {
81
+ return null;
82
+ }
83
+ return isValidDate(year.value, month.value, day.value)
84
+ ? plainDate(year.value, month.value, day.value)
85
+ : null;
86
+ };
87
+ const filledCount = () => PARTS.filter((part) => parts[part].value !== null).length;
88
+ const def = (part) => {
89
+ if (part === "month")
90
+ return { min: 1, max: 12, maxDigits: 2, pageStep: 3 };
91
+ if (part === "year")
92
+ return { min: 1, max: 9999, maxDigits: 4, pageStep: 10 };
93
+ const { month, year } = parts;
94
+ const max = month.value === null ? 31 : daysInMonth(year.value ?? 2000, month.value);
95
+ return { min: 1, max, maxDigits: 2, pageStep: 7 };
96
+ };
97
+ const validityNow = () => {
98
+ if (options.mode === "text") {
99
+ if (text.trim() === "")
100
+ return "empty";
101
+ if (invalidText)
102
+ return "invalid-date";
103
+ const value = control.get();
104
+ return value ? getValidity(3, value, constraints()) : "invalid-date";
105
+ }
106
+ const date = derive();
107
+ return getValidity(filledCount(), date, constraints());
108
+ };
109
+ const compute = () => {
110
+ const locale = localeOf();
111
+ const messages = mergeMessages(defaultMessages, options.messages);
112
+ const { order, separators, prefix, suffix } = getDatePartOrder(locale);
113
+ const names = getMonthNames(locale, "long");
114
+ const placeholders = {
115
+ day: messages.placeholderDay,
116
+ month: messages.placeholderMonth,
117
+ year: messages.placeholderYear,
118
+ };
119
+ const display = (part) => {
120
+ const segment = parts[part];
121
+ if (segment.buffer !== "")
122
+ return toLocaleDigits(segment.buffer, locale);
123
+ if (segment.value === null)
124
+ return placeholders[part];
125
+ return toLocaleDigits(String(segment.value).padStart(part === "year" ? 4 : 2, "0"), locale);
126
+ };
127
+ const literal = (value) => ({
128
+ type: "literal",
129
+ text: value,
130
+ value: null,
131
+ placeholder: "",
132
+ min: 0,
133
+ max: 0,
134
+ valueText: "",
135
+ editable: false,
136
+ });
137
+ const segments = [];
138
+ if (prefix)
139
+ segments.push(literal(prefix));
140
+ order.forEach((part, index) => {
141
+ const segment = parts[part];
142
+ const bounds = def(part);
143
+ const shown = display(part);
144
+ segments.push({
145
+ type: part,
146
+ text: shown,
147
+ value: segment.value,
148
+ placeholder: placeholders[part],
149
+ min: bounds.min,
150
+ max: bounds.max,
151
+ valueText: segment.value === null
152
+ ? messages.empty
153
+ : part === "month"
154
+ ? names[segment.value - 1]
155
+ : shown,
156
+ editable: true,
157
+ });
158
+ const separator = separators[index];
159
+ if (index < 2 && separator)
160
+ segments.push(literal(separator));
161
+ });
162
+ if (suffix)
163
+ segments.push(literal(suffix));
164
+ const value = control.get();
165
+ return withOptional({
166
+ id,
167
+ mode: options.mode ?? "segmented",
168
+ segments,
169
+ text,
170
+ value,
171
+ validity: validityNow(),
172
+ focusedPart,
173
+ pattern: getDateFormatPattern(locale, messages),
174
+ required: options.required ?? false,
175
+ readOnly: options.readOnly ?? false,
176
+ disabled: options.disabled ?? false,
177
+ direction: getTextDirection(locale),
178
+ locale,
179
+ messages,
180
+ hidden: getHiddenInputs([[options.name, value ? toIsoString(value) : null]]),
181
+ });
182
+ };
183
+ const refresh = () => {
184
+ const next = compute();
185
+ if (state && JSON.stringify(state) === JSON.stringify(next))
186
+ return;
187
+ state = next;
188
+ for (const listener of [...listeners])
189
+ listener(state);
190
+ };
191
+ state = compute();
192
+ /** Push the parts into the value after an edit. */
193
+ const afterEdit = () => {
194
+ const next = derive();
195
+ if (!sameNullable(next, control.get()))
196
+ control.set(next);
197
+ refresh();
198
+ };
199
+ const orderParts = () => [...getDatePartOrder(localeOf()).order];
200
+ const settlePart = (part) => {
201
+ const segment = parts[part];
202
+ if (part !== "year" || segment.buffer === "")
203
+ return;
204
+ const typed = Number(segment.buffer);
205
+ const resolved = segment.buffer.length === 2 ? resolveTwoDigitYear(typed, todayNow().year) : typed;
206
+ parts = {
207
+ ...parts,
208
+ year: {
209
+ value: resolved >= 1 && resolved <= 9999 ? resolved : null,
210
+ buffer: "",
211
+ },
212
+ };
213
+ };
214
+ const settleAll = () => {
215
+ for (const part of PARTS)
216
+ settlePart(part);
217
+ };
218
+ const moveFocus = (part, step) => {
219
+ const list = orderParts();
220
+ const index = list.indexOf(part) + step;
221
+ const target = list[index];
222
+ if (target)
223
+ focusedPart = target;
224
+ else
225
+ options.onFocusEdge?.(step);
226
+ };
227
+ const setSegment = (part, segment) => {
228
+ parts = { ...parts, [part]: segment };
229
+ };
230
+ const controller = {
231
+ getState: () => state,
232
+ subscribe(listener) {
233
+ listeners.add(listener);
234
+ return () => {
235
+ listeners.delete(listener);
236
+ };
237
+ },
238
+ setOptions(next) {
239
+ options = { ...options, ...next };
240
+ control.sync({ value: options.value });
241
+ if (options.mode === "text") {
242
+ if (!sameNullable(textValue, control.get())) {
243
+ syncParts(control.get());
244
+ }
245
+ }
246
+ else if (!sameNullable(derive(), control.get())) {
247
+ syncParts(control.get());
248
+ }
249
+ refresh();
250
+ },
251
+ focusPart(part) {
252
+ if (focusedPart !== part) {
253
+ focusedPart = part;
254
+ refresh();
255
+ }
256
+ },
257
+ settle() {
258
+ settleAll();
259
+ afterEdit();
260
+ },
261
+ handleKeyDown(part, key, modifiers) {
262
+ if (options.disabled)
263
+ return false;
264
+ if (modifiers.ctrl || modifiers.meta)
265
+ return false;
266
+ const rtl = state.direction === "rtl";
267
+ if (key === "ArrowLeft" || key === "ArrowRight") {
268
+ settlePart(part);
269
+ moveFocus(part, (key === "ArrowRight") !== rtl ? 1 : -1);
270
+ afterEdit();
271
+ return true;
272
+ }
273
+ if (key === "Enter") {
274
+ settleAll();
275
+ afterEdit();
276
+ controller.commit();
277
+ return false;
278
+ }
279
+ if (options.readOnly)
280
+ return false;
281
+ const latin = toLatinDigits(key, localeOf());
282
+ if (/^\d$/.test(latin)) {
283
+ const result = typeDigit(def(part), parts[part], Number(latin));
284
+ let segment = result.segment;
285
+ // A year is pending until it has four digits or is settled on blur.
286
+ if (part === "year" && segment.buffer.length < 4) {
287
+ segment = { value: null, buffer: segment.buffer };
288
+ }
289
+ setSegment(part, segment);
290
+ if (result.advance) {
291
+ settlePart(part);
292
+ moveFocus(part, 1);
293
+ }
294
+ afterEdit();
295
+ return true;
296
+ }
297
+ const pv = toPlainDate(options.placeholderValue ?? todayNow(), options.timeZone);
298
+ const bounds = def(part);
299
+ if (key === "ArrowUp" || key === "ArrowDown" || key === "PageUp" || key === "PageDown") {
300
+ settlePart(part);
301
+ const direction = key === "ArrowUp" || key === "PageUp" ? 1 : -1;
302
+ const amount = key.startsWith("Page") ? bounds.pageStep : 1;
303
+ const wasComplete = derive() !== null;
304
+ setSegment(part, stepSegment(bounds, parts[part], direction * amount, pv[part]));
305
+ if (wasComplete && part !== "day") {
306
+ const { day, month, year } = parts;
307
+ const limit = daysInMonth(year.value ?? 2000, month.value ?? 1);
308
+ if (day.value > limit)
309
+ setSegment("day", segmentOf(limit));
310
+ }
311
+ afterEdit();
312
+ return true;
313
+ }
314
+ if (key === "Home" || key === "End") {
315
+ setSegment(part, segmentOf(key === "Home" ? bounds.min : bounds.max));
316
+ afterEdit();
317
+ return true;
318
+ }
319
+ if (key === "Backspace" || key === "Delete") {
320
+ setSegment(part, key === "Backspace" ? backspace(parts[part]) : emptySegment);
321
+ afterEdit();
322
+ return true;
323
+ }
324
+ return false;
325
+ },
326
+ paste(value) {
327
+ if (options.disabled || options.readOnly)
328
+ return false;
329
+ const result = parseText(value);
330
+ if ("date" in result) {
331
+ syncParts(result.date);
332
+ invalidText = false;
333
+ afterEdit();
334
+ return true;
335
+ }
336
+ options.onInvalidInput?.(value);
337
+ return false;
338
+ },
339
+ setText(value) {
340
+ text = value;
341
+ invalidText = false;
342
+ refresh();
343
+ },
344
+ commitText() {
345
+ const result = parseText(text);
346
+ if ("date" in result) {
347
+ invalidText = false;
348
+ control.set(result.date);
349
+ text = formatValue(result.date);
350
+ textValue = result.date;
351
+ refresh();
352
+ return true;
353
+ }
354
+ if (result.error === "empty") {
355
+ invalidText = false;
356
+ text = "";
357
+ textValue = null;
358
+ control.set(null);
359
+ refresh();
360
+ return true;
361
+ }
362
+ invalidText = true;
363
+ options.onInvalidInput?.(text);
364
+ refresh();
365
+ return false;
366
+ },
367
+ handleTextKeyDown(key) {
368
+ if (key === "Enter") {
369
+ controller.commitText();
370
+ controller.commit();
371
+ return false;
372
+ }
373
+ if (key === "Escape") {
374
+ const before = text;
375
+ const value = control.get();
376
+ text = value ? formatValue(value) : "";
377
+ invalidText = false;
378
+ refresh();
379
+ return before !== text;
380
+ }
381
+ return false;
382
+ },
383
+ commit() {
384
+ if (options.mode === "text")
385
+ controller.commitText();
386
+ else {
387
+ settleAll();
388
+ afterEdit();
389
+ }
390
+ const value = control.get();
391
+ if (value && state.validity === "valid" && !sameNullable(value, lastCommitted)) {
392
+ lastCommitted = value;
393
+ options.onValueCommit?.(value);
394
+ }
395
+ },
396
+ clear() {
397
+ if (options.disabled || options.readOnly)
398
+ return;
399
+ syncParts(null);
400
+ focusedPart = orderParts()[0];
401
+ control.set(null);
402
+ lastCommitted = null;
403
+ refresh();
404
+ },
405
+ reset() {
406
+ const value = options.defaultValue ?? null;
407
+ syncParts(value);
408
+ focusedPart = orderParts()[0];
409
+ control.set(value);
410
+ lastCommitted = value;
411
+ refresh();
412
+ },
413
+ getRootAttributes: () => ({
414
+ role: "group",
415
+ "data-chrono-date-input": true,
416
+ "data-mode": state.mode,
417
+ "data-disabled": state.disabled,
418
+ "data-readonly": state.readOnly,
419
+ "data-invalid": isInvalid(state.validity),
420
+ "aria-disabled": state.disabled ? "true" : undefined,
421
+ dir: state.direction,
422
+ }),
423
+ getSegmentAttributes(segment) {
424
+ if (segment.type === "literal") {
425
+ return { "aria-hidden": "true", "data-chrono-literal": true };
426
+ }
427
+ return {
428
+ role: "spinbutton",
429
+ "aria-label": state.messages[segment.type],
430
+ "aria-valuenow": segment.value ?? undefined,
431
+ "aria-valuemin": segment.min,
432
+ "aria-valuemax": segment.max,
433
+ "aria-valuetext": segment.valueText,
434
+ "aria-readonly": state.readOnly ? "true" : undefined,
435
+ "aria-disabled": state.disabled ? "true" : undefined,
436
+ "aria-required": state.required ? "true" : undefined,
437
+ "aria-invalid": isInvalid(state.validity) ? "true" : undefined,
438
+ tabindex: state.disabled ? undefined : segment.type === state.focusedPart ? 0 : -1,
439
+ inputmode: "numeric",
440
+ "data-placeholder": segment.value === null && segment.text === segment.placeholder,
441
+ "data-invalid": isInvalid(state.validity),
442
+ "data-chrono-part": segment.type,
443
+ };
444
+ },
445
+ getTextFieldAttributes: () => ({
446
+ type: "text",
447
+ autocomplete: "off",
448
+ spellcheck: "false",
449
+ placeholder: state.pattern,
450
+ "aria-invalid": isInvalid(state.validity) ? "true" : undefined,
451
+ "aria-required": state.required ? "true" : undefined,
452
+ "data-invalid": isInvalid(state.validity),
453
+ disabled: state.disabled,
454
+ readonly: state.readOnly,
455
+ }),
456
+ getClearButtonAttributes: () => ({
457
+ type: "button",
458
+ "aria-label": state.messages.clear,
459
+ "data-disabled": state.disabled || state.validity === "empty",
460
+ }),
461
+ destroy() {
462
+ listeners.clear();
463
+ },
464
+ };
465
+ return controller;
466
+ }
@@ -0,0 +1,43 @@
1
+ import { type Attributes, type DateRange, type HiddenInput } from "../../foundation/index.js";
2
+ import { type PickConstraints, type RangeReason } from "../selection/range.js";
3
+ import type { DateRangeValue } from "../types.js";
4
+ import { type DateInputController, type DateInputOptions, type DateInputState } from "./date-input-controller.js";
5
+ import { type DateValidity } from "./validity.js";
6
+ export type DateRangeInputOptions = Omit<DateInputOptions, "value" | "defaultValue" | "onValueChange" | "onValueCommit" | "name"> & {
7
+ value?: DateRangeValue;
8
+ defaultValue?: DateRangeValue;
9
+ onValueChange?: (value: DateRangeValue) => void;
10
+ onValueCommit?: (value: DateRange) => void;
11
+ name?: string;
12
+ startName?: string;
13
+ endName?: string;
14
+ minDays?: PickConstraints["minDays"];
15
+ maxDays?: PickConstraints["maxDays"];
16
+ allowUnavailableInside?: boolean;
17
+ allowDisabledInside?: boolean;
18
+ };
19
+ export type RangeValidity = DateValidity | RangeReason;
20
+ export type DateRangeInputState = {
21
+ id: string;
22
+ value: DateRangeValue;
23
+ validity: RangeValidity;
24
+ start: DateInputState;
25
+ end: DateInputState;
26
+ disabled: boolean;
27
+ readOnly: boolean;
28
+ hidden: HiddenInput[];
29
+ messages: DateInputState["messages"];
30
+ };
31
+ export type DateRangeInputController = {
32
+ getState(): DateRangeInputState;
33
+ subscribe(listener: (state: DateRangeInputState) => void): () => void;
34
+ setOptions(options: Partial<DateRangeInputOptions>): void;
35
+ getStart(): DateInputController;
36
+ getEnd(): DateInputController;
37
+ commit(): void;
38
+ clear(): void;
39
+ reset(): void;
40
+ getRootAttributes(): Attributes;
41
+ destroy(): void;
42
+ };
43
+ export declare function createDateRangeInputController(initial?: DateRangeInputOptions): DateRangeInputController;
@@ -0,0 +1,186 @@
1
+ import { compare, compileAvailability, createControllable, createId, getHiddenInputs, isSameDay, toIsoString, } from "../../foundation/index.js";
2
+ import { checkPicked } from "../selection/range.js";
3
+ import { createDateInputController, } from "./date-input-controller.js";
4
+ import { isInvalid } from "./validity.js";
5
+ const sameNullable = (a, b) => a === b || (a !== null && b !== null && isSameDay(a, b));
6
+ const sameRange = (a, b) => a === b ||
7
+ (a !== null && b !== null && sameNullable(a.start, b.start) && sameNullable(a.end, b.end));
8
+ export function createDateRangeInputController(initial = {}) {
9
+ let options = initial;
10
+ const id = options.id ?? createId("chrono-date-range-input");
11
+ const control = createControllable({
12
+ value: options.value,
13
+ defaultValue: options.defaultValue ?? null,
14
+ onChange: (value) => options.onValueChange?.(value),
15
+ equals: sameRange,
16
+ });
17
+ let lastCommitted = control.get();
18
+ const childOptions = () => {
19
+ const { value: _v, defaultValue: _d, onValueChange: _c, onValueCommit: _m, name: _n, startName: _s, endName: _e, minDays: _a, maxDays: _b, allowUnavailableInside: _u, allowDisabledInside: _i, ...shared } = options;
20
+ return shared;
21
+ };
22
+ const combine = (start, end) => start === null && end === null ? null : { start, end };
23
+ const setSide = (side, value) => {
24
+ const current = control.get();
25
+ const next = combine(side === "start" ? value : (current?.start ?? null), side === "end" ? value : (current?.end ?? null));
26
+ control.set(next);
27
+ propagate();
28
+ refresh();
29
+ };
30
+ const startController = createDateInputController({
31
+ ...childOptions(),
32
+ id: `${id}-start`,
33
+ value: control.get()?.start ?? null,
34
+ defaultValue: undefined,
35
+ onValueChange: (value) => setSide("start", value),
36
+ });
37
+ const endController = createDateInputController({
38
+ ...childOptions(),
39
+ id: `${id}-end`,
40
+ value: control.get()?.end ?? null,
41
+ defaultValue: undefined,
42
+ onValueChange: (value) => setSide("end", value),
43
+ });
44
+ function propagate() {
45
+ const value = control.get();
46
+ startController.setOptions({ value: value?.start ?? null });
47
+ endController.setOptions({ value: value?.end ?? null });
48
+ }
49
+ let state;
50
+ const listeners = new Set();
51
+ const availabilityOf = () => options.availability === undefined
52
+ ? undefined
53
+ : compileAvailability(options.availability, {
54
+ timeZone: options.timeZone,
55
+ now: options.now,
56
+ });
57
+ const pickConstraints = () => ({
58
+ minDays: options.minDays,
59
+ maxDays: options.maxDays,
60
+ allowUnavailableInside: options.allowUnavailableInside,
61
+ allowDisabledInside: options.allowDisabledInside,
62
+ isDateDisabled: options.isDateDisabled,
63
+ isDateUnavailable: (date) => (options.isDateUnavailable?.(date) ?? false) ||
64
+ availabilityOf()?.getDayStatus(date) === "unavailable",
65
+ });
66
+ const validityOf = (start, end) => {
67
+ if (start.validity === "empty" && end.validity === "empty")
68
+ return "empty";
69
+ for (const side of [start, end]) {
70
+ if (side.validity !== "valid" && side.validity !== "empty")
71
+ return side.validity;
72
+ }
73
+ if (start.validity === "empty" || end.validity === "empty")
74
+ return "incomplete";
75
+ const a = start.value;
76
+ const b = end.value;
77
+ if (compare(b, a) < 0)
78
+ return "end-before-start";
79
+ const check = checkPicked({ start: a, end: b }, pickConstraints());
80
+ return check.valid ? "valid" : check.reason;
81
+ };
82
+ const compute = () => {
83
+ const start = startController.getState();
84
+ const end = endController.getState();
85
+ const value = control.get();
86
+ const name = options.name;
87
+ return {
88
+ id,
89
+ value,
90
+ validity: validityOf(start, end),
91
+ start,
92
+ end,
93
+ disabled: start.disabled,
94
+ readOnly: start.readOnly,
95
+ hidden: getHiddenInputs([
96
+ [
97
+ options.startName ?? (name ? `${name}-start` : undefined),
98
+ value?.start ? toIsoString(value.start) : null,
99
+ ],
100
+ [
101
+ options.endName ?? (name ? `${name}-end` : undefined),
102
+ value?.end ? toIsoString(value.end) : null,
103
+ ],
104
+ ]),
105
+ messages: start.messages,
106
+ };
107
+ };
108
+ const refresh = () => {
109
+ const next = compute();
110
+ if (state && JSON.stringify(state) === JSON.stringify(next))
111
+ return;
112
+ state = next;
113
+ for (const listener of [...listeners])
114
+ listener(state);
115
+ };
116
+ state = compute();
117
+ startController.subscribe(refresh);
118
+ endController.subscribe(refresh);
119
+ const controller = {
120
+ getState: () => state,
121
+ subscribe(listener) {
122
+ listeners.add(listener);
123
+ return () => {
124
+ listeners.delete(listener);
125
+ };
126
+ },
127
+ setOptions(next) {
128
+ options = { ...options, ...next };
129
+ control.sync({ value: options.value });
130
+ const shared = childOptions();
131
+ startController.setOptions({
132
+ ...shared,
133
+ value: control.get()?.start ?? null,
134
+ });
135
+ endController.setOptions({
136
+ ...shared,
137
+ value: control.get()?.end ?? null,
138
+ });
139
+ refresh();
140
+ },
141
+ getStart: () => startController,
142
+ getEnd: () => endController,
143
+ commit() {
144
+ startController.settle();
145
+ endController.settle();
146
+ const value = control.get();
147
+ if (state.validity === "valid" &&
148
+ value?.start &&
149
+ value.end &&
150
+ !sameRange(value, lastCommitted)) {
151
+ lastCommitted = value;
152
+ options.onValueCommit?.({ start: value.start, end: value.end });
153
+ }
154
+ },
155
+ clear() {
156
+ startController.clear();
157
+ endController.clear();
158
+ lastCommitted = null;
159
+ },
160
+ reset() {
161
+ const value = options.defaultValue ?? null;
162
+ control.set(value);
163
+ propagate();
164
+ startController.reset();
165
+ endController.reset();
166
+ lastCommitted = value;
167
+ refresh();
168
+ },
169
+ getRootAttributes: () => ({
170
+ role: "group",
171
+ "data-chrono-date-range-input": true,
172
+ "data-mode": state.start.mode,
173
+ "data-disabled": state.disabled,
174
+ "data-readonly": state.readOnly,
175
+ "data-invalid": isInvalid(state.validity),
176
+ "aria-disabled": state.disabled ? "true" : undefined,
177
+ dir: state.start.direction,
178
+ }),
179
+ destroy() {
180
+ listeners.clear();
181
+ startController.destroy();
182
+ endController.destroy();
183
+ },
184
+ };
185
+ return controller;
186
+ }