@cdx-ui/primitives 0.0.1-beta.140 → 0.0.1-beta.141

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 (384) hide show
  1. package/lib/commonjs/calendar/CalendarGrid.js +33 -0
  2. package/lib/commonjs/calendar/CalendarGrid.js.map +1 -0
  3. package/lib/commonjs/calendar/CalendarRoot.js +95 -0
  4. package/lib/commonjs/calendar/CalendarRoot.js.map +1 -0
  5. package/lib/commonjs/calendar/context.js +17 -0
  6. package/lib/commonjs/calendar/context.js.map +1 -0
  7. package/lib/commonjs/calendar/index.js +27 -0
  8. package/lib/commonjs/calendar/index.js.map +1 -0
  9. package/lib/commonjs/calendar/types.js +6 -0
  10. package/lib/commonjs/calendar/types.js.map +1 -0
  11. package/lib/commonjs/date-field/DateFieldHiddenInput.js +148 -0
  12. package/lib/commonjs/date-field/DateFieldHiddenInput.js.map +1 -0
  13. package/lib/commonjs/date-field/DateFieldInput.js +122 -0
  14. package/lib/commonjs/date-field/DateFieldInput.js.map +1 -0
  15. package/lib/commonjs/date-field/DateFieldRoot.js +85 -0
  16. package/lib/commonjs/date-field/DateFieldRoot.js.map +1 -0
  17. package/lib/commonjs/date-field/DateFieldSegment.js +92 -0
  18. package/lib/commonjs/date-field/DateFieldSegment.js.map +1 -0
  19. package/lib/commonjs/date-field/context.js +19 -0
  20. package/lib/commonjs/date-field/context.js.map +1 -0
  21. package/lib/commonjs/date-field/index.js +34 -0
  22. package/lib/commonjs/date-field/index.js.map +1 -0
  23. package/lib/commonjs/date-field/segmentIndex.js +23 -0
  24. package/lib/commonjs/date-field/segmentIndex.js.map +1 -0
  25. package/lib/commonjs/date-field/segmentKeyboard.js +169 -0
  26. package/lib/commonjs/date-field/segmentKeyboard.js.map +1 -0
  27. package/lib/commonjs/date-field/types.js +6 -0
  28. package/lib/commonjs/date-field/types.js.map +1 -0
  29. package/lib/commonjs/date-field/useDateFieldSegmentState.js +381 -0
  30. package/lib/commonjs/date-field/useDateFieldSegmentState.js.map +1 -0
  31. package/lib/commonjs/date-field/useRangeDateFieldBridge.js +67 -0
  32. package/lib/commonjs/date-field/useRangeDateFieldBridge.js.map +1 -0
  33. package/lib/commonjs/date-picker/DatePickerRoot.js +123 -0
  34. package/lib/commonjs/date-picker/DatePickerRoot.js.map +1 -0
  35. package/lib/commonjs/date-picker/context.js +17 -0
  36. package/lib/commonjs/date-picker/context.js.map +1 -0
  37. package/lib/commonjs/date-picker/index.js +26 -0
  38. package/lib/commonjs/date-picker/index.js.map +1 -0
  39. package/lib/commonjs/date-range-picker/DateRangePickerRoot.js +144 -0
  40. package/lib/commonjs/date-range-picker/DateRangePickerRoot.js.map +1 -0
  41. package/lib/commonjs/date-range-picker/context.js +23 -0
  42. package/lib/commonjs/date-range-picker/context.js.map +1 -0
  43. package/lib/commonjs/date-range-picker/index.js +26 -0
  44. package/lib/commonjs/date-range-picker/index.js.map +1 -0
  45. package/lib/commonjs/date-time-field/DateTimeFieldHiddenInput.js +150 -0
  46. package/lib/commonjs/date-time-field/DateTimeFieldHiddenInput.js.map +1 -0
  47. package/lib/commonjs/date-time-field/DateTimeFieldInput.js +104 -0
  48. package/lib/commonjs/date-time-field/DateTimeFieldInput.js.map +1 -0
  49. package/lib/commonjs/date-time-field/DateTimeFieldRoot.js +159 -0
  50. package/lib/commonjs/date-time-field/DateTimeFieldRoot.js.map +1 -0
  51. package/lib/commonjs/date-time-field/DateTimeFieldSegment.js +87 -0
  52. package/lib/commonjs/date-time-field/DateTimeFieldSegment.js.map +1 -0
  53. package/lib/commonjs/date-time-field/context.js +17 -0
  54. package/lib/commonjs/date-time-field/context.js.map +1 -0
  55. package/lib/commonjs/date-time-field/index.js +40 -0
  56. package/lib/commonjs/date-time-field/index.js.map +1 -0
  57. package/lib/commonjs/date-time-field/useDateTimeFieldSegmentState.js +564 -0
  58. package/lib/commonjs/date-time-field/useDateTimeFieldSegmentState.js.map +1 -0
  59. package/lib/commonjs/date-time-list/DateTimeListRoot.js +418 -0
  60. package/lib/commonjs/date-time-list/DateTimeListRoot.js.map +1 -0
  61. package/lib/commonjs/date-time-list/context.js +26 -0
  62. package/lib/commonjs/date-time-list/context.js.map +1 -0
  63. package/lib/commonjs/date-time-list/index.js +62 -0
  64. package/lib/commonjs/date-time-list/index.js.map +1 -0
  65. package/lib/commonjs/date-time-picker/DateTimePickerRoot.js +134 -0
  66. package/lib/commonjs/date-time-picker/DateTimePickerRoot.js.map +1 -0
  67. package/lib/commonjs/date-time-picker/context.js +17 -0
  68. package/lib/commonjs/date-time-picker/context.js.map +1 -0
  69. package/lib/commonjs/date-time-picker/index.js +26 -0
  70. package/lib/commonjs/date-time-picker/index.js.map +1 -0
  71. package/lib/commonjs/dialog/DialogRoot.js +1 -1
  72. package/lib/commonjs/dialog/DialogRoot.js.map +1 -1
  73. package/lib/commonjs/index.js +148 -0
  74. package/lib/commonjs/index.js.map +1 -1
  75. package/lib/commonjs/month-calendar/MonthCalendarCell.js +64 -0
  76. package/lib/commonjs/month-calendar/MonthCalendarCell.js.map +1 -0
  77. package/lib/commonjs/month-calendar/MonthCalendarRoot.js +103 -0
  78. package/lib/commonjs/month-calendar/MonthCalendarRoot.js.map +1 -0
  79. package/lib/commonjs/month-calendar/MonthCalendarYearCell.js +63 -0
  80. package/lib/commonjs/month-calendar/MonthCalendarYearCell.js.map +1 -0
  81. package/lib/commonjs/month-calendar/context.js +17 -0
  82. package/lib/commonjs/month-calendar/context.js.map +1 -0
  83. package/lib/commonjs/month-calendar/index.js +34 -0
  84. package/lib/commonjs/month-calendar/index.js.map +1 -0
  85. package/lib/commonjs/month-picker/MonthPickerRoot.js +118 -0
  86. package/lib/commonjs/month-picker/MonthPickerRoot.js.map +1 -0
  87. package/lib/commonjs/month-picker/context.js +17 -0
  88. package/lib/commonjs/month-picker/context.js.map +1 -0
  89. package/lib/commonjs/month-picker/index.js +26 -0
  90. package/lib/commonjs/month-picker/index.js.map +1 -0
  91. package/lib/commonjs/overlay/useAnchorPosition.js +27 -16
  92. package/lib/commonjs/overlay/useAnchorPosition.js.map +1 -1
  93. package/lib/commonjs/overlay/useDismissOverlay.web.js +10 -2
  94. package/lib/commonjs/overlay/useDismissOverlay.web.js.map +1 -1
  95. package/lib/commonjs/overlay/useOverlayPosition.js +5 -2
  96. package/lib/commonjs/overlay/useOverlayPosition.js.map +1 -1
  97. package/lib/commonjs/portal/portal.js +59 -2
  98. package/lib/commonjs/portal/portal.js.map +1 -1
  99. package/lib/commonjs/range-calendar/RangeCalendarRoot.js +148 -0
  100. package/lib/commonjs/range-calendar/RangeCalendarRoot.js.map +1 -0
  101. package/lib/commonjs/range-calendar/context.js +17 -0
  102. package/lib/commonjs/range-calendar/context.js.map +1 -0
  103. package/lib/commonjs/range-calendar/index.js +20 -0
  104. package/lib/commonjs/range-calendar/index.js.map +1 -0
  105. package/lib/commonjs/select/SelectRoot.js +1 -1
  106. package/lib/commonjs/select/SelectRoot.js.map +1 -1
  107. package/lib/commonjs/utils/accessibleLabel.js +23 -0
  108. package/lib/commonjs/utils/accessibleLabel.js.map +1 -0
  109. package/lib/commonjs/utils/createPortal.web.js +21 -0
  110. package/lib/commonjs/utils/createPortal.web.js.map +1 -0
  111. package/lib/module/calendar/CalendarGrid.js +29 -0
  112. package/lib/module/calendar/CalendarGrid.js.map +1 -0
  113. package/lib/module/calendar/CalendarRoot.js +91 -0
  114. package/lib/module/calendar/CalendarRoot.js.map +1 -0
  115. package/lib/module/calendar/context.js +12 -0
  116. package/lib/module/calendar/context.js.map +1 -0
  117. package/lib/module/calendar/index.js +6 -0
  118. package/lib/module/calendar/index.js.map +1 -0
  119. package/lib/module/calendar/types.js +4 -0
  120. package/lib/module/calendar/types.js.map +1 -0
  121. package/lib/module/date-field/DateFieldHiddenInput.js +146 -0
  122. package/lib/module/date-field/DateFieldHiddenInput.js.map +1 -0
  123. package/lib/module/date-field/DateFieldInput.js +118 -0
  124. package/lib/module/date-field/DateFieldInput.js.map +1 -0
  125. package/lib/module/date-field/DateFieldRoot.js +81 -0
  126. package/lib/module/date-field/DateFieldRoot.js.map +1 -0
  127. package/lib/module/date-field/DateFieldSegment.js +88 -0
  128. package/lib/module/date-field/DateFieldSegment.js.map +1 -0
  129. package/lib/module/date-field/context.js +15 -0
  130. package/lib/module/date-field/context.js.map +1 -0
  131. package/lib/module/date-field/index.js +7 -0
  132. package/lib/module/date-field/index.js.map +1 -0
  133. package/lib/module/date-field/segmentIndex.js +18 -0
  134. package/lib/module/date-field/segmentIndex.js.map +1 -0
  135. package/lib/module/date-field/segmentKeyboard.js +157 -0
  136. package/lib/module/date-field/segmentKeyboard.js.map +1 -0
  137. package/lib/module/date-field/types.js +4 -0
  138. package/lib/module/date-field/types.js.map +1 -0
  139. package/lib/module/date-field/useDateFieldSegmentState.js +378 -0
  140. package/lib/module/date-field/useDateFieldSegmentState.js.map +1 -0
  141. package/lib/module/date-field/useRangeDateFieldBridge.js +63 -0
  142. package/lib/module/date-field/useRangeDateFieldBridge.js.map +1 -0
  143. package/lib/module/date-picker/DatePickerRoot.js +119 -0
  144. package/lib/module/date-picker/DatePickerRoot.js.map +1 -0
  145. package/lib/module/date-picker/context.js +12 -0
  146. package/lib/module/date-picker/context.js.map +1 -0
  147. package/lib/module/date-picker/index.js +5 -0
  148. package/lib/module/date-picker/index.js.map +1 -0
  149. package/lib/module/date-range-picker/DateRangePickerRoot.js +140 -0
  150. package/lib/module/date-range-picker/DateRangePickerRoot.js.map +1 -0
  151. package/lib/module/date-range-picker/context.js +19 -0
  152. package/lib/module/date-range-picker/context.js.map +1 -0
  153. package/lib/module/date-range-picker/index.js +5 -0
  154. package/lib/module/date-range-picker/index.js.map +1 -0
  155. package/lib/module/date-time-field/DateTimeFieldHiddenInput.js +148 -0
  156. package/lib/module/date-time-field/DateTimeFieldHiddenInput.js.map +1 -0
  157. package/lib/module/date-time-field/DateTimeFieldInput.js +100 -0
  158. package/lib/module/date-time-field/DateTimeFieldInput.js.map +1 -0
  159. package/lib/module/date-time-field/DateTimeFieldRoot.js +154 -0
  160. package/lib/module/date-time-field/DateTimeFieldRoot.js.map +1 -0
  161. package/lib/module/date-time-field/DateTimeFieldSegment.js +83 -0
  162. package/lib/module/date-time-field/DateTimeFieldSegment.js.map +1 -0
  163. package/lib/module/date-time-field/context.js +12 -0
  164. package/lib/module/date-time-field/context.js.map +1 -0
  165. package/lib/module/date-time-field/index.js +7 -0
  166. package/lib/module/date-time-field/index.js.map +1 -0
  167. package/lib/module/date-time-field/useDateTimeFieldSegmentState.js +561 -0
  168. package/lib/module/date-time-field/useDateTimeFieldSegmentState.js.map +1 -0
  169. package/lib/module/date-time-list/DateTimeListRoot.js +416 -0
  170. package/lib/module/date-time-list/DateTimeListRoot.js.map +1 -0
  171. package/lib/module/date-time-list/context.js +20 -0
  172. package/lib/module/date-time-list/context.js.map +1 -0
  173. package/lib/module/date-time-list/index.js +5 -0
  174. package/lib/module/date-time-list/index.js.map +1 -0
  175. package/lib/module/date-time-picker/DateTimePickerRoot.js +130 -0
  176. package/lib/module/date-time-picker/DateTimePickerRoot.js.map +1 -0
  177. package/lib/module/date-time-picker/context.js +12 -0
  178. package/lib/module/date-time-picker/context.js.map +1 -0
  179. package/lib/module/date-time-picker/index.js +5 -0
  180. package/lib/module/date-time-picker/index.js.map +1 -0
  181. package/lib/module/dialog/DialogRoot.js +1 -1
  182. package/lib/module/dialog/DialogRoot.js.map +1 -1
  183. package/lib/module/index.js +11 -2
  184. package/lib/module/index.js.map +1 -1
  185. package/lib/module/month-calendar/MonthCalendarCell.js +60 -0
  186. package/lib/module/month-calendar/MonthCalendarCell.js.map +1 -0
  187. package/lib/module/month-calendar/MonthCalendarRoot.js +99 -0
  188. package/lib/module/month-calendar/MonthCalendarRoot.js.map +1 -0
  189. package/lib/module/month-calendar/MonthCalendarYearCell.js +59 -0
  190. package/lib/module/month-calendar/MonthCalendarYearCell.js.map +1 -0
  191. package/lib/module/month-calendar/context.js +12 -0
  192. package/lib/module/month-calendar/context.js.map +1 -0
  193. package/lib/module/month-calendar/index.js +7 -0
  194. package/lib/module/month-calendar/index.js.map +1 -0
  195. package/lib/module/month-picker/MonthPickerRoot.js +114 -0
  196. package/lib/module/month-picker/MonthPickerRoot.js.map +1 -0
  197. package/lib/module/month-picker/context.js +12 -0
  198. package/lib/module/month-picker/context.js.map +1 -0
  199. package/lib/module/month-picker/index.js +5 -0
  200. package/lib/module/month-picker/index.js.map +1 -0
  201. package/lib/module/overlay/useAnchorPosition.js +27 -16
  202. package/lib/module/overlay/useAnchorPosition.js.map +1 -1
  203. package/lib/module/overlay/useDismissOverlay.web.js +9 -2
  204. package/lib/module/overlay/useDismissOverlay.web.js.map +1 -1
  205. package/lib/module/overlay/useOverlayPosition.js +5 -2
  206. package/lib/module/overlay/useOverlayPosition.js.map +1 -1
  207. package/lib/module/portal/portal.js +59 -2
  208. package/lib/module/portal/portal.js.map +1 -1
  209. package/lib/module/range-calendar/RangeCalendarRoot.js +144 -0
  210. package/lib/module/range-calendar/RangeCalendarRoot.js.map +1 -0
  211. package/lib/module/range-calendar/context.js +12 -0
  212. package/lib/module/range-calendar/context.js.map +1 -0
  213. package/lib/module/range-calendar/index.js +5 -0
  214. package/lib/module/range-calendar/index.js.map +1 -0
  215. package/lib/module/select/SelectRoot.js +1 -1
  216. package/lib/module/select/SelectRoot.js.map +1 -1
  217. package/lib/module/utils/accessibleLabel.js +18 -0
  218. package/lib/module/utils/accessibleLabel.js.map +1 -0
  219. package/lib/module/utils/createPortal.web.js +17 -0
  220. package/lib/module/utils/createPortal.web.js.map +1 -0
  221. package/lib/typescript/calendar/CalendarGrid.d.ts +7 -0
  222. package/lib/typescript/calendar/CalendarGrid.d.ts.map +1 -0
  223. package/lib/typescript/calendar/CalendarRoot.d.ts +10 -0
  224. package/lib/typescript/calendar/CalendarRoot.d.ts.map +1 -0
  225. package/lib/typescript/calendar/context.d.ts +18 -0
  226. package/lib/typescript/calendar/context.d.ts.map +1 -0
  227. package/lib/typescript/calendar/index.d.ts +5 -0
  228. package/lib/typescript/calendar/index.d.ts.map +1 -0
  229. package/lib/typescript/calendar/types.d.ts +29 -0
  230. package/lib/typescript/calendar/types.d.ts.map +1 -0
  231. package/lib/typescript/date-field/DateFieldHiddenInput.d.ts +4 -0
  232. package/lib/typescript/date-field/DateFieldHiddenInput.d.ts.map +1 -0
  233. package/lib/typescript/date-field/DateFieldInput.d.ts +8 -0
  234. package/lib/typescript/date-field/DateFieldInput.d.ts.map +1 -0
  235. package/lib/typescript/date-field/DateFieldRoot.d.ts +10 -0
  236. package/lib/typescript/date-field/DateFieldRoot.d.ts.map +1 -0
  237. package/lib/typescript/date-field/DateFieldSegment.d.ts +9 -0
  238. package/lib/typescript/date-field/DateFieldSegment.d.ts.map +1 -0
  239. package/lib/typescript/date-field/context.d.ts +33 -0
  240. package/lib/typescript/date-field/context.d.ts.map +1 -0
  241. package/lib/typescript/date-field/index.d.ts +9 -0
  242. package/lib/typescript/date-field/index.d.ts.map +1 -0
  243. package/lib/typescript/date-field/segmentIndex.d.ts +7 -0
  244. package/lib/typescript/date-field/segmentIndex.d.ts.map +1 -0
  245. package/lib/typescript/date-field/segmentKeyboard.d.ts +23 -0
  246. package/lib/typescript/date-field/segmentKeyboard.d.ts.map +1 -0
  247. package/lib/typescript/date-field/types.d.ts +38 -0
  248. package/lib/typescript/date-field/types.d.ts.map +1 -0
  249. package/lib/typescript/date-field/useDateFieldSegmentState.d.ts +26 -0
  250. package/lib/typescript/date-field/useDateFieldSegmentState.d.ts.map +1 -0
  251. package/lib/typescript/date-field/useRangeDateFieldBridge.d.ts +4 -0
  252. package/lib/typescript/date-field/useRangeDateFieldBridge.d.ts.map +1 -0
  253. package/lib/typescript/date-picker/DatePickerRoot.d.ts +28 -0
  254. package/lib/typescript/date-picker/DatePickerRoot.d.ts.map +1 -0
  255. package/lib/typescript/date-picker/context.d.ts +25 -0
  256. package/lib/typescript/date-picker/context.d.ts.map +1 -0
  257. package/lib/typescript/date-picker/index.d.ts +5 -0
  258. package/lib/typescript/date-picker/index.d.ts.map +1 -0
  259. package/lib/typescript/date-range-picker/DateRangePickerRoot.d.ts +43 -0
  260. package/lib/typescript/date-range-picker/DateRangePickerRoot.d.ts.map +1 -0
  261. package/lib/typescript/date-range-picker/context.d.ts +42 -0
  262. package/lib/typescript/date-range-picker/context.d.ts.map +1 -0
  263. package/lib/typescript/date-range-picker/index.d.ts +4 -0
  264. package/lib/typescript/date-range-picker/index.d.ts.map +1 -0
  265. package/lib/typescript/date-time-field/DateTimeFieldHiddenInput.d.ts +4 -0
  266. package/lib/typescript/date-time-field/DateTimeFieldHiddenInput.d.ts.map +1 -0
  267. package/lib/typescript/date-time-field/DateTimeFieldInput.d.ts +10 -0
  268. package/lib/typescript/date-time-field/DateTimeFieldInput.d.ts.map +1 -0
  269. package/lib/typescript/date-time-field/DateTimeFieldRoot.d.ts +24 -0
  270. package/lib/typescript/date-time-field/DateTimeFieldRoot.d.ts.map +1 -0
  271. package/lib/typescript/date-time-field/DateTimeFieldSegment.d.ts +10 -0
  272. package/lib/typescript/date-time-field/DateTimeFieldSegment.d.ts.map +1 -0
  273. package/lib/typescript/date-time-field/context.d.ts +27 -0
  274. package/lib/typescript/date-time-field/context.d.ts.map +1 -0
  275. package/lib/typescript/date-time-field/index.d.ts +8 -0
  276. package/lib/typescript/date-time-field/index.d.ts.map +1 -0
  277. package/lib/typescript/date-time-field/useDateTimeFieldSegmentState.d.ts +26 -0
  278. package/lib/typescript/date-time-field/useDateTimeFieldSegmentState.d.ts.map +1 -0
  279. package/lib/typescript/date-time-list/DateTimeListRoot.d.ts +42 -0
  280. package/lib/typescript/date-time-list/DateTimeListRoot.d.ts.map +1 -0
  281. package/lib/typescript/date-time-list/context.d.ts +29 -0
  282. package/lib/typescript/date-time-list/context.d.ts.map +1 -0
  283. package/lib/typescript/date-time-list/index.d.ts +4 -0
  284. package/lib/typescript/date-time-list/index.d.ts.map +1 -0
  285. package/lib/typescript/date-time-picker/DateTimePickerRoot.d.ts +36 -0
  286. package/lib/typescript/date-time-picker/DateTimePickerRoot.d.ts.map +1 -0
  287. package/lib/typescript/date-time-picker/context.d.ts +25 -0
  288. package/lib/typescript/date-time-picker/context.d.ts.map +1 -0
  289. package/lib/typescript/date-time-picker/index.d.ts +4 -0
  290. package/lib/typescript/date-time-picker/index.d.ts.map +1 -0
  291. package/lib/typescript/dialog/types.d.ts +2 -1
  292. package/lib/typescript/dialog/types.d.ts.map +1 -1
  293. package/lib/typescript/index.d.ts +11 -2
  294. package/lib/typescript/index.d.ts.map +1 -1
  295. package/lib/typescript/month-calendar/MonthCalendarCell.d.ts +9 -0
  296. package/lib/typescript/month-calendar/MonthCalendarCell.d.ts.map +1 -0
  297. package/lib/typescript/month-calendar/MonthCalendarRoot.d.ts +30 -0
  298. package/lib/typescript/month-calendar/MonthCalendarRoot.d.ts.map +1 -0
  299. package/lib/typescript/month-calendar/MonthCalendarYearCell.d.ts +9 -0
  300. package/lib/typescript/month-calendar/MonthCalendarYearCell.d.ts.map +1 -0
  301. package/lib/typescript/month-calendar/context.d.ts +20 -0
  302. package/lib/typescript/month-calendar/context.d.ts.map +1 -0
  303. package/lib/typescript/month-calendar/index.d.ts +7 -0
  304. package/lib/typescript/month-calendar/index.d.ts.map +1 -0
  305. package/lib/typescript/month-picker/MonthPickerRoot.d.ts +29 -0
  306. package/lib/typescript/month-picker/MonthPickerRoot.d.ts.map +1 -0
  307. package/lib/typescript/month-picker/context.d.ts +23 -0
  308. package/lib/typescript/month-picker/context.d.ts.map +1 -0
  309. package/lib/typescript/month-picker/index.d.ts +4 -0
  310. package/lib/typescript/month-picker/index.d.ts.map +1 -0
  311. package/lib/typescript/overlay/useAnchorPosition.d.ts.map +1 -1
  312. package/lib/typescript/overlay/useDismissOverlay.web.d.ts.map +1 -1
  313. package/lib/typescript/overlay/useOverlayPosition.d.ts.map +1 -1
  314. package/lib/typescript/portal/portal.d.ts.map +1 -1
  315. package/lib/typescript/range-calendar/RangeCalendarRoot.d.ts +34 -0
  316. package/lib/typescript/range-calendar/RangeCalendarRoot.d.ts.map +1 -0
  317. package/lib/typescript/range-calendar/context.d.ts +26 -0
  318. package/lib/typescript/range-calendar/context.d.ts.map +1 -0
  319. package/lib/typescript/range-calendar/index.d.ts +5 -0
  320. package/lib/typescript/range-calendar/index.d.ts.map +1 -0
  321. package/lib/typescript/select/types.d.ts +2 -1
  322. package/lib/typescript/select/types.d.ts.map +1 -1
  323. package/lib/typescript/utils/accessibleLabel.d.ts +13 -0
  324. package/lib/typescript/utils/accessibleLabel.d.ts.map +1 -0
  325. package/lib/typescript/utils/createPortal.web.d.ts +17 -0
  326. package/lib/typescript/utils/createPortal.web.d.ts.map +1 -0
  327. package/package.json +3 -2
  328. package/src/calendar/CalendarGrid.tsx +29 -0
  329. package/src/calendar/CalendarRoot.tsx +138 -0
  330. package/src/calendar/context.tsx +28 -0
  331. package/src/calendar/index.ts +4 -0
  332. package/src/calendar/types.ts +30 -0
  333. package/src/date-field/DateFieldHiddenInput.tsx +152 -0
  334. package/src/date-field/DateFieldInput.tsx +138 -0
  335. package/src/date-field/DateFieldRoot.tsx +117 -0
  336. package/src/date-field/DateFieldSegment.tsx +97 -0
  337. package/src/date-field/context.tsx +48 -0
  338. package/src/date-field/index.ts +8 -0
  339. package/src/date-field/segmentIndex.tsx +17 -0
  340. package/src/date-field/segmentKeyboard.ts +207 -0
  341. package/src/date-field/types.ts +40 -0
  342. package/src/date-field/useDateFieldSegmentState.ts +455 -0
  343. package/src/date-field/useRangeDateFieldBridge.ts +78 -0
  344. package/src/date-picker/DatePickerRoot.tsx +186 -0
  345. package/src/date-picker/context.tsx +34 -0
  346. package/src/date-picker/index.ts +4 -0
  347. package/src/date-range-picker/DateRangePickerRoot.tsx +236 -0
  348. package/src/date-range-picker/context.tsx +48 -0
  349. package/src/date-range-picker/index.ts +8 -0
  350. package/src/date-time-field/DateTimeFieldHiddenInput.tsx +156 -0
  351. package/src/date-time-field/DateTimeFieldInput.tsx +119 -0
  352. package/src/date-time-field/DateTimeFieldRoot.tsx +209 -0
  353. package/src/date-time-field/DateTimeFieldSegment.tsx +95 -0
  354. package/src/date-time-field/context.tsx +41 -0
  355. package/src/date-time-field/index.ts +7 -0
  356. package/src/date-time-field/useDateTimeFieldSegmentState.ts +672 -0
  357. package/src/date-time-list/DateTimeListRoot.tsx +530 -0
  358. package/src/date-time-list/context.tsx +45 -0
  359. package/src/date-time-list/index.ts +16 -0
  360. package/src/date-time-picker/DateTimePickerRoot.tsx +210 -0
  361. package/src/date-time-picker/context.tsx +33 -0
  362. package/src/date-time-picker/index.ts +7 -0
  363. package/src/dialog/DialogRoot.tsx +1 -1
  364. package/src/dialog/types.ts +2 -1
  365. package/src/index.ts +21 -2
  366. package/src/month-calendar/MonthCalendarCell.tsx +53 -0
  367. package/src/month-calendar/MonthCalendarRoot.tsx +153 -0
  368. package/src/month-calendar/MonthCalendarYearCell.tsx +54 -0
  369. package/src/month-calendar/context.tsx +30 -0
  370. package/src/month-calendar/index.ts +6 -0
  371. package/src/month-picker/MonthPickerRoot.tsx +183 -0
  372. package/src/month-picker/context.tsx +31 -0
  373. package/src/month-picker/index.ts +3 -0
  374. package/src/overlay/useAnchorPosition.ts +25 -11
  375. package/src/overlay/useDismissOverlay.web.ts +10 -2
  376. package/src/overlay/useOverlayPosition.ts +5 -2
  377. package/src/portal/portal.tsx +79 -2
  378. package/src/range-calendar/RangeCalendarRoot.tsx +213 -0
  379. package/src/range-calendar/context.tsx +33 -0
  380. package/src/range-calendar/index.ts +4 -0
  381. package/src/select/SelectRoot.tsx +1 -1
  382. package/src/select/types.ts +2 -1
  383. package/src/utils/accessibleLabel.ts +22 -0
  384. package/src/utils/createPortal.web.ts +18 -0
@@ -0,0 +1,530 @@
1
+ import {
2
+ forwardRef,
3
+ useCallback,
4
+ useEffect,
5
+ useMemo,
6
+ useRef,
7
+ type ComponentRef,
8
+ type ReactNode,
9
+ } from 'react';
10
+ import {
11
+ NativeScrollEvent,
12
+ NativeSyntheticEvent,
13
+ Platform,
14
+ ScrollView,
15
+ View,
16
+ type ViewProps,
17
+ type ViewStyle,
18
+ } from 'react-native';
19
+ import {
20
+ clampDateTimeId,
21
+ compareDateIds,
22
+ dateRangeAroundDay,
23
+ eachDateIdInRange,
24
+ formatDateId,
25
+ formatDateTimeListDateRow,
26
+ formatDateTimeListHour,
27
+ formatDateTimeListMinute,
28
+ formatDateTimeListPeriod,
29
+ isLocaleHour12,
30
+ parseDateTimeId,
31
+ todayDateId,
32
+ type DateId,
33
+ type DateTimeGranularity,
34
+ type DateTimeId,
35
+ } from '@cdx-ui/formatters';
36
+ import { useControllableState } from '@cdx-ui/utils';
37
+ import { Slot } from '../slot';
38
+ import { accessibleLabelAttributes, resolveAccessibleLabel } from '../utils/accessibleLabel';
39
+ import { dataAttributes, mergeDataAttributes } from '../utils/dataAttributes';
40
+ import { applyDateTimePartChange } from '../date-time-field/DateTimeFieldRoot';
41
+ import {
42
+ DateTimeListContext,
43
+ DateTimeListColumnContext,
44
+ useDateTimeListContext,
45
+ type DateTimeListColumnType,
46
+ } from './context';
47
+
48
+ /**
49
+ * Visible days before/after the date-column anchor in the scroll wheel.
50
+ * Default anchor is today; when the selected date falls outside this window it becomes the anchor
51
+ * so controlled values always appear in the list.
52
+ */
53
+ const DATE_COLUMN_WINDOW_DAYS = 90;
54
+
55
+ /** Row height for wheel columns (must match styled component). */
56
+ export const DATE_TIME_LIST_ITEM_HEIGHT = 40;
57
+
58
+ /** Odd count so one row sits exactly in the center. */
59
+ export const DATE_TIME_LIST_VISIBLE_ITEMS = 5;
60
+
61
+ export const DATE_TIME_LIST_HEIGHT = DATE_TIME_LIST_ITEM_HEIGHT * DATE_TIME_LIST_VISIBLE_ITEMS;
62
+
63
+ /** Top/bottom padding so first/last items can snap into the center highlight. */
64
+ export const DATE_TIME_LIST_EDGE_PAD = (DATE_TIME_LIST_HEIGHT - DATE_TIME_LIST_ITEM_HEIGHT) / 2;
65
+
66
+ /**
67
+ * Native snap tuned to match web CSS `scroll-snap-align: center` resting positions.
68
+ * With edge padding, `scrollY = index * itemHeight` centers row `index` — same as web.
69
+ * iOS: snapToInterval (interval API). Android: snapToOffsets (interval is iOS-only).
70
+ */
71
+ const iosSnapProps = {
72
+ snapToInterval: DATE_TIME_LIST_ITEM_HEIGHT,
73
+ snapToAlignment: 'start' as const,
74
+ };
75
+
76
+ const WEB_SCROLL_SNAP: ViewStyle | undefined =
77
+ Platform.OS === 'web' ? ({ scrollSnapType: 'y mandatory' } as ViewStyle) : undefined;
78
+
79
+ const WEB_ITEM_SNAP: ViewStyle | undefined =
80
+ Platform.OS === 'web'
81
+ ? ({ scrollSnapAlign: 'center', scrollSnapStop: 'always' } as ViewStyle)
82
+ : undefined;
83
+
84
+ export interface DateTimeListRootProps extends Omit<ViewProps, 'children'> {
85
+ asChild?: boolean;
86
+ children?: ReactNode;
87
+ className?: string;
88
+ value?: DateTimeId;
89
+ defaultValue?: DateTimeId;
90
+ onValueChange?: (value: DateTimeId) => void;
91
+ onUserInteract?: () => void;
92
+ granularity?: DateTimeGranularity;
93
+ locale?: string;
94
+ /** Force a 12- or 24-hour clock. Defaults to the locale's convention when omitted. */
95
+ hour12?: boolean;
96
+ disabled?: boolean;
97
+ /** Earliest selectable date-time. Dates before it are hidden; times are clamped. Build with `dateTimeId(...)`. */
98
+ minValue?: DateTimeId;
99
+ /** Latest selectable date-time. Dates after it are hidden; times are clamped. Build with `dateTimeId(...)`. */
100
+ maxValue?: DateTimeId;
101
+ }
102
+
103
+ export const DateTimeListRoot = forwardRef<ComponentRef<typeof View>, DateTimeListRootProps>(
104
+ (
105
+ {
106
+ asChild,
107
+ children,
108
+ value: valueProp,
109
+ defaultValue,
110
+ onValueChange,
111
+ onUserInteract,
112
+ granularity = 'minute',
113
+ locale = 'en-US',
114
+ hour12: hour12Prop,
115
+ disabled = false,
116
+ minValue,
117
+ maxValue,
118
+ accessibilityLabel: accessibilityLabelProp,
119
+ 'aria-label': ariaLabelProp,
120
+ ...props
121
+ },
122
+ ref,
123
+ ) => {
124
+ const hour12 = hour12Prop ?? isLocaleHour12(locale);
125
+ const accessibilityLabel = resolveAccessibleLabel({
126
+ accessibilityLabel: accessibilityLabelProp,
127
+ 'aria-label': ariaLabelProp,
128
+ });
129
+ const [value, setValue] = useControllableState<DateTimeId | undefined>({
130
+ prop: valueProp,
131
+ defaultProp: defaultValue,
132
+ onChange: (next) => {
133
+ if (next !== undefined) {
134
+ onValueChange?.(next);
135
+ }
136
+ },
137
+ });
138
+
139
+ const commitValue = useCallback(
140
+ (next: DateTimeId) => {
141
+ const clamped = clampDateTimeId(next, { min: minValue, max: maxValue });
142
+ if (clamped !== value) {
143
+ setValue(clamped);
144
+ } else {
145
+ onValueChange?.(clamped);
146
+ }
147
+ },
148
+ [maxValue, minValue, onValueChange, setValue, value],
149
+ );
150
+
151
+ const contextValue = useMemo(
152
+ () => ({
153
+ value,
154
+ onValueChange: commitValue,
155
+ onUserInteract,
156
+ granularity,
157
+ locale,
158
+ hour12,
159
+ disabled,
160
+ minValue,
161
+ maxValue,
162
+ }),
163
+ [
164
+ value,
165
+ commitValue,
166
+ onUserInteract,
167
+ granularity,
168
+ locale,
169
+ hour12,
170
+ disabled,
171
+ minValue,
172
+ maxValue,
173
+ ],
174
+ );
175
+
176
+ const Comp = asChild ? Slot : View;
177
+
178
+ return (
179
+ <DateTimeListContext.Provider value={contextValue}>
180
+ <Comp
181
+ ref={ref}
182
+ {...props}
183
+ {...mergeDataAttributes(props, dataAttributes({ disabled }))}
184
+ {...accessibleLabelAttributes(accessibilityLabel)}
185
+ >
186
+ {children}
187
+ </Comp>
188
+ </DateTimeListContext.Provider>
189
+ );
190
+ },
191
+ );
192
+
193
+ DateTimeListRoot.displayName = 'DateTimeListRoot';
194
+
195
+ function dateColumnAnchor(today: DateId, selectedDateId?: DateId): DateId {
196
+ const { startId, endId } = dateRangeAroundDay(
197
+ DATE_COLUMN_WINDOW_DAYS,
198
+ DATE_COLUMN_WINDOW_DAYS,
199
+ today,
200
+ );
201
+ if (
202
+ selectedDateId &&
203
+ (compareDateIds(selectedDateId, startId) < 0 || compareDateIds(selectedDateId, endId) > 0)
204
+ ) {
205
+ return selectedDateId;
206
+ }
207
+ return today;
208
+ }
209
+
210
+ function buildDateOptions(
211
+ locale: string,
212
+ selectedDateId?: DateId,
213
+ minDateId?: DateId,
214
+ maxDateId?: DateId,
215
+ ): { value: DateId; label: string }[] {
216
+ const today = todayDateId();
217
+ // Keep the window centered on an in-range anchor so the clamped ends never invert.
218
+ let anchor = dateColumnAnchor(today, selectedDateId);
219
+ if (minDateId && compareDateIds(anchor, minDateId) < 0) {
220
+ anchor = minDateId;
221
+ }
222
+ if (maxDateId && compareDateIds(anchor, maxDateId) > 0) {
223
+ anchor = maxDateId;
224
+ }
225
+
226
+ let { startId, endId } = dateRangeAroundDay(
227
+ DATE_COLUMN_WINDOW_DAYS,
228
+ DATE_COLUMN_WINDOW_DAYS,
229
+ anchor,
230
+ );
231
+ if (minDateId && compareDateIds(startId, minDateId) < 0) {
232
+ startId = minDateId;
233
+ }
234
+ if (maxDateId && compareDateIds(endId, maxDateId) > 0) {
235
+ endId = maxDateId;
236
+ }
237
+
238
+ return eachDateIdInRange(startId, endId).map((id) => ({
239
+ value: id,
240
+ label: formatDateTimeListDateRow(id, { todayDateId: today, locale }),
241
+ }));
242
+ }
243
+
244
+ function clampIndex(index: number, length: number): number {
245
+ if (length <= 0) {
246
+ return 0;
247
+ }
248
+ return Math.max(0, Math.min(length - 1, index));
249
+ }
250
+
251
+ function indexFromOffset(y: number, length: number): number {
252
+ return clampIndex(Math.round(y / DATE_TIME_LIST_ITEM_HEIGHT), length);
253
+ }
254
+
255
+ export interface DateTimeListColumnProps extends Omit<ViewProps, 'children'> {
256
+ column: DateTimeListColumnType;
257
+ asChild?: boolean;
258
+ className?: string;
259
+ children?: (option: {
260
+ value: string | number;
261
+ label: string;
262
+ selected: boolean;
263
+ }) => React.ReactNode;
264
+ }
265
+
266
+ export const DateTimeListColumn = forwardRef<ComponentRef<typeof View>, DateTimeListColumnProps>(
267
+ ({ column, asChild, className, style, children, ...props }, ref) => {
268
+ const { value, onValueChange, onUserInteract, hour12, locale, disabled, minValue, maxValue } =
269
+ useDateTimeListContext();
270
+ const parts = value ? parseDateTimeId(value) : null;
271
+ const selectedDateId = parts ? formatDateId(parts) : undefined;
272
+ const minDateId = useMemo(() => {
273
+ const p = minValue ? parseDateTimeId(minValue) : null;
274
+ return p ? formatDateId(p) : undefined;
275
+ }, [minValue]);
276
+ const maxDateId = useMemo(() => {
277
+ const p = maxValue ? parseDateTimeId(maxValue) : null;
278
+ return p ? formatDateId(p) : undefined;
279
+ }, [maxValue]);
280
+ const scrollRef = useRef<ScrollView>(null);
281
+ const isUserScrollingRef = useRef(false);
282
+ const lastEmittedIndexRef = useRef(-1);
283
+ const settleFrameRef = useRef<number | null>(null);
284
+
285
+ const options = useMemo(() => {
286
+ if (column === 'date') {
287
+ return buildDateOptions(locale, selectedDateId, minDateId, maxDateId);
288
+ }
289
+ if (column === 'hour') {
290
+ const hours = hour12
291
+ ? Array.from({ length: 12 }, (_, i) => i + 1)
292
+ : Array.from({ length: 24 }, (_, i) => i);
293
+ return hours.map((h) => ({
294
+ value: h,
295
+ label: formatDateTimeListHour(h, { hour12 }),
296
+ }));
297
+ }
298
+ if (column === 'minute' || column === 'second') {
299
+ return Array.from({ length: 60 }, (_, i) => ({
300
+ value: i,
301
+ label: formatDateTimeListMinute(i),
302
+ }));
303
+ }
304
+ return [
305
+ { value: 0, label: formatDateTimeListPeriod(0, { locale }) },
306
+ { value: 1, label: formatDateTimeListPeriod(12, { locale }) },
307
+ ];
308
+ }, [column, hour12, locale, selectedDateId, minDateId, maxDateId]);
309
+
310
+ const snapOffsets = useMemo(
311
+ () => options.map((_, index) => index * DATE_TIME_LIST_ITEM_HEIGHT),
312
+ [options],
313
+ );
314
+
315
+ const selectedValue = useMemo(() => {
316
+ if (!parts) {
317
+ return undefined;
318
+ }
319
+ if (column === 'date') {
320
+ return formatDateId(parts);
321
+ }
322
+ if (column === 'hour') {
323
+ return hour12 ? parts.hour % 12 || 12 : parts.hour;
324
+ }
325
+ if (column === 'minute') {
326
+ return parts.minute;
327
+ }
328
+ if (column === 'period') {
329
+ return parts.hour >= 12 ? 1 : 0;
330
+ }
331
+ return parts.second ?? 0;
332
+ }, [column, hour12, parts]);
333
+
334
+ const selectedIndex = useMemo(() => {
335
+ if (selectedValue === undefined) {
336
+ return -1;
337
+ }
338
+ return options.findIndex((option) => option.value === selectedValue);
339
+ }, [options, selectedValue]);
340
+
341
+ const commitIndex = useCallback(
342
+ (index: number) => {
343
+ if (disabled) {
344
+ return;
345
+ }
346
+ const nextIndex = clampIndex(index, options.length);
347
+ const option = options[nextIndex];
348
+ if (lastEmittedIndexRef.current === nextIndex) {
349
+ return;
350
+ }
351
+ lastEmittedIndexRef.current = nextIndex;
352
+
353
+ let next: DateTimeId | undefined;
354
+ if (column === 'date' && typeof option.value === 'string') {
355
+ next = applyDateTimePartChange(value, 'date', option.value);
356
+ } else if (column === 'hour' && typeof option.value === 'number') {
357
+ const hour = hour12
358
+ ? (parts && parts.hour >= 12 ? 12 : 0) + (option.value % 12)
359
+ : option.value;
360
+ next = applyDateTimePartChange(value, 'hour', hour);
361
+ } else if (column === 'minute' && typeof option.value === 'number') {
362
+ next = applyDateTimePartChange(value, 'minute', option.value);
363
+ } else if (column === 'second' && typeof option.value === 'number') {
364
+ next = applyDateTimePartChange(value, 'second', option.value);
365
+ } else if (column === 'period' && typeof option.value === 'number') {
366
+ next = applyDateTimePartChange(value, 'period', option.value);
367
+ }
368
+ if (next) {
369
+ onValueChange?.(next);
370
+ }
371
+ },
372
+ [column, disabled, hour12, onValueChange, options, parts, value],
373
+ );
374
+
375
+ const scrollToIndex = useCallback(
376
+ (index: number, animated: boolean) => {
377
+ const nextIndex = clampIndex(index, options.length);
378
+ scrollRef.current?.scrollTo({
379
+ y: nextIndex * DATE_TIME_LIST_ITEM_HEIGHT,
380
+ animated,
381
+ });
382
+ },
383
+ [options.length],
384
+ );
385
+
386
+ const settleToNearest = useCallback(
387
+ (y: number) => {
388
+ const index = indexFromOffset(y, options.length);
389
+ const targetY = index * DATE_TIME_LIST_ITEM_HEIGHT;
390
+ isUserScrollingRef.current = false;
391
+
392
+ if (settleFrameRef.current != null) {
393
+ cancelAnimationFrame(settleFrameRef.current);
394
+ }
395
+
396
+ // Animate into place, then lock the exact offset (mirrors CSS scroll-snap settle).
397
+ const needsAnimate = Math.abs(y - targetY) > 0.5;
398
+ scrollRef.current?.scrollTo({ y: targetY, animated: needsAnimate });
399
+ settleFrameRef.current = requestAnimationFrame(() => {
400
+ scrollRef.current?.scrollTo({ y: targetY, animated: false });
401
+ settleFrameRef.current = null;
402
+ });
403
+ commitIndex(index);
404
+ },
405
+ [commitIndex, options.length],
406
+ );
407
+
408
+ useEffect(() => {
409
+ return () => {
410
+ if (settleFrameRef.current != null) {
411
+ cancelAnimationFrame(settleFrameRef.current);
412
+ }
413
+ };
414
+ }, []);
415
+
416
+ useEffect(() => {
417
+ if (selectedIndex < 0 || isUserScrollingRef.current) {
418
+ return;
419
+ }
420
+ lastEmittedIndexRef.current = selectedIndex;
421
+ const frame = requestAnimationFrame(() => {
422
+ scrollToIndex(selectedIndex, false);
423
+ });
424
+ return () => cancelAnimationFrame(frame);
425
+ }, [scrollToIndex, selectedIndex]);
426
+
427
+ const onSelect = useCallback(
428
+ (optionValue: string | number) => {
429
+ const index = options.findIndex((option) => option.value === optionValue);
430
+ if (index < 0) {
431
+ return;
432
+ }
433
+ isUserScrollingRef.current = false;
434
+ onUserInteract?.();
435
+ scrollToIndex(index, true);
436
+ lastEmittedIndexRef.current = -1;
437
+ commitIndex(index);
438
+ },
439
+ [commitIndex, onUserInteract, options, scrollToIndex],
440
+ );
441
+
442
+ const handleScrollEnd = useCallback(
443
+ (event: NativeSyntheticEvent<NativeScrollEvent>) => {
444
+ settleToNearest(event.nativeEvent.contentOffset.y);
445
+ },
446
+ [settleToNearest],
447
+ );
448
+
449
+ const columnContext = useMemo(
450
+ () => ({
451
+ column,
452
+ options,
453
+ selectedValue,
454
+ onSelect,
455
+ }),
456
+ [column, options, selectedValue, onSelect],
457
+ );
458
+
459
+ const Comp = asChild ? Slot : View;
460
+
461
+ const snapProps =
462
+ Platform.OS === 'ios'
463
+ ? iosSnapProps
464
+ : Platform.OS === 'android'
465
+ ? { snapToOffsets: snapOffsets, snapToAlignment: 'start' as const }
466
+ : {};
467
+
468
+ return (
469
+ <DateTimeListColumnContext.Provider value={columnContext}>
470
+ <Comp
471
+ ref={ref}
472
+ className={className}
473
+ style={style}
474
+ accessibilityRole="none"
475
+ {...props}
476
+ {...mergeDataAttributes(props, dataAttributes({ slot: `date-time-list-${column}` }))}
477
+ >
478
+ <ScrollView
479
+ ref={scrollRef}
480
+ showsVerticalScrollIndicator={false}
481
+ {...snapProps}
482
+ // Closest native match to CSS scroll-snap deceleration.
483
+ decelerationRate={Platform.OS === 'ios' ? 0.98 : 'fast'}
484
+ nestedScrollEnabled
485
+ disableIntervalMomentum
486
+ scrollEventThrottle={16}
487
+ style={WEB_SCROLL_SNAP}
488
+ onScrollBeginDrag={() => {
489
+ isUserScrollingRef.current = true;
490
+ onUserInteract?.();
491
+ }}
492
+ onMomentumScrollEnd={handleScrollEnd}
493
+ onScrollEndDrag={(event) => {
494
+ const velocityY = event.nativeEvent.velocity?.y ?? 0;
495
+ // Web / weak flings never get a reliable momentum end — settle here.
496
+ // Native strong flings wait for onMomentumScrollEnd (same as CSS snap).
497
+ if (Platform.OS === 'web' || Math.abs(velocityY) < 0.35) {
498
+ handleScrollEnd(event);
499
+ }
500
+ }}
501
+ contentContainerStyle={{
502
+ paddingTop: DATE_TIME_LIST_EDGE_PAD,
503
+ paddingBottom: DATE_TIME_LIST_EDGE_PAD,
504
+ }}
505
+ >
506
+ {options.map((option) => {
507
+ const selected = option.value === selectedValue;
508
+ return (
509
+ <View
510
+ key={String(option.value)}
511
+ style={[{ height: DATE_TIME_LIST_ITEM_HEIGHT }, WEB_ITEM_SNAP]}
512
+ >
513
+ {children ? (
514
+ children({ ...option, selected })
515
+ ) : (
516
+ <View accessibilityRole="button" accessibilityState={{ selected }}>
517
+ {option.label}
518
+ </View>
519
+ )}
520
+ </View>
521
+ );
522
+ })}
523
+ </ScrollView>
524
+ </Comp>
525
+ </DateTimeListColumnContext.Provider>
526
+ );
527
+ },
528
+ );
529
+
530
+ DateTimeListColumn.displayName = 'DateTimeListColumn';
@@ -0,0 +1,45 @@
1
+ import { createContext, useContext } from 'react';
2
+ import type { DateTimeGranularity, DateTimeId } from '@cdx-ui/formatters';
3
+
4
+ export type DateTimeListColumnType = 'date' | 'hour' | 'minute' | 'second' | 'period';
5
+
6
+ export interface DateTimeListContextValue {
7
+ value?: DateTimeId;
8
+ onValueChange?: (value: DateTimeId) => void;
9
+ onUserInteract?: () => void;
10
+ granularity: DateTimeGranularity;
11
+ locale: string;
12
+ hour12: boolean;
13
+ disabled: boolean;
14
+ /** Earliest selectable date-time (`YYYY-MM-DDTHH:MM`). */
15
+ minValue?: DateTimeId;
16
+ /** Latest selectable date-time (`YYYY-MM-DDTHH:MM`). */
17
+ maxValue?: DateTimeId;
18
+ }
19
+
20
+ export const DateTimeListContext = createContext<DateTimeListContextValue | null>(null);
21
+
22
+ export function useDateTimeListContext(): DateTimeListContextValue {
23
+ const ctx = useContext(DateTimeListContext);
24
+ if (!ctx) {
25
+ throw new Error('DateTimeList compound components must be used within DateTimeListRoot');
26
+ }
27
+ return ctx;
28
+ }
29
+
30
+ export interface DateTimeListColumnContextValue {
31
+ column: DateTimeListColumnType;
32
+ options: { value: string | number; label: string }[];
33
+ selectedValue?: string | number;
34
+ onSelect: (value: string | number) => void;
35
+ }
36
+
37
+ export const DateTimeListColumnContext = createContext<DateTimeListColumnContextValue | null>(null);
38
+
39
+ export function useDateTimeListColumnContext(): DateTimeListColumnContextValue {
40
+ const ctx = useContext(DateTimeListColumnContext);
41
+ if (!ctx) {
42
+ throw new Error('DateTimeListColumn must be used within DateTimeListRoot column setup');
43
+ }
44
+ return ctx;
45
+ }
@@ -0,0 +1,16 @@
1
+ export {
2
+ DateTimeListRoot,
3
+ DateTimeListColumn,
4
+ DATE_TIME_LIST_ITEM_HEIGHT,
5
+ DATE_TIME_LIST_VISIBLE_ITEMS,
6
+ DATE_TIME_LIST_HEIGHT,
7
+ DATE_TIME_LIST_EDGE_PAD,
8
+ } from './DateTimeListRoot';
9
+ export type { DateTimeListRootProps, DateTimeListColumnProps } from './DateTimeListRoot';
10
+ export {
11
+ DateTimeListContext,
12
+ useDateTimeListContext,
13
+ useDateTimeListColumnContext,
14
+ type DateTimeListColumnType,
15
+ type DateTimeListContextValue,
16
+ } from './context';