@42-central/ui-react 0.0.0 → 0.17.0

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 (1248) hide show
  1. package/README.md +453 -1
  2. package/dist/chunk-2762HZYX.js +284 -0
  3. package/dist/chunk-2762HZYX.js.map +1 -0
  4. package/dist/chunk-2GILNBZW.js +31 -0
  5. package/dist/chunk-2GILNBZW.js.map +1 -0
  6. package/dist/chunk-2H46IXW4.js +264 -0
  7. package/dist/chunk-2H46IXW4.js.map +1 -0
  8. package/dist/chunk-2SVX3MQQ.js +78 -0
  9. package/dist/chunk-2SVX3MQQ.js.map +1 -0
  10. package/dist/chunk-3GYOIQW7.js +242 -0
  11. package/dist/chunk-3GYOIQW7.js.map +1 -0
  12. package/dist/chunk-3NZXWCGF.js +152 -0
  13. package/dist/chunk-3NZXWCGF.js.map +1 -0
  14. package/dist/chunk-44OV3PNH.js +294 -0
  15. package/dist/chunk-44OV3PNH.js.map +1 -0
  16. package/dist/chunk-5FDOOG4J.js +15 -0
  17. package/dist/chunk-5FDOOG4J.js.map +1 -0
  18. package/dist/chunk-6I4R3HR6.js +90 -0
  19. package/dist/chunk-6I4R3HR6.js.map +1 -0
  20. package/dist/chunk-6SWK4XG5.js +128 -0
  21. package/dist/chunk-6SWK4XG5.js.map +1 -0
  22. package/dist/chunk-7NZSTCJO.js +82 -0
  23. package/dist/chunk-7NZSTCJO.js.map +1 -0
  24. package/dist/chunk-7P32XCEU.js +15 -0
  25. package/dist/chunk-7P32XCEU.js.map +1 -0
  26. package/dist/chunk-ACE7FBWE.js +216 -0
  27. package/dist/chunk-ACE7FBWE.js.map +1 -0
  28. package/dist/chunk-AIQG7IIT.js +39 -0
  29. package/dist/chunk-AIQG7IIT.js.map +1 -0
  30. package/dist/chunk-B2LCHXUB.js +26 -0
  31. package/dist/chunk-B2LCHXUB.js.map +1 -0
  32. package/dist/chunk-BEL75C7N.js +35 -0
  33. package/dist/chunk-BEL75C7N.js.map +1 -0
  34. package/dist/chunk-BJZLQTAZ.js +3 -0
  35. package/dist/chunk-BJZLQTAZ.js.map +1 -0
  36. package/dist/chunk-BUIHQJGE.js +8 -0
  37. package/dist/chunk-BUIHQJGE.js.map +1 -0
  38. package/dist/chunk-CHTN5AHI.js +106 -0
  39. package/dist/chunk-CHTN5AHI.js.map +1 -0
  40. package/dist/chunk-CSCVTESP.js +58 -0
  41. package/dist/chunk-CSCVTESP.js.map +1 -0
  42. package/dist/chunk-EEMRRRYS.js +60 -0
  43. package/dist/chunk-EEMRRRYS.js.map +1 -0
  44. package/dist/chunk-FD6P6PLQ.js +153 -0
  45. package/dist/chunk-FD6P6PLQ.js.map +1 -0
  46. package/dist/chunk-FMMKEYHB.js +3 -0
  47. package/dist/chunk-FMMKEYHB.js.map +1 -0
  48. package/dist/chunk-FUWSTUDM.js +219 -0
  49. package/dist/chunk-FUWSTUDM.js.map +1 -0
  50. package/dist/chunk-G52U24GR.js +10 -0
  51. package/dist/chunk-G52U24GR.js.map +1 -0
  52. package/dist/chunk-GTKKRV5N.js +14 -0
  53. package/dist/chunk-GTKKRV5N.js.map +1 -0
  54. package/dist/chunk-HWNPXAEN.js +31 -0
  55. package/dist/chunk-HWNPXAEN.js.map +1 -0
  56. package/dist/chunk-IFWCCAQV.js +222 -0
  57. package/dist/chunk-IFWCCAQV.js.map +1 -0
  58. package/dist/chunk-IG7FBZVM.js +101 -0
  59. package/dist/chunk-IG7FBZVM.js.map +1 -0
  60. package/dist/chunk-IHYFYMHJ.js +167 -0
  61. package/dist/chunk-IHYFYMHJ.js.map +1 -0
  62. package/dist/chunk-IRXZHLUL.js +51 -0
  63. package/dist/chunk-IRXZHLUL.js.map +1 -0
  64. package/dist/chunk-IXKELBJA.js +202 -0
  65. package/dist/chunk-IXKELBJA.js.map +1 -0
  66. package/dist/chunk-J3PELDH3.js +279 -0
  67. package/dist/chunk-J3PELDH3.js.map +1 -0
  68. package/dist/chunk-JBVFWSRQ.js +21 -0
  69. package/dist/chunk-JBVFWSRQ.js.map +1 -0
  70. package/dist/chunk-MOI7B3KH.js +217 -0
  71. package/dist/chunk-MOI7B3KH.js.map +1 -0
  72. package/dist/chunk-NF5JM2YO.js +57 -0
  73. package/dist/chunk-NF5JM2YO.js.map +1 -0
  74. package/dist/chunk-NGAQITWP.js +156 -0
  75. package/dist/chunk-NGAQITWP.js.map +1 -0
  76. package/dist/chunk-NSDM3FEB.js +82 -0
  77. package/dist/chunk-NSDM3FEB.js.map +1 -0
  78. package/dist/chunk-ORTCK34Y.js +3 -0
  79. package/dist/chunk-ORTCK34Y.js.map +1 -0
  80. package/dist/chunk-P3XMBETI.js +26 -0
  81. package/dist/chunk-P3XMBETI.js.map +1 -0
  82. package/dist/chunk-P7A3BCAC.js +93 -0
  83. package/dist/chunk-P7A3BCAC.js.map +1 -0
  84. package/dist/chunk-PJL4ZL5V.js +639 -0
  85. package/dist/chunk-PJL4ZL5V.js.map +1 -0
  86. package/dist/chunk-POKDSVQT.js +223 -0
  87. package/dist/chunk-POKDSVQT.js.map +1 -0
  88. package/dist/chunk-QMW7D5GU.js +207 -0
  89. package/dist/chunk-QMW7D5GU.js.map +1 -0
  90. package/dist/chunk-QP4I37PA.js +14 -0
  91. package/dist/chunk-QP4I37PA.js.map +1 -0
  92. package/dist/chunk-R5GMMWAY.js +3 -0
  93. package/dist/chunk-R5GMMWAY.js.map +1 -0
  94. package/dist/chunk-S53FHWNG.js +30 -0
  95. package/dist/chunk-S53FHWNG.js.map +1 -0
  96. package/dist/chunk-SIG4DMNZ.js +238 -0
  97. package/dist/chunk-SIG4DMNZ.js.map +1 -0
  98. package/dist/chunk-SKPM2FRX.js +44 -0
  99. package/dist/chunk-SKPM2FRX.js.map +1 -0
  100. package/dist/chunk-TCWYBVIL.js +33 -0
  101. package/dist/chunk-TCWYBVIL.js.map +1 -0
  102. package/dist/chunk-TMMEJKLI.js +363 -0
  103. package/dist/chunk-TMMEJKLI.js.map +1 -0
  104. package/dist/chunk-TNNH3FVQ.js +155 -0
  105. package/dist/chunk-TNNH3FVQ.js.map +1 -0
  106. package/dist/chunk-TWGCWKRV.js +44 -0
  107. package/dist/chunk-TWGCWKRV.js.map +1 -0
  108. package/dist/chunk-U5GW5EBR.js +150 -0
  109. package/dist/chunk-U5GW5EBR.js.map +1 -0
  110. package/dist/chunk-UNSAA7YG.js +148 -0
  111. package/dist/chunk-UNSAA7YG.js.map +1 -0
  112. package/dist/chunk-UVYTJQTJ.js +14 -0
  113. package/dist/chunk-UVYTJQTJ.js.map +1 -0
  114. package/dist/chunk-VLUKI3HL.js +120 -0
  115. package/dist/chunk-VLUKI3HL.js.map +1 -0
  116. package/dist/chunk-VZ2TPU4B.js +348 -0
  117. package/dist/chunk-VZ2TPU4B.js.map +1 -0
  118. package/dist/chunk-VZH6TS7M.js +153 -0
  119. package/dist/chunk-VZH6TS7M.js.map +1 -0
  120. package/dist/chunk-WYCMIIRR.js +12 -0
  121. package/dist/chunk-WYCMIIRR.js.map +1 -0
  122. package/dist/chunk-WZB6LPQI.js +47 -0
  123. package/dist/chunk-WZB6LPQI.js.map +1 -0
  124. package/dist/chunk-YBJB7FGE.js +187 -0
  125. package/dist/chunk-YBJB7FGE.js.map +1 -0
  126. package/dist/chunk-YIQI2CF3.js +92 -0
  127. package/dist/chunk-YIQI2CF3.js.map +1 -0
  128. package/dist/chunk-YKUCSV34.js +72 -0
  129. package/dist/chunk-YKUCSV34.js.map +1 -0
  130. package/dist/chunk-ZP6EBROY.js +3 -0
  131. package/dist/chunk-ZP6EBROY.js.map +1 -0
  132. package/dist/colors.css +296 -0
  133. package/dist/components/accordion/accordion-data.d.ts +52 -0
  134. package/dist/components/accordion/accordion-data.d.ts.map +1 -0
  135. package/dist/components/accordion/accordion.d.ts +116 -0
  136. package/dist/components/accordion/accordion.d.ts.map +1 -0
  137. package/dist/components/accordion/index.d.ts +3 -0
  138. package/dist/components/accordion/index.d.ts.map +1 -0
  139. package/dist/components/accordion/index.js +206 -0
  140. package/dist/components/accordion/index.js.map +1 -0
  141. package/dist/components/action-icon/action-icon.d.ts +51 -0
  142. package/dist/components/action-icon/action-icon.d.ts.map +1 -0
  143. package/dist/components/action-icon/index.d.ts +2 -0
  144. package/dist/components/action-icon/index.d.ts.map +1 -0
  145. package/dist/components/action-icon/index.js +8 -0
  146. package/dist/components/action-icon/index.js.map +1 -0
  147. package/dist/components/alert/alert.d.ts +82 -0
  148. package/dist/components/alert/alert.d.ts.map +1 -0
  149. package/dist/components/alert/index.d.ts +2 -0
  150. package/dist/components/alert/index.d.ts.map +1 -0
  151. package/dist/components/alert/index.js +74 -0
  152. package/dist/components/alert/index.js.map +1 -0
  153. package/dist/components/ambient-background/ambient-background.d.ts +47 -0
  154. package/dist/components/ambient-background/ambient-background.d.ts.map +1 -0
  155. package/dist/components/ambient-background/index.d.ts +2 -0
  156. package/dist/components/ambient-background/index.d.ts.map +1 -0
  157. package/dist/components/ambient-background/index.js +35 -0
  158. package/dist/components/ambient-background/index.js.map +1 -0
  159. package/dist/components/app-shell/app-shell.d.ts +185 -0
  160. package/dist/components/app-shell/app-shell.d.ts.map +1 -0
  161. package/dist/components/app-shell/index.d.ts +2 -0
  162. package/dist/components/app-shell/index.d.ts.map +1 -0
  163. package/dist/components/app-shell/index.js +243 -0
  164. package/dist/components/app-shell/index.js.map +1 -0
  165. package/dist/components/autocomplete/autocomplete.d.ts +70 -0
  166. package/dist/components/autocomplete/autocomplete.d.ts.map +1 -0
  167. package/dist/components/autocomplete/index.d.ts +3 -0
  168. package/dist/components/autocomplete/index.d.ts.map +1 -0
  169. package/dist/components/autocomplete/index.js +149 -0
  170. package/dist/components/autocomplete/index.js.map +1 -0
  171. package/dist/components/avatar/avatar.d.ts +105 -0
  172. package/dist/components/avatar/avatar.d.ts.map +1 -0
  173. package/dist/components/avatar/index.d.ts +2 -0
  174. package/dist/components/avatar/index.d.ts.map +1 -0
  175. package/dist/components/avatar/index.js +211 -0
  176. package/dist/components/avatar/index.js.map +1 -0
  177. package/dist/components/badge/badge.d.ts +48 -0
  178. package/dist/components/badge/badge.d.ts.map +1 -0
  179. package/dist/components/badge/index.d.ts +2 -0
  180. package/dist/components/badge/index.d.ts.map +1 -0
  181. package/dist/components/badge/index.js +102 -0
  182. package/dist/components/badge/index.js.map +1 -0
  183. package/dist/components/breadcrumb/breadcrumb.d.ts +64 -0
  184. package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -0
  185. package/dist/components/breadcrumb/index.d.ts +2 -0
  186. package/dist/components/breadcrumb/index.d.ts.map +1 -0
  187. package/dist/components/breadcrumb/index.js +203 -0
  188. package/dist/components/breadcrumb/index.js.map +1 -0
  189. package/dist/components/button/button.d.ts +72 -0
  190. package/dist/components/button/button.d.ts.map +1 -0
  191. package/dist/components/button/index.d.ts +2 -0
  192. package/dist/components/button/index.d.ts.map +1 -0
  193. package/dist/components/button/index.js +9 -0
  194. package/dist/components/button/index.js.map +1 -0
  195. package/dist/components/button-group/button-group.d.ts +49 -0
  196. package/dist/components/button-group/button-group.d.ts.map +1 -0
  197. package/dist/components/button-group/index.d.ts +2 -0
  198. package/dist/components/button-group/index.d.ts.map +1 -0
  199. package/dist/components/button-group/index.js +5 -0
  200. package/dist/components/button-group/index.js.map +1 -0
  201. package/dist/components/button-multi-select/button-multi-select.d.ts +39 -0
  202. package/dist/components/button-multi-select/button-multi-select.d.ts.map +1 -0
  203. package/dist/components/button-multi-select/index.d.ts +5 -0
  204. package/dist/components/button-multi-select/index.d.ts.map +1 -0
  205. package/dist/components/button-multi-select/index.js +45 -0
  206. package/dist/components/button-multi-select/index.js.map +1 -0
  207. package/dist/components/button-select/button-select-control.d.ts +56 -0
  208. package/dist/components/button-select/button-select-control.d.ts.map +1 -0
  209. package/dist/components/button-select/button-select-data.d.ts +53 -0
  210. package/dist/components/button-select/button-select-data.d.ts.map +1 -0
  211. package/dist/components/button-select/button-select-items.d.ts +72 -0
  212. package/dist/components/button-select/button-select-items.d.ts.map +1 -0
  213. package/dist/components/button-select/button-select.d.ts +98 -0
  214. package/dist/components/button-select/button-select.d.ts.map +1 -0
  215. package/dist/components/button-select/index.d.ts +5 -0
  216. package/dist/components/button-select/index.d.ts.map +1 -0
  217. package/dist/components/button-select/index.js +45 -0
  218. package/dist/components/button-select/index.js.map +1 -0
  219. package/dist/components/calendar/calendar-body.d.ts +48 -0
  220. package/dist/components/calendar/calendar-body.d.ts.map +1 -0
  221. package/dist/components/calendar/calendar.d.ts +88 -0
  222. package/dist/components/calendar/calendar.d.ts.map +1 -0
  223. package/dist/components/calendar/index.d.ts +4 -0
  224. package/dist/components/calendar/index.d.ts.map +1 -0
  225. package/dist/components/calendar/index.js +11 -0
  226. package/dist/components/calendar/index.js.map +1 -0
  227. package/dist/components/card/card.d.ts +69 -0
  228. package/dist/components/card/card.d.ts.map +1 -0
  229. package/dist/components/card/index.d.ts +2 -0
  230. package/dist/components/card/index.d.ts.map +1 -0
  231. package/dist/components/card/index.js +6 -0
  232. package/dist/components/card/index.js.map +1 -0
  233. package/dist/components/chart/chart.d.ts +103 -0
  234. package/dist/components/chart/chart.d.ts.map +1 -0
  235. package/dist/components/chart/index.d.ts +2 -0
  236. package/dist/components/chart/index.d.ts.map +1 -0
  237. package/dist/components/chart/index.js +70 -0
  238. package/dist/components/chart/index.js.map +1 -0
  239. package/dist/components/chart/styles.css +50 -0
  240. package/dist/components/checkbox/checkbox.d.ts +74 -0
  241. package/dist/components/checkbox/checkbox.d.ts.map +1 -0
  242. package/dist/components/checkbox/control.d.ts +28 -0
  243. package/dist/components/checkbox/control.d.ts.map +1 -0
  244. package/dist/components/checkbox/index.d.ts +2 -0
  245. package/dist/components/checkbox/index.d.ts.map +1 -0
  246. package/dist/components/checkbox/index.js +10 -0
  247. package/dist/components/checkbox/index.js.map +1 -0
  248. package/dist/components/choice-card-group/choice-card-group.d.ts +148 -0
  249. package/dist/components/choice-card-group/choice-card-group.d.ts.map +1 -0
  250. package/dist/components/choice-card-group/index.d.ts +2 -0
  251. package/dist/components/choice-card-group/index.d.ts.map +1 -0
  252. package/dist/components/choice-card-group/index.js +280 -0
  253. package/dist/components/choice-card-group/index.js.map +1 -0
  254. package/dist/components/circular-progress/circular-progress.d.ts +49 -0
  255. package/dist/components/circular-progress/circular-progress.d.ts.map +1 -0
  256. package/dist/components/circular-progress/index.d.ts +2 -0
  257. package/dist/components/circular-progress/index.d.ts.map +1 -0
  258. package/dist/components/circular-progress/index.js +133 -0
  259. package/dist/components/circular-progress/index.js.map +1 -0
  260. package/dist/components/clipboard/clipboard.d.ts +95 -0
  261. package/dist/components/clipboard/clipboard.d.ts.map +1 -0
  262. package/dist/components/clipboard/copy.d.ts +67 -0
  263. package/dist/components/clipboard/copy.d.ts.map +1 -0
  264. package/dist/components/clipboard/index.d.ts +3 -0
  265. package/dist/components/clipboard/index.d.ts.map +1 -0
  266. package/dist/components/clipboard/index.js +86 -0
  267. package/dist/components/clipboard/index.js.map +1 -0
  268. package/dist/components/code/code.d.ts +37 -0
  269. package/dist/components/code/code.d.ts.map +1 -0
  270. package/dist/components/code/index.d.ts +2 -0
  271. package/dist/components/code/index.d.ts.map +1 -0
  272. package/dist/components/code/index.js +28 -0
  273. package/dist/components/code/index.js.map +1 -0
  274. package/dist/components/code-block/chrome.d.ts +77 -0
  275. package/dist/components/code-block/chrome.d.ts.map +1 -0
  276. package/dist/components/code-block/chrome.js +15 -0
  277. package/dist/components/code-block/chrome.js.map +1 -0
  278. package/dist/components/code-block/code-block.d.ts +99 -0
  279. package/dist/components/code-block/code-block.d.ts.map +1 -0
  280. package/dist/components/code-block/diff.d.ts +79 -0
  281. package/dist/components/code-block/diff.d.ts.map +1 -0
  282. package/dist/components/code-block/diff.js +23 -0
  283. package/dist/components/code-block/diff.js.map +1 -0
  284. package/dist/components/code-block/gutters.d.ts +100 -0
  285. package/dist/components/code-block/gutters.d.ts.map +1 -0
  286. package/dist/components/code-block/highlighter.d.ts +84 -0
  287. package/dist/components/code-block/highlighter.d.ts.map +1 -0
  288. package/dist/components/code-block/index.d.ts +23 -0
  289. package/dist/components/code-block/index.d.ts.map +1 -0
  290. package/dist/components/code-block/index.js +463 -0
  291. package/dist/components/code-block/index.js.map +1 -0
  292. package/dist/components/code-block/notation.d.ts +126 -0
  293. package/dist/components/code-block/notation.d.ts.map +1 -0
  294. package/dist/components/code-block/presets.d.ts +23 -0
  295. package/dist/components/code-block/presets.d.ts.map +1 -0
  296. package/dist/components/code-block/static.d.ts +65 -0
  297. package/dist/components/code-block/static.d.ts.map +1 -0
  298. package/dist/components/code-block/static.js +380 -0
  299. package/dist/components/code-block/static.js.map +1 -0
  300. package/dist/components/code-block/styles.css +198 -0
  301. package/dist/components/collapse/collapse.d.ts +50 -0
  302. package/dist/components/collapse/collapse.d.ts.map +1 -0
  303. package/dist/components/collapse/index.d.ts +2 -0
  304. package/dist/components/collapse/index.d.ts.map +1 -0
  305. package/dist/components/collapse/index.js +5 -0
  306. package/dist/components/collapse/index.js.map +1 -0
  307. package/dist/components/combobox/combobox.d.ts +78 -0
  308. package/dist/components/combobox/combobox.d.ts.map +1 -0
  309. package/dist/components/combobox/index.d.ts +3 -0
  310. package/dist/components/combobox/index.d.ts.map +1 -0
  311. package/dist/components/combobox/index.js +15 -0
  312. package/dist/components/combobox/index.js.map +1 -0
  313. package/dist/components/combobox-list/combobox-list.d.ts +77 -0
  314. package/dist/components/combobox-list/combobox-list.d.ts.map +1 -0
  315. package/dist/components/combobox-list/index.d.ts +2 -0
  316. package/dist/components/combobox-list/index.d.ts.map +1 -0
  317. package/dist/components/combobox-list/index.js +16 -0
  318. package/dist/components/combobox-list/index.js.map +1 -0
  319. package/dist/components/container/container.d.ts +18 -0
  320. package/dist/components/container/container.d.ts.map +1 -0
  321. package/dist/components/container/index.d.ts +2 -0
  322. package/dist/components/container/index.d.ts.map +1 -0
  323. package/dist/components/container/index.js +40 -0
  324. package/dist/components/container/index.js.map +1 -0
  325. package/dist/components/data-table/data-table-features.d.ts +80 -0
  326. package/dist/components/data-table/data-table-features.d.ts.map +1 -0
  327. package/dist/components/data-table/data-table-filter/data-table-date-filter.d.ts +53 -0
  328. package/dist/components/data-table/data-table-filter/data-table-date-filter.d.ts.map +1 -0
  329. package/dist/components/data-table/data-table-filter/data-table-filter-fns.d.ts +18 -0
  330. package/dist/components/data-table/data-table-filter/data-table-filter-fns.d.ts.map +1 -0
  331. package/dist/components/data-table/data-table-filter/data-table-number-filter.d.ts +7 -0
  332. package/dist/components/data-table/data-table-filter/data-table-number-filter.d.ts.map +1 -0
  333. package/dist/components/data-table/data-table-filter/data-table-select-filter.d.ts +15 -0
  334. package/dist/components/data-table/data-table-filter/data-table-select-filter.d.ts.map +1 -0
  335. package/dist/components/data-table/data-table-filter/data-table-text-filter.d.ts +7 -0
  336. package/dist/components/data-table/data-table-filter/data-table-text-filter.d.ts.map +1 -0
  337. package/dist/components/data-table/data-table-filter/index.d.ts +15 -0
  338. package/dist/components/data-table/data-table-filter/index.d.ts.map +1 -0
  339. package/dist/components/data-table/data-table-filter/utils.d.ts +52 -0
  340. package/dist/components/data-table/data-table-filter/utils.d.ts.map +1 -0
  341. package/dist/components/data-table/data-table-header-cell.d.ts +65 -0
  342. package/dist/components/data-table/data-table-header-cell.d.ts.map +1 -0
  343. package/dist/components/data-table/data-table-meta.d.ts +103 -0
  344. package/dist/components/data-table/data-table-meta.d.ts.map +1 -0
  345. package/dist/components/data-table/data-table-pagination.d.ts +56 -0
  346. package/dist/components/data-table/data-table-pagination.d.ts.map +1 -0
  347. package/dist/components/data-table/data-table-placeholder.d.ts +18 -0
  348. package/dist/components/data-table/data-table-placeholder.d.ts.map +1 -0
  349. package/dist/components/data-table/data-table-schema.d.ts +45 -0
  350. package/dist/components/data-table/data-table-schema.d.ts.map +1 -0
  351. package/dist/components/data-table/data-table-skeleton.d.ts +10 -0
  352. package/dist/components/data-table/data-table-skeleton.d.ts.map +1 -0
  353. package/dist/components/data-table/data-table-stack.d.ts +48 -0
  354. package/dist/components/data-table/data-table-stack.d.ts.map +1 -0
  355. package/dist/components/data-table/data-table-state.d.ts +10 -0
  356. package/dist/components/data-table/data-table-state.d.ts.map +1 -0
  357. package/dist/components/data-table/data-table-toolbar.d.ts +21 -0
  358. package/dist/components/data-table/data-table-toolbar.d.ts.map +1 -0
  359. package/dist/components/data-table/data-table.d.ts +194 -0
  360. package/dist/components/data-table/data-table.d.ts.map +1 -0
  361. package/dist/components/data-table/index.d.ts +14 -0
  362. package/dist/components/data-table/index.d.ts.map +1 -0
  363. package/dist/components/data-table/index.js +1603 -0
  364. package/dist/components/data-table/index.js.map +1 -0
  365. package/dist/components/date-picker/aliases.d.ts +11 -0
  366. package/dist/components/date-picker/aliases.d.ts.map +1 -0
  367. package/dist/components/date-picker/date-picker.d.ts +204 -0
  368. package/dist/components/date-picker/date-picker.d.ts.map +1 -0
  369. package/dist/components/date-picker/date-time-text.d.ts +32 -0
  370. package/dist/components/date-picker/date-time-text.d.ts.map +1 -0
  371. package/dist/components/date-picker/index.d.ts +7 -0
  372. package/dist/components/date-picker/index.d.ts.map +1 -0
  373. package/dist/components/date-picker/index.js +48 -0
  374. package/dist/components/date-picker/index.js.map +1 -0
  375. package/dist/components/divider/divider.d.ts +79 -0
  376. package/dist/components/divider/divider.d.ts.map +1 -0
  377. package/dist/components/divider/index.d.ts +2 -0
  378. package/dist/components/divider/index.d.ts.map +1 -0
  379. package/dist/components/divider/index.js +5 -0
  380. package/dist/components/divider/index.js.map +1 -0
  381. package/dist/components/drawer/drawer.d.ts +103 -0
  382. package/dist/components/drawer/drawer.d.ts.map +1 -0
  383. package/dist/components/drawer/index.d.ts +2 -0
  384. package/dist/components/drawer/index.d.ts.map +1 -0
  385. package/dist/components/drawer/index.js +13 -0
  386. package/dist/components/drawer/index.js.map +1 -0
  387. package/dist/components/field/field.d.ts +79 -0
  388. package/dist/components/field/field.d.ts.map +1 -0
  389. package/dist/components/field/index.d.ts +2 -0
  390. package/dist/components/field/index.d.ts.map +1 -0
  391. package/dist/components/field/index.js +6 -0
  392. package/dist/components/field/index.js.map +1 -0
  393. package/dist/components/file-upload/file-upload.d.ts +68 -0
  394. package/dist/components/file-upload/file-upload.d.ts.map +1 -0
  395. package/dist/components/file-upload/index.d.ts +2 -0
  396. package/dist/components/file-upload/index.d.ts.map +1 -0
  397. package/dist/components/file-upload/index.js +189 -0
  398. package/dist/components/file-upload/index.js.map +1 -0
  399. package/dist/components/flex/flex.d.ts +25 -0
  400. package/dist/components/flex/flex.d.ts.map +1 -0
  401. package/dist/components/flex/index.d.ts +2 -0
  402. package/dist/components/flex/index.d.ts.map +1 -0
  403. package/dist/components/flex/index.js +5 -0
  404. package/dist/components/flex/index.js.map +1 -0
  405. package/dist/components/grid/grid.d.ts +21 -0
  406. package/dist/components/grid/grid.d.ts.map +1 -0
  407. package/dist/components/grid/index.d.ts +2 -0
  408. package/dist/components/grid/index.d.ts.map +1 -0
  409. package/dist/components/grid/index.js +44 -0
  410. package/dist/components/grid/index.js.map +1 -0
  411. package/dist/components/hover-card/hover-card.d.ts +122 -0
  412. package/dist/components/hover-card/hover-card.d.ts.map +1 -0
  413. package/dist/components/hover-card/index.d.ts +2 -0
  414. package/dist/components/hover-card/index.d.ts.map +1 -0
  415. package/dist/components/hover-card/index.js +157 -0
  416. package/dist/components/hover-card/index.js.map +1 -0
  417. package/dist/components/indicator/index.d.ts +2 -0
  418. package/dist/components/indicator/index.d.ts.map +1 -0
  419. package/dist/components/indicator/index.js +152 -0
  420. package/dist/components/indicator/index.js.map +1 -0
  421. package/dist/components/indicator/indicator.d.ts +69 -0
  422. package/dist/components/indicator/indicator.d.ts.map +1 -0
  423. package/dist/components/input/index.d.ts +2 -0
  424. package/dist/components/input/index.d.ts.map +1 -0
  425. package/dist/components/input/index.js +7 -0
  426. package/dist/components/input/index.js.map +1 -0
  427. package/dist/components/input/input.d.ts +116 -0
  428. package/dist/components/input/input.d.ts.map +1 -0
  429. package/dist/components/kbd/index.d.ts +2 -0
  430. package/dist/components/kbd/index.d.ts.map +1 -0
  431. package/dist/components/kbd/index.js +65 -0
  432. package/dist/components/kbd/index.js.map +1 -0
  433. package/dist/components/kbd/kbd.d.ts +43 -0
  434. package/dist/components/kbd/kbd.d.ts.map +1 -0
  435. package/dist/components/mark/index.d.ts +2 -0
  436. package/dist/components/mark/index.d.ts.map +1 -0
  437. package/dist/components/mark/index.js +5 -0
  438. package/dist/components/mark/index.js.map +1 -0
  439. package/dist/components/mark/mark.d.ts +50 -0
  440. package/dist/components/mark/mark.d.ts.map +1 -0
  441. package/dist/components/menu/index.d.ts +3 -0
  442. package/dist/components/menu/index.d.ts.map +1 -0
  443. package/dist/components/menu/index.js +88 -0
  444. package/dist/components/menu/index.js.map +1 -0
  445. package/dist/components/menu/menu-data.d.ts +119 -0
  446. package/dist/components/menu/menu-data.d.ts.map +1 -0
  447. package/dist/components/menu/menu.d.ts +123 -0
  448. package/dist/components/menu/menu.d.ts.map +1 -0
  449. package/dist/components/modal/index.d.ts +2 -0
  450. package/dist/components/modal/index.d.ts.map +1 -0
  451. package/dist/components/modal/index.js +12 -0
  452. package/dist/components/modal/index.js.map +1 -0
  453. package/dist/components/modal/modal.d.ts +100 -0
  454. package/dist/components/modal/modal.d.ts.map +1 -0
  455. package/dist/components/multi-combobox-list/index.d.ts +2 -0
  456. package/dist/components/multi-combobox-list/index.d.ts.map +1 -0
  457. package/dist/components/multi-combobox-list/index.js +16 -0
  458. package/dist/components/multi-combobox-list/index.js.map +1 -0
  459. package/dist/components/multi-combobox-list/multi-combobox-list.d.ts +83 -0
  460. package/dist/components/multi-combobox-list/multi-combobox-list.d.ts.map +1 -0
  461. package/dist/components/multi-select/index.d.ts +3 -0
  462. package/dist/components/multi-select/index.d.ts.map +1 -0
  463. package/dist/components/multi-select/index.js +203 -0
  464. package/dist/components/multi-select/index.js.map +1 -0
  465. package/dist/components/multi-select/multi-select.d.ts +83 -0
  466. package/dist/components/multi-select/multi-select.d.ts.map +1 -0
  467. package/dist/components/nav-link/index.d.ts +3 -0
  468. package/dist/components/nav-link/index.d.ts.map +1 -0
  469. package/dist/components/nav-link/index.js +11 -0
  470. package/dist/components/nav-link/index.js.map +1 -0
  471. package/dist/components/nav-link/nav-link.d.ts +40 -0
  472. package/dist/components/nav-link/nav-link.d.ts.map +1 -0
  473. package/dist/components/nav-link/navigation.d.ts +45 -0
  474. package/dist/components/nav-link/navigation.d.ts.map +1 -0
  475. package/dist/components/nav-link/tanstack.d.ts +38 -0
  476. package/dist/components/nav-link/tanstack.d.ts.map +1 -0
  477. package/dist/components/nav-link/tanstack.js +21 -0
  478. package/dist/components/nav-link/tanstack.js.map +1 -0
  479. package/dist/components/notification/create-notifier.d.ts +117 -0
  480. package/dist/components/notification/create-notifier.d.ts.map +1 -0
  481. package/dist/components/notification/index.d.ts +5 -0
  482. package/dist/components/notification/index.d.ts.map +1 -0
  483. package/dist/components/notification/index.js +388 -0
  484. package/dist/components/notification/index.js.map +1 -0
  485. package/dist/components/notification/notification.d.ts +124 -0
  486. package/dist/components/notification/notification.d.ts.map +1 -0
  487. package/dist/components/notification/store.d.ts +42 -0
  488. package/dist/components/notification/store.d.ts.map +1 -0
  489. package/dist/components/notification/types.d.ts +62 -0
  490. package/dist/components/notification/types.d.ts.map +1 -0
  491. package/dist/components/number-input/index.d.ts +2 -0
  492. package/dist/components/number-input/index.d.ts.map +1 -0
  493. package/dist/components/number-input/index.js +16 -0
  494. package/dist/components/number-input/index.js.map +1 -0
  495. package/dist/components/number-input/number-input.d.ts +105 -0
  496. package/dist/components/number-input/number-input.d.ts.map +1 -0
  497. package/dist/components/overlays/create-overlays.d.ts +77 -0
  498. package/dist/components/overlays/create-overlays.d.ts.map +1 -0
  499. package/dist/components/overlays/index.d.ts +4 -0
  500. package/dist/components/overlays/index.d.ts.map +1 -0
  501. package/dist/components/overlays/index.js +332 -0
  502. package/dist/components/overlays/index.js.map +1 -0
  503. package/dist/components/overlays/renderer.d.ts +30 -0
  504. package/dist/components/overlays/renderer.d.ts.map +1 -0
  505. package/dist/components/overlays/store.d.ts +33 -0
  506. package/dist/components/overlays/store.d.ts.map +1 -0
  507. package/dist/components/overlays/types.d.ts +119 -0
  508. package/dist/components/overlays/types.d.ts.map +1 -0
  509. package/dist/components/password-input/index.d.ts +2 -0
  510. package/dist/components/password-input/index.d.ts.map +1 -0
  511. package/dist/components/password-input/index.js +125 -0
  512. package/dist/components/password-input/index.js.map +1 -0
  513. package/dist/components/password-input/password-input.d.ts +65 -0
  514. package/dist/components/password-input/password-input.d.ts.map +1 -0
  515. package/dist/components/pill/index.d.ts +2 -0
  516. package/dist/components/pill/index.d.ts.map +1 -0
  517. package/dist/components/pill/index.js +8 -0
  518. package/dist/components/pill/index.js.map +1 -0
  519. package/dist/components/pill/pill.d.ts +69 -0
  520. package/dist/components/pill/pill.d.ts.map +1 -0
  521. package/dist/components/pills-input/index.d.ts +2 -0
  522. package/dist/components/pills-input/index.d.ts.map +1 -0
  523. package/dist/components/pills-input/index.js +10 -0
  524. package/dist/components/pills-input/index.js.map +1 -0
  525. package/dist/components/pills-input/pills-input.d.ts +146 -0
  526. package/dist/components/pills-input/pills-input.d.ts.map +1 -0
  527. package/dist/components/pin-input/index.d.ts +2 -0
  528. package/dist/components/pin-input/index.d.ts.map +1 -0
  529. package/dist/components/pin-input/index.js +107 -0
  530. package/dist/components/pin-input/index.js.map +1 -0
  531. package/dist/components/pin-input/pin-input.d.ts +80 -0
  532. package/dist/components/pin-input/pin-input.d.ts.map +1 -0
  533. package/dist/components/popover/icons.d.ts +24 -0
  534. package/dist/components/popover/icons.d.ts.map +1 -0
  535. package/dist/components/popover/index.d.ts +2 -0
  536. package/dist/components/popover/index.d.ts.map +1 -0
  537. package/dist/components/popover/index.js +10 -0
  538. package/dist/components/popover/index.js.map +1 -0
  539. package/dist/components/popover/popover.d.ts +190 -0
  540. package/dist/components/popover/popover.d.ts.map +1 -0
  541. package/dist/components/progress/index.d.ts +2 -0
  542. package/dist/components/progress/index.d.ts.map +1 -0
  543. package/dist/components/progress/index.js +111 -0
  544. package/dist/components/progress/index.js.map +1 -0
  545. package/dist/components/progress/progress.d.ts +47 -0
  546. package/dist/components/progress/progress.d.ts.map +1 -0
  547. package/dist/components/radio-group/index.d.ts +2 -0
  548. package/dist/components/radio-group/index.d.ts.map +1 -0
  549. package/dist/components/radio-group/index.js +104 -0
  550. package/dist/components/radio-group/index.js.map +1 -0
  551. package/dist/components/radio-group/radio-group.d.ts +86 -0
  552. package/dist/components/radio-group/radio-group.d.ts.map +1 -0
  553. package/dist/components/rating/icons.d.ts +19 -0
  554. package/dist/components/rating/icons.d.ts.map +1 -0
  555. package/dist/components/rating/index.d.ts +2 -0
  556. package/dist/components/rating/index.d.ts.map +1 -0
  557. package/dist/components/rating/index.js +194 -0
  558. package/dist/components/rating/index.js.map +1 -0
  559. package/dist/components/rating/rating.d.ts +119 -0
  560. package/dist/components/rating/rating.d.ts.map +1 -0
  561. package/dist/components/schedule/index.d.ts +98 -0
  562. package/dist/components/schedule/index.d.ts.map +1 -0
  563. package/dist/components/schedule/index.js +6582 -0
  564. package/dist/components/schedule/index.js.map +1 -0
  565. package/dist/components/schedule/now-cursor-line.d.ts +97 -0
  566. package/dist/components/schedule/now-cursor-line.d.ts.map +1 -0
  567. package/dist/components/schedule/schedule-agenda-list.d.ts +55 -0
  568. package/dist/components/schedule/schedule-agenda-list.d.ts.map +1 -0
  569. package/dist/components/schedule/schedule-agenda-view.d.ts +48 -0
  570. package/dist/components/schedule/schedule-agenda-view.d.ts.map +1 -0
  571. package/dist/components/schedule/schedule-all-day-row.d.ts +100 -0
  572. package/dist/components/schedule/schedule-all-day-row.d.ts.map +1 -0
  573. package/dist/components/schedule/schedule-create-draft.d.ts +29 -0
  574. package/dist/components/schedule/schedule-create-draft.d.ts.map +1 -0
  575. package/dist/components/schedule/schedule-dates.d.ts +359 -0
  576. package/dist/components/schedule/schedule-dates.d.ts.map +1 -0
  577. package/dist/components/schedule/schedule-day-view.d.ts +24 -0
  578. package/dist/components/schedule/schedule-day-view.d.ts.map +1 -0
  579. package/dist/components/schedule/schedule-days-view.d.ts +60 -0
  580. package/dist/components/schedule/schedule-days-view.d.ts.map +1 -0
  581. package/dist/components/schedule/schedule-disabled-overlay.d.ts +34 -0
  582. package/dist/components/schedule/schedule-disabled-overlay.d.ts.map +1 -0
  583. package/dist/components/schedule/schedule-drag-ghost.d.ts +24 -0
  584. package/dist/components/schedule/schedule-drag-ghost.d.ts.map +1 -0
  585. package/dist/components/schedule/schedule-event-chip.d.ts +101 -0
  586. package/dist/components/schedule/schedule-event-chip.d.ts.map +1 -0
  587. package/dist/components/schedule/schedule-event-details.d.ts +37 -0
  588. package/dist/components/schedule/schedule-event-details.d.ts.map +1 -0
  589. package/dist/components/schedule/schedule-event-list-popover-content.d.ts +41 -0
  590. package/dist/components/schedule/schedule-event-list-popover-content.d.ts.map +1 -0
  591. package/dist/components/schedule/schedule-event-styles.d.ts +58 -0
  592. package/dist/components/schedule/schedule-event-styles.d.ts.map +1 -0
  593. package/dist/components/schedule/schedule-geometry.d.ts +291 -0
  594. package/dist/components/schedule/schedule-geometry.d.ts.map +1 -0
  595. package/dist/components/schedule/schedule-grid-gesture.d.ts +288 -0
  596. package/dist/components/schedule/schedule-grid-gesture.d.ts.map +1 -0
  597. package/dist/components/schedule/schedule-layout.d.ts +83 -0
  598. package/dist/components/schedule/schedule-layout.d.ts.map +1 -0
  599. package/dist/components/schedule/schedule-month-view.d.ts +44 -0
  600. package/dist/components/schedule/schedule-month-view.d.ts.map +1 -0
  601. package/dist/components/schedule/schedule-next-up-grouping.d.ts +37 -0
  602. package/dist/components/schedule/schedule-next-up-grouping.d.ts.map +1 -0
  603. package/dist/components/schedule/schedule-next-up.d.ts +79 -0
  604. package/dist/components/schedule/schedule-next-up.d.ts.map +1 -0
  605. package/dist/components/schedule/schedule-overflow-chip.d.ts +45 -0
  606. package/dist/components/schedule/schedule-overflow-chip.d.ts.map +1 -0
  607. package/dist/components/schedule/schedule-overflow-popover.d.ts +57 -0
  608. package/dist/components/schedule/schedule-overflow-popover.d.ts.map +1 -0
  609. package/dist/components/schedule/schedule-segments.d.ts +89 -0
  610. package/dist/components/schedule/schedule-segments.d.ts.map +1 -0
  611. package/dist/components/schedule/schedule-snap.d.ts +204 -0
  612. package/dist/components/schedule/schedule-snap.d.ts.map +1 -0
  613. package/dist/components/schedule/schedule-timed-grid.d.ts +78 -0
  614. package/dist/components/schedule/schedule-timed-grid.d.ts.map +1 -0
  615. package/dist/components/schedule/schedule-toolbar.d.ts +107 -0
  616. package/dist/components/schedule/schedule-toolbar.d.ts.map +1 -0
  617. package/dist/components/schedule/schedule-types.d.ts +841 -0
  618. package/dist/components/schedule/schedule-types.d.ts.map +1 -0
  619. package/dist/components/schedule/schedule-views.d.ts +197 -0
  620. package/dist/components/schedule/schedule-views.d.ts.map +1 -0
  621. package/dist/components/schedule/schedule-week-view.d.ts +19 -0
  622. package/dist/components/schedule/schedule-week-view.d.ts.map +1 -0
  623. package/dist/components/schedule/schedule-year-view.d.ts +38 -0
  624. package/dist/components/schedule/schedule-year-view.d.ts.map +1 -0
  625. package/dist/components/schedule/schedule.d.ts +163 -0
  626. package/dist/components/schedule/schedule.d.ts.map +1 -0
  627. package/dist/components/schedule/use-event-create.d.ts +54 -0
  628. package/dist/components/schedule/use-event-create.d.ts.map +1 -0
  629. package/dist/components/schedule/use-event-drag.d.ts +95 -0
  630. package/dist/components/schedule/use-event-drag.d.ts.map +1 -0
  631. package/dist/components/schedule/use-event-resize.d.ts +63 -0
  632. package/dist/components/schedule/use-event-resize.d.ts.map +1 -0
  633. package/dist/components/schedule/use-schedule-selection.d.ts +74 -0
  634. package/dist/components/schedule/use-schedule-selection.d.ts.map +1 -0
  635. package/dist/components/schedule/use-schedule.d.ts +78 -0
  636. package/dist/components/schedule/use-schedule.d.ts.map +1 -0
  637. package/dist/components/segment-group/index.d.ts +2 -0
  638. package/dist/components/segment-group/index.d.ts.map +1 -0
  639. package/dist/components/segment-group/index.js +10 -0
  640. package/dist/components/segment-group/index.js.map +1 -0
  641. package/dist/components/segment-group/segment-group.d.ts +187 -0
  642. package/dist/components/segment-group/segment-group.d.ts.map +1 -0
  643. package/dist/components/select/index.d.ts +3 -0
  644. package/dist/components/select/index.d.ts.map +1 -0
  645. package/dist/components/select/index.js +17 -0
  646. package/dist/components/select/index.js.map +1 -0
  647. package/dist/components/select/select.d.ts +83 -0
  648. package/dist/components/select/select.d.ts.map +1 -0
  649. package/dist/components/skeleton/index.d.ts +2 -0
  650. package/dist/components/skeleton/index.d.ts.map +1 -0
  651. package/dist/components/skeleton/index.js +5 -0
  652. package/dist/components/skeleton/index.js.map +1 -0
  653. package/dist/components/skeleton/skeleton.d.ts +83 -0
  654. package/dist/components/skeleton/skeleton.d.ts.map +1 -0
  655. package/dist/components/slider/index.d.ts +2 -0
  656. package/dist/components/slider/index.d.ts.map +1 -0
  657. package/dist/components/slider/index.js +258 -0
  658. package/dist/components/slider/index.js.map +1 -0
  659. package/dist/components/slider/slider.d.ts +90 -0
  660. package/dist/components/slider/slider.d.ts.map +1 -0
  661. package/dist/components/slider/sliderThumb.d.ts +1 -0
  662. package/dist/components/slider/sliderThumb.d.ts.map +1 -0
  663. package/dist/components/spinner/index.d.ts +2 -0
  664. package/dist/components/spinner/index.d.ts.map +1 -0
  665. package/dist/components/spinner/index.js +5 -0
  666. package/dist/components/spinner/index.js.map +1 -0
  667. package/dist/components/spinner/spinner.d.ts +61 -0
  668. package/dist/components/spinner/spinner.d.ts.map +1 -0
  669. package/dist/components/switch/index.d.ts +2 -0
  670. package/dist/components/switch/index.d.ts.map +1 -0
  671. package/dist/components/switch/index.js +140 -0
  672. package/dist/components/switch/index.js.map +1 -0
  673. package/dist/components/switch/switch.d.ts +48 -0
  674. package/dist/components/switch/switch.d.ts.map +1 -0
  675. package/dist/components/table/index.d.ts +2 -0
  676. package/dist/components/table/index.d.ts.map +1 -0
  677. package/dist/components/table/index.js +5 -0
  678. package/dist/components/table/index.js.map +1 -0
  679. package/dist/components/table/table.d.ts +113 -0
  680. package/dist/components/table/table.d.ts.map +1 -0
  681. package/dist/components/tabs/index.d.ts +3 -0
  682. package/dist/components/tabs/index.d.ts.map +1 -0
  683. package/dist/components/tabs/index.js +8 -0
  684. package/dist/components/tabs/index.js.map +1 -0
  685. package/dist/components/tabs/tabs-data.d.ts +67 -0
  686. package/dist/components/tabs/tabs-data.d.ts.map +1 -0
  687. package/dist/components/tabs/tabs.d.ts +96 -0
  688. package/dist/components/tabs/tabs.d.ts.map +1 -0
  689. package/dist/components/tags-input/index.d.ts +2 -0
  690. package/dist/components/tags-input/index.d.ts.map +1 -0
  691. package/dist/components/tags-input/index.js +203 -0
  692. package/dist/components/tags-input/index.js.map +1 -0
  693. package/dist/components/tags-input/tags-input.d.ts +68 -0
  694. package/dist/components/tags-input/tags-input.d.ts.map +1 -0
  695. package/dist/components/text/index.d.ts +2 -0
  696. package/dist/components/text/index.d.ts.map +1 -0
  697. package/dist/components/text/index.js +6 -0
  698. package/dist/components/text/index.js.map +1 -0
  699. package/dist/components/text/text.d.ts +50 -0
  700. package/dist/components/text/text.d.ts.map +1 -0
  701. package/dist/components/text-input/index.d.ts +2 -0
  702. package/dist/components/text-input/index.d.ts.map +1 -0
  703. package/dist/components/text-input/index.js +34 -0
  704. package/dist/components/text-input/index.js.map +1 -0
  705. package/dist/components/text-input/text-input.d.ts +56 -0
  706. package/dist/components/text-input/text-input.d.ts.map +1 -0
  707. package/dist/components/textarea/index.d.ts +2 -0
  708. package/dist/components/textarea/index.d.ts.map +1 -0
  709. package/dist/components/textarea/index.js +116 -0
  710. package/dist/components/textarea/index.js.map +1 -0
  711. package/dist/components/textarea/textarea.d.ts +48 -0
  712. package/dist/components/textarea/textarea.d.ts.map +1 -0
  713. package/dist/components/theme-icon/index.d.ts +2 -0
  714. package/dist/components/theme-icon/index.d.ts.map +1 -0
  715. package/dist/components/theme-icon/index.js +6 -0
  716. package/dist/components/theme-icon/index.js.map +1 -0
  717. package/dist/components/theme-icon/theme-icon.d.ts +34 -0
  718. package/dist/components/theme-icon/theme-icon.d.ts.map +1 -0
  719. package/dist/components/theme-script/index.d.ts +2 -0
  720. package/dist/components/theme-script/index.d.ts.map +1 -0
  721. package/dist/components/theme-script/index.js +29 -0
  722. package/dist/components/theme-script/index.js.map +1 -0
  723. package/dist/components/theme-script/theme-script.d.ts +41 -0
  724. package/dist/components/theme-script/theme-script.d.ts.map +1 -0
  725. package/dist/components/time-input/hour-cycle.d.ts +32 -0
  726. package/dist/components/time-input/hour-cycle.d.ts.map +1 -0
  727. package/dist/components/time-input/index.d.ts +3 -0
  728. package/dist/components/time-input/index.d.ts.map +1 -0
  729. package/dist/components/time-input/index.js +125 -0
  730. package/dist/components/time-input/index.js.map +1 -0
  731. package/dist/components/time-input/time-input.d.ts +63 -0
  732. package/dist/components/time-input/time-input.d.ts.map +1 -0
  733. package/dist/components/time-input/time-row.d.ts +72 -0
  734. package/dist/components/time-input/time-row.d.ts.map +1 -0
  735. package/dist/components/timeline/index.d.ts +2 -0
  736. package/dist/components/timeline/index.d.ts.map +1 -0
  737. package/dist/components/timeline/index.js +372 -0
  738. package/dist/components/timeline/index.js.map +1 -0
  739. package/dist/components/timeline/timeline.d.ts +194 -0
  740. package/dist/components/timeline/timeline.d.ts.map +1 -0
  741. package/dist/components/title/index.d.ts +2 -0
  742. package/dist/components/title/index.d.ts.map +1 -0
  743. package/dist/components/title/index.js +6 -0
  744. package/dist/components/title/index.js.map +1 -0
  745. package/dist/components/title/title.d.ts +47 -0
  746. package/dist/components/title/title.d.ts.map +1 -0
  747. package/dist/components/tooltip/index.d.ts +2 -0
  748. package/dist/components/tooltip/index.d.ts.map +1 -0
  749. package/dist/components/tooltip/index.js +10 -0
  750. package/dist/components/tooltip/index.js.map +1 -0
  751. package/dist/components/tooltip/tooltip.d.ts +70 -0
  752. package/dist/components/tooltip/tooltip.d.ts.map +1 -0
  753. package/dist/components/tree-multi-select/index.d.ts +3 -0
  754. package/dist/components/tree-multi-select/index.d.ts.map +1 -0
  755. package/dist/components/tree-multi-select/index.js +424 -0
  756. package/dist/components/tree-multi-select/index.js.map +1 -0
  757. package/dist/components/tree-multi-select/tree-multi-select.d.ts +72 -0
  758. package/dist/components/tree-multi-select/tree-multi-select.d.ts.map +1 -0
  759. package/dist/components/tree-select/index.d.ts +3 -0
  760. package/dist/components/tree-select/index.d.ts.map +1 -0
  761. package/dist/components/tree-select/index.js +425 -0
  762. package/dist/components/tree-select/index.js.map +1 -0
  763. package/dist/components/tree-select/tree-select.d.ts +68 -0
  764. package/dist/components/tree-select/tree-select.d.ts.map +1 -0
  765. package/dist/index.d.ts +24 -0
  766. package/dist/index.d.ts.map +1 -0
  767. package/dist/index.js +269 -0
  768. package/dist/index.js.map +1 -0
  769. package/dist/lib/align.d.ts +7 -0
  770. package/dist/lib/align.d.ts.map +1 -0
  771. package/dist/lib/available-if.d.ts +114 -0
  772. package/dist/lib/available-if.d.ts.map +1 -0
  773. package/dist/lib/brand.d.ts +22 -0
  774. package/dist/lib/brand.d.ts.map +1 -0
  775. package/dist/lib/cn.d.ts +14 -0
  776. package/dist/lib/cn.d.ts.map +1 -0
  777. package/dist/lib/cn.js +3 -0
  778. package/dist/lib/cn.js.map +1 -0
  779. package/dist/lib/colors.d.ts +14 -0
  780. package/dist/lib/colors.d.ts.map +1 -0
  781. package/dist/lib/control-open.d.ts +28 -0
  782. package/dist/lib/control-open.d.ts.map +1 -0
  783. package/dist/lib/date-predicates.d.ts +28 -0
  784. package/dist/lib/date-predicates.d.ts.map +1 -0
  785. package/dist/lib/date-value.d.ts +45 -0
  786. package/dist/lib/date-value.d.ts.map +1 -0
  787. package/dist/lib/dev-warn.d.ts +2 -0
  788. package/dist/lib/dev-warn.d.ts.map +1 -0
  789. package/dist/lib/focus-styles.d.ts +102 -0
  790. package/dist/lib/focus-styles.d.ts.map +1 -0
  791. package/dist/lib/form-control.d.ts +72 -0
  792. package/dist/lib/form-control.d.ts.map +1 -0
  793. package/dist/lib/gradient.d.ts +31 -0
  794. package/dist/lib/gradient.d.ts.map +1 -0
  795. package/dist/lib/intl.d.ts +77 -0
  796. package/dist/lib/intl.d.ts.map +1 -0
  797. package/dist/lib/link-component.d.ts +13 -0
  798. package/dist/lib/link-component.d.ts.map +1 -0
  799. package/dist/lib/merge-refs.d.ts +12 -0
  800. package/dist/lib/merge-refs.d.ts.map +1 -0
  801. package/dist/lib/overlay-container.d.ts +14 -0
  802. package/dist/lib/overlay-container.d.ts.map +1 -0
  803. package/dist/lib/overlay-layer.d.ts +51 -0
  804. package/dist/lib/overlay-layer.d.ts.map +1 -0
  805. package/dist/lib/placement.d.ts +16 -0
  806. package/dist/lib/placement.d.ts.map +1 -0
  807. package/dist/lib/props.d.ts +40 -0
  808. package/dist/lib/props.d.ts.map +1 -0
  809. package/dist/lib/required-if.d.ts +46 -0
  810. package/dist/lib/required-if.d.ts.map +1 -0
  811. package/dist/lib/schedule-predicates.d.ts +72 -0
  812. package/dist/lib/schedule-predicates.d.ts.map +1 -0
  813. package/dist/lib/select-data.d.ts +135 -0
  814. package/dist/lib/select-data.d.ts.map +1 -0
  815. package/dist/lib/sizes.d.ts +20 -0
  816. package/dist/lib/sizes.d.ts.map +1 -0
  817. package/dist/lib/test-id.d.ts +30 -0
  818. package/dist/lib/test-id.d.ts.map +1 -0
  819. package/dist/lib/theme-init-runtime.d.ts +26 -0
  820. package/dist/lib/theme-init-runtime.d.ts.map +1 -0
  821. package/dist/lib/theme.d.ts +93 -0
  822. package/dist/lib/theme.d.ts.map +1 -0
  823. package/dist/lib/tree-data.d.ts +99 -0
  824. package/dist/lib/tree-data.d.ts.map +1 -0
  825. package/dist/lib/typography-size.d.ts +49 -0
  826. package/dist/lib/typography-size.d.ts.map +1 -0
  827. package/dist/lib/use-container-query.d.ts +19 -0
  828. package/dist/lib/use-container-query.d.ts.map +1 -0
  829. package/dist/lib/use-disclosure.d.ts +35 -0
  830. package/dist/lib/use-disclosure.d.ts.map +1 -0
  831. package/dist/lib/use-isomorphic-layout-effect.d.ts +12 -0
  832. package/dist/lib/use-isomorphic-layout-effect.d.ts.map +1 -0
  833. package/dist/lib/use-local-storage.d.ts +45 -0
  834. package/dist/lib/use-local-storage.d.ts.map +1 -0
  835. package/dist/lib/use-logger.d.ts +2 -0
  836. package/dist/lib/use-logger.d.ts.map +1 -0
  837. package/dist/lib/use-media-query.d.ts +11 -0
  838. package/dist/lib/use-media-query.d.ts.map +1 -0
  839. package/dist/lib/use-now.d.ts +7 -0
  840. package/dist/lib/use-now.d.ts.map +1 -0
  841. package/dist/lib/use-theme.d.ts +101 -0
  842. package/dist/lib/use-theme.d.ts.map +1 -0
  843. package/dist/lib/use-uncontrolled.d.ts +45 -0
  844. package/dist/lib/use-uncontrolled.d.ts.map +1 -0
  845. package/dist/styles.css +17 -0
  846. package/dist/test-setup.d.ts +2 -0
  847. package/dist/test-setup.d.ts.map +1 -0
  848. package/dist/theme-init-script.d.ts +2 -0
  849. package/dist/theme-init-script.d.ts.map +1 -0
  850. package/dist/theme-init.js +2 -0
  851. package/dist/theme-init.js.map +1 -0
  852. package/dist/theme.css +1275 -0
  853. package/package.json +99 -3
  854. package/src/colors.css +296 -0
  855. package/src/components/accordion/accordion-data.tsx +86 -0
  856. package/src/components/accordion/accordion.test.tsx +234 -0
  857. package/src/components/accordion/accordion.tsx +336 -0
  858. package/src/components/accordion/index.ts +18 -0
  859. package/src/components/action-icon/action-icon.test.tsx +57 -0
  860. package/src/components/action-icon/action-icon.tsx +180 -0
  861. package/src/components/action-icon/index.ts +12 -0
  862. package/src/components/alert/alert.test.tsx +125 -0
  863. package/src/components/alert/alert.tsx +158 -0
  864. package/src/components/alert/index.ts +3 -0
  865. package/src/components/ambient-background/ambient-background.test.tsx +64 -0
  866. package/src/components/ambient-background/ambient-background.tsx +76 -0
  867. package/src/components/ambient-background/index.ts +1 -0
  868. package/src/components/app-shell/app-shell.test.tsx +271 -0
  869. package/src/components/app-shell/app-shell.tsx +492 -0
  870. package/src/components/app-shell/index.ts +17 -0
  871. package/src/components/autocomplete/autocomplete.test.tsx +120 -0
  872. package/src/components/autocomplete/autocomplete.tsx +249 -0
  873. package/src/components/autocomplete/index.ts +11 -0
  874. package/src/components/avatar/avatar.test.tsx +345 -0
  875. package/src/components/avatar/avatar.tsx +456 -0
  876. package/src/components/avatar/index.ts +12 -0
  877. package/src/components/badge/badge.test.tsx +51 -0
  878. package/src/components/badge/badge.tsx +148 -0
  879. package/src/components/badge/index.ts +6 -0
  880. package/src/components/breadcrumb/breadcrumb.test.tsx +238 -0
  881. package/src/components/breadcrumb/breadcrumb.tsx +348 -0
  882. package/src/components/breadcrumb/index.ts +9 -0
  883. package/src/components/button/button.test.tsx +87 -0
  884. package/src/components/button/button.tsx +253 -0
  885. package/src/components/button/index.ts +12 -0
  886. package/src/components/button-group/button-group.test.tsx +168 -0
  887. package/src/components/button-group/button-group.tsx +121 -0
  888. package/src/components/button-group/index.ts +1 -0
  889. package/src/components/button-multi-select/button-multi-select.test.tsx +146 -0
  890. package/src/components/button-multi-select/button-multi-select.tsx +76 -0
  891. package/src/components/button-multi-select/index.ts +17 -0
  892. package/src/components/button-select/button-select-control.tsx +153 -0
  893. package/src/components/button-select/button-select-data.tsx +96 -0
  894. package/src/components/button-select/button-select-items.ts +103 -0
  895. package/src/components/button-select/button-select.test.tsx +239 -0
  896. package/src/components/button-select/button-select.tsx +323 -0
  897. package/src/components/button-select/index.ts +14 -0
  898. package/src/components/calendar/calendar-body.tsx +403 -0
  899. package/src/components/calendar/calendar.test.tsx +278 -0
  900. package/src/components/calendar/calendar.tsx +220 -0
  901. package/src/components/calendar/index.ts +10 -0
  902. package/src/components/card/card.tsx +211 -0
  903. package/src/components/card/index.ts +12 -0
  904. package/src/components/chart/chart.test.tsx +98 -0
  905. package/src/components/chart/chart.tsx +192 -0
  906. package/src/components/chart/index.ts +8 -0
  907. package/src/components/chart/styles.css +50 -0
  908. package/src/components/checkbox/checkbox.test.tsx +113 -0
  909. package/src/components/checkbox/checkbox.tsx +182 -0
  910. package/src/components/checkbox/control.ts +76 -0
  911. package/src/components/checkbox/index.ts +3 -0
  912. package/src/components/choice-card-group/choice-card-group.test.tsx +250 -0
  913. package/src/components/choice-card-group/choice-card-group.tsx +549 -0
  914. package/src/components/choice-card-group/index.ts +9 -0
  915. package/src/components/circular-progress/circular-progress.test.tsx +120 -0
  916. package/src/components/circular-progress/circular-progress.tsx +214 -0
  917. package/src/components/circular-progress/index.ts +15 -0
  918. package/src/components/clipboard/clipboard.test.tsx +229 -0
  919. package/src/components/clipboard/clipboard.tsx +128 -0
  920. package/src/components/clipboard/copy.tsx +127 -0
  921. package/src/components/clipboard/index.ts +12 -0
  922. package/src/components/code/code.test.tsx +57 -0
  923. package/src/components/code/code.tsx +54 -0
  924. package/src/components/code/index.ts +1 -0
  925. package/src/components/code-block/chrome.tsx +347 -0
  926. package/src/components/code-block/code-block.test.tsx +252 -0
  927. package/src/components/code-block/code-block.tsx +254 -0
  928. package/src/components/code-block/diff.test.ts +177 -0
  929. package/src/components/code-block/diff.ts +114 -0
  930. package/src/components/code-block/gutters.test.ts +280 -0
  931. package/src/components/code-block/gutters.ts +260 -0
  932. package/src/components/code-block/highlighter.test.ts +261 -0
  933. package/src/components/code-block/highlighter.ts +290 -0
  934. package/src/components/code-block/index.ts +53 -0
  935. package/src/components/code-block/notation.test.ts +166 -0
  936. package/src/components/code-block/notation.ts +233 -0
  937. package/src/components/code-block/presets.test.ts +43 -0
  938. package/src/components/code-block/presets.ts +28 -0
  939. package/src/components/code-block/static.tsx +130 -0
  940. package/src/components/code-block/styles.css +198 -0
  941. package/src/components/collapse/collapse.test.tsx +96 -0
  942. package/src/components/collapse/collapse.tsx +81 -0
  943. package/src/components/collapse/index.ts +1 -0
  944. package/src/components/combobox/combobox.tsx +317 -0
  945. package/src/components/combobox/index.ts +15 -0
  946. package/src/components/combobox-list/combobox-list.test.tsx +148 -0
  947. package/src/components/combobox-list/combobox-list.tsx +276 -0
  948. package/src/components/combobox-list/index.ts +3 -0
  949. package/src/components/container/container.tsx +47 -0
  950. package/src/components/container/index.ts +1 -0
  951. package/src/components/data-table/data-table-features.ts +127 -0
  952. package/src/components/data-table/data-table-filter/data-table-date-filter.tsx +275 -0
  953. package/src/components/data-table/data-table-filter/data-table-filter-fns.ts +126 -0
  954. package/src/components/data-table/data-table-filter/data-table-number-filter.tsx +74 -0
  955. package/src/components/data-table/data-table-filter/data-table-select-filter.tsx +47 -0
  956. package/src/components/data-table/data-table-filter/data-table-text-filter.tsx +29 -0
  957. package/src/components/data-table/data-table-filter/index.tsx +62 -0
  958. package/src/components/data-table/data-table-filter/utils.ts +112 -0
  959. package/src/components/data-table/data-table-filter-fns.test.tsx +145 -0
  960. package/src/components/data-table/data-table-filter.test.tsx +365 -0
  961. package/src/components/data-table/data-table-header-cell.tsx +292 -0
  962. package/src/components/data-table/data-table-meta.ts +102 -0
  963. package/src/components/data-table/data-table-pagination.tsx +175 -0
  964. package/src/components/data-table/data-table-placeholder.tsx +61 -0
  965. package/src/components/data-table/data-table-schema.test.tsx +22 -0
  966. package/src/components/data-table/data-table-schema.ts +23 -0
  967. package/src/components/data-table/data-table-skeleton.ts +9 -0
  968. package/src/components/data-table/data-table-stack.tsx +376 -0
  969. package/src/components/data-table/data-table-state.ts +35 -0
  970. package/src/components/data-table/data-table-toolbar.tsx +81 -0
  971. package/src/components/data-table/data-table.test.tsx +1143 -0
  972. package/src/components/data-table/data-table.tsx +829 -0
  973. package/src/components/data-table/index.ts +46 -0
  974. package/src/components/date-picker/aliases.tsx +15 -0
  975. package/src/components/date-picker/date-picker.test.tsx +699 -0
  976. package/src/components/date-picker/date-picker.tsx +1000 -0
  977. package/src/components/date-picker/date-time-text.test.ts +68 -0
  978. package/src/components/date-picker/date-time-text.ts +103 -0
  979. package/src/components/date-picker/index.ts +32 -0
  980. package/src/components/divider/divider.test.tsx +106 -0
  981. package/src/components/divider/divider.tsx +162 -0
  982. package/src/components/divider/index.ts +8 -0
  983. package/src/components/drawer/drawer.tsx +405 -0
  984. package/src/components/drawer/index.ts +21 -0
  985. package/src/components/field/field.tsx +235 -0
  986. package/src/components/field/index.ts +3 -0
  987. package/src/components/file-upload/file-upload.test.tsx +47 -0
  988. package/src/components/file-upload/file-upload.tsx +280 -0
  989. package/src/components/file-upload/index.ts +3 -0
  990. package/src/components/flex/flex.tsx +81 -0
  991. package/src/components/flex/index.ts +1 -0
  992. package/src/components/grid/grid.tsx +52 -0
  993. package/src/components/grid/index.ts +1 -0
  994. package/src/components/hover-card/hover-card.test.tsx +192 -0
  995. package/src/components/hover-card/hover-card.tsx +376 -0
  996. package/src/components/hover-card/index.ts +9 -0
  997. package/src/components/indicator/index.ts +6 -0
  998. package/src/components/indicator/indicator.test.tsx +241 -0
  999. package/src/components/indicator/indicator.tsx +275 -0
  1000. package/src/components/input/index.ts +12 -0
  1001. package/src/components/input/input.test.tsx +111 -0
  1002. package/src/components/input/input.tsx +320 -0
  1003. package/src/components/kbd/index.ts +1 -0
  1004. package/src/components/kbd/kbd.test.tsx +20 -0
  1005. package/src/components/kbd/kbd.tsx +98 -0
  1006. package/src/components/mark/index.ts +1 -0
  1007. package/src/components/mark/mark.test.tsx +85 -0
  1008. package/src/components/mark/mark.tsx +79 -0
  1009. package/src/components/menu/index.ts +27 -0
  1010. package/src/components/menu/menu-data.tsx +230 -0
  1011. package/src/components/menu/menu.test.tsx +547 -0
  1012. package/src/components/menu/menu.tsx +514 -0
  1013. package/src/components/modal/index.ts +14 -0
  1014. package/src/components/modal/modal.tsx +420 -0
  1015. package/src/components/multi-combobox-list/index.ts +3 -0
  1016. package/src/components/multi-combobox-list/multi-combobox-list.test.tsx +190 -0
  1017. package/src/components/multi-combobox-list/multi-combobox-list.tsx +308 -0
  1018. package/src/components/multi-select/index.ts +12 -0
  1019. package/src/components/multi-select/multi-select.test.tsx +248 -0
  1020. package/src/components/multi-select/multi-select.tsx +355 -0
  1021. package/src/components/nav-link/index.ts +4 -0
  1022. package/src/components/nav-link/nav-link.test.tsx +107 -0
  1023. package/src/components/nav-link/nav-link.tsx +205 -0
  1024. package/src/components/nav-link/navigation.test.tsx +117 -0
  1025. package/src/components/nav-link/navigation.tsx +81 -0
  1026. package/src/components/nav-link/tanstack.tsx +67 -0
  1027. package/src/components/notification/create-notifier.tsx +517 -0
  1028. package/src/components/notification/index.ts +20 -0
  1029. package/src/components/notification/notification.test.tsx +306 -0
  1030. package/src/components/notification/notification.tsx +353 -0
  1031. package/src/components/notification/store.ts +159 -0
  1032. package/src/components/notification/types.ts +67 -0
  1033. package/src/components/number-input/index.ts +3 -0
  1034. package/src/components/number-input/number-input.test.tsx +291 -0
  1035. package/src/components/number-input/number-input.tsx +407 -0
  1036. package/src/components/overlays/create-overlays.tsx +267 -0
  1037. package/src/components/overlays/index.ts +25 -0
  1038. package/src/components/overlays/renderer.tsx +214 -0
  1039. package/src/components/overlays/store.ts +103 -0
  1040. package/src/components/overlays/types.ts +150 -0
  1041. package/src/components/password-input/index.ts +3 -0
  1042. package/src/components/password-input/password-input.test.tsx +94 -0
  1043. package/src/components/password-input/password-input.tsx +191 -0
  1044. package/src/components/pill/index.ts +9 -0
  1045. package/src/components/pill/pill.test.tsx +22 -0
  1046. package/src/components/pill/pill.tsx +221 -0
  1047. package/src/components/pills-input/index.ts +12 -0
  1048. package/src/components/pills-input/pills-input.test.ts +136 -0
  1049. package/src/components/pills-input/pills-input.tsx +422 -0
  1050. package/src/components/pin-input/index.ts +3 -0
  1051. package/src/components/pin-input/pin-input.test.tsx +74 -0
  1052. package/src/components/pin-input/pin-input.tsx +186 -0
  1053. package/src/components/popover/icons.tsx +129 -0
  1054. package/src/components/popover/index.ts +8 -0
  1055. package/src/components/popover/popover.test.tsx +223 -0
  1056. package/src/components/popover/popover.tsx +635 -0
  1057. package/src/components/progress/index.ts +18 -0
  1058. package/src/components/progress/progress.test.tsx +112 -0
  1059. package/src/components/progress/progress.tsx +194 -0
  1060. package/src/components/radio-group/index.ts +9 -0
  1061. package/src/components/radio-group/radio-group.test.tsx +107 -0
  1062. package/src/components/radio-group/radio-group.tsx +207 -0
  1063. package/src/components/rating/icons.tsx +35 -0
  1064. package/src/components/rating/index.ts +9 -0
  1065. package/src/components/rating/rating.test.tsx +288 -0
  1066. package/src/components/rating/rating.tsx +389 -0
  1067. package/src/components/schedule/index.ts +170 -0
  1068. package/src/components/schedule/now-cursor-line.test.tsx +262 -0
  1069. package/src/components/schedule/now-cursor-line.tsx +343 -0
  1070. package/src/components/schedule/schedule-agenda-list.tsx +480 -0
  1071. package/src/components/schedule/schedule-agenda-view.test.tsx +333 -0
  1072. package/src/components/schedule/schedule-agenda-view.tsx +209 -0
  1073. package/src/components/schedule/schedule-all-day-row.test.ts +187 -0
  1074. package/src/components/schedule/schedule-all-day-row.tsx +616 -0
  1075. package/src/components/schedule/schedule-create-draft.tsx +181 -0
  1076. package/src/components/schedule/schedule-dates.test.ts +771 -0
  1077. package/src/components/schedule/schedule-dates.ts +721 -0
  1078. package/src/components/schedule/schedule-day-view.tsx +30 -0
  1079. package/src/components/schedule/schedule-days-view.tsx +277 -0
  1080. package/src/components/schedule/schedule-details-popover.test.tsx +765 -0
  1081. package/src/components/schedule/schedule-disabled-overlay.tsx +51 -0
  1082. package/src/components/schedule/schedule-drag-ghost.tsx +157 -0
  1083. package/src/components/schedule/schedule-event-chip.tsx +1176 -0
  1084. package/src/components/schedule/schedule-event-details.tsx +101 -0
  1085. package/src/components/schedule/schedule-event-list-popover-content.tsx +149 -0
  1086. package/src/components/schedule/schedule-event-styles.ts +60 -0
  1087. package/src/components/schedule/schedule-geometry.test.ts +426 -0
  1088. package/src/components/schedule/schedule-geometry.ts +461 -0
  1089. package/src/components/schedule/schedule-grid-gesture.test.ts +153 -0
  1090. package/src/components/schedule/schedule-grid-gesture.ts +567 -0
  1091. package/src/components/schedule/schedule-layout.test.ts +260 -0
  1092. package/src/components/schedule/schedule-layout.ts +270 -0
  1093. package/src/components/schedule/schedule-month-view.test.tsx +193 -0
  1094. package/src/components/schedule/schedule-month-view.tsx +688 -0
  1095. package/src/components/schedule/schedule-next-up-grouping.test.ts +95 -0
  1096. package/src/components/schedule/schedule-next-up-grouping.ts +69 -0
  1097. package/src/components/schedule/schedule-next-up.test.tsx +189 -0
  1098. package/src/components/schedule/schedule-next-up.tsx +136 -0
  1099. package/src/components/schedule/schedule-overflow-chip.tsx +156 -0
  1100. package/src/components/schedule/schedule-overflow-popover.tsx +173 -0
  1101. package/src/components/schedule/schedule-segments.test.ts +201 -0
  1102. package/src/components/schedule/schedule-segments.ts +120 -0
  1103. package/src/components/schedule/schedule-snap.test.ts +546 -0
  1104. package/src/components/schedule/schedule-snap.ts +380 -0
  1105. package/src/components/schedule/schedule-timed-grid.tsx +1609 -0
  1106. package/src/components/schedule/schedule-toolbar.tsx +264 -0
  1107. package/src/components/schedule/schedule-type-cost.test.ts +104 -0
  1108. package/src/components/schedule/schedule-types.test.ts +64 -0
  1109. package/src/components/schedule/schedule-types.ts +1149 -0
  1110. package/src/components/schedule/schedule-views.test.ts +263 -0
  1111. package/src/components/schedule/schedule-views.ts +293 -0
  1112. package/src/components/schedule/schedule-week-view.tsx +25 -0
  1113. package/src/components/schedule/schedule-year-view.test.tsx +105 -0
  1114. package/src/components/schedule/schedule-year-view.tsx +305 -0
  1115. package/src/components/schedule/schedule.test.tsx +4268 -0
  1116. package/src/components/schedule/schedule.tsx +1038 -0
  1117. package/src/components/schedule/use-event-create.ts +590 -0
  1118. package/src/components/schedule/use-event-drag.ts +504 -0
  1119. package/src/components/schedule/use-event-resize.ts +563 -0
  1120. package/src/components/schedule/use-schedule-selection.ts +119 -0
  1121. package/src/components/schedule/use-schedule.test.ts +91 -0
  1122. package/src/components/schedule/use-schedule.ts +135 -0
  1123. package/src/components/segment-group/index.ts +15 -0
  1124. package/src/components/segment-group/segment-group.test.tsx +172 -0
  1125. package/src/components/segment-group/segment-group.tsx +570 -0
  1126. package/src/components/select/index.ts +12 -0
  1127. package/src/components/select/select.test.tsx +173 -0
  1128. package/src/components/select/select.tsx +405 -0
  1129. package/src/components/skeleton/index.ts +7 -0
  1130. package/src/components/skeleton/skeleton.test.tsx +96 -0
  1131. package/src/components/skeleton/skeleton.tsx +178 -0
  1132. package/src/components/slider/index.ts +3 -0
  1133. package/src/components/slider/slider.test.tsx +136 -0
  1134. package/src/components/slider/slider.tsx +390 -0
  1135. package/src/components/slider/sliderThumb.tsx +0 -0
  1136. package/src/components/spinner/index.ts +6 -0
  1137. package/src/components/spinner/spinner.tsx +136 -0
  1138. package/src/components/switch/index.ts +3 -0
  1139. package/src/components/switch/switch.test.tsx +98 -0
  1140. package/src/components/switch/switch.tsx +234 -0
  1141. package/src/components/table/index.ts +14 -0
  1142. package/src/components/table/table.test.tsx +262 -0
  1143. package/src/components/table/table.tsx +309 -0
  1144. package/src/components/tabs/index.ts +17 -0
  1145. package/src/components/tabs/tabs-data.tsx +125 -0
  1146. package/src/components/tabs/tabs.test.tsx +172 -0
  1147. package/src/components/tabs/tabs.tsx +292 -0
  1148. package/src/components/tags-input/index.ts +3 -0
  1149. package/src/components/tags-input/tags-input.test.tsx +85 -0
  1150. package/src/components/tags-input/tags-input.tsx +294 -0
  1151. package/src/components/text/index.ts +1 -0
  1152. package/src/components/text/text.test.tsx +73 -0
  1153. package/src/components/text/text.tsx +107 -0
  1154. package/src/components/text-input/index.ts +3 -0
  1155. package/src/components/text-input/text-input.test.tsx +129 -0
  1156. package/src/components/text-input/text-input.tsx +88 -0
  1157. package/src/components/textarea/index.ts +3 -0
  1158. package/src/components/textarea/textarea.test.tsx +88 -0
  1159. package/src/components/textarea/textarea.tsx +205 -0
  1160. package/src/components/theme-icon/index.ts +7 -0
  1161. package/src/components/theme-icon/theme-icon.test.tsx +20 -0
  1162. package/src/components/theme-icon/theme-icon.tsx +114 -0
  1163. package/src/components/theme-script/index.ts +1 -0
  1164. package/src/components/theme-script/theme-script.tsx +68 -0
  1165. package/src/components/time-input/hour-cycle.ts +61 -0
  1166. package/src/components/time-input/index.ts +4 -0
  1167. package/src/components/time-input/time-input.test.tsx +292 -0
  1168. package/src/components/time-input/time-input.tsx +196 -0
  1169. package/src/components/time-input/time-row.tsx +305 -0
  1170. package/src/components/timeline/index.ts +11 -0
  1171. package/src/components/timeline/timeline.test.tsx +701 -0
  1172. package/src/components/timeline/timeline.tsx +720 -0
  1173. package/src/components/title/index.ts +1 -0
  1174. package/src/components/title/title.test.tsx +68 -0
  1175. package/src/components/title/title.tsx +95 -0
  1176. package/src/components/tooltip/index.ts +9 -0
  1177. package/src/components/tooltip/tooltip.test.tsx +96 -0
  1178. package/src/components/tooltip/tooltip.tsx +255 -0
  1179. package/src/components/tree-multi-select/index.ts +11 -0
  1180. package/src/components/tree-multi-select/tree-multi-select.test.tsx +327 -0
  1181. package/src/components/tree-multi-select/tree-multi-select.tsx +626 -0
  1182. package/src/components/tree-select/index.ts +11 -0
  1183. package/src/components/tree-select/tree-select.test.tsx +376 -0
  1184. package/src/components/tree-select/tree-select.tsx +634 -0
  1185. package/src/index.ts +64 -0
  1186. package/src/lib/align.ts +6 -0
  1187. package/src/lib/available-if.test.ts +76 -0
  1188. package/src/lib/available-if.ts +114 -0
  1189. package/src/lib/brand.ts +19 -0
  1190. package/src/lib/cn.test.ts +13 -0
  1191. package/src/lib/cn.ts +28 -0
  1192. package/src/lib/colors.ts +31 -0
  1193. package/src/lib/control-open.ts +38 -0
  1194. package/src/lib/date-predicates.test.ts +149 -0
  1195. package/src/lib/date-predicates.ts +83 -0
  1196. package/src/lib/date-value.test.ts +107 -0
  1197. package/src/lib/date-value.ts +76 -0
  1198. package/src/lib/dev-warn.ts +18 -0
  1199. package/src/lib/focus-styles.test.ts +138 -0
  1200. package/src/lib/focus-styles.ts +145 -0
  1201. package/src/lib/form-control.ts +72 -0
  1202. package/src/lib/gradient.ts +81 -0
  1203. package/src/lib/intl-direction.test.tsx +96 -0
  1204. package/src/lib/intl.test.tsx +162 -0
  1205. package/src/lib/intl.tsx +210 -0
  1206. package/src/lib/link-component.test.tsx +46 -0
  1207. package/src/lib/link-component.tsx +32 -0
  1208. package/src/lib/merge-refs.ts +20 -0
  1209. package/src/lib/overlay-container.test.tsx +69 -0
  1210. package/src/lib/overlay-container.tsx +64 -0
  1211. package/src/lib/overlay-layer.test.tsx +139 -0
  1212. package/src/lib/overlay-layer.tsx +81 -0
  1213. package/src/lib/placement.ts +23 -0
  1214. package/src/lib/props.ts +48 -0
  1215. package/src/lib/required-if.ts +57 -0
  1216. package/src/lib/schedule-predicates.test.ts +230 -0
  1217. package/src/lib/schedule-predicates.ts +193 -0
  1218. package/src/lib/select-data.ts +227 -0
  1219. package/src/lib/sizes.ts +20 -0
  1220. package/src/lib/test-id.ts +27 -0
  1221. package/src/lib/theme-init-runtime.test.ts +152 -0
  1222. package/src/lib/theme-init-runtime.ts +79 -0
  1223. package/src/lib/theme.test.ts +223 -0
  1224. package/src/lib/theme.ts +153 -0
  1225. package/src/lib/tree-data.ts +159 -0
  1226. package/src/lib/typography-size.ts +59 -0
  1227. package/src/lib/use-container-query.test.ts +83 -0
  1228. package/src/lib/use-container-query.ts +44 -0
  1229. package/src/lib/use-disclosure.test.ts +85 -0
  1230. package/src/lib/use-disclosure.ts +77 -0
  1231. package/src/lib/use-isomorphic-layout-effect.ts +12 -0
  1232. package/src/lib/use-local-storage.test.ts +165 -0
  1233. package/src/lib/use-local-storage.ts +178 -0
  1234. package/src/lib/use-logger.ts +39 -0
  1235. package/src/lib/use-media-query.test.ts +77 -0
  1236. package/src/lib/use-media-query.ts +35 -0
  1237. package/src/lib/use-now.ts +59 -0
  1238. package/src/lib/use-theme.test.ts +305 -0
  1239. package/src/lib/use-theme.ts +279 -0
  1240. package/src/lib/use-uncontrolled.test.ts +207 -0
  1241. package/src/lib/use-uncontrolled.ts +85 -0
  1242. package/src/styles.css +17 -0
  1243. package/src/test-setup.ts +130 -0
  1244. package/src/theme-init-script.ts +10 -0
  1245. package/src/theme.css +1275 -0
  1246. package/src/theme.forced-colors.test.tsx +215 -0
  1247. package/src/theme.test.ts +221 -0
  1248. package/src/visually-hidden-containment.test.tsx +98 -0
@@ -0,0 +1,4268 @@
1
+ import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react"
2
+ import { useState } from "react"
3
+ import { describe, expect, it, vi } from "vitest"
4
+ import { IntlProvider } from "../../lib/intl"
5
+ import { disableOutsideHours } from "../../lib/schedule-predicates"
6
+ import { Schedule } from "./index"
7
+ import { ScheduleRoot } from "./schedule"
8
+ import { timeRangeLabel } from "./schedule-dates"
9
+ import { DayView } from "./schedule-day-view"
10
+ import { isScheduleSlotProps } from "./schedule-snap"
11
+ import type {
12
+ ScheduleEvent,
13
+ ScheduleEventCreateHandler,
14
+ ScheduleStaticEvent,
15
+ ScheduleTimedProps,
16
+ SlotMultiple,
17
+ } from "./schedule-types"
18
+ import type { ScheduleViewOption } from "./schedule-views"
19
+ import { WeekView } from "./schedule-week-view"
20
+
21
+ /**
22
+ * Component-level coverage for `Schedule`'s root — the pure-logic modules
23
+ * (`schedule-dates`, `-geometry`, `-layout`, `-snap`, `-types`) already have
24
+ * their own `.test.ts`; this is the rendering/interaction layer those don't
25
+ * touch. Real pointer-based drag/resize/click-drag-to-create gestures aren't
26
+ * covered here — jsdom doesn't meaningfully implement `setPointerCapture` or
27
+ * `getBoundingClientRect`, so those need a real browser (Playwright) to test
28
+ * honestly. The keyboard-driven move path below doesn't need either.
29
+ */
30
+
31
+ const day = (y: number, m: number, d: number, h = 0, min = 0) => new Date(Date.UTC(y, m, d, h, min))
32
+ const NOW = day(2026, 0, 15, 12) // a fixed Thursday, at noon UTC
33
+
34
+ const EVENTS: ScheduleEvent[] = [
35
+ {
36
+ kind: "event",
37
+ id: "e1",
38
+ title: "Standup",
39
+ start: day(2026, 0, 15, 9),
40
+ end: day(2026, 0, 15, 9, 30),
41
+ },
42
+ ]
43
+ const STATIC_EVENTS: ScheduleStaticEvent[] = [
44
+ {
45
+ kind: "static",
46
+ id: "s1",
47
+ title: "Class",
48
+ start: day(2026, 0, 15, 11),
49
+ end: day(2026, 0, 15, 12),
50
+ },
51
+ ]
52
+
53
+ describe("ScheduleRoot — rendering", () => {
54
+ it("renders the toolbar and defaults to the days (timed-grid) view", () => {
55
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" />)
56
+ expect(document.querySelector('[data-schedule-part="timed-grid"]')).not.toBeNull()
57
+ expect(document.querySelector('[data-schedule-part="month-view"]')).toBeNull()
58
+ })
59
+
60
+ it("shows the empty message when data and staticEvents are both empty", () => {
61
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" />)
62
+ expect(screen.getByText("No events")).toBeTruthy()
63
+ })
64
+
65
+ it("renders data and staticEvents as chips, each keyed by its own testId default (id)", () => {
66
+ render(<ScheduleRoot data={EVENTS} staticEvents={STATIC_EVENTS} now={NOW} timeZone="UTC" />)
67
+ expect(screen.getByTestId("e1")).toBeTruthy()
68
+ expect(screen.getByTestId("s1")).toBeTruthy()
69
+ })
70
+ })
71
+
72
+ describe("ScheduleRoot — text direction", () => {
73
+ // #243: direction comes from the locale. Under an RTL locale, every part that stamps a `dir` —
74
+ // both chip kinds and the view switcher's Ark parts — must agree with the RTL page around it.
75
+ it("renders every dir-stamped part rtl under an rtl locale", () => {
76
+ const { container } = render(
77
+ <div dir="rtl">
78
+ <IntlProvider locale="ar">
79
+ <ScheduleRoot data={EVENTS} staticEvents={STATIC_EVENTS} now={NOW} timeZone="UTC" />
80
+ </IntlProvider>
81
+ </div>,
82
+ )
83
+ const chips = container.querySelectorAll('[data-schedule-part="event-chip"]')
84
+ const stamped = [...container.querySelectorAll("[dir]")].map((el) => el.getAttribute("dir"))
85
+
86
+ expect(chips).toHaveLength(2)
87
+ expect([...chips].map((chip) => chip.getAttribute("dir"))).toEqual(["rtl", "rtl"])
88
+ expect(stamped.filter((dir) => dir !== "rtl")).toEqual([])
89
+ })
90
+ })
91
+
92
+ describe("ScheduleRoot — view switching", () => {
93
+ it("switches to Month view on its tab and back to Week", async () => {
94
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" />)
95
+ // Ark binds the trigger handlers after the machine reaches ready (a
96
+ // macrotask); flush it before driving the click (same gotcha as Tabs'
97
+ // own test suite hits).
98
+ await new Promise((resolve) => setTimeout(resolve, 0))
99
+
100
+ fireEvent.click(screen.getByRole("tab", { name: "Month" }))
101
+ await waitFor(() =>
102
+ expect(document.querySelector('[data-schedule-part="month-view"]')).not.toBeNull(),
103
+ )
104
+ expect(document.querySelector('[data-schedule-part="timed-grid"]')).toBeNull()
105
+
106
+ fireEvent.click(screen.getByRole("tab", { name: "Week" }))
107
+ await waitFor(() =>
108
+ expect(document.querySelector('[data-schedule-part="timed-grid"]')).not.toBeNull(),
109
+ )
110
+ })
111
+ })
112
+
113
+ /**
114
+ * RFC §9/§10's drill-down. `Schedule` is the only place where both the anchor
115
+ * date and the view are in scope (no context, by RFC §3), so this is where a
116
+ * day or month click turns into navigation — the Google/Apple Calendar
117
+ * default, and previously left entirely to the consumer.
118
+ *
119
+ * Titles are compared against a *second* `ScheduleRoot` rendered directly at
120
+ * the expected view + date rather than against a hard-coded string, so these
121
+ * assert "it landed where the toolbar itself would put it" without also
122
+ * pinning `formatScheduleTitle`'s locale formatting.
123
+ */
124
+ describe("ScheduleRoot — drill-down", () => {
125
+ const title = (root: ParentNode = document) =>
126
+ root.querySelector('[data-schedule-part="toolbar-title"]')?.textContent
127
+
128
+ /** What the toolbar reads when `Schedule` is put there directly. */
129
+ const titleAt = (view: "days" | "month", date: Date, visibleDays?: number) => {
130
+ const { container, unmount } = render(
131
+ <ScheduleRoot
132
+ data={[]}
133
+ defaultView={view}
134
+ defaultDate={date}
135
+ now={NOW}
136
+ timeZone="UTC"
137
+ visibleDays={visibleDays}
138
+ />,
139
+ )
140
+ const text = title(container)
141
+ unmount()
142
+ return text
143
+ }
144
+
145
+ it("lands on the clicked day in Days view, from Month", () => {
146
+ const target = day(2026, 0, 22)
147
+ const expected = titleAt("days", target)
148
+
149
+ const { container } = render(
150
+ <ScheduleRoot data={[]} defaultView="month" now={NOW} timeZone="UTC" />,
151
+ )
152
+ fireEvent.click(container.querySelector('[data-testid="day-2026-01-22"]') as HTMLElement)
153
+
154
+ expect(container.querySelector('[data-schedule-part="days-view"]')).not.toBeNull()
155
+ expect(container.querySelector('[data-schedule-part="month-view"]')).toBeNull()
156
+ expect(title(container)).toBe(expected)
157
+ })
158
+
159
+ it("lands on the clicked month in Month view, from Year", () => {
160
+ const expected = titleAt("month", day(2026, 2, 1))
161
+
162
+ const { container } = render(
163
+ <ScheduleRoot data={[]} defaultView="year" now={NOW} timeZone="UTC" />,
164
+ )
165
+ fireEvent.click(container.querySelector('[data-testid="month-2026-03"]') as HTMLElement)
166
+
167
+ expect(container.querySelector('[data-schedule-part="month-view"]')).not.toBeNull()
168
+ expect(title(container)).toBe(expected)
169
+ })
170
+
171
+ it("lands on the clicked day in Days view, from Year", () => {
172
+ const expected = titleAt("days", day(2026, 6, 4))
173
+
174
+ const { container } = render(
175
+ <ScheduleRoot data={[]} defaultView="year" now={NOW} timeZone="UTC" />,
176
+ )
177
+ fireEvent.click(container.querySelector('[data-testid="day-2026-07-04"]') as HTMLElement)
178
+
179
+ expect(container.querySelector('[data-schedule-part="days-view"]')).not.toBeNull()
180
+ expect(title(container)).toBe(expected)
181
+ })
182
+
183
+ // Drilling in moves the anchor; it does not resize the window. A 3-day
184
+ // Schedule stays a 3-day Schedule with the clicked day inside it.
185
+ //
186
+ // Asserted against a literal title and the rendered columns, deliberately
187
+ // NOT against `titleAt(...)`: comparing one `formatScheduleTitle` result to
188
+ // another is a tautology that moves with whatever the window rule happens to
189
+ // be, and it hid a real bug — before the sub-week window slide this rendered
190
+ // "Jan 18 - 20, 2026", a window that does not contain the 22nd at all.
191
+ it("keeps the consumer's visibleDays window, with the clicked day inside it", () => {
192
+ const { container } = render(
193
+ <ScheduleRoot data={[]} defaultView="month" now={NOW} timeZone="UTC" visibleDays={3} />,
194
+ )
195
+ fireEvent.click(container.querySelector('[data-testid="day-2026-01-22"]') as HTMLElement)
196
+
197
+ // Thu 22 Jan 2026 is index 4 of its Sunday-started week, so a 3-day window
198
+ // is tile 1: Wed 21 .. Fri 23.
199
+ expect(title(container)).toBe("Jan 21 – 23, 2026")
200
+ const columns = [
201
+ ...container.querySelectorAll('[data-schedule-part="day-column"][data-day-key]'),
202
+ ].map((el) => el.getAttribute("data-day-key"))
203
+ expect(columns).toEqual(["2026-01-21", "2026-01-22", "2026-01-23"])
204
+ })
205
+
206
+ // Presence-gated like every other Schedule callback — a consumer's own
207
+ // handler replaces the drill-down rather than firing alongside it.
208
+ it("defers to a consumer onDayClick / onMonthClick instead of navigating", () => {
209
+ const onDayClick = vi.fn()
210
+ const onMonthClick = vi.fn()
211
+
212
+ const month = render(
213
+ <ScheduleRoot
214
+ data={[]}
215
+ defaultView="month"
216
+ now={NOW}
217
+ timeZone="UTC"
218
+ onDayClick={onDayClick}
219
+ />,
220
+ )
221
+ fireEvent.click(month.container.querySelector('[data-testid="day-2026-01-22"]') as HTMLElement)
222
+ expect(onDayClick).toHaveBeenCalledTimes(1)
223
+ expect(month.container.querySelector('[data-schedule-part="month-view"]')).not.toBeNull()
224
+ month.unmount()
225
+
226
+ const year = render(
227
+ <ScheduleRoot
228
+ data={[]}
229
+ defaultView="year"
230
+ now={NOW}
231
+ timeZone="UTC"
232
+ onMonthClick={onMonthClick}
233
+ />,
234
+ )
235
+ fireEvent.click(year.container.querySelector('[data-testid="month-2026-03"]') as HTMLElement)
236
+ expect(onMonthClick).toHaveBeenCalledTimes(1)
237
+ expect(year.container.querySelector('[data-schedule-part="year-view"]')).not.toBeNull()
238
+ })
239
+
240
+ // Controlled roots get the same navigation through their own callbacks.
241
+ it("reports both halves of the move through onDateChange/onViewChange", () => {
242
+ const onDateChange = vi.fn()
243
+ const onViewChange = vi.fn()
244
+
245
+ const { container } = render(
246
+ <ScheduleRoot
247
+ data={[]}
248
+ view="month"
249
+ date={day(2026, 0, 15)}
250
+ onViewChange={onViewChange}
251
+ onDateChange={onDateChange}
252
+ now={NOW}
253
+ timeZone="UTC"
254
+ />,
255
+ )
256
+ fireEvent.click(container.querySelector('[data-testid="day-2026-01-22"]') as HTMLElement)
257
+
258
+ expect(onViewChange).toHaveBeenCalledWith("days")
259
+ expect(onDateChange).toHaveBeenCalledWith(day(2026, 0, 22))
260
+ // Fully controlled: nothing moves until the consumer feeds it back.
261
+ expect(container.querySelector('[data-schedule-part="month-view"]')).not.toBeNull()
262
+ })
263
+ })
264
+
265
+ describe("ScheduleRoot — pagination", () => {
266
+ const title = () => document.querySelector('[data-schedule-part="toolbar-title"]')?.textContent
267
+
268
+ it("Next/Prev are inverses and Now resets to the anchor `now`", () => {
269
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" />)
270
+ const initial = title()
271
+
272
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
273
+ const afterNext = title()
274
+ expect(afterNext).not.toBe(initial)
275
+
276
+ fireEvent.click(screen.getByRole("button", { name: "Previous" }))
277
+ expect(title()).toBe(initial)
278
+
279
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
280
+ fireEvent.click(screen.getByRole("button", { name: "Now" }))
281
+ expect(title()).toBe(initial)
282
+ })
283
+ })
284
+
285
+ /**
286
+ * Reveal-on-navigate: the day half of the reveal rule.
287
+ *
288
+ * What is and is not observable here matters. jsdom does no layout, so
289
+ * `test-setup.ts` hands every element the same constant rect — which makes the
290
+ * hour gutter always "cover" a day column, so a day reveal that gets as far as
291
+ * the geometry always scrolls. That makes *whether the reveal was armed at all*
292
+ * the real assertion, which is exactly what separates a drill-down from a page
293
+ * turn. Whether a genuinely visible column is correctly left alone is a
294
+ * question only a browser can answer, and is verified there instead; the
295
+ * geometry itself is unit-tested in `schedule-geometry.test.ts`.
296
+ */
297
+ describe("ScheduleRoot — reveal on navigate", () => {
298
+ const mockScroll = () => {
299
+ Object.defineProperty(window, "matchMedia", {
300
+ writable: true,
301
+ value: vi.fn().mockReturnValue({ matches: false }),
302
+ })
303
+ const scrollTo = vi.fn()
304
+ HTMLElement.prototype.scrollTo = scrollTo
305
+ return scrollTo
306
+ }
307
+
308
+ it("scrolls the drilled-into day's column into view", () => {
309
+ const scrollTo = mockScroll()
310
+ const { container } = render(
311
+ <ScheduleRoot data={[]} defaultView="month" now={NOW} timeZone="UTC" />,
312
+ )
313
+ fireEvent.click(container.querySelector('[data-testid="day-2026-01-22"]') as HTMLElement)
314
+
315
+ // Inline axis only — the time of day the reader was on must survive.
316
+ expect(scrollTo).toHaveBeenCalledTimes(1)
317
+ expect(scrollTo).toHaveBeenCalledWith(expect.objectContaining({ top: 0 }))
318
+ })
319
+
320
+ it("reveals the day even when the anchor was already on it", () => {
321
+ // The case that shipped broken. A Schedule anchors on today by default, so
322
+ // drilling into today moves no date at all — and arming on the date alone
323
+ // meant the likeliest first click in any month view did nothing while the
324
+ // column sat off screen. Arriving in the days view is the event here, not
325
+ // the date.
326
+ const scrollTo = mockScroll()
327
+ const { container } = render(
328
+ <ScheduleRoot data={[]} defaultView="month" now={NOW} timeZone="UTC" />,
329
+ )
330
+ // NOW is 15 Jan 2026, which is also the anchor.
331
+ fireEvent.click(container.querySelector('[data-testid="day-2026-01-15"]') as HTMLElement)
332
+
333
+ expect(scrollTo).toHaveBeenCalledTimes(1)
334
+ })
335
+
336
+ it("reveals the anchor on any arrival in the days view, not just a drill-down", () => {
337
+ // Same reasoning: the grid mounts at `scrollLeft: 0` however you got here,
338
+ // so switching views is as much an arrival as a drill-down is. Driven
339
+ // through the controlled `view` prop rather than the switcher — Ark's tabs
340
+ // don't respond to a bare `fireEvent.click` under jsdom.
341
+ const scrollTo = mockScroll()
342
+ const props = { data: [], now: NOW, timeZone: "UTC" }
343
+ const { rerender } = render(<ScheduleRoot {...props} view="month" />)
344
+ expect(scrollTo).not.toHaveBeenCalled()
345
+
346
+ rerender(<ScheduleRoot {...props} view="days" />)
347
+
348
+ expect(scrollTo).toHaveBeenCalledTimes(1)
349
+ })
350
+
351
+ it("does not animate a reveal by default", () => {
352
+ const scrollTo = mockScroll() // matchMedia says motion is fine
353
+ const { container } = render(
354
+ <ScheduleRoot data={[]} defaultView="month" now={NOW} timeZone="UTC" />,
355
+ )
356
+ fireEvent.click(container.querySelector('[data-testid="day-2026-01-22"]') as HTMLElement)
357
+
358
+ // A reveal is a side effect of navigating, not a gesture — animating it
359
+ // reads as the grid drifting.
360
+ expect(scrollTo).toHaveBeenCalledWith(expect.objectContaining({ behavior: "auto" }))
361
+ })
362
+
363
+ it("animates a reveal when revealBehavior asks for it", () => {
364
+ const scrollTo = mockScroll()
365
+ const { container } = render(
366
+ <ScheduleRoot
367
+ data={[]}
368
+ defaultView="month"
369
+ now={NOW}
370
+ timeZone="UTC"
371
+ revealBehavior="smooth"
372
+ />,
373
+ )
374
+ fireEvent.click(container.querySelector('[data-testid="day-2026-01-22"]') as HTMLElement)
375
+
376
+ expect(scrollTo).toHaveBeenCalledWith(expect.objectContaining({ behavior: "smooth" }))
377
+ })
378
+
379
+ it("lets prefers-reduced-motion win over an explicit revealBehavior", () => {
380
+ Object.defineProperty(window, "matchMedia", {
381
+ writable: true,
382
+ value: vi.fn().mockReturnValue({ matches: true }),
383
+ })
384
+ const scrollTo = vi.fn()
385
+ HTMLElement.prototype.scrollTo = scrollTo
386
+ const { container } = render(
387
+ <ScheduleRoot
388
+ data={[]}
389
+ defaultView="month"
390
+ now={NOW}
391
+ timeZone="UTC"
392
+ revealBehavior="smooth"
393
+ />,
394
+ )
395
+ fireEvent.click(container.querySelector('[data-testid="day-2026-01-22"]') as HTMLElement)
396
+
397
+ // The prop can ask for motion; it cannot override someone asking for none.
398
+ expect(scrollTo).toHaveBeenCalledWith(expect.objectContaining({ behavior: "auto" }))
399
+ })
400
+
401
+ it("does not scroll on a page turn", () => {
402
+ // Under reduced motion the grid renders no outgoing band, so the reveal's
403
+ // own `[data-page-exiting]` guard is out of the picture and the navigation
404
+ // flag is the only thing left that can suppress this. Without that
405
+ // isolation the test would pass for the wrong reason.
406
+ Object.defineProperty(window, "matchMedia", {
407
+ writable: true,
408
+ value: vi.fn().mockReturnValue({ matches: true }),
409
+ })
410
+ const scrollTo = vi.fn()
411
+ HTMLElement.prototype.scrollTo = scrollTo
412
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" view="days" />)
413
+
414
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
415
+ fireEvent.click(screen.getByRole("button", { name: "Previous" }))
416
+
417
+ // Paging away and being dragged back is the exact yank the reveal rule
418
+ // exists to avoid.
419
+ expect(scrollTo).not.toHaveBeenCalled()
420
+ })
421
+
422
+ it("lets the Now button do its own scrolling, exactly once", () => {
423
+ const scrollTo = mockScroll()
424
+ // Anchored a day off today, so the Now click is a real date change — the
425
+ // shape that would arm a day reveal if the button were not marked as
426
+ // navigation. The now-marker is rendered (today is in this window), so
427
+ // Now's own both-axis scroll onto it runs.
428
+ render(
429
+ <ScheduleRoot
430
+ data={[]}
431
+ now={NOW}
432
+ timeZone="UTC"
433
+ view="days"
434
+ defaultDate={day(2026, 0, 13)}
435
+ />,
436
+ )
437
+ scrollTo.mockClear()
438
+
439
+ fireEvent.click(screen.getByRole("button", { name: "Now" }))
440
+
441
+ // Exactly one: a second, competing inline scroll on the next commit would
442
+ // abort this one partway through its smooth animation.
443
+ expect(scrollTo).toHaveBeenCalledTimes(1)
444
+ })
445
+
446
+ it("does not scroll when a controlled `date` is re-created on every render", () => {
447
+ const scrollTo = mockScroll()
448
+ const Harness = () => {
449
+ const [, force] = useState(0)
450
+ return (
451
+ <>
452
+ <button type="button" onClick={() => force((n) => n + 1)}>
453
+ rerender
454
+ </button>
455
+ {/* A fresh `Date` object every render, same calendar day — the shape
456
+ a consumer writing `date={new Date(iso)}` produces. */}
457
+ <ScheduleRoot
458
+ data={[]}
459
+ now={NOW}
460
+ timeZone="UTC"
461
+ view="days"
462
+ date={new Date(NOW.getTime())}
463
+ />
464
+ </>
465
+ )
466
+ }
467
+ render(<Harness />)
468
+ fireEvent.click(screen.getByRole("button", { name: "rerender" }))
469
+ fireEvent.click(screen.getByRole("button", { name: "rerender" }))
470
+
471
+ expect(scrollTo).not.toHaveBeenCalled()
472
+ })
473
+
474
+ it("lets a selection in the same commit win over the day underneath it", () => {
475
+ // `goTo("day")(event)` moves `selected`, `date` and `view` at once. The
476
+ // event is the more specific target, so its own date axis must still run —
477
+ // if the day reveal had clobbered it, the anchor would never move.
478
+ const onDateChange = vi.fn()
479
+ const far: ScheduleEvent[] = [
480
+ {
481
+ kind: "event",
482
+ id: "far",
483
+ title: "Far away",
484
+ start: day(2026, 2, 3, 9),
485
+ end: day(2026, 2, 3, 10),
486
+ },
487
+ ]
488
+ const { rerender } = render(
489
+ <ScheduleRoot data={far} now={NOW} timeZone="UTC" view="days" onDateChange={onDateChange} />,
490
+ )
491
+ rerender(
492
+ <ScheduleRoot
493
+ data={far}
494
+ now={NOW}
495
+ timeZone="UTC"
496
+ view="days"
497
+ date={day(2026, 0, 20)}
498
+ selected="far"
499
+ onDateChange={onDateChange}
500
+ />,
501
+ )
502
+
503
+ expect(onDateChange).toHaveBeenCalledWith(far[0]?.start)
504
+ })
505
+ })
506
+
507
+ describe("ScheduleRoot — scroll-to-now", () => {
508
+ // jsdom implements neither `Element#scrollTo` nor `window.matchMedia` (same
509
+ // limitation this file's own top-of-file comment notes for
510
+ // `setPointerCapture`/`getBoundingClientRect`) — both stubbed locally here,
511
+ // matching `lib/use-media-query.test.ts`'s own `matchMedia` mock shape.
512
+ it("scrolls the Days view's timed grid when the Now button is clicked", () => {
513
+ Object.defineProperty(window, "matchMedia", {
514
+ writable: true,
515
+ value: vi.fn().mockReturnValue({ matches: false }),
516
+ })
517
+ const scrollTo = vi.fn()
518
+ HTMLElement.prototype.scrollTo = scrollTo
519
+
520
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" view="days" />)
521
+ fireEvent.click(screen.getByRole("button", { name: "Now" }))
522
+
523
+ expect(scrollTo).toHaveBeenCalledWith(
524
+ expect.objectContaining({ top: expect.any(Number), behavior: "smooth" }),
525
+ )
526
+ })
527
+
528
+ it("respects prefers-reduced-motion — an instant jump, not a smooth scroll", () => {
529
+ Object.defineProperty(window, "matchMedia", {
530
+ writable: true,
531
+ value: vi.fn().mockReturnValue({ matches: true }),
532
+ })
533
+ const scrollTo = vi.fn()
534
+ HTMLElement.prototype.scrollTo = scrollTo
535
+
536
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" view="days" />)
537
+ fireEvent.click(screen.getByRole("button", { name: "Now" }))
538
+
539
+ expect(scrollTo).toHaveBeenCalledWith(expect.objectContaining({ behavior: "auto" }))
540
+ })
541
+
542
+ it("does not scroll when the active view has no timed grid (Month)", () => {
543
+ Object.defineProperty(window, "matchMedia", {
544
+ writable: true,
545
+ value: vi.fn().mockReturnValue({ matches: false }),
546
+ })
547
+ const scrollTo = vi.fn()
548
+ HTMLElement.prototype.scrollTo = scrollTo
549
+
550
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" view="month" />)
551
+ fireEvent.click(screen.getByRole("button", { name: "Now" }))
552
+
553
+ expect(scrollTo).not.toHaveBeenCalled()
554
+ })
555
+ })
556
+
557
+ describe("ScheduleRoot — the now-cursor is scoped to the painted window", () => {
558
+ // Host-local by construction, unlike this file's UTC-based `day()` helper,
559
+ // and with no `timeZone` prop: the now-cursor's position and its window
560
+ // gate both read the host's own clock by design (RFC §14, and
561
+ // `clockTimeLabel`'s note in `schedule-dates.ts`), so a UTC-built instant
562
+ // would mean a different wall-clock hour on a UTC CI box than on a Paris
563
+ // laptop and this whole block would pass or fail by timezone.
564
+ const localAt = (h: number, m = 0) => new Date(2026, 0, 15, h, m)
565
+ const LINE = '[data-schedule-part="now-indicator"]'
566
+ const LABEL = '[data-schedule-part="now-indicator-label"]'
567
+
568
+ it("draws the marker, the cross-day guide and the clock label inside [startHour, endHour)", () => {
569
+ render(<ScheduleRoot data={[]} now={localAt(9, 30)} view="days" startHour={7} endHour={13} />)
570
+ expect(document.querySelectorAll(`${LINE}[data-variant="marker"]`).length).toBe(1)
571
+ expect(document.querySelectorAll(`${LINE}[data-variant="guide"]`).length).toBe(1)
572
+ expect(document.querySelector(LABEL)).not.toBeNull()
573
+ })
574
+
575
+ it("draws none of the three when now is past endHour", () => {
576
+ render(<ScheduleRoot data={[]} now={localAt(18, 50)} view="days" startHour={7} endHour={13} />)
577
+ expect(document.querySelector(LINE)).toBeNull()
578
+ expect(document.querySelector(LABEL)).toBeNull()
579
+ })
580
+
581
+ it("draws none of the three when now is before startHour", () => {
582
+ render(<ScheduleRoot data={[]} now={localAt(5, 20)} view="days" startHour={7} endHour={13} />)
583
+ expect(document.querySelector(LINE)).toBeNull()
584
+ expect(document.querySelector(LABEL)).toBeNull()
585
+ })
586
+
587
+ it("leaves the Now button working — it still navigates, it just has nothing to scroll to", () => {
588
+ // Both Now handlers (`Schedule.Root` here, `DaysView` for the standalone
589
+ // view) already guard on their own `nowRef.current`, so a cursor that
590
+ // doesn't render degrades to "navigate without re-centering" rather than
591
+ // throwing on a null node — pinned here so that guard can't be dropped.
592
+ Object.defineProperty(window, "matchMedia", {
593
+ writable: true,
594
+ value: vi.fn().mockReturnValue({ matches: false }),
595
+ })
596
+ const scrollTo = vi.fn()
597
+ HTMLElement.prototype.scrollTo = scrollTo
598
+ const onDateChange = vi.fn()
599
+
600
+ render(
601
+ <ScheduleRoot
602
+ data={[]}
603
+ now={localAt(18, 50)}
604
+ view="days"
605
+ startHour={7}
606
+ endHour={13}
607
+ onDateChange={onDateChange}
608
+ />,
609
+ )
610
+ expect(() => fireEvent.click(screen.getByRole("button", { name: "Now" }))).not.toThrow()
611
+
612
+ expect(onDateChange).toHaveBeenCalledTimes(1)
613
+ expect(scrollTo).not.toHaveBeenCalled()
614
+ expect(document.querySelector(LINE)).toBeNull()
615
+ })
616
+ })
617
+
618
+ describe("ScheduleRoot — event interaction", () => {
619
+ // The static chip is a plain `<button onClick>` (no drag hook, no pointer
620
+ // capture) — jsdom doesn't implement `setPointerCapture`, which the
621
+ // interactive chip's click-detection goes through, so this is the
622
+ // jsdom-safe way to exercise `onSelect` without faking a full gesture.
623
+ it("fires onSelect when a static chip is clicked", () => {
624
+ const onSelect = vi.fn()
625
+ render(
626
+ <ScheduleRoot
627
+ data={[]}
628
+ staticEvents={STATIC_EVENTS}
629
+ now={NOW}
630
+ timeZone="UTC"
631
+ onSelect={onSelect}
632
+ />,
633
+ )
634
+ fireEvent.click(screen.getByTestId("s1"))
635
+ expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({ id: "s1" }))
636
+ })
637
+
638
+ it("fires onDayClick when a day header is clicked", () => {
639
+ const onDayClick = vi.fn()
640
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" onDayClick={onDayClick} />)
641
+ const headers = document.querySelectorAll('[data-schedule-part="timed-grid"] button')
642
+ expect(headers.length).toBeGreaterThan(0)
643
+ fireEvent.click(headers[0] as HTMLElement)
644
+ expect(onDayClick).toHaveBeenCalledTimes(1)
645
+ })
646
+
647
+ it("fires onEventRemove on the click itself, not after the exit", () => {
648
+ // Deliberately synchronous. This used to be deferred until Ark Presence
649
+ // reported the exit animation finished, which meant the consumer learned
650
+ // about a removal ~140ms late and only ever for the built-in button. The
651
+ // exit is now driven by the event leaving `data`, so the callback is free
652
+ // to fire immediately.
653
+ const onEventRemove = vi.fn()
654
+ render(
655
+ <ScheduleRoot
656
+ data={EVENTS}
657
+ now={NOW}
658
+ timeZone="UTC"
659
+ editable={["remove"]}
660
+ onEventRemove={onEventRemove}
661
+ />,
662
+ )
663
+ fireEvent.click(screen.getByRole("button", { name: "Remove event" }))
664
+ expect(onEventRemove).toHaveBeenCalledWith(expect.objectContaining({ id: "e1" }))
665
+ })
666
+
667
+ /** The flip side of driving the exit from `data`: a consumer that ignores
668
+ * `onEventRemove` keeps its event, rather than being left with an invisible
669
+ * chip the way the old deferred path did. */
670
+ it("keeps the event when the consumer does not remove it", () => {
671
+ render(
672
+ <ScheduleRoot
673
+ data={EVENTS}
674
+ now={NOW}
675
+ timeZone="UTC"
676
+ editable={["remove"]}
677
+ onEventRemove={() => {}}
678
+ />,
679
+ )
680
+ fireEvent.click(screen.getByRole("button", { name: "Remove event" }))
681
+ const chip = screen.getByTestId("e1")
682
+ expect(chip.getAttribute("data-state")).not.toBe("closed")
683
+ })
684
+
685
+ /**
686
+ * Regression: `present` used to be local `useState` on each chip, and a
687
+ * multi-day event renders one chip *per day column* — so clicking one `x`
688
+ * animated that piece while its siblings vanished the moment the consumer's
689
+ * `data` update landed. The state lives on the grid now, keyed by event id.
690
+ *
691
+ * The second assertion is the other half of that move: every piece reports a
692
+ * completed exit, so without a guard the removal would commit once per piece.
693
+ */
694
+ it("exits every piece of a multi-day event together", async () => {
695
+ const spanning: ScheduleEvent[] = [
696
+ {
697
+ kind: "event",
698
+ id: "span",
699
+ title: "Conference",
700
+ start: day(2026, 0, 15, 22),
701
+ end: day(2026, 0, 16, 2),
702
+ },
703
+ ]
704
+ const onEventRemove = vi.fn()
705
+ // A real consumer: the exit is driven by the event leaving `data`, so the
706
+ // removal has to actually happen for anything to animate.
707
+ const Host = () => {
708
+ const [data, setData] = useState(spanning)
709
+ return (
710
+ <ScheduleRoot
711
+ data={data}
712
+ now={NOW}
713
+ timeZone="UTC"
714
+ editable={["remove"]}
715
+ onEventRemove={(event) => {
716
+ onEventRemove(event)
717
+ setData((current) => current.filter((e) => e.id !== event.id))
718
+ }}
719
+ />
720
+ )
721
+ }
722
+ render(<Host />)
723
+ const pieces = () => [
724
+ ...document.querySelectorAll('[data-schedule-part="event-chip"][data-event-id="span"]'),
725
+ ]
726
+ expect(pieces()).toHaveLength(2)
727
+
728
+ fireEvent.click(screen.getAllByRole("button", { name: "Remove event" })[0] as HTMLElement)
729
+ expect(onEventRemove).toHaveBeenCalledTimes(1)
730
+
731
+ // Both pieces are kept mounted as outgoing copies and exit together — the
732
+ // regression this guards is one piece animating while its siblings vanish.
733
+ await waitFor(() => {
734
+ const p = pieces()
735
+ expect(p).toHaveLength(2)
736
+ expect(p.every((el) => el.getAttribute("data-state") === "closed")).toBe(true)
737
+ })
738
+ })
739
+ })
740
+
741
+ describe("ScheduleRoot — all-day row", () => {
742
+ const midnightUtc = (y: number, m: number, d: number) => new Date(Date.UTC(y, m, d))
743
+
744
+ it("renders no all-day row when there's no all-day event", () => {
745
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" />)
746
+ expect(document.querySelector('[data-schedule-part="all-day-row"]')).toBeNull()
747
+ })
748
+
749
+ it("renders a single-day all-day event as a one-column bar", () => {
750
+ const conference: ScheduleEvent = {
751
+ kind: "event",
752
+ id: "ad1",
753
+ title: "Conference",
754
+ allDay: true,
755
+ start: midnightUtc(2026, 0, 15),
756
+ end: midnightUtc(2026, 0, 16),
757
+ }
758
+ render(<ScheduleRoot data={[conference]} now={NOW} timeZone="UTC" />)
759
+ const bar = screen.getByTestId("ad1") as HTMLElement
760
+ const [start, end] = bar.style.gridColumn.split("/").map((s) => Number.parseInt(s.trim(), 10))
761
+ expect((end as number) - (start as number)).toBe(1)
762
+ })
763
+
764
+ it("spans a multi-day all-day event across every day column it covers", () => {
765
+ const conference: ScheduleEvent = {
766
+ kind: "event",
767
+ id: "ad1",
768
+ title: "Conference",
769
+ allDay: true,
770
+ start: midnightUtc(2026, 0, 15),
771
+ end: midnightUtc(2026, 0, 17), // two days: Jan 15 – 16
772
+ }
773
+ render(<ScheduleRoot data={[conference]} now={NOW} timeZone="UTC" />)
774
+ const bar = screen.getByTestId("ad1") as HTMLElement
775
+ const [start, end] = bar.style.gridColumn.split("/").map((s) => Number.parseInt(s.trim(), 10))
776
+ expect((end as number) - (start as number)).toBe(2)
777
+ })
778
+
779
+ it("fires onSelect when an all-day bar is clicked", () => {
780
+ const onSelect = vi.fn()
781
+ const conference: ScheduleEvent = {
782
+ kind: "event",
783
+ id: "ad1",
784
+ title: "Conference",
785
+ allDay: true,
786
+ start: midnightUtc(2026, 0, 15),
787
+ end: midnightUtc(2026, 0, 16),
788
+ }
789
+ render(<ScheduleRoot data={[conference]} now={NOW} timeZone="UTC" onSelect={onSelect} />)
790
+ fireEvent.click(screen.getByTestId("ad1"))
791
+ expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({ id: "ad1" }))
792
+ })
793
+
794
+ it('caps the total row count at maxAllDayRows, promoting a lone daily overflow to a real bar and collapsing 2+ into a "+N"', () => {
795
+ // `blocker` (3 days, longest) is the sole survivor once maxAllDayRows=2
796
+ // forces a reduction to 1 real lane. Jan 15 then has only "p" left over
797
+ // (promoted to a real bar, not a wasteful "+1"); Jan 16 has both "q" and
798
+ // "r" left over (a genuine "+2").
799
+ const blocker: ScheduleEvent = {
800
+ kind: "event",
801
+ id: "blocker",
802
+ title: "Blocker",
803
+ allDay: true,
804
+ start: midnightUtc(2026, 0, 15),
805
+ end: midnightUtc(2026, 0, 18),
806
+ }
807
+ const p: ScheduleEvent = {
808
+ kind: "event",
809
+ id: "p",
810
+ title: "P",
811
+ allDay: true,
812
+ start: midnightUtc(2026, 0, 15),
813
+ end: midnightUtc(2026, 0, 16),
814
+ }
815
+ const q: ScheduleEvent = {
816
+ kind: "event",
817
+ id: "q",
818
+ title: "Q",
819
+ allDay: true,
820
+ start: midnightUtc(2026, 0, 16),
821
+ end: midnightUtc(2026, 0, 17),
822
+ }
823
+ const r: ScheduleEvent = { ...q, id: "r", title: "R" }
824
+ render(<ScheduleRoot data={[blocker, p, q, r]} now={NOW} timeZone="UTC" maxAllDayRows={2} />)
825
+
826
+ expect(
827
+ document.querySelector('[data-schedule-part="all-day-event"][data-testid="blocker"]'),
828
+ ).not.toBeNull()
829
+ // "p" is the only thing left over on its day — promoted to a real bar,
830
+ // not a wasteful "+1".
831
+ expect(
832
+ document.querySelector('[data-schedule-part="all-day-event"][data-testid="p"]'),
833
+ ).not.toBeNull()
834
+ expect(screen.queryByText("+1")).toBeNull()
835
+ // "q" and "r" share a day, so together they collapse into a real "+2" —
836
+ // never rendered as their own bars, only inside the "+N" menu's (closed)
837
+ // content, so excluded by scoping to the bar part.
838
+ expect(
839
+ document.querySelector('[data-schedule-part="all-day-event"][data-testid="q"]'),
840
+ ).toBeNull()
841
+ expect(
842
+ document.querySelector('[data-schedule-part="all-day-event"][data-testid="r"]'),
843
+ ).toBeNull()
844
+ expect(screen.getByText("+2")).toBeTruthy()
845
+ // Row count itself must never exceed maxAllDayRows (2): the "All day"
846
+ // gutter label spans exactly that many grid rows. Offset by 1 (starts at
847
+ // row 2, not row 1) since the all-day lanes now render into the same
848
+ // shared grid as the header row above them, not a grid of their own.
849
+ const label = screen.getByText("All day")
850
+ expect((label as HTMLElement).style.gridRow).toBe("2 / 4")
851
+ })
852
+ })
853
+
854
+ describe("ScheduleRoot — overlap overflow", () => {
855
+ // maxOverlapColumns bounds the TOTAL column count (see schedule-layout.ts's
856
+ // own comment): a cluster whose natural need exceeds it is re-placed at
857
+ // one fewer real column, reserving the last one for a single overflow
858
+ // indicator spanning the *union* of every hidden event's own range — not
859
+ // one indicator per instant-by-instant change in exactly who's hidden,
860
+ // which used to fragment a cluster of staggered short events into several
861
+ // awkwardly-short, visually-colliding chips. One consequence: reducing by
862
+ // exactly one column can only free up room for one *fewer* real event, so
863
+ // a cluster's overflow is always either empty or >= 2 events — never
864
+ // exactly 1 — so unlike the all-day row (which sub-buckets overflow by
865
+ // day and can genuinely have a lone hidden event on a given day), the
866
+ // timed grid never renders a "+1"; that branch would be unreachable.
867
+ it('collapses an entire overflowing cluster into one real "+N", spanning every hidden event\'s own time range', () => {
868
+ const blocker: ScheduleEvent = {
869
+ kind: "event",
870
+ id: "blocker",
871
+ title: "Blocker",
872
+ start: day(2026, 0, 15, 9),
873
+ end: day(2026, 0, 15, 12),
874
+ }
875
+ const p: ScheduleEvent = {
876
+ kind: "event",
877
+ id: "p",
878
+ title: "P",
879
+ start: day(2026, 0, 15, 9, 5),
880
+ end: day(2026, 0, 15, 10, 30),
881
+ }
882
+ const q: ScheduleEvent = {
883
+ kind: "event",
884
+ id: "q",
885
+ title: "Q",
886
+ start: day(2026, 0, 15, 10), // overlaps both blocker and p — genuine 3-way concurrency
887
+ end: day(2026, 0, 15, 10, 35),
888
+ }
889
+ render(<ScheduleRoot data={[blocker, p, q]} now={NOW} timeZone="UTC" maxOverlapColumns={2} />)
890
+ // "blocker" is the sole real survivor once the cluster is reduced to 1
891
+ // real column (2 - 1 reserved for the overflow indicator).
892
+ expect(
893
+ document.querySelector('[data-schedule-part="event-chip"][data-testid="blocker"]'),
894
+ ).not.toBeNull()
895
+ // "p" and "q" never overlap each other directly, but both overflow the
896
+ // same (blocker's) cluster — they collapse into one shared "+2", never
897
+ // rendered as their own chips, only inside the "+N" menu's (closed)
898
+ // content.
899
+ expect(document.querySelector('[data-schedule-part="event-chip"][data-testid="p"]')).toBeNull()
900
+ expect(document.querySelector('[data-schedule-part="event-chip"][data-testid="q"]')).toBeNull()
901
+ expect(screen.queryByText("+1")).toBeNull()
902
+ expect(screen.getByText("+2")).toBeTruthy()
903
+ })
904
+ })
905
+
906
+ describe("ScheduleRoot — chip DOM order matches visual order (tab order)", () => {
907
+ // Every chip is its own independent `tabIndex={0}` stop
908
+ // (`schedule-event-chip.tsx`) — native Tab/screen-reader order always
909
+ // follows DOM order, so these lock in that DOM order tracks visual
910
+ // position (top-to-bottom, then left-to-right), not `data`/`staticEvents`'
911
+ // own array order or a layout algorithm's own internal sort priority.
912
+ const midnightUtc = (y: number, m: number, d: number) => new Date(Date.UTC(y, m, d))
913
+
914
+ it("renders timed-grid chips in start-time order regardless of the data array's own order", () => {
915
+ const early: ScheduleEvent = {
916
+ kind: "event",
917
+ id: "early",
918
+ title: "Early",
919
+ start: day(2026, 0, 15, 9),
920
+ end: day(2026, 0, 15, 9, 30),
921
+ }
922
+ const late: ScheduleEvent = {
923
+ kind: "event",
924
+ id: "late",
925
+ title: "Late",
926
+ start: day(2026, 0, 15, 11),
927
+ end: day(2026, 0, 15, 11, 30),
928
+ }
929
+ // Deliberately reversed relative to start time.
930
+ render(<ScheduleRoot data={[late, early]} now={NOW} timeZone="UTC" />)
931
+ const chips = Array.from(
932
+ document.querySelectorAll('[data-schedule-part="event-chip"]'),
933
+ ) as HTMLElement[]
934
+ expect(chips.map((el) => el.dataset["testid"])).toEqual(["early", "late"])
935
+ })
936
+
937
+ it("renders same-start real and static chips in column order, not static-before-real DOM order", () => {
938
+ const realEvent: ScheduleEvent = {
939
+ kind: "event",
940
+ id: "real",
941
+ title: "Real",
942
+ start: day(2026, 0, 15, 9),
943
+ end: day(2026, 0, 15, 10),
944
+ }
945
+ const staticEvent: ScheduleStaticEvent = {
946
+ kind: "static",
947
+ id: "static",
948
+ title: "Static",
949
+ start: day(2026, 0, 15, 9),
950
+ end: day(2026, 0, 15, 10),
951
+ }
952
+ render(
953
+ <ScheduleRoot data={[realEvent]} staticEvents={[staticEvent]} now={NOW} timeZone="UTC" />,
954
+ )
955
+ // Real events tie-break ahead of static ones at an identical instant
956
+ // (`schedule-layout.ts`'s documented rule) — "real" gets column 0
957
+ // (left), "static" gets column 1 (right). DOM order must follow that
958
+ // column order, not the old dayStatic-then-dayEvents render order, which
959
+ // used to put "static" first despite it being the visually rightmost
960
+ // (higher-column) chip.
961
+ const chips = Array.from(
962
+ document.querySelectorAll('[data-schedule-part="event-chip"]'),
963
+ ) as HTMLElement[]
964
+ expect(chips.map((el) => el.dataset["testid"])).toEqual(["real", "static"])
965
+ })
966
+
967
+ it("renders all-day bars in lane-then-column order, not computeAllDayLayout's own duration-first order", () => {
968
+ // `computeAllDayLayout` sweeps longest-duration first: "a" (4 days)
969
+ // placed before "b" (3 days) before "c" (1 day). "a" and "b" genuinely
970
+ // overlap (both start Jan 15), so "b" is bumped to lane 1; "c" starts
971
+ // exactly when both "a" and "b" end, so it freely reuses the lowest
972
+ // open lane — lane 0, alongside "a". `bars`' own sweep-order array is
973
+ // therefore `[a, b, c]`, but the correct top-to-bottom/left-to-right
974
+ // visual order is `[a, c, b]` — lane 0's "a" then "c" (a is left of c
975
+ // within that shared lane), only then lane 1's "b". This is a real
976
+ // divergence a "just sort by duration" render (the old behavior) gets
977
+ // wrong: it would render "b" before "c" despite "b" sitting one row
978
+ // below.
979
+ const a: ScheduleEvent = {
980
+ kind: "event",
981
+ id: "a",
982
+ title: "A",
983
+ allDay: true,
984
+ start: midnightUtc(2026, 0, 15),
985
+ end: midnightUtc(2026, 0, 19),
986
+ }
987
+ const b: ScheduleEvent = {
988
+ kind: "event",
989
+ id: "b",
990
+ title: "B",
991
+ allDay: true,
992
+ start: midnightUtc(2026, 0, 15),
993
+ end: midnightUtc(2026, 0, 18),
994
+ }
995
+ const c: ScheduleEvent = {
996
+ kind: "event",
997
+ id: "c",
998
+ title: "C",
999
+ allDay: true,
1000
+ start: midnightUtc(2026, 0, 19),
1001
+ end: midnightUtc(2026, 0, 20),
1002
+ }
1003
+ // `align="relative"` anchors the window at `now` itself (Jan 15) rather
1004
+ // than snapping back to the locale's own start-of-week — otherwise the
1005
+ // default week-start snap could exclude "c" (Jan 19-20) from the visible
1006
+ // window entirely.
1007
+ render(
1008
+ <ScheduleRoot
1009
+ data={[a, b, c]}
1010
+ now={NOW}
1011
+ timeZone="UTC"
1012
+ view="days"
1013
+ visibleDays={7}
1014
+ align="relative"
1015
+ />,
1016
+ )
1017
+ const bars = Array.from(
1018
+ document.querySelectorAll('[data-schedule-part="all-day-event"]'),
1019
+ ) as HTMLElement[]
1020
+ expect(bars.map((el) => el.dataset["testid"])).toEqual(["a", "c", "b"])
1021
+ })
1022
+ })
1023
+
1024
+ /**
1025
+ * #237: a browser restarts a node's CSS animations when it is re-inserted, and
1026
+ * the DOM-order sort above re-inserts a chip whenever two of them swap order.
1027
+ * The entrance class must be gone by then. jsdom plays no animations, so the
1028
+ * end of the entrance is fired by hand — under its WebKit name, because jsdom
1029
+ * has no `AnimationEvent` and React then listens for `webkitAnimationEnd`
1030
+ * instead, which a plain `fireEvent.animationEnd` never reaches.
1031
+ */
1032
+ describe("ScheduleEventChip — entrance plays once per mount", () => {
1033
+ const ENTRANCE = "animate-schedule-chip-in"
1034
+ const animationEnd = (el: Element) =>
1035
+ fireEvent(el, new Event("webkitAnimationEnd", { bubbles: true }))
1036
+ const pair = <K extends "event" | "static">(kind: K, bStart: number) => [
1037
+ { kind, id: "a", title: "A", start: day(2026, 0, 15, 14), end: day(2026, 0, 15, 16) },
1038
+ {
1039
+ kind,
1040
+ id: "b",
1041
+ title: "B",
1042
+ start: day(2026, 0, 15, 14, bStart),
1043
+ end: day(2026, 0, 15, 14, 45),
1044
+ },
1045
+ ]
1046
+ const order = () =>
1047
+ (
1048
+ Array.from(document.querySelectorAll('[data-schedule-part="event-chip"]')) as HTMLElement[]
1049
+ ).map((el) => el.dataset["testid"])
1050
+
1051
+ it.each([
1052
+ ["interactive", "event"],
1053
+ ["static", "static"],
1054
+ ] as const)("the %s chip does not replay its entrance when a reorder moves it", (_, kind) => {
1055
+ const at = (bStart: number) =>
1056
+ kind === "event"
1057
+ ? { data: pair("event", bStart) as ScheduleEvent[] }
1058
+ : { data: [], staticEvents: pair("static", bStart) as ScheduleStaticEvent[] }
1059
+ const props = { now: NOW, timeZone: "UTC", view: "days", visibleDays: 1 } as const
1060
+ const { rerender } = render(<ScheduleRoot {...props} {...at(30)} />)
1061
+ const a = screen.getByTestId("a")
1062
+ expect(a.className).toContain(ENTRANCE)
1063
+
1064
+ animationEnd(a)
1065
+ animationEnd(screen.getByTestId("b"))
1066
+ expect(a.className).not.toContain(ENTRANCE)
1067
+
1068
+ // B now starts with A and, being shorter, takes column 0 — the order
1069
+ // flips and React moves A's node.
1070
+ rerender(<ScheduleRoot {...props} {...at(0)} />)
1071
+ expect(order()).toEqual(["b", "a"])
1072
+ expect(screen.getByTestId("a")).toBe(a)
1073
+ expect(a.className).not.toContain(ENTRANCE)
1074
+ })
1075
+
1076
+ it("ignores an animation that ends inside the chip", () => {
1077
+ render(<ScheduleRoot data={pair("event", 30) as ScheduleEvent[]} now={NOW} timeZone="UTC" />)
1078
+ const a = screen.getByTestId("a")
1079
+ animationEnd(within(a).getByText("A"))
1080
+ expect(a.className).toContain(ENTRANCE)
1081
+ })
1082
+
1083
+ it("still plays the entrance for an event added later", () => {
1084
+ const both = pair("event", 30) as ScheduleEvent[]
1085
+ const { rerender } = render(<ScheduleRoot data={both.slice(0, 1)} now={NOW} timeZone="UTC" />)
1086
+ animationEnd(screen.getByTestId("a"))
1087
+ rerender(<ScheduleRoot data={both} now={NOW} timeZone="UTC" />)
1088
+ expect(screen.getByTestId("b").className).toContain(ENTRANCE)
1089
+ })
1090
+ })
1091
+
1092
+ describe("ScheduleRoot — cascading overlap depth", () => {
1093
+ // A multi-day window's day-columns are much narrower than a single-day
1094
+ // window's one full-width column, so its cascade leans further in for
1095
+ // legibility on a busy cluster (see `schedule-timed-grid.tsx`'s
1096
+ // `DEFAULT_COLUMN_OVERLAP_PX_MULTI_DAY`) — `visibleDays={1}` keeps the
1097
+ // original, more modest default.
1098
+ it("gives a multi-day window a deeper cascade than a single-day one", () => {
1099
+ const { rerender } = render(
1100
+ <ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" view="days" visibleDays={7} />,
1101
+ )
1102
+ const weekGrid = document.querySelector('[data-schedule-part="timed-grid"]') as HTMLElement
1103
+ expect(weekGrid.style.getPropertyValue("--sch-column-overlap")).toBe("20px")
1104
+
1105
+ rerender(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" view="days" visibleDays={1} />)
1106
+ const dayGrid = document.querySelector('[data-schedule-part="timed-grid"]') as HTMLElement
1107
+ expect(dayGrid.style.getPropertyValue("--sch-column-overlap")).toBe("10px")
1108
+ })
1109
+ })
1110
+
1111
+ describe("ScheduleRoot — disabled slots", () => {
1112
+ it("renders the disabled overlay and blocks a keyboard-driven move", () => {
1113
+ const onEventChange = vi.fn()
1114
+ render(
1115
+ <ScheduleRoot
1116
+ data={EVENTS}
1117
+ now={NOW}
1118
+ timeZone="UTC"
1119
+ slotDisabled={() => true}
1120
+ editable={["drag"]}
1121
+ onEventChange={onEventChange}
1122
+ />,
1123
+ )
1124
+ expect(document.querySelector('[data-schedule-part="disabled-overlay"]')).not.toBeNull()
1125
+
1126
+ fireEvent.keyDown(screen.getByTestId("e1"), { key: "ArrowDown" })
1127
+ expect(onEventChange).not.toHaveBeenCalled()
1128
+ })
1129
+
1130
+ it("probes the disabled overlay in the schedule's own timeZone, not the host's", () => {
1131
+ // Deliberately a spy on the *instants probed*, not on the overlay's
1132
+ // geometry. A host-local probe paired with a host-local predicate drifts
1133
+ // together — `disableOutsideHours` would report the same 0-9/17-24 runs
1134
+ // either way — so geometry cannot tell the two apart, and a test asserting
1135
+ // it would pass on the bug. What the bug actually gets wrong is *which
1136
+ // hour* each run stands for, and that is visible only here.
1137
+ const probes: Date[] = []
1138
+ render(
1139
+ <ScheduleRoot
1140
+ data={[]}
1141
+ now={NOW}
1142
+ timeZone="Pacific/Kiritimati"
1143
+ startHour={0}
1144
+ endHour={24}
1145
+ visibleDays={1}
1146
+ slotDisabled={({ start }) => {
1147
+ probes.push(start)
1148
+ return false
1149
+ }}
1150
+ />,
1151
+ )
1152
+ const hourIn = (date: Date, timeZone: string) =>
1153
+ new Intl.DateTimeFormat("en-US", { timeZone, hour: "2-digit", hour12: false }).format(date)
1154
+ // The band starts at the schedule's own midnight, so the first hour probed
1155
+ // must read 00 in the schedule's zone — whatever the host's happens to be.
1156
+ expect(probes.length).toBeGreaterThan(0)
1157
+ expect(hourIn(probes[0] as Date, "Pacific/Kiritimati")).toBe("00")
1158
+ })
1159
+
1160
+ it("paints the overlay to a sub-hour boundary, not the enclosing hour", () => {
1161
+ // The whole point of probing at `slotDuration`: a schedule that opens at
1162
+ // 08:45 used to tint through to 09:00, so a bookable 15-minute strip looked
1163
+ // blocked. Enforcement was always exact — only the picture of it was not.
1164
+ const OPENS_AT = 8 * 60 + 45
1165
+ render(
1166
+ <ScheduleRoot
1167
+ data={[]}
1168
+ now={NOW}
1169
+ timeZone="UTC"
1170
+ startHour={7}
1171
+ endHour={13}
1172
+ slotDuration={15}
1173
+ visibleDays={1}
1174
+ slotDisabled={({ start }) => start.getUTCHours() * 60 + start.getUTCMinutes() < OPENS_AT}
1175
+ />,
1176
+ )
1177
+ const overlays = [
1178
+ ...document.querySelectorAll<HTMLElement>('[data-schedule-part="disabled-overlay"]'),
1179
+ ]
1180
+ expect(overlays).toHaveLength(1)
1181
+ // 07:00 to 08:45 of a 07:00-13:00 band = the first 1h45m of 6h.
1182
+ expect(overlays[0]?.style.top).toBe("0%")
1183
+ expect(overlays[0]?.style.height).toBe(`${(105 / 360) * 100}%`)
1184
+ })
1185
+
1186
+ it("refuses a create drag that rolls into the next day", () => {
1187
+ // The end-to-end shape of the reported bug: two-axis create hands
1188
+ // `checkRangeCommit` a range spanning midnight, which `disableOutsideHours`
1189
+ // used to wave through because both of its ends read as inside 9-17.
1190
+ HTMLElement.prototype.setPointerCapture = vi.fn()
1191
+ HTMLElement.prototype.releasePointerCapture = vi.fn()
1192
+ const onEventCreate = vi.fn()
1193
+ render(
1194
+ <ScheduleRoot
1195
+ data={[]}
1196
+ now={NOW}
1197
+ timeZone="UTC"
1198
+ startHour={0}
1199
+ endHour={24}
1200
+ editable={["create"]}
1201
+ slotDisabled={disableOutsideHours(9, 17)}
1202
+ onEventCreate={onEventCreate}
1203
+ />,
1204
+ )
1205
+ for (const column of document.querySelectorAll<HTMLElement>(
1206
+ "[data-schedule-part='day-column'][data-day-index]",
1207
+ )) {
1208
+ const index = Number(column.dataset["dayIndex"])
1209
+ vi.spyOn(column, "getBoundingClientRect").mockReturnValue({
1210
+ top: 0,
1211
+ bottom: 2880,
1212
+ height: 2880,
1213
+ left: index * 100,
1214
+ right: index * 100 + 100,
1215
+ width: 100,
1216
+ } as DOMRect)
1217
+ }
1218
+ const columns = document.querySelectorAll<HTMLElement>("[data-schedule-part='day-column']")
1219
+ const col = columns[4] as HTMLElement
1220
+ // Thu 11:00 (1320px / 2px-per-min) in column 4, released at Fri 12:00 in
1221
+ // column 5 — inside 9-17 at both ends, and a whole night in between.
1222
+ fireEvent.pointerDown(col, {
1223
+ clientX: 450,
1224
+ clientY: 1320,
1225
+ pointerId: 1,
1226
+ button: 0,
1227
+ pointerType: "mouse",
1228
+ })
1229
+ fireEvent.pointerMove(col, { clientX: 550, clientY: 1440, pointerId: 1 })
1230
+ fireEvent.pointerUp(col, { clientX: 550, clientY: 1440, pointerId: 1 })
1231
+
1232
+ expect(onEventCreate).not.toHaveBeenCalled()
1233
+ })
1234
+
1235
+ it("hands the keyboard drag path the schedule's timeZone", () => {
1236
+ // `schedule-event-chip.tsx` is the one `checkRangeCommit` call site not
1237
+ // reached by a pointer gesture, so it gets its own guard.
1238
+ const seen: (string | undefined)[] = []
1239
+ render(
1240
+ <ScheduleRoot
1241
+ data={EVENTS}
1242
+ now={NOW}
1243
+ timeZone="Pacific/Kiritimati"
1244
+ editable={["drag"]}
1245
+ slotDisabled={(_range, timeZone) => {
1246
+ seen.push(timeZone)
1247
+ return false
1248
+ }}
1249
+ onEventChange={vi.fn(() => {})}
1250
+ />,
1251
+ )
1252
+ seen.length = 0 // drop what the disabled-overlay probe already asked
1253
+ fireEvent.keyDown(screen.getByTestId("e1"), { key: "ArrowDown" })
1254
+ expect(seen).toContain("Pacific/Kiritimati")
1255
+ expect(seen.every((zone) => zone === "Pacific/Kiritimati")).toBe(true)
1256
+ })
1257
+ })
1258
+
1259
+ describe("ScheduleRoot — slotDuration default", () => {
1260
+ it("defaults slotDuration to 15 minutes (the keyboard move step)", () => {
1261
+ const onEventChange = vi.fn()
1262
+ render(
1263
+ <ScheduleRoot
1264
+ data={EVENTS}
1265
+ now={NOW}
1266
+ timeZone="UTC"
1267
+ editable={["drag"]}
1268
+ onEventChange={onEventChange}
1269
+ />,
1270
+ )
1271
+
1272
+ fireEvent.keyDown(screen.getByTestId("e1"), { key: "ArrowDown" })
1273
+
1274
+ expect(onEventChange).toHaveBeenCalledWith(
1275
+ expect.objectContaining({ id: "e1" }),
1276
+ { start: day(2026, 0, 15, 9, 15), end: day(2026, 0, 15, 9, 45) },
1277
+ "drag",
1278
+ )
1279
+ })
1280
+ })
1281
+
1282
+ describe("ScheduleRoot — resize handle keyboard", () => {
1283
+ it("resizes only the focused edge, not also moving the whole event", () => {
1284
+ const onEventChange = vi.fn()
1285
+ // Both "drag" and "resize" granted: if propagation weren't stopped, the
1286
+ // chip body's own arrow-key move handler (gated on "drag") would also
1287
+ // fire on bubble — this needs both permissions to actually exercise
1288
+ // that failure mode, not just resize alone.
1289
+ render(
1290
+ <ScheduleRoot
1291
+ data={EVENTS}
1292
+ now={NOW}
1293
+ timeZone="UTC"
1294
+ editable={["drag", "resize"]}
1295
+ onEventChange={onEventChange}
1296
+ />,
1297
+ )
1298
+
1299
+ const endHandle = screen.getByRole("separator", { name: /Adjust end time of Standup/ })
1300
+ fireEvent.keyDown(endHandle, { key: "ArrowDown" })
1301
+
1302
+ // Only the resize handle's own commit should fire — not also the chip
1303
+ // body's keyboard-move handler via bubbling.
1304
+ expect(onEventChange).toHaveBeenCalledTimes(1)
1305
+ expect(onEventChange).toHaveBeenCalledWith(
1306
+ expect.objectContaining({ id: "e1" }),
1307
+ expect.objectContaining({ start: EVENTS[0]?.start }),
1308
+ "resize",
1309
+ )
1310
+ })
1311
+ })
1312
+
1313
+ describe("ScheduleRoot — percentage-based geometry (correction after v1 shipped)", () => {
1314
+ // Structural regression coverage for the fill-height refactor: the timed
1315
+ // row's height is now a CSS `minmax(floor, 1fr)` (not a fixed inline px
1316
+ // style on each day-column), and every chip's position is a CSS
1317
+ // percentage/`max()` expression (not a baked px number) — both readable
1318
+ // straight off inline style strings, no real layout engine needed.
1319
+ it("gives the timed row a minmax(floor, 1fr) track, not a fixed px row", () => {
1320
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" />)
1321
+ const innerGrid = document.querySelector(
1322
+ '[data-schedule-part="timed-grid"] > div',
1323
+ ) as HTMLElement
1324
+ expect(innerGrid.style.gridTemplateRows).toMatch(/^auto minmax\(\d+px, 1fr\)$/)
1325
+ })
1326
+
1327
+ it("no longer sets a fixed inline height on the day-column itself", () => {
1328
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" />)
1329
+ const col = screen.getByTestId("e1").closest('[data-schedule-part="day-column"]') as HTMLElement
1330
+ expect(col.style.height).toBe("")
1331
+ })
1332
+
1333
+ it("positions a chip with a percentage top and a content-derived one-line height floor", () => {
1334
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" />)
1335
+ const chip = screen.getByTestId("e1") as HTMLElement
1336
+ expect(chip.style.getPropertyValue("--sch-base-top")).toMatch(/^-?[\d.]+%$/)
1337
+ // The var carries the chip's *true* height, unfloored — the resize preview
1338
+ // does its arithmetic on it and has to start from the real value.
1339
+ expect(chip.style.getPropertyValue("--sch-base-height")).toMatch(/^[\d.]+%$/)
1340
+ // The floor lives at the use site instead: one `text-xs` line (exactly
1341
+ // 1rem at any root font-size) plus the chip's own 2px border. Was a bare
1342
+ // `18px` — the same number at a 16px root, but wrong at any other, and the
1343
+ // fixed `py-1` then ate 8px of it.
1344
+ expect(chip.className).toContain("h-[max(var(--sch-base-height),calc(1rem+2px))]")
1345
+ })
1346
+
1347
+ /**
1348
+ * Regression: the floor used to be baked into `--sch-base-height` itself,
1349
+ * and the resize preview then subtracted true pixel deltas from that already
1350
+ * floored value. Wherever one slot renders shorter than a line of content
1351
+ * (a 13-hour day in a 624px column puts a 15-minute slot at 12px against an
1352
+ * 18px floor) the preview started 6px inflated and every size after it
1353
+ * inherited the error — shrinking drew a box that jumped up on release,
1354
+ * growing one that jumped down.
1355
+ *
1356
+ * What makes it correct is that the arithmetic reads the *raw* var and the
1357
+ * `max()` wraps the result, so the preview is exactly the box the commit
1358
+ * produces. Only the formula is assertable here; that the two actually agree
1359
+ * on screen is browser-only.
1360
+ */
1361
+ it("floors the resize preview on its result, never on its input", () => {
1362
+ render(
1363
+ <ScheduleRoot
1364
+ data={EVENTS}
1365
+ now={NOW}
1366
+ timeZone="UTC"
1367
+ editable={["resize"]}
1368
+ onEventChange={() => {}}
1369
+ />,
1370
+ )
1371
+ const chip = screen.getByTestId("e1") as HTMLElement
1372
+ const preview = chip.className.split(" ").find((c) => c.startsWith("data-resizing:h-["))
1373
+ expect(preview).toBeDefined()
1374
+ // The deltas apply to the raw height...
1375
+ expect(preview).toContain(
1376
+ "calc(var(--sch-base-height)-var(--sch-resize-delta-start,0px)+var(--sch-resize-delta-end,0px))",
1377
+ )
1378
+ // ...and the floor wraps the whole thing.
1379
+ expect(preview).toMatch(/^data-resizing:h-\[max\(calc\(.*\),calc\(1rem\+2px\)\)\]$/)
1380
+ })
1381
+ })
1382
+
1383
+ /**
1384
+ * The chip decides how much of itself to show from its own *rendered* height,
1385
+ * via `@container` size queries, rather than from the floor-derived px
1386
+ * estimate it used to be passed. jsdom evaluates no container queries (same
1387
+ * caveat `data-table.test.tsx` already carries), so what is assertable here is
1388
+ * that the component ships the right containers, defaults and thresholds —
1389
+ * whether the row actually appears at the right height is browser-only.
1390
+ */
1391
+ describe("ScheduleEventChip — vertical fit", () => {
1392
+ const chipOf = (testId: string) => screen.getByTestId(testId) as HTMLElement
1393
+ const timeRowOf = (chip: HTMLElement) => chip.querySelectorAll("p")[1] as HTMLElement | undefined
1394
+
1395
+ it("makes the chip a named size container so the queries read its real height", () => {
1396
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" />)
1397
+ expect(chipOf("e1").className).toContain("@container-size/sch-chip")
1398
+ })
1399
+
1400
+ it("gives both chip kinds a flex column, so a static <button> can't centre its title (#236)", () => {
1401
+ render(<ScheduleRoot data={EVENTS} staticEvents={STATIC_EVENTS} now={NOW} timeZone="UTC" />)
1402
+ // The static chip stays a native button; the display is what keeps the
1403
+ // browser's vertical centring of button content off it. jsdom has no
1404
+ // layout, so the class is the most this can check — the title offsets
1405
+ // themselves were measured in Chromium (see #236's PR).
1406
+ expect(chipOf("s1").tagName).toBe("BUTTON")
1407
+ expect(chipOf("e1").tagName).toBe("DIV")
1408
+ for (const chip of [chipOf("s1"), chipOf("e1")]) {
1409
+ const tokens = chip.className.split(/\s+/)
1410
+ expect(tokens).toContain("flex")
1411
+ expect(tokens).toContain("flex-col")
1412
+ }
1413
+ })
1414
+
1415
+ it("carries no vertical padding on the root, so the queried content box can't depend on it", () => {
1416
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" />)
1417
+ const cls = chipOf("e1").className
1418
+ // `px-2` stays; any `py-*`/`p-*` here would make the query circular.
1419
+ expect(cls).toContain("px-2")
1420
+ expect(cls).not.toMatch(/(^|\s)-?py-/)
1421
+ expect(cls).not.toMatch(/(^|\s)-?p-\d/)
1422
+ })
1423
+
1424
+ it("renders the time row always, hidden by default, revealed only by the query", () => {
1425
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" />)
1426
+ const row = timeRowOf(chipOf("e1"))
1427
+ // Always in the DOM now — `hidden` is the default so an engine without
1428
+ // container-query support fails *closed*, with the title still readable.
1429
+ expect(row).toBeTruthy()
1430
+ expect(row?.className).toContain("hidden")
1431
+ expect(row?.className).toContain("[@container_sch-chip_(height>=calc(2rem+8px))]:block")
1432
+ })
1433
+
1434
+ it("keeps the full time range in the accessible name whether or not the row is shown", () => {
1435
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" />)
1436
+ const event = EVENTS[0] as ScheduleEvent
1437
+ // Derived, never hardcoded: `timeRangeLabel` formats host-local and the
1438
+ // suite does not pin `TZ`.
1439
+ const range = timeRangeLabel(event.start, event.end)
1440
+ expect(chipOf("e1").getAttribute("aria-label")).toBe(`${event.title}, ${range}`)
1441
+ })
1442
+
1443
+ it("keeps the one-line floor and the two-line time threshold in step", () => {
1444
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" />)
1445
+ const chip = chipOf("e1")
1446
+
1447
+ // The floor moved off `--sch-base-height` onto the height utilities, so
1448
+ // that is where its `rem` term is read from now.
1449
+ const floorRem = Number(/calc\((\d*\.?\d+)rem\+2px\)/.exec(chip.className)?.[1])
1450
+
1451
+ const timeCls = timeRowOf(chip)?.className ?? ""
1452
+ const [, timeRem, timePx] =
1453
+ /height>=calc\((\d*\.?\d+)rem\+(\d+)px\)/.exec(timeCls)?.map(Number) ?? []
1454
+
1455
+ const rowCls = (chip.querySelector("div") as HTMLElement).className
1456
+ const padPx = [...rowCls.matchAll(/height>=calc\(\d*\.?\d+rem\+(\d+)px\)/g)].map((m) =>
1457
+ Number(m[1]),
1458
+ )
1459
+
1460
+ // The time row needs exactly twice the text of the floor…
1461
+ expect(timeRem).toBe(2 * floorRem)
1462
+ // …plus the full vertical padding the widest band puts back on.
1463
+ expect(timePx).toBe(Math.max(...padPx))
1464
+ // And the bands must climb, never collide.
1465
+ expect(padPx).toEqual([...padPx].sort((a, b) => a - b))
1466
+ expect(new Set(padPx).size).toBe(padPx.length)
1467
+ })
1468
+
1469
+ /** Reads a `prop-<n>` utility and its `@container sch-chip` banded variants
1470
+ * off one class string, as `{ base, steps }`. The base must be preceded by
1471
+ * whitespace so a banded `…]:top-0.5` can't be mistaken for it. */
1472
+ const bandsOf = (cls: string, prop: string) => ({
1473
+ base: Number(new RegExp(`(?:^|\\s)${prop}-(\\d*\\.?\\d+)(?=\\s|$)`).exec(cls)?.[1]),
1474
+ steps: [
1475
+ ...cls.matchAll(
1476
+ new RegExp(
1477
+ `height>=calc\\((\\d*\\.?\\d+)rem\\+(\\d+)px\\)\\)\\]:${prop}-(\\d*\\.?\\d+)`,
1478
+ "g",
1479
+ ),
1480
+ ),
1481
+ ].map((m) => ({ rem: Number(m[1]), px: Number(m[2]), value: Number(m[3]) })),
1482
+ })
1483
+
1484
+ it("keeps the remove button's top offset in step with the content row's padding", () => {
1485
+ render(
1486
+ <ScheduleRoot
1487
+ data={EVENTS}
1488
+ now={NOW}
1489
+ timeZone="UTC"
1490
+ editable={["remove"]}
1491
+ onEventRemove={() => {}}
1492
+ />,
1493
+ )
1494
+ const chip = chipOf("e1")
1495
+ const row = chip.querySelector("div") as HTMLElement
1496
+ const button = chip.querySelector('[data-schedule-part="remove"]') as HTMLElement
1497
+
1498
+ const py = bandsOf(row.className, "py")
1499
+ const top = bandsOf(button.className, "top")
1500
+
1501
+ // The button's own box is exactly one line tall (`p-0.5` x2 + `size-3` =
1502
+ // 1rem), and each band's lower bound is `1rem + 2*py`. So `top === py` at
1503
+ // every band is precisely the condition under which the button ends at
1504
+ // `py + 1rem <= 1rem + 2*py <= H` — i.e. never past the chip's own bottom,
1505
+ // at any height, fractional ones inside a band included. A fixed `top-1`
1506
+ // (what this replaced) needed 1.25rem and overhung a floored chip by 3px.
1507
+ expect(top.base).toBe(py.base)
1508
+ expect(top.steps).toEqual(py.steps)
1509
+ // Guard the guard: if the bands ever stop being parsed, the equality above
1510
+ // would pass vacuously on two empty lists.
1511
+ expect(py.steps.length).toBeGreaterThan(0)
1512
+ })
1513
+ })
1514
+
1515
+ /**
1516
+ * The remove button's *presence* and the title column's `pe-5` reservation for
1517
+ * it have to be driven by the same condition. They weren't: the reservation
1518
+ * tested `onEventRemove != null`, which is never false, because every chip is
1519
+ * handed `ScheduleTimedGrid`'s own `handleEventRemove` (an unconditional
1520
+ * `useCallback` that announces, then optional-chains the consumer's handler).
1521
+ */
1522
+ describe("ScheduleEventChip — remove button space reservation", () => {
1523
+ const titleColumnOf = (chip: HTMLElement) =>
1524
+ (chip.querySelector("p") as HTMLElement).parentElement as HTMLElement
1525
+ const removeButtonOf = (chip: HTMLElement) => chip.querySelector('[data-schedule-part="remove"]')
1526
+
1527
+ it("reserves nothing on a read-only schedule, even with onEventRemove passed", () => {
1528
+ // The default configuration: no `editable` grant at all, so no button —
1529
+ // and so no reason to give up 20px of a single truncating title line.
1530
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" onEventRemove={() => {}} />)
1531
+ const chip = screen.getByTestId("e1") as HTMLElement
1532
+ expect(removeButtonOf(chip)).toBeNull()
1533
+ expect(titleColumnOf(chip).className).not.toContain("pe-5")
1534
+ })
1535
+
1536
+ it("reserves space whenever the button renders", () => {
1537
+ // `editable` including "remove" makes `onEventRemove` required at the type
1538
+ // level (`requiredIf`), so "granted, but no handler" isn't reachable from
1539
+ // typed code — the divergence that mattered is the other direction, above.
1540
+ render(
1541
+ <ScheduleRoot
1542
+ data={EVENTS}
1543
+ now={NOW}
1544
+ timeZone="UTC"
1545
+ editable={["remove"]}
1546
+ onEventRemove={() => {}}
1547
+ />,
1548
+ )
1549
+ const chip = screen.getByTestId("e1") as HTMLElement
1550
+ expect(removeButtonOf(chip)).not.toBeNull()
1551
+ expect(titleColumnOf(chip).className).toContain("pe-5")
1552
+ })
1553
+
1554
+ it("follows per-event narrowing, not just the schedule-level grant", () => {
1555
+ render(
1556
+ <ScheduleRoot
1557
+ data={[{ ...(EVENTS[0] as ScheduleEvent), editable: false }]}
1558
+ now={NOW}
1559
+ timeZone="UTC"
1560
+ editable={["remove"]}
1561
+ onEventRemove={() => {}}
1562
+ />,
1563
+ )
1564
+ const chip = screen.getByTestId("e1") as HTMLElement
1565
+ expect(removeButtonOf(chip)).toBeNull()
1566
+ expect(titleColumnOf(chip).className).not.toContain("pe-5")
1567
+ })
1568
+ })
1569
+
1570
+ describe("ScheduleRoot — day-boundary segmentation", () => {
1571
+ // Host-local fixtures, and no `timeZone` override, because that is what real
1572
+ // usage looks like: `ScheduleRoot` defaults to `getLocalTimeZone()` and the
1573
+ // hour axis is host-local wall-clock throughout (see `segmentEvents`' own
1574
+ // comment). Building these in UTC on a non-UTC host would test a mismatch
1575
+ // between the day buckets and the painted band rather than the clipping.
1576
+ const local = (y: number, m: number, d: number, h = 0, min = 0) => new Date(y, m, d, h, min, 0, 0)
1577
+ const MONDAY = local(2026, 0, 12, 12)
1578
+
1579
+ const overnight: ScheduleEvent[] = [
1580
+ {
1581
+ kind: "event",
1582
+ id: "night",
1583
+ title: "Night shift",
1584
+ start: local(2026, 0, 12, 22),
1585
+ end: local(2026, 0, 13, 2),
1586
+ },
1587
+ ]
1588
+
1589
+ it("renders an event crossing midnight as one piece per day, each clipped to its own column", () => {
1590
+ render(<ScheduleRoot data={overnight} now={MONDAY} view="days" />)
1591
+
1592
+ // Two pieces, not the single full-duration chip repeated per column that
1593
+ // this component rendered before `segmentEvents` existed.
1594
+ const chips = screen.getAllByTestId("night")
1595
+ expect(chips).toHaveLength(2)
1596
+
1597
+ // Monday 22:00 -> 24:00: starts at 22/24 of the day, two hours tall.
1598
+ expect(chips[0]?.style.getPropertyValue("--sch-base-top")).toBe("91.66666666666666%")
1599
+ // A bare percentage: the legibility floor is applied by the height utility,
1600
+ // not baked into the var.
1601
+ expect(chips[0]?.style.getPropertyValue("--sch-base-height")).toBe("8.333333333333332%")
1602
+ // Tuesday 00:00 -> 02:00: starts at the very top, same two hours. Before
1603
+ // segmentation this piece was drawn at 22:00 as well, with the event's
1604
+ // whole four-hour duration, overflowing its column.
1605
+ expect(chips[1]?.style.getPropertyValue("--sch-base-top")).toBe("0%")
1606
+ expect(chips[1]?.style.getPropertyValue("--sch-base-height")).toBe("8.333333333333332%")
1607
+ })
1608
+
1609
+ it("marks only the cut edges as continuing, leaving a same-day event unmarked", () => {
1610
+ render(
1611
+ <ScheduleRoot
1612
+ data={[
1613
+ ...overnight,
1614
+ {
1615
+ kind: "event",
1616
+ id: "solo",
1617
+ title: "Standup",
1618
+ start: local(2026, 0, 12, 9),
1619
+ end: local(2026, 0, 12, 10),
1620
+ },
1621
+ ]}
1622
+ now={MONDAY}
1623
+ view="days"
1624
+ />,
1625
+ )
1626
+
1627
+ const [first, second] = screen.getAllByTestId("night")
1628
+ expect(first?.dataset["continuesBefore"]).toBeUndefined()
1629
+ expect(first?.dataset["continuesAfter"]).toBe("true")
1630
+ expect(second?.dataset["continuesBefore"]).toBe("true")
1631
+ expect(second?.dataset["continuesAfter"]).toBeUndefined()
1632
+
1633
+ // `props()` drops falsy entries, so an ordinary chip's DOM is untouched.
1634
+ const solo = screen.getByTestId("solo")
1635
+ expect(solo.dataset["continuesBefore"]).toBeUndefined()
1636
+ expect(solo.dataset["continuesAfter"]).toBeUndefined()
1637
+ })
1638
+
1639
+ it("puts each resize grip only on the piece that owns that real edge", () => {
1640
+ render(
1641
+ <ScheduleRoot
1642
+ data={overnight}
1643
+ now={MONDAY}
1644
+ view="days"
1645
+ editable={["resize"]}
1646
+ onEventChange={vi.fn(() => {})}
1647
+ />,
1648
+ )
1649
+
1650
+ // The start grip lives on the first piece, the end grip on the last — so
1651
+ // neither piece offers a handle for a boundary that isn't on screen.
1652
+ expect(
1653
+ screen.getAllByRole("separator", { name: /Adjust start time of Night shift/ }),
1654
+ ).toHaveLength(1)
1655
+ expect(
1656
+ screen.getAllByRole("separator", { name: /Adjust end time of Night shift/ }),
1657
+ ).toHaveLength(1)
1658
+
1659
+ const [first, second] = screen.getAllByTestId("night")
1660
+ expect(first?.querySelectorAll("[data-schedule-part='resize-handle']")).toHaveLength(1)
1661
+ expect(second?.querySelectorAll("[data-schedule-part='resize-handle']")).toHaveLength(1)
1662
+ })
1663
+
1664
+ it("gives a three-day event a middle piece with no grips at all", () => {
1665
+ render(
1666
+ <ScheduleRoot
1667
+ data={[
1668
+ {
1669
+ kind: "event",
1670
+ id: "span",
1671
+ title: "Piscine",
1672
+ start: local(2026, 0, 12, 14),
1673
+ end: local(2026, 0, 14, 11),
1674
+ },
1675
+ ]}
1676
+ now={MONDAY}
1677
+ view="days"
1678
+ editable={["resize"]}
1679
+ onEventChange={vi.fn(() => {})}
1680
+ />,
1681
+ )
1682
+
1683
+ const [first, middle, last] = screen.getAllByTestId("span")
1684
+ expect(screen.getAllByTestId("span")).toHaveLength(3)
1685
+ expect(first?.querySelectorAll("[data-schedule-part='resize-handle']")).toHaveLength(1)
1686
+ // Owns neither real edge, so there is nothing here to grab.
1687
+ expect(middle?.querySelectorAll("[data-schedule-part='resize-handle']")).toHaveLength(0)
1688
+ expect(middle?.dataset["continuesBefore"]).toBe("true")
1689
+ expect(middle?.dataset["continuesAfter"]).toBe("true")
1690
+ expect(last?.querySelectorAll("[data-schedule-part='resize-handle']")).toHaveLength(1)
1691
+ })
1692
+
1693
+ it("renders no phantom piece for an event ending exactly at midnight", () => {
1694
+ render(
1695
+ <ScheduleRoot
1696
+ data={[
1697
+ {
1698
+ kind: "event",
1699
+ id: "exam",
1700
+ title: "Exam",
1701
+ start: local(2026, 0, 12, 21),
1702
+ end: local(2026, 0, 13, 0),
1703
+ },
1704
+ ]}
1705
+ now={MONDAY}
1706
+ view="days"
1707
+ />,
1708
+ )
1709
+ // Exclusive end: the next day's band starts exactly where this stops.
1710
+ expect(screen.getAllByTestId("exam")).toHaveLength(1)
1711
+ })
1712
+
1713
+ it("renders nothing at all for an event outside the visible hour window", () => {
1714
+ render(
1715
+ <ScheduleRoot
1716
+ data={[
1717
+ {
1718
+ kind: "event",
1719
+ id: "early",
1720
+ title: "Early",
1721
+ start: local(2026, 0, 12, 2),
1722
+ end: local(2026, 0, 12, 3),
1723
+ },
1724
+ ]}
1725
+ now={MONDAY}
1726
+ view="days"
1727
+ startHour={6}
1728
+ endHour={22}
1729
+ />,
1730
+ )
1731
+ // Previously this rendered at a negative `top`, i.e. above the grid.
1732
+ expect(screen.queryByTestId("early")).toBeNull()
1733
+ })
1734
+ })
1735
+
1736
+ describe("ScheduleRoot — keyboard day move", () => {
1737
+ const renderChip = (onEventChange: () => void, extra = {}) =>
1738
+ render(
1739
+ <ScheduleRoot
1740
+ data={EVENTS}
1741
+ now={NOW}
1742
+ timeZone="UTC"
1743
+ editable={["drag"]}
1744
+ onEventChange={onEventChange}
1745
+ {...extra}
1746
+ />,
1747
+ )
1748
+
1749
+ it("moves an event one day later on ArrowRight", () => {
1750
+ const onEventChange = vi.fn()
1751
+ renderChip(onEventChange)
1752
+ fireEvent.keyDown(screen.getByTestId("e1"), { key: "ArrowRight" })
1753
+
1754
+ expect(onEventChange).toHaveBeenCalledWith(
1755
+ expect.objectContaining({ id: "e1" }),
1756
+ { start: day(2026, 0, 16, 9), end: day(2026, 0, 16, 9, 30) },
1757
+ "drag",
1758
+ )
1759
+ })
1760
+
1761
+ it("moves an event one day earlier on ArrowLeft, keeping the time", () => {
1762
+ const onEventChange = vi.fn()
1763
+ renderChip(onEventChange)
1764
+ fireEvent.keyDown(screen.getByTestId("e1"), { key: "ArrowLeft" })
1765
+
1766
+ expect(onEventChange).toHaveBeenCalledWith(
1767
+ expect.objectContaining({ id: "e1" }),
1768
+ { start: day(2026, 0, 14, 9), end: day(2026, 0, 14, 9, 30) },
1769
+ "drag",
1770
+ )
1771
+ })
1772
+
1773
+ it("ignores Shift on a day move — one press is one day", () => {
1774
+ const onEventChange = vi.fn()
1775
+ renderChip(onEventChange)
1776
+ fireEvent.keyDown(screen.getByTestId("e1"), { key: "ArrowRight", shiftKey: true })
1777
+
1778
+ expect(onEventChange).toHaveBeenCalledWith(
1779
+ expect.objectContaining({ id: "e1" }),
1780
+ { start: day(2026, 0, 16, 9), end: day(2026, 0, 16, 9, 30) },
1781
+ "drag",
1782
+ )
1783
+ })
1784
+
1785
+ it("rejects a day move onto a disabled slot instead of committing it", () => {
1786
+ const onEventChange = vi.fn()
1787
+ renderChip(onEventChange, {
1788
+ slotDisabled: ({ start }: { start: Date }) => start.getUTCDate() === 16,
1789
+ })
1790
+ fireEvent.keyDown(screen.getByTestId("e1"), { key: "ArrowRight" })
1791
+
1792
+ expect(onEventChange).not.toHaveBeenCalled()
1793
+ })
1794
+
1795
+ it("leaves a day move to the chip body when the resize handle has focus", () => {
1796
+ // The handle stops propagation for Up/Down only, so Left/Right still
1797
+ // reaches the body — changing the day, not one edge.
1798
+ const onEventChange = vi.fn()
1799
+ render(
1800
+ <ScheduleRoot
1801
+ data={EVENTS}
1802
+ now={NOW}
1803
+ timeZone="UTC"
1804
+ editable={["drag", "resize"]}
1805
+ onEventChange={onEventChange}
1806
+ />,
1807
+ )
1808
+ fireEvent.keyDown(screen.getByRole("separator", { name: /Adjust end time of Standup/ }), {
1809
+ key: "ArrowRight",
1810
+ })
1811
+
1812
+ expect(onEventChange).toHaveBeenCalledWith(
1813
+ expect.objectContaining({ id: "e1" }),
1814
+ { start: day(2026, 0, 16, 9), end: day(2026, 0, 16, 9, 30) },
1815
+ "drag",
1816
+ )
1817
+ })
1818
+ })
1819
+
1820
+ describe("ScheduleRoot — cross-day drag", () => {
1821
+ /** jsdom has no layout, so the horizontal axis has to be furnished by hand:
1822
+ * give every day column a distinct, strictly-ordered 100px box. Without
1823
+ * this the columns are indistinguishable and `measureColumns` deliberately
1824
+ * reports no usable layout, which is what the last test here pins. */
1825
+ const layOutColumns = () => {
1826
+ const columns = document.querySelectorAll<HTMLElement>(
1827
+ "[data-schedule-part='day-column'][data-day-index]",
1828
+ )
1829
+ for (const column of columns) {
1830
+ const index = Number(column.dataset["dayIndex"])
1831
+ vi.spyOn(column, "getBoundingClientRect").mockReturnValue({
1832
+ height: 2880, // 2880px / 1440min = 2px per minute
1833
+ left: index * 100,
1834
+ right: index * 100 + 100,
1835
+ width: 100,
1836
+ } as DOMRect)
1837
+ }
1838
+ }
1839
+
1840
+ const dragTo = (clientX: number, clientY: number) => {
1841
+ const chip = screen.getByTestId("e1")
1842
+ fireEvent.pointerDown(chip, { clientX: 400, clientY: 100, pointerId: 1, button: 0 })
1843
+ layOutColumns()
1844
+ fireEvent.pointerMove(chip, { clientX, clientY, pointerId: 1 })
1845
+ fireEvent.pointerUp(chip, { clientX, clientY, pointerId: 1 })
1846
+ }
1847
+
1848
+ const renderGrid = (onEventChange: () => void) => {
1849
+ HTMLElement.prototype.setPointerCapture = vi.fn()
1850
+ HTMLElement.prototype.releasePointerCapture = vi.fn()
1851
+ render(
1852
+ <ScheduleRoot
1853
+ data={EVENTS}
1854
+ now={NOW}
1855
+ timeZone="UTC"
1856
+ editable={["drag"]}
1857
+ onEventChange={onEventChange}
1858
+ />,
1859
+ )
1860
+ layOutColumns()
1861
+ }
1862
+
1863
+ it("commits a day change when the pointer ends over another column", () => {
1864
+ const onEventChange = vi.fn()
1865
+ renderGrid(onEventChange)
1866
+ // "e1" sits on Thu Jan 15 — column index 4, i.e. x in [400, 500). Drop it
1867
+ // at x = 550: column 5, Fri Jan 16. Vertically unmoved.
1868
+ dragTo(550, 100)
1869
+
1870
+ expect(onEventChange).toHaveBeenCalledWith(
1871
+ expect.objectContaining({ id: "e1" }),
1872
+ { start: day(2026, 0, 16, 9), end: day(2026, 0, 16, 9, 30) },
1873
+ "drag",
1874
+ )
1875
+ })
1876
+
1877
+ it("applies both axes in one gesture, preserving duration", () => {
1878
+ const onEventChange = vi.fn()
1879
+ renderGrid(onEventChange)
1880
+ // Two columns left (Tue Jan 13) and 60px down (+30min at 2px/min).
1881
+ dragTo(250, 160)
1882
+
1883
+ expect(onEventChange).toHaveBeenCalledWith(
1884
+ expect.objectContaining({ id: "e1" }),
1885
+ { start: day(2026, 0, 13, 9, 30), end: day(2026, 0, 13, 10, 0) },
1886
+ "drag",
1887
+ )
1888
+ })
1889
+
1890
+ it("leaves the day unchanged when the pointer is over no column", () => {
1891
+ const onEventChange = vi.fn()
1892
+ renderGrid(onEventChange)
1893
+ // x = 5000 is past the last column — over nothing. The single fallback rule
1894
+ // is "the day doesn't change", never "clamp to the nearest".
1895
+ dragTo(5000, 160)
1896
+
1897
+ expect(onEventChange).toHaveBeenCalledWith(
1898
+ expect.objectContaining({ id: "e1" }),
1899
+ { start: day(2026, 0, 15, 9, 30), end: day(2026, 0, 15, 10, 0) },
1900
+ "drag",
1901
+ )
1902
+ })
1903
+
1904
+ it("keeps a rejected cross-day drop from committing", () => {
1905
+ const onEventChange = vi.fn()
1906
+ HTMLElement.prototype.setPointerCapture = vi.fn()
1907
+ render(
1908
+ <ScheduleRoot
1909
+ data={EVENTS}
1910
+ now={NOW}
1911
+ timeZone="UTC"
1912
+ editable={["drag"]}
1913
+ onEventChange={onEventChange}
1914
+ slotDisabled={({ start }) => start.getUTCDay() === 5}
1915
+ />,
1916
+ )
1917
+ layOutColumns()
1918
+ dragTo(550, 100) // Friday — disabled
1919
+
1920
+ expect(onEventChange).not.toHaveBeenCalled()
1921
+ })
1922
+
1923
+ it("falls back to a single-axis drag when the columns have no usable layout", () => {
1924
+ // No `layOutColumns()` here: every jsdom rect is identical, so a
1925
+ // naive hit-test would resolve any x to the first column and silently
1926
+ // commit a multi-day jump. `measureColumns` reports no usable layout
1927
+ // instead, and only the time changes.
1928
+ const onEventChange = vi.fn()
1929
+ HTMLElement.prototype.setPointerCapture = vi.fn()
1930
+ render(
1931
+ <ScheduleRoot
1932
+ data={EVENTS}
1933
+ now={NOW}
1934
+ timeZone="UTC"
1935
+ editable={["drag"]}
1936
+ onEventChange={onEventChange}
1937
+ />,
1938
+ )
1939
+ const chip = screen.getByTestId("e1")
1940
+ const column = chip.closest("[data-schedule-part='day-column']") as HTMLElement
1941
+ vi.spyOn(column, "getBoundingClientRect").mockReturnValue({ height: 2880 } as DOMRect)
1942
+
1943
+ fireEvent.pointerDown(chip, { clientX: 0, clientY: 100, pointerId: 1, button: 0 })
1944
+ fireEvent.pointerMove(chip, { clientX: 0, clientY: 160, pointerId: 1 })
1945
+ fireEvent.pointerUp(chip, { clientX: 0, clientY: 160, pointerId: 1 })
1946
+
1947
+ expect(onEventChange).toHaveBeenCalledWith(
1948
+ expect.objectContaining({ id: "e1" }),
1949
+ { start: day(2026, 0, 15, 9, 30), end: day(2026, 0, 15, 10, 0) },
1950
+ "drag",
1951
+ )
1952
+ })
1953
+ })
1954
+
1955
+ describe("ScheduleRoot — pointer gesture geometry measures the day-column", () => {
1956
+ // jsdom doesn't implement real layout, but `getBoundingClientRect` and
1957
+ // `setPointerCapture` are both mockable enough to exercise the actual
1958
+ // pixel→minute conversion a real drag/resize commits — the numeric
1959
+ // regression risk of the fill-height refactor (visual verification still
1960
+ // needs a real browser, per this file's own top comment).
1961
+ it("derives drag distance from the day-column's own rendered height, not the outer scrollable viewport", () => {
1962
+ HTMLElement.prototype.setPointerCapture = vi.fn()
1963
+ const onEventChange = vi.fn()
1964
+ render(
1965
+ <ScheduleRoot
1966
+ data={EVENTS}
1967
+ now={NOW}
1968
+ timeZone="UTC"
1969
+ editable={["drag"]}
1970
+ onEventChange={onEventChange}
1971
+ />,
1972
+ )
1973
+ const chip = screen.getByTestId("e1")
1974
+ const dayColumnEl = chip.closest('[data-schedule-part="day-column"]') as HTMLElement
1975
+ const timedGridEl = document.querySelector('[data-schedule-part="timed-grid"]') as HTMLElement
1976
+
1977
+ // Deliberately different, deliberately wrong-if-used heights: if drag
1978
+ // physics ever regressed back to measuring the outer scrollable
1979
+ // viewport instead of the day-column (the exact bug this fix corrects
1980
+ // — both used to resolve identically since the old `resolvePxPerMinute`
1981
+ // only ever probed a shared CSS var, never a real rendered box), this
1982
+ // test would compute a different, wrong committed time.
1983
+ vi.spyOn(timedGridEl, "getBoundingClientRect").mockReturnValue({ height: 999_999 } as DOMRect)
1984
+ vi.spyOn(dayColumnEl, "getBoundingClientRect").mockReturnValue({ height: 2880 } as DOMRect)
1985
+ // 2880px / 1440min (the default 0-24 window) = 2px/min.
1986
+
1987
+ fireEvent.pointerDown(chip, { clientY: 100, pointerId: 1, button: 0 })
1988
+ fireEvent.pointerMove(chip, { clientY: 160, pointerId: 1 }) // 60px = 30min at 2px/min
1989
+ fireEvent.pointerUp(chip, { clientY: 160, pointerId: 1 })
1990
+
1991
+ expect(onEventChange).toHaveBeenCalledWith(
1992
+ expect.objectContaining({ id: "e1" }),
1993
+ { start: day(2026, 0, 15, 9, 30), end: day(2026, 0, 15, 10, 0) },
1994
+ "drag",
1995
+ )
1996
+ })
1997
+
1998
+ it("derives resize distance from the day-column's own rendered height too", () => {
1999
+ HTMLElement.prototype.setPointerCapture = vi.fn()
2000
+ const onEventChange = vi.fn()
2001
+ render(
2002
+ <ScheduleRoot
2003
+ data={EVENTS}
2004
+ now={NOW}
2005
+ timeZone="UTC"
2006
+ editable={["resize"]}
2007
+ onEventChange={onEventChange}
2008
+ />,
2009
+ )
2010
+ const dayColumnEl = screen
2011
+ .getByTestId("e1")
2012
+ .closest('[data-schedule-part="day-column"]') as HTMLElement
2013
+ vi.spyOn(dayColumnEl, "getBoundingClientRect").mockReturnValue({ height: 2880 } as DOMRect)
2014
+
2015
+ const endHandle = screen.getByRole("separator", { name: /Adjust end time of Standup/ })
2016
+ fireEvent.pointerDown(endHandle, { clientY: 100, pointerId: 1, button: 0 })
2017
+ fireEvent.pointerMove(endHandle, { clientY: 160, pointerId: 1 }) // +30min at 2px/min
2018
+ fireEvent.pointerUp(endHandle, { clientY: 160, pointerId: 1 })
2019
+
2020
+ expect(onEventChange).toHaveBeenCalledWith(
2021
+ expect.objectContaining({ id: "e1" }),
2022
+ { start: EVENTS[0]?.start, end: day(2026, 0, 15, 10, 0) },
2023
+ "resize",
2024
+ )
2025
+ })
2026
+ })
2027
+
2028
+ describe("ScheduleRoot — onGridClick", () => {
2029
+ it("fires on a plain click (no discernible drag) on empty grid space", () => {
2030
+ HTMLElement.prototype.setPointerCapture = vi.fn()
2031
+ const onGridClick = vi.fn()
2032
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" onGridClick={onGridClick} />)
2033
+ const col = document.querySelector('[data-schedule-part="day-column"]') as HTMLElement
2034
+ fireEvent.pointerDown(col, { clientY: 100, pointerId: 1, button: 0, pointerType: "mouse" })
2035
+ fireEvent.pointerUp(col, { clientY: 100, pointerId: 1 })
2036
+ expect(onGridClick).toHaveBeenCalledTimes(1)
2037
+ })
2038
+
2039
+ it("does not fire when the click lands on an event chip", () => {
2040
+ HTMLElement.prototype.setPointerCapture = vi.fn()
2041
+ const onGridClick = vi.fn()
2042
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" onGridClick={onGridClick} />)
2043
+ const chip = screen.getByTestId("e1")
2044
+ fireEvent.pointerDown(chip, { clientY: 100, pointerId: 1, button: 0 })
2045
+ fireEvent.pointerUp(chip, { clientY: 100, pointerId: 1 })
2046
+ expect(onGridClick).not.toHaveBeenCalled()
2047
+ })
2048
+
2049
+ it("does not fire alongside a committed create-drag — mutually exclusive branches of the same click-vs-drag check", () => {
2050
+ HTMLElement.prototype.setPointerCapture = vi.fn()
2051
+ const onGridClick = vi.fn()
2052
+ const onEventCreate = vi.fn()
2053
+ render(
2054
+ <ScheduleRoot
2055
+ data={[]}
2056
+ now={NOW}
2057
+ timeZone="UTC"
2058
+ editable={["create"]}
2059
+ onEventCreate={onEventCreate}
2060
+ onGridClick={onGridClick}
2061
+ />,
2062
+ )
2063
+ const col = document.querySelector('[data-schedule-part="day-column"]') as HTMLElement
2064
+ fireEvent.pointerDown(col, { clientY: 100, pointerId: 1, button: 0, pointerType: "mouse" })
2065
+ fireEvent.pointerMove(col, { clientY: 140, pointerId: 1 }) // past CLICK_SLOP — a real drag
2066
+ fireEvent.pointerUp(col, { clientY: 140, pointerId: 1 })
2067
+ expect(onEventCreate).toHaveBeenCalledTimes(1)
2068
+ expect(onGridClick).not.toHaveBeenCalled()
2069
+ })
2070
+
2071
+ it('fires even when editable doesn\'t include "create" — dismiss is independent of create permission', () => {
2072
+ HTMLElement.prototype.setPointerCapture = vi.fn()
2073
+ const onGridClick = vi.fn()
2074
+ render(
2075
+ <ScheduleRoot
2076
+ data={EVENTS}
2077
+ now={NOW}
2078
+ timeZone="UTC"
2079
+ editable={["drag"]}
2080
+ onEventChange={() => {}}
2081
+ onGridClick={onGridClick}
2082
+ />,
2083
+ )
2084
+ const col = document.querySelector('[data-schedule-part="day-column"]') as HTMLElement
2085
+ fireEvent.pointerDown(col, { clientY: 100, pointerId: 1, button: 0, pointerType: "mouse" })
2086
+ fireEvent.pointerUp(col, { clientY: 100, pointerId: 1 })
2087
+ expect(onGridClick).toHaveBeenCalledTimes(1)
2088
+ })
2089
+ })
2090
+
2091
+ describe("DayView / WeekView — thin DaysView prefabs", () => {
2092
+ it("DayView renders exactly 1 day column, regardless of visibleDays not being settable", () => {
2093
+ render(<DayView data={EVENTS} now={NOW} timeZone="UTC" />)
2094
+ expect(document.querySelectorAll('[data-schedule-part="day-column"]')).toHaveLength(1)
2095
+ })
2096
+
2097
+ it("WeekView renders exactly 7 day columns", () => {
2098
+ render(<WeekView data={EVENTS} now={NOW} timeZone="UTC" />)
2099
+ expect(document.querySelectorAll('[data-schedule-part="day-column"]')).toHaveLength(7)
2100
+ })
2101
+
2102
+ it('both prefabs still mount as data-schedule-part="days-view" — one DaysView underneath, no separate identity', () => {
2103
+ const { unmount } = render(<DayView data={EVENTS} now={NOW} timeZone="UTC" testId="day" />)
2104
+ expect(screen.getByTestId("day").getAttribute("data-schedule-part")).toBe("days-view")
2105
+ unmount()
2106
+
2107
+ render(<WeekView data={EVENTS} now={NOW} timeZone="UTC" testId="week" />)
2108
+ expect(screen.getByTestId("week").getAttribute("data-schedule-part")).toBe("days-view")
2109
+ })
2110
+
2111
+ it("WeekView still accepts align to anchor its window", () => {
2112
+ // Thursday 2026-01-15, UTC. Monday-start week containing it is 01-12..01-18.
2113
+ const onDayClick = vi.fn()
2114
+ render(<WeekView data={EVENTS} now={NOW} timeZone="UTC" align="mon" onDayClick={onDayClick} />)
2115
+ const headers = document.querySelectorAll('[data-schedule-part="timed-grid"] button')
2116
+ fireEvent.click(headers[0] as HTMLElement)
2117
+ expect(onDayClick).toHaveBeenCalledWith(day(2026, 0, 12))
2118
+ })
2119
+
2120
+ it("DayView has no align in its public props — always anchors on the date itself", () => {
2121
+ // visibleDays===1 always behaves like align: "relative" internally
2122
+ // (schedule-dates.ts), so DayView never needs (or accepts) align —
2123
+ // it always shows `now`'s own day, matching the old standalone DayView.
2124
+ const onDayClick = vi.fn()
2125
+ render(<DayView data={EVENTS} now={NOW} timeZone="UTC" onDayClick={onDayClick} />)
2126
+ const headers = document.querySelectorAll('[data-schedule-part="timed-grid"] button')
2127
+ expect(headers).toHaveLength(1)
2128
+ fireEvent.click(headers[0] as HTMLElement)
2129
+ expect(onDayClick).toHaveBeenCalledWith(day(2026, 0, 15))
2130
+ })
2131
+
2132
+ // Pinned because `cva` composes with clsx, not tailwind-merge: a second ring
2133
+ // colour introduced here would ship alongside this one rather than replace it.
2134
+ it("rings a chip in the palette, at the kit's single tinted strength", () => {
2135
+ const { container } = render(
2136
+ <ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" view="days" visibleDays={1} />,
2137
+ )
2138
+ const chip = container.querySelector('[class*="focus-visible:ring-(--c-text)"]')
2139
+ expect(chip).not.toBeNull()
2140
+ expect(chip?.className).toContain("focus-visible:ring-(--c-text)")
2141
+ expect(chip?.className).toContain("focus-visible:ring-2")
2142
+ expect(chip?.className).not.toContain("focus-visible:ring-brand-500")
2143
+ })
2144
+ })
2145
+
2146
+ describe("ScheduleRoot — cross-day create", () => {
2147
+ /** jsdom has no layout, so the horizontal axis has to be furnished by hand —
2148
+ * the same trick the cross-day drag suite uses. `top`/`bottom` matter here
2149
+ * where they don't for a drag: a create anchors on an absolute position
2150
+ * inside the column, not on a delta. 2880px over 1440 minutes = 2px/min. */
2151
+ const layOutColumns = () => {
2152
+ for (const column of document.querySelectorAll<HTMLElement>(
2153
+ "[data-schedule-part='day-column'][data-day-index]",
2154
+ )) {
2155
+ const index = Number(column.dataset["dayIndex"])
2156
+ vi.spyOn(column, "getBoundingClientRect").mockReturnValue({
2157
+ top: 0,
2158
+ bottom: 2880,
2159
+ height: 2880,
2160
+ left: index * 100,
2161
+ right: index * 100 + 100,
2162
+ width: 100,
2163
+ } as DOMRect)
2164
+ }
2165
+ }
2166
+
2167
+ const renderGrid = (
2168
+ onEventCreate: ScheduleEventCreateHandler,
2169
+ props: Pick<ScheduleTimedProps, "slotDisabled" | "onGridClick"> & {
2170
+ maxDuration?: SlotMultiple<15>
2171
+ editable?: false
2172
+ } = {},
2173
+ ) => {
2174
+ HTMLElement.prototype.setPointerCapture = vi.fn()
2175
+ HTMLElement.prototype.releasePointerCapture = vi.fn()
2176
+ render(
2177
+ <ScheduleRoot
2178
+ data={[]}
2179
+ now={NOW}
2180
+ timeZone="UTC"
2181
+ startHour={0}
2182
+ endHour={24}
2183
+ editable={["create"]}
2184
+ onEventCreate={onEventCreate}
2185
+ {...props}
2186
+ />,
2187
+ )
2188
+ layOutColumns()
2189
+ }
2190
+
2191
+ const columnAt = (index: number) =>
2192
+ document.querySelectorAll<HTMLElement>("[data-schedule-part='day-column']")[
2193
+ index
2194
+ ] as HTMLElement
2195
+
2196
+ const draftIn = (index: number) =>
2197
+ columnAt(index).querySelector<HTMLElement>("[data-schedule-part='create-draft']") as HTMLElement
2198
+
2199
+ it("commits one continuous range when the drag ends over a later column", () => {
2200
+ const onEventCreate = vi.fn()
2201
+ renderGrid(onEventCreate)
2202
+ // Thu Jan 15 is column 4 (x in [400, 500)); 1320px / 2 = 660min = 11:00.
2203
+ const col = columnAt(4)
2204
+ fireEvent.pointerDown(col, {
2205
+ clientX: 450,
2206
+ clientY: 1320,
2207
+ pointerId: 1,
2208
+ button: 0,
2209
+ pointerType: "mouse",
2210
+ })
2211
+ // x = 550 is column 5 (Fri Jan 16); 1440px / 2 = 720min = 12:00.
2212
+ fireEvent.pointerMove(col, { clientX: 550, clientY: 1440, pointerId: 1 })
2213
+ fireEvent.pointerUp(col, { clientX: 550, clientY: 1440, pointerId: 1 })
2214
+
2215
+ expect(onEventCreate).toHaveBeenCalledWith([
2216
+ { start: day(2026, 0, 15, 11), end: day(2026, 0, 16, 12) },
2217
+ ])
2218
+ })
2219
+
2220
+ it("commits a backwards drag as the same range, low-to-high", () => {
2221
+ const onEventCreate = vi.fn()
2222
+ renderGrid(onEventCreate)
2223
+ // Press on Fri at 12:00, release on Thu at 11:00 — the mirror of the
2224
+ // previous case, and the range must come out identical.
2225
+ const col = columnAt(5)
2226
+ fireEvent.pointerDown(col, {
2227
+ clientX: 550,
2228
+ clientY: 1440,
2229
+ pointerId: 1,
2230
+ button: 0,
2231
+ pointerType: "mouse",
2232
+ })
2233
+ fireEvent.pointerMove(col, { clientX: 450, clientY: 1320, pointerId: 1 })
2234
+ fireEvent.pointerUp(col, { clientX: 450, clientY: 1320, pointerId: 1 })
2235
+
2236
+ expect(onEventCreate).toHaveBeenCalledWith([
2237
+ { start: day(2026, 0, 15, 11), end: day(2026, 0, 16, 12) },
2238
+ ])
2239
+ })
2240
+
2241
+ it("rolls past the bottom of a column into the next day", () => {
2242
+ const onEventCreate = vi.fn()
2243
+ renderGrid(onEventCreate)
2244
+ // 2760px / 2 = 1380min = 23:00, dragged 240px (= 120min) below the band.
2245
+ const col = columnAt(4)
2246
+ fireEvent.pointerDown(col, {
2247
+ clientX: 450,
2248
+ clientY: 2760,
2249
+ pointerId: 1,
2250
+ button: 0,
2251
+ pointerType: "mouse",
2252
+ })
2253
+ fireEvent.pointerMove(col, { clientX: 450, clientY: 3000, pointerId: 1 })
2254
+ fireEvent.pointerUp(col, { clientX: 450, clientY: 3000, pointerId: 1 })
2255
+
2256
+ expect(onEventCreate).toHaveBeenCalledWith([
2257
+ { start: day(2026, 0, 15, 23), end: day(2026, 0, 16, 1) },
2258
+ ])
2259
+ })
2260
+
2261
+ it("draws one draft piece per day, squared off on the cut edges", () => {
2262
+ renderGrid(vi.fn())
2263
+ const col = columnAt(4)
2264
+ fireEvent.pointerDown(col, {
2265
+ clientX: 450,
2266
+ clientY: 2760,
2267
+ pointerId: 1,
2268
+ button: 0,
2269
+ pointerType: "mouse",
2270
+ })
2271
+ fireEvent.pointerMove(col, { clientX: 450, clientY: 3000, pointerId: 1 })
2272
+
2273
+ const thursday = draftIn(4)
2274
+ const friday = draftIn(5)
2275
+ expect(thursday.dataset["active"]).toBe("true")
2276
+ expect(friday.dataset["active"]).toBe("true")
2277
+ // Thursday holds 23:00 → midnight and continues; Friday starts at midnight
2278
+ // as a continuation and ends at the candidate's real end.
2279
+ expect(thursday.dataset["continuesAfter"]).toBe("true")
2280
+ expect(thursday.dataset["continuesBefore"]).toBeUndefined()
2281
+ expect(friday.dataset["continuesBefore"]).toBe("true")
2282
+ expect(friday.dataset["continuesAfter"]).toBeUndefined()
2283
+ expect(thursday.style.getPropertyValue("--sch-create-top")).toBe(`${(1380 / 1440) * 100}%`)
2284
+ expect(friday.style.getPropertyValue("--sch-create-top")).toBe("0%")
2285
+
2286
+ fireEvent.pointerUp(col, { clientX: 450, clientY: 3000, pointerId: 1 })
2287
+ // Every piece is cleared on release, not just the one that was pressed in.
2288
+ expect(thursday.dataset["active"]).toBeUndefined()
2289
+ expect(friday.dataset["active"]).toBeUndefined()
2290
+ })
2291
+
2292
+ it("day-qualifies the readout only once the candidate crosses a boundary", () => {
2293
+ renderGrid(vi.fn())
2294
+ const col = columnAt(4)
2295
+ const label = () =>
2296
+ draftIn(4).querySelector<HTMLElement>("[data-schedule-part='create-draft-label']")
2297
+ ?.textContent
2298
+
2299
+ fireEvent.pointerDown(col, {
2300
+ clientX: 450,
2301
+ clientY: 1320,
2302
+ pointerId: 1,
2303
+ button: 0,
2304
+ pointerType: "mouse",
2305
+ })
2306
+ fireEvent.pointerMove(col, { clientX: 450, clientY: 1440, pointerId: 1 })
2307
+ // Formatted in the schedule's own `timeZone`, so this assertion holds on
2308
+ // any host zone — which is exactly what it is here to pin.
2309
+ expect(label()).toBe("11:00 AM – 12:00 PM")
2310
+
2311
+ // Same press, now dragged onto the next column — the label has to name the
2312
+ // day, since "11:00 – 12:00" would read as a one-hour event.
2313
+ fireEvent.pointerMove(col, { clientX: 550, clientY: 1440, pointerId: 1 })
2314
+ expect(label()).toMatch(/Thu/)
2315
+ expect(label()).toMatch(/Fri/)
2316
+ })
2317
+
2318
+ it("recovers the day axis when a column is only measurable after the press", () => {
2319
+ // Every gesture snapshots `measureColumns` once at pointerdown, and one
2320
+ // zero-width column rejects the whole list. That used to pin the gesture to
2321
+ // its starting day for its entire life, even once the layout was fine a
2322
+ // frame later — the only thing that could re-measure was a page turn.
2323
+ //
2324
+ // The pressed column is laid out throughout, so the vertical anchor is
2325
+ // sound and the *only* thing under test is the day axis recovering.
2326
+ const onEventCreate = vi.fn()
2327
+ renderGrid(onEventCreate)
2328
+ let hiddenColumnLaidOut = false
2329
+ const hidden = columnAt(0)
2330
+ vi.spyOn(hidden, "getBoundingClientRect").mockImplementation(
2331
+ () =>
2332
+ ({
2333
+ top: 0,
2334
+ bottom: 2880,
2335
+ height: 2880,
2336
+ left: 0,
2337
+ right: hiddenColumnLaidOut ? 100 : 0,
2338
+ width: hiddenColumnLaidOut ? 100 : 0,
2339
+ }) as DOMRect,
2340
+ )
2341
+
2342
+ const col = columnAt(4)
2343
+ fireEvent.pointerDown(col, {
2344
+ clientX: 450,
2345
+ clientY: 1320,
2346
+ pointerId: 1,
2347
+ button: 0,
2348
+ pointerType: "mouse",
2349
+ })
2350
+ // The layout settles between the press and the first move.
2351
+ hiddenColumnLaidOut = true
2352
+ fireEvent.pointerMove(col, { clientX: 550, clientY: 1440, pointerId: 1 })
2353
+ fireEvent.pointerUp(col, { clientX: 550, clientY: 1440, pointerId: 1 })
2354
+
2355
+ expect(onEventCreate).toHaveBeenCalledWith([
2356
+ { start: day(2026, 0, 15, 11), end: day(2026, 0, 16, 12) },
2357
+ ])
2358
+ })
2359
+
2360
+ it("falls back to a single-axis create when the columns have no usable layout", () => {
2361
+ const onEventCreate = vi.fn()
2362
+ HTMLElement.prototype.setPointerCapture = vi.fn()
2363
+ render(
2364
+ <ScheduleRoot
2365
+ data={[]}
2366
+ now={NOW}
2367
+ timeZone="UTC"
2368
+ startHour={0}
2369
+ endHour={24}
2370
+ editable={["create"]}
2371
+ onEventCreate={onEventCreate}
2372
+ />,
2373
+ )
2374
+ // No `layOutColumns()` — every column reports the same box, which
2375
+ // `measureColumns` deliberately rejects rather than resolving every x to
2376
+ // column 0 and fabricating a multi-day range.
2377
+ const col = columnAt(4)
2378
+ fireEvent.pointerDown(col, {
2379
+ clientX: 450,
2380
+ clientY: 10,
2381
+ pointerId: 1,
2382
+ button: 0,
2383
+ pointerType: "mouse",
2384
+ })
2385
+ fireEvent.pointerMove(col, { clientX: 5000, clientY: 20, pointerId: 1 })
2386
+ fireEvent.pointerUp(col, { clientX: 5000, clientY: 20, pointerId: 1 })
2387
+
2388
+ const range = onEventCreate.mock.calls[0]?.[0]?.[0] as { start: Date; end: Date } | undefined
2389
+ expect(range?.start.getUTCDate()).toBe(15)
2390
+ expect(range?.end.getUTCDate()).toBe(15)
2391
+ })
2392
+
2393
+ it("stops growing at `maxDuration`, from the anchor", () => {
2394
+ const onEventCreate = vi.fn()
2395
+ renderGrid(onEventCreate, { maxDuration: 120 })
2396
+ const col = columnAt(4)
2397
+ fireEvent.pointerDown(col, {
2398
+ clientX: 450,
2399
+ clientY: 1320,
2400
+ pointerId: 1,
2401
+ button: 0,
2402
+ pointerType: "mouse",
2403
+ })
2404
+ fireEvent.pointerMove(col, { clientX: 550, clientY: 1440, pointerId: 1 })
2405
+ // The draft stops too, so it never promises what releasing won't make.
2406
+ expect(draftIn(5).dataset["active"]).toBeUndefined()
2407
+ fireEvent.pointerUp(col, { clientX: 550, clientY: 1440, pointerId: 1 })
2408
+
2409
+ expect(onEventCreate).toHaveBeenCalledWith([
2410
+ { start: day(2026, 0, 15, 11), end: day(2026, 0, 15, 13) },
2411
+ ])
2412
+ })
2413
+
2414
+ describe("with the right button", () => {
2415
+ /** Press at (x, y), drag to (toX, toY) and release — one gesture. */
2416
+ const rightDrag = (from: [number, number], to: [number, number]) => {
2417
+ const col = columnAt(Math.floor(from[0] / 100))
2418
+ fireEvent.pointerDown(col, {
2419
+ clientX: from[0],
2420
+ clientY: from[1],
2421
+ pointerId: 1,
2422
+ button: 2,
2423
+ pointerType: "mouse",
2424
+ })
2425
+ fireEvent.pointerMove(col, { clientX: to[0], clientY: to[1], pointerId: 1 })
2426
+ fireEvent.pointerUp(col, { clientX: to[0], clientY: to[1], pointerId: 1 })
2427
+ }
2428
+ /** Whether a `contextmenu` fired now would open the browser's menu. */
2429
+ const contextMenuOpens = () => fireEvent.contextMenu(window)
2430
+
2431
+ it("commits one range per day, each over the same time of day", () => {
2432
+ const onEventCreate = vi.fn()
2433
+ renderGrid(onEventCreate)
2434
+ // Thu 08:00 (960px) → Sat 16:00 (1920px).
2435
+ rightDrag([450, 960], [650, 1920])
2436
+
2437
+ expect(onEventCreate).toHaveBeenCalledTimes(1)
2438
+ expect(onEventCreate).toHaveBeenCalledWith([
2439
+ { start: day(2026, 0, 15, 8), end: day(2026, 0, 15, 16) },
2440
+ { start: day(2026, 0, 16, 8), end: day(2026, 0, 16, 16) },
2441
+ { start: day(2026, 0, 17, 8), end: day(2026, 0, 17, 16) },
2442
+ ])
2443
+ })
2444
+
2445
+ it("commits a backwards drag as the same ranges", () => {
2446
+ const onEventCreate = vi.fn()
2447
+ renderGrid(onEventCreate)
2448
+ rightDrag([650, 1920], [450, 960])
2449
+
2450
+ expect(onEventCreate).toHaveBeenCalledWith([
2451
+ { start: day(2026, 0, 15, 8), end: day(2026, 0, 15, 16) },
2452
+ { start: day(2026, 0, 16, 8), end: day(2026, 0, 16, 16) },
2453
+ { start: day(2026, 0, 17, 8), end: day(2026, 0, 17, 16) },
2454
+ ])
2455
+ })
2456
+
2457
+ it("skips the days that would be rejected", () => {
2458
+ const onEventCreate = vi.fn()
2459
+ const friday = day(2026, 0, 16)
2460
+ renderGrid(onEventCreate, {
2461
+ slotDisabled: ({ start }) => start.getUTCDate() === friday.getUTCDate(),
2462
+ })
2463
+ rightDrag([450, 960], [650, 1920])
2464
+
2465
+ expect(onEventCreate).toHaveBeenCalledWith([
2466
+ { start: day(2026, 0, 15, 8), end: day(2026, 0, 15, 16) },
2467
+ { start: day(2026, 0, 17, 8), end: day(2026, 0, 17, 16) },
2468
+ ])
2469
+ })
2470
+
2471
+ it("tints only the rejected day's draft", () => {
2472
+ const friday = day(2026, 0, 16)
2473
+ renderGrid(vi.fn(), {
2474
+ slotDisabled: ({ start }) => start.getUTCDate() === friday.getUTCDate(),
2475
+ })
2476
+ const col = columnAt(4)
2477
+ fireEvent.pointerDown(col, {
2478
+ clientX: 450,
2479
+ clientY: 960,
2480
+ pointerId: 1,
2481
+ button: 2,
2482
+ pointerType: "mouse",
2483
+ })
2484
+ fireEvent.pointerMove(col, { clientX: 650, clientY: 1920, pointerId: 1 })
2485
+
2486
+ expect([4, 5, 6].map((i) => draftIn(i).dataset["active"])).toEqual(["true", "true", "true"])
2487
+ expect([4, 5, 6].map((i) => draftIn(i).dataset["invalid"])).toEqual([
2488
+ undefined,
2489
+ "true",
2490
+ undefined,
2491
+ ])
2492
+ // Every day carries its own readout, not just the first.
2493
+ const label = (i: number) =>
2494
+ draftIn(i).querySelector("[data-schedule-part='create-draft-label']")?.textContent
2495
+ expect([4, 5, 6].map(label)).toEqual(Array(3).fill("08:00 AM – 04:00 PM"))
2496
+ fireEvent.pointerUp(col, { clientX: 650, clientY: 1920, pointerId: 1 })
2497
+ })
2498
+
2499
+ it("rejects the gesture only when every day is rejected", () => {
2500
+ const onEventCreate = vi.fn()
2501
+ renderGrid(onEventCreate, { slotDisabled: () => true })
2502
+ rightDrag([450, 960], [650, 1920])
2503
+ expect(onEventCreate).not.toHaveBeenCalled()
2504
+ })
2505
+
2506
+ it("does nothing on a still right-click", () => {
2507
+ const onEventCreate = vi.fn()
2508
+ const onGridClick = vi.fn()
2509
+ renderGrid(onEventCreate, { onGridClick })
2510
+ rightDrag([450, 960], [450, 960])
2511
+ expect(onEventCreate).not.toHaveBeenCalled()
2512
+ expect(onGridClick).not.toHaveBeenCalled()
2513
+ })
2514
+
2515
+ it("suppresses the context menu for the gesture and its trailing event only", () => {
2516
+ renderGrid(vi.fn())
2517
+ const col = columnAt(4)
2518
+ fireEvent.pointerDown(col, {
2519
+ clientX: 450,
2520
+ clientY: 960,
2521
+ pointerId: 1,
2522
+ button: 2,
2523
+ pointerType: "mouse",
2524
+ })
2525
+ // macOS/Linux: fired on press.
2526
+ expect(contextMenuOpens()).toBe(false)
2527
+ fireEvent.pointerUp(col, { clientX: 450, clientY: 1920, pointerId: 1 })
2528
+ // Windows: fired on release.
2529
+ expect(contextMenuOpens()).toBe(false)
2530
+ // A later, unrelated right-click keeps its menu.
2531
+ expect(contextMenuOpens()).toBe(true)
2532
+ })
2533
+
2534
+ it("stops suppressing at the next press when no trailing event came", () => {
2535
+ renderGrid(vi.fn())
2536
+ rightDrag([450, 960], [450, 1920])
2537
+ fireEvent.pointerDown(document.body, { button: 2, pointerId: 2 })
2538
+ expect(contextMenuOpens()).toBe(true)
2539
+ })
2540
+
2541
+ it("leaves the context menu alone without the create grant", () => {
2542
+ const onEventCreate = vi.fn()
2543
+ renderGrid(onEventCreate, { editable: false })
2544
+ const col = columnAt(4)
2545
+ fireEvent.pointerDown(col, {
2546
+ clientX: 450,
2547
+ clientY: 960,
2548
+ pointerId: 1,
2549
+ button: 2,
2550
+ pointerType: "mouse",
2551
+ })
2552
+ expect(contextMenuOpens()).toBe(true)
2553
+ fireEvent.pointerUp(col, { clientX: 450, clientY: 1920, pointerId: 1 })
2554
+ expect(onEventCreate).not.toHaveBeenCalled()
2555
+ })
2556
+ })
2557
+ })
2558
+
2559
+ describe("ScheduleRoot — cross-day resize", () => {
2560
+ const layOutColumns = () => {
2561
+ for (const column of document.querySelectorAll<HTMLElement>(
2562
+ "[data-schedule-part='day-column'][data-day-index]",
2563
+ )) {
2564
+ const index = Number(column.dataset["dayIndex"])
2565
+ vi.spyOn(column, "getBoundingClientRect").mockReturnValue({
2566
+ top: 0,
2567
+ bottom: 2880,
2568
+ height: 2880,
2569
+ left: index * 100,
2570
+ right: index * 100 + 100,
2571
+ width: 100,
2572
+ } as DOMRect)
2573
+ }
2574
+ }
2575
+
2576
+ const renderGrid = (onEventChange: () => void, maxDuration?: SlotMultiple<15>) => {
2577
+ HTMLElement.prototype.setPointerCapture = vi.fn()
2578
+ HTMLElement.prototype.releasePointerCapture = vi.fn()
2579
+ render(
2580
+ <ScheduleRoot
2581
+ data={EVENTS}
2582
+ now={NOW}
2583
+ timeZone="UTC"
2584
+ startHour={0}
2585
+ endHour={24}
2586
+ editable={["resize"]}
2587
+ onEventChange={onEventChange}
2588
+ maxDuration={maxDuration}
2589
+ />,
2590
+ )
2591
+ layOutColumns()
2592
+ }
2593
+
2594
+ /** "e1" runs 09:00–09:30, so it has both grips; the second is the end. */
2595
+ const endHandle = () =>
2596
+ screen
2597
+ .getByTestId("e1")
2598
+ .querySelectorAll<HTMLElement>("[data-schedule-part='resize-handle']")[1] as HTMLElement
2599
+
2600
+ const draftIn = (index: number) =>
2601
+ document
2602
+ .querySelectorAll<HTMLElement>("[data-schedule-part='day-column']")
2603
+ [index]?.querySelector<HTMLElement>("[data-schedule-part='create-draft']") as HTMLElement
2604
+
2605
+ it("carries the dragged edge onto another day", () => {
2606
+ const onEventChange = vi.fn()
2607
+ renderGrid(onEventChange)
2608
+ const handle = endHandle()
2609
+ // 09:30 is 570min → 1140px at 2px/min. Move to Friday (x in [500, 600)),
2610
+ // same height: a pure day change, which the vertical-only gesture could
2611
+ // not express at all.
2612
+ fireEvent.pointerDown(handle, { clientX: 450, clientY: 1140, pointerId: 1, button: 0 })
2613
+ fireEvent.pointerMove(handle, { clientX: 550, clientY: 1140, pointerId: 1 })
2614
+ fireEvent.pointerUp(handle, { clientX: 550, clientY: 1140, pointerId: 1 })
2615
+
2616
+ expect(onEventChange).toHaveBeenCalledWith(
2617
+ expect.objectContaining({ id: "e1" }),
2618
+ { start: day(2026, 0, 15, 9), end: day(2026, 0, 16, 9, 30) },
2619
+ "resize",
2620
+ )
2621
+ })
2622
+
2623
+ it("stops the dragged edge at `maxDuration`", () => {
2624
+ const onEventChange = vi.fn()
2625
+ renderGrid(onEventChange, 60)
2626
+ const handle = endHandle()
2627
+ fireEvent.pointerDown(handle, { clientX: 450, clientY: 1140, pointerId: 1, button: 0 })
2628
+ fireEvent.pointerMove(handle, { clientX: 550, clientY: 1140, pointerId: 1 })
2629
+ fireEvent.pointerUp(handle, { clientX: 550, clientY: 1140, pointerId: 1 })
2630
+
2631
+ expect(onEventChange).toHaveBeenCalledWith(
2632
+ expect.objectContaining({ id: "e1" }),
2633
+ { start: day(2026, 0, 15, 9), end: day(2026, 0, 15, 10) },
2634
+ "resize",
2635
+ )
2636
+ })
2637
+
2638
+ it("keeps the chip-stretch preview while the edge stays on its own day", () => {
2639
+ renderGrid(vi.fn())
2640
+ const handle = endHandle()
2641
+ const chip = screen.getByTestId("e1")
2642
+ fireEvent.pointerDown(handle, { clientX: 450, clientY: 1140, pointerId: 1, button: 0 })
2643
+ fireEvent.pointerMove(handle, { clientX: 450, clientY: 1260, pointerId: 1 })
2644
+
2645
+ // One delta per edge: an ordinary end resize moves only the end, so the
2646
+ // pair reduces to exactly the single-delta stretch this always was.
2647
+ expect(chip.dataset["resizing"]).toBe("true")
2648
+ expect(chip.dataset["resizingEdge"]).toBe("end")
2649
+ expect(chip.style.getPropertyValue("--sch-resize-delta-end")).toBe("120px")
2650
+ expect(chip.style.getPropertyValue("--sch-resize-delta-start")).toBe("0px")
2651
+ expect(chip.dataset["dragging"]).toBeUndefined()
2652
+ expect(draftIn(4).dataset["active"]).toBeUndefined()
2653
+ })
2654
+
2655
+ it("clamps the stretch to the day column instead of overflowing it", () => {
2656
+ // The regression this pair of vars exists for. "e1" ends 09:30; dragging
2657
+ // its end grip down by 40 hours' worth of pixels used to write that whole
2658
+ // raw delta, so the chip rendered ~4.6k px tall inside a 2880px column,
2659
+ // grew the `overflow-auto` grid's own scrollHeight, and fed the auto-
2660
+ // scroll that produced the delta in the first place.
2661
+ renderGrid(vi.fn())
2662
+ const handle = endHandle()
2663
+ const chip = screen.getByTestId("e1")
2664
+ fireEvent.pointerDown(handle, { clientX: 450, clientY: 1140, pointerId: 1, button: 0 })
2665
+ fireEvent.pointerMove(handle, { clientX: 450, clientY: 1140 + 2880 * 2, pointerId: 1 })
2666
+
2667
+ // Past the band edge, so the pieces take over and the chip holds nothing
2668
+ // — which is the strongest form of "the stretch cannot overflow".
2669
+ expect(chip.dataset["resizing"]).toBeUndefined()
2670
+ expect(chip.style.getPropertyValue("--sch-resize-delta-end")).toBe("")
2671
+ expect(chip.dataset["dragging"]).toBe("true")
2672
+ expect(draftIn(4).dataset["active"]).toBe("true")
2673
+ expect(draftIn(4).dataset["continuesAfter"]).toBe("true")
2674
+ })
2675
+
2676
+ it("keeps stretching a candidate that crosses the same band edges as before", () => {
2677
+ // A multi-day event always crosses a band edge, so "is it inside the band"
2678
+ // would hand every one of its grip nudges over to the pieces. The real
2679
+ // question is whether it crosses the *same* edges it already did.
2680
+ const onEventChange = vi.fn()
2681
+ HTMLElement.prototype.setPointerCapture = vi.fn()
2682
+ HTMLElement.prototype.releasePointerCapture = vi.fn()
2683
+ render(
2684
+ <ScheduleRoot
2685
+ data={[
2686
+ {
2687
+ kind: "event",
2688
+ id: "m1",
2689
+ title: "Retreat",
2690
+ start: day(2026, 0, 15, 9),
2691
+ end: day(2026, 0, 17, 9),
2692
+ },
2693
+ ]}
2694
+ now={NOW}
2695
+ timeZone="UTC"
2696
+ startHour={0}
2697
+ endHour={24}
2698
+ editable={["resize"]}
2699
+ onEventChange={onEventChange}
2700
+ />,
2701
+ )
2702
+ layOutColumns()
2703
+ // The Thursday piece owns the real start, so it carries the only start grip.
2704
+ const startGrip = screen.getAllByRole("separator", {
2705
+ name: /Adjust start time of Retreat/,
2706
+ })[0] as HTMLElement
2707
+ const chip = startGrip.closest<HTMLElement>("[data-schedule-part='event-chip']") as HTMLElement
2708
+ fireEvent.pointerDown(startGrip, { clientX: 450, clientY: 1080, pointerId: 1, button: 0 })
2709
+ fireEvent.pointerMove(startGrip, { clientX: 450, clientY: 1140, pointerId: 1 })
2710
+
2711
+ expect(chip.dataset["resizing"]).toBe("true")
2712
+ expect(chip.style.getPropertyValue("--sch-resize-delta-start")).toBe("60px")
2713
+ // Its own piece is clipped at midnight, so the bottom never moves.
2714
+ expect(chip.style.getPropertyValue("--sch-resize-delta-end")).toBe("0px")
2715
+ expect(chip.dataset["dragging"]).toBeUndefined()
2716
+ })
2717
+
2718
+ it("commits each resizeCollision mode's own answer at the other edge", () => {
2719
+ // Same gesture three times over: drag "e1"'s end grip up past its start.
2720
+ // 09:30 is 1140px; 08:00 is 960px, well past the 09:15 floor.
2721
+ for (const [resizeCollision, expected] of [
2722
+ ["none", { start: day(2026, 0, 15, 9), end: day(2026, 0, 15, 9, 15) }],
2723
+ ["push", { start: day(2026, 0, 15, 7, 45), end: day(2026, 0, 15, 8) }],
2724
+ ["swap", { start: day(2026, 0, 15, 8), end: day(2026, 0, 15, 9) }],
2725
+ ] as const) {
2726
+ const onEventChange = vi.fn()
2727
+ HTMLElement.prototype.setPointerCapture = vi.fn()
2728
+ HTMLElement.prototype.releasePointerCapture = vi.fn()
2729
+ const { unmount } = render(
2730
+ <ScheduleRoot
2731
+ data={EVENTS}
2732
+ now={NOW}
2733
+ timeZone="UTC"
2734
+ startHour={0}
2735
+ endHour={24}
2736
+ editable={["resize"]}
2737
+ resizeCollision={resizeCollision}
2738
+ onEventChange={onEventChange}
2739
+ />,
2740
+ )
2741
+ layOutColumns()
2742
+ const handle = endHandle()
2743
+ fireEvent.pointerDown(handle, { clientX: 450, clientY: 1140, pointerId: 1, button: 0 })
2744
+ fireEvent.pointerMove(handle, { clientX: 450, clientY: 960, pointerId: 1 })
2745
+ fireEvent.pointerUp(handle, { clientX: 450, clientY: 960, pointerId: 1 })
2746
+
2747
+ expect(onEventChange, resizeCollision).toHaveBeenCalledWith(
2748
+ expect.objectContaining({ id: "e1" }),
2749
+ expected,
2750
+ "resize",
2751
+ )
2752
+ unmount()
2753
+ }
2754
+ })
2755
+
2756
+ it("applies the resizeCollision mode to the keyboard nudge too", () => {
2757
+ // The grip's ArrowUp/Down routes through the same commit, so parity is
2758
+ // structural rather than a second implementation.
2759
+ const onEventChange = vi.fn()
2760
+ HTMLElement.prototype.setPointerCapture = vi.fn()
2761
+ render(
2762
+ <ScheduleRoot
2763
+ data={EVENTS}
2764
+ now={NOW}
2765
+ timeZone="UTC"
2766
+ startHour={0}
2767
+ endHour={24}
2768
+ editable={["resize"]}
2769
+ resizeCollision="push"
2770
+ onEventChange={onEventChange}
2771
+ />,
2772
+ )
2773
+ layOutColumns()
2774
+ const handle = endHandle()
2775
+ // `data` is uncontrolled here, so every nudge recomputes from the same
2776
+ // 09:00–09:30 — one Shift step (×4 = 60min) is what actually clears the
2777
+ // floor, where a plain 15-minute step lands exactly on it.
2778
+ fireEvent.keyDown(handle, { key: "ArrowUp", shiftKey: true })
2779
+ expect(onEventChange).toHaveBeenLastCalledWith(
2780
+ expect.objectContaining({ id: "e1" }),
2781
+ { start: day(2026, 0, 15, 8, 15), end: day(2026, 0, 15, 8, 30) },
2782
+ "resize",
2783
+ )
2784
+ })
2785
+
2786
+ it("hands the preview over to the draft pieces once the edge leaves its day", () => {
2787
+ renderGrid(vi.fn())
2788
+ const handle = endHandle()
2789
+ const chip = screen.getByTestId("e1")
2790
+ fireEvent.pointerDown(handle, { clientX: 450, clientY: 1140, pointerId: 1, button: 0 })
2791
+ fireEvent.pointerMove(handle, { clientX: 550, clientY: 1140, pointerId: 1 })
2792
+
2793
+ // The stretch can't represent a day change, so it steps back entirely
2794
+ // rather than holding a stale — and here zero — delta.
2795
+ expect(chip.dataset["resizingEdge"]).toBeUndefined()
2796
+ expect(chip.dataset["dragging"]).toBe("true")
2797
+ expect(draftIn(4).dataset["active"]).toBe("true")
2798
+ expect(draftIn(5).dataset["active"]).toBe("true")
2799
+ expect(draftIn(4).dataset["continuesAfter"]).toBe("true")
2800
+
2801
+ // Crossing back restores it — the handover is not one-way.
2802
+ fireEvent.pointerMove(handle, { clientX: 450, clientY: 1140, pointerId: 1 })
2803
+ expect(chip.dataset["resizingEdge"]).toBe("end")
2804
+ expect(chip.dataset["dragging"]).toBeUndefined()
2805
+ expect(draftIn(5).dataset["active"]).toBeUndefined()
2806
+ })
2807
+ })
2808
+
2809
+ describe("ScheduleRoot — page-turn animation", () => {
2810
+ const columns = (selector = "") =>
2811
+ document.querySelectorAll(`[data-schedule-part="day-column"][data-day-index]${selector}`).length
2812
+
2813
+ const live = () => columns(":not([data-page-exiting])")
2814
+ const exiting = () => columns("[data-page-exiting]")
2815
+
2816
+ /** jsdom's default stub never matches; a test that needs the reduced-motion
2817
+ * branch has to say so explicitly. */
2818
+ const setReducedMotion = (matches: boolean) => {
2819
+ window.matchMedia = vi.fn().mockImplementation((query: string) => ({
2820
+ matches,
2821
+ media: query,
2822
+ onchange: null,
2823
+ addListener: vi.fn(),
2824
+ removeListener: vi.fn(),
2825
+ addEventListener: vi.fn(),
2826
+ removeEventListener: vi.fn(),
2827
+ dispatchEvent: vi.fn(),
2828
+ })) as unknown as typeof window.matchMedia
2829
+ }
2830
+
2831
+ it("keeps the outgoing range mounted for one animation, then drops it", () => {
2832
+ vi.useFakeTimers()
2833
+ try {
2834
+ setReducedMotion(false)
2835
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" />)
2836
+ expect(live()).toBe(7)
2837
+ expect(exiting()).toBe(0)
2838
+
2839
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
2840
+ // Both bands are in the DOM together — that is the whole mechanism.
2841
+ expect(live()).toBe(7)
2842
+ expect(exiting()).toBe(7)
2843
+
2844
+ act(() => {
2845
+ vi.advanceTimersByTime(500)
2846
+ })
2847
+ expect(exiting()).toBe(0)
2848
+ expect(live()).toBe(7)
2849
+ } finally {
2850
+ vi.useRealTimers()
2851
+ }
2852
+ })
2853
+
2854
+ it("marks the outgoing band inert and hidden from assistive tech", () => {
2855
+ setReducedMotion(false)
2856
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" />)
2857
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
2858
+ const ghost = document.querySelector('[data-schedule-part="day-column"][data-page-exiting]')
2859
+ expect(ghost?.getAttribute("aria-hidden")).toBe("true")
2860
+ // The attribute, not the IDL property: jsdom does not reflect `inert`.
2861
+ expect(ghost?.hasAttribute("inert")).toBe(true)
2862
+ })
2863
+
2864
+ /**
2865
+ * Regression: the outgoing day-header buttons and day columns were marked
2866
+ * correctly, but the outgoing *all-day row* only ever received the leave
2867
+ * animation class — so its bars stayed focusable, announced, and carrying
2868
+ * `data-testid`s that collided with the incoming band's, for the ~220ms the
2869
+ * ghost was on screen. Only caught because looking an event up by
2870
+ * `data-event-id` needs `isLive` to be able to filter these out.
2871
+ */
2872
+ it("marks the outgoing all-day bars inert and hidden too", () => {
2873
+ setReducedMotion(false)
2874
+ const allDay: ScheduleEvent[] = [
2875
+ {
2876
+ kind: "event",
2877
+ id: "ad1",
2878
+ title: "Conference",
2879
+ // Spans the page boundary deliberately, so BOTH bands render a bar for
2880
+ // it — which is the only arrangement that tests whether a lookup by id
2881
+ // can tell the live copy from the ghost.
2882
+ start: day(2026, 0, 12),
2883
+ end: day(2026, 0, 26),
2884
+ allDay: true,
2885
+ },
2886
+ ]
2887
+ render(<ScheduleRoot data={allDay} now={NOW} timeZone="UTC" />)
2888
+ expect(document.querySelectorAll('[data-schedule-part="all-day-event"]').length).toBe(1)
2889
+
2890
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
2891
+
2892
+ const bars = [...document.querySelectorAll('[data-schedule-part="all-day-event"]')]
2893
+ const ghosts = bars.filter((el) => el.hasAttribute("data-page-exiting"))
2894
+ expect(ghosts.length).toBeGreaterThan(0)
2895
+ for (const ghost of ghosts) {
2896
+ expect(ghost.getAttribute("aria-hidden")).toBe("true")
2897
+ // The attribute, not the IDL property: jsdom does not reflect `inert`.
2898
+ expect(ghost.hasAttribute("inert")).toBe(true)
2899
+ }
2900
+ // ...and `isLive`'s selector can now tell the two copies apart by id:
2901
+ // both bands carry a bar for this event, and exactly one of them is live.
2902
+ const byId = [...document.querySelectorAll('[data-event-id="ad1"]')]
2903
+ expect(byId.length).toBeGreaterThan(1)
2904
+ expect(byId.filter((el) => el.closest("[data-page-exiting]") === null)).toHaveLength(1)
2905
+ })
2906
+
2907
+ it("does not animate a jump that isn't one page — Now, or a consumer-set date", () => {
2908
+ setReducedMotion(false)
2909
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" />)
2910
+ // Three pages forward, then Now: the return trip is 21 days, not 7.
2911
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
2912
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
2913
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
2914
+ fireEvent.click(screen.getByRole("button", { name: "Now" }))
2915
+ expect(exiting()).toBe(0)
2916
+ })
2917
+
2918
+ it("does not animate when the user asked for reduced motion", () => {
2919
+ setReducedMotion(true)
2920
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" />)
2921
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
2922
+ expect(exiting()).toBe(0)
2923
+ })
2924
+
2925
+ it("leaves exactly one live band for the gesture layer to measure", () => {
2926
+ setReducedMotion(false)
2927
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" />)
2928
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
2929
+ // `measureColumns` rejects a non-monotonic column list outright, so a
2930
+ // doubled band would silently degrade every two-axis gesture to one axis.
2931
+ expect(live()).toBe(7)
2932
+ const indices = [
2933
+ ...document.querySelectorAll<HTMLElement>(
2934
+ '[data-schedule-part="day-column"][data-day-index]:not([data-page-exiting])',
2935
+ ),
2936
+ ].map((el) => Number(el.dataset["dayIndex"]))
2937
+ expect(indices).toEqual([0, 1, 2, 3, 4, 5, 6])
2938
+ })
2939
+ })
2940
+
2941
+ describe("ScheduleRoot — drag preview across a day boundary", () => {
2942
+ const layOutColumns = () => {
2943
+ for (const column of document.querySelectorAll<HTMLElement>(
2944
+ "[data-schedule-part='day-column'][data-day-index]",
2945
+ )) {
2946
+ const index = Number(column.dataset["dayIndex"])
2947
+ vi.spyOn(column, "getBoundingClientRect").mockReturnValue({
2948
+ top: 0,
2949
+ bottom: 2880,
2950
+ height: 2880, // 2880px / 1440min = 2px per minute
2951
+ left: index * 100,
2952
+ right: index * 100 + 100,
2953
+ width: 100,
2954
+ } as DOMRect)
2955
+ }
2956
+ }
2957
+
2958
+ /** The preview leaf inside one day column — there is one per column now, the
2959
+ * same shape the create draft has, so a move that spans two days can draw
2960
+ * both of its pieces. */
2961
+ const ghostIn = (index: number) =>
2962
+ document
2963
+ .querySelectorAll<HTMLElement>("[data-schedule-part='day-column']")
2964
+ [index]?.querySelector<HTMLElement>("[data-schedule-part='drag-ghost']") as HTMLElement
2965
+
2966
+ const activeGhosts = () =>
2967
+ [...document.querySelectorAll<HTMLElement>("[data-schedule-part='drag-ghost']")]
2968
+ .map((el, i) => ({ i, active: el.dataset["active"] === "true" }))
2969
+ .filter((g) => g.active)
2970
+ .map((g) => g.i)
2971
+
2972
+ const renderGrid = (data: ScheduleEvent[] = EVENTS) => {
2973
+ HTMLElement.prototype.setPointerCapture = vi.fn()
2974
+ HTMLElement.prototype.releasePointerCapture = vi.fn()
2975
+ render(
2976
+ <ScheduleRoot
2977
+ data={data}
2978
+ now={NOW}
2979
+ timeZone="UTC"
2980
+ startHour={0}
2981
+ endHour={24}
2982
+ editable={["drag"]}
2983
+ onEventChange={() => {}}
2984
+ />,
2985
+ )
2986
+ layOutColumns()
2987
+ }
2988
+
2989
+ it("moves the preview onto the previous day when a drag crosses the band's start", () => {
2990
+ renderGrid()
2991
+ const chip = screen.getByTestId("e1") // Thu Jan 15, 09:00 — column 4
2992
+ // 1200px up at 2px/min is 600 minutes: 09:00 back to 23:00 on *Wednesday*.
2993
+ fireEvent.pointerDown(chip, { clientX: 450, clientY: 1080, pointerId: 1, button: 0 })
2994
+ layOutColumns()
2995
+ fireEvent.pointerMove(chip, { clientX: 450, clientY: -120, pointerId: 1 })
2996
+
2997
+ // Wednesday is column 3. Reading the *host's* clock instead of the day's
2998
+ // own band put this at 96% of column 4 — the column it started in.
2999
+ expect(activeGhosts()).toEqual([3])
3000
+ expect(ghostIn(3).style.getPropertyValue("--sch-ghost-top")).toBe(`${(1380 / 1440) * 100}%`)
3001
+
3002
+ fireEvent.pointerUp(chip, { clientX: 450, clientY: -120, pointerId: 1 })
3003
+ })
3004
+
3005
+ it("draws a piece on *both* days when the move straddles midnight", () => {
3006
+ renderGrid()
3007
+ const chip = screen.getByTestId("e1") // 09:00–09:30 Thursday
3008
+ // +885 minutes puts it at 23:45–00:15, i.e. across into Friday.
3009
+ fireEvent.pointerDown(chip, { clientX: 450, clientY: 1080, pointerId: 1, button: 0 })
3010
+ layOutColumns()
3011
+ fireEvent.pointerMove(chip, { clientX: 450, clientY: 1080 + 885 * 2, pointerId: 1 })
3012
+
3013
+ // A single grid-level box could only ever draw one of these, which is what
3014
+ // made a move through midnight look like it lost its preview.
3015
+ expect(activeGhosts()).toEqual([4, 5])
3016
+ expect(ghostIn(4).dataset["continuesAfter"]).toBe("true")
3017
+ expect(ghostIn(4).dataset["continuesBefore"]).toBeUndefined()
3018
+ expect(ghostIn(5).dataset["continuesBefore"]).toBe("true")
3019
+ expect(ghostIn(5).style.getPropertyValue("--sch-ghost-top")).toBe("0%")
3020
+
3021
+ fireEvent.pointerUp(chip, { clientX: 450, clientY: 1080 + 885 * 2, pointerId: 1 })
3022
+ })
3023
+
3024
+ it("paints into the live band, not the copy a page turn is animating out", () => {
3025
+ // The outgoing band a page turn keeps mounted is a full second set of
3026
+ // columns carrying the *same* `data-day-index` values, later in the DOM —
3027
+ // so collecting the pieces without skipping it hands every one of them to
3028
+ // the copy that is sliding away, and the preview is drawn where it can
3029
+ // never be seen.
3030
+ const nextWeek: ScheduleEvent = {
3031
+ kind: "event",
3032
+ id: "e2",
3033
+ title: "Standup",
3034
+ start: day(2026, 0, 22, 9),
3035
+ end: day(2026, 0, 22, 9, 30),
3036
+ }
3037
+ renderGrid([...EVENTS, nextWeek])
3038
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
3039
+ layOutColumns()
3040
+ // Precondition: the turn is actually animating, so both bands are mounted.
3041
+ expect(
3042
+ document.querySelectorAll("[data-schedule-part='day-column'][data-page-exiting]"),
3043
+ ).toHaveLength(7)
3044
+
3045
+ const chip = screen.getByTestId("e2")
3046
+ fireEvent.pointerDown(chip, { clientX: 450, clientY: 1080, pointerId: 1, button: 0 })
3047
+ layOutColumns()
3048
+ fireEvent.pointerMove(chip, { clientX: 450, clientY: 1080 + 885 * 2, pointerId: 1 })
3049
+
3050
+ const painted = [
3051
+ ...document.querySelectorAll<HTMLElement>("[data-schedule-part='drag-ghost']"),
3052
+ ].filter((el) => el.dataset["active"] === "true")
3053
+ expect(painted).toHaveLength(2)
3054
+ expect(painted.every((el) => el.closest("[data-page-exiting]") === null)).toBe(true)
3055
+
3056
+ fireEvent.pointerUp(chip, { clientX: 450, clientY: 1080 + 885 * 2, pointerId: 1 })
3057
+ })
3058
+
3059
+ it("clips each piece to its own band instead of overflowing the column", () => {
3060
+ renderGrid()
3061
+ const chip = screen.getByTestId("e1")
3062
+ fireEvent.pointerDown(chip, { clientX: 450, clientY: 1080, pointerId: 1, button: 0 })
3063
+ layOutColumns()
3064
+ fireEvent.pointerMove(chip, { clientX: 450, clientY: 1080 + 885 * 2, pointerId: 1 })
3065
+
3066
+ for (const index of activeGhosts()) {
3067
+ const el = ghostIn(index)
3068
+ const top = Number.parseFloat(el.style.getPropertyValue("--sch-ghost-top"))
3069
+ const height = Number.parseFloat(el.style.getPropertyValue("--sch-ghost-height"))
3070
+ expect(top).toBeGreaterThanOrEqual(0)
3071
+ expect(top + height).toBeLessThanOrEqual(100.0001)
3072
+ }
3073
+
3074
+ fireEvent.pointerUp(chip, { clientX: 450, clientY: 1080 + 885 * 2, pointerId: 1 })
3075
+ })
3076
+ })
3077
+
3078
+ /**
3079
+ * `views` — the configurable view-switcher entries. Type-level narrowing is
3080
+ * verified separately with a tsc harness (see the PR); these cover the runtime
3081
+ * half: what renders, what the switcher offers, and how drill-down resolves a
3082
+ * renderer to an entry id.
3083
+ */
3084
+ describe("ScheduleRoot — views", () => {
3085
+ const tabNames = () => screen.queryAllByRole("tab").map((el) => el.textContent?.trim() ?? "")
3086
+
3087
+ it("offers days/month/year by default, unchanged", async () => {
3088
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" />)
3089
+ await new Promise((r) => setTimeout(r, 0))
3090
+ expect(tabNames()).toEqual(["Week", "Month", "Year"])
3091
+ })
3092
+
3093
+ it("offers exactly the configured entries, in order", async () => {
3094
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" views={["month", "day", "week"]} />)
3095
+ await new Promise((r) => setTimeout(r, 0))
3096
+ expect(tabNames()).toEqual(["Month", "Day", "Week"])
3097
+ })
3098
+
3099
+ it("renders no switcher at all for a single entry", async () => {
3100
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" views={["week"]} />)
3101
+ await new Promise((r) => setTimeout(r, 0))
3102
+ expect(screen.queryAllByRole("tab")).toHaveLength(0)
3103
+ // ...and still renders that view.
3104
+ expect(document.querySelector('[data-schedule-part="timed-grid"]')).not.toBeNull()
3105
+ })
3106
+
3107
+ it("labels a custom entry from its own `label`, falling back to the id", async () => {
3108
+ render(
3109
+ <ScheduleRoot
3110
+ data={[]}
3111
+ now={NOW}
3112
+ timeZone="UTC"
3113
+ views={[
3114
+ { id: "fortnight", visibleDays: 14, label: "2 weeks" },
3115
+ { id: "quarter", visibleDays: 90 },
3116
+ ]}
3117
+ />,
3118
+ )
3119
+ await new Promise((r) => setTimeout(r, 0))
3120
+ expect(tabNames()).toEqual(["2 weeks", "quarter"])
3121
+ })
3122
+
3123
+ it("starts on the first entry when `defaultView` is omitted", () => {
3124
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" views={["month", "week"]} />)
3125
+ // Month, not the historical hard-coded "days" — which would have rendered a
3126
+ // view with no tab selected.
3127
+ expect(document.querySelector('[data-schedule-part="month-view"]')).not.toBeNull()
3128
+ })
3129
+
3130
+ it("sizes the days window from the active entry, overriding `visibleDays`", () => {
3131
+ render(
3132
+ <ScheduleRoot data={[]} now={NOW} timeZone="UTC" visibleDays={5} views={["day", "week"]} />,
3133
+ )
3134
+ expect(
3135
+ document.querySelectorAll('[data-schedule-part="day-column"][data-day-index]'),
3136
+ ).toHaveLength(1)
3137
+ })
3138
+
3139
+ /** The backwards-compatibility guarantee: `"days"` pins no window of its own,
3140
+ * so a consumer's `visibleDays` still wins under the default entries. */
3141
+ it("leaves `visibleDays` alone for the `days` entry", () => {
3142
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" visibleDays={5} />)
3143
+ expect(
3144
+ document.querySelectorAll('[data-schedule-part="day-column"][data-day-index]'),
3145
+ ).toHaveLength(5)
3146
+ })
3147
+
3148
+ it("drills into the first entry using the days renderer, by id", async () => {
3149
+ const onViewChange = vi.fn()
3150
+ render(
3151
+ <ScheduleRoot
3152
+ data={[]}
3153
+ now={NOW}
3154
+ timeZone="UTC"
3155
+ defaultView="month"
3156
+ views={["day", "week", "month"]}
3157
+ onViewChange={onViewChange}
3158
+ />,
3159
+ )
3160
+ fireEvent.click(
3161
+ document.querySelector('[data-schedule-part="month-day-number"]') as HTMLElement,
3162
+ )
3163
+ // "day" — the first days-renderer entry — not the literal string "days",
3164
+ // which is not an id here at all.
3165
+ expect(onViewChange).toHaveBeenCalledWith("day")
3166
+ })
3167
+
3168
+ it("moves the date but not the view when no entry offers the target renderer", () => {
3169
+ const onViewChange = vi.fn()
3170
+ const onDateChange = vi.fn()
3171
+ render(
3172
+ <ScheduleRoot
3173
+ data={[]}
3174
+ now={NOW}
3175
+ timeZone="UTC"
3176
+ views={["month", "year"]}
3177
+ onViewChange={onViewChange}
3178
+ onDateChange={onDateChange}
3179
+ />,
3180
+ )
3181
+ fireEvent.click(
3182
+ document.querySelector('[data-schedule-part="month-day-number"]') as HTMLElement,
3183
+ )
3184
+ expect(onDateChange).toHaveBeenCalled()
3185
+ expect(onViewChange).not.toHaveBeenCalled()
3186
+ })
3187
+ })
3188
+
3189
+ describe("ScheduleRoot — selection", () => {
3190
+ const chip = (id: string) => screen.getByTestId(id)
3191
+
3192
+ /**
3193
+ * An interactive chip has no DOM `onClick`: its click is resolved at
3194
+ * pointerup by `use-event-drag.ts`'s `maxAbsDelta < CLICK_SLOP` check, which
3195
+ * is precisely why selection inherits a correct drag-vs-click answer for
3196
+ * free. So a plain `fireEvent.click` would (correctly) do nothing here.
3197
+ */
3198
+ const clickChip = (id: string) => {
3199
+ HTMLElement.prototype.setPointerCapture = vi.fn()
3200
+ const el = chip(id)
3201
+ fireEvent.pointerDown(el, { clientX: 0, clientY: 100, pointerId: 1, button: 0 })
3202
+ fireEvent.pointerUp(el, { clientX: 0, clientY: 100, pointerId: 1 })
3203
+ }
3204
+
3205
+ it("selects an interactive event on click and reports the whole event", () => {
3206
+ const onSelect = vi.fn()
3207
+ render(<ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" onSelect={onSelect} />)
3208
+ clickChip("e1")
3209
+ expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({ id: "e1" }))
3210
+ expect(chip("e1").hasAttribute("data-selected")).toBe(true)
3211
+ })
3212
+
3213
+ it("selects a static event on a plain click", () => {
3214
+ const onSelect = vi.fn()
3215
+ render(
3216
+ <ScheduleRoot
3217
+ data={[]}
3218
+ staticEvents={STATIC_EVENTS}
3219
+ now={NOW}
3220
+ timeZone="UTC"
3221
+ onSelect={onSelect}
3222
+ />,
3223
+ )
3224
+ fireEvent.click(chip("s1"))
3225
+ expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({ id: "s1" }))
3226
+ })
3227
+
3228
+ /** The drag-vs-click guarantee, stated as a test: a real drag commits a
3229
+ * change and must never also select. */
3230
+ it("does not select when the gesture resolves to a drag", () => {
3231
+ HTMLElement.prototype.setPointerCapture = vi.fn()
3232
+ const onSelect = vi.fn()
3233
+ render(
3234
+ <ScheduleRoot
3235
+ data={EVENTS}
3236
+ now={NOW}
3237
+ timeZone="UTC"
3238
+ editable={["drag"]}
3239
+ onEventChange={() => {}}
3240
+ onSelect={onSelect}
3241
+ />,
3242
+ )
3243
+ const el = chip("e1")
3244
+ fireEvent.pointerDown(el, { clientX: 0, clientY: 100, pointerId: 1, button: 0 })
3245
+ fireEvent.pointerMove(el, { clientX: 0, clientY: 160, pointerId: 1 })
3246
+ fireEvent.pointerUp(el, { clientX: 0, clientY: 160, pointerId: 1 })
3247
+ expect(onSelect).not.toHaveBeenCalled()
3248
+ })
3249
+
3250
+ it("stamps data-selected only on the selected chip", () => {
3251
+ render(
3252
+ <ScheduleRoot
3253
+ data={[
3254
+ ...EVENTS,
3255
+ {
3256
+ kind: "event",
3257
+ id: "e2",
3258
+ title: "Other",
3259
+ start: day(2026, 0, 15, 14),
3260
+ end: day(2026, 0, 15, 15),
3261
+ },
3262
+ ]}
3263
+ now={NOW}
3264
+ timeZone="UTC"
3265
+ defaultSelected="e1"
3266
+ />,
3267
+ )
3268
+ expect(chip("e1").hasAttribute("data-selected")).toBe(true)
3269
+ expect(chip("e2").hasAttribute("data-selected")).toBe(false)
3270
+ })
3271
+
3272
+ it("clears the selection on a plain click on empty grid space, alongside onGridClick", () => {
3273
+ HTMLElement.prototype.setPointerCapture = vi.fn()
3274
+ const onSelect = vi.fn()
3275
+ const onGridClick = vi.fn()
3276
+ render(
3277
+ <ScheduleRoot
3278
+ data={EVENTS}
3279
+ now={NOW}
3280
+ timeZone="UTC"
3281
+ defaultSelected="e1"
3282
+ onSelect={onSelect}
3283
+ onGridClick={onGridClick}
3284
+ />,
3285
+ )
3286
+ const col = document.querySelector('[data-schedule-part="day-column"]') as HTMLElement
3287
+ fireEvent.pointerDown(col, { clientY: 100, pointerId: 1, button: 0, pointerType: "mouse" })
3288
+ fireEvent.pointerUp(col, { clientY: 100, pointerId: 1 })
3289
+ // Both fire, and they are not synonyms: one reports the state change, the
3290
+ // other the raw gesture with the instant pressed.
3291
+ expect(onSelect).toHaveBeenCalledWith(null)
3292
+ expect(onGridClick).toHaveBeenCalledTimes(1)
3293
+ expect(onGridClick.mock.calls[0]?.[0]).toBeInstanceOf(Date)
3294
+ })
3295
+
3296
+ it("honours a controlled `selected` and does not move on its own", () => {
3297
+ const onSelect = vi.fn()
3298
+ const { rerender } = render(
3299
+ <ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" selected={null} onSelect={onSelect} />,
3300
+ )
3301
+ clickChip("e1")
3302
+ expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({ id: "e1" }))
3303
+ // Controlled and unchanged by the parent: nothing is selected.
3304
+ expect(chip("e1").hasAttribute("data-selected")).toBe(false)
3305
+
3306
+ rerender(
3307
+ <ScheduleRoot data={EVENTS} now={NOW} timeZone="UTC" selected="e1" onSelect={onSelect} />,
3308
+ )
3309
+ expect(chip("e1").hasAttribute("data-selected")).toBe(true)
3310
+ })
3311
+
3312
+ it("does nothing at all with withSelection={false}", () => {
3313
+ const onSelect = vi.fn()
3314
+ render(
3315
+ <ScheduleRoot
3316
+ data={EVENTS}
3317
+ now={NOW}
3318
+ timeZone="UTC"
3319
+ withSelection={false}
3320
+ defaultSelected="e1"
3321
+ onSelect={onSelect}
3322
+ />,
3323
+ )
3324
+ expect(chip("e1").hasAttribute("data-selected")).toBe(false)
3325
+ clickChip("e1")
3326
+ expect(onSelect).not.toHaveBeenCalled()
3327
+ })
3328
+
3329
+ it("mounts no details popover with withEventDetails={false}", () => {
3330
+ render(
3331
+ <ScheduleRoot
3332
+ data={EVENTS}
3333
+ now={NOW}
3334
+ timeZone="UTC"
3335
+ withEventDetails={false}
3336
+ defaultSelected="e1"
3337
+ />,
3338
+ )
3339
+ expect(chip("e1").hasAttribute("data-selected")).toBe(true)
3340
+ expect(screen.queryByRole("dialog")).toBeNull()
3341
+ // No popover means no disclosure semantics to announce either.
3342
+ expect(chip("e1").getAttribute("aria-haspopup")).toBeNull()
3343
+ })
3344
+
3345
+ it("ignores a `selected` id that matches no event", () => {
3346
+ const onDateChange = vi.fn()
3347
+ render(
3348
+ <ScheduleRoot
3349
+ data={EVENTS}
3350
+ now={NOW}
3351
+ timeZone="UTC"
3352
+ selected="nope"
3353
+ onDateChange={onDateChange}
3354
+ />,
3355
+ )
3356
+ expect(onDateChange).not.toHaveBeenCalled()
3357
+ expect(chip("e1").hasAttribute("data-selected")).toBe(false)
3358
+ })
3359
+ })
3360
+
3361
+ /**
3362
+ * #240: one thing drawn as several chips — an offer split around the booking
3363
+ * that bites into it. `selected` takes the list; the first id is the anchor.
3364
+ */
3365
+ describe("ScheduleRoot — several selected chips", () => {
3366
+ const OFFER: ScheduleEvent[] = [
3367
+ {
3368
+ kind: "event",
3369
+ id: "offer:before",
3370
+ title: "Offer",
3371
+ start: day(2026, 0, 15, 9),
3372
+ end: day(2026, 0, 15, 10),
3373
+ },
3374
+ {
3375
+ kind: "event",
3376
+ id: "offer:after",
3377
+ title: "Offer",
3378
+ start: day(2026, 0, 15, 11),
3379
+ end: day(2026, 0, 15, 12),
3380
+ },
3381
+ ]
3382
+ const chip = (id: string) => screen.getByTestId(id)
3383
+
3384
+ it("paints every listed chip and opens one popover, on the first", () => {
3385
+ render(
3386
+ <ScheduleRoot
3387
+ data={OFFER}
3388
+ now={NOW}
3389
+ timeZone="UTC"
3390
+ selected={["offer:before", "offer:after"]}
3391
+ />,
3392
+ )
3393
+ expect(chip("offer:before").hasAttribute("data-selected")).toBe(true)
3394
+ expect(chip("offer:after").hasAttribute("data-selected")).toBe(true)
3395
+ expect(screen.getAllByRole("dialog")).toHaveLength(1)
3396
+ expect(chip("offer:before").getAttribute("aria-expanded")).toBe("true")
3397
+ expect(chip("offer:after").getAttribute("aria-expanded")).toBe("false")
3398
+ })
3399
+
3400
+ it("moves the popover when the order changes", () => {
3401
+ const { rerender } = render(
3402
+ <ScheduleRoot
3403
+ data={OFFER}
3404
+ now={NOW}
3405
+ timeZone="UTC"
3406
+ selected={["offer:before", "offer:after"]}
3407
+ />,
3408
+ )
3409
+ rerender(
3410
+ <ScheduleRoot
3411
+ data={OFFER}
3412
+ now={NOW}
3413
+ timeZone="UTC"
3414
+ selected={["offer:after", "offer:before"]}
3415
+ />,
3416
+ )
3417
+ expect(screen.getAllByRole("dialog")).toHaveLength(1)
3418
+ expect(chip("offer:after").getAttribute("aria-expanded")).toBe("true")
3419
+ expect(chip("offer:before").getAttribute("aria-expanded")).toBe("false")
3420
+ })
3421
+
3422
+ it("still reports the one chip that was pressed", () => {
3423
+ const onSelect = vi.fn()
3424
+ HTMLElement.prototype.setPointerCapture = vi.fn()
3425
+ render(
3426
+ <ScheduleRoot
3427
+ data={OFFER}
3428
+ now={NOW}
3429
+ timeZone="UTC"
3430
+ selected={["offer:before", "offer:after"]}
3431
+ onSelect={onSelect}
3432
+ />,
3433
+ )
3434
+ const el = chip("offer:after")
3435
+ fireEvent.pointerDown(el, { clientX: 0, clientY: 100, pointerId: 1, button: 0 })
3436
+ fireEvent.pointerUp(el, { clientX: 0, clientY: 100, pointerId: 1 })
3437
+ expect(onSelect).toHaveBeenCalledTimes(1)
3438
+ expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({ id: "offer:after" }))
3439
+ })
3440
+
3441
+ it("treats an empty list as nothing selected", () => {
3442
+ render(<ScheduleRoot data={OFFER} now={NOW} timeZone="UTC" selected={[]} />)
3443
+ expect(document.querySelector('[data-schedule-part="event-chip"][data-selected]')).toBeNull()
3444
+ expect(screen.queryByRole("dialog")).toBeNull()
3445
+ })
3446
+
3447
+ it("ignores the list with withSelection={false}", () => {
3448
+ render(
3449
+ <ScheduleRoot
3450
+ data={OFFER}
3451
+ now={NOW}
3452
+ timeZone="UTC"
3453
+ withSelection={false}
3454
+ selected={["offer:before", "offer:after"]}
3455
+ />,
3456
+ )
3457
+ expect(document.querySelector('[data-schedule-part="event-chip"][data-selected]')).toBeNull()
3458
+ })
3459
+
3460
+ it("does not re-arm the reveal when the same list is passed again as a fresh array", () => {
3461
+ // A consumer deriving `selected` builds a new array every render. The
3462
+ // reveal keys on the anchor id, so paging away and re-rendering must not
3463
+ // yank the view back to the selection.
3464
+ const far: ScheduleEvent[] = [
3465
+ {
3466
+ kind: "event",
3467
+ id: "far:a",
3468
+ title: "Far",
3469
+ start: day(2026, 2, 3, 9),
3470
+ end: day(2026, 2, 3, 10),
3471
+ },
3472
+ {
3473
+ kind: "event",
3474
+ id: "far:b",
3475
+ title: "Far",
3476
+ start: day(2026, 2, 3, 11),
3477
+ end: day(2026, 2, 3, 12),
3478
+ },
3479
+ ]
3480
+ const onDateChange = vi.fn()
3481
+ const { rerender } = render(
3482
+ <ScheduleRoot
3483
+ data={far}
3484
+ now={NOW}
3485
+ timeZone="UTC"
3486
+ selected={["far:a", "far:b"]}
3487
+ onDateChange={onDateChange}
3488
+ />,
3489
+ )
3490
+ expect(onDateChange).toHaveBeenCalledTimes(1)
3491
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
3492
+ expect(onDateChange).toHaveBeenCalledTimes(2)
3493
+ rerender(
3494
+ <ScheduleRoot
3495
+ data={far}
3496
+ now={NOW}
3497
+ timeZone="UTC"
3498
+ selected={["far:a", "far:b"]}
3499
+ onDateChange={onDateChange}
3500
+ />,
3501
+ )
3502
+ expect(onDateChange).toHaveBeenCalledTimes(2)
3503
+ })
3504
+
3505
+ it("paints several pills in Month and opens one popover", () => {
3506
+ render(
3507
+ <ScheduleRoot
3508
+ data={OFFER}
3509
+ now={NOW}
3510
+ timeZone="UTC"
3511
+ view="month"
3512
+ selected={["offer:before", "offer:after"]}
3513
+ />,
3514
+ )
3515
+ expect(chip("offer:before").hasAttribute("data-selected")).toBe(true)
3516
+ expect(chip("offer:after").hasAttribute("data-selected")).toBe(true)
3517
+ expect(screen.getAllByRole("dialog")).toHaveLength(1)
3518
+ })
3519
+
3520
+ it("paints several rows in the agenda and opens one popover", () => {
3521
+ render(
3522
+ <ScheduleRoot
3523
+ data={OFFER}
3524
+ now={NOW}
3525
+ timeZone="UTC"
3526
+ views={["days", "agenda"]}
3527
+ view="agenda"
3528
+ selected={["offer:before", "offer:after"]}
3529
+ />,
3530
+ )
3531
+ const rows = document.querySelectorAll('[data-schedule-part="agenda-event"][data-selected]')
3532
+ expect(rows).toHaveLength(2)
3533
+ expect(screen.getAllByRole("dialog")).toHaveLength(1)
3534
+ })
3535
+ })
3536
+
3537
+ /**
3538
+ * A multi-day event is several pieces sharing one id. Every piece is painted
3539
+ * selected, but only one may open the details popover: the pressed piece,
3540
+ * else the first on screen. Each used to open its own.
3541
+ */
3542
+ describe("ScheduleRoot — one popover per multi-piece event", () => {
3543
+ // Monday 22:00 UTC → Wednesday 02:00 UTC: a piece on Mon, Tue and Wed.
3544
+ const LONG: ScheduleEvent[] = [
3545
+ {
3546
+ kind: "event",
3547
+ id: "long",
3548
+ title: "Night watch",
3549
+ start: day(2026, 0, 12, 22),
3550
+ end: day(2026, 0, 14, 2),
3551
+ },
3552
+ ]
3553
+ const MONDAY = day(2026, 0, 12, 12)
3554
+ const expanded = (id: string) =>
3555
+ screen.getAllByTestId(id).map((el) => el.getAttribute("aria-expanded"))
3556
+ const press = (el: HTMLElement) => {
3557
+ HTMLElement.prototype.setPointerCapture = vi.fn()
3558
+ fireEvent.pointerDown(el, { clientX: 0, clientY: 100, pointerId: 1, button: 0 })
3559
+ fireEvent.pointerUp(el, { clientX: 0, clientY: 100, pointerId: 1 })
3560
+ }
3561
+
3562
+ it("opens one popover, on the first piece, for a selection from outside", () => {
3563
+ render(<ScheduleRoot data={LONG} now={MONDAY} timeZone="UTC" view="days" selected="long" />)
3564
+ expect(screen.getAllByTestId("long")).toHaveLength(3)
3565
+ expect(screen.getAllByRole("dialog")).toHaveLength(1)
3566
+ expect(expanded("long")).toEqual(["true", "false", "false"])
3567
+ })
3568
+
3569
+ it("opens it on the piece that was pressed", async () => {
3570
+ render(<ScheduleRoot data={LONG} now={MONDAY} timeZone="UTC" view="days" />)
3571
+ press(screen.getAllByTestId("long")[1] as HTMLElement)
3572
+ for (const el of screen.getAllByTestId("long")) {
3573
+ expect(el.hasAttribute("data-selected")).toBe(true)
3574
+ }
3575
+ // The panel is lazy-mounted, so it lands a tick after the press.
3576
+ expect(await screen.findAllByRole("dialog")).toHaveLength(1)
3577
+ expect(expanded("long")).toEqual(["false", "true", "false"])
3578
+ })
3579
+
3580
+ it("keeps it on the pressed piece under a controlled selection", async () => {
3581
+ function Controlled() {
3582
+ const [selected, setSelected] = useState<string | null>(null)
3583
+ return (
3584
+ <ScheduleRoot
3585
+ data={LONG}
3586
+ now={MONDAY}
3587
+ timeZone="UTC"
3588
+ view="days"
3589
+ selected={selected}
3590
+ onSelect={(event) => setSelected(event?.id ?? null)}
3591
+ />
3592
+ )
3593
+ }
3594
+ render(<Controlled />)
3595
+ press(screen.getAllByTestId("long")[2] as HTMLElement)
3596
+ expect(await screen.findAllByRole("dialog")).toHaveLength(1)
3597
+ expect(expanded("long")).toEqual(["false", "false", "true"])
3598
+ })
3599
+
3600
+ it("still opens one when the event is also part of a multi-id selection", () => {
3601
+ render(
3602
+ <ScheduleRoot
3603
+ data={[...LONG, ...EVENTS]}
3604
+ now={MONDAY}
3605
+ timeZone="UTC"
3606
+ view="days"
3607
+ selected={["long", "e1"]}
3608
+ />,
3609
+ )
3610
+ expect(screen.getAllByRole("dialog")).toHaveLength(1)
3611
+ expect(expanded("long")).toEqual(["true", "false", "false"])
3612
+ })
3613
+
3614
+ it("opens one popover in Month, on the pressed pill", async () => {
3615
+ const fortnight: ScheduleEvent[] = [
3616
+ {
3617
+ kind: "event",
3618
+ id: "piscine",
3619
+ title: "Piscine",
3620
+ start: day(2026, 0, 5),
3621
+ end: day(2026, 0, 17),
3622
+ allDay: true,
3623
+ },
3624
+ ]
3625
+ render(<ScheduleRoot data={fortnight} now={MONDAY} timeZone="UTC" view="month" />)
3626
+ const pills = screen.getAllByTestId("piscine")
3627
+ expect(pills.length).toBeGreaterThan(2)
3628
+ fireEvent.click(pills[3] as HTMLElement)
3629
+ expect(await screen.findAllByRole("dialog")).toHaveLength(1)
3630
+ expect(expanded("piscine").indexOf("true")).toBe(3)
3631
+ })
3632
+ })
3633
+
3634
+ /**
3635
+ * The reveal rule's date axis. The scroll axis is invisible to jsdom —
3636
+ * `test-setup.ts` stubs every rect to a constant and `scrollTo` to a no-op —
3637
+ * so it is verified in a real browser instead.
3638
+ */
3639
+ describe("ScheduleRoot — reveal on select", () => {
3640
+ const FAR: ScheduleEvent[] = [
3641
+ {
3642
+ kind: "event",
3643
+ id: "far",
3644
+ title: "Far away",
3645
+ start: day(2026, 2, 3, 9),
3646
+ end: day(2026, 2, 3, 10),
3647
+ },
3648
+ ]
3649
+
3650
+ it("moves the anchor to an event that is not in the visible range", () => {
3651
+ const onDateChange = vi.fn()
3652
+ render(
3653
+ <ScheduleRoot
3654
+ data={FAR}
3655
+ now={NOW}
3656
+ timeZone="UTC"
3657
+ selected="far"
3658
+ onDateChange={onDateChange}
3659
+ />,
3660
+ )
3661
+ expect(onDateChange).toHaveBeenCalledWith(FAR[0]?.start)
3662
+ })
3663
+
3664
+ it("leaves the anchor alone for an event already in range", () => {
3665
+ const onDateChange = vi.fn()
3666
+ render(
3667
+ <ScheduleRoot
3668
+ data={EVENTS}
3669
+ now={NOW}
3670
+ timeZone="UTC"
3671
+ selected="e1"
3672
+ onDateChange={onDateChange}
3673
+ />,
3674
+ )
3675
+ expect(onDateChange).not.toHaveBeenCalled()
3676
+ })
3677
+
3678
+ /** The case an `event.start` test gets wrong: the event is on screen every
3679
+ * day of the window, so anchoring to its start would page *away* from it. */
3680
+ it("leaves the anchor alone for a long event that merely starts before the window", () => {
3681
+ const onDateChange = vi.fn()
3682
+ const spanning: ScheduleEvent[] = [
3683
+ {
3684
+ kind: "event",
3685
+ id: "span",
3686
+ title: "Long haul",
3687
+ start: day(2025, 11, 20),
3688
+ end: day(2026, 1, 20),
3689
+ allDay: true,
3690
+ },
3691
+ ]
3692
+ render(
3693
+ <ScheduleRoot
3694
+ data={spanning}
3695
+ now={NOW}
3696
+ timeZone="UTC"
3697
+ selected="span"
3698
+ onDateChange={onDateChange}
3699
+ />,
3700
+ )
3701
+ expect(onDateChange).not.toHaveBeenCalled()
3702
+ })
3703
+
3704
+ /** Armed by selection alone — otherwise paging away from a selected event
3705
+ * would drag the user straight back to it. */
3706
+ it("does not re-reveal when the date changes on its own", () => {
3707
+ const onDateChange = vi.fn()
3708
+ render(
3709
+ <ScheduleRoot
3710
+ data={EVENTS}
3711
+ now={NOW}
3712
+ timeZone="UTC"
3713
+ defaultSelected="e1"
3714
+ onDateChange={onDateChange}
3715
+ />,
3716
+ )
3717
+ onDateChange.mockClear()
3718
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
3719
+ // Exactly one call: the page turn itself. No second, corrective one.
3720
+ expect(onDateChange).toHaveBeenCalledTimes(1)
3721
+ })
3722
+ })
3723
+
3724
+ /**
3725
+ * The agenda renderer under `Root` — that it is a switcher entry at all, and
3726
+ * that the month-windowed chrome `Root` feeds it is coherent. The view's own
3727
+ * rendering is covered in `schedule-agenda-view.test.tsx`.
3728
+ */
3729
+ describe("ScheduleRoot — the agenda view", () => {
3730
+ const tabNames = () => screen.queryAllByRole("tab").map((el) => el.textContent?.trim() ?? "")
3731
+ const title = () =>
3732
+ document.querySelector('[data-schedule-part="toolbar-title"]')?.textContent ?? ""
3733
+ const agenda = () => document.querySelector('[data-schedule-part="agenda-view"]')
3734
+ const rowIds = () =>
3735
+ Array.from(
3736
+ document.querySelectorAll<HTMLElement>(
3737
+ '[data-schedule-part="agenda-list"] [data-schedule-part="agenda-event"]',
3738
+ ),
3739
+ ).map((el) => el.dataset["eventId"])
3740
+
3741
+ const SEPT: ScheduleEvent[] = [
3742
+ {
3743
+ kind: "event",
3744
+ id: "sept",
3745
+ title: "Sept planning",
3746
+ start: day(2026, 8, 10, 9),
3747
+ end: day(2026, 8, 10, 10),
3748
+ },
3749
+ {
3750
+ kind: "event",
3751
+ id: "oct",
3752
+ title: "Oct retro",
3753
+ start: day(2026, 9, 10, 9),
3754
+ end: day(2026, 9, 10, 10),
3755
+ },
3756
+ ]
3757
+ const SEPT_NOW = day(2026, 8, 15, 12)
3758
+
3759
+ it("offers an Agenda tab when `views` asks for one", async () => {
3760
+ render(<ScheduleRoot data={[]} now={NOW} timeZone="UTC" views={["week", "agenda", "month"]} />)
3761
+ await new Promise((r) => setTimeout(r, 0))
3762
+ expect(tabNames()).toEqual(["Week", "Agenda", "Month"])
3763
+ })
3764
+
3765
+ it("renders the agenda, titled and windowed by month", () => {
3766
+ render(
3767
+ <ScheduleRoot
3768
+ data={SEPT}
3769
+ now={SEPT_NOW}
3770
+ timeZone="UTC"
3771
+ locale="en-GB"
3772
+ views={["agenda", "month"]}
3773
+ />,
3774
+ )
3775
+ expect(agenda()).not.toBeNull()
3776
+ expect(title()).toBe("September 2026")
3777
+ expect(rowIds()).toEqual(["sept"])
3778
+ })
3779
+
3780
+ it("steps a month per Prev/Next from Root's own toolbar", () => {
3781
+ render(
3782
+ <ScheduleRoot
3783
+ data={SEPT}
3784
+ now={SEPT_NOW}
3785
+ timeZone="UTC"
3786
+ locale="en-GB"
3787
+ views={["agenda", "month"]}
3788
+ />,
3789
+ )
3790
+ fireEvent.click(screen.getByRole("button", { name: "Next" }))
3791
+ expect(title()).toBe("October 2026")
3792
+ expect(rowIds()).toEqual(["oct"])
3793
+ })
3794
+
3795
+ it("suppresses the view's own pagination chrome", () => {
3796
+ render(<ScheduleRoot data={[]} now={SEPT_NOW} timeZone="UTC" views={["agenda", "month"]} />)
3797
+ // Root's toolbar supplies exactly one of each.
3798
+ expect(screen.getAllByRole("button", { name: "Next" })).toHaveLength(1)
3799
+ expect(screen.getAllByRole("button", { name: "Previous" })).toHaveLength(1)
3800
+ })
3801
+
3802
+ it("reports a row click through Root's own onSelect", () => {
3803
+ const onSelect = vi.fn()
3804
+ render(
3805
+ <ScheduleRoot
3806
+ data={SEPT}
3807
+ now={SEPT_NOW}
3808
+ timeZone="UTC"
3809
+ locale="en-GB"
3810
+ views={["agenda"]}
3811
+ onSelect={onSelect}
3812
+ />,
3813
+ )
3814
+ const control = document.querySelector<HTMLElement>(
3815
+ '[data-schedule-part="agenda-event-trigger"]',
3816
+ )
3817
+ if (control) fireEvent.click(control)
3818
+ expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({ id: "sept" }))
3819
+ })
3820
+
3821
+ /**
3822
+ * The load-bearing integration: `Root`'s reveal effect asks
3823
+ * `isEventInVisibleRange`, which resolves the agenda's strict month — so a
3824
+ * selection outside the window pages to it with no agenda-specific code in
3825
+ * `Root` at all. It is tested precisely *because* nothing implements it.
3826
+ */
3827
+ it("pages to a selection outside the current month", () => {
3828
+ const onDateChange = vi.fn()
3829
+ render(
3830
+ <ScheduleRoot
3831
+ data={SEPT}
3832
+ now={SEPT_NOW}
3833
+ timeZone="UTC"
3834
+ views={["agenda"]}
3835
+ selected="oct"
3836
+ onDateChange={onDateChange}
3837
+ />,
3838
+ )
3839
+ expect(onDateChange).toHaveBeenCalledWith(SEPT[1]?.start)
3840
+ })
3841
+
3842
+ it("leaves the anchor alone for a selection already in the month", () => {
3843
+ const onDateChange = vi.fn()
3844
+ render(
3845
+ <ScheduleRoot
3846
+ data={SEPT}
3847
+ now={SEPT_NOW}
3848
+ timeZone="UTC"
3849
+ views={["agenda"]}
3850
+ selected="sept"
3851
+ onDateChange={onDateChange}
3852
+ />,
3853
+ )
3854
+ expect(onDateChange).not.toHaveBeenCalled()
3855
+ })
3856
+
3857
+ it("carries a custom entry id rather than the renderer name", async () => {
3858
+ const onViewChange = vi.fn()
3859
+ render(
3860
+ <ScheduleRoot
3861
+ data={[]}
3862
+ now={SEPT_NOW}
3863
+ timeZone="UTC"
3864
+ views={["month", { id: "upcoming", view: "agenda", label: "Upcoming" }]}
3865
+ onViewChange={onViewChange}
3866
+ />,
3867
+ )
3868
+ await new Promise((r) => setTimeout(r, 0))
3869
+ fireEvent.click(screen.getByRole("tab", { name: "Upcoming" }))
3870
+ await waitFor(() => expect(agenda()).not.toBeNull())
3871
+ // The *id*, never the renderer name — the whole point of the id/renderer
3872
+ // split once one schedule can name its agenda whatever it likes.
3873
+ expect(onViewChange).toHaveBeenCalledWith("upcoming")
3874
+ })
3875
+ })
3876
+
3877
+ /**
3878
+ * `maxEventsPerDay` reaching Month *through* `Root`. Month-only, and `Root` is
3879
+ * the only composition with a view switcher, so before this was forwarded the
3880
+ * common case was pinned to the default `3` — the escape hatch was to abandon
3881
+ * `Root` and hand-compose `Schedule.Toolbar` around a standalone `MonthView`.
3882
+ *
3883
+ * Both halves matter, and the second is the one that actually unclips a short
3884
+ * container: the cap slices the chip list, *and* it sets each row's height
3885
+ * floor (`monthRowMinHeight`), which is what keeps the cell's own
3886
+ * `overflow-hidden` from eating the last pill and the "+N" chip with it.
3887
+ */
3888
+ describe("ScheduleRoot — month chip cap", () => {
3889
+ const FIVE: ScheduleStaticEvent[] = [8, 9, 10, 11, 12].map((h) => ({
3890
+ kind: "static",
3891
+ id: `m${h}`,
3892
+ title: `M${h}`,
3893
+ start: day(2026, 0, 15, h),
3894
+ end: day(2026, 0, 15, h + 1),
3895
+ }))
3896
+
3897
+ const renderMonth = (maxEventsPerDay?: number) =>
3898
+ render(
3899
+ <ScheduleRoot
3900
+ data={[]}
3901
+ staticEvents={FIVE}
3902
+ now={NOW}
3903
+ timeZone="UTC"
3904
+ defaultView="month"
3905
+ maxEventsPerDay={maxEventsPerDay}
3906
+ />,
3907
+ ).container
3908
+
3909
+ it("caps the day's chip list and counts the rest into the '+N' chip", () => {
3910
+ const container = renderMonth(2)
3911
+ const cell = container.querySelector('[data-testid="day-2026-01-15"]')
3912
+ expect(cell?.querySelectorAll('[data-schedule-part="event-chip"]')).toHaveLength(2)
3913
+ expect(cell?.querySelector('[data-schedule-part="month-overflow-chip"]')?.textContent).toBe(
3914
+ "+3",
3915
+ )
3916
+ })
3917
+
3918
+ it("carries the cap into the row-height floor, so the cap it promises fits", () => {
3919
+ const rows = (container: Element) =>
3920
+ container.querySelector<HTMLElement>('[style*="grid-template-rows"]')?.style
3921
+ .gridTemplateRows ?? ""
3922
+ // Two pills + the "+N" chip, against three + it: exactly one pill's box
3923
+ // (1rem line + py-0.5 + a 2px border + one gap-0.5) shorter.
3924
+ expect(rows(renderMonth(2))).toBe("auto repeat(5, minmax(calc(5.625rem + 6px), 1fr))")
3925
+ expect(rows(renderMonth(3))).toBe("auto repeat(5, minmax(calc(7rem + 8px), 1fr))")
3926
+ })
3927
+
3928
+ it("leaves the default where it already lives — MonthView's own `3`", () => {
3929
+ // `Root` destructures the prop without a default of its own, so omitting
3930
+ // it here must be indistinguishable from the standalone default. A second
3931
+ // default on `Root` would silently fork the two.
3932
+ const omitted = renderMonth(undefined)
3933
+ const explicit = renderMonth(3)
3934
+ const chips = (container: Element) =>
3935
+ container
3936
+ .querySelector('[data-testid="day-2026-01-15"]')
3937
+ ?.querySelectorAll('[data-schedule-part="event-chip"]').length
3938
+ expect(chips(omitted)).toBe(3)
3939
+ expect(chips(omitted)).toBe(chips(explicit))
3940
+ })
3941
+ })
3942
+
3943
+ /**
3944
+ * Prop scoping — `ScheduleProps` gates each slice on `views` actually
3945
+ * configuring a renderer that reads it (`lib/available-if.ts`).
3946
+ *
3947
+ * Most of this block is type-level: the elements are constructed and never
3948
+ * rendered, and `pnpm typecheck` is what enforces them. A bare
3949
+ * `@ts-expect-error` passes if the line errors for *any* reason, so every
3950
+ * negative case is paired with a positive twin — the same element with the
3951
+ * offending prop removed — which fails the typecheck if the rest of the line
3952
+ * ever stops being well-formed.
3953
+ *
3954
+ * Two of the cases exist specifically to catch traps that compile clean while
3955
+ * being wrong: a mixed `views` literal (which a tuple-wrapped renderer
3956
+ * projection resolves to `never`, silently forbidding everything), and
3957
+ * `dayDisabled` under `views={["days","month"]}` (which an "all of" gate
3958
+ * wrongly rejects even though Month is rendering). A suite that only covered
3959
+ * the uniform all-shorthand tuples would pass with either bug in place.
3960
+ */
3961
+ describe("ScheduleRoot — prop scoping", () => {
3962
+ const noop = () => {}
3963
+
3964
+ it("keeps every prop when `views` is omitted — the default call site is untouched", () => {
3965
+ const el = (
3966
+ <ScheduleRoot
3967
+ data={[]}
3968
+ slotDuration={30}
3969
+ editable={["drag"]}
3970
+ onEventChange={noop}
3971
+ onMonthClick={noop}
3972
+ maxEventsPerDay={4}
3973
+ dayDisabled={() => false}
3974
+ onDayClick={noop}
3975
+ align="relative"
3976
+ />
3977
+ )
3978
+ expect(el).toBeTruthy()
3979
+ })
3980
+
3981
+ it("rejects a days-only prop when no entry renders the days grid", () => {
3982
+ const ok = <ScheduleRoot data={[]} views={["month", "year"]} dayDisabled={() => false} />
3983
+ // @ts-expect-error `slotDuration` needs a days/day/week entry — ScheduleRenderers
3984
+ const bad = <ScheduleRoot data={[]} views={["month", "year"]} slotDuration={30} />
3985
+ // @ts-expect-error `maxDuration` caps days-grid gestures only
3986
+ const noCap = <ScheduleRoot data={[]} views={["month"]} maxDuration={120} />
3987
+ // @ts-expect-error `minDuration` floors days-grid gestures only
3988
+ const noFloor = <ScheduleRoot data={[]} views={["month"]} minDuration={60} />
3989
+ expect([ok, bad, noCap, noFloor]).toHaveLength(4)
3990
+ })
3991
+
3992
+ it("checks `minDuration`/`maxDuration` against the `slotDuration` beside them", () => {
3993
+ const ok = <ScheduleRoot data={[]} slotDuration={30} minDuration={60} maxDuration={240} />
3994
+ const defaultSlot = <ScheduleRoot data={[]} minDuration={45} />
3995
+ const pastADay = <ScheduleRoot data={[]} slotDuration={60} maxDuration={2880} />
3996
+ // @ts-expect-error only 15, 30 or 60
3997
+ const oddSlot = <ScheduleRoot data={[]} slotDuration={5} />
3998
+ // @ts-expect-error 45 is not a whole number of 30-minute slots
3999
+ const offGrid = <ScheduleRoot data={[]} slotDuration={30} minDuration={45} />
4000
+ // @ts-expect-error nor is 90 of 60-minute ones
4001
+ const offGridCap = <ScheduleRoot data={[]} slotDuration={60} maxDuration={90} />
4002
+ // @ts-expect-error the default slot is 15, and 20 is not a multiple of it
4003
+ const offDefault = <ScheduleRoot data={[]} minDuration={20} />
4004
+ // The standalone views carry the same check through their own `Omit`.
4005
+ const day = <DayView data={[]} slotDuration={30} minDuration={90} />
4006
+ // @ts-expect-error `DayViewProps` must not collapse the union
4007
+ const dayOffGrid = <DayView data={[]} slotDuration={30} minDuration={45} />
4008
+ // @ts-expect-error nor may `WeekViewProps`
4009
+ const weekOffGrid = <WeekView data={[]} slotDuration={60} minDuration={30} />
4010
+ // Values read at runtime are `number`s: refused as they are, accepted once
4011
+ // the guard has checked them together.
4012
+ const rules = { slotDuration: 15 as number, minDuration: 30 as number }
4013
+ // @ts-expect-error a bare `number` could be anything
4014
+ const unchecked = <ScheduleRoot data={[]} {...rules} />
4015
+ const checked = isScheduleSlotProps(rules) ? <ScheduleRoot data={[]} {...rules} /> : null
4016
+ expect([unchecked, checked]).toHaveLength(2)
4017
+ expect([
4018
+ ok,
4019
+ defaultSlot,
4020
+ pastADay,
4021
+ oddSlot,
4022
+ offGrid,
4023
+ offGridCap,
4024
+ offDefault,
4025
+ day,
4026
+ dayOffGrid,
4027
+ weekOffGrid,
4028
+ ]).toHaveLength(10)
4029
+ })
4030
+
4031
+ it("rejects `onMonthClick` without a year entry, and `renderDayDetails` without a month one", () => {
4032
+ const ok = <ScheduleRoot data={[]} views={["year"]} onMonthClick={noop} />
4033
+ // @ts-expect-error no year entry
4034
+ const noYear = <ScheduleRoot data={[]} views={["days"]} onMonthClick={noop} />
4035
+ // @ts-expect-error no month entry
4036
+ const noMonth = <ScheduleRoot data={[]} views={["days"]} renderDayDetails={() => null} />
4037
+ // @ts-expect-error no month entry
4038
+ const noCap = <ScheduleRoot data={[]} views={["days"]} maxEventsPerDay={4} />
4039
+ expect([ok, noYear, noMonth, noCap]).toHaveLength(4)
4040
+ })
4041
+
4042
+ it("rejects `renderEvent` under the default views, which exclude the agenda", () => {
4043
+ const ok = <ScheduleRoot data={[]} views={["days", "agenda"]} renderEvent={() => null} />
4044
+ // @ts-expect-error `DEFAULT_SCHEDULE_VIEWS` has no agenda entry
4045
+ const bad = <ScheduleRoot data={[]} renderEvent={() => null} />
4046
+ expect([ok, bad]).toHaveLength(2)
4047
+ })
4048
+
4049
+ it("allows `dayDisabled` when only one of month/year is configured — the gate is 'any of'", () => {
4050
+ // Guards the trap: `[R] extends [ScheduleRenderers<V>]` would read as "all
4051
+ // of R" and reject this, even though Month is rendering and reads it.
4052
+ const el = <ScheduleRoot data={[]} views={["days", "month"]} dayDisabled={() => false} />
4053
+ expect(el).toBeTruthy()
4054
+ })
4055
+
4056
+ it("resolves a mixed literal rather than collapsing it to `never`", () => {
4057
+ // Guards the trap: tuple-wrapping the renderer projection makes this
4058
+ // `never`, which forbids *every* scoped prop while still answering
4059
+ // correctly for the uniform tuples above.
4060
+ const el = (
4061
+ <ScheduleRoot
4062
+ data={[]}
4063
+ views={["day", { id: "quarter", view: "year" }]}
4064
+ slotDuration={30}
4065
+ onMonthClick={noop}
4066
+ />
4067
+ )
4068
+ const bad = (
4069
+ <ScheduleRoot
4070
+ data={[]}
4071
+ views={["day", { id: "quarter", view: "year" }]}
4072
+ // @ts-expect-error neither entry renders a month
4073
+ maxEventsPerDay={4}
4074
+ />
4075
+ )
4076
+ expect([el, bad]).toHaveLength(2)
4077
+ })
4078
+
4079
+ it("narrows `align`'s own type, not just its availability", () => {
4080
+ const ok = <ScheduleRoot data={[]} views={["month"]} align="mon" />
4081
+ // @ts-expect-error `"relative"` is a rolling days window; Month has no use for one
4082
+ const bad = <ScheduleRoot data={[]} views={["month"]} align="relative" />
4083
+ expect([ok, bad]).toHaveLength(2)
4084
+ })
4085
+
4086
+ it("still requires a granted gesture's callback, and forbids the pair without a days grid", () => {
4087
+ const ok = <ScheduleRoot data={[]} views={["days"]} editable={["drag"]} onEventChange={noop} />
4088
+ // @ts-expect-error `editable: ["drag"]` makes `onEventChange` required
4089
+ const missing = <ScheduleRoot data={[]} views={["days"]} editable={["drag"]} />
4090
+ // @ts-expect-error nothing is editable without a timed grid
4091
+ const noGrid = <ScheduleRoot data={[]} views={["month"]} editable onEventChange={noop} />
4092
+ expect([ok, missing, noGrid]).toHaveLength(3)
4093
+ })
4094
+
4095
+ it("accepts the overflow trio under month, and rejects it under year", () => {
4096
+ const ok = (
4097
+ <ScheduleRoot
4098
+ data={[]}
4099
+ views={["month"]}
4100
+ onOverflowClick={noop}
4101
+ withOverflowDetails={false}
4102
+ renderOverflowDetails={() => null}
4103
+ />
4104
+ )
4105
+ // @ts-expect-error Year caps nothing, so it has no "+N" to disclose
4106
+ const bad = <ScheduleRoot data={[]} views={["year"]} onOverflowClick={noop} />
4107
+ // @ts-expect-error same — the agenda is an unbounded list
4108
+ const alsoBad = <ScheduleRoot data={[]} views={["agenda"]} withOverflowDetails={false} />
4109
+ expect([ok, bad, alsoBad]).toHaveLength(3)
4110
+ })
4111
+
4112
+ it("keeps every prop for a `views` array it cannot resolve — it fails open", () => {
4113
+ const dynamic: ScheduleViewOption[] = ["month", "year"]
4114
+ const el = (
4115
+ <ScheduleRoot
4116
+ data={[]}
4117
+ views={dynamic}
4118
+ slotDuration={30}
4119
+ onMonthClick={noop}
4120
+ maxEventsPerDay={4}
4121
+ />
4122
+ )
4123
+ const empty = <ScheduleRoot data={[]} views={[]} slotDuration={30} />
4124
+ expect([el, empty]).toHaveLength(2)
4125
+ })
4126
+
4127
+ it("keeps the generic through the Object.assign namespace", () => {
4128
+ // Nothing else in this package renders through the barrel, and an erased
4129
+ // call signature would pin `V` to the default and only show up here.
4130
+ const ok = <Schedule data={[]} views={["month", "year"]} view="month" />
4131
+ // @ts-expect-error `"days"` is not one of the configured ids
4132
+ const bad = <Schedule data={[]} views={["month", "year"]} view="days" />
4133
+ expect([ok, bad]).toHaveLength(2)
4134
+ })
4135
+
4136
+ it("warns at runtime for a `views` array the type layer had to widen open", () => {
4137
+ const warn = vi.spyOn(console, "warn").mockImplementation(() => {})
4138
+ // A `ScheduleViewOption[]` can't be resolved at compile time, so the gates
4139
+ // permit everything — this is the only layer left that can say anything.
4140
+ const dynamic: ScheduleViewOption[] = ["month", "year"]
4141
+ render(
4142
+ <ScheduleRoot
4143
+ data={[]}
4144
+ now={NOW}
4145
+ timeZone="UTC"
4146
+ views={dynamic}
4147
+ slotDuration={30}
4148
+ onGridClick={noop}
4149
+ />,
4150
+ )
4151
+ expect(warn).toHaveBeenCalledWith(
4152
+ expect.stringContaining("`slotDuration` and `onGridClick` are ignored"),
4153
+ )
4154
+ expect(warn).toHaveBeenCalledWith(
4155
+ expect.stringContaining("no `views` entry renders the `days` view"),
4156
+ )
4157
+ warn.mockRestore()
4158
+ })
4159
+
4160
+ it("does not warn when every passed prop has a renderer that reads it", () => {
4161
+ const warn = vi.spyOn(console, "warn").mockImplementation(() => {})
4162
+ const dynamic: ScheduleViewOption[] = ["month", "year"]
4163
+ render(
4164
+ <ScheduleRoot data={[]} now={NOW} timeZone="UTC" views={dynamic} dayDisabled={() => false} />,
4165
+ )
4166
+ expect(warn).not.toHaveBeenCalledWith(expect.stringContaining("ignored"))
4167
+ warn.mockRestore()
4168
+ })
4169
+ })
4170
+
4171
+ describe("ScheduleRoot — minDuration", () => {
4172
+ /** 2880px over 1440 minutes = 2px/min, one 100px column per day. */
4173
+ const layOutColumns = () => {
4174
+ for (const column of document.querySelectorAll<HTMLElement>(
4175
+ "[data-schedule-part='day-column'][data-day-index]",
4176
+ )) {
4177
+ const index = Number(column.dataset["dayIndex"])
4178
+ vi.spyOn(column, "getBoundingClientRect").mockReturnValue({
4179
+ top: 0,
4180
+ bottom: 2880,
4181
+ height: 2880,
4182
+ left: index * 100,
4183
+ right: index * 100 + 100,
4184
+ width: 100,
4185
+ } as DOMRect)
4186
+ }
4187
+ }
4188
+
4189
+ const columnAt = (index: number) =>
4190
+ document.querySelectorAll<HTMLElement>("[data-schedule-part='day-column']")[
4191
+ index
4192
+ ] as HTMLElement
4193
+
4194
+ const setUp = () => {
4195
+ HTMLElement.prototype.setPointerCapture = vi.fn()
4196
+ HTMLElement.prototype.releasePointerCapture = vi.fn()
4197
+ }
4198
+
4199
+ it("grows a create shorter than the floor up to it", () => {
4200
+ setUp()
4201
+ const onEventCreate = vi.fn()
4202
+ render(
4203
+ <ScheduleRoot
4204
+ data={[]}
4205
+ now={NOW}
4206
+ timeZone="UTC"
4207
+ slotDuration={30}
4208
+ minDuration={60}
4209
+ editable={["create"]}
4210
+ onEventCreate={onEventCreate}
4211
+ />,
4212
+ )
4213
+ layOutColumns()
4214
+ // Thu Jan 15 is column 4. 10:00 → 10:20 is a 20-minute drag.
4215
+ const col = columnAt(4)
4216
+ fireEvent.pointerDown(col, {
4217
+ clientX: 450,
4218
+ clientY: 1200,
4219
+ pointerId: 1,
4220
+ button: 0,
4221
+ pointerType: "mouse",
4222
+ })
4223
+ fireEvent.pointerMove(col, { clientX: 450, clientY: 1240, pointerId: 1 })
4224
+ fireEvent.pointerUp(col, { clientX: 450, clientY: 1240, pointerId: 1 })
4225
+
4226
+ expect(onEventCreate).toHaveBeenCalledWith([
4227
+ { start: day(2026, 0, 15, 10), end: day(2026, 0, 15, 11) },
4228
+ ])
4229
+ })
4230
+
4231
+ it("stops a resize grip a whole floor away from the other edge", () => {
4232
+ setUp()
4233
+ const onEventChange = vi.fn()
4234
+ render(
4235
+ <ScheduleRoot
4236
+ data={[
4237
+ {
4238
+ kind: "event",
4239
+ id: "long",
4240
+ title: "Long",
4241
+ start: day(2026, 0, 15, 9),
4242
+ end: day(2026, 0, 15, 11),
4243
+ },
4244
+ ]}
4245
+ now={NOW}
4246
+ timeZone="UTC"
4247
+ slotDuration={30}
4248
+ minDuration={60}
4249
+ editable={["resize"]}
4250
+ onEventChange={onEventChange}
4251
+ />,
4252
+ )
4253
+ layOutColumns()
4254
+ const handle = screen
4255
+ .getByTestId("long")
4256
+ .querySelectorAll<HTMLElement>("[data-schedule-part='resize-handle']")[1] as HTMLElement
4257
+ // Drag the 11:00 end up to 09:00 (1320px → 1080px): it must stop at 10:00.
4258
+ fireEvent.pointerDown(handle, { clientX: 450, clientY: 1320, pointerId: 1, button: 0 })
4259
+ fireEvent.pointerMove(handle, { clientX: 450, clientY: 1080, pointerId: 1 })
4260
+ fireEvent.pointerUp(handle, { clientX: 450, clientY: 1080, pointerId: 1 })
4261
+
4262
+ expect(onEventChange).toHaveBeenCalledWith(
4263
+ expect.objectContaining({ id: "long" }),
4264
+ { start: day(2026, 0, 15, 9), end: day(2026, 0, 15, 10) },
4265
+ "resize",
4266
+ )
4267
+ })
4268
+ })