@gravity-ui/date-components 3.4.2 → 4.1.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 (405) hide show
  1. package/README.md +31 -0
  2. package/dist/cjs/components/Calendar/Calendar.d.ts +6 -2
  3. package/dist/cjs/components/Calendar/Calendar.js +1 -1
  4. package/dist/cjs/components/Calendar/Calendar.js.map +1 -1
  5. package/dist/cjs/components/CalendarView/Calendar.css +3 -0
  6. package/dist/cjs/components/CalendarView/Calendar.css.map +1 -1
  7. package/dist/cjs/components/CalendarView/CalendarView.d.ts +2 -1
  8. package/dist/cjs/components/CalendarView/CalendarView.js +8 -8
  9. package/dist/cjs/components/CalendarView/CalendarView.js.map +1 -1
  10. package/dist/cjs/components/CalendarView/hooks/types.d.ts +5 -3
  11. package/dist/cjs/components/CalendarView/hooks/types.js.map +1 -1
  12. package/dist/cjs/components/CalendarView/hooks/useCalendarCellProps.js +1 -2
  13. package/dist/cjs/components/CalendarView/hooks/useCalendarCellProps.js.map +1 -1
  14. package/dist/cjs/components/CalendarView/hooks/useCalendarGridProps.js +10 -3
  15. package/dist/cjs/components/CalendarView/hooks/useCalendarGridProps.js.map +1 -1
  16. package/dist/cjs/components/CalendarView/hooks/useCalendarProps.js +7 -1
  17. package/dist/cjs/components/CalendarView/hooks/useCalendarProps.js.map +1 -1
  18. package/dist/cjs/components/CalendarView/hooks/useCalendarState.d.ts +5 -3
  19. package/dist/cjs/components/CalendarView/hooks/useCalendarState.js +74 -30
  20. package/dist/cjs/components/CalendarView/hooks/useCalendarState.js.map +1 -1
  21. package/dist/cjs/components/CalendarView/hooks/useRangeCalendarState.js +16 -9
  22. package/dist/cjs/components/CalendarView/hooks/useRangeCalendarState.js.map +1 -1
  23. package/dist/cjs/components/DateField/DateField.d.ts +1 -1
  24. package/dist/cjs/components/DateField/DateField.js +5 -17
  25. package/dist/cjs/components/DateField/DateField.js.map +1 -1
  26. package/dist/cjs/components/DateField/IncompleteDate.d.ts +28 -0
  27. package/dist/cjs/components/DateField/IncompleteDate.js +116 -0
  28. package/dist/cjs/components/DateField/IncompleteDate.js.map +1 -0
  29. package/dist/cjs/components/DateField/hooks/useBaseDateFieldState.d.ts +34 -68
  30. package/dist/cjs/components/DateField/hooks/useBaseDateFieldState.js +18 -249
  31. package/dist/cjs/components/DateField/hooks/useBaseDateFieldState.js.map +1 -1
  32. package/dist/cjs/components/DateField/hooks/useDateFieldProps.d.ts +2 -0
  33. package/dist/cjs/components/DateField/hooks/useDateFieldProps.js +250 -54
  34. package/dist/cjs/components/DateField/hooks/useDateFieldProps.js.map +1 -1
  35. package/dist/cjs/components/DateField/hooks/useDateFieldState.d.ts +20 -2
  36. package/dist/cjs/components/DateField/hooks/useDateFieldState.js +84 -118
  37. package/dist/cjs/components/DateField/hooks/useDateFieldState.js.map +1 -1
  38. package/dist/cjs/components/DateField/hooks/useFocusManager.d.ts +29 -0
  39. package/dist/cjs/components/DateField/hooks/useFocusManager.js +116 -0
  40. package/dist/cjs/components/DateField/hooks/useFocusManager.js.map +1 -0
  41. package/dist/cjs/components/{RangeDateField → DateField}/hooks/useRangeDateFieldState.d.ts +1 -1
  42. package/dist/cjs/components/DateField/hooks/useRangeDateFieldState.js +236 -0
  43. package/dist/cjs/components/DateField/hooks/useRangeDateFieldState.js.map +1 -0
  44. package/dist/cjs/components/DateField/i18n/ru.json +1 -1
  45. package/dist/cjs/components/DateField/index.d.ts +2 -1
  46. package/dist/cjs/components/DateField/index.js +1 -1
  47. package/dist/cjs/components/DateField/index.js.map +1 -1
  48. package/dist/cjs/components/DateField/types.d.ts +2 -22
  49. package/dist/cjs/components/DateField/types.js.map +1 -1
  50. package/dist/cjs/components/DateField/utils.d.ts +21 -34
  51. package/dist/cjs/components/DateField/utils.js +180 -132
  52. package/dist/cjs/components/DateField/utils.js.map +1 -1
  53. package/dist/cjs/components/DatePicker/DatePicker.d.ts +3 -3
  54. package/dist/cjs/components/DatePicker/DatePicker.js +3 -4
  55. package/dist/cjs/components/DatePicker/DatePicker.js.map +1 -1
  56. package/dist/cjs/components/DatePicker/MobileCalendar.d.ts +1 -1
  57. package/dist/cjs/components/DatePicker/MobileCalendar.js +3 -5
  58. package/dist/cjs/components/DatePicker/MobileCalendar.js.map +1 -1
  59. package/dist/cjs/components/DatePicker/StubButton.d.ts +1 -1
  60. package/dist/cjs/components/DatePicker/hooks/datePickerStateFactory.d.ts +1 -1
  61. package/dist/cjs/components/DatePicker/hooks/datePickerStateFactory.js +15 -6
  62. package/dist/cjs/components/DatePicker/hooks/datePickerStateFactory.js.map +1 -1
  63. package/dist/cjs/components/DatePicker/hooks/useDatePickerProps.d.ts +2 -2
  64. package/dist/cjs/components/DatePicker/hooks/useDatePickerProps.js +30 -17
  65. package/dist/cjs/components/DatePicker/hooks/useDatePickerProps.js.map +1 -1
  66. package/dist/cjs/components/HiddenInput/HiddenInput.d.ts +2 -5
  67. package/dist/cjs/components/HiddenInput/HiddenInput.js +2 -4
  68. package/dist/cjs/components/HiddenInput/HiddenInput.js.map +1 -1
  69. package/dist/cjs/components/RangeCalendar/RangeCalendar.d.ts +2 -2
  70. package/dist/cjs/components/RangeCalendar/RangeCalendar.js +2 -3
  71. package/dist/cjs/components/RangeCalendar/RangeCalendar.js.map +1 -1
  72. package/dist/cjs/components/RangeDateField/RangeDateField.d.ts +1 -1
  73. package/dist/cjs/components/RangeDateField/RangeDateField.js +6 -19
  74. package/dist/cjs/components/RangeDateField/RangeDateField.js.map +1 -1
  75. package/dist/cjs/components/RangeDateField/index.d.ts +0 -1
  76. package/dist/cjs/components/RangeDateField/index.js +0 -1
  77. package/dist/cjs/components/RangeDateField/index.js.map +1 -1
  78. package/dist/cjs/components/RangeDatePicker/RangeDatePicker.d.ts +2 -1
  79. package/dist/cjs/components/RangeDatePicker/RangeDatePicker.js +4 -5
  80. package/dist/cjs/components/RangeDatePicker/RangeDatePicker.js.map +1 -1
  81. package/dist/cjs/components/RangeDatePicker/hooks/useRangeDatePickerState.d.ts +1 -1
  82. package/dist/cjs/components/RangeDatePicker/hooks/useRangeDatePickerState.js +3 -4
  83. package/dist/cjs/components/RangeDatePicker/hooks/useRangeDatePickerState.js.map +1 -1
  84. package/dist/cjs/components/RangeDateSelection/RangeDateSelection.d.ts +1 -1
  85. package/dist/cjs/components/RangeDateSelection/RangeDateSelection.js +4 -5
  86. package/dist/cjs/components/RangeDateSelection/RangeDateSelection.js.map +1 -1
  87. package/dist/cjs/components/RangeDateSelection/components/NowLine/NowLine.d.ts +2 -1
  88. package/dist/cjs/components/RangeDateSelection/components/Ruler/Ruler.d.ts +1 -1
  89. package/dist/cjs/components/RangeDateSelection/components/Ruler/Ruler.js +1 -1
  90. package/dist/cjs/components/RangeDateSelection/components/Ruler/Ruler.js.map +1 -1
  91. package/dist/cjs/components/RangeDateSelection/components/RulerViewport/RulerViewport.js +2 -2
  92. package/dist/cjs/components/RangeDateSelection/components/RulerViewport/RulerViewport.js.map +1 -1
  93. package/dist/cjs/components/RangeDateSelection/components/SelectionControl/SelectionControl.d.ts +2 -1
  94. package/dist/cjs/components/RangeDateSelection/components/SelectionControl/SelectionControl.js +12 -21
  95. package/dist/cjs/components/RangeDateSelection/components/SelectionControl/SelectionControl.js.map +1 -1
  96. package/dist/cjs/components/RangeDateSelection/components/Ticks/MiddleTicks.d.ts +1 -1
  97. package/dist/cjs/components/RangeDateSelection/components/Ticks/SlitTicks.d.ts +1 -1
  98. package/dist/cjs/components/RangeDateSelection/components/Ticks/Ticks.d.ts +2 -2
  99. package/dist/cjs/components/RangeDateSelection/components/Ticks/Ticks.js.map +1 -1
  100. package/dist/cjs/components/RangeDateSelection/components/Ticks/UnavialableTicks.d.ts +3 -4
  101. package/dist/cjs/components/RangeDateSelection/components/Ticks/UnavialableTicks.js +0 -3
  102. package/dist/cjs/components/RangeDateSelection/components/Ticks/UnavialableTicks.js.map +1 -1
  103. package/dist/cjs/components/RangeDateSelection/hooks/useRangeDateSelectionState.js +9 -10
  104. package/dist/cjs/components/RangeDateSelection/hooks/useRangeDateSelectionState.js.map +1 -1
  105. package/dist/cjs/components/RangeDateSelection/utils/span.d.ts +2 -1
  106. package/dist/cjs/components/RangeDateSelection/utils/span.js.map +1 -1
  107. package/dist/cjs/components/RelativeDateField/RelativeDateField.d.ts +1 -1
  108. package/dist/cjs/components/RelativeDateField/RelativeDateField.js +3 -40
  109. package/dist/cjs/components/RelativeDateField/RelativeDateField.js.map +1 -1
  110. package/dist/cjs/components/RelativeDateField/hooks/useRelativeDateFieldProps.d.ts +7 -2
  111. package/dist/cjs/components/RelativeDateField/hooks/useRelativeDateFieldProps.js +71 -9
  112. package/dist/cjs/components/RelativeDateField/hooks/useRelativeDateFieldProps.js.map +1 -1
  113. package/dist/cjs/components/RelativeDateField/hooks/useRelativeDateFieldState.d.ts +2 -0
  114. package/dist/cjs/components/RelativeDateField/hooks/useRelativeDateFieldState.js +48 -34
  115. package/dist/cjs/components/RelativeDateField/hooks/useRelativeDateFieldState.js.map +1 -1
  116. package/dist/cjs/components/RelativeDatePicker/RelativeDatePicker.d.ts +1 -1
  117. package/dist/cjs/components/RelativeDatePicker/RelativeDatePicker.js +7 -4
  118. package/dist/cjs/components/RelativeDatePicker/RelativeDatePicker.js.map +1 -1
  119. package/dist/cjs/components/RelativeDatePicker/hooks/useRelativeDatePickerProps.d.ts +1 -1
  120. package/dist/cjs/components/RelativeDatePicker/hooks/useRelativeDatePickerProps.js +52 -21
  121. package/dist/cjs/components/RelativeDatePicker/hooks/useRelativeDatePickerProps.js.map +1 -1
  122. package/dist/cjs/components/RelativeDatePicker/hooks/useRelativeDatePickerState.js +9 -10
  123. package/dist/cjs/components/RelativeDatePicker/hooks/useRelativeDatePickerState.js.map +1 -1
  124. package/dist/cjs/components/RelativeRangeDatePicker/RelativeRangeDatePicker.d.ts +2 -1
  125. package/dist/cjs/components/RelativeRangeDatePicker/RelativeRangeDatePicker.js +13 -5
  126. package/dist/cjs/components/RelativeRangeDatePicker/RelativeRangeDatePicker.js.map +1 -1
  127. package/dist/cjs/components/RelativeRangeDatePicker/components/Control/Control.css +1 -1
  128. package/dist/cjs/components/RelativeRangeDatePicker/components/Control/Control.css.map +1 -1
  129. package/dist/cjs/components/RelativeRangeDatePicker/components/Control/Control.d.ts +2 -1
  130. package/dist/cjs/components/RelativeRangeDatePicker/components/Control/Control.js +12 -6
  131. package/dist/cjs/components/RelativeRangeDatePicker/components/Control/Control.js.map +1 -1
  132. package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/PickerDialog.d.ts +1 -1
  133. package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/PickerDialog.js +6 -8
  134. package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/PickerDialog.js.map +1 -1
  135. package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/PickerDoc.d.ts +5 -3
  136. package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/PickerDoc.js +18 -16
  137. package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/PickerDoc.js.map +1 -1
  138. package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/PickerForm.d.ts +5 -1
  139. package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/PickerForm.js +34 -7
  140. package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/PickerForm.js.map +1 -1
  141. package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/useRelativeRangeDatePickerDialogState.d.ts +3 -3
  142. package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/useRelativeRangeDatePickerDialogState.js +19 -18
  143. package/dist/cjs/components/RelativeRangeDatePicker/components/PickerDialog/useRelativeRangeDatePickerDialogState.js.map +1 -1
  144. package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/Presets.d.ts +6 -9
  145. package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/Presets.js +9 -12
  146. package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/Presets.js.map +1 -1
  147. package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/defaultPresets.d.ts +2 -2
  148. package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/defaultPresets.js.map +1 -1
  149. package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/utils.d.ts +9 -4
  150. package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/utils.js +27 -16
  151. package/dist/cjs/components/RelativeRangeDatePicker/components/Presets/utils.js.map +1 -1
  152. package/dist/cjs/components/RelativeRangeDatePicker/components/Zones/Zones.d.ts +3 -3
  153. package/dist/cjs/components/RelativeRangeDatePicker/components/Zones/Zones.js +3 -4
  154. package/dist/cjs/components/RelativeRangeDatePicker/components/Zones/Zones.js.map +1 -1
  155. package/dist/cjs/components/RelativeRangeDatePicker/hooks/useRelativeRangeDatePickerState.js +8 -7
  156. package/dist/cjs/components/RelativeRangeDatePicker/hooks/useRelativeRangeDatePickerState.js.map +1 -1
  157. package/dist/cjs/components/RelativeRangeDatePicker/types.d.ts +3 -1
  158. package/dist/cjs/components/RelativeRangeDatePicker/types.js.map +1 -1
  159. package/dist/cjs/components/RelativeRangeDatePicker/utils.d.ts +2 -2
  160. package/dist/cjs/components/RelativeRangeDatePicker/utils.js +32 -9
  161. package/dist/cjs/components/RelativeRangeDatePicker/utils.js.map +1 -1
  162. package/dist/cjs/components/utils/constants.d.ts +2 -0
  163. package/dist/cjs/components/utils/constants.js +7 -1
  164. package/dist/cjs/components/utils/constants.js.map +1 -1
  165. package/dist/cjs/components/utils/dates.d.ts +6 -1
  166. package/dist/cjs/components/utils/dates.js +6 -1
  167. package/dist/cjs/components/utils/dates.js.map +1 -1
  168. package/dist/cjs/components/utils/filterDOMProps.js +1 -1
  169. package/dist/cjs/components/utils/filterDOMProps.js.map +1 -1
  170. package/dist/cjs/components/utils/mergeProps.js +1 -1
  171. package/dist/cjs/components/utils/mergeProps.js.map +1 -1
  172. package/dist/cjs/components/utils/validation/datePicker.js +1 -1
  173. package/dist/cjs/components/utils/validation/datePicker.js.map +1 -1
  174. package/dist/cjs/components/utils/validation/i18n/ru.json +2 -2
  175. package/dist/cjs/components/utils/validation/relativeRangeDatePicker.d.ts +7 -11
  176. package/dist/cjs/components/utils/validation/relativeRangeDatePicker.js +6 -1
  177. package/dist/cjs/components/utils/validation/relativeRangeDatePicker.js.map +1 -1
  178. package/dist/cjs/hooks/useEventHandler.js +1 -2
  179. package/dist/cjs/hooks/useEventHandler.js.map +1 -1
  180. package/dist/cjs/hooks/useMove.d.ts +2 -2
  181. package/dist/cjs/hooks/useMove.js +6 -9
  182. package/dist/cjs/hooks/useMove.js.map +1 -1
  183. package/dist/cjs/hooks/useResizeObserver.js +1 -1
  184. package/dist/cjs/hooks/useResizeObserver.js.map +1 -1
  185. package/dist/cjs/package.json +1 -1
  186. package/dist/docs/INDEX.md +131 -0
  187. package/dist/docs/components/Calendar.md +125 -0
  188. package/dist/docs/components/DateField.md +206 -0
  189. package/dist/docs/components/DatePicker.md +194 -0
  190. package/dist/docs/components/RangeCalendar.md +125 -0
  191. package/dist/docs/components/RelativeDateField.md +73 -0
  192. package/dist/docs/components/RelativeDatePicker.md +59 -0
  193. package/dist/esm/components/Calendar/Calendar.d.ts +6 -2
  194. package/dist/esm/components/Calendar/Calendar.js +1 -1
  195. package/dist/esm/components/Calendar/Calendar.js.map +1 -1
  196. package/dist/esm/components/CalendarView/Calendar.css +3 -0
  197. package/dist/esm/components/CalendarView/Calendar.css.map +1 -1
  198. package/dist/esm/components/CalendarView/CalendarView.d.ts +2 -1
  199. package/dist/esm/components/CalendarView/CalendarView.js +8 -8
  200. package/dist/esm/components/CalendarView/CalendarView.js.map +1 -1
  201. package/dist/esm/components/CalendarView/hooks/types.d.ts +5 -3
  202. package/dist/esm/components/CalendarView/hooks/types.js.map +1 -1
  203. package/dist/esm/components/CalendarView/hooks/useCalendarCellProps.js +1 -2
  204. package/dist/esm/components/CalendarView/hooks/useCalendarCellProps.js.map +1 -1
  205. package/dist/esm/components/CalendarView/hooks/useCalendarGridProps.js +10 -3
  206. package/dist/esm/components/CalendarView/hooks/useCalendarGridProps.js.map +1 -1
  207. package/dist/esm/components/CalendarView/hooks/useCalendarProps.js +7 -1
  208. package/dist/esm/components/CalendarView/hooks/useCalendarProps.js.map +1 -1
  209. package/dist/esm/components/CalendarView/hooks/useCalendarState.d.ts +5 -3
  210. package/dist/esm/components/CalendarView/hooks/useCalendarState.js +74 -30
  211. package/dist/esm/components/CalendarView/hooks/useCalendarState.js.map +1 -1
  212. package/dist/esm/components/CalendarView/hooks/useRangeCalendarState.js +16 -10
  213. package/dist/esm/components/CalendarView/hooks/useRangeCalendarState.js.map +1 -1
  214. package/dist/esm/components/DateField/DateField.d.ts +1 -1
  215. package/dist/esm/components/DateField/DateField.js +6 -18
  216. package/dist/esm/components/DateField/DateField.js.map +1 -1
  217. package/dist/esm/components/DateField/IncompleteDate.d.ts +28 -0
  218. package/dist/esm/components/DateField/IncompleteDate.js +112 -0
  219. package/dist/esm/components/DateField/IncompleteDate.js.map +1 -0
  220. package/dist/esm/components/DateField/hooks/useBaseDateFieldState.d.ts +34 -68
  221. package/dist/esm/components/DateField/hooks/useBaseDateFieldState.js +17 -248
  222. package/dist/esm/components/DateField/hooks/useBaseDateFieldState.js.map +1 -1
  223. package/dist/esm/components/DateField/hooks/useDateFieldProps.d.ts +2 -0
  224. package/dist/esm/components/DateField/hooks/useDateFieldProps.js +250 -54
  225. package/dist/esm/components/DateField/hooks/useDateFieldProps.js.map +1 -1
  226. package/dist/esm/components/DateField/hooks/useDateFieldState.d.ts +20 -2
  227. package/dist/esm/components/DateField/hooks/useDateFieldState.js +85 -119
  228. package/dist/esm/components/DateField/hooks/useDateFieldState.js.map +1 -1
  229. package/dist/esm/components/DateField/hooks/useFocusManager.d.ts +29 -0
  230. package/dist/esm/components/DateField/hooks/useFocusManager.js +112 -0
  231. package/dist/esm/components/DateField/hooks/useFocusManager.js.map +1 -0
  232. package/dist/esm/components/{RangeDateField → DateField}/hooks/useRangeDateFieldState.d.ts +1 -1
  233. package/dist/esm/components/DateField/hooks/useRangeDateFieldState.js +232 -0
  234. package/dist/esm/components/DateField/hooks/useRangeDateFieldState.js.map +1 -0
  235. package/dist/esm/components/DateField/i18n/ru.json +1 -1
  236. package/dist/esm/components/DateField/index.d.ts +2 -1
  237. package/dist/esm/components/DateField/index.js +1 -1
  238. package/dist/esm/components/DateField/index.js.map +1 -1
  239. package/dist/esm/components/DateField/types.d.ts +2 -22
  240. package/dist/esm/components/DateField/types.js.map +1 -1
  241. package/dist/esm/components/DateField/utils.d.ts +21 -34
  242. package/dist/esm/components/DateField/utils.js +179 -125
  243. package/dist/esm/components/DateField/utils.js.map +1 -1
  244. package/dist/esm/components/DatePicker/DatePicker.d.ts +3 -3
  245. package/dist/esm/components/DatePicker/DatePicker.js +3 -5
  246. package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
  247. package/dist/esm/components/DatePicker/MobileCalendar.d.ts +1 -1
  248. package/dist/esm/components/DatePicker/MobileCalendar.js +3 -5
  249. package/dist/esm/components/DatePicker/MobileCalendar.js.map +1 -1
  250. package/dist/esm/components/DatePicker/StubButton.d.ts +1 -1
  251. package/dist/esm/components/DatePicker/hooks/datePickerStateFactory.d.ts +1 -1
  252. package/dist/esm/components/DatePicker/hooks/datePickerStateFactory.js +15 -6
  253. package/dist/esm/components/DatePicker/hooks/datePickerStateFactory.js.map +1 -1
  254. package/dist/esm/components/DatePicker/hooks/useDatePickerProps.d.ts +2 -2
  255. package/dist/esm/components/DatePicker/hooks/useDatePickerProps.js +30 -18
  256. package/dist/esm/components/DatePicker/hooks/useDatePickerProps.js.map +1 -1
  257. package/dist/esm/components/HiddenInput/HiddenInput.d.ts +2 -5
  258. package/dist/esm/components/HiddenInput/HiddenInput.js +3 -4
  259. package/dist/esm/components/HiddenInput/HiddenInput.js.map +1 -1
  260. package/dist/esm/components/RangeCalendar/RangeCalendar.d.ts +2 -2
  261. package/dist/esm/components/RangeCalendar/RangeCalendar.js +2 -3
  262. package/dist/esm/components/RangeCalendar/RangeCalendar.js.map +1 -1
  263. package/dist/esm/components/RangeDateField/RangeDateField.d.ts +1 -1
  264. package/dist/esm/components/RangeDateField/RangeDateField.js +7 -20
  265. package/dist/esm/components/RangeDateField/RangeDateField.js.map +1 -1
  266. package/dist/esm/components/RangeDateField/index.d.ts +0 -1
  267. package/dist/esm/components/RangeDateField/index.js +0 -1
  268. package/dist/esm/components/RangeDateField/index.js.map +1 -1
  269. package/dist/esm/components/RangeDatePicker/RangeDatePicker.d.ts +2 -1
  270. package/dist/esm/components/RangeDatePicker/RangeDatePicker.js +4 -6
  271. package/dist/esm/components/RangeDatePicker/RangeDatePicker.js.map +1 -1
  272. package/dist/esm/components/RangeDatePicker/hooks/useRangeDatePickerState.d.ts +1 -1
  273. package/dist/esm/components/RangeDatePicker/hooks/useRangeDatePickerState.js +2 -3
  274. package/dist/esm/components/RangeDatePicker/hooks/useRangeDatePickerState.js.map +1 -1
  275. package/dist/esm/components/RangeDateSelection/RangeDateSelection.d.ts +1 -1
  276. package/dist/esm/components/RangeDateSelection/RangeDateSelection.js +4 -5
  277. package/dist/esm/components/RangeDateSelection/RangeDateSelection.js.map +1 -1
  278. package/dist/esm/components/RangeDateSelection/components/NowLine/NowLine.d.ts +2 -1
  279. package/dist/esm/components/RangeDateSelection/components/Ruler/Ruler.d.ts +1 -1
  280. package/dist/esm/components/RangeDateSelection/components/Ruler/Ruler.js +1 -1
  281. package/dist/esm/components/RangeDateSelection/components/Ruler/Ruler.js.map +1 -1
  282. package/dist/esm/components/RangeDateSelection/components/RulerViewport/RulerViewport.js +2 -2
  283. package/dist/esm/components/RangeDateSelection/components/RulerViewport/RulerViewport.js.map +1 -1
  284. package/dist/esm/components/RangeDateSelection/components/SelectionControl/SelectionControl.d.ts +2 -1
  285. package/dist/esm/components/RangeDateSelection/components/SelectionControl/SelectionControl.js +12 -22
  286. package/dist/esm/components/RangeDateSelection/components/SelectionControl/SelectionControl.js.map +1 -1
  287. package/dist/esm/components/RangeDateSelection/components/Ticks/MiddleTicks.d.ts +1 -1
  288. package/dist/esm/components/RangeDateSelection/components/Ticks/SlitTicks.d.ts +1 -1
  289. package/dist/esm/components/RangeDateSelection/components/Ticks/Ticks.d.ts +2 -2
  290. package/dist/esm/components/RangeDateSelection/components/Ticks/Ticks.js.map +1 -1
  291. package/dist/esm/components/RangeDateSelection/components/Ticks/UnavialableTicks.d.ts +3 -4
  292. package/dist/esm/components/RangeDateSelection/components/Ticks/UnavialableTicks.js +1 -2
  293. package/dist/esm/components/RangeDateSelection/components/Ticks/UnavialableTicks.js.map +1 -1
  294. package/dist/esm/components/RangeDateSelection/hooks/useRangeDateSelectionState.js +9 -10
  295. package/dist/esm/components/RangeDateSelection/hooks/useRangeDateSelectionState.js.map +1 -1
  296. package/dist/esm/components/RangeDateSelection/utils/span.d.ts +2 -1
  297. package/dist/esm/components/RangeDateSelection/utils/span.js.map +1 -1
  298. package/dist/esm/components/RelativeDateField/RelativeDateField.d.ts +1 -1
  299. package/dist/esm/components/RelativeDateField/RelativeDateField.js +4 -40
  300. package/dist/esm/components/RelativeDateField/RelativeDateField.js.map +1 -1
  301. package/dist/esm/components/RelativeDateField/hooks/useRelativeDateFieldProps.d.ts +7 -2
  302. package/dist/esm/components/RelativeDateField/hooks/useRelativeDateFieldProps.js +71 -9
  303. package/dist/esm/components/RelativeDateField/hooks/useRelativeDateFieldProps.js.map +1 -1
  304. package/dist/esm/components/RelativeDateField/hooks/useRelativeDateFieldState.d.ts +2 -0
  305. package/dist/esm/components/RelativeDateField/hooks/useRelativeDateFieldState.js +48 -34
  306. package/dist/esm/components/RelativeDateField/hooks/useRelativeDateFieldState.js.map +1 -1
  307. package/dist/esm/components/RelativeDatePicker/RelativeDatePicker.d.ts +1 -1
  308. package/dist/esm/components/RelativeDatePicker/RelativeDatePicker.js +7 -4
  309. package/dist/esm/components/RelativeDatePicker/RelativeDatePicker.js.map +1 -1
  310. package/dist/esm/components/RelativeDatePicker/hooks/useRelativeDatePickerProps.d.ts +1 -1
  311. package/dist/esm/components/RelativeDatePicker/hooks/useRelativeDatePickerProps.js +52 -22
  312. package/dist/esm/components/RelativeDatePicker/hooks/useRelativeDatePickerProps.js.map +1 -1
  313. package/dist/esm/components/RelativeDatePicker/hooks/useRelativeDatePickerState.js +9 -10
  314. package/dist/esm/components/RelativeDatePicker/hooks/useRelativeDatePickerState.js.map +1 -1
  315. package/dist/esm/components/RelativeRangeDatePicker/RelativeRangeDatePicker.d.ts +2 -1
  316. package/dist/esm/components/RelativeRangeDatePicker/RelativeRangeDatePicker.js +13 -5
  317. package/dist/esm/components/RelativeRangeDatePicker/RelativeRangeDatePicker.js.map +1 -1
  318. package/dist/esm/components/RelativeRangeDatePicker/components/Control/Control.css +1 -1
  319. package/dist/esm/components/RelativeRangeDatePicker/components/Control/Control.css.map +1 -1
  320. package/dist/esm/components/RelativeRangeDatePicker/components/Control/Control.d.ts +2 -1
  321. package/dist/esm/components/RelativeRangeDatePicker/components/Control/Control.js +12 -6
  322. package/dist/esm/components/RelativeRangeDatePicker/components/Control/Control.js.map +1 -1
  323. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerDialog.d.ts +1 -1
  324. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerDialog.js +6 -8
  325. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerDialog.js.map +1 -1
  326. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerDoc.d.ts +5 -3
  327. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerDoc.js +18 -17
  328. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerDoc.js.map +1 -1
  329. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerForm.d.ts +5 -1
  330. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerForm.js +33 -7
  331. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/PickerForm.js.map +1 -1
  332. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/useRelativeRangeDatePickerDialogState.d.ts +3 -3
  333. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/useRelativeRangeDatePickerDialogState.js +19 -18
  334. package/dist/esm/components/RelativeRangeDatePicker/components/PickerDialog/useRelativeRangeDatePickerDialogState.js.map +1 -1
  335. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/Presets.d.ts +6 -9
  336. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/Presets.js +8 -10
  337. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/Presets.js.map +1 -1
  338. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/defaultPresets.d.ts +2 -2
  339. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/defaultPresets.js.map +1 -1
  340. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/utils.d.ts +9 -4
  341. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/utils.js +26 -15
  342. package/dist/esm/components/RelativeRangeDatePicker/components/Presets/utils.js.map +1 -1
  343. package/dist/esm/components/RelativeRangeDatePicker/components/Zones/Zones.d.ts +3 -3
  344. package/dist/esm/components/RelativeRangeDatePicker/components/Zones/Zones.js +3 -4
  345. package/dist/esm/components/RelativeRangeDatePicker/components/Zones/Zones.js.map +1 -1
  346. package/dist/esm/components/RelativeRangeDatePicker/hooks/useRelativeRangeDatePickerState.js +8 -7
  347. package/dist/esm/components/RelativeRangeDatePicker/hooks/useRelativeRangeDatePickerState.js.map +1 -1
  348. package/dist/esm/components/RelativeRangeDatePicker/types.d.ts +3 -1
  349. package/dist/esm/components/RelativeRangeDatePicker/types.js.map +1 -1
  350. package/dist/esm/components/RelativeRangeDatePicker/utils.d.ts +2 -2
  351. package/dist/esm/components/RelativeRangeDatePicker/utils.js +33 -9
  352. package/dist/esm/components/RelativeRangeDatePicker/utils.js.map +1 -1
  353. package/dist/esm/components/utils/constants.d.ts +2 -0
  354. package/dist/esm/components/utils/constants.js +6 -0
  355. package/dist/esm/components/utils/constants.js.map +1 -1
  356. package/dist/esm/components/utils/dates.d.ts +6 -1
  357. package/dist/esm/components/utils/dates.js +5 -1
  358. package/dist/esm/components/utils/dates.js.map +1 -1
  359. package/dist/esm/components/utils/filterDOMProps.js +1 -1
  360. package/dist/esm/components/utils/filterDOMProps.js.map +1 -1
  361. package/dist/esm/components/utils/mergeProps.js +1 -1
  362. package/dist/esm/components/utils/mergeProps.js.map +1 -1
  363. package/dist/esm/components/utils/validation/datePicker.js +1 -1
  364. package/dist/esm/components/utils/validation/datePicker.js.map +1 -1
  365. package/dist/esm/components/utils/validation/i18n/ru.json +2 -2
  366. package/dist/esm/components/utils/validation/relativeRangeDatePicker.d.ts +7 -11
  367. package/dist/esm/components/utils/validation/relativeRangeDatePicker.js +6 -1
  368. package/dist/esm/components/utils/validation/relativeRangeDatePicker.js.map +1 -1
  369. package/dist/esm/hooks/useEventHandler.js +1 -2
  370. package/dist/esm/hooks/useEventHandler.js.map +1 -1
  371. package/dist/esm/hooks/useMove.d.ts +2 -2
  372. package/dist/esm/hooks/useMove.js +6 -9
  373. package/dist/esm/hooks/useMove.js.map +1 -1
  374. package/dist/esm/hooks/useResizeObserver.js +1 -1
  375. package/dist/esm/hooks/useResizeObserver.js.map +1 -1
  376. package/dist/esm/package.json +1 -1
  377. package/package.json +34 -27
  378. package/dist/cjs/components/RangeDateField/hooks/useRangeDateFieldState.js +0 -224
  379. package/dist/cjs/components/RangeDateField/hooks/useRangeDateFieldState.js.map +0 -1
  380. package/dist/cjs/components/RangeDateField/utils/createPlaceholderRangeValue.d.ts +0 -5
  381. package/dist/cjs/components/RangeDateField/utils/createPlaceholderRangeValue.js +0 -9
  382. package/dist/cjs/components/RangeDateField/utils/createPlaceholderRangeValue.js.map +0 -1
  383. package/dist/cjs/components/RangeDateField/utils/getRangeEditableSections.d.ts +0 -5
  384. package/dist/cjs/components/RangeDateField/utils/getRangeEditableSections.js +0 -42
  385. package/dist/cjs/components/RangeDateField/utils/getRangeEditableSections.js.map +0 -1
  386. package/dist/cjs/components/RangeDateField/utils/index.d.ts +0 -3
  387. package/dist/cjs/components/RangeDateField/utils/index.js +0 -7
  388. package/dist/cjs/components/RangeDateField/utils/index.js.map +0 -1
  389. package/dist/cjs/components/RangeDateField/utils/isValidRange.d.ts +0 -3
  390. package/dist/cjs/components/RangeDateField/utils/isValidRange.js +0 -7
  391. package/dist/cjs/components/RangeDateField/utils/isValidRange.js.map +0 -1
  392. package/dist/esm/components/RangeDateField/hooks/useRangeDateFieldState.js +0 -220
  393. package/dist/esm/components/RangeDateField/hooks/useRangeDateFieldState.js.map +0 -1
  394. package/dist/esm/components/RangeDateField/utils/createPlaceholderRangeValue.d.ts +0 -5
  395. package/dist/esm/components/RangeDateField/utils/createPlaceholderRangeValue.js +0 -6
  396. package/dist/esm/components/RangeDateField/utils/createPlaceholderRangeValue.js.map +0 -1
  397. package/dist/esm/components/RangeDateField/utils/getRangeEditableSections.d.ts +0 -5
  398. package/dist/esm/components/RangeDateField/utils/getRangeEditableSections.js +0 -39
  399. package/dist/esm/components/RangeDateField/utils/getRangeEditableSections.js.map +0 -1
  400. package/dist/esm/components/RangeDateField/utils/index.d.ts +0 -3
  401. package/dist/esm/components/RangeDateField/utils/index.js +0 -4
  402. package/dist/esm/components/RangeDateField/utils/index.js.map +0 -1
  403. package/dist/esm/components/RangeDateField/utils/isValidRange.d.ts +0 -3
  404. package/dist/esm/components/RangeDateField/utils/isValidRange.js +0 -4
  405. package/dist/esm/components/RangeDateField/utils/isValidRange.js.map +0 -1
@@ -1,4 +1,3 @@
1
- import { __rest } from "tslib";
2
1
  import React from 'react';
3
2
  import { isDateTime } from '@gravity-ui/date-utils';
4
3
  import { useFocusWithin, useForkRef } from '@gravity-ui/uikit';
@@ -8,9 +7,7 @@ import { getButtonSizeForInput } from "../../utils/getButtonSizeForInput.js";
8
7
  import { mergeProps } from "../../utils/mergeProps.js";
9
8
  import { i18n } from "../i18n/index.js";
10
9
  import { getCalendarModes, getDateTimeValue } from "../utils/index.js";
11
- export function useDatePickerProps(state, _a) {
12
- var { onFocus, onBlur } = _a, props = __rest(_a, ["onFocus", "onBlur"]);
13
- const [isActive, setActive] = React.useState(false);
10
+ export function useDatePickerProps(state, { onFocus, onBlur, ...props }) {
14
11
  const [focusedDate, setFocusedDate] = React.useState(isDateTime(state.dateFieldState.displayValue)
15
12
  ? state.dateFieldState.displayValue
16
13
  : state.dateFieldState.displayValue.start);
@@ -32,17 +29,18 @@ export function useDatePickerProps(state, _a) {
32
29
  setFocusedDate(state.dateFieldState.displayValue.end);
33
30
  }
34
31
  }
32
+ const { inputProps } = useDateFieldProps(state.dateFieldState, props);
35
33
  const { focusWithinProps } = useFocusWithin({
36
34
  onFocusWithin: onFocus,
37
35
  onBlurWithin: onBlur,
38
36
  onFocusWithinChange(isFocusWithin) {
39
- setActive(isFocusWithin);
37
+ state.dateFieldState.setActive(isFocusWithin);
40
38
  if (!isFocusWithin) {
41
39
  state.setOpen(false, 'FocusOut');
40
+ state.dateFieldState.confirmPlaceholder();
42
41
  }
43
42
  },
44
43
  });
45
- const { inputProps } = useDateFieldProps(state.dateFieldState, props);
46
44
  const inputRef = React.useRef(null);
47
45
  const handleRef = useForkRef(inputRef, inputProps.controlRef);
48
46
  const calendarRef = React.useRef(null);
@@ -50,8 +48,7 @@ export function useDatePickerProps(state, _a) {
50
48
  const groupRef = React.useRef(null);
51
49
  function focusInput() {
52
50
  setTimeout(() => {
53
- var _a;
54
- (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
51
+ inputRef.current?.focus({ preventScroll: true });
55
52
  });
56
53
  }
57
54
  const onlyTime = state.formatInfo.hasTime && !state.formatInfo.hasDate;
@@ -60,16 +57,33 @@ export function useDatePickerProps(state, _a) {
60
57
  const DOMProps = filterDOMProps(props);
61
58
  delete DOMProps.id;
62
59
  return {
63
- groupProps: Object.assign(Object.assign(Object.assign(Object.assign({}, DOMProps), { ref: groupRef, tabIndex: -1, role: 'group' }), focusWithinProps), { style: props.style, 'aria-disabled': state.disabled || undefined, onKeyDown: (e) => {
64
- if (!onlyTime && e.altKey && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {
60
+ groupProps: {
61
+ ...DOMProps,
62
+ ref: groupRef,
63
+ tabIndex: -1,
64
+ role: 'group',
65
+ ...focusWithinProps,
66
+ style: props.style,
67
+ 'aria-disabled': state.disabled || undefined,
68
+ onKeyDown: (e) => {
69
+ const isTargetInsideGroup = e.currentTarget.contains(e.target);
70
+ if (state.isOpen && e.key === 'Escape' && isTargetInsideGroup) {
71
+ e.preventDefault();
72
+ e.stopPropagation();
73
+ state.setOpen(false, 'EscapeKeyDown');
74
+ return;
75
+ }
76
+ if (!onlyTime &&
77
+ e.altKey &&
78
+ (e.key === 'ArrowDown' || e.key === 'ArrowUp') &&
79
+ isTargetInsideGroup) {
65
80
  e.preventDefault();
66
81
  e.stopPropagation();
67
82
  state.setOpen(true, 'ShortcutKeyDown');
68
83
  }
69
- } }),
70
- fieldProps: mergeProps(inputProps, state.dateFieldState.isEmpty && !isActive && props.placeholder
71
- ? { value: '' }
72
- : undefined, {
84
+ },
85
+ },
86
+ fieldProps: mergeProps(inputProps, {
73
87
  controlRef: handleRef,
74
88
  controlProps: { role: 'combobox', 'aria-expanded': state.isOpen },
75
89
  }),
@@ -82,24 +96,22 @@ export function useDatePickerProps(state, _a) {
82
96
  'aria-expanded': state.isOpen,
83
97
  view: 'flat-secondary',
84
98
  onClick: () => {
85
- setActive(true);
86
99
  state.setOpen(!state.isOpen, 'TriggerButtonClick');
87
100
  },
88
101
  },
89
102
  popupProps: {
90
103
  open: state.isOpen,
91
104
  onOpenChange: (open, e, reason) => {
92
- var _a, _b;
93
105
  if (!open) {
94
106
  if (reason === 'escape-key') {
95
107
  state.setOpen(false, 'EscapeKeyDown');
96
108
  focusInput();
97
109
  }
98
110
  else if (reason === 'outside-press') {
99
- if (!(e === null || e === void 0 ? void 0 : e.target) || !((_a = calendarButtonRef.current) === null || _a === void 0 ? void 0 : _a.contains(e.target))) {
111
+ if (!e?.target || !calendarButtonRef.current?.contains(e.target)) {
100
112
  state.setOpen(false, 'ClickOutside');
101
113
  }
102
- if ((e === null || e === void 0 ? void 0 : e.target) && ((_b = groupRef.current) === null || _b === void 0 ? void 0 : _b.contains(e.target))) {
114
+ if (e?.target && groupRef.current?.contains(e.target)) {
103
115
  focusInput();
104
116
  }
105
117
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useDatePickerProps.js","sourceRoot":"../../../../../src","sources":["components/DatePicker/hooks/useDatePickerProps.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAC,cAAc,EAAE,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAI7D,OAAO,EAAC,iBAAiB,EAAC,iCAAwB;AAGlD,OAAO,EAAC,cAAc,EAAC,sCAAmC;AAC1D,OAAO,EAAC,qBAAqB,EAAC,6CAA0C;AACxE,OAAO,EAAC,UAAU,EAAC,kCAA+B;AAElD,OAAO,EAAC,IAAI,EAAC,yBAAgB;AAC7B,OAAO,EAAC,gBAAgB,EAAE,gBAAgB,EAAC,0BAAiB;AAc5D,MAAM,UAAU,kBAAkB,CAC9B,KAAyB,EACzB,EAA+C;QAA/C,EAAC,OAAO,EAAE,MAAM,OAA+B,EAA1B,KAAK,cAA1B,qBAA2B,CAAD;IAE1B,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEpD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAChD,UAAU,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC;QACzC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY;QACnC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,KAAK,CAChD,CAAC;IACF,MAAM,CAA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,CAAC","sourcesContent":["import React from 'react';\n\nimport {isDateTime} from '@gravity-ui/date-utils';\nimport type {DateTime} from '@gravity-ui/date-utils';\nimport {useFocusWithin, useForkRef} from '@gravity-ui/uikit';\nimport type {ButtonButtonProps, PopupProps, TextInputProps} from '@gravity-ui/uikit';\n\nimport type {CalendarInstance, CalendarProps} from '../../Calendar';\nimport {useDateFieldProps} from '../../DateField';\nimport type {DateFieldProps} from '../../DateField';\nimport type {RangeValue} from '../../types';\nimport {filterDOMProps} from '../../utils/filterDOMProps';\nimport {getButtonSizeForInput} from '../../utils/getButtonSizeForInput';\nimport {mergeProps} from '../../utils/mergeProps';\nimport type {DatePickerProps} from '../DatePicker';\nimport {i18n} from '../i18n';\nimport {getCalendarModes, getDateTimeValue} from '../utils';\n\nimport type {DatePickerState} from './useDatePickerState';\n\ninterface InnerDatePickerProps<T = DateTime> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n groupProps: React.HTMLAttributes<unknown> & {ref: React.Ref<any>};\n fieldProps: TextInputProps;\n calendarButtonProps: ButtonButtonProps & {ref: React.Ref<HTMLButtonElement>};\n popupProps: PopupProps;\n calendarProps: CalendarProps<T> & {ref: React.Ref<CalendarInstance>};\n timeInputProps: DateFieldProps<T>;\n}\n\nexport function useDatePickerProps<T extends DateTime | RangeValue<DateTime>>(\n state: DatePickerState<T>,\n {onFocus, onBlur, ...props}: DatePickerProps<T>,\n): InnerDatePickerProps<T> {\n const [isActive, setActive] = React.useState(false);\n\n const [focusedDate, setFocusedDate] = React.useState(\n isDateTime(state.dateFieldState.displayValue)\n ? state.dateFieldState.displayValue\n : state.dateFieldState.displayValue.start,\n );\n const [prevDateValue, setPrevDateValue] = React.useState(state.dateFieldState.displayValue);\n\n if (isDateTime(prevDateValue)) {\n if (\n isDateTime(state.dateFieldState.displayValue) &&\n !state.dateFieldState.displayValue.isSame(prevDateValue, 'day')\n ) {\n setPrevDateValue(state.dateFieldState.displayValue);\n setFocusedDate(state.dateFieldState.displayValue);\n }\n } else if (!isDateTime(state.dateFieldState.displayValue)) {\n if (!state.dateFieldState.displayValue.start.isSame(prevDateValue.start, 'day')) {\n setPrevDateValue(state.dateFieldState.displayValue);\n setFocusedDate(state.dateFieldState.displayValue.start);\n } else if (!state.dateFieldState.displayValue.end.isSame(prevDateValue.end, 'day')) {\n setPrevDateValue(state.dateFieldState.displayValue);\n setFocusedDate(state.dateFieldState.displayValue.end);\n }\n }\n\n const {focusWithinProps} = useFocusWithin({\n onFocusWithin: onFocus,\n onBlurWithin: onBlur,\n onFocusWithinChange(isFocusWithin) {\n setActive(isFocusWithin);\n if (!isFocusWithin) {\n state.setOpen(false, 'FocusOut');\n }\n },\n });\n\n const {inputProps} = useDateFieldProps(state.dateFieldState, props);\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n\n const handleRef = useForkRef(inputRef, inputProps.controlRef);\n\n const calendarRef = React.useRef<CalendarInstance>(null);\n const calendarButtonRef = React.useRef<HTMLButtonElement>(null);\n const groupRef = React.useRef<HTMLElement>(null);\n\n function focusInput() {\n setTimeout(() => {\n inputRef.current?.focus({preventScroll: true});\n });\n }\n\n const onlyTime = state.formatInfo.hasTime && !state.formatInfo.hasDate;\n const calendarModes = getCalendarModes(state.formatInfo);\n\n const {t} = i18n.useTranslation();\n\n const DOMProps = filterDOMProps(props);\n delete DOMProps.id;\n\n return {\n groupProps: {\n ...DOMProps,\n ref: groupRef,\n tabIndex: -1,\n role: 'group',\n ...focusWithinProps,\n style: props.style,\n 'aria-disabled': state.disabled || undefined,\n onKeyDown: (e) => {\n if (!onlyTime && e.altKey && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {\n e.preventDefault();\n e.stopPropagation();\n state.setOpen(true, 'ShortcutKeyDown');\n }\n },\n },\n fieldProps: mergeProps(\n inputProps,\n state.dateFieldState.isEmpty && !isActive && props.placeholder\n ? {value: ''}\n : undefined,\n {\n controlRef: handleRef,\n controlProps: {role: 'combobox', 'aria-expanded': state.isOpen},\n },\n ),\n calendarButtonProps: {\n ref: calendarButtonRef,\n size: getButtonSizeForInput(props.size),\n disabled: state.disabled,\n 'aria-label': t('Calendar'),\n 'aria-haspopup': 'dialog',\n 'aria-expanded': state.isOpen,\n view: 'flat-secondary',\n onClick: () => {\n setActive(true);\n state.setOpen(!state.isOpen, 'TriggerButtonClick');\n },\n },\n popupProps: {\n open: state.isOpen,\n onOpenChange: (open, e, reason) => {\n if (!open) {\n if (reason === 'escape-key') {\n state.setOpen(false, 'EscapeKeyDown');\n focusInput();\n } else if (reason === 'outside-press') {\n if (!e?.target || !calendarButtonRef.current?.contains(e.target as Node)) {\n state.setOpen(false, 'ClickOutside');\n }\n\n if (e?.target && groupRef.current?.contains(e.target as Node)) {\n focusInput();\n }\n }\n }\n },\n onTransitionOutComplete: () => {\n setFocusedDate(\n isDateTime(state.dateFieldState.displayValue)\n ? state.dateFieldState.displayValue\n : state.dateFieldState.displayValue.start,\n );\n },\n modal: !props.disableFocusTrap,\n returnFocus: !props.disableFocusTrap,\n disablePortal: props.disablePortal,\n placement: props.popupPlacement,\n offset: props.popupOffset,\n className: props.popupClassName,\n style: props.popupStyle,\n },\n calendarProps: {\n ref: calendarRef,\n autoFocus: true,\n size: props.size === 's' ? 'm' : props.size,\n disabled: props.disabled,\n readOnly: props.readOnly,\n onUpdate: (d) => {\n state.setDateValue(d);\n if (!state.formatInfo.hasTime) {\n focusInput();\n }\n },\n value: state.dateFieldState.displayValue,\n minValue: props.minValue,\n maxValue: props.maxValue,\n isDateUnavailable: props.isDateUnavailable,\n timeZone: state.timeZone,\n focusedValue: focusedDate,\n onFocusUpdate: setFocusedDate,\n modes: calendarModes,\n },\n timeInputProps: {\n value: state.timeValue,\n placeholderValue: getDateTimeValue(state.dateFieldState.displayValue),\n onUpdate: state.setTimeValue,\n format: state.timeFormat,\n readOnly: state.readOnly,\n disabled: state.disabled,\n timeZone: state.timeZone,\n hasClear: props.hasClear,\n size: props.size,\n },\n };\n}\n"]}
1
+ {"version":3,"file":"useDatePickerPro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AAC,KAAK,CAAC,IAAI;YAC3C,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;gBACZ,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;gBACtB,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;oBAC5B,UAAU,EAAE,CAAC;gBACjB,CAAC;YACL,CAAC;YACD,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,YAAY;YACxC,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;YAC1C,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,YAAY,EAAE,WAAW;YACzB,aAAa,EAAE,cAAc;YAC7B,KAAK,EAAE,aAAa;SACvB;QACD,cAAc,EAAE;YACZ,KAAK,EAAE,KAAK,CAAC,SAAS;YACtB,gBAAgB,EAAE,gBAAgB,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC;YACrE,QAAQ,EAAE,KAAK,CAAC,YAAY;YAC5B,MAAM,EAAE,KAAK,CAAC,UAAU;YACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;SACnB;KACJ,CAAC;AACN,CAAC","sourcesContent":["import React from 'react';\n\nimport {isDateTime} from '@gravity-ui/date-utils';\nimport type {DateTime} from '@gravity-ui/date-utils';\nimport {useFocusWithin, useForkRef} from '@gravity-ui/uikit';\nimport type {ButtonButtonProps, PopupProps, TextInputProps} from '@gravity-ui/uikit';\n\nimport type {CalendarCommonProps, CalendarInstance} from '../../Calendar';\nimport {useDateFieldProps} from '../../DateField';\nimport type {DateFieldProps} from '../../DateField';\nimport type {RangeValue} from '../../types';\nimport {filterDOMProps} from '../../utils/filterDOMProps';\nimport {getButtonSizeForInput} from '../../utils/getButtonSizeForInput';\nimport {mergeProps} from '../../utils/mergeProps';\nimport type {DatePickerProps} from '../DatePicker';\nimport {i18n} from '../i18n';\nimport {getCalendarModes, getDateTimeValue} from '../utils';\n\nimport type {DatePickerState} from './useDatePickerState';\n\ninterface InnerDatePickerProps<T = DateTime> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n groupProps: React.HTMLAttributes<unknown> & {ref: React.Ref<any>};\n fieldProps: TextInputProps;\n calendarButtonProps: ButtonButtonProps & {ref: React.Ref<HTMLButtonElement>};\n popupProps: PopupProps;\n calendarProps: CalendarCommonProps<T> & {ref: React.Ref<CalendarInstance>};\n timeInputProps: DateFieldProps<T>;\n}\n\nexport function useDatePickerProps<T extends DateTime | RangeValue<DateTime>>(\n state: DatePickerState<T>,\n {onFocus, onBlur, ...props}: DatePickerProps<T>,\n): InnerDatePickerProps<T> {\n const [focusedDate, setFocusedDate] = React.useState(\n isDateTime(state.dateFieldState.displayValue)\n ? state.dateFieldState.displayValue\n : state.dateFieldState.displayValue.start,\n );\n const [prevDateValue, setPrevDateValue] = React.useState(state.dateFieldState.displayValue);\n\n if (isDateTime(prevDateValue)) {\n if (\n isDateTime(state.dateFieldState.displayValue) &&\n !state.dateFieldState.displayValue.isSame(prevDateValue, 'day')\n ) {\n setPrevDateValue(state.dateFieldState.displayValue);\n setFocusedDate(state.dateFieldState.displayValue);\n }\n } else if (!isDateTime(state.dateFieldState.displayValue)) {\n if (!state.dateFieldState.displayValue.start.isSame(prevDateValue.start, 'day')) {\n setPrevDateValue(state.dateFieldState.displayValue);\n setFocusedDate(state.dateFieldState.displayValue.start);\n } else if (!state.dateFieldState.displayValue.end.isSame(prevDateValue.end, 'day')) {\n setPrevDateValue(state.dateFieldState.displayValue);\n setFocusedDate(state.dateFieldState.displayValue.end);\n }\n }\n\n const {inputProps} = useDateFieldProps(state.dateFieldState, props);\n\n const {focusWithinProps} = useFocusWithin({\n onFocusWithin: onFocus,\n onBlurWithin: onBlur,\n onFocusWithinChange(isFocusWithin) {\n state.dateFieldState.setActive(isFocusWithin);\n if (!isFocusWithin) {\n state.setOpen(false, 'FocusOut');\n state.dateFieldState.confirmPlaceholder();\n }\n },\n });\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n\n const handleRef = useForkRef(inputRef, inputProps.controlRef);\n\n const calendarRef = React.useRef<CalendarInstance>(null);\n const calendarButtonRef = React.useRef<HTMLButtonElement>(null);\n const groupRef = React.useRef<HTMLElement>(null);\n\n function focusInput() {\n setTimeout(() => {\n inputRef.current?.focus({preventScroll: true});\n });\n }\n\n const onlyTime = state.formatInfo.hasTime && !state.formatInfo.hasDate;\n const calendarModes = getCalendarModes(state.formatInfo);\n\n const {t} = i18n.useTranslation();\n\n const DOMProps = filterDOMProps(props);\n delete DOMProps.id;\n\n return {\n groupProps: {\n ...DOMProps,\n ref: groupRef,\n tabIndex: -1,\n role: 'group',\n ...focusWithinProps,\n style: props.style,\n 'aria-disabled': state.disabled || undefined,\n onKeyDown: (e) => {\n const isTargetInsideGroup = (e.currentTarget as HTMLElement).contains(\n e.target as Node,\n );\n\n if (state.isOpen && e.key === 'Escape' && isTargetInsideGroup) {\n e.preventDefault();\n e.stopPropagation();\n state.setOpen(false, 'EscapeKeyDown');\n return;\n }\n\n if (\n !onlyTime &&\n e.altKey &&\n (e.key === 'ArrowDown' || e.key === 'ArrowUp') &&\n isTargetInsideGroup\n ) {\n e.preventDefault();\n e.stopPropagation();\n state.setOpen(true, 'ShortcutKeyDown');\n }\n },\n },\n fieldProps: mergeProps(inputProps, {\n controlRef: handleRef,\n controlProps: {role: 'combobox', 'aria-expanded': state.isOpen},\n }),\n calendarButtonProps: {\n ref: calendarButtonRef,\n size: getButtonSizeForInput(props.size),\n disabled: state.disabled,\n 'aria-label': t('Calendar'),\n 'aria-haspopup': 'dialog',\n 'aria-expanded': state.isOpen,\n view: 'flat-secondary',\n onClick: () => {\n state.setOpen(!state.isOpen, 'TriggerButtonClick');\n },\n },\n popupProps: {\n open: state.isOpen,\n onOpenChange: (open, e, reason) => {\n if (!open) {\n if (reason === 'escape-key') {\n state.setOpen(false, 'EscapeKeyDown');\n focusInput();\n } else if (reason === 'outside-press') {\n if (!e?.target || !calendarButtonRef.current?.contains(e.target as Node)) {\n state.setOpen(false, 'ClickOutside');\n }\n\n if (e?.target && groupRef.current?.contains(e.target as Node)) {\n focusInput();\n }\n }\n }\n },\n onTransitionOutComplete: () => {\n setFocusedDate(\n isDateTime(state.dateFieldState.displayValue)\n ? state.dateFieldState.displayValue\n : state.dateFieldState.displayValue.start,\n );\n },\n modal: !props.disableFocusTrap,\n returnFocus: !props.disableFocusTrap,\n disablePortal: props.disablePortal,\n placement: props.popupPlacement,\n offset: props.popupOffset,\n className: props.popupClassName,\n style: props.popupStyle,\n },\n calendarProps: {\n ref: calendarRef,\n autoFocus: true,\n size: props.size === 's' ? 'm' : props.size,\n disabled: props.disabled,\n readOnly: props.readOnly,\n onUpdate: (d) => {\n state.setDateValue(d);\n if (!state.formatInfo.hasTime) {\n focusInput();\n }\n },\n value: state.dateFieldState.displayValue,\n minValue: props.minValue,\n maxValue: props.maxValue,\n isDateUnavailable: props.isDateUnavailable,\n timeZone: state.timeZone,\n focusedValue: focusedDate,\n onFocusUpdate: setFocusedDate,\n modes: calendarModes,\n },\n timeInputProps: {\n value: state.timeValue,\n placeholderValue: getDateTimeValue(state.dateFieldState.displayValue),\n onUpdate: state.setTimeValue,\n format: state.timeFormat,\n readOnly: state.readOnly,\n disabled: state.disabled,\n timeZone: state.timeZone,\n hasClear: props.hasClear,\n size: props.size,\n },\n };\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  interface HiddenInputProps<T> {
2
3
  value: T;
3
4
  onReset?: (value: T) => void;
@@ -6,9 +7,5 @@ interface HiddenInputProps<T> {
6
7
  disabled?: boolean;
7
8
  form?: string;
8
9
  }
9
- export declare function HiddenInput<T>({ name, value, onReset, form, disabled, toStringValue, }: HiddenInputProps<T>): import("react/jsx-runtime").JSX.Element | null;
10
- export declare function useFormResetHandler<T>({ initialValue, onReset, }: {
11
- initialValue: T;
12
- onReset?: (value: T) => void;
13
- }): (node: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null) => void;
10
+ export declare function HiddenInput<T>({ name, value, onReset, form, disabled, toStringValue, }: HiddenInputProps<T>): React.JSX.Element | null;
14
11
  export {};
@@ -5,10 +5,10 @@ export function HiddenInput({ name, value, onReset, form, disabled, toStringValu
5
5
  if (!name) {
6
6
  return null;
7
7
  }
8
- const v = toStringValue ? toStringValue(value) : `${value !== null && value !== void 0 ? value : ''}`;
8
+ const v = toStringValue ? toStringValue(value) : `${value ?? ''}`;
9
9
  return _jsx("input", { ref: ref, type: "hidden", name: name, value: v, disabled: disabled, form: form });
10
10
  }
11
- export function useFormResetHandler({ initialValue, onReset, }) {
11
+ function useFormResetHandler({ initialValue, onReset, }) {
12
12
  const [formElement, setFormElement] = React.useState(null);
13
13
  const resetValue = React.useRef(initialValue);
14
14
  React.useEffect(() => {
@@ -24,8 +24,7 @@ export function useFormResetHandler({ initialValue, onReset, }) {
24
24
  };
25
25
  }, [formElement, onReset]);
26
26
  const ref = React.useCallback((node) => {
27
- var _a;
28
- setFormElement((_a = node === null || node === void 0 ? void 0 : node.form) !== null && _a !== void 0 ? _a : null);
27
+ setFormElement(node?.form ?? null);
29
28
  }, []);
30
29
  return ref;
31
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"HiddenInput.js","sourceRoot":"../../../../src","sources":["components/HiddenInput/HiddenInput.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,UAAU,WAAW,CAAI,EAC3B,IAAI,EACJ,KAAK,EACL,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,aAAa,GACK;I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AC,IAAuE,EAAE,EAAE;;QACxE,cAAc,CAAC,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,mCAAI,IAAI,CAAC,CAAC;IACvC,CAAC,EACD,EAAE,CACL,CAAC;IAEF,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import React from 'react';\n\ninterface HiddenInputProps<T> {\n value: T;\n onReset?: (value: T) => void;\n toStringValue?: (value: T) => string;\n name?: string;\n disabled?: boolean;\n form?: string;\n}\nexport function HiddenInput<T>({\n name,\n value,\n onReset,\n form,\n disabled,\n toStringValue,\n}: HiddenInputProps<T>) {\n const ref = useFormResetHandler<T>({initialValue: value, onReset});\n\n if (!name) {\n return null;\n }\n\n const v = toStringValue ? toStringValue(value) : `${value ?? ''}`;\n return <input ref={ref} type=\"hidden\" name={name} value={v} disabled={disabled} form={form} />;\n}\n\nexport function useFormResetHandler<T>({\n initialValue,\n onReset,\n}: {\n initialValue: T;\n onReset?: (value: T) => void;\n}) {\n const [formElement, setFormElement] = React.useState<HTMLFormElement | null>(null);\n\n const resetValue = React.useRef(initialValue);\n\n React.useEffect(() => {\n if (!formElement || !onReset) {\n return undefined;\n }\n\n const handleReset = () => {\n onReset(resetValue.current);\n };\n\n formElement.addEventListener('reset', handleReset);\n return () => {\n formElement.removeEventListener('reset', handleReset);\n };\n }, [formElement, onReset]);\n\n const ref = React.useCallback(\n (node: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null) => {\n setFormElement(node?.form ?? null);\n },\n [],\n );\n\n return ref;\n}\n"]}
1
+ {"version":3,"file":"HiddenInput.js","sourceRoot":"../../../../src","sources":["components/HiddenInput/HiddenInput.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,MAAM,UAAU,WAAW,CAAI,EAC3B,IAAI,EACJ,KAAK,EACL,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,aAAa,GACK;IAClB,MAAM,GAAG,GAAG,mBAAmB,CAAI,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AAI,CAAC,CAAC;IACvC,CAAC,EACD,EAAE,CACL,CAAC;IAEF,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import React from 'react';\n\ninterface HiddenInputProps<T> {\n value: T;\n onReset?: (value: T) => void;\n toStringValue?: (value: T) => string;\n name?: string;\n disabled?: boolean;\n form?: string;\n}\nexport function HiddenInput<T>({\n name,\n value,\n onReset,\n form,\n disabled,\n toStringValue,\n}: HiddenInputProps<T>) {\n const ref = useFormResetHandler<T>({initialValue: value, onReset});\n\n if (!name) {\n return null;\n }\n\n const v = toStringValue ? toStringValue(value) : `${value ?? ''}`;\n return <input ref={ref} type=\"hidden\" name={name} value={v} disabled={disabled} form={form} />;\n}\n\nfunction useFormResetHandler<T>({\n initialValue,\n onReset,\n}: {\n initialValue: T;\n onReset?: (value: T) => void;\n}) {\n const [formElement, setFormElement] = React.useState<HTMLFormElement | null>(null);\n\n const resetValue = React.useRef(initialValue);\n\n React.useEffect(() => {\n if (!formElement || !onReset) {\n return undefined;\n }\n\n const handleReset = () => {\n onReset(resetValue.current);\n };\n\n formElement.addEventListener('reset', handleReset);\n return () => {\n formElement.removeEventListener('reset', handleReset);\n };\n }, [formElement, onReset]);\n\n const ref = React.useCallback(\n (node: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null) => {\n setFormElement(node?.form ?? null);\n },\n [],\n );\n\n return ref;\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { DateTime } from '@gravity-ui/date-utils';
3
- import type { CalendarProps } from "../Calendar/Calendar.js";
3
+ import type { CalendarCommonProps } from "../Calendar/Calendar.js";
4
4
  import type { CalendarInstance } from "../CalendarView/CalendarView.js";
5
5
  import type { RangeValue } from "../types/index.js";
6
6
  import "../CalendarView/Calendar.css";
7
- export type RangeCalendarProps = CalendarProps<RangeValue<DateTime>>;
7
+ export type RangeCalendarProps = CalendarCommonProps<RangeValue<DateTime>>;
8
8
  export declare const RangeCalendar: React.ForwardRefExoticComponent<RangeCalendarProps & React.RefAttributes<CalendarInstance>>;
@@ -7,12 +7,11 @@ import "../CalendarView/Calendar.css";
7
7
  export const RangeCalendar = React.forwardRef(function Calendar(props, ref) {
8
8
  const state = useRangeCalendarState(props);
9
9
  const handleBlur = (e) => {
10
- var _a;
11
10
  if (state.anchorDate) {
12
11
  state.selectFocusedDate();
13
12
  }
14
- (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
13
+ props.onBlur?.(e);
15
14
  };
16
- return _jsx(CalendarView, Object.assign({ ref: ref }, props, { state: state, onBlur: handleBlur }));
15
+ return _jsx(CalendarView, { ref: ref, ...props, state: state, onBlur: handleBlur });
17
16
  });
18
17
  //# sourceMappingURL=RangeCalendar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RangeCalendar.js","sourceRoot":"../../../../src","sources":["components/RangeCalendar/RangeCalendar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAC,YAAY,EAAC,wCAAqC;AAE1D,OAAO,EAAC,qBAAqB,EAAC,uDAAoD;AAGlF,sCAAuC;AAIvC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CACzC,SAAS,QAAQ,CAAC,KAAyB,EAAE,GAAG;IAC5C,MAAM,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAE3C,MAAM,UAAU,GAAG,CAAC,CAAmB,EAAE,EAAE;;QACvC,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;YACnB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC9B,CAAC;QACD,MAAA,KAAK,CAAC,MAAM,sDAAG,CAAC,CAAC,CAAC;IACtB,CAAC,CAAC;IACF,OAAO,KAAC,YAAY,kBAAC,GAAG,EAAE,GAAG,IAAM,KAAK,IAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,IAAI,CAAC;AACnF,CAAC,CACJ,CAAC","sourcesContent":["'use client';\n\nimport React from 'react';\n\nimport type {DateTime} from '@gravity-ui/date-utils';\n\nimport type {CalendarProps} from '../Calendar/Calendar';\nimport {CalendarView} from '../CalendarView/CalendarView';\nimport type {CalendarInstance} from '../CalendarView/CalendarView';\nimport {useRangeCalendarState} from '../CalendarView/hooks/useRangeCalendarState';\nimport type {RangeValue} from '../types';\n\nimport '../CalendarView/Calendar.scss';\n\nexport type RangeCalendarProps = CalendarProps<RangeValue<DateTime>>;\n\nexport const RangeCalendar = React.forwardRef<CalendarInstance, RangeCalendarProps>(\n function Calendar(props: RangeCalendarProps, ref) {\n const state = useRangeCalendarState(props);\n\n const handleBlur = (e: React.FocusEvent) => {\n if (state.anchorDate) {\n state.selectFocusedDate();\n }\n props.onBlur?.(e);\n };\n return <CalendarView ref={ref} {...props} state={state} onBlur={handleBlur} />;\n },\n);\n"]}
1
+ {"version":3,"file":"RangeCalendar.js","sourceRoot":"../../../../src","sources":["components/RangeCalendar/RangeCalendar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAC,YAAY,EAAC,wCAAqC;AAE1D,OAAO,EAAC,qBAAqB,EAAC,uDAAoD;AAGlF,sCAAuC;AAIvC,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CACzC,SAAS,QAAQ,CAAC,KAAyB,EAAE,GAAG;IAC5C,MAAM,KAAK,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAE3C,MAAM,UAAU,GAAG,CAAC,CAAmB,EAAE,EAAE;QACvC,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;YACnB,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC9B,CAAC;QACD,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC,CAAC;IACF,OAAO,KAAC,YAAY,IAAC,GAAG,EAAE,GAAG,KAAM,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,GAAI,CAAC;AACnF,CAAC,CACJ,CAAC","sourcesContent":["'use client';\n\nimport React from 'react';\n\nimport type {DateTime} from '@gravity-ui/date-utils';\n\nimport type {CalendarCommonProps} from '../Calendar/Calendar';\nimport {CalendarView} from '../CalendarView/CalendarView';\nimport type {CalendarInstance} from '../CalendarView/CalendarView';\nimport {useRangeCalendarState} from '../CalendarView/hooks/useRangeCalendarState';\nimport type {RangeValue} from '../types';\n\nimport '../CalendarView/Calendar.scss';\n\nexport type RangeCalendarProps = CalendarCommonProps<RangeValue<DateTime>>;\n\nexport const RangeCalendar = React.forwardRef<CalendarInstance, RangeCalendarProps>(\n function Calendar(props: RangeCalendarProps, ref) {\n const state = useRangeCalendarState(props);\n\n const handleBlur = (e: React.FocusEvent) => {\n if (state.anchorDate) {\n state.selectFocusedDate();\n }\n props.onBlur?.(e);\n };\n return <CalendarView ref={ref} {...props} state={state} onBlur={handleBlur} />;\n },\n);\n"]}
@@ -9,4 +9,4 @@ export type RangeDateFieldProps = DateFieldProps<RangeValue<DateTime>> & {
9
9
  */
10
10
  delimiter?: string;
11
11
  };
12
- export declare function RangeDateField({ className, ...props }: RangeDateFieldProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function RangeDateField({ className, ...props }: RangeDateFieldProps): import("react").JSX.Element;
@@ -1,30 +1,17 @@
1
1
  'use client';
2
- import { __rest } from "tslib";
3
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
- import React from 'react';
5
- import { TextInput, useFocusWithin } from '@gravity-ui/uikit';
3
+ import { TextInput } from '@gravity-ui/uikit';
6
4
  import { block } from "../../utils/cn.js";
7
5
  import { useDateFieldProps } from "../DateField/hooks/useDateFieldProps.js";
6
+ import { useRangeDateFieldState } from "../DateField/hooks/useRangeDateFieldState.js";
8
7
  import { HiddenInput } from "../HiddenInput/HiddenInput.js";
9
- import { filterDOMProps } from "../utils/filterDOMProps.js";
10
- import { useRangeDateFieldState } from "./hooks/useRangeDateFieldState.js";
11
8
  import "./RangeDateField.css";
12
9
  const b = block('range-date-field');
13
- export function RangeDateField(_a) {
14
- var _b, _c;
15
- var { className } = _a, props = __rest(_a, ["className"]);
10
+ export function RangeDateField({ className, ...props }) {
16
11
  const state = useRangeDateFieldState(props);
17
- const { inputProps } = useDateFieldProps(state, props);
18
- const [isActive, setActive] = React.useState(false);
19
- const { focusWithinProps } = useFocusWithin({
20
- onFocusWithinChange(isFocusWithin) {
21
- setActive(isFocusWithin);
22
- },
23
- });
24
- const DOMProps = filterDOMProps(props);
25
- delete DOMProps.id;
26
- return (_jsxs("div", Object.assign({}, DOMProps, { className: b(null, className), style: props.style }, focusWithinProps, { children: [_jsx(TextInput, Object.assign({}, inputProps, { value: state.isEmpty && !isActive && props.placeholder ? '' : inputProps.value })), _jsx(HiddenInput, { name: props.name, form: props.form, onReset: (v) => {
27
- state.setDate(v);
28
- }, value: (_b = state.value) !== null && _b !== void 0 ? _b : null, toStringValue: (v) => (v ? v.start.toISOString() : ''), disabled: state.disabled }), _jsx(HiddenInput, { name: props.name, form: props.form, value: (_c = state.value) !== null && _c !== void 0 ? _c : null, toStringValue: (v) => (v ? v.end.toISOString() : ''), disabled: state.disabled })] })));
12
+ const { groupProps, inputProps } = useDateFieldProps(state, props);
13
+ return (_jsxs("div", { ...groupProps, className: b(null, className), style: props.style, children: [_jsx(TextInput, { ...inputProps }), _jsx(HiddenInput, { name: props.name, form: props.form, onReset: (v) => {
14
+ state.setValue(v);
15
+ }, value: state.value ?? null, toStringValue: (v) => (v ? v.start.toISOString() : ''), disabled: state.disabled }), _jsx(HiddenInput, { name: props.name, form: props.form, value: state.value ?? null, toStringValue: (v) => (v ? v.end.toISOString() : ''), disabled: state.disabled })] }));
29
16
  }
30
17
  //# sourceMappingURL=RangeDateField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RangeDateField.js","sourceRoot":"../../../../src","sources":["components/RangeDateField/RangeDateField.tsx"],"names":[],"mappings":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AE,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,IAChF,EACF,KAAC,WAAW,IACR,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACX,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBACrB,CAAC,EACD,KAAK,EAAE,MAAA,KAAK,CAAC,KAAK,mCAAI,IAAI,EAC1B,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACtD,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAC1B,EACF,KAAC,WAAW,IACR,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,KAAK,EAAE,MAAA,KAAK,CAAC,KAAK,mCAAI,IAAI,EAC1B,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACpD,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAC1B,KACA,CACT,CAAC;AACN,CAAC","sourcesContent":["'use client';\n\nimport React from 'react';\n\nimport type {DateTime} from '@gravity-ui/date-utils';\nimport {TextInput, useFocusWithin} from '@gravity-ui/uikit';\n\nimport {block} from '../../utils/cn';\nimport {useDateFieldProps} from '../DateField/hooks/useDateFieldProps';\nimport type {DateFieldProps} from '../DateField/hooks/useDateFieldProps';\nimport {HiddenInput} from '../HiddenInput/HiddenInput';\nimport type {RangeValue} from '../types';\nimport {filterDOMProps} from '../utils/filterDOMProps';\n\nimport {useRangeDateFieldState} from './hooks/useRangeDateFieldState';\n\nimport './RangeDateField.scss';\n\nconst b = block('range-date-field');\n\nexport type RangeDateFieldProps = DateFieldProps<RangeValue<DateTime>> & {\n /**\n * Delimiter separating the start and end parts of the range.\n * @default ' — '\n */\n delimiter?: string;\n};\n\nexport function RangeDateField({className, ...props}: RangeDateFieldProps) {\n const state = useRangeDateFieldState(props);\n\n const {inputProps} = useDateFieldProps(state, props);\n\n const [isActive, setActive] = React.useState(false);\n const {focusWithinProps} = useFocusWithin({\n onFocusWithinChange(isFocusWithin) {\n setActive(isFocusWithin);\n },\n });\n\n const DOMProps = filterDOMProps(props);\n delete DOMProps.id;\n\n return (\n <div {...DOMProps} className={b(null, className)} style={props.style} {...focusWithinProps}>\n <TextInput\n {...inputProps}\n value={state.isEmpty && !isActive && props.placeholder ? '' : inputProps.value}\n />\n <HiddenInput\n name={props.name}\n form={props.form}\n onReset={(v) => {\n state.setDate(v);\n }}\n value={state.value ?? null}\n toStringValue={(v) => (v ? v.start.toISOString() : '')}\n disabled={state.disabled}\n />\n <HiddenInput\n name={props.name}\n form={props.form}\n value={state.value ?? null}\n toStringValue={(v) => (v ? v.end.toISOString() : '')}\n disabled={state.disabled}\n />\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"RangeDateField.js","sourceRoot":"../../../../src","sources":["components/RangeDateField/RangeDateField.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAC,KAAK,EAAC,0BAAuB;AACrC,OAAO,EAAC,iBAAiB,EAAC,gDAA6C;AAEvE,OAAO,EAAC,sBAAsB,EAAC,qDAAkD;AACjF,OAAO,EAAC,WAAW,EAAC,sCAAmC;AAGvD,8BAA+B;AAE/B,MAAM,CAAC,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAAC;AAUpC,MAAM,UAAU,cAAc,CAAC,EAAC,SAAS,EAAE,GAAG,KAAK,EAAsB;IACrE,MAAM,KAAK,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAE5C,MAAM,EAAC,UAAU,EAAE,UAAU,EAAC,GAAG,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAEjE,OAAO,CACH,kBAAS,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,aAClE,KAAC,SAAS,OAAK,UAAU,GAAI,EAC7B,KAAC,WAAW,IACR,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACX,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBACtB,CAAC,EACD,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI,EAC1B,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACtD,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAC1B,EACF,KAAC,WAAW,IACR,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI,EAC1B,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACpD,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAC1B,IACA,CACT,CAAC;AACN,CAAC","sourcesContent":["'use client';\n\nimport type {DateTime} from '@gravity-ui/date-utils';\nimport {TextInput} from '@gravity-ui/uikit';\n\nimport {block} from '../../utils/cn';\nimport {useDateFieldProps} from '../DateField/hooks/useDateFieldProps';\nimport type {DateFieldProps} from '../DateField/hooks/useDateFieldProps';\nimport {useRangeDateFieldState} from '../DateField/hooks/useRangeDateFieldState';\nimport {HiddenInput} from '../HiddenInput/HiddenInput';\nimport type {RangeValue} from '../types';\n\nimport './RangeDateField.scss';\n\nconst b = block('range-date-field');\n\nexport type RangeDateFieldProps = DateFieldProps<RangeValue<DateTime>> & {\n /**\n * Delimiter separating the start and end parts of the range.\n * @default ' — '\n */\n delimiter?: string;\n};\n\nexport function RangeDateField({className, ...props}: RangeDateFieldProps) {\n const state = useRangeDateFieldState(props);\n\n const {groupProps, inputProps} = useDateFieldProps(state, props);\n\n return (\n <div {...groupProps} className={b(null, className)} style={props.style}>\n <TextInput {...inputProps} />\n <HiddenInput\n name={props.name}\n form={props.form}\n onReset={(v) => {\n state.setValue(v);\n }}\n value={state.value ?? null}\n toStringValue={(v) => (v ? v.start.toISOString() : '')}\n disabled={state.disabled}\n />\n <HiddenInput\n name={props.name}\n form={props.form}\n value={state.value ?? null}\n toStringValue={(v) => (v ? v.end.toISOString() : '')}\n disabled={state.disabled}\n />\n </div>\n );\n}\n"]}
@@ -1,2 +1 @@
1
1
  export * from "./RangeDateField.js";
2
- export * from "./hooks/useRangeDateFieldState.js";
@@ -1,3 +1,2 @@
1
1
  export * from "./RangeDateField.js";
2
- export * from "./hooks/useRangeDateFieldState.js";
3
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../../../../src","sources":["components/RangeDateField/index.ts"],"names":[],"mappings":"AAAA,oCAAiC;AAEjC,kDAA+C","sourcesContent":["export * from './RangeDateField';\n\nexport * from './hooks/useRangeDateFieldState';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"../../../../src","sources":["components/RangeDateField/index.ts"],"names":[],"mappings":"AAAA,oCAAiC","sourcesContent":["export * from './RangeDateField';\n"]}
@@ -1,6 +1,7 @@
1
+ import React from 'react';
1
2
  import type { DateTime } from '@gravity-ui/date-utils';
2
3
  import type { DatePickerProps } from "../DatePicker/index.js";
3
4
  import type { RangeValue } from "../types/index.js";
4
5
  import "./RangeDatePicker.css";
5
6
  export type RangeDatePickerProps = DatePickerProps<RangeValue<DateTime>>;
6
- export declare function RangeDatePicker({ className, ...props }: RangeDatePickerProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function RangeDatePicker({ className, ...props }: RangeDatePickerProps): React.JSX.Element;
@@ -1,5 +1,4 @@
1
1
  'use client';
2
- import { __rest } from "tslib";
3
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
3
  import React from 'react';
5
4
  import { Calendar as CalendarIcon, Clock as ClockIcon } from '@gravity-ui/icons';
@@ -13,14 +12,13 @@ import { RangeDateField } from "../RangeDateField/index.js";
13
12
  import { useRangeDatePickerState } from "./hooks/useRangeDatePickerState.js";
14
13
  import "./RangeDatePicker.css";
15
14
  const b = block('range-date-picker');
16
- export function RangeDatePicker(_a) {
17
- var { className } = _a, props = __rest(_a, ["className"]);
15
+ export function RangeDatePicker({ className, ...props }) {
18
16
  const [anchor, setAnchor] = React.useState(null);
19
17
  const state = useRangeDatePickerState(props);
20
18
  const { groupProps, fieldProps, calendarButtonProps, popupProps, calendarProps, timeInputProps } = useDatePickerProps(state, props);
21
19
  const isOnlyTime = state.formatInfo.hasTime && !state.formatInfo.hasDate;
22
- return (_jsxs("div", Object.assign({ className: b(null, className) }, groupProps, { children: [!isOnlyTime && (_jsx("div", { ref: setAnchor, className: b('popup-anchor'), children: _jsx(Popup, Object.assign({ anchorElement: anchor }, popupProps, { children: _jsxs("div", { className: b('popup-content'), children: [typeof props.children === 'function' ? (props.children(Object.assign(Object.assign({}, calendarProps), { value: state.value }))) : (_jsx(RangeCalendar, Object.assign({}, calendarProps, { value: state.value }))), state.formatInfo.hasTime && (_jsx("div", { className: b('time-field-wrapper'), children: _jsx(RangeDateField, Object.assign({}, timeInputProps)) }))] }) })) })), _jsx(TextInput, Object.assign({}, fieldProps, { className: b('field'), endContent: _jsxs(React.Fragment, { children: [!isOnlyTime && (_jsx(Button, Object.assign({}, calendarButtonProps, { children: _jsx(Icon, { data: CalendarIcon }) }))), isOnlyTime && (_jsx(StubButton, { size: calendarButtonProps.size, icon: ClockIcon }))] }) })), _jsx(HiddenInput, { name: props.name, form: props.form, onReset: (v) => {
23
- state.dateFieldState.setDate(v);
24
- }, value: state.value, toStringValue: (v) => (v ? v.start.toISOString() : ''), disabled: state.disabled }), _jsx(HiddenInput, { name: props.name, form: props.form, value: state.value, toStringValue: (v) => (v ? v.end.toISOString() : ''), disabled: state.disabled })] })));
20
+ return (_jsxs("div", { className: b(null, className), ...groupProps, children: [!isOnlyTime && (_jsx("div", { ref: setAnchor, className: b('popup-anchor'), children: _jsx(Popup, { anchorElement: anchor, ...popupProps, children: _jsxs("div", { className: b('popup-content'), children: [typeof props.children === 'function' ? (props.children({ ...calendarProps, value: state.value })) : (_jsx(RangeCalendar, { ...calendarProps, value: state.value })), state.formatInfo.hasTime && (_jsx("div", { className: b('time-field-wrapper'), children: _jsx(RangeDateField, { ...timeInputProps }) }))] }) }) })), _jsx(TextInput, { ...fieldProps, className: b('field'), endContent: _jsxs(React.Fragment, { children: [!isOnlyTime && (_jsx(Button, { ...calendarButtonProps, children: _jsx(Icon, { data: CalendarIcon }) })), isOnlyTime && (_jsx(StubButton, { size: calendarButtonProps.size, icon: ClockIcon }))] }) }), _jsx(HiddenInput, { name: props.name, form: props.form, onReset: (v) => {
21
+ state.dateFieldState.setValue(v);
22
+ }, value: state.value, toStringValue: (v) => (v ? v.start.toISOString() : ''), disabled: state.disabled }), _jsx(HiddenInput, { name: props.name, form: props.form, value: state.value, toStringValue: (v) => (v ? v.end.toISOString() : ''), disabled: state.disabled })] }));
25
23
  }
26
24
  //# sourceMappingURL=RangeDatePicker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RangeDatePicker.js","sourceRoot":"../../../../src","sources":["components/RangeDatePicker/RangeDatePicker.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAC,QAAQ,IAAI,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F,KAAC,WAAW,IACR,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACpD,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAC1B,KACA,CACT,CAAC;AACN,CAAC","sourcesContent":["'use client';\n\nimport React from 'react';\n\nimport type {DateTime} from '@gravity-ui/date-utils';\nimport {Calendar as CalendarIcon, Clock as ClockIcon} from '@gravity-ui/icons';\nimport {Button, Icon, Popup, TextInput} from '@gravity-ui/uikit';\n\nimport {block} from '../../utils/cn';\nimport {RangeCalendar} from '../Calendar';\nimport {useDatePickerProps} from '../DatePicker';\nimport type {DatePickerProps} from '../DatePicker';\nimport {StubButton} from '../DatePicker/StubButton';\nimport {HiddenInput} from '../HiddenInput/HiddenInput';\nimport {RangeDateField} from '../RangeDateField';\nimport type {RangeValue} from '../types';\n\nimport {useRangeDatePickerState} from './hooks/useRangeDatePickerState';\n\nimport './RangeDatePicker.scss';\n\nconst b = block('range-date-picker');\n\nexport type RangeDatePickerProps = DatePickerProps<RangeValue<DateTime>>;\n\nexport function RangeDatePicker({className, ...props}: RangeDatePickerProps) {\n const [anchor, setAnchor] = React.useState<HTMLDivElement | null>(null);\n\n const state = useRangeDatePickerState(props);\n\n const {groupProps, fieldProps, calendarButtonProps, popupProps, calendarProps, timeInputProps} =\n useDatePickerProps(state, props);\n\n const isOnlyTime = state.formatInfo.hasTime && !state.formatInfo.hasDate;\n\n return (\n <div className={b(null, className)} {...groupProps}>\n {!isOnlyTime && (\n <div ref={setAnchor} className={b('popup-anchor')}>\n <Popup anchorElement={anchor} {...popupProps}>\n <div className={b('popup-content')}>\n {typeof props.children === 'function' ? (\n props.children({...calendarProps, value: state.value})\n ) : (\n <RangeCalendar {...calendarProps} value={state.value} />\n )}\n {state.formatInfo.hasTime && (\n <div className={b('time-field-wrapper')}>\n <RangeDateField {...timeInputProps} />\n </div>\n )}\n </div>\n </Popup>\n </div>\n )}\n <TextInput\n {...fieldProps}\n className={b('field')}\n endContent={\n <React.Fragment>\n {!isOnlyTime && (\n <Button {...calendarButtonProps}>\n <Icon data={CalendarIcon} />\n </Button>\n )}\n {isOnlyTime && (\n <StubButton size={calendarButtonProps.size} icon={ClockIcon} />\n )}\n </React.Fragment>\n }\n />\n <HiddenInput\n name={props.name}\n form={props.form}\n onReset={(v) => {\n state.dateFieldState.setDate(v);\n }}\n value={state.value}\n toStringValue={(v) => (v ? v.start.toISOString() : '')}\n disabled={state.disabled}\n />\n <HiddenInput\n name={props.name}\n form={props.form}\n value={state.value}\n toStringValue={(v) => (v ? v.end.toISOString() : '')}\n disabled={state.disabled}\n />\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"RangeDatePicker.js","sourceRoot":"../../../../src","sources":["components/RangeDatePicker/RangeDatePicker.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAC,QAAQ,IAAI,YAAY,EAAE,KAAK,IAAI,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAC,KAAK,EAAC,0BAAuB;AACrC,OAAO,EAAC,aAAa,EAAC,6BAAoB;AAC1C,OAAO,EAAC,kBAAkB,EAAC,+BAAsB;AAEjD,OAAO,EAAC,UAAU,EAAC,oCAAiC;AACpD,OAAO,EAAC,WAAW,EAAC,sCAAmC;AACvD,OAAO,EAAC,cAAc,EAAC,mCAA0B;AAGjD,OAAO,EAAC,uBAAuB,EAAC,2CAAwC;AAExE,+BAAgC;AAEhC,MAAM,CAAC,GAA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,EACd,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,EACrB,UAAU,EACN,MAAC,KAAK,CAAC,QAAQ,eACV,CAAC,UAAU,IAAI,CACZ,KAAC,MAAM,OAAK,mBAAmB,YAC3B,KAAC,IAAI,IAAC,IAAI,EAAE,YAAY,GAAI,GACvB,CACZ,EACA,UAAU,IAAI,CACX,KAAC,UAAU,IAAC,IAAI,EAAE,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,GAAI,CAClE,IACY,GAEvB,EACF,KAAC,WAAW,IACR,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACX,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBACrC,CAAC,EACD,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACtD,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAC1B,EACF,KAAC,WAAW,IACR,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,aAAa,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EACpD,QAAQ,EAAE,KAAK,CAAC,QAAQ,GAC1B,IACA,CACT,CAAC;AACN,CAAC","sourcesContent":["'use client';\n\nimport React from 'react';\n\nimport type {DateTime} from '@gravity-ui/date-utils';\nimport {Calendar as CalendarIcon, Clock as ClockIcon} from '@gravity-ui/icons';\nimport {Button, Icon, Popup, TextInput} from '@gravity-ui/uikit';\n\nimport {block} from '../../utils/cn';\nimport {RangeCalendar} from '../Calendar';\nimport {useDatePickerProps} from '../DatePicker';\nimport type {DatePickerProps} from '../DatePicker';\nimport {StubButton} from '../DatePicker/StubButton';\nimport {HiddenInput} from '../HiddenInput/HiddenInput';\nimport {RangeDateField} from '../RangeDateField';\nimport type {RangeValue} from '../types';\n\nimport {useRangeDatePickerState} from './hooks/useRangeDatePickerState';\n\nimport './RangeDatePicker.scss';\n\nconst b = block('range-date-picker');\n\nexport type RangeDatePickerProps = DatePickerProps<RangeValue<DateTime>>;\n\nexport function RangeDatePicker({className, ...props}: RangeDatePickerProps) {\n const [anchor, setAnchor] = React.useState<HTMLDivElement | null>(null);\n\n const state = useRangeDatePickerState(props);\n\n const {groupProps, fieldProps, calendarButtonProps, popupProps, calendarProps, timeInputProps} =\n useDatePickerProps(state, props);\n\n const isOnlyTime = state.formatInfo.hasTime && !state.formatInfo.hasDate;\n\n return (\n <div className={b(null, className)} {...groupProps}>\n {!isOnlyTime && (\n <div ref={setAnchor} className={b('popup-anchor')}>\n <Popup anchorElement={anchor} {...popupProps}>\n <div className={b('popup-content')}>\n {typeof props.children === 'function' ? (\n props.children({...calendarProps, value: state.value})\n ) : (\n <RangeCalendar {...calendarProps} value={state.value} />\n )}\n {state.formatInfo.hasTime && (\n <div className={b('time-field-wrapper')}>\n <RangeDateField {...timeInputProps} />\n </div>\n )}\n </div>\n </Popup>\n </div>\n )}\n <TextInput\n {...fieldProps}\n className={b('field')}\n endContent={\n <React.Fragment>\n {!isOnlyTime && (\n <Button {...calendarButtonProps}>\n <Icon data={CalendarIcon} />\n </Button>\n )}\n {isOnlyTime && (\n <StubButton size={calendarButtonProps.size} icon={ClockIcon} />\n )}\n </React.Fragment>\n }\n />\n <HiddenInput\n name={props.name}\n form={props.form}\n onReset={(v) => {\n state.dateFieldState.setValue(v);\n }}\n value={state.value}\n toStringValue={(v) => (v ? v.start.toISOString() : '')}\n disabled={state.disabled}\n />\n <HiddenInput\n name={props.name}\n form={props.form}\n value={state.value}\n toStringValue={(v) => (v ? v.end.toISOString() : '')}\n disabled={state.disabled}\n />\n </div>\n );\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { DateTime } from '@gravity-ui/date-utils';
2
+ import type { RangeDateFieldStateOptions } from "../../DateField/index.js";
2
3
  import type { DatePickerState } from "../../DatePicker/index.js";
3
- import type { RangeDateFieldStateOptions } from "../../RangeDateField/index.js";
4
4
  import type { RangeValue } from "../../types/index.js";
5
5
  export type RangeDatePickerState = DatePickerState<RangeValue<DateTime>>;
6
6
  export type RangeDatePickerStateOptions = RangeDateFieldStateOptions;
@@ -1,9 +1,8 @@
1
+ import { useRangeDateFieldState } from "../../DateField/index.js";
1
2
  import { adjustDateToFormat } from "../../DateField/utils.js";
2
3
  import { datePickerStateFactory } from "../../DatePicker/hooks/datePickerStateFactory.js";
3
4
  import { getDateTimeValue } from "../../DatePicker/utils/index.js";
4
- import { useRangeDateFieldState } from "../../RangeDateField/index.js";
5
- import { createPlaceholderRangeValue } from "../../RangeDateField/utils/index.js";
6
- import { mergeDateTime } from "../../utils/dates.js";
5
+ import { createPlaceholderRangeValue, mergeDateTime } from "../../utils/dates.js";
7
6
  export const useRangeDatePickerState = datePickerStateFactory({
8
7
  getPlaceholderTime,
9
8
  mergeDateTime: mergeRangeDateTime,
@@ -1 +1 @@
1
- {"version":3,"file":"useRangeDatePickerState.js","sourceRoot":"../../../../../src","sources":["components/RangeDatePicker/hooks/useRangeDatePickerState.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,kBAAkB,EAAC,iCAA8B;AAEzD,OAAO,EAAC,sBAAsB,EAAC,yDAAsD;AACrF,OAAO,EAAC,gBAAgB,EAAC,wCAA+B;AACxD,OAAO,EAAC,sBAAsB,EAAC,sCAA6B;AAE5D,OAAO,EAAC,2BAA2B,EAAC,4CAAmC;AAEvE,OAAO,EAAC,aAAa,EAAC,6BAA0B;AAMhD,MAAM,CAAC,MAAM,uBAAu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nimport {adjustDateToFormat} from '../../DateField/utils';\nimport type {DatePickerState} from '../../DatePicker';\nimport {datePickerStateFactory} from '../../DatePicker/hooks/datePickerStateFactory';\nimport {getDateTimeValue} from '../../DatePicker/utils';\nimport {useRangeDateFieldState} from '../../RangeDateField';\nimport type {RangeDateFieldStateOptions} from '../../RangeDateField';\nimport {createPlaceholderRangeValue} from '../../RangeDateField/utils';\nimport type {RangeValue} from '../../types';\nimport {mergeDateTime} from '../../utils/dates';\n\nexport type RangeDatePickerState = DatePickerState<RangeValue<DateTime>>;\n\nexport type RangeDatePickerStateOptions = RangeDateFieldStateOptions;\n\nexport const useRangeDatePickerState = datePickerStateFactory({\n getPlaceholderTime,\n mergeDateTime: mergeRangeDateTime,\n setTimezone,\n getDateTime: getDateTimeValue,\n useDateFieldState: useRangeDateFieldState,\n adjustDateToFormat: adjustRangeToFormat,\n});\n\nfunction getPlaceholderTime(\n placeholderValue: DateTime | undefined,\n timeZone?: string,\n): RangeValue<DateTime> {\n return createPlaceholderRangeValue({placeholderValue, timeZone});\n}\n\nfunction mergeRangeDateTime(\n date: RangeValue<DateTime>,\n time: RangeValue<DateTime>,\n): RangeValue<DateTime> {\n const start = mergeDateTime(date.start, time.start);\n const end = mergeDateTime(date.end, time.end);\n return {start, end};\n}\n\nfunction setTimezone(date: RangeValue<DateTime>, timeZone: string): RangeValue<DateTime> {\n const start = date.start.timeZone(timeZone);\n const end = date.end.timeZone(timeZone);\n return {start, end};\n}\n\nfunction adjustRangeToFormat(date: RangeValue<DateTime>, sectionsInfo: FormatInfo) {\n const start = adjustDateToFormat(date.start, sectionsInfo, 'startOf');\n const end = adjustDateToFormat(date.end, sectionsInfo, 'endOf');\n return {start, end};\n}\n"]}
1
+ {"version":3,"file":"useRangeDatePickerState.js","sourceRoot":"../../../../../src","sources":["components/RangeDatePicker/hooks/useRangeDatePickerState.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,sBAAsB,EAAC,iCAAwB;AAGvD,OAAO,EAAC,kB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AAC,IAAI,CAAC,GAAG,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;IAChE,OAAO,EAAC,KAAK,EAAE,GAAG,EAAC,CAAC;AACxB,CAAC","sourcesContent":["import type {DateTime} from '@gravity-ui/date-utils';\n\nimport {useRangeDateFieldState} from '../../DateField';\nimport type {RangeDateFieldStateOptions} from '../../DateField';\nimport type {FormatInfo} from '../../DateField/types';\nimport {adjustDateToFormat} from '../../DateField/utils';\nimport type {DatePickerState} from '../../DatePicker';\nimport {datePickerStateFactory} from '../../DatePicker/hooks/datePickerStateFactory';\nimport {getDateTimeValue} from '../../DatePicker/utils';\nimport type {RangeValue} from '../../types';\nimport {createPlaceholderRangeValue, mergeDateTime} from '../../utils/dates';\n\nexport type RangeDatePickerState = DatePickerState<RangeValue<DateTime>>;\n\nexport type RangeDatePickerStateOptions = RangeDateFieldStateOptions;\n\nexport const useRangeDatePickerState = datePickerStateFactory({\n getPlaceholderTime,\n mergeDateTime: mergeRangeDateTime,\n setTimezone,\n getDateTime: getDateTimeValue,\n useDateFieldState: useRangeDateFieldState,\n adjustDateToFormat: adjustRangeToFormat,\n});\n\nfunction getPlaceholderTime(\n placeholderValue: DateTime | undefined,\n timeZone?: string,\n): RangeValue<DateTime> {\n return createPlaceholderRangeValue({placeholderValue, timeZone});\n}\n\nfunction mergeRangeDateTime(\n date: RangeValue<DateTime>,\n time: RangeValue<DateTime>,\n): RangeValue<DateTime> {\n const start = mergeDateTime(date.start, time.start);\n const end = mergeDateTime(date.end, time.end);\n return {start, end};\n}\n\nfunction setTimezone(date: RangeValue<DateTime>, timeZone: string): RangeValue<DateTime> {\n const start = date.start.timeZone(timeZone);\n const end = date.end.timeZone(timeZone);\n return {start, end};\n}\n\nfunction adjustRangeToFormat(date: RangeValue<DateTime>, sectionsInfo: FormatInfo) {\n const start = adjustDateToFormat(date.start, sectionsInfo, 'startOf');\n const end = adjustDateToFormat(date.end, sectionsInfo, 'endOf');\n return {start, end};\n}\n"]}
@@ -21,4 +21,4 @@ export interface RangeDateSelectionProps extends RangeDateSelectionOptions, DomP
21
21
  dimensions: ViewportDimensions;
22
22
  }) => React.ReactNode;
23
23
  }
24
- export declare function RangeDateSelection(props: RangeDateSelectionProps): import("react/jsx-runtime").JSX.Element;
24
+ export declare function RangeDateSelection(props: RangeDateSelectionProps): React.JSX.Element;
@@ -12,7 +12,6 @@ import { i18n } from "./i18n/index.js";
12
12
  import "./RangeDateSelection.css";
13
13
  const b = block('range-date-selection');
14
14
  export function RangeDateSelection(props) {
15
- var _a, _b;
16
15
  const state = useRangeDateSelectionState(props);
17
16
  const [isDraggingRuler, setDraggingRuler] = React.useState(false);
18
17
  const handleRulerMoveStart = () => {
@@ -29,10 +28,10 @@ export function RangeDateSelection(props) {
29
28
  state.endDragging();
30
29
  };
31
30
  let id = React.useId();
32
- id = (_a = props.id) !== null && _a !== void 0 ? _a : id;
31
+ id = props.id ?? id;
33
32
  const { t } = i18n.useTranslation();
34
- return (_jsxs("div", Object.assign({}, filterDOMProps(props, { labelable: true }), { id: id, className: b(null, props.className), style: props.style, dir: "ltr" // TODO: RTL support
35
- , children: [_jsx(DateTimeRuler, Object.assign({ className: b('ruler', { dragging: isDraggingRuler }) }, state.viewportInterval, { onMoveStart: handleRulerMoveStart, onMove: props.draggableRuler ? handleRulerMove : undefined, onMoveEnd: handleRulerMoveEnd, dragDisabled: state.isDragging, displayNow: props.displayNow, minValue: props.minValue, maxValue: props.maxValue, formatTime: props.formatTime, timeZone: state.timeZone, renderAdditionalRulerContent: props.renderAdditionalRulerContent, children: _jsx(SelectionControl, { className: b('selection'), state: state, "aria-labelledby": id }) })), props.hasScaleButtons ? (_jsxs("div", { className: b('buttons', { position: (_b = props.scaleButtonsPosition) !== null && _b !== void 0 ? _b : 'start' }), children: [_jsx(Button, { view: "flat-secondary", size: "xs", onClick: () => {
33
+ return (_jsxs("div", { ...filterDOMProps(props, { labelable: true }), id: id, className: b(null, props.className), style: props.style, dir: "ltr" // TODO: RTL support
34
+ , children: [_jsx(DateTimeRuler, { className: b('ruler', { dragging: isDraggingRuler }), ...state.viewportInterval, onMoveStart: handleRulerMoveStart, onMove: props.draggableRuler ? handleRulerMove : undefined, onMoveEnd: handleRulerMoveEnd, dragDisabled: state.isDragging, displayNow: props.displayNow, minValue: props.minValue, maxValue: props.maxValue, formatTime: props.formatTime, timeZone: state.timeZone, renderAdditionalRulerContent: props.renderAdditionalRulerContent, children: _jsx(SelectionControl, { className: b('selection'), state: state, "aria-labelledby": id }) }), props.hasScaleButtons ? (_jsxs("div", { className: b('buttons', { position: props.scaleButtonsPosition ?? 'start' }), children: [_jsx(Button, { view: "flat-secondary", size: "xs", onClick: () => {
36
35
  state.startDragging();
37
36
  state.scale(0.5);
38
37
  state.endDragging();
@@ -40,6 +39,6 @@ export function RangeDateSelection(props) {
40
39
  state.startDragging();
41
40
  state.scale(1.5);
42
41
  state.endDragging();
43
- }, "aria-label": t('Increase range'), children: _jsx(Icon, { data: Plus }) })] })) : null] })));
42
+ }, "aria-label": t('Increase range'), children: _jsx(Icon, { data: Plus }) })] })) : null] }));
44
43
  }
45
44
  //# sourceMappingURL=RangeDateSelection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RangeDateSelection.js","sourceRoot":"../../../../src","sources":["components/RangeDateSelection/RangeDateSelection.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAC,KAAK,EAAC,0BAAuB;AAErC,OAAO,EAAC,cAAc,EAAC,mCAAgC;AAEvD,OAAO,EAAC,aAAa,EAAC,oCAAiC;AAEvD,OAAO,EAAC,gBAAgB,EAAC,0DAAuD;AAChF,OAAO,EAAC,0BAA0B,EAAC,8CAA2C;AAE9E,OAAO,EAAC,IAAI,E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,GAAI,GAChB,EACT,KAAC,MAAM,IACH,IAAI,EAAC,gBAAgB,EACrB,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,GAAG,EAAE;4BACV,KAAK,CAAC,aAAa,EAAE,CAAC;4BACtB,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;4BACjB,KAAK,CAAC,WAAW,EAAE,CAAC;wBACxB,CAAC,gBACW,CAAC,CAAC,gBAAgB,CAAC,YAE/B,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,GAAI,GACf,IACP,CACT,CAAC,CAAC,CAAC,IAAI,KACN,CACT,CAAC;AACN,CAAC","sourcesContent":["'use client';\n\nimport React from 'react';\n\nimport type {DateTime} from '@gravity-ui/date-utils';\nimport {Minus, Plus} from '@gravity-ui/icons';\nimport {Button, Icon} from '@gravity-ui/uikit';\n\nimport {block} from '../../utils/cn';\nimport type {AccessibilityProps, DomProps, StyleProps} from '../types';\nimport {filterDOMProps} from '../utils/filterDOMProps';\n\nimport {DateTimeRuler} from './components/Ruler/Ruler';\nimport type {ViewportDimensions, ViewportInterval} from './components/Ruler/Ruler';\nimport {SelectionControl} from './components/SelectionControl/SelectionControl';\nimport {useRangeDateSelectionState} from './hooks/useRangeDateSelectionState';\nimport type {RangeDateSelectionOptions} from './hooks/useRangeDateSelectionState';\nimport {i18n} from './i18n';\n\nimport './RangeDateSelection.scss';\n\nconst b = block('range-date-selection');\n\nexport interface RangeDateSelectionProps\n extends RangeDateSelectionOptions, DomProps, StyleProps, AccessibilityProps {\n /** Formats time ticks */\n formatTime?: (time: DateTime) => string;\n /** Displays now line */\n displayNow?: boolean;\n /** Enables dragging ruler */\n draggableRuler?: boolean;\n /** Displays buttons to scale selection */\n hasScaleButtons?: boolean;\n /** Position of scale buttons */\n scaleButtonsPosition?: 'start' | 'end';\n /** Renders additional svg content in the ruler */\n renderAdditionalRulerContent?: (props: {\n interval: ViewportInterval;\n dimensions: ViewportDimensions;\n }) => React.ReactNode;\n}\n\nexport function RangeDateSelection(props: RangeDateSelectionProps) {\n const state = useRangeDateSelectionState(props);\n\n const [isDraggingRuler, setDraggingRuler] = React.useState(false);\n\n const handleRulerMoveStart = () => {\n state.setDraggingValue(state.value);\n setDraggingRuler(true);\n };\n const handleRulerMove = (d: number) => {\n const intervalWidth = state.viewportInterval.end.diff(state.viewportInterval.start);\n const delta = -Math.floor((d * intervalWidth) / 100);\n state.move(delta);\n };\n const handleRulerMoveEnd = () => {\n setDraggingRuler(false);\n state.endDragging();\n };\n\n let id = React.useId();\n id = props.id ?? id;\n\n const {t} = i18n.useTranslation();\n\n return (\n <div\n {...filterDOMProps(props, {labelable: true})}\n id={id}\n className={b(null, props.className)}\n style={props.style}\n dir=\"ltr\" // TODO: RTL support\n >\n <DateTimeRuler\n className={b('ruler', {dragging: isDraggingRuler})}\n {...state.viewportInterval}\n onMoveStart={handleRulerMoveStart}\n onMove={props.draggableRuler ? handleRulerMove : undefined}\n onMoveEnd={handleRulerMoveEnd}\n dragDisabled={state.isDragging}\n displayNow={props.displayNow}\n minValue={props.minValue}\n maxValue={props.maxValue}\n formatTime={props.formatTime}\n timeZone={state.timeZone}\n renderAdditionalRulerContent={props.renderAdditionalRulerContent}\n >\n <SelectionControl className={b('selection')} state={state} aria-labelledby={id} />\n </DateTimeRuler>\n {props.hasScaleButtons ? (\n <div className={b('buttons', {position: props.scaleButtonsPosition ?? 'start'})}>\n <Button\n view=\"flat-secondary\"\n size=\"xs\"\n onClick={() => {\n state.startDragging();\n state.scale(0.5);\n state.endDragging();\n }}\n aria-label={t('Decrease range')}\n >\n <Icon data={Minus} />\n </Button>\n <Button\n view=\"flat-secondary\"\n size=\"xs\"\n onClick={() => {\n state.startDragging();\n state.scale(1.5);\n state.endDragging();\n }}\n aria-label={t('Increase range')}\n >\n <Icon data={Plus} />\n </Button>\n </div>\n ) : null}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"RangeDateSelection.js","sourceRoot":"../../../../src","sources":["components/RangeDateSelection/RangeDateSelection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eAAK,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,EAAC,QAAQ,EAAE,KAAK,CAAC,oBAAoB,IAAI,OAAO,EAAC,CAAC,aAC3E,KAAC,MAAM,IACH,IAAI,EAAC,gBAAgB,EACrB,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,GAAG,EAAE;4BACV,KAAK,CAAC,aAAa,EAAE,CAAC;4BACtB,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;4BACjB,KAAK,CAAC,WAAW,EAAE,CAAC;wBACxB,CAAC,gBACW,CAAC,CAAC,gBAAgB,CAAC,YAE/B,KAAC,IAAI,IAAC,IAAI,EAAE,KAAK,GAAI,GAChB,EACT,KAAC,MAAM,IACH,IAAI,EAAC,gBAAgB,EACrB,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,GAAG,EAAE;4BACV,KAAK,CAAC,aAAa,EAAE,CAAC;4BACtB,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;4BACjB,KAAK,CAAC,WAAW,EAAE,CAAC;wBACxB,CAAC,gBACW,CAAC,CAAC,gBAAgB,CAAC,YAE/B,KAAC,IAAI,IAAC,IAAI,EAAE,IAAI,GAAI,GACf,IACP,CACT,CAAC,CAAC,CAAC,IAAI,IACN,CACT,CAAC;AACN,CAAC","sourcesContent":["'use client';\n\nimport React from 'react';\n\nimport type {DateTime} from '@gravity-ui/date-utils';\nimport {Minus, Plus} from '@gravity-ui/icons';\nimport {Button, Icon} from '@gravity-ui/uikit';\n\nimport {block} from '../../utils/cn';\nimport type {AccessibilityProps, DomProps, StyleProps} from '../types';\nimport {filterDOMProps} from '../utils/filterDOMProps';\n\nimport {DateTimeRuler} from './components/Ruler/Ruler';\nimport type {ViewportDimensions, ViewportInterval} from './components/Ruler/Ruler';\nimport {SelectionControl} from './components/SelectionControl/SelectionControl';\nimport {useRangeDateSelectionState} from './hooks/useRangeDateSelectionState';\nimport type {RangeDateSelectionOptions} from './hooks/useRangeDateSelectionState';\nimport {i18n} from './i18n';\n\nimport './RangeDateSelection.scss';\n\nconst b = block('range-date-selection');\n\nexport interface RangeDateSelectionProps\n extends RangeDateSelectionOptions, DomProps, StyleProps, AccessibilityProps {\n /** Formats time ticks */\n formatTime?: (time: DateTime) => string;\n /** Displays now line */\n displayNow?: boolean;\n /** Enables dragging ruler */\n draggableRuler?: boolean;\n /** Displays buttons to scale selection */\n hasScaleButtons?: boolean;\n /** Position of scale buttons */\n scaleButtonsPosition?: 'start' | 'end';\n /** Renders additional svg content in the ruler */\n renderAdditionalRulerContent?: (props: {\n interval: ViewportInterval;\n dimensions: ViewportDimensions;\n }) => React.ReactNode;\n}\n\nexport function RangeDateSelection(props: RangeDateSelectionProps) {\n const state = useRangeDateSelectionState(props);\n\n const [isDraggingRuler, setDraggingRuler] = React.useState(false);\n\n const handleRulerMoveStart = () => {\n state.setDraggingValue(state.value);\n setDraggingRuler(true);\n };\n const handleRulerMove = (d: number) => {\n const intervalWidth = state.viewportInterval.end.diff(state.viewportInterval.start);\n const delta = -Math.floor((d * intervalWidth) / 100);\n state.move(delta);\n };\n const handleRulerMoveEnd = () => {\n setDraggingRuler(false);\n state.endDragging();\n };\n\n let id = React.useId();\n id = props.id ?? id;\n\n const {t} = i18n.useTranslation();\n\n return (\n <div\n {...filterDOMProps(props, {labelable: true})}\n id={id}\n className={b(null, props.className)}\n style={props.style}\n dir=\"ltr\" // TODO: RTL support\n >\n <DateTimeRuler\n className={b('ruler', {dragging: isDraggingRuler})}\n {...state.viewportInterval}\n onMoveStart={handleRulerMoveStart}\n onMove={props.draggableRuler ? handleRulerMove : undefined}\n onMoveEnd={handleRulerMoveEnd}\n dragDisabled={state.isDragging}\n displayNow={props.displayNow}\n minValue={props.minValue}\n maxValue={props.maxValue}\n formatTime={props.formatTime}\n timeZone={state.timeZone}\n renderAdditionalRulerContent={props.renderAdditionalRulerContent}\n >\n <SelectionControl className={b('selection')} state={state} aria-labelledby={id} />\n </DateTimeRuler>\n {props.hasScaleButtons ? (\n <div className={b('buttons', {position: props.scaleButtonsPosition ?? 'start'})}>\n <Button\n view=\"flat-secondary\"\n size=\"xs\"\n onClick={() => {\n state.startDragging();\n state.scale(0.5);\n state.endDragging();\n }}\n aria-label={t('Decrease range')}\n >\n <Icon data={Minus} />\n </Button>\n <Button\n view=\"flat-secondary\"\n size=\"xs\"\n onClick={() => {\n state.startDragging();\n state.scale(1.5);\n state.endDragging();\n }}\n aria-label={t('Increase range')}\n >\n <Icon data={Plus} />\n </Button>\n </div>\n ) : null}\n </div>\n );\n}\n"]}
@@ -1,2 +1,3 @@
1
+ import React from 'react';
1
2
  import "./NowLine.css";
2
- export declare function NowLine(): import("react/jsx-runtime").JSX.Element | null;
3
+ export declare function NowLine(): React.JSX.Element | null;
@@ -26,7 +26,7 @@ export interface ViewportDimensions {
26
26
  height: number;
27
27
  }
28
28
  export type ViewportInterval = RangeValue<DateTime>;
29
- export declare function DateTimeRuler({ className, children, start, end, minValue, maxValue, onMove, onMoveStart, onMoveEnd, displayNow, formatTime, timeZone, dragDisabled, renderAdditionalRulerContent, }: RulerProps): import("react/jsx-runtime").JSX.Element;
29
+ export declare function DateTimeRuler({ className, children, start, end, minValue, maxValue, onMove, onMoveStart, onMoveEnd, displayNow, formatTime, timeZone, dragDisabled, renderAdditionalRulerContent, }: RulerProps): React.JSX.Element;
30
30
  export declare function useViewportDimensions(): ViewportDimensions;
31
31
  export declare function useViewportInterval(): ViewportInterval;
32
32
  export {};