@cognite/aura 0.3.5 → 1.0.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 (540) hide show
  1. package/CHANGELOG.md +274 -0
  2. package/DESIGN.md +664 -281
  3. package/LICENSE +21 -0
  4. package/README.md +21 -13
  5. package/dist/colors-deprecated.css +618 -0
  6. package/dist/colors.css +803 -830
  7. package/dist/components/index.d.ts +63 -57
  8. package/dist/components/index.js +62 -59
  9. package/dist/components/index.js.map +1 -0
  10. package/dist/components/ui/core/accordion/accordion.d.ts +19 -18
  11. package/dist/components/ui/core/accordion/accordion.js +99 -78
  12. package/dist/components/ui/core/accordion/accordion.js.map +1 -0
  13. package/dist/components/ui/core/action-toolbar/action-toolbar-motion.d.ts +8 -0
  14. package/dist/components/ui/core/action-toolbar/action-toolbar-motion.js +132 -0
  15. package/dist/components/ui/core/action-toolbar/action-toolbar-motion.js.map +1 -0
  16. package/dist/components/ui/core/action-toolbar/action-toolbar.d.ts +31 -31
  17. package/dist/components/ui/core/action-toolbar/action-toolbar.js +156 -106
  18. package/dist/components/ui/core/action-toolbar/action-toolbar.js.map +1 -0
  19. package/dist/components/ui/core/alert/alert.d.ts +25 -25
  20. package/dist/components/ui/core/alert/alert.gallery.d.ts +2 -0
  21. package/dist/components/ui/core/alert/alert.gallery.js +54 -0
  22. package/dist/components/ui/core/alert/alert.gallery.js.map +1 -0
  23. package/dist/components/ui/core/alert/alert.js +181 -152
  24. package/dist/components/ui/core/alert/alert.js.map +1 -0
  25. package/dist/components/ui/core/avatar/avatar.d.ts +10 -9
  26. package/dist/components/ui/core/avatar/avatar.gallery.d.ts +2 -0
  27. package/dist/components/ui/core/avatar/avatar.gallery.js +67 -0
  28. package/dist/components/ui/core/avatar/avatar.gallery.js.map +1 -0
  29. package/dist/components/ui/core/avatar/avatar.js +75 -65
  30. package/dist/components/ui/core/avatar/avatar.js.map +1 -0
  31. package/dist/components/ui/core/badge/badge.d.ts +13 -12
  32. package/dist/components/ui/core/badge/badge.gallery.d.ts +2 -0
  33. package/dist/components/ui/core/badge/badge.gallery.js +64 -0
  34. package/dist/components/ui/core/badge/badge.gallery.js.map +1 -0
  35. package/dist/components/ui/core/badge/badge.js +88 -72
  36. package/dist/components/ui/core/badge/badge.js.map +1 -0
  37. package/dist/components/ui/core/banner/banner.d.ts +18 -18
  38. package/dist/components/ui/core/banner/banner.gallery.d.ts +2 -0
  39. package/dist/components/ui/core/banner/banner.gallery.js +56 -0
  40. package/dist/components/ui/core/banner/banner.gallery.js.map +1 -0
  41. package/dist/components/ui/core/banner/banner.js +179 -142
  42. package/dist/components/ui/core/banner/banner.js.map +1 -0
  43. package/dist/components/ui/core/breadcrumb/breadcrumb.d.ts +12 -12
  44. package/dist/components/ui/core/breadcrumb/breadcrumb.gallery.d.ts +2 -0
  45. package/dist/components/ui/core/breadcrumb/breadcrumb.gallery.js +31 -0
  46. package/dist/components/ui/core/breadcrumb/breadcrumb.gallery.js.map +1 -0
  47. package/dist/components/ui/core/breadcrumb/breadcrumb.js +139 -104
  48. package/dist/components/ui/core/breadcrumb/breadcrumb.js.map +1 -0
  49. package/dist/components/ui/core/button/button.d.ts +7 -7
  50. package/dist/components/ui/core/button/button.gallery.d.ts +2 -0
  51. package/dist/components/ui/core/button/button.gallery.js +76 -0
  52. package/dist/components/ui/core/button/button.gallery.js.map +1 -0
  53. package/dist/components/ui/core/button/button.js +57 -47
  54. package/dist/components/ui/core/button/button.js.map +1 -0
  55. package/dist/components/ui/core/button-group/button-group.d.ts +9 -9
  56. package/dist/components/ui/core/button-group/button-group.gallery.d.ts +2 -0
  57. package/dist/components/ui/core/button-group/button-group.gallery.js +62 -0
  58. package/dist/components/ui/core/button-group/button-group.gallery.js.map +1 -0
  59. package/dist/components/ui/core/button-group/button-group.js +50 -40
  60. package/dist/components/ui/core/button-group/button-group.js.map +1 -0
  61. package/dist/components/ui/core/calendar/calendar-header.d.ts +7 -7
  62. package/dist/components/ui/core/calendar/calendar-header.js +102 -63
  63. package/dist/components/ui/core/calendar/calendar-header.js.map +1 -0
  64. package/dist/components/ui/core/calendar/calendar-utils.d.ts +30 -30
  65. package/dist/components/ui/core/calendar/calendar-utils.js +116 -39
  66. package/dist/components/ui/core/calendar/calendar-utils.js.map +1 -0
  67. package/dist/components/ui/core/calendar/calendar.d.ts +10 -10
  68. package/dist/components/ui/core/calendar/calendar.js +95 -66
  69. package/dist/components/ui/core/calendar/calendar.js.map +1 -0
  70. package/dist/components/ui/core/calendar/constants.js +3 -0
  71. package/dist/components/ui/core/calendar/constants.js.map +1 -0
  72. package/dist/components/ui/core/card/card.d.ts +20 -20
  73. package/dist/components/ui/core/card/card.js +133 -104
  74. package/dist/components/ui/core/card/card.js.map +1 -0
  75. package/dist/components/ui/core/chart/chart.d.ts +55 -53
  76. package/dist/components/ui/core/chart/chart.js +196 -116
  77. package/dist/components/ui/core/chart/chart.js.map +1 -0
  78. package/dist/components/ui/core/chart/index.d.ts +2 -2
  79. package/dist/components/ui/core/chart/index.js +3 -2
  80. package/dist/components/ui/core/chart/index.js.map +1 -0
  81. package/dist/components/ui/core/checkbox/checkbox.d.ts +9 -9
  82. package/dist/components/ui/core/checkbox/checkbox.gallery.d.ts +2 -0
  83. package/dist/components/ui/core/checkbox/checkbox.gallery.js +36 -0
  84. package/dist/components/ui/core/checkbox/checkbox.gallery.js.map +1 -0
  85. package/dist/components/ui/core/checkbox/checkbox.js +88 -68
  86. package/dist/components/ui/core/checkbox/checkbox.js.map +1 -0
  87. package/dist/components/ui/core/checkbox/checkbox.metadata.d.ts +1 -1
  88. package/dist/components/ui/core/checkbox/checkbox.metadata.js +6 -7
  89. package/dist/components/ui/core/checkbox/checkbox.metadata.js.map +1 -0
  90. package/dist/components/ui/core/code-block/code-block.d.ts +19 -19
  91. package/dist/components/ui/core/code-block/code-block.js +260 -175
  92. package/dist/components/ui/core/code-block/code-block.js.map +1 -0
  93. package/dist/components/ui/core/collapsible/collapsible.d.ts +5 -5
  94. package/dist/components/ui/core/collapsible/collapsible.gallery.d.ts +2 -0
  95. package/dist/components/ui/core/collapsible/collapsible.gallery.js +39 -0
  96. package/dist/components/ui/core/collapsible/collapsible.gallery.js.map +1 -0
  97. package/dist/components/ui/core/collapsible/collapsible.js +36 -30
  98. package/dist/components/ui/core/collapsible/collapsible.js.map +1 -0
  99. package/dist/components/ui/core/combobox/combobox.d.ts +13 -13
  100. package/dist/components/ui/core/combobox/combobox.js +89 -40
  101. package/dist/components/ui/core/combobox/combobox.js.map +1 -0
  102. package/dist/components/ui/core/command/command.d.ts +20 -18
  103. package/dist/components/ui/core/command/command.js +137 -85
  104. package/dist/components/ui/core/command/command.js.map +1 -0
  105. package/dist/components/ui/core/conversation/conversation.d.ts +14 -0
  106. package/dist/components/ui/core/conversation/conversation.js +51 -0
  107. package/dist/components/ui/core/conversation/conversation.js.map +1 -0
  108. package/dist/components/ui/core/count/count.d.ts +8 -6
  109. package/dist/components/ui/core/count/count.gallery.d.ts +2 -0
  110. package/dist/components/ui/core/count/count.gallery.js +55 -0
  111. package/dist/components/ui/core/count/count.gallery.js.map +1 -0
  112. package/dist/components/ui/core/count/count.js +51 -21
  113. package/dist/components/ui/core/count/count.js.map +1 -0
  114. package/dist/components/ui/core/data-grid/data-grid-cell.d.ts +5 -7
  115. package/dist/components/ui/core/data-grid/data-grid-cell.js +18 -22
  116. package/dist/components/ui/core/data-grid/data-grid-cell.js.map +1 -0
  117. package/dist/components/ui/core/data-grid/data-grid-column-filter.d.ts +4 -0
  118. package/dist/components/ui/core/data-grid/data-grid-column-filter.js +13 -0
  119. package/dist/components/ui/core/data-grid/data-grid-column-filter.js.map +1 -0
  120. package/dist/components/ui/core/data-grid/data-grid-column-resizer.d.ts +8 -0
  121. package/dist/components/ui/core/data-grid/data-grid-column-resizer.js +25 -0
  122. package/dist/components/ui/core/data-grid/data-grid-column-resizer.js.map +1 -0
  123. package/dist/components/ui/core/data-grid/data-grid-filter-clauses.d.ts +14 -0
  124. package/dist/components/ui/core/data-grid/data-grid-filter-clauses.js +36 -0
  125. package/dist/components/ui/core/data-grid/data-grid-filter-clauses.js.map +1 -0
  126. package/dist/components/ui/core/data-grid/data-grid-filter-panel.d.ts +43 -0
  127. package/dist/components/ui/core/data-grid/data-grid-filter-panel.js +287 -0
  128. package/dist/components/ui/core/data-grid/data-grid-filter-panel.js.map +1 -0
  129. package/dist/components/ui/core/data-grid/data-grid-footer.d.ts +6 -0
  130. package/dist/components/ui/core/data-grid/data-grid-footer.js +34 -0
  131. package/dist/components/ui/core/data-grid/data-grid-footer.js.map +1 -0
  132. package/dist/components/ui/core/data-grid/data-grid-header-row.d.ts +10 -10
  133. package/dist/components/ui/core/data-grid/data-grid-header-row.js +85 -55
  134. package/dist/components/ui/core/data-grid/data-grid-header-row.js.map +1 -0
  135. package/dist/components/ui/core/data-grid/data-grid-header.d.ts +11 -0
  136. package/dist/components/ui/core/data-grid/data-grid-header.js +67 -0
  137. package/dist/components/ui/core/data-grid/data-grid-header.js.map +1 -0
  138. package/dist/components/ui/core/data-grid/data-grid-row.d.ts +13 -15
  139. package/dist/components/ui/core/data-grid/data-grid-row.js +117 -76
  140. package/dist/components/ui/core/data-grid/data-grid-row.js.map +1 -0
  141. package/dist/components/ui/core/data-grid/data-grid-selection-state.d.ts +15 -0
  142. package/dist/components/ui/core/data-grid/data-grid-selection-state.js +32 -0
  143. package/dist/components/ui/core/data-grid/data-grid-selection-state.js.map +1 -0
  144. package/dist/components/ui/core/data-grid/data-grid-selection-toolbar.d.ts +11 -0
  145. package/dist/components/ui/core/data-grid/data-grid-selection-toolbar.js +129 -0
  146. package/dist/components/ui/core/data-grid/data-grid-selection-toolbar.js.map +1 -0
  147. package/dist/components/ui/core/data-grid/data-grid-selection.types.d.ts +24 -0
  148. package/dist/components/ui/core/data-grid/data-grid-selection.types.js +3 -0
  149. package/dist/components/ui/core/data-grid/data-grid-selection.types.js.map +1 -0
  150. package/dist/components/ui/core/data-grid/data-grid.d.ts +125 -35
  151. package/dist/components/ui/core/data-grid/data-grid.fixtures.d.ts +7 -7
  152. package/dist/components/ui/core/data-grid/data-grid.fixtures.js +139 -0
  153. package/dist/components/ui/core/data-grid/data-grid.fixtures.js.map +1 -0
  154. package/dist/components/ui/core/data-grid/data-grid.js +540 -132
  155. package/dist/components/ui/core/data-grid/data-grid.js.map +1 -0
  156. package/dist/components/ui/core/data-grid/data-grid.utils.d.ts +3 -4
  157. package/dist/components/ui/core/data-grid/data-grid.utils.js +46 -33
  158. package/dist/components/ui/core/data-grid/data-grid.utils.js.map +1 -0
  159. package/dist/components/ui/core/data-grid/index.d.ts +6 -1
  160. package/dist/components/ui/core/data-grid/index.js +6 -2
  161. package/dist/components/ui/core/data-grid/index.js.map +1 -0
  162. package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.d.ts +11 -13
  163. package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.js +85 -61
  164. package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.js.map +1 -0
  165. package/dist/components/ui/core/date-time-pickers/date-picker/index.d.ts +3 -3
  166. package/dist/components/ui/core/date-time-pickers/date-picker/index.js +3 -0
  167. package/dist/components/ui/core/date-time-pickers/date-picker/index.js.map +1 -0
  168. package/dist/components/ui/core/date-time-pickers/date-picker/types.d.ts +14 -14
  169. package/dist/components/ui/core/date-time-pickers/date-picker/types.js +3 -0
  170. package/dist/components/ui/core/date-time-pickers/date-picker/types.js.map +1 -0
  171. package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.d.ts +2 -2
  172. package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.js +51 -36
  173. package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.js.map +1 -0
  174. package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.d.ts +11 -13
  175. package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js +89 -64
  176. package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js.map +1 -0
  177. package/dist/components/ui/core/date-time-pickers/date-range-picker/index.d.ts +3 -3
  178. package/dist/components/ui/core/date-time-pickers/date-range-picker/index.js +3 -0
  179. package/dist/components/ui/core/date-time-pickers/date-range-picker/index.js.map +1 -0
  180. package/dist/components/ui/core/date-time-pickers/date-range-picker/types.d.ts +20 -20
  181. package/dist/components/ui/core/date-time-pickers/date-range-picker/types.js +3 -0
  182. package/dist/components/ui/core/date-time-pickers/date-range-picker/types.js.map +1 -0
  183. package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.d.ts +4 -4
  184. package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js +95 -60
  185. package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js.map +1 -0
  186. package/dist/components/ui/core/date-time-pickers/date-time-picker/date-time-picker.d.ts +15 -0
  187. package/dist/components/ui/core/date-time-pickers/date-time-picker/date-time-picker.js +120 -0
  188. package/dist/components/ui/core/date-time-pickers/date-time-picker/date-time-picker.js.map +1 -0
  189. package/dist/components/ui/core/date-time-pickers/date-time-picker/index.d.ts +3 -1
  190. package/dist/components/ui/core/date-time-pickers/date-time-picker/index.js +3 -0
  191. package/dist/components/ui/core/date-time-pickers/date-time-picker/index.js.map +1 -0
  192. package/dist/components/ui/core/date-time-pickers/date-time-picker/types.d.ts +25 -32
  193. package/dist/components/ui/core/date-time-pickers/date-time-picker/types.js +3 -0
  194. package/dist/components/ui/core/date-time-pickers/date-time-picker/types.js.map +1 -0
  195. package/dist/components/ui/core/date-time-pickers/date-time-picker/use-date-time-picker.d.ts +2 -2
  196. package/dist/components/ui/core/date-time-pickers/date-time-picker/use-date-time-picker.js +78 -0
  197. package/dist/components/ui/core/date-time-pickers/date-time-picker/use-date-time-picker.js.map +1 -0
  198. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.d.ts +13 -15
  199. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js +165 -119
  200. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js.map +1 -0
  201. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/index.d.ts +3 -3
  202. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/index.js +3 -0
  203. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/index.js.map +1 -0
  204. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.d.ts +37 -37
  205. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.js +3 -0
  206. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.js.map +1 -0
  207. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.d.ts +3 -3
  208. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js +163 -104
  209. package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js.map +1 -0
  210. package/dist/components/ui/core/date-time-pickers/index.d.ts +17 -12
  211. package/dist/components/ui/core/date-time-pickers/index.js +10 -6
  212. package/dist/components/ui/core/date-time-pickers/index.js.map +1 -0
  213. package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.d.ts +5 -5
  214. package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.js +52 -42
  215. package/dist/components/ui/core/date-time-pickers/shared/am-pm-scroll/am-pm-scroll.js.map +1 -0
  216. package/dist/components/ui/core/date-time-pickers/shared/constants.d.ts +6 -1
  217. package/dist/components/ui/core/date-time-pickers/shared/constants.js +23 -0
  218. package/dist/components/ui/core/date-time-pickers/shared/constants.js.map +1 -0
  219. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.d.ts +16 -15
  220. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js +87 -64
  221. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js.map +1 -0
  222. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.d.ts +10 -9
  223. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.js +89 -38
  224. package/dist/components/ui/core/date-time-pickers/shared/date-time-input/range-input-display.js.map +1 -0
  225. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.d.ts +5 -5
  226. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js +34 -23
  227. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js.map +1 -0
  228. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.d.ts +23 -23
  229. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.js +95 -52
  230. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-date-state.js.map +1 -0
  231. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.d.ts +5 -5
  232. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.js +22 -18
  233. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-range-step-manager.js.map +1 -0
  234. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.d.ts +19 -19
  235. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.js +41 -24
  236. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.js.map +1 -0
  237. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.d.ts +13 -13
  238. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.js +33 -24
  239. package/dist/components/ui/core/date-time-pickers/shared/hooks/use-time-state.js.map +1 -0
  240. package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.d.ts +5 -5
  241. package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.js +9 -4
  242. package/dist/components/ui/core/date-time-pickers/shared/scroll-cell-classes.js.map +1 -0
  243. package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.d.ts +13 -9
  244. package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.js +22 -17
  245. package/dist/components/ui/core/date-time-pickers/shared/shortcuts-panel/shortcuts-panel.js.map +1 -0
  246. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/index.d.ts +2 -2
  247. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/index.js +3 -0
  248. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/index.js.map +1 -0
  249. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.d.ts +13 -13
  250. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.js +49 -40
  251. package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.js.map +1 -0
  252. package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.d.ts +7 -7
  253. package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.js +41 -34
  254. package/dist/components/ui/core/date-time-pickers/shared/time-picker-scroll/time-picker-scroll.js.map +1 -0
  255. package/dist/components/ui/core/date-time-pickers/time-picker/index.d.ts +3 -3
  256. package/dist/components/ui/core/date-time-pickers/time-picker/index.js +3 -0
  257. package/dist/components/ui/core/date-time-pickers/time-picker/index.js.map +1 -0
  258. package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.d.ts +12 -14
  259. package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.js +99 -79
  260. package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.js.map +1 -0
  261. package/dist/components/ui/core/date-time-pickers/time-picker/types.d.ts +20 -20
  262. package/dist/components/ui/core/date-time-pickers/time-picker/types.js +3 -0
  263. package/dist/components/ui/core/date-time-pickers/time-picker/types.js.map +1 -0
  264. package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.d.ts +2 -2
  265. package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.js +63 -41
  266. package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.js.map +1 -0
  267. package/dist/components/ui/core/date-time-pickers/time-range-picker/index.d.ts +3 -1
  268. package/dist/components/ui/core/date-time-pickers/time-range-picker/index.js +3 -0
  269. package/dist/components/ui/core/date-time-pickers/time-range-picker/index.js.map +1 -0
  270. package/dist/components/ui/core/date-time-pickers/time-range-picker/time-range-picker.d.ts +14 -0
  271. package/dist/components/ui/core/date-time-pickers/time-range-picker/time-range-picker.js +115 -0
  272. package/dist/components/ui/core/date-time-pickers/time-range-picker/time-range-picker.js.map +1 -0
  273. package/dist/components/ui/core/date-time-pickers/time-range-picker/types.d.ts +30 -36
  274. package/dist/components/ui/core/date-time-pickers/time-range-picker/types.js +3 -0
  275. package/dist/components/ui/core/date-time-pickers/time-range-picker/types.js.map +1 -0
  276. package/dist/components/ui/core/date-time-pickers/time-range-picker/use-time-range-picker.d.ts +2 -2
  277. package/dist/components/ui/core/date-time-pickers/time-range-picker/use-time-range-picker.js +145 -0
  278. package/dist/components/ui/core/date-time-pickers/time-range-picker/use-time-range-picker.js.map +1 -0
  279. package/dist/components/ui/core/date-time-pickers/utils/date-input.d.ts +56 -0
  280. package/dist/components/ui/core/date-time-pickers/utils/date-input.js +67 -0
  281. package/dist/components/ui/core/date-time-pickers/utils/date-input.js.map +1 -0
  282. package/dist/components/ui/core/date-time-pickers/utils/date-range-utils.d.ts +18 -18
  283. package/dist/components/ui/core/date-time-pickers/utils/date-range-utils.js +42 -0
  284. package/dist/components/ui/core/date-time-pickers/utils/date-range-utils.js.map +1 -0
  285. package/dist/components/ui/core/date-time-pickers/utils/format-utils.d.ts +31 -29
  286. package/dist/components/ui/core/date-time-pickers/utils/format-utils.js +56 -0
  287. package/dist/components/ui/core/date-time-pickers/utils/format-utils.js.map +1 -0
  288. package/dist/components/ui/core/date-time-pickers/utils/segment-utils.d.ts +21 -21
  289. package/dist/components/ui/core/date-time-pickers/utils/segment-utils.js +170 -0
  290. package/dist/components/ui/core/date-time-pickers/utils/segment-utils.js.map +1 -0
  291. package/dist/components/ui/core/date-time-pickers/utils/time-utils.d.ts +28 -28
  292. package/dist/components/ui/core/date-time-pickers/utils/time-utils.js +88 -7
  293. package/dist/components/ui/core/date-time-pickers/utils/time-utils.js.map +1 -0
  294. package/dist/components/ui/core/date-time-pickers/utils/time-validation.d.ts +17 -17
  295. package/dist/components/ui/core/date-time-pickers/utils/time-validation.js +43 -0
  296. package/dist/components/ui/core/date-time-pickers/utils/time-validation.js.map +1 -0
  297. package/dist/components/ui/core/dialog/dialog.d.ts +12 -9
  298. package/dist/components/ui/core/dialog/dialog.js +90 -82
  299. package/dist/components/ui/core/dialog/dialog.js.map +1 -0
  300. package/dist/components/ui/core/dropdown-menu/dropdown-menu.d.ts +22 -19
  301. package/dist/components/ui/core/dropdown-menu/dropdown-menu.js +204 -149
  302. package/dist/components/ui/core/dropdown-menu/dropdown-menu.js.map +1 -0
  303. package/dist/components/ui/core/empty-state/empty-state.context.d.ts +4 -4
  304. package/dist/components/ui/core/empty-state/empty-state.context.js +8 -5
  305. package/dist/components/ui/core/empty-state/empty-state.context.js.map +1 -0
  306. package/dist/components/ui/core/empty-state/empty-state.d.ts +14 -14
  307. package/dist/components/ui/core/empty-state/empty-state.js +96 -82
  308. package/dist/components/ui/core/empty-state/empty-state.js.map +1 -0
  309. package/dist/components/ui/core/helper-text/helper-text.d.ts +7 -7
  310. package/dist/components/ui/core/helper-text/helper-text.js +55 -36
  311. package/dist/components/ui/core/helper-text/helper-text.js.map +1 -0
  312. package/dist/components/ui/core/hover-card/hover-card.d.ts +7 -6
  313. package/dist/components/ui/core/hover-card/hover-card.js +56 -52
  314. package/dist/components/ui/core/hover-card/hover-card.js.map +1 -0
  315. package/dist/components/ui/core/inline-citation/inline-citation.d.ts +26 -25
  316. package/dist/components/ui/core/inline-citation/inline-citation.js +121 -97
  317. package/dist/components/ui/core/inline-citation/inline-citation.js.map +1 -0
  318. package/dist/components/ui/core/input/input.d.ts +2 -2
  319. package/dist/components/ui/core/input/input.gallery.d.ts +2 -0
  320. package/dist/components/ui/core/input/input.gallery.js +89 -0
  321. package/dist/components/ui/core/input/input.gallery.js.map +1 -0
  322. package/dist/components/ui/core/input/input.js +15 -13
  323. package/dist/components/ui/core/input/input.js.map +1 -0
  324. package/dist/components/ui/core/input-group/input-group.d.ts +25 -14
  325. package/dist/components/ui/core/input-group/input-group.js +149 -76
  326. package/dist/components/ui/core/input-group/input-group.js.map +1 -0
  327. package/dist/components/ui/core/item/item.d.ts +20 -0
  328. package/dist/components/ui/core/item/item.js +93 -0
  329. package/dist/components/ui/core/item/item.js.map +1 -0
  330. package/dist/components/ui/core/kbd/kbd.d.ts +3 -3
  331. package/dist/components/ui/core/kbd/kbd.js +24 -20
  332. package/dist/components/ui/core/kbd/kbd.js.map +1 -0
  333. package/dist/components/ui/core/label/label.d.ts +3 -3
  334. package/dist/components/ui/core/label/label.gallery.d.ts +2 -0
  335. package/dist/components/ui/core/label/label.gallery.js +57 -0
  336. package/dist/components/ui/core/label/label.gallery.js.map +1 -0
  337. package/dist/components/ui/core/label/label.js +33 -26
  338. package/dist/components/ui/core/label/label.js.map +1 -0
  339. package/dist/components/ui/core/loader/loader.d.ts +6 -6
  340. package/dist/components/ui/core/loader/loader.js +97 -80
  341. package/dist/components/ui/core/loader/loader.js.map +1 -0
  342. package/dist/components/ui/core/message/message-response-default-streamdown-controls.d.ts +8 -9
  343. package/dist/components/ui/core/message/message-response-default-streamdown-controls.js +18 -12
  344. package/dist/components/ui/core/message/message-response-default-streamdown-controls.js.map +1 -0
  345. package/dist/components/ui/core/message/message-response-math-plugin.d.ts +3 -0
  346. package/dist/components/ui/core/message/message-response-math-plugin.js +6 -0
  347. package/dist/components/ui/core/message/message-response-math-plugin.js.map +1 -0
  348. package/dist/components/ui/core/message/message.d.ts +27 -23
  349. package/dist/components/ui/core/message/message.js +458 -316
  350. package/dist/components/ui/core/message/message.js.map +1 -0
  351. package/dist/components/ui/core/overflow-list/overflow-list.d.ts +21 -0
  352. package/dist/components/ui/core/overflow-list/overflow-list.js +197 -0
  353. package/dist/components/ui/core/overflow-list/overflow-list.js.map +1 -0
  354. package/dist/components/ui/core/overflow-list/overflow-list.utils.d.ts +37 -35
  355. package/dist/components/ui/core/overflow-list/overflow-list.utils.js +206 -0
  356. package/dist/components/ui/core/overflow-list/overflow-list.utils.js.map +1 -0
  357. package/dist/components/ui/core/pagination/pagination-size-context.d.ts +2 -2
  358. package/dist/components/ui/core/pagination/pagination-size-context.js +6 -5
  359. package/dist/components/ui/core/pagination/pagination-size-context.js.map +1 -0
  360. package/dist/components/ui/core/pagination/pagination-teleport.d.ts +9 -9
  361. package/dist/components/ui/core/pagination/pagination-teleport.js +127 -84
  362. package/dist/components/ui/core/pagination/pagination-teleport.js.map +1 -0
  363. package/dist/components/ui/core/pagination/pagination-teleport.utils.js +6 -6
  364. package/dist/components/ui/core/pagination/pagination-teleport.utils.js.map +1 -0
  365. package/dist/components/ui/core/pagination/pagination.d.ts +39 -39
  366. package/dist/components/ui/core/pagination/pagination.js +294 -234
  367. package/dist/components/ui/core/pagination/pagination.js.map +1 -0
  368. package/dist/components/ui/core/popover/popover.d.ts +12 -11
  369. package/dist/components/ui/core/popover/popover.js +104 -89
  370. package/dist/components/ui/core/popover/popover.js.map +1 -0
  371. package/dist/components/ui/core/progress/progress.d.ts +9 -8
  372. package/dist/components/ui/core/progress/progress.js +50 -35
  373. package/dist/components/ui/core/progress/progress.js.map +1 -0
  374. package/dist/components/ui/core/prompt-input/prompt-input.d.ts +27 -27
  375. package/dist/components/ui/core/prompt-input/prompt-input.js +342 -271
  376. package/dist/components/ui/core/prompt-input/prompt-input.js.map +1 -0
  377. package/dist/components/ui/core/radio-group/radio-group.d.ts +12 -12
  378. package/dist/components/ui/core/radio-group/radio-group.gallery.d.ts +2 -0
  379. package/dist/components/ui/core/radio-group/radio-group.gallery.js +44 -0
  380. package/dist/components/ui/core/radio-group/radio-group.gallery.js.map +1 -0
  381. package/dist/components/ui/core/radio-group/radio-group.js +88 -58
  382. package/dist/components/ui/core/radio-group/radio-group.js.map +1 -0
  383. package/dist/components/ui/core/reasoning/reasoning.d.ts +7 -7
  384. package/dist/components/ui/core/reasoning/reasoning.js +68 -56
  385. package/dist/components/ui/core/reasoning/reasoning.js.map +1 -0
  386. package/dist/components/ui/core/scroll-area/scroll-area.d.ts +4 -4
  387. package/dist/components/ui/core/scroll-area/scroll-area.js +50 -40
  388. package/dist/components/ui/core/scroll-area/scroll-area.js.map +1 -0
  389. package/dist/components/ui/core/search/search.d.ts +8 -8
  390. package/dist/components/ui/core/search/search.js +122 -76
  391. package/dist/components/ui/core/search/search.js.map +1 -0
  392. package/dist/components/ui/core/segmented-control/segmented-control.d.ts +10 -10
  393. package/dist/components/ui/core/segmented-control/segmented-control.js +203 -149
  394. package/dist/components/ui/core/segmented-control/segmented-control.js.map +1 -0
  395. package/dist/components/ui/core/select/select.d.ts +33 -26
  396. package/dist/components/ui/core/select/select.js +262 -168
  397. package/dist/components/ui/core/select/select.js.map +1 -0
  398. package/dist/components/ui/core/separator/separator.d.ts +2 -2
  399. package/dist/components/ui/core/separator/separator.gallery.d.ts +2 -0
  400. package/dist/components/ui/core/separator/separator.gallery.js +63 -0
  401. package/dist/components/ui/core/separator/separator.gallery.js.map +1 -0
  402. package/dist/components/ui/core/separator/separator.js +13 -13
  403. package/dist/components/ui/core/separator/separator.js.map +1 -0
  404. package/dist/components/ui/core/shimmer/shimmer.d.ts +8 -8
  405. package/dist/components/ui/core/shimmer/shimmer.js +64 -40
  406. package/dist/components/ui/core/shimmer/shimmer.js.map +1 -0
  407. package/dist/components/ui/core/skeleton/skeleton.d.ts +2 -2
  408. package/dist/components/ui/core/skeleton/skeleton.gallery.d.ts +2 -0
  409. package/dist/components/ui/core/skeleton/skeleton.gallery.js +22 -0
  410. package/dist/components/ui/core/skeleton/skeleton.gallery.js.map +1 -0
  411. package/dist/components/ui/core/skeleton/skeleton.js +13 -13
  412. package/dist/components/ui/core/skeleton/skeleton.js.map +1 -0
  413. package/dist/components/ui/core/slider/slider.d.ts +7 -7
  414. package/dist/components/ui/core/slider/slider.gallery.d.ts +2 -0
  415. package/dist/components/ui/core/slider/slider.gallery.js +62 -0
  416. package/dist/components/ui/core/slider/slider.gallery.js.map +1 -0
  417. package/dist/components/ui/core/slider/slider.js +51 -39
  418. package/dist/components/ui/core/slider/slider.js.map +1 -0
  419. package/dist/components/ui/core/sonner-toast/sonner-toast.d.ts +2 -2
  420. package/dist/components/ui/core/sonner-toast/sonner-toast.js +67 -54
  421. package/dist/components/ui/core/sonner-toast/sonner-toast.js.map +1 -0
  422. package/dist/components/ui/core/sources/sources.d.ts +12 -12
  423. package/dist/components/ui/core/sources/sources.js +87 -58
  424. package/dist/components/ui/core/sources/sources.js.map +1 -0
  425. package/dist/components/ui/core/status-text/status-text.d.ts +4 -0
  426. package/dist/components/ui/core/status-text/status-text.js +14 -0
  427. package/dist/components/ui/core/status-text/status-text.js.map +1 -0
  428. package/dist/components/ui/core/switch/switch.d.ts +9 -9
  429. package/dist/components/ui/core/switch/switch.gallery.d.ts +2 -0
  430. package/dist/components/ui/core/switch/switch.gallery.js +67 -0
  431. package/dist/components/ui/core/switch/switch.gallery.js.map +1 -0
  432. package/dist/components/ui/core/switch/switch.js +83 -61
  433. package/dist/components/ui/core/switch/switch.js.map +1 -0
  434. package/dist/components/ui/core/switch/switch.metadata.d.ts +1 -1
  435. package/dist/components/ui/core/switch/switch.metadata.js +8 -0
  436. package/dist/components/ui/core/switch/switch.metadata.js.map +1 -0
  437. package/dist/components/ui/core/tabs/tabs.d.ts +20 -18
  438. package/dist/components/ui/core/tabs/tabs.js +176 -147
  439. package/dist/components/ui/core/tabs/tabs.js.map +1 -0
  440. package/dist/components/ui/core/tabs/tabs.utils.d.ts +1 -1
  441. package/dist/components/ui/core/tabs/tabs.utils.js +10 -6
  442. package/dist/components/ui/core/tabs/tabs.utils.js.map +1 -0
  443. package/dist/components/ui/core/textarea/textarea.d.ts +2 -2
  444. package/dist/components/ui/core/textarea/textarea.gallery.d.ts +2 -0
  445. package/dist/components/ui/core/textarea/textarea.gallery.js +51 -0
  446. package/dist/components/ui/core/textarea/textarea.gallery.js.map +1 -0
  447. package/dist/components/ui/core/textarea/textarea.js +13 -13
  448. package/dist/components/ui/core/textarea/textarea.js.map +1 -0
  449. package/dist/components/ui/core/toggle/toggle.d.ts +9 -9
  450. package/dist/components/ui/core/toggle/toggle.gallery.d.ts +2 -0
  451. package/dist/components/ui/core/toggle/toggle.gallery.js +32 -0
  452. package/dist/components/ui/core/toggle/toggle.gallery.js.map +1 -0
  453. package/dist/components/ui/core/toggle/toggle.js +60 -54
  454. package/dist/components/ui/core/toggle/toggle.js.map +1 -0
  455. package/dist/components/ui/core/tool/tool.d.ts +18 -18
  456. package/dist/components/ui/core/tool/tool.js +167 -126
  457. package/dist/components/ui/core/tool/tool.js.map +1 -0
  458. package/dist/components/ui/core/toolbar/toolbar.d.ts +37 -0
  459. package/dist/components/ui/core/toolbar/toolbar.js +171 -0
  460. package/dist/components/ui/core/toolbar/toolbar.js.map +1 -0
  461. package/dist/components/ui/core/tooltip/tooltip.d.ts +8 -7
  462. package/dist/components/ui/core/tooltip/tooltip.gallery.d.ts +2 -0
  463. package/dist/components/ui/core/tooltip/tooltip.gallery.js +52 -0
  464. package/dist/components/ui/core/tooltip/tooltip.gallery.js.map +1 -0
  465. package/dist/components/ui/core/tooltip/tooltip.js +53 -46
  466. package/dist/components/ui/core/tooltip/tooltip.js.map +1 -0
  467. package/dist/components/ui/core/topbar/topbar.d.ts +26 -26
  468. package/dist/components/ui/core/topbar/topbar.js +160 -105
  469. package/dist/components/ui/core/topbar/topbar.js.map +1 -0
  470. package/dist/components/ui/core/tree/tree.d.ts +20 -0
  471. package/dist/components/ui/core/tree/tree.js +100 -0
  472. package/dist/components/ui/core/tree/tree.js.map +1 -0
  473. package/dist/eslint/index.d.ts +5 -5
  474. package/dist/eslint/index.js +9 -5
  475. package/dist/eslint/index.js.map +1 -0
  476. package/dist/eslint/no-overriding-styles.d.ts +1 -1
  477. package/dist/eslint/no-overriding-styles.js +341 -201
  478. package/dist/eslint/no-overriding-styles.js.map +1 -0
  479. package/dist/icons/index.d.ts +1 -1
  480. package/dist/icons/index.js +2 -0
  481. package/dist/icons/index.js.map +1 -0
  482. package/dist/index.d.ts +1 -1
  483. package/dist/index.js +3 -0
  484. package/dist/index.js.map +1 -0
  485. package/dist/lib/ai/types.d.ts +43 -43
  486. package/dist/lib/ai/types.js +3 -0
  487. package/dist/lib/ai/types.js.map +1 -0
  488. package/dist/lib/decorative-variant-classes.d.ts +53 -0
  489. package/dist/lib/decorative-variant-classes.js +58 -0
  490. package/dist/lib/decorative-variant-classes.js.map +1 -0
  491. package/dist/lib/highlight-code.d.ts +11 -8
  492. package/dist/lib/highlight-code.js +58 -40
  493. package/dist/lib/highlight-code.js.map +1 -0
  494. package/dist/lib/portal-container-context.d.ts +1 -1
  495. package/dist/lib/portal-container-context.js +8 -8
  496. package/dist/lib/portal-container-context.js.map +1 -0
  497. package/dist/lib/shared-theme-from-url.d.ts +13 -0
  498. package/dist/lib/shared-theme-from-url.js +61 -0
  499. package/dist/lib/shared-theme-from-url.js.map +1 -0
  500. package/dist/lib/style-scope.d.ts +2 -2
  501. package/dist/lib/style-scope.js +6 -6
  502. package/dist/lib/style-scope.js.map +1 -0
  503. package/dist/lib/theme-share-url.d.ts +31 -0
  504. package/dist/lib/theme-share-url.js +116 -0
  505. package/dist/lib/theme-share-url.js.map +1 -0
  506. package/dist/lib/types.d.ts +39 -39
  507. package/dist/lib/types.js +3 -0
  508. package/dist/lib/types.js.map +1 -0
  509. package/dist/lib/use-controllable-state.d.ts +4 -7
  510. package/dist/lib/use-controllable-state.js +34 -21
  511. package/dist/lib/use-controllable-state.js.map +1 -0
  512. package/dist/lib/utils.d.ts +63 -34
  513. package/dist/lib/utils.js +134 -32
  514. package/dist/lib/utils.js.map +1 -0
  515. package/dist/styles.css +2 -1
  516. package/dist/styles.source.css +46 -16
  517. package/dist/utils/assign-ref.d.ts +3 -0
  518. package/dist/utils/assign-ref.js +13 -0
  519. package/dist/utils/assign-ref.js.map +1 -0
  520. package/package.json +49 -14
  521. package/src/components/ui/core/alert/alert.md +46 -0
  522. package/src/components/ui/core/avatar/avatar.md +30 -0
  523. package/src/components/ui/core/badge/badge.md +32 -0
  524. package/src/components/ui/core/banner/banner.md +51 -0
  525. package/src/components/ui/core/breadcrumb/breadcrumb.md +45 -0
  526. package/src/components/ui/core/button/button.md +93 -0
  527. package/src/components/ui/core/button-group/button-group.md +38 -0
  528. package/src/components/ui/core/checkbox/checkbox.md +37 -0
  529. package/src/components/ui/core/collapsible/collapsible.md +42 -0
  530. package/src/components/ui/core/count/count.md +33 -0
  531. package/src/components/ui/core/input/input.md +48 -0
  532. package/src/components/ui/core/label/label.md +35 -0
  533. package/src/components/ui/core/radio-group/radio-group.md +38 -0
  534. package/src/components/ui/core/separator/separator.md +32 -0
  535. package/src/components/ui/core/skeleton/skeleton.md +33 -0
  536. package/src/components/ui/core/slider/slider.md +41 -0
  537. package/src/components/ui/core/switch/switch.md +26 -0
  538. package/src/components/ui/core/textarea/textarea.md +42 -0
  539. package/src/components/ui/core/toggle/toggle.md +39 -0
  540. package/src/components/ui/core/tooltip/tooltip.md +41 -0
@@ -0,0 +1,115 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../../../../../lib/utils.js";
3
+ import { Button } from "../../button/button.js";
4
+ import { Popover, PopoverContent, PopoverTrigger } from "../../popover/popover.js";
5
+ import { DateTimeInput } from "../shared/date-time-input/date-time-input.js";
6
+ import { ShortcutsPanel } from "../shared/shortcuts-panel/shortcuts-panel.js";
7
+ import { TimePickerPanel } from "../shared/time-picker-panel/time-picker-panel.js";
8
+ import { normalizeIn, normalizeOutRange, normalizeShortcutValue, resolveValueType } from "../utils/date-input.js";
9
+ import { useTimeRangePicker } from "./use-time-range-picker.js";
10
+ export function TimeRangePicker({ value, onChange, timeFormat = '24h', format, placeholder, shortcuts, defaultDate, valueType, className }) {
11
+ const displayFormat = format ?? (timeFormat === '12h' ? 'h:mm A' : 'HH:mm');
12
+ const resolvedType = resolveValueType(value[0] ?? value[1], defaultDate, valueType);
13
+ const djValue = [
14
+ normalizeIn(value[0]),
15
+ normalizeIn(value[1])
16
+ ];
17
+ const djDefault = defaultDate != null ? normalizeIn(defaultDate) ?? undefined : undefined;
18
+ const handleChange = (range)=>{
19
+ onChange(normalizeOutRange(range, resolvedType));
20
+ };
21
+ const djShortcuts = shortcuts?.map((shortcut)=>({
22
+ ...shortcut,
23
+ getValue: ()=>normalizeShortcutValue(shortcut.getValue())
24
+ }));
25
+ const { isOpen, step, tempStartHour, tempStartMinute, tempEndHour, tempEndMinute, startAmPm, endAmPm, displayValue, handleOpenChange, handleSetStep, handleStartHourChange, handleStartMinuteChange, handleEndHourChange, handleEndMinuteChange, handleStartAmPmChange, handleEndAmPmChange, handleNext, handleApply, handleApplyShortcut, inputRef, popoverRef } = useTimeRangePicker({
26
+ value: djValue,
27
+ onChange: handleChange,
28
+ timeFormat,
29
+ defaultDate: djDefault
30
+ });
31
+ const currentHour = step === 'start' ? tempStartHour : tempEndHour;
32
+ const currentMinute = step === 'start' ? tempStartMinute : tempEndMinute;
33
+ const currentAmPm = step === 'start' ? startAmPm : endAmPm;
34
+ const onHourChange = step === 'start' ? handleStartHourChange : handleEndHourChange;
35
+ const onMinuteChange = step === 'start' ? handleStartMinuteChange : handleEndMinuteChange;
36
+ const onAmPmChange = step === 'start' ? handleStartAmPmChange : handleEndAmPmChange;
37
+ return /*#__PURE__*/ _jsx("div", {
38
+ "data-slot": "time-range-picker",
39
+ className: cn('relative w-full', className),
40
+ children: /*#__PURE__*/ _jsxs(Popover, {
41
+ open: isOpen,
42
+ onOpenChange: handleOpenChange,
43
+ children: [
44
+ /*#__PURE__*/ _jsx(PopoverTrigger, {
45
+ render: /*#__PURE__*/ _jsx("div", {
46
+ ref: inputRef,
47
+ className: "w-full"
48
+ }),
49
+ children: /*#__PURE__*/ _jsx(DateTimeInput, {
50
+ value: displayValue,
51
+ format: displayFormat,
52
+ placeholder: placeholder,
53
+ isOpen: isOpen,
54
+ variant: "time",
55
+ ariaLabel: "Time range picker",
56
+ activeRangePart: isOpen ? step : undefined,
57
+ onRangePartClick: isOpen ? handleSetStep : undefined
58
+ })
59
+ }),
60
+ /*#__PURE__*/ _jsx(PopoverContent, {
61
+ ref: popoverRef,
62
+ className: "rounded-xl w-auto p-0",
63
+ side: "bottom",
64
+ align: "start",
65
+ children: /*#__PURE__*/ _jsxs("div", {
66
+ "data-slot": "time-range-picker-content",
67
+ className: "flex flex-col",
68
+ children: [
69
+ /*#__PURE__*/ _jsxs("div", {
70
+ className: "flex flex-row",
71
+ children: [
72
+ djShortcuts && djShortcuts.length > 0 && /*#__PURE__*/ _jsx(ShortcutsPanel, {
73
+ shortcuts: djShortcuts,
74
+ onShortcutClick: handleApplyShortcut
75
+ }),
76
+ timeFormat === '12h' ? /*#__PURE__*/ _jsx(TimePickerPanel, {
77
+ hour: currentHour,
78
+ minute: currentMinute,
79
+ amPm: currentAmPm,
80
+ timeFormat: "12h",
81
+ onHourChange: onHourChange,
82
+ onMinuteChange: onMinuteChange,
83
+ onAmPmChange: onAmPmChange
84
+ }) : /*#__PURE__*/ _jsx(TimePickerPanel, {
85
+ hour: currentHour,
86
+ minute: currentMinute,
87
+ timeFormat: "24h",
88
+ onHourChange: onHourChange,
89
+ onMinuteChange: onMinuteChange
90
+ })
91
+ ]
92
+ }),
93
+ /*#__PURE__*/ _jsx("div", {
94
+ className: "flex p-2 border-t border-border",
95
+ children: step === 'start' ? /*#__PURE__*/ _jsx(Button, {
96
+ variant: "secondary",
97
+ className: "w-full",
98
+ onClick: handleNext,
99
+ children: "Next"
100
+ }) : /*#__PURE__*/ _jsx(Button, {
101
+ variant: "secondary",
102
+ className: "w-full",
103
+ onClick: handleApply,
104
+ children: "Apply"
105
+ })
106
+ })
107
+ ]
108
+ })
109
+ })
110
+ ]
111
+ })
112
+ });
113
+ }
114
+
115
+ //# sourceMappingURL=time-range-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/components/ui/core/date-time-pickers/time-range-picker/time-range-picker.tsx"],"sourcesContent":["import type { JSX } from 'react';\n\nimport type { Dayjs } from 'dayjs';\n\nimport { cn } from '../../../../../lib/utils';\nimport { Button } from '../../button/button';\nimport { Popover, PopoverContent, PopoverTrigger } from '../../popover/popover';\nimport { DateTimeInput } from '../shared/date-time-input/date-time-input';\nimport { ShortcutsPanel } from '../shared/shortcuts-panel/shortcuts-panel';\nimport type { ShortcutItem } from '../shared/shortcuts-panel/shortcuts-panel';\nimport { TimePickerPanel } from '../shared/time-picker-panel/time-picker-panel';\nimport {\n type DateInput,\n type DateRangeValueProps,\n normalizeIn,\n normalizeOutRange,\n normalizeShortcutValue,\n resolveValueType,\n} from '../utils/date-input';\nimport type { TimeFormat } from '../utils/format-utils';\n\nimport { useTimeRangePicker } from './use-time-range-picker';\n\nexport type { ShortcutItem };\n\nexport interface TimeRangePickerProps<\n T extends DateInput = Dayjs,\n> extends DateRangeValueProps<T> {\n timeFormat?: TimeFormat;\n format?: string;\n placeholder?: string;\n shortcuts?: ShortcutItem[];\n className?: string;\n}\n\nexport function TimeRangePicker<T extends DateInput = Dayjs>({\n value,\n onChange,\n timeFormat = '24h',\n format,\n placeholder,\n shortcuts,\n defaultDate,\n valueType,\n className,\n}: TimeRangePickerProps<T>): JSX.Element {\n const displayFormat = format ?? (timeFormat === '12h' ? 'h:mm A' : 'HH:mm');\n const resolvedType = resolveValueType(\n value[0] ?? value[1],\n defaultDate,\n valueType\n );\n const djValue: [Dayjs | null, Dayjs | null] = [\n normalizeIn(value[0]),\n normalizeIn(value[1]),\n ];\n const djDefault =\n defaultDate != null ? (normalizeIn(defaultDate) ?? undefined) : undefined;\n\n const handleChange = (range: [Dayjs | null, Dayjs | null]) => {\n onChange(normalizeOutRange<T>(range, resolvedType));\n };\n\n const djShortcuts = shortcuts?.map((shortcut) => ({\n ...shortcut,\n getValue: () => normalizeShortcutValue(shortcut.getValue()),\n }));\n\n const {\n isOpen,\n step,\n tempStartHour,\n tempStartMinute,\n tempEndHour,\n tempEndMinute,\n startAmPm,\n endAmPm,\n displayValue,\n handleOpenChange,\n handleSetStep,\n handleStartHourChange,\n handleStartMinuteChange,\n handleEndHourChange,\n handleEndMinuteChange,\n handleStartAmPmChange,\n handleEndAmPmChange,\n handleNext,\n handleApply,\n handleApplyShortcut,\n inputRef,\n popoverRef,\n } = useTimeRangePicker({\n value: djValue,\n onChange: handleChange,\n timeFormat,\n defaultDate: djDefault,\n });\n\n const currentHour = step === 'start' ? tempStartHour : tempEndHour;\n const currentMinute = step === 'start' ? tempStartMinute : tempEndMinute;\n const currentAmPm = step === 'start' ? startAmPm : endAmPm;\n const onHourChange =\n step === 'start' ? handleStartHourChange : handleEndHourChange;\n const onMinuteChange =\n step === 'start' ? handleStartMinuteChange : handleEndMinuteChange;\n const onAmPmChange =\n step === 'start' ? handleStartAmPmChange : handleEndAmPmChange;\n\n return (\n <div\n data-slot=\"time-range-picker\"\n className={cn('relative w-full', className)}\n >\n <Popover open={isOpen} onOpenChange={handleOpenChange}>\n <PopoverTrigger render={<div ref={inputRef} className=\"w-full\" />}>\n <DateTimeInput\n value={displayValue}\n format={displayFormat}\n placeholder={placeholder}\n isOpen={isOpen}\n variant=\"time\"\n ariaLabel=\"Time range picker\"\n activeRangePart={isOpen ? step : undefined}\n onRangePartClick={isOpen ? handleSetStep : undefined}\n />\n </PopoverTrigger>\n <PopoverContent\n ref={popoverRef}\n className=\"rounded-xl w-auto p-0\"\n side=\"bottom\"\n align=\"start\"\n >\n <div data-slot=\"time-range-picker-content\" className=\"flex flex-col\">\n <div className=\"flex flex-row\">\n {djShortcuts && djShortcuts.length > 0 && (\n <ShortcutsPanel\n shortcuts={djShortcuts}\n onShortcutClick={handleApplyShortcut}\n />\n )}\n {timeFormat === '12h' ? (\n <TimePickerPanel\n hour={currentHour}\n minute={currentMinute}\n amPm={currentAmPm}\n timeFormat=\"12h\"\n onHourChange={onHourChange}\n onMinuteChange={onMinuteChange}\n onAmPmChange={onAmPmChange}\n />\n ) : (\n <TimePickerPanel\n hour={currentHour}\n minute={currentMinute}\n timeFormat=\"24h\"\n onHourChange={onHourChange}\n onMinuteChange={onMinuteChange}\n />\n )}\n </div>\n <div className=\"flex p-2 border-t border-border\">\n {step === 'start' ? (\n <Button\n variant=\"secondary\"\n className=\"w-full\"\n onClick={handleNext}\n >\n Next\n </Button>\n ) : (\n <Button\n variant=\"secondary\"\n className=\"w-full\"\n onClick={handleApply}\n >\n Apply\n </Button>\n )}\n </div>\n </div>\n </PopoverContent>\n </Popover>\n </div>\n );\n}\n"],"names":["cn","Button","Popover","PopoverContent","PopoverTrigger","DateTimeInput","ShortcutsPanel","TimePickerPanel","normalizeIn","normalizeOutRange","normalizeShortcutValue","resolveValueType","useTimeRangePicker","TimeRangePicker","value","onChange","timeFormat","format","placeholder","shortcuts","defaultDate","valueType","className","displayFormat","resolvedType","djValue","djDefault","undefined","handleChange","range","djShortcuts","map","shortcut","getValue","isOpen","step","tempStartHour","tempStartMinute","tempEndHour","tempEndMinute","startAmPm","endAmPm","displayValue","handleOpenChange","handleSetStep","handleStartHourChange","handleStartMinuteChange","handleEndHourChange","handleEndMinuteChange","handleStartAmPmChange","handleEndAmPmChange","handleNext","handleApply","handleApplyShortcut","inputRef","popoverRef","currentHour","currentMinute","currentAmPm","onHourChange","onMinuteChange","onAmPmChange","div","data-slot","open","onOpenChange","render","ref","variant","ariaLabel","activeRangePart","onRangePartClick","side","align","length","onShortcutClick","hour","minute","amPm","onClick"],"mappings":"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"}
@@ -1,40 +1,34 @@
1
- import { Dayjs } from 'dayjs';
2
- import { RangeSelectionStep } from '../shared/hooks/use-range-step-manager';
3
- import { ShortcutItem, ShortcutValueDayjs } from '../shared/shortcuts-panel/shortcuts-panel';
4
- import { AmPm, TimeFormat } from '../utils/format-utils';
1
+ import type { Dayjs } from "dayjs";
2
+ import type { RangeSelectionStep } from "../shared/hooks/use-range-step-manager";
3
+ import type { ShortcutValueDayjs } from "../shared/shortcuts-panel/shortcuts-panel";
4
+ import type { AmPm, TimeFormat } from "../utils/format-utils";
5
5
  export interface UseTimeRangePickerProps {
6
- value: [Dayjs | null, Dayjs | null];
7
- onChange: (range: [Dayjs | null, Dayjs | null]) => void;
8
- timeFormat?: TimeFormat;
9
- defaultDate?: Dayjs;
6
+ value: [Dayjs | null, Dayjs | null];
7
+ onChange: (range: [Dayjs | null, Dayjs | null]) => void;
8
+ timeFormat?: TimeFormat;
9
+ defaultDate?: Dayjs;
10
10
  }
11
11
  export interface UseTimeRangePickerReturn {
12
- isOpen: boolean;
13
- step: RangeSelectionStep;
14
- tempStartHour: number;
15
- tempStartMinute: number;
16
- tempEndHour: number;
17
- tempEndMinute: number;
18
- startAmPm: AmPm;
19
- endAmPm: AmPm;
20
- displayValue: [Dayjs | null, Dayjs | null];
21
- handleOpenChange: (open: boolean) => void;
22
- handleSetStep: (step: RangeSelectionStep) => void;
23
- handleStartHourChange: (hour: number) => void;
24
- handleStartMinuteChange: (minute: number) => void;
25
- handleEndHourChange: (hour: number) => void;
26
- handleEndMinuteChange: (minute: number) => void;
27
- handleStartAmPmChange: (amPm: AmPm) => void;
28
- handleEndAmPmChange: (amPm: AmPm) => void;
29
- handleNext: () => void;
30
- handleApply: () => void;
31
- handleApplyShortcut: (shortcutValue: ShortcutValueDayjs) => void;
32
- inputRef: React.RefObject<HTMLDivElement>;
33
- popoverRef: React.RefObject<HTMLDivElement>;
34
- }
35
- export interface TimeRangePickerProps extends UseTimeRangePickerProps {
36
- format?: string;
37
- placeholder?: string;
38
- shortcuts?: ShortcutItem[];
39
- className?: string;
12
+ isOpen: boolean;
13
+ step: RangeSelectionStep;
14
+ tempStartHour: number;
15
+ tempStartMinute: number;
16
+ tempEndHour: number;
17
+ tempEndMinute: number;
18
+ startAmPm: AmPm;
19
+ endAmPm: AmPm;
20
+ displayValue: [Dayjs | null, Dayjs | null];
21
+ handleOpenChange: (open: boolean) => void;
22
+ handleSetStep: (step: RangeSelectionStep) => void;
23
+ handleStartHourChange: (hour: number) => void;
24
+ handleStartMinuteChange: (minute: number) => void;
25
+ handleEndHourChange: (hour: number) => void;
26
+ handleEndMinuteChange: (minute: number) => void;
27
+ handleStartAmPmChange: (amPm: AmPm) => void;
28
+ handleEndAmPmChange: (amPm: AmPm) => void;
29
+ handleNext: () => void;
30
+ handleApply: () => void;
31
+ handleApplyShortcut: (shortcutValue: ShortcutValueDayjs) => void;
32
+ inputRef: React.RefObject<HTMLDivElement>;
33
+ popoverRef: React.RefObject<HTMLDivElement>;
40
34
  }
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/components/ui/core/date-time-pickers/time-range-picker/types.ts"],"sourcesContent":["import type { Dayjs } from 'dayjs';\n\nimport type { RangeSelectionStep } from '../shared/hooks/use-range-step-manager';\nimport type { ShortcutValueDayjs } from '../shared/shortcuts-panel/shortcuts-panel';\nimport type { AmPm, TimeFormat } from '../utils/format-utils';\n\nexport interface UseTimeRangePickerProps {\n value: [Dayjs | null, Dayjs | null];\n onChange: (range: [Dayjs | null, Dayjs | null]) => void;\n timeFormat?: TimeFormat;\n defaultDate?: Dayjs;\n}\n\nexport interface UseTimeRangePickerReturn {\n isOpen: boolean;\n step: RangeSelectionStep;\n tempStartHour: number;\n tempStartMinute: number;\n tempEndHour: number;\n tempEndMinute: number;\n startAmPm: AmPm;\n endAmPm: AmPm;\n displayValue: [Dayjs | null, Dayjs | null];\n handleOpenChange: (open: boolean) => void;\n handleSetStep: (step: RangeSelectionStep) => void;\n handleStartHourChange: (hour: number) => void;\n handleStartMinuteChange: (minute: number) => void;\n handleEndHourChange: (hour: number) => void;\n handleEndMinuteChange: (minute: number) => void;\n handleStartAmPmChange: (amPm: AmPm) => void;\n handleEndAmPmChange: (amPm: AmPm) => void;\n handleNext: () => void;\n handleApply: () => void;\n handleApplyShortcut: (shortcutValue: ShortcutValueDayjs) => void;\n inputRef: React.RefObject<HTMLDivElement>;\n popoverRef: React.RefObject<HTMLDivElement>;\n}\n"],"names":[],"mappings":"AAaA,WAuBC"}
@@ -1,3 +1,3 @@
1
- import { UseTimeRangePickerProps, UseTimeRangePickerReturn } from './types';
1
+ import type { UseTimeRangePickerProps, UseTimeRangePickerReturn } from "./types";
2
2
  export type { UseTimeRangePickerProps, UseTimeRangePickerReturn };
3
- export declare const useTimeRangePicker: ({ value, onChange, timeFormat, defaultDate, }: UseTimeRangePickerProps) => UseTimeRangePickerReturn;
3
+ export declare const useTimeRangePicker: ({ value, onChange, timeFormat, defaultDate }: UseTimeRangePickerProps) => UseTimeRangePickerReturn;
@@ -0,0 +1,145 @@
1
+ import { useCallback, useEffect, useMemo, useRef } from "react";
2
+ import dayjs from "dayjs";
3
+ import { DEFAULT_MINUTE, DEFAULT_START_HOUR, END_OF_DAY_HOUR, END_OF_DAY_MINUTE } from "../shared/constants.js";
4
+ import { usePopoverState } from "../shared/hooks/use-popover-state.js";
5
+ import { useRangeStepManager } from "../shared/hooks/use-range-step-manager.js";
6
+ import { useTimeState } from "../shared/hooks/use-time-state.js";
7
+ const buildTimeOnAnchor = (base, hour24, minute)=>base.hour(hour24).minute(minute).second(0).millisecond(0);
8
+ export const useTimeRangePicker = ({ value, onChange, timeFormat = '24h', defaultDate = dayjs() })=>{
9
+ const onBackspaceRef = useRef(()=>{});
10
+ const { isOpen, setIsOpen, popoverRef, inputRef } = usePopoverState({
11
+ onBackspace: useCallback(()=>onBackspaceRef.current(), [])
12
+ });
13
+ const stepMgr = useRangeStepManager();
14
+ const { step, handleNext, handleBack: stepBack, resetStep } = stepMgr;
15
+ const startAnchor = value[0] ?? value[1] ?? defaultDate;
16
+ const endAnchor = value[1] ?? value[0] ?? defaultDate;
17
+ const startTime = useTimeState({
18
+ initialHour: value[0]?.hour() ?? DEFAULT_START_HOUR,
19
+ initialMinute: value[0]?.minute() ?? DEFAULT_MINUTE,
20
+ timeFormat
21
+ });
22
+ const { hour: tempStartHour, minute: tempStartMinute, amPm: startAmPm, hour24: startHour24, handleHourChange: handleStartHourChange, handleMinuteChange: handleStartMinuteChange, handleAmPmChange: handleStartAmPmChange, resetTime: resetStartTime } = startTime;
23
+ const endTime = useTimeState({
24
+ initialHour: value[1]?.hour() ?? END_OF_DAY_HOUR,
25
+ initialMinute: value[1]?.minute() ?? END_OF_DAY_MINUTE,
26
+ timeFormat
27
+ });
28
+ const { hour: tempEndHour, minute: tempEndMinute, amPm: endAmPm, hour24: endHour24, handleHourChange: handleEndHourChange, handleMinuteChange: handleEndMinuteChange, handleAmPmChange: handleEndAmPmChange, resetTime: resetEndTime } = endTime;
29
+ const resetAll = useCallback(()=>{
30
+ resetStep();
31
+ resetStartTime(value[0]?.hour() ?? DEFAULT_START_HOUR, value[0]?.minute() ?? DEFAULT_MINUTE);
32
+ resetEndTime(value[1]?.hour() ?? END_OF_DAY_HOUR, value[1]?.minute() ?? END_OF_DAY_MINUTE);
33
+ }, [
34
+ value,
35
+ resetStep,
36
+ resetStartTime,
37
+ resetEndTime
38
+ ]);
39
+ const handleBackspace = useCallback(()=>{
40
+ if (step === 'end') {
41
+ stepBack();
42
+ resetEndTime(value[1]?.hour() ?? END_OF_DAY_HOUR, value[1]?.minute() ?? END_OF_DAY_MINUTE);
43
+ return;
44
+ }
45
+ if (value[0] !== null || value[1] !== null) {
46
+ onChange([
47
+ null,
48
+ null
49
+ ]);
50
+ resetAll();
51
+ }
52
+ }, [
53
+ step,
54
+ stepBack,
55
+ value,
56
+ onChange,
57
+ resetAll,
58
+ resetEndTime
59
+ ]);
60
+ useEffect(()=>{
61
+ onBackspaceRef.current = handleBackspace;
62
+ }, [
63
+ handleBackspace
64
+ ]);
65
+ const handleOpenChange = (open)=>{
66
+ resetAll();
67
+ setIsOpen(open);
68
+ };
69
+ const handleSetStep = (s)=>{
70
+ if (s === 'start') {
71
+ stepBack();
72
+ } else {
73
+ handleNext();
74
+ }
75
+ };
76
+ const handleApply = ()=>{
77
+ const start = buildTimeOnAnchor(startAnchor, startHour24, tempStartMinute);
78
+ const end = buildTimeOnAnchor(endAnchor, endHour24, tempEndMinute);
79
+ const ordered = start.isAfter(end) ? [
80
+ end,
81
+ start
82
+ ] : [
83
+ start,
84
+ end
85
+ ];
86
+ onChange(ordered);
87
+ setIsOpen(false);
88
+ resetStep();
89
+ };
90
+ const handleApplyShortcut = (shortcutValue)=>{
91
+ const range = Array.isArray(shortcutValue) ? shortcutValue : [
92
+ shortcutValue,
93
+ shortcutValue
94
+ ];
95
+ onChange([
96
+ range[0] ? buildTimeOnAnchor(startAnchor, range[0].hour(), range[0].minute()) : null,
97
+ range[1] ? buildTimeOnAnchor(endAnchor, range[1].hour(), range[1].minute()) : null
98
+ ]);
99
+ setIsOpen(false);
100
+ resetStep();
101
+ };
102
+ const displayValue = useMemo(()=>{
103
+ const startWithTime = buildTimeOnAnchor(startAnchor, startHour24, tempStartMinute);
104
+ const endWithTime = buildTimeOnAnchor(endAnchor, endHour24, tempEndMinute);
105
+ return isOpen ? [
106
+ startWithTime,
107
+ endWithTime
108
+ ] : value;
109
+ }, [
110
+ isOpen,
111
+ value,
112
+ startAnchor,
113
+ endAnchor,
114
+ startHour24,
115
+ tempStartMinute,
116
+ endHour24,
117
+ tempEndMinute
118
+ ]);
119
+ return {
120
+ isOpen,
121
+ step,
122
+ tempStartHour,
123
+ tempStartMinute,
124
+ tempEndHour,
125
+ tempEndMinute,
126
+ startAmPm,
127
+ endAmPm,
128
+ displayValue,
129
+ handleOpenChange,
130
+ handleSetStep,
131
+ handleStartHourChange,
132
+ handleStartMinuteChange,
133
+ handleEndHourChange,
134
+ handleEndMinuteChange,
135
+ handleStartAmPmChange,
136
+ handleEndAmPmChange,
137
+ handleNext,
138
+ handleApply,
139
+ handleApplyShortcut,
140
+ inputRef,
141
+ popoverRef
142
+ };
143
+ };
144
+
145
+ //# sourceMappingURL=use-time-range-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/components/ui/core/date-time-pickers/time-range-picker/use-time-range-picker.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport type { Dayjs } from 'dayjs';\nimport dayjs from 'dayjs';\n\nimport {\n DEFAULT_MINUTE,\n DEFAULT_START_HOUR,\n END_OF_DAY_HOUR,\n END_OF_DAY_MINUTE,\n} from '../shared/constants';\nimport { usePopoverState } from '../shared/hooks/use-popover-state';\nimport type { RangeSelectionStep } from '../shared/hooks/use-range-step-manager';\nimport { useRangeStepManager } from '../shared/hooks/use-range-step-manager';\nimport { useTimeState } from '../shared/hooks/use-time-state';\nimport type { ShortcutValueDayjs } from '../shared/shortcuts-panel/shortcuts-panel';\n\nimport type {\n UseTimeRangePickerProps,\n UseTimeRangePickerReturn,\n} from './types';\n\nexport type { UseTimeRangePickerProps, UseTimeRangePickerReturn };\n\nconst buildTimeOnAnchor = (\n base: Dayjs,\n hour24: number,\n minute: number\n): Dayjs => base.hour(hour24).minute(minute).second(0).millisecond(0);\n\nexport const useTimeRangePicker = ({\n value,\n onChange,\n timeFormat = '24h',\n defaultDate = dayjs(),\n}: UseTimeRangePickerProps): UseTimeRangePickerReturn => {\n const onBackspaceRef = useRef<() => void>(() => {});\n\n const { isOpen, setIsOpen, popoverRef, inputRef } = usePopoverState({\n onBackspace: useCallback(() => onBackspaceRef.current(), []),\n });\n\n const stepMgr = useRangeStepManager();\n const { step, handleNext, handleBack: stepBack, resetStep } = stepMgr;\n\n const startAnchor = value[0] ?? value[1] ?? defaultDate;\n const endAnchor = value[1] ?? value[0] ?? defaultDate;\n\n const startTime = useTimeState({\n initialHour: value[0]?.hour() ?? DEFAULT_START_HOUR,\n initialMinute: value[0]?.minute() ?? DEFAULT_MINUTE,\n timeFormat,\n });\n const {\n hour: tempStartHour,\n minute: tempStartMinute,\n amPm: startAmPm,\n hour24: startHour24,\n handleHourChange: handleStartHourChange,\n handleMinuteChange: handleStartMinuteChange,\n handleAmPmChange: handleStartAmPmChange,\n resetTime: resetStartTime,\n } = startTime;\n\n const endTime = useTimeState({\n initialHour: value[1]?.hour() ?? END_OF_DAY_HOUR,\n initialMinute: value[1]?.minute() ?? END_OF_DAY_MINUTE,\n timeFormat,\n });\n const {\n hour: tempEndHour,\n minute: tempEndMinute,\n amPm: endAmPm,\n hour24: endHour24,\n handleHourChange: handleEndHourChange,\n handleMinuteChange: handleEndMinuteChange,\n handleAmPmChange: handleEndAmPmChange,\n resetTime: resetEndTime,\n } = endTime;\n\n const resetAll = useCallback(() => {\n resetStep();\n resetStartTime(\n value[0]?.hour() ?? DEFAULT_START_HOUR,\n value[0]?.minute() ?? DEFAULT_MINUTE\n );\n resetEndTime(\n value[1]?.hour() ?? END_OF_DAY_HOUR,\n value[1]?.minute() ?? END_OF_DAY_MINUTE\n );\n }, [value, resetStep, resetStartTime, resetEndTime]);\n\n const handleBackspace = useCallback(() => {\n if (step === 'end') {\n stepBack();\n resetEndTime(\n value[1]?.hour() ?? END_OF_DAY_HOUR,\n value[1]?.minute() ?? END_OF_DAY_MINUTE\n );\n return;\n }\n if (value[0] !== null || value[1] !== null) {\n onChange([null, null]);\n resetAll();\n }\n }, [step, stepBack, value, onChange, resetAll, resetEndTime]);\n\n useEffect(() => {\n onBackspaceRef.current = handleBackspace;\n }, [handleBackspace]);\n\n const handleOpenChange = (open: boolean) => {\n resetAll();\n setIsOpen(open);\n };\n\n const handleSetStep = (s: RangeSelectionStep) => {\n if (s === 'start') {\n stepBack();\n } else {\n handleNext();\n }\n };\n\n const handleApply = () => {\n const start = buildTimeOnAnchor(startAnchor, startHour24, tempStartMinute);\n const end = buildTimeOnAnchor(endAnchor, endHour24, tempEndMinute);\n const ordered: [Dayjs, Dayjs] = start.isAfter(end)\n ? [end, start]\n : [start, end];\n onChange(ordered);\n setIsOpen(false);\n resetStep();\n };\n\n const handleApplyShortcut = (shortcutValue: ShortcutValueDayjs) => {\n const range: [Dayjs | null, Dayjs | null] = Array.isArray(shortcutValue)\n ? shortcutValue\n : [shortcutValue, shortcutValue];\n\n onChange([\n range[0]\n ? buildTimeOnAnchor(startAnchor, range[0].hour(), range[0].minute())\n : null,\n range[1]\n ? buildTimeOnAnchor(endAnchor, range[1].hour(), range[1].minute())\n : null,\n ]);\n setIsOpen(false);\n resetStep();\n };\n\n const displayValue: [Dayjs | null, Dayjs | null] = useMemo(() => {\n const startWithTime = buildTimeOnAnchor(\n startAnchor,\n startHour24,\n tempStartMinute\n );\n const endWithTime = buildTimeOnAnchor(endAnchor, endHour24, tempEndMinute);\n return isOpen ? [startWithTime, endWithTime] : value;\n }, [\n isOpen,\n value,\n startAnchor,\n endAnchor,\n startHour24,\n tempStartMinute,\n endHour24,\n tempEndMinute,\n ]);\n\n return {\n isOpen,\n step,\n tempStartHour,\n tempStartMinute,\n tempEndHour,\n tempEndMinute,\n startAmPm,\n endAmPm,\n displayValue,\n handleOpenChange,\n handleSetStep,\n handleStartHourChange,\n handleStartMinuteChange,\n handleEndHourChange,\n handleEndMinuteChange,\n handleStartAmPmChange,\n handleEndAmPmChange,\n handleNext,\n handleApply,\n handleApplyShortcut,\n inputRef,\n popoverRef,\n };\n};\n"],"names":["useCallback","useEffect","useMemo","useRef","dayjs","DEFAULT_MINUTE","DEFAULT_START_HOUR","END_OF_DAY_HOUR","END_OF_DAY_MINUTE","usePopoverState","useRangeStepManager","useTimeState","buildTimeOnAnchor","base","hour24","minute","hour","second","millisecond","useTimeRangePicker","value","onChange","timeFormat","defaultDate","onBackspaceRef","isOpen","setIsOpen","popoverRef","inputRef","onBackspace","current","stepMgr","step","handleNext","handleBack","stepBack","resetStep","startAnchor","endAnchor","startTime","initialHour","initialMinute","tempStartHour","tempStartMinute","amPm","startAmPm","startHour24","handleHourChange","handleStartHourChange","handleMinuteChange","handleStartMinuteChange","handleAmPmChange","handleStartAmPmChange","resetTime","resetStartTime","endTime","tempEndHour","tempEndMinute","endAmPm","endHour24","handleEndHourChange","handleEndMinuteChange","handleEndAmPmChange","resetEndTime","resetAll","handleBackspace","handleOpenChange","open","handleSetStep","s","handleApply","start","end","ordered","isAfter","handleApplyShortcut","shortcutValue","range","Array","isArray","displayValue","startWithTime","endWithTime"],"mappings":"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"}
@@ -0,0 +1,56 @@
1
+ import type { Dayjs } from "dayjs";
2
+ /** A date value accepted by picker public APIs. */
3
+ export type DateInput = Date | Dayjs;
4
+ /** Resolved output type for picker value binding. */
5
+ export type DateValueType = "date" | "dayjs";
6
+ export type ShortcutValueInput = DateInput | null | [DateInput, DateInput] | [DateInput | null, DateInput | null];
7
+ export type ShortcutValueDayjs = Dayjs | null | [Dayjs, Dayjs] | [Dayjs | null, Dayjs | null];
8
+ /**
9
+ * Converts a consumer date value to an internal Dayjs instance.
10
+ */
11
+ export declare const normalizeIn: (input: DateInput | null | undefined) => Dayjs | null;
12
+ /**
13
+ * Infers the consumer value type from the current value or default date.
14
+ *
15
+ * When both `value` and `defaultDate` are null on first render, falls back to
16
+ * `explicit` or `'dayjs'` for backwards compatibility.
17
+ */
18
+ export declare const resolveValueType: (value: DateInput | null | undefined, defaultDate?: DateInput | null, explicit?: DateValueType) => DateValueType;
19
+ /**
20
+ * Converts an internal Dayjs value back to Date or Dayjs, preserving the instant.
21
+ */
22
+ export declare const normalizeOut: <T extends DateInput>(d: Dayjs | null, type: DateValueType) => T | null;
23
+ /** Converts a Dayjs range back to the consumer's value type. */
24
+ export declare const normalizeOutRange: <T extends DateInput>(range: [Dayjs | null, Dayjs | null], type: DateValueType) => [T | null, T | null];
25
+ /** Normalizes shortcut values to internal Dayjs before passing to picker hooks. */
26
+ export declare const normalizeShortcutValue: (value: ShortcutValueInput) => ShortcutValueDayjs;
27
+ /** Shared value-binding props for single-value pickers. */
28
+ export interface DateValueProps<T extends DateInput = Dayjs> {
29
+ /** Current value. Accepts Dayjs or native Date. */
30
+ value: T | null;
31
+ /** Called when the value changes. Returns the same type as `value`. */
32
+ onChange: (date: T | null) => void;
33
+ /** Fallback date when value is empty. Same type as `value`. */
34
+ defaultDate?: T;
35
+ /**
36
+ * Output type when `value` and `defaultDate` are both null on first render.
37
+ * @default 'dayjs'
38
+ */
39
+ valueType?: DateValueType;
40
+ }
41
+ /** Shared value-binding props for range pickers. */
42
+ export interface DateRangeValueProps<T extends DateInput = Dayjs> {
43
+ /** Current range. Each bound accepts Dayjs or native Date. */
44
+ value: [T | null, T | null];
45
+ /**
46
+ * Called when the range changes. Returns the same element type as `value`.
47
+ */
48
+ onChange: (range: [T | null, T | null]) => void;
49
+ /** Fallback date when a bound is empty. Same type as range elements. */
50
+ defaultDate?: T;
51
+ /**
52
+ * Output type when range values and `defaultDate` are all null on first render.
53
+ * @default 'dayjs'
54
+ */
55
+ valueType?: DateValueType;
56
+ }
@@ -0,0 +1,67 @@
1
+ import dayjs from "dayjs";
2
+ /**
3
+ * Converts a consumer date value to an internal Dayjs instance.
4
+ */ export const normalizeIn = (input)=>{
5
+ if (input == null) {
6
+ return null;
7
+ }
8
+ if (dayjs.isDayjs(input)) {
9
+ return input;
10
+ }
11
+ if (!(input instanceof Date)) {
12
+ return null;
13
+ }
14
+ const parsed = dayjs(input);
15
+ return parsed.isValid() ? parsed : null;
16
+ };
17
+ /**
18
+ * Infers the consumer value type from the current value or default date.
19
+ *
20
+ * When both `value` and `defaultDate` are null on first render, falls back to
21
+ * `explicit` or `'dayjs'` for backwards compatibility.
22
+ */ export const resolveValueType = (value, defaultDate, explicit)=>{
23
+ if (explicit) {
24
+ return explicit;
25
+ }
26
+ const candidate = value ?? defaultDate;
27
+ if (candidate == null) {
28
+ return 'dayjs';
29
+ }
30
+ if (dayjs.isDayjs(candidate)) {
31
+ return 'dayjs';
32
+ }
33
+ return 'date';
34
+ };
35
+ /**
36
+ * Converts an internal Dayjs value back to Date or Dayjs, preserving the instant.
37
+ */ export const normalizeOut = (d, type)=>{
38
+ if (d == null) {
39
+ return null;
40
+ }
41
+ return toConsumerValue(type === 'date' ? d.toDate() : d);
42
+ };
43
+ /** Converts a Dayjs range back to the consumer's value type. */ export const normalizeOutRange = (range, type)=>[
44
+ normalizeOut(range[0], type),
45
+ normalizeOut(range[1], type)
46
+ ];
47
+ /** Normalizes shortcut values to internal Dayjs before passing to picker hooks. */ export const normalizeShortcutValue = (value)=>{
48
+ if (Array.isArray(value)) {
49
+ return [
50
+ normalizeIn(value[0]),
51
+ normalizeIn(value[1])
52
+ ];
53
+ }
54
+ if (value == null) {
55
+ return null;
56
+ }
57
+ const normalized = normalizeIn(value);
58
+ if (normalized == null) {
59
+ throw new Error('Shortcut value must resolve to a valid date');
60
+ }
61
+ return normalized;
62
+ };
63
+ const toConsumerValue = (value)=>{
64
+ return value;
65
+ };
66
+
67
+ //# sourceMappingURL=date-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/components/ui/core/date-time-pickers/utils/date-input.ts"],"sourcesContent":["import type { Dayjs } from 'dayjs';\nimport dayjs from 'dayjs';\n\n/** A date value accepted by picker public APIs. */\nexport type DateInput = Date | Dayjs;\n\n/** Resolved output type for picker value binding. */\nexport type DateValueType = 'date' | 'dayjs';\n\nexport type ShortcutValueInput =\n | DateInput\n | null\n | [DateInput, DateInput]\n | [DateInput | null, DateInput | null];\n\nexport type ShortcutValueDayjs =\n Dayjs | null | [Dayjs, Dayjs] | [Dayjs | null, Dayjs | null];\n\n/**\n * Converts a consumer date value to an internal Dayjs instance.\n */\nexport const normalizeIn = (\n input: DateInput | null | undefined\n): Dayjs | null => {\n if (input == null) {\n return null;\n }\n\n if (dayjs.isDayjs(input)) {\n return input;\n }\n\n if (!(input instanceof Date)) {\n return null;\n }\n\n const parsed = dayjs(input);\n return parsed.isValid() ? parsed : null;\n};\n\n/**\n * Infers the consumer value type from the current value or default date.\n *\n * When both `value` and `defaultDate` are null on first render, falls back to\n * `explicit` or `'dayjs'` for backwards compatibility.\n */\nexport const resolveValueType = (\n value: DateInput | null | undefined,\n defaultDate?: DateInput | null,\n explicit?: DateValueType\n): DateValueType => {\n if (explicit) {\n return explicit;\n }\n\n const candidate = value ?? defaultDate;\n if (candidate == null) {\n return 'dayjs';\n }\n\n if (dayjs.isDayjs(candidate)) {\n return 'dayjs';\n }\n\n return 'date';\n};\n\n/**\n * Converts an internal Dayjs value back to Date or Dayjs, preserving the instant.\n */\nexport const normalizeOut = <T extends DateInput>(\n d: Dayjs | null,\n type: DateValueType\n): T | null => {\n if (d == null) {\n return null;\n }\n\n return toConsumerValue<T>(type === 'date' ? d.toDate() : d);\n};\n\n/** Converts a Dayjs range back to the consumer's value type. */\nexport const normalizeOutRange = <T extends DateInput>(\n range: [Dayjs | null, Dayjs | null],\n type: DateValueType\n): [T | null, T | null] => [\n normalizeOut<T>(range[0], type),\n normalizeOut<T>(range[1], type),\n];\n\n/** Normalizes shortcut values to internal Dayjs before passing to picker hooks. */\nexport const normalizeShortcutValue = (\n value: ShortcutValueInput\n): ShortcutValueDayjs => {\n if (Array.isArray(value)) {\n return [normalizeIn(value[0]), normalizeIn(value[1])];\n }\n\n if (value == null) {\n return null;\n }\n\n const normalized = normalizeIn(value);\n if (normalized == null) {\n throw new Error('Shortcut value must resolve to a valid date');\n }\n\n return normalized;\n};\n\n/** Shared value-binding props for single-value pickers. */\nexport interface DateValueProps<T extends DateInput = Dayjs> {\n /** Current value. Accepts Dayjs or native Date. */\n value: T | null;\n /** Called when the value changes. Returns the same type as `value`. */\n onChange: (date: T | null) => void;\n /** Fallback date when value is empty. Same type as `value`. */\n defaultDate?: T;\n /**\n * Output type when `value` and `defaultDate` are both null on first render.\n * @default 'dayjs'\n */\n valueType?: DateValueType;\n}\n\n/** Shared value-binding props for range pickers. */\nexport interface DateRangeValueProps<T extends DateInput = Dayjs> {\n /** Current range. Each bound accepts Dayjs or native Date. */\n value: [T | null, T | null];\n /**\n * Called when the range changes. Returns the same element type as `value`.\n */\n onChange: (range: [T | null, T | null]) => void;\n /** Fallback date when a bound is empty. Same type as range elements. */\n defaultDate?: T;\n /**\n * Output type when range values and `defaultDate` are all null on first render.\n * @default 'dayjs'\n */\n valueType?: DateValueType;\n}\n\nconst toConsumerValue = <T extends DateInput>(value: DateInput): T => {\n return value as T;\n};\n"],"names":["dayjs","normalizeIn","input","isDayjs","Date","parsed","isValid","resolveValueType","value","defaultDate","explicit","candidate","normalizeOut","d","type","toConsumerValue","toDate","normalizeOutRange","range","normalizeShortcutValue","Array","isArray","normalized","Error"],"mappings":"AACA,OAAOA,WAAW,QAAQ;AAiB1B;;CAEC,GACD,OAAO,MAAMC,cAAc,CACzBC;IAEA,IAAIA,SAAS,MAAM;QACjB,OAAO;IACT;IAEA,IAAIF,MAAMG,OAAO,CAACD,QAAQ;QACxB,OAAOA;IACT;IAEA,IAAI,CAAEA,CAAAA,iBAAiBE,IAAG,GAAI;QAC5B,OAAO;IACT;IAEA,MAAMC,SAASL,MAAME;IACrB,OAAOG,OAAOC,OAAO,KAAKD,SAAS;AACrC,EAAE;AAEF;;;;;CAKC,GACD,OAAO,MAAME,mBAAmB,CAC9BC,OACAC,aACAC;IAEA,IAAIA,UAAU;QACZ,OAAOA;IACT;IAEA,MAAMC,YAAYH,SAASC;IAC3B,IAAIE,aAAa,MAAM;QACrB,OAAO;IACT;IAEA,IAAIX,MAAMG,OAAO,CAACQ,YAAY;QAC5B,OAAO;IACT;IAEA,OAAO;AACT,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMC,eAAe,CAC1BC,GACAC;IAEA,IAAID,KAAK,MAAM;QACb,OAAO;IACT;IAEA,OAAOE,gBAAmBD,SAAS,SAASD,EAAEG,MAAM,KAAKH;AAC3D,EAAE;AAEF,8DAA8D,GAC9D,OAAO,MAAMI,oBAAoB,CAC/BC,OACAJ,OACyB;QACzBF,aAAgBM,KAAK,CAAC,EAAE,EAAEJ;QAC1BF,aAAgBM,KAAK,CAAC,EAAE,EAAEJ;KAC3B,CAAC;AAEF,iFAAiF,GACjF,OAAO,MAAMK,yBAAyB,CACpCX;IAEA,IAAIY,MAAMC,OAAO,CAACb,QAAQ;QACxB,OAAO;YAACP,YAAYO,KAAK,CAAC,EAAE;YAAGP,YAAYO,KAAK,CAAC,EAAE;SAAE;IACvD;IAEA,IAAIA,SAAS,MAAM;QACjB,OAAO;IACT;IAEA,MAAMc,aAAarB,YAAYO;IAC/B,IAAIc,cAAc,MAAM;QACtB,MAAM,IAAIC,MAAM;IAClB;IAEA,OAAOD;AACT,EAAE;AAkCF,MAAMP,kBAAkB,CAAsBP;IAC5C,OAAOA;AACT"}
@@ -1,26 +1,26 @@
1
- import { Dayjs } from 'dayjs';
1
+ import type { Dayjs } from "dayjs";
2
2
  /**
3
- * Applies start of day (00:00:00.000) to a given date
4
- * @param date - Dayjs object
5
- * @returns Dayjs object with time set to 00:00:00.000
6
- */
3
+ * Applies start of day (00:00:00.000) to a given date
4
+ * @param date - Dayjs object
5
+ * @returns Dayjs object with time set to 00:00:00.000
6
+ */
7
7
  export declare const applyStartOfDay: (date: Dayjs) => Dayjs;
8
8
  /**
9
- * Applies end of day (23:59:59.999) to a given date
10
- * @param date - Dayjs object
11
- * @returns Dayjs object with time set to 23:59:59.999
12
- */
9
+ * Applies end of day (23:59:59.999) to a given date
10
+ * @param date - Dayjs object
11
+ * @returns Dayjs object with time set to 23:59:59.999
12
+ */
13
13
  export declare const applyEndOfDay: (date: Dayjs) => Dayjs;
14
14
  /**
15
- * Validates that a date range is valid (start is before or equal to end)
16
- * @param start - Start date (Dayjs or null)
17
- * @param end - End date (Dayjs or null)
18
- * @returns True if the range is valid, false otherwise
19
- */
15
+ * Validates that a date range is valid (start is before or equal to end)
16
+ * @param start - Start date (Dayjs or null)
17
+ * @param end - End date (Dayjs or null)
18
+ * @returns True if the range is valid, false otherwise
19
+ */
20
20
  export declare const validateDateRange: (start: Dayjs | null, end: Dayjs | null) => boolean;
21
21
  /**
22
- * Converts a timestamp (milliseconds) to a Dayjs object
23
- * @param timestamp - Timestamp in milliseconds
24
- * @returns Dayjs object or null if timestamp is null or undefined
25
- */
22
+ * Converts a timestamp (milliseconds) to a Dayjs object
23
+ * @param timestamp - Timestamp in milliseconds
24
+ * @returns Dayjs object or null if timestamp is null or undefined
25
+ */
26
26
  export declare const timestampToDayjs: (timestamp: number | undefined | null) => Dayjs | null;
@@ -0,0 +1,42 @@
1
+ import dayjs from "dayjs";
2
+ /**
3
+ * Applies start of day (00:00:00.000) to a given date
4
+ * @param date - Dayjs object
5
+ * @returns Dayjs object with time set to 00:00:00.000
6
+ */ export const applyStartOfDay = (date)=>{
7
+ return date.startOf('day');
8
+ };
9
+ /**
10
+ * Applies end of day (23:59:59.999) to a given date
11
+ * @param date - Dayjs object
12
+ * @returns Dayjs object with time set to 23:59:59.999
13
+ */ export const applyEndOfDay = (date)=>{
14
+ return date.endOf('day');
15
+ };
16
+ /**
17
+ * Validates that a date range is valid (start is before or equal to end)
18
+ * @param start - Start date (Dayjs or null)
19
+ * @param end - End date (Dayjs or null)
20
+ * @returns True if the range is valid, false otherwise
21
+ */ export const validateDateRange = (start, end)=>{
22
+ if (!start || !end) {
23
+ return false;
24
+ }
25
+ if (!start.isValid() || !end.isValid()) {
26
+ return false;
27
+ }
28
+ return start.isBefore(end) || start.isSame(end);
29
+ };
30
+ /**
31
+ * Converts a timestamp (milliseconds) to a Dayjs object
32
+ * @param timestamp - Timestamp in milliseconds
33
+ * @returns Dayjs object or null if timestamp is null or undefined
34
+ */ export const timestampToDayjs = (timestamp)=>{
35
+ if (timestamp == null) {
36
+ return null;
37
+ }
38
+ const date = dayjs(timestamp);
39
+ return date.isValid() ? date : null;
40
+ };
41
+
42
+ //# sourceMappingURL=date-range-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/components/ui/core/date-time-pickers/utils/date-range-utils.ts"],"sourcesContent":["import type { Dayjs } from 'dayjs';\nimport dayjs from 'dayjs';\n\n/**\n * Applies start of day (00:00:00.000) to a given date\n * @param date - Dayjs object\n * @returns Dayjs object with time set to 00:00:00.000\n */\nexport const applyStartOfDay = (date: Dayjs): Dayjs => {\n return date.startOf('day');\n};\n\n/**\n * Applies end of day (23:59:59.999) to a given date\n * @param date - Dayjs object\n * @returns Dayjs object with time set to 23:59:59.999\n */\nexport const applyEndOfDay = (date: Dayjs): Dayjs => {\n return date.endOf('day');\n};\n\n/**\n * Validates that a date range is valid (start is before or equal to end)\n * @param start - Start date (Dayjs or null)\n * @param end - End date (Dayjs or null)\n * @returns True if the range is valid, false otherwise\n */\nexport const validateDateRange = (\n start: Dayjs | null,\n end: Dayjs | null\n): boolean => {\n if (!start || !end) {\n return false;\n }\n\n if (!start.isValid() || !end.isValid()) {\n return false;\n }\n\n return start.isBefore(end) || start.isSame(end);\n};\n\n/**\n * Converts a timestamp (milliseconds) to a Dayjs object\n * @param timestamp - Timestamp in milliseconds\n * @returns Dayjs object or null if timestamp is null or undefined\n */\nexport const timestampToDayjs = (\n timestamp: number | undefined | null\n): Dayjs | null => {\n if (timestamp == null) {\n return null;\n }\n\n const date = dayjs(timestamp);\n return date.isValid() ? date : null;\n};\n"],"names":["dayjs","applyStartOfDay","date","startOf","applyEndOfDay","endOf","validateDateRange","start","end","isValid","isBefore","isSame","timestampToDayjs","timestamp"],"mappings":"AACA,OAAOA,WAAW,QAAQ;AAE1B;;;;CAIC,GACD,OAAO,MAAMC,kBAAkB,CAACC;IAC9B,OAAOA,KAAKC,OAAO,CAAC;AACtB,EAAE;AAEF;;;;CAIC,GACD,OAAO,MAAMC,gBAAgB,CAACF;IAC5B,OAAOA,KAAKG,KAAK,CAAC;AACpB,EAAE;AAEF;;;;;CAKC,GACD,OAAO,MAAMC,oBAAoB,CAC/BC,OACAC;IAEA,IAAI,CAACD,SAAS,CAACC,KAAK;QAClB,OAAO;IACT;IAEA,IAAI,CAACD,MAAME,OAAO,MAAM,CAACD,IAAIC,OAAO,IAAI;QACtC,OAAO;IACT;IAEA,OAAOF,MAAMG,QAAQ,CAACF,QAAQD,MAAMI,MAAM,CAACH;AAC7C,EAAE;AAEF;;;;CAIC,GACD,OAAO,MAAMI,mBAAmB,CAC9BC;IAEA,IAAIA,aAAa,MAAM;QACrB,OAAO;IACT;IAEA,MAAMX,OAAOF,MAAMa;IACnB,OAAOX,KAAKO,OAAO,KAAKP,OAAO;AACjC,EAAE"}